Skip to content

Commit 0bb10c5

Browse files
committed
fix today
1 parent 12c69e1 commit 0bb10c5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

client/my-sites/stats/hooks/use-moment-site-zone.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import moment from 'moment';
44
import { useSelector } from 'calypso/state';
55
import { getSiteOption } from 'calypso/state/sites/selectors';
66
import { getSelectedSiteId } from 'calypso/state/ui/selectors';
7+
import { DATE_FORMAT } from '../constants';
78

89
export const getMomentSiteZone = createSelector(
910
( state: object, siteId: number | null ) => {
@@ -16,7 +17,9 @@ export const getMomentSiteZone = createSelector(
1617

1718
const gmtOffset = getSiteOption( state, siteId, 'gmt_offset' ) as number;
1819
if ( Number.isFinite( gmtOffset ) ) {
19-
return localizedMoment.utcOffset( gmtOffset );
20+
// In all the components, `moment` is directly used, which defaults to the browser's local timezone.
21+
// As a result, we need to convert the moment object to the site's timezone for easier comparison like `isSame`.
22+
return moment( localizedMoment.utcOffset( gmtOffset ).format( DATE_FORMAT ) );
2023
}
2124

2225
// Falls back to the browser's local timezone if no GMT offset is found

0 commit comments

Comments
 (0)