@codecademy/brand 5.11.0-alpha.93b754c9d.0 → 5.11.0-alpha.ad9aef5f7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,14 +6,14 @@ const formatTime = (timeString, format) => {
|
|
|
6
6
|
return formatInTimeZone(new Date(timeString), Intl.DateTimeFormat().resolvedOptions().timeZone, format);
|
|
7
7
|
};
|
|
8
8
|
const formatDaysLeft = timeString => {
|
|
9
|
-
const
|
|
10
|
-
if (Number.isNaN(
|
|
11
|
-
const now = Date
|
|
9
|
+
const startDate = new Date(timeString);
|
|
10
|
+
if (Number.isNaN(startDate.getTime())) return '';
|
|
11
|
+
const now = new Date();
|
|
12
|
+
const startDay = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate()).getTime();
|
|
13
|
+
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
|
|
12
14
|
const dayInMs = 24 * 60 * 60 * 1000;
|
|
13
|
-
const daysLeft = Math.max(0, Math.
|
|
14
|
-
if (daysLeft === 0)
|
|
15
|
-
return 'today';
|
|
16
|
-
}
|
|
15
|
+
const daysLeft = Math.max(0, Math.round((startDay - today) / dayInMs));
|
|
16
|
+
if (daysLeft === 0) return 'today';
|
|
17
17
|
return `in ${daysLeft} day${daysLeft === 1 ? '' : 's'}`;
|
|
18
18
|
};
|
|
19
19
|
export const CoachingSessionCard = ({
|
package/package.json
CHANGED