( progressTimestamps: ProgressTimestamp[] | null )
| 7 | * @returns The object with keys based on the timestamps. |
| 8 | */ |
| 9 | export const getCalendar = ( |
| 10 | progressTimestamps: ProgressTimestamp[] | null |
| 11 | ): Calendar => { |
| 12 | const calendar: Calendar = {}; |
| 13 | |
| 14 | progressTimestamps?.forEach(progress => { |
| 15 | if (progress === null) return; |
| 16 | if (typeof progress === 'number') { |
| 17 | calendar[Math.floor(progress / 1000)] = 1; |
| 18 | } else { |
| 19 | calendar[Math.floor(progress.timestamp / 1000)] = 1; |
| 20 | } |
| 21 | }); |
| 22 | |
| 23 | return calendar; |
| 24 | }; |
| 25 | |
| 26 | /** |
| 27 | * Converts a ProgressTimestamp array to an integer number of points. |
no outgoing calls
no test coverage detected