(start: Date, end?: Date)
| 286 | }; |
| 287 | |
| 288 | const publishExperienceTime = (start: Date, end?: Date): string => { |
| 289 | const difference = |
| 290 | new Date(end || Date.now()).getTime() - new Date(start).getTime(); |
| 291 | const differenceInMonths = Math.floor(difference / oneMonth); |
| 292 | const years = Math.floor(differenceInMonths / 12); |
| 293 | const months = differenceInMonths % 12; |
| 294 | |
| 295 | if (years > 0) { |
| 296 | const yearCopy = `${years} ${pluralize('year', years)}`; |
| 297 | |
| 298 | if (months === 0) { |
| 299 | return yearCopy; |
| 300 | } |
| 301 | |
| 302 | return `${yearCopy} ${months} ${pluralize('month', months)}`; |
| 303 | } |
| 304 | |
| 305 | return months > 0 |
| 306 | ? `${months} ${pluralize('month', months)}` |
| 307 | : 'Less than a month'; |
| 308 | }; |
| 309 | |
| 310 | export const getTodayTz = (timeZone: string, now = new Date()): Date => { |
| 311 | const timeZonedToday = now.toLocaleString('en', { timeZone }); |
no test coverage detected