(offset: number)
| 235 | } |
| 236 | |
| 237 | function offsetToString(offset: number) { |
| 238 | let sign = Math.sign(offset) < 0 ? '-' : '+'; |
| 239 | offset = Math.abs(offset); |
| 240 | let offsetHours = Math.floor(offset / (60 * 60 * 1000)); |
| 241 | let offsetMinutes = Math.floor((offset % (60 * 60 * 1000)) / (60 * 1000)); |
| 242 | let offsetSeconds = Math.floor(((offset % (60 * 60 * 1000)) % (60 * 1000)) / 1000); |
| 243 | let stringOffset = `${sign}${String(offsetHours).padStart(2, '0')}:${String(offsetMinutes).padStart(2, '0')}`; |
| 244 | if (offsetSeconds !== 0) { |
| 245 | stringOffset += `:${String(offsetSeconds).padStart(2, '0')}`; |
| 246 | } |
| 247 | |
| 248 | return stringOffset; |
| 249 | } |
| 250 | |
| 251 | export function zonedDateTimeToString(date: ZonedDateTime): string { |
| 252 | return `${dateTimeToString(date)}${offsetToString(date.offset)}[${date.timeZone}]`; |
no outgoing calls
no test coverage detected