|
1 | | -import { TableCellUser, TableCellValue, TableFormView } from 'mobx-lark'; |
2 | | -import { formatDate } from 'web-utility'; |
| 1 | +import { TableCellValue, TableFormView } from 'mobx-lark'; |
| 2 | +import { Day, formatDate } from 'web-utility'; |
3 | 3 |
|
4 | 4 | import type { HackathonScheduleTone } from './Schedule'; |
5 | 5 | import { i18n, I18nKey } from '../../../models/Translation'; |
@@ -94,16 +94,6 @@ const textOf = (value: TextLike) => { |
94 | 94 | export const firstTextOf = (value: TextListLike) => |
95 | 95 | (Array.isArray(value) ? value.map(textOf).find(Boolean) : textOf(value)) || ''; |
96 | 96 |
|
97 | | -export const textListOf = (value: TextListLike) => |
98 | | - (Array.isArray(value) ? value : [value]).map(textOf).filter(Boolean); |
99 | | - |
100 | | -export const relationNameOf = (value: TextListLike) => firstTextOf(value); |
101 | | - |
102 | | -export const userOf = (value?: TableCellValue | TableCellUser) => |
103 | | - value && typeof value === 'object' && !Array.isArray(value) && 'name' in value |
104 | | - ? (value as TableCellUser) |
105 | | - : undefined; |
106 | | - |
107 | 97 | export const formatMoment = (value?: TableCellValue) => (value ? formatDate(value as string) : ''); |
108 | 98 |
|
109 | 99 | export const formatPeriod = (startedAt?: TableCellValue, endedAt?: TableCellValue) => |
@@ -152,7 +142,8 @@ export const resolveCountdownState = <T extends CountdownWindow>( |
152 | 142 | ? nextItem?.startedAt |
153 | 143 | : nextItem?.endedAt; |
154 | 144 | const fallbackCountdownTarget = timeOf(startTime) > referenceTime ? startTime : endTime; |
155 | | - const countdownTo = countdownTextOf(nextCountdownTarget) || countdownTextOf(fallbackCountdownTarget); |
| 145 | + const countdownTo = |
| 146 | + countdownTextOf(nextCountdownTarget) || countdownTextOf(fallbackCountdownTarget); |
156 | 147 |
|
157 | 148 | return { nextItem, countdownTo }; |
158 | 149 | }; |
@@ -219,7 +210,7 @@ export const daysBetween = (startedAt?: TableCellValue, endedAt?: TableCellValue |
219 | 210 |
|
220 | 211 | if (!Number.isFinite(start) || !Number.isFinite(end) || end < start) return 0; |
221 | 212 |
|
222 | | - return Math.max(1, Math.ceil((end - start) / (24 * 60 * 60 * 1000))); |
| 213 | + return Math.max(1, Math.ceil((end - start) / Day)); |
223 | 214 | }; |
224 | 215 |
|
225 | 216 | export const normalizeAgendaType = (value?: TableCellValue) => |
|
0 commit comments