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

bug: ion datetime forces to local time without options for backwards compatibility #19401

Closed
MKhowaja opened this issue Sep 20, 2019 · 7 comments
Labels
package: core @ionic/core package type: feature request a new feature, enhancement, or improvement

Comments

@MKhowaja
Copy link

Bug Report

[x] 4.9.1

Current behavior:
With the more recent releases of ionic, ion datetime now always converts the date to the system's timezone. This is not backwards compatible with previous behaviour and there is no option for configurability.

Expected behavior:
Ion datetime needs to be enhanced so that backwards compatibility is supported.

Steps to reproduce:
N/A Just want backwards compatibility (ie there should be an option to allow datetime to behave as it did before all the changes with respecting timezones).

Related code:

i
            /**
             * Prevent convertDataToISO from doing any
             * kind of transformation based on timezone
             * This cancels out any change it attempts to make
             *
             * Important: Take the timezone offset based on
             * the date that is currently selected, otherwise
             * there can be 1 hr difference when dealing w/ DST
             */
            const date = new Date(convertDataToISO(this.datetimeValue));
            this.datetimeValue.tzOffset = date.getTimezoneOffset() * -1;

Other information:

Ionic info:


Ionic:

   ionic (Ionic CLI)             : 4.9.0 (/Users/mustaqeemk/.nvm/versions/node/v11.6.0/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.9.1
   @angular-devkit/build-angular : 0.803.2
   @angular-devkit/schematics    : 8.3.2
   @angular/cli                  : 8.3.2
   @ionic/angular-toolkit        : 2.0.0

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.4, ios 5.0.1
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.1, (and 30 other plugins)

System:

   Android SDK Tools : 26.1.1 (/Users/mustaqeemk/Library/Android/sdk)
   ios-deploy        : 1.9.4
   ios-sim           : 8.0.2
   NodeJS            : v11.6.0 (/Users/mustaqeemk/.nvm/versions/node/v11.6.0/bin/node)
   npm               : 6.10.2
   OS                : macOS Mojave
   Xcode             : Xcode 10.2.1 Build version 10E1001
@ionitron-bot ionitron-bot bot added the triage label Sep 20, 2019
@daem0ndev
Copy link
Contributor

daem0ndev commented Oct 1, 2019

We could have an optional prop for timezone that if not supplied will default to the users local timezone but if supplied the ion date time will display the value in the provided timezone. For users expecting the behavior pre 4.2 they would simply supply a timezone prop of 'UTC' and the ion date time will not convert the value to the device timezone

@liamdebeasi
Copy link
Member

liamdebeasi commented Oct 1, 2019

Thanks for the feature request. @daem0ndev's approach sounds good. I imagine it would look something like this:

@Prop() displayTimezone?: string;

If timezone is undefined, the date options will be displayed relative to the user's timezone (current behavior).

Example of forcing all values to be displayed in UTC:

<ion-datetime value="2019-10-01T15:43:40.394Z" display-timezone="utc"></ion-datetime>

edit: spoke with @daem0ndev offline, and we decided displayTimezone would be better to keep it consistent with the other props. Updated my example.

@liamdebeasi liamdebeasi added package: core @ionic/core package type: feature request a new feature, enhancement, or improvement labels Oct 1, 2019
@ionitron-bot ionitron-bot bot removed triage labels Oct 1, 2019
@daem0ndev
Copy link
Contributor

PR coming in soon! thanks ionic team!!!

@daem0ndev
Copy link
Contributor

after discussing with @liamdebeasi we are going to go with a prop name of displayTimezone instead of just timezone to make it clear that this is only the timezone to be respected for display. The input and output values will always be in UTC (current behavior)

@daem0ndev
Copy link
Contributor

PR is up!

@liamdebeasi
Copy link
Member

Thanks for the issue. This has been resolved via #19519 and will be available in an upcoming release of Ionic Framework.

@ionitron-bot
Copy link

ionitron-bot bot commented Feb 8, 2020

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Feb 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: core @ionic/core package type: feature request a new feature, enhancement, or improvement
Projects
None yet
Development

No branches or pull requests

3 participants