(start: Date, end?: Date)
| 275 | }; |
| 276 | |
| 277 | const publishExperienceTime = (start: Date, end?: Date): string => { |
| 278 | const difference = |
| 279 | new Date(end || Date.now()).getTime() - new Date(start).getTime(); |
| 280 | const differenceInMonths = Math.floor(difference / oneMonth); |
| 281 | const years = Math.floor(differenceInMonths / 12); |
| 282 | const months = differenceInMonths % 12; |
| 283 | |
| 284 | if (years > 0) { |
| 285 | const yearCopy = `${years} ${pluralize('year', years)}`; |
| 286 | |
| 287 | if (months === 0) { |
| 288 | return yearCopy; |
| 289 | } |
| 290 | |
| 291 | return `${yearCopy} ${months} ${pluralize('month', months)}`; |
| 292 | } |
| 293 | |
| 294 | return months > 0 |
| 295 | ? `${months} ${pluralize('month', months)}` |
| 296 | : 'Less than a month'; |
| 297 | }; |
| 298 | |
| 299 | export const getTodayTz = (timeZone: string, now = new Date()): Date => { |
| 300 | const timeZonedToday = now.toLocaleString('en', { timeZone }); |
no test coverage detected