React-calendar: Timezone Handling

Created on 15 Oct 2018  路  1Comment  路  Source: wojtekmaj/react-calendar

Is there any chance of making the calendar timezone aware?

I'm currently having to write code like follows to strip out the (wrong) time data produced because the calendar is pulling from my local timezone, and not from a defined timezone that will vary with the input data. The app in question involves disparate locations, and those locations won't always be in the same timezone as the user. So I'm writing weird code like:

loadCalendar = (time) => {
  const date = moment(time).format('YYYY-MM-DD');
  const start = moment.tz(date, this.props.business.timezone).startOf('month');
  const end = moment.tz(date, this.props.business.timezone).endOf('month');
  ...//Business logic to query data between start and end of month
}

I'm having to cast the time provided by the calendar (the first second of the month) into a string, in order to re-create it using a timezone aware format.

An example of this creating a bug would be if I were in the EST time zone, and the location whose calendar I was managing was in PST. When selecting a new month, the calendar would produce the timestamp "October 1st, 00:00" When converted to the business's timezone, that produces "September 31st, 21:00".

Current behavior: calendar defaults to current user's timezone.

Desired behavior: calendar defaults to current user's timezone, but it's possible to tell it to use a different timezone instead.

question

>All comments

Timezone conversion is a too complex task to handle by a simple widget which React-Calendar aims to be. As there are other, well tested solutions (like the very one you're using) out there, I don't think it would be good to include yet another one in this library.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wojtekmaj picture wojtekmaj  路  3Comments

guydewinton picture guydewinton  路  3Comments

rmccue picture rmccue  路  4Comments

dumkanki picture dumkanki  路  3Comments

Hubro picture Hubro  路  3Comments