Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 4be0527

Browse files
committed
Removed unnecessary timezone-handling code.
1 parent bdbe5b9 commit 4be0527

File tree

4 files changed

+9
-16
lines changed

4 files changed

+9
-16
lines changed

src/constants/workPeriods.js

-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ export const DATE_FORMAT_ISO = "YYYY-MM-DD";
3333
export const DATE_FORMAT_UI = "MMM DD, YYYY";
3434
export const DATETIME_FORMAT_UI = "MMM DD, YYYY h:mm a";
3535

36-
export const TIMEZONE_SOURCE = "America/New_York";
37-
3836
// Field names that are required to be retrieved for display, filtering and sorting.
3937
export const API_REQUIRED_FIELDS = [
4038
"id",

src/routes/WorkPeriods/components/PaymentsListItem/index.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import PaymentStatus from "../PaymentStatus";
88
import {
99
currencyFormatter,
1010
formatChallengeUrl,
11-
formatDateTimeInTimeZone,
11+
formatDateTimeAsLocal,
1212
} from "utils/formatters";
1313
import { PAYMENT_STATUS } from "constants/workPeriods";
1414
import styles from "./styles.module.scss";
@@ -60,7 +60,7 @@ const PaymentsListItem = ({ daysPaid, daysWorked, item }) => {
6060
<td className={styles.days}>{item.days}</td>
6161
<td className={styles.amount}>{currencyFormatter.format(item.amount)}</td>
6262
<td className={styles.createdAt}>
63-
{formatDateTimeInTimeZone(item.createdAt)}
63+
{formatDateTimeAsLocal(item.createdAt)}
6464
</td>
6565
<td className={styles.paymentStatus}>
6666
<div className={styles.statusWithError}>

src/utils/formatters.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import moment from "moment-timezone";
1+
import moment from "moment";
22
import isNumber from "lodash/isNumber";
33
import {
44
DATETIME_FORMAT_UI,
55
DATE_FORMAT_UI,
66
PAYMENT_STATUS_LABELS,
7-
TIMEZONE_SOURCE,
87
} from "constants/workPeriods";
98
import {
109
PLATFORM_WEBSITE_URL,
@@ -34,17 +33,14 @@ export function formatDate(date) {
3433
return date ? moment(date).format(DATE_FORMAT_UI) : "-";
3534
}
3635

37-
const TIMEZONE_BROWSER = moment.tz.guess();
38-
3936
/**
40-
* Formats the date and time using the provided timezone.
37+
* Formats the provided time in UTC-0 as time in local timezone.
4138
*
42-
* @param {*} dateTime value that can be parsed by Moment
43-
* @param {string} [tz] timezone in which the resulting time will be displayed
39+
* @param {number} dateTime number of milliseconds since UTC epoch
4440
* @returns {string}
4541
*/
46-
export function formatDateTimeInTimeZone(dateTime, tz = TIMEZONE_BROWSER) {
47-
return moment.tz(dateTime, TIMEZONE_SOURCE).tz(tz).format(DATETIME_FORMAT_UI);
42+
export function formatDateTimeAsLocal(dateTime) {
43+
return moment(dateTime).format(DATETIME_FORMAT_UI);
4844
}
4945

5046
/**

src/utils/workPeriods.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import moment from "moment-timezone";
1+
import moment from "moment";
22
import {
33
ALERT,
44
API_CHALLENGE_PAYMENT_STATUS_MAP,
55
API_PAYMENT_STATUS_MAP,
66
DATE_FORMAT_ISO,
77
PAYMENT_STATUS,
88
REASON_DISABLED,
9-
TIMEZONE_SOURCE,
109
URL_QUERY_PARAM_MAP,
1110
} from "constants/workPeriods";
1211

@@ -230,7 +229,7 @@ export function normalizePeriodData(period) {
230229
export function normalizePeriodPayments(payments, data) {
231230
let lastFailedPayment = null;
232231
for (let payment of payments) {
233-
payment.createdAt = moment.tz(payment.createdAt, TIMEZONE_SOURCE).valueOf();
232+
payment.createdAt = moment.utc(payment.createdAt).valueOf();
234233
payment.status = normalizeChallengePaymentStatus(payment.status);
235234
if (payment.status === PAYMENT_STATUS.FAILED) {
236235
lastFailedPayment = payment;

0 commit comments

Comments
 (0)