Skip to content

Commit

Permalink
change default value of second argument in formatDate function and us…
Browse files Browse the repository at this point in the history
…e it in this case to fix time zone calculation
  • Loading branch information
dzonidoo committed Aug 20, 2024
1 parent f21b14b commit ab586ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion assets/user-profile/components/profile/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class UserProfile extends React.PureComponent<IProps> {
<div className="nh-container nh-container__text--alert">
<div className='d-flex flex-column gap-3 p-3'>
<div>
{gettext('All notifications will be paused from {{dateFrom}} to {{dateTo}}', {dateFrom: formatDate(pausedFrom), dateTo: formatDate(pausedTo)})}
{gettext('All notifications will be paused from {{dateFrom}} to {{dateTo}}', {dateFrom: formatDate(pausedFrom, true), dateTo: formatDate(pausedTo, true)})}
</div>
<div>
<button
Expand Down
6 changes: 3 additions & 3 deletions assets/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export function getProductQuery(product: any) {
* @param {Boolean} ignoreTimezone - avoid converting time to different timezone, will output the date as it is
* @return {Date}
*/
export function parseDate(dateString: any, ignoreTimezone: any = false) {
export function parseDate(dateString: any, ignoreTimezone?: boolean) {
const parsed = ignoreTimezone ? moment.utc(dateString) : moment(dateString);

parsed.locale(getLocale());
Expand Down Expand Up @@ -283,8 +283,8 @@ export function formatTime(dateString: any) {
* @param {String} dateString
* @return {String}
*/
export function formatDate(dateString: any) {
return parseDate(dateString).format(DATE_FORMAT);
export function formatDate(dateString: any, ignoreTimezone?: boolean) {
return parseDate(dateString, ignoreTimezone).format(DATE_FORMAT);
}

/**
Expand Down

0 comments on commit ab586ec

Please sign in to comment.