Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Year Calendar in FileMaker with Carafe


This topic is 1363 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

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

Year Calendar.png

Returned Data.png

  • Newbies
Posted (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__&param="+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.

Year Calendar.png

Edited by Malcolm McLeary
  • 5 months later...
Posted

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

This topic is 1363 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.