Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new Time().fromJSDate() sets timezone to 'floating' #403

Closed
nthgol opened this issue Sep 17, 2019 · 3 comments
Closed

new Time().fromJSDate() sets timezone to 'floating' #403

nthgol opened this issue Sep 17, 2019 · 3 comments

Comments

@nthgol
Copy link

nthgol commented Sep 17, 2019

I would have expected fromJSDate() to respect the timezone/offset of the JSDate supplied as an argument, however, the code defaults to Timezone.localTimezone, which is floating.

This can be pretty dangerous as local environments will behave pretty different to cloud deployments. It leads to a solution like:

const newTime = new ICAL.Time.fromJSDate(
        moment.tz(dateTime, timezone).toDate()
    ) //this timezone will by default be in local timezone/floating of server, regardless of what js date you feed into it

    //fix timezone
    newTime.timezone = timezone //not sure if necessary, but it comes with the initial parsed version of ics file
    newTime.zone = new ICAL.Timezone({
        tzid: timezone,
    })

Also - while i'm at it - what is the timezone property on a Time? its not documented but it shows up when parsing an ics.

@kewisch
Copy link
Owner

kewisch commented Jan 13, 2020

This is a tricky case, as there is no real timezone information available on the js date, just an offset. In theory we could assume one of the Etc timezones, but to get a reliable timezone I think this should be the responsibility of the client code.

@dilyanpalauzov
Copy link
Contributor

I would have expected fromJSDate() to respect the timezone/offset of the JSDate supplied as an argument,

The argument contains only the seconds since unix epoch start. The argument, the JavaScript Date object, contains no timezone. What a Date object contains can be retreived by calling date.valueOf(). The Date object does not contain even an utc-offset, but it can derive it from the environment.

@kewisch
Copy link
Owner

kewisch commented May 1, 2024

I'm going to close this one because I believe the behavior is expected. If someone wants to add documentation around this I'm open to PRs and additions to the wiki.

@kewisch kewisch closed this as not planned Won't fix, can't repro, duplicate, stale May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants