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

Datetime polyfill, removed moment.tz.guess() #26248

Merged
merged 4 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
3 changes: 1 addition & 2 deletions src/libs/Navigation/AppNavigator/AuthScreens.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import Onyx, {withOnyx} from 'react-native-onyx';
import PropTypes from 'prop-types';
import moment from 'moment';
import _ from 'underscore';
import lodashGet from 'lodash/get';
import {View} from 'react-native';
Expand Down Expand Up @@ -65,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
4 changes: 1 addition & 3 deletions src/libs/actions/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import moment from 'moment-timezone';
import 'moment/locale/es';
import {AppState} from 'react-native';
import Onyx from 'react-native-onyx';
import lodashGet from 'lodash/get';
Expand Down Expand Up @@ -386,7 +384,7 @@ function openProfile(personalDetails) {
if (lodashGet(oldTimezoneData, 'automatic', true)) {
newTimezoneData = {
automatic: true,
selected: moment.tz.guess(true),
selected: Intl.DateTimeFormat().resolvedOptions().timeZone,
};
}

Expand Down
3 changes: 1 addition & 2 deletions src/pages/settings/Profile/TimezoneInitialPage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import lodashGet from 'lodash/get';
import React from 'react';
import {View} from 'react-native';
import moment from 'moment-timezone';
import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsPropTypes, withCurrentUserPersonalDetailsDefaultProps} from '../../../components/withCurrentUserPersonalDetails';
import ScreenWrapper from '../../../components/ScreenWrapper';
import HeaderWithBackButton from '../../../components/HeaderWithBackButton';
Expand Down Expand Up @@ -37,7 +36,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
Loading