Newbies Malcolm McLeary Posted September 10, 2020 Newbies Share Posted September 10, 2020 Hi Guys, Is there a "timezone" setting in this Year Calendar example as it seems to pass incorrect dates back to FileMaker. Enclosed is a screenshot of what happens when I click on the sample event on January 2, 2019. Its not just the events ... every click action seems to return the date before the clicked date. Interestingly the examples on the developers site appear to work fine. I would have thought a Year Calendar of dates wouldn't need to take "time" into account as its not being displayed but if I adjust the function which returns clicks to FileMaker to not format the "timestamp" it clearly contains time and a timezone so clicking on "today" gives me "yesterday" at 2pm. Anyone know why date selection is including time and timezone? Cheers, Malcolm Link to comment Share on other sites More sharing options...
Newbies Malcolm McLeary Posted September 11, 2020 Author Newbies Share Posted September 11, 2020 (edited) I believe the problem is how the retuned date is being formatted in the function which does the callback to FileMaker. In that function "toISOString" is used to format the timestamp in an ISO format and then the time component is simply truncated. The problem here is that "toISOString also converts the timestamp to be UTC time so truncating the time component is only valid if your timezone happens to be UTC. As I'm +10 this operation changes the date component to "yesterday" most of the time. There is probably a window of time when this function does work but in practice it doesn't. I now have it working by using simply "toDateString" and then parsing out the Year, Month and Day and constructing the string. function formatDate(date) { var d = new Date(date); var month = '' + (d.getMonth() + 1); var day = '' + d.getDate(); var year = d.getFullYear(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; return [year, month, day].join('-'); } function editEvent(event) { var param = {}; param.startDate = formatDate(event.startDate.toDateString()); param.endDate = formatDate(event.endDate.toDateString()); var theURL = "fmp://$/__fileName__?script=__scriptName__¶m="+encodeURIComponent(JSON.stringify(param)); window.location = theURL; } Now when I click January 2, I get a dialog reflecting the date correctly. Note that "getMonth" is zero based so its necessary to add 1 to get the actual month number. Edited September 11, 2020 by Malcolm McLeary Link to comment Share on other sites More sharing options...
Hydroxy Posted February 27, 2021 Share Posted February 27, 2021 If I need event name, customEvents[i].title, with startDate and endDate in the parameter that return to FM when I click on a event. How can I modify it to get event.name in the parameter? Many thank in advance, Pat Link to comment Share on other sites More sharing options...
Recommended Posts
This topic is 827 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now