* Create a new Date object with the given date value, and the time set to midnight. * * We cannot use `new Date(year, month, date)` because it maps years between 0 and 99 to 1900-1999. * See: https://github.com/angular/angular/issues/40377 * * Note that this function returns a Date object whose
(year: number, month: number, date: number)
| 178 | * considerable breaking change. |
| 179 | */ |
| 180 | function createDate(year: number, month: number, date: number): Date { |
| 181 | // The `newDate` is set to midnight (UTC) on January 1st 1970. |
| 182 | // - In PST this will be December 31st 1969 at 4pm. |
| 183 | // - In GMT this will be January 1st 1970 at 1am. |
| 184 | // Note that they even have different years, dates and months! |
| 185 | const newDate = new Date(0); |
| 186 | |
| 187 | // `setFullYear()` allows years like 0001 to be set correctly. This function does not |
| 188 | // change the internal time of the date. |
| 189 | // Consider calling `setFullYear(2019, 8, 20)` (September 20, 2019). |
| 190 | // - In PST this will now be September 20, 2019 at 4pm |
| 191 | // - In GMT this will now be September 20, 2019 at 1am |
| 192 | |
| 193 | newDate.setFullYear(year, month, date); |
| 194 | // We want the final date to be at local midnight, so we reset the time. |
| 195 | // - In PST this will now be September 20, 2019 at 12am |
| 196 | // - In GMT this will now be September 20, 2019 at 12am |
| 197 | newDate.setHours(0, 0, 0); |
| 198 | |
| 199 | return newDate; |
| 200 | } |
| 201 | |
| 202 | function getNamedFormat(locale: string, format: string): string { |
| 203 | const localeId = getLocaleId(locale); |
no outgoing calls
no test coverage detected
searching dependent graphs…