-
Notifications
You must be signed in to change notification settings - Fork 79
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
Configure the timezone that is assumed by parsing methods #273
Comments
Easiest way to do that is to add the offset to the string (if one doesn't exist). Dates in JS are always local to the host computer. This will be true even if you set the offset (it'll return the date in the local timezone just modified so it's accurate if it was the time you wanted. So without a major overhaul of JS date parsing the solution is "append the tz to your data" |
Any suggestions on detecting whether an offset exists on the string already? I can't append it unconditionally, since DateJS parser seems to use that, instead of any previously defined offsets. Seems like I'm going to have to write my own complicated date parser, just to do that. But doesn't DateJS's parser extract the offset and apply it already? Seems like it would be very simple just to add an override to that. That wouldn't be a major overhaul at all. Just something like:
|
You're asking for a chain modifier - so chain modify it yourself?
|
But I want to add the offset only conditionally. Currently, there is no API to detect if the parser applied a user-defined offset. Example:
How would I detect that the parser has added a 7 hour offset to I mean, if you guys don't want to implement this that's fine. Its just a suggestion to help improve the library. I suppose I'll just have a separate select box for specifying a timezone, and then maybe use MomentJS's UTC parsing mode. |
It's not going to be a priority either way. What you're describing with MomentJS can be done with existing DateJS functions btw so I refer you to my previous solution. That said - if you absolutely want it then PRs are welcome. |
When a user doesn't provide a timezone in a string, I would like to assume GMT/UTC timezone. Currently, if a timezone is not provided, it is assuming my local computer's timezone. For example (my computer is set to MST timezone):
Can we add an argument to
Date.parse
to supply the UTC offset to assume, rather than using the computer's local timezone? This is the behavior I would expect:The text was updated successfully, but these errors were encountered: