javascript - Full calendar Timezone Moment js Issue -


i've been wrestling while now, reaching out bit of please.

i have realtime multi timezone application uses signal r, datetimes stored , broadcast using utc , want manipulate them client side avoid multiple broadcasts different users if 1 appointment updated.

i'm trying fullcalendar display dates in appropriate timezone user, not based on browser local string held when user logs on.

is possible? or need store offsets , way (i hoping avoid this). using eventrender manipulate giving me other issues , have raise bug.

my code is:

   $(document).ready(function() {        function rendercalendar() {         $('#calendar').fullcalendar({             header: {                 left: 'prev,next today',                 center: 'title',                 right: 'month,agendaweek,agendaday'             },             editable: true,             timezone: "europe/istanbul",             eventlimit: true, // allow "more" link when many events             events: [{"id":1026,"tasktypeid":4,"title":"(new appointment)","start":"2015-06-11t11:00:00z","end":"2015-06-11t12:00:00z", "timezone":"utc","allday":false,"url":null,"location":"","people":null,"classname":"event-appointment"}],             eventrender: function(event, el) {                   if (event.start.haszone()) {                     el.find('.fc-title').after(                     $('<div class="tzo"/>').text(event.start.format('z'))                     );                 }              }         });     }      rendercalendar();  });   

fullcalendar's time zone documentation explains named time zones expected calculated on server. while supports tagging events time zone, doesn't time zone conversion on client-side. unless behavior changes in future release, doesn't fit scenario described.

however, doesn't mean you're stuck. fullcalendar takes dependency on moment.js, , there add-on moment.js called moment-timezone. designed perform client-side time zone conversions using iana time zone identifiers, such "europe/istanbul" 1 show in sample.

when receive event signalr broadcast, can use moment-timezone convert utc desired zone before sending result fullcalendar event object.

var s = moment("2015-06-11t11:00:00z").tz("europe/istanbul").format(); // result: "2015-06-11t14:00:00+03:00" 

a couple of additional points:

  • time zone data changes periodically, governments of world change minds offset , daylight saving time rules. stay on top of updates subscribing iana time zone announcements mailing list. it's reasonable expect updates time zone library within week or of iana release.

  • since using signalr, assume end must .net. fullcalendar documentation shows using php end, has support iana time zones. however, in .net can use noda time same functionality.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -