I trying to implementing scheduler in web application.
I am using full calendar for scheduler ,I am showing all scheduled event on days and I have set eventLimit on day as 4.
Now I have question how can i show plus more event on other day have not any events.
Eg:
Event Start Date 13 Jan 2017 and EndDate 21 Jan 2017.
Event Start Date 16 Jan 2017 :Have 4 events. End date :18 Jan 2017.
[Note :2nd displaying 4 events with title on 16 Jan to 18 Jan]
Now 1st event start 13 Jan 2017 to 21 Jan 2017 When event goes 16 Jan 2017 then event limit do automatically plus more 1 .same continue on 17 Jan to 21 Jan 2017.
Now Question is 19 ,20 ,21 Jan 2017 have not any events then event should be displayed with title. but this kind of not happens it displaying plus more 1 on 19 ,20 ,21 Jan 2017.]
How can we show plus more event with title on the day have any events ?
thanks in Advance.
Related
I'm playing with the GSuite services Calendar (https://developers.google.com/apps-script/reference/calendar/calendar) to retrieve events from my Google Calendar.
I'm french (this is important for timezone).
I noticed something strange :
On my Google Calendar, I create an event, for exemple: 2017-11-17 from 10am to 18pm (notice the year 2017).
With Javascript and calendar service API, I retrieve this event and print start and end date:
function runMe() {
var calendar = CalendarApp.getDefaultCalendar();
Logger.log('My default calendar is set to the time zone "%s".', calendar.getTimeZone());
const events = calendar.getEvents(new Date(2017, 10, 17), new Date(2017, 10, 18));
events.forEach(event => Logger.log (event.getStartTime()+" - "+event.getEndTime()));
}
// logs:
// My default calendar is set to the time zone "Europe/Paris".
// Fri Nov 17 2017 09:00:00 GMT+0100 (heure normale d’Europe centrale) - Fri Nov 17 2017 17:00:00 GMT+0100 (heure normale d’Europe centrale)
The date is not correct, I expect Fri Nov 17 2017 10:00:00 GMT+0100 (heure normale d’Europe centrale) - Fri Nov 17 2017 18:00:00 GMT+0100 (heure normale d’Europe centrale)
Now, on my Google Calendar, I create another event at the same date, but on year 2018.
With Javascript and calendar service API, I retrieve this event and print start and end date:
...
function runMe() {
var calendar = CalendarApp.getDefaultCalendar();
Logger.log('My default calendar is set to the time zone "%s".', calendar.getTimeZone());
const events = calendar.getEvents(new Date(2018, 10, 17), new Date(2018, 10, 18));
events.forEach(event => Logger.log (event.getStartTime()+" - "+event.getEndTime()));
}
// logs:
// My default calendar is set to the time zone "Europe/Paris".
// Sat Nov 17 2018 10:00:00 GMT+0100 (heure normale d’Europe centrale) - Sat Nov 17 2018 18:00:00 GMT+0100 (heure normale d’Europe centrale)
The date is correct.
What happened?
This appears to be a bug!
I've done a lot of testing regarding this and it appears that the Calendar API returns the time incorrectly between the period between when DST ended in 2017, and when it began again in 2018.
I have taken the liberty of reporting this on Google's Issue Tracker for you, detailing the behaviour:
Calendar API returns incorrect event start and end time for events between end of DST 2017 and beginning of DST 2018
You can hit the ☆ next to the issue number in the top left on the page which lets Google know more people are encountering this and so it is more likely to be seen to faster.
The issue is specific to moment.year()
I am trying to get the beginning date of the next week based on the current date. It works well except for the last month of the year. The example should explain.
new Date(moment(1577379939000).year(2020).week(1).weekday(0).format('MM/DD/YYYY'))
Sun Dec 29 2019 00:00:00 GMT-0500 (Eastern Standard Time)
This gives me Sun Dec 29 2019 00:00:00 GMT-0500 (Eastern Standard Time) 29th dec 2019 as begining of the next week(sunday)
This is correct
1577379939000 is 26th of December 2019(Thursday).
However, if the input is 1577466306000 which is 27th of December 2019(Friday)
it gives me 2020 December date, not 2019
new Date(moment(1577466306000).year(2020).week(1).weekday(0).format('MM/DD/YYYY'))
Sun Dec 27 2020 00:00:00 GMT-0500 (Eastern Standard Time)
If it is moment.js error. is there any workaround?
Try to use weekYear instead of year
I think this is working as intended. After you use .year(2020) you're changing the dates to December 2020. This is the calendary for that month:
Su Mo Tu We Th Fr Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
In the United States, moment.js defines weeks to start on Sunday, and week 1 is the week containing January 1. So the week beginning with December 27 is actually week 1 of 2021.
That means that when you call .week(1), it doesn't change anything for December 27, and returns a date in December 2020 when you call .weekday(0).
But December 26 is in week 26 of 2020, so calling .week(1) changes the date to Saturday in week 1 of 2020, which is January 4. Then calling .weekday(0) returns the Sunday before that, which is December 29, 2019.
As mentioned in a comment, the way to get the first day of the next week after a given date, just use .weekday(7).
new Date(moment(1577466306000).weekday(7))
I'm not sure why you're specifying a particular year or week number.
My first post here so go easy.
I am trying to create a Google script on a spreadsheet which uses a form to get information about events which are then added to a calendar. The script creates a createEventSeries for selected weekdays between two dates. It also checks how many events there are on valid days for every hour between those the events times.
I am having issues with one line of code which should add a day on each loop:
var floatdate = new Date(floatdate.setDate(starttime.getDate()+d)) ;
Where floatdate is the date which it is currently being checked, d is in a number days after starttime.
my issues is that when d = 4 the day and month changes, see this example:
var floatdate = new Date(floatdate.setDate(starttime.getDate()+0))
Logger.log(floatdate)
var floatdate = new Date(floatdate.setDate(starttime.getDate()+1))
Logger.log(floatdate)
var floatdate = new Date(floatdate.setDate(starttime.getDate()+2))
Logger.log(floatdate)
var floatdate = new Date(floatdate.setDate(starttime.getDate()+3))
Logger.log(floatdate)
var floatdate = new Date(floatdate.setDate(starttime.getDate()+4))
Logger.log(floatdate)
Gives the following:
[17-06-02 05:06:47:933 PDT] Mon May 29 08:00:00 GMT+08:00 2017
[17-06-02 05:06:47:933 PDT] Tue May 30 08:00:00 GMT+08:00 2017
[17-06-02 05:06:47:934 PDT] Wed May 31 08:00:00 GMT+08:00 2017
[17-06-02 05:06:47:935 PDT] Thu Jun 01 08:00:00 GMT+08:00 2017
[17-06-02 05:06:47:935 PDT] Mon Jul 03 08:00:00 GMT+08:00 2017
Please help!
I had the same issue with nonsence date iteration in log view:
[20-06-25 20:42:05:887 CEST] Month 2020-06-26T18:42:05+0000
[20-06-25 20:42:05:889 CEST] Month 2020-06-27T18:42:05+0000
[20-06-25 20:42:05:893 CEST] Month 2020-06-29T18:42:05+0000
[20-06-25 20:42:05:900 CEST] Month 2020-07-03T18:42:05+0000
At the end, I found it is just some weird sample and whole output can be found in
"Apps Script Dashboard" (View -> Logs -> link Apps Script Dashboard). This whole output is correct with all dates.
Another option how to get to whole Log outputs is https://script.google.com/home/my -> select your project -> project details menu -> select Executions -> open your execution and observe results.
Say I have some data that can span anywhere from 28-31 days. I don't know how many days the data spans, but I know the beginning and ending date, and I create a d3 time scale using the two dates as the domain.
If I specify that I want 1 tick per day, is there a way to get the axis to return how many ticks it's going to create?
Or put another way, is there another method to determine in Javascript how many days are in a range of two dates?
Check out d3.time.day. It's what d3.time.scale uses to do "time math". It's kinda hard to figure how to use, but it looks like there's a method that'll return every day between two dates (represented as a Date object at midnight of each day).
For example, here are the days that elapsed between Jan 24th and now:
d3.time.day.range(new Date(2015,0,24), new Date())
/* returns
[
Sat Jan 24 2015 00:00:00 GMT-0500 (EST),
Sun Jan 25 2015 00:00:00 GMT-0500 (EST),
Mon Jan 26 2015 00:00:00 GMT-0500 (EST),
...
Tue Feb 03 2015 00:00:00 GMT-0500 (EST),
Wed Feb 04 2015 00:00:00 GMT-0500 (EST)
]
*/
So then you can take the .length of that array and there you have it... There are also equivalent functions for counting hours, weeks, months etc.
Maybe there's also a way to get just the number of days — without producing the actual array of Dates — but I couldn't find one.
In the library D3. I find the set of functions to handle dates a bit inconsistent. For example, doing the following 4 steps in a console of a page loading D3 I get:
> start = new Date(2010, 11, 30)
Thu Dec 30 2010 00:00:00 GMT+0000 (GMT Standard Time)
> end = new Date(2011, 0, 2)
Sun Jan 02 2011 00:00:00 GMT+0000 (GMT Standard Time)
> d3.time.months(start, end, 1)
[Sat Jan 01 2011 00:00:00 GMT+0000 (GMT Standard Time)]
> d3.time.days(start, end, 1)
[Thu Dec 30 2010 00:00:00 GMT+0000 (GMT Standard Time), Fri Dec 31 2010 00:00:00 GMT+0000 (GMT Standard Time), Sat Jan 01 2011 00:00:00 GMT+0000 (GMT Standard Time)]
the above indicates that day.range starts from the first item and ends just before the second, while month.range seems to do the opposite.
In the documentation it's stated:
# d3.time.months(start, stop[, step])
Alias for d3.time.month.range. Returns the month boundaries (e.g., January 01)
after or equal to start and before stop. If step is specified, then every step'th
month will be returned, based on the month of the year. For example, a step of 3
will return January, April, July, etc.
after or equal to start and before stop is also mentioned for time.days but the result appears to be different. Also, when these functions return after and when equal to the start? What makes the difference?
NB: my wish would be having these functions returning arrays of days, months, years including both start and end parameters.
As clearly explained in here the behaviour is in fact consistent. Both day.range and month.range aim to return each daily and monthly boundaries between the start and end parameter.