Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Year Calendar in FileMaker with Carafe

Featured Replies

  • Newbies

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

  • Author
  • Newbies

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...

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

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.