问题
I am trying to create an appointment-scheduling application with fullcalendar
. I want to represent time-slots on the calendar in only one timezone(i.e., EST) across all locations. So even if a person from PST zone is viewing the calendar, the times should be in EST. Also, even he/she schedules clicks a slot, the time should be in EST. How can I set a default time-zone for the calendar irrespective of location.
回答1:
I believe this can be done by specifying the timezone string when you initialize your calendar:
$('#calendar-selector-id-name').fullCalendar({
timezone: 'American/Indiana/Indianapolis'
});
You mentioned the gcal.js
and so, I am wondering if this needs to be defined like:
$('#calendar-selector-id-name').fullCalendar({
timezone: 'American/Indiana/Indianapolis',
eventSources:[{
url: 'https://www.google.com/calendar/feeds/...',
currentTimezone: 'American/Indiana/Indianapolis'
}]
});
Demo
Docs
Timezone problems when using Google Calendar #1801
EDIT
@jaykumarark did some further research and dug up the following:
Google Calendar - htmlLink not always defined #2844
Which revealed that for GoogleApps calendars, an initialized htmlLink
variable is not provided for events that only share free/busy information, and hide event details.
Jay also noted discovering the following work-around:
"commenting line 144 in gcal.js //url=injectQsComponent(url, 'ctz=' + timezoneArg);
I could represent times in a particular timezone irrespective of location."
So, in summary:
- Currently, setting timezone, irrelevant of location, seems to work fine with GoogleApps calendars, as long one of the 3 "Share all information, ..." sharing settings is selected.
- Adam Shaw has acknowledged the issue of
htmlLink
requiring an existence check, i.e. at some point the javascript error will be addressed. - Jay has provided a work-around, for those looking to implement a synonymous solution.
Please refer to comments below for additional information/clarifications.
来源:https://stackoverflow.com/questions/35043289/fullcalendar-default-timezone-irrespective-of-clients-location