Skip to content

Commit

Permalink
datetime polyfill, remove moment.tz.guess()
Browse files Browse the repository at this point in the history
  • Loading branch information
waterim committed Aug 29, 2023
1 parent 766dd65 commit 6fbfec7
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 3 deletions.
57 changes: 57 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
},
"dependencies": {
"@expensify/react-native-web": "0.18.15",
"@formatjs/intl-datetimeformat": "^6.10.0",
"@formatjs/intl-getcanonicallocales": "^2.2.0",
"@formatjs/intl-listformat": "^7.2.2",
"@formatjs/intl-locale": "^3.3.0",
Expand Down
1 change: 1 addition & 0 deletions src/libs/IntlPolyfill/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ import polyfillNumberFormat from './polyfillNumberFormat';
export default function intlPolyfill() {
// Just need to polyfill Intl.NumberFormat for web based platforms
polyfillNumberFormat();
require('@formatjs/intl-datetimeformat');
}
1 change: 1 addition & 0 deletions src/libs/IntlPolyfill/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default function polyfill() {
require('@formatjs/intl-getcanonicallocales/polyfill');
require('@formatjs/intl-locale/polyfill');
require('@formatjs/intl-pluralrules/polyfill');
require('@formatjs/intl-datetimeformat');
polyfillNumberFormat();
polyfillListFormat();
}
2 changes: 1 addition & 1 deletion src/libs/Navigation/AppNavigator/AuthScreens.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Onyx.connect({
}

timezone = lodashGet(val, [currentAccountID, 'timezone'], {});
const currentTimezone = moment.tz.guess(true);
const currentTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;

// If the current timezone is different than the user's timezone, and their timezone is set to automatic
// then update their timezone.
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ function openProfile(personalDetails) {
if (lodashGet(oldTimezoneData, 'automatic', true)) {
newTimezoneData = {
automatic: true,
selected: moment.tz.guess(true),
selected: Intl.DateTimeFormat().resolvedOptions().timeZone,
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/Profile/TimezoneInitialPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function TimezoneInitialPage(props) {
const updateAutomaticTimezone = (isAutomatic) => {
PersonalDetails.updateAutomaticTimezone({
automatic: isAutomatic,
selected: isAutomatic ? moment.tz.guess() : timezone.selected,
selected: isAutomatic ? Intl.DateTimeFormat().resolvedOptions().timeZone : timezone.selected,
});
};

Expand Down

0 comments on commit 6fbfec7

Please sign in to comment.