(start: TemporalValue, end: TemporalValue)
| 1793 | * Compute the duration between two temporal values in days only. |
| 1794 | */ |
| 1795 | export function durationInDays(start: TemporalValue, end: TemporalValue): DurationValue | null { |
| 1796 | if ( |
| 1797 | (start instanceof DateValue || |
| 1798 | start instanceof LocalDateTimeValue || |
| 1799 | start instanceof DateTimeValue) && |
| 1800 | (end instanceof DateValue || end instanceof LocalDateTimeValue || end instanceof DateTimeValue) |
| 1801 | ) { |
| 1802 | const startDate = new Date(Date.UTC(start.year, start.month - 1, start.day)); |
| 1803 | const endDate = new Date(Date.UTC(end.year, end.month - 1, end.day)); |
| 1804 | const diffMs = endDate.getTime() - startDate.getTime(); |
| 1805 | const days = Math.round(diffMs / (24 * 60 * 60 * 1000)); |
| 1806 | return new DurationValue(0, days, 0, 0); |
| 1807 | } |
| 1808 | return null; |
| 1809 | } |
| 1810 | |
| 1811 | /** |
| 1812 | * Compute the duration between two temporal values in seconds only. |
no outgoing calls
no test coverage detected