Create an event parameter allDay = true (end = null). And then using the updateEvent method changing the end time of the event. All good, but the end time is saved with less 12 hours (time zone). How can I fix this?
With the start time of the event this doesn't happen.
Thanks for the link. Now I will consider.
With the problem figured out. In the properties fullcalendar installed " 'timezone':'local'". Somehow a method of "updateEvent" transforms the end time (the start time does not change) events to UTC time.
So now clearly indicate the start and end times of the event:
moment.parseZone("2017-10-05T17:00").utc().format()
or
moment.parseZone("2017-10-05T17:00").local().format()
Related
I am setting local notifications to fire at specific time in Xamarin.Android application. It all works but the set time seems to be little off, set time comes from user input (with minute precision). When setting notifications further in the future (days later) the notification fired at the next minute than it should have.
Below is my current code to calculate time. calendarEvent.StartTime is a DateTime property.
TimeSpan span = calendarEvent.StartTime - DateTime.Now;
manager.Set(AlarmType.ElapsedRealtime,(long)(SystemClock.ElapsedRealtime() + span.TotalMilliseconds),pendingIntent);
I would like to know how to accurately calculate the time so that notifications would fire at the start of the minute they are supposed to. In the current code they fire in the middle of the minute or later.
If you really need precision try to use the SetExact() method of the alarm manager class.
TimeSpan span = calendarEvent.StartTime - DateTime.Now;
manager.SetExact(AlarmType.ElapsedRealtime,(long)(SystemClock.ElapsedRealtime() + span.TotalMilliseconds),pendingIntent);
And I don't know if it is relevant, but if you are using events for a calendar maybe you should use RTC, since AlarmType.RTC is based on the clock, whereas AlarmType.ElapsedRealTime is based on the time passed since the device was turned on.
I am trying to use Fullcalendar in AngularJS.
I somehow implemented the calendar and it works (saves data to the SQL).
However, if I click on the day in the calendar, the modal pops up and the start date shows 00:00:00 in time aspect.
My questions is how can you set the time for the hour of current time?
If it is 9AM currently, then, how can the time in the start initialize the time as 09:00:00 ?
This is what I have for the coding.
select: function(start, end) {
$('#ModalAdd #start').val(moment(start).format('YYYY-MM-DD HH:mm:ss'));
$('#ModalAdd #end').val(moment(end).format('YYYY-MM-DD HH:mm:ss'));
$('#ModalAdd').modal('show');
}
I have a feeling that it would be nice to somehow modify the code below and place it within the above code, but I am stuck on where to put it.
var time = new Time();
var h = date.getHour();
I don't know it the Time() even works (it was Date() from other source).
Please can anyone help me on initializing the hour in the Fullcalendar based on the current hour? I am looking for any advice or even a hint to solve this matter.
Thank you in advance!
You can use momentJS to add the current (local) system time to the selected day:
select: function(start, end) {
var today = moment();
start.set({ hours: today.hours(), minute: today.minutes() });
$('#ModalAdd #start').val(start.format('YYYY-MM-DD HH:mm:ss'));
$('#ModalAdd #end').val(end.format('YYYY-MM-DD HH:mm:ss'));
$('#ModalAdd').modal('show');
}
See https://momentjs.com/docs/#/get-set/set/
Also it's worth mentioning that start and end are already moments, so you don't need to wrap them in the moment constructor again as you were doing before.
Another thing to consider if you do this, is whether your calendar has other views available, in particular the agenda-style views, on which selections can be made which would trigger the modal? If so, then you need to ensure that the time-manipulation code above only runs when the view is "month", because the agenda view will, by default, already use the time that the user actually chose on the calendar.
I'm working on a WebAPI that schedules Events and appointments.In order to do that, I am using the chroniton.NetCore package. I am able to set the schedule using a cron expression or other functions, but is there any way to set a stop date or termination date for the schedule?
var schedule = new EveryXTimeSchedule(TimeSpan.FromSeconds(5));
var scheduledJob = singularity.ScheduleParameterizedJob(
schedule, job, "Hello World", true); //starts immediately
I wish to stop this job on the next day at midnight without using Task.Delay(since the api is stateless)
Thank you.
Current version of chroniton.NETCore does not support such behaviour out of the box. You can implement your own logic based on fact, that you have information about time range.
ScheduleParameterizedJob() returns an IScheduledJob which can be used to cancel the job if needed. You can create additional RunOnceSchedule to close your first job on the next day at midnight using
Singularity.Instance.StopScheduledJob(IScheduledJob job);
you can inherit from EveryXTimeSchedule and override NextScheduledTime method to return Chroniton.Constants.Never if 'next scheduled time' is >= the next day at midnight;
Best way to create a Midnight DateTime in C# :
DateTime nextDayAtMidnight = DateTime.Today.AddDays(1)
According to rfc5545:
The "DTEND" property for a "VEVENT" calendar component specifies the
non-inclusive end of the event.
Also in fullcalendar documentation for end property of event object written the same:
The exclusive date/time an event ends. Optional.
A Moment-ish input, like an ISO8601 string. Throughout the API this
will become a real Moment object.
It is the moment immediately after the event has ended. For example,
if the last full day of an event is Thursday, the exclusive end of the
event will be 00:00:00 on Friday!
With allday event everything is clear, if event from 24/03/2016 to 25/03/2016 I need to write according to described above from 24/03/2016 to 25/03/2016.
Now, my question is how I supposed to write in DTEND when event from 24/03/2016 10:00 to 24/03/2016 10:30, i.e. 30 min event? Do I need to write
24/03/2016 10:30:01 to create non-inclusive end date?
Your understanding of the RFC5545 is correct, it is your math which is failing you:
Say you want to have a 1 min event you would have
DTSTART:20160324T173000Z
DTEND:20160324T173100Z
Similarly for a 30 min event you would have:
DTSTART:20160324T173000Z
DTEND:20160324T180000Z
guys!
I'm developing an online auction with time limit.
The ending time period is only for one opened auction.
After logging into the site I show the time left for the open auction. The time is calculated in this way:
EndDateTime = Date and Time of end of auction;
DateTime.Now() = current Date and Time
timeLeft= (EndDateTime - DateTime.Now()).Seconds().
In javascript, I update the time left by:
timeLeft=timeLeft-1
The problem is that when I login from different browsers at the same time the browsers show a different count down.
Help me, please!
I guess there will always be differences of a few seconds because of the server processing time and the time needed to download the page.
The best way would be to actually send the end time to the browser and calculate the time remaining in javascript. That way the times should be the same (on the same machine of course).
Roman,
I had a little look at eBay (they know a thing or two about this stuff :)) and noticed that once the item is inside the last 90 seconds, a GET request gets fired every 2 seconds to update the variables in the javascript via a json response. you can look at this inside firebug/fiddler to see what it does.
here is an example of the json it pulls down:
{
"ViewItemLiteResponse":{
"Item":[
{
"IsRefreshPage":false,
"ViewerItemRelation":"NONE",
"EndDate":{
"Time":"12:38:48 BST",
"Date":"01 Oct, 2010"
},
"LastModifiedDate":1285932821000,
"CurrentPrice":{
"CleanAmount":"23.00",
"Amount":23,
"MoneyStandard":"£23.00",
"CurrencyCode":"GBP"
},
"IsEnded":false,
"AccessedDate":1285933031000,
"BidCount":4,
"MinimumToBid":{
"CleanAmount":"24.00",
"Amount":24,
"MoneyStandard":"£24.00",
"CurrencyCode":"GBP"
},
"TimeLeft":{
"SecondsLeft":37,
"MinutesLeft":1,
"HoursLeft":0,
"DaysLeft":0
},
"Id":160485015499,
"IsFinalized":false,
"ViewerItemRelationId":0,
"IsAutoRefreshEnabled":true
}
]
}
}
You could do something similar inside your code.
[edit] - on further looking at the eBay code, altho it only runs the intensive GET requests in the last 90 seconds, the same json as above is added when the page is initially loaded as well. Then, at 3 mins or so, the GET request is run every 10 seconds. therefore i assume the same javascript is run against that structure whether it be >90 seconds or not.
This may be a problem with javascript loading at different speeds,
or the setInterval will trigger at slightly different times depending on the loop
i would look into those two