-
Notifications
You must be signed in to change notification settings - Fork 409
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
add ability to set a specific timezone for an individual picker #420
Comments
I'm looking into working on this because we need it for our application and I'd rather contribute here than write our own adapter. |
Hey @gmiller-in-situ thanks for looking into this enhancement. I'm not sure how relevant this feature is/will be for the existing user base but if you will find it helpful I'll work with you to get a PR merged. I think Off the top of my head something like the following seems reasonable.
This would cause the picker to display and store all dates in the I'm open to using either timezone or offset. It seems that timezone will be more accurate as offset for a timezone can/has/will change over time. 😄 I haven't thought about how the input directive will work when specifying timezone. This enhancement was written before the input directive was added. The input directive allows for storage in one format, display in a different format, and input in multiple formats so I think that might be a bit more complicated. Would this enhancement support displaying in one timezone, saving the model in a different timezone? Something to think about. To be clear, these are not requirements or anything, just stuff to think about as you work on your changes, |
I've spent some time looking into this, and there are a number of reasons why I'm going to drop this enhancement.
I've written an adapter in our code that can sit on top of this library and apply offsets after users have selected a time. This is fairly simple and doesn't require changing the library's function. The component that the datetime picker is used within can have something like the following to move times emitted from the picker to a desired timezone:
I still really appreciate having this library, it's a very good tool for the task we use it for! edit: a code comment |
I'm glad you find it useful and appreciate you posting your code here. How is the code above called in your project? |
This function would be called on the value emitted by the
This moves the time from the timezone-unaware space of the date-time-picker to a timezone-aware space in our code. |
thanks @gmiller-in-situ - Seems simple enough and I see why there is no need to change this component. I'm glad it all worked out for you. |
I have a question @gmiller-in-situ, how does that work when the user opens the picker a second time? It seems like the |
Yeah, it doesn't totally solve the issue. When applying a timezone outside of the datepicker, we're ignoring the [(ngModel)]-bound property and instead relying on the value coming out of the (change). So the property bound to the [(ngModel)] is not modified with a timezone. |
Ah, that makes sense. You made me think of something. Did you consider supplying your own |
Yeah I'm considering coming back to this and trying something where you can just pass the picker a moment with a timezone, and it keeps the timezone intact. I think this would be the best way to handle this probably, but I don't yet know how feasible it is. |
Default to browser timezone if not set.
Timezone is considered in the determination of
.now
, parsing dates from the model, serializing dates to the model, and raisingchange
eventsThe text was updated successfully, but these errors were encountered: