(start: Date, end?: Date)
| 260 | }; |
| 261 | |
| 262 | const publishExperienceTime = (start: Date, end?: Date): string => { |
| 263 | const difference = |
| 264 | new Date(end || Date.now()).getTime() - new Date(start).getTime(); |
| 265 | const differenceInMonths = Math.floor(difference / oneMonth); |
| 266 | const years = Math.floor(differenceInMonths / 12); |
| 267 | const months = differenceInMonths % 12; |
| 268 | |
| 269 | if (years > 0) { |
| 270 | const yearCopy = `${years} ${pluralize('year', years)}`; |
| 271 | |
| 272 | if (months === 0) { |
| 273 | return yearCopy; |
| 274 | } |
| 275 | |
| 276 | return `${yearCopy} ${months} ${pluralize('month', months)}`; |
| 277 | } |
| 278 | |
| 279 | return months > 0 |
| 280 | ? `${months} ${pluralize('month', months)}` |
| 281 | : 'Less than a month'; |
| 282 | }; |
| 283 | |
| 284 | export const getTodayTz = (timeZone: string, now = new Date()): Date => { |
| 285 | const timeZonedToday = now.toLocaleString('en', { timeZone }); |
no test coverage detected