* @internal * Function syncs time to internal date, applying the current time zone offset. * * @param {Date} date - `Date` to sync
(date)
| 156 | * @param {Date} date - `Date` to sync |
| 157 | */ |
| 158 | function syncToInternal(date) { |
| 159 | // Start internal from the same real timestamp as external. |
| 160 | date.internal.setTime(+date); |
| 161 | |
| 162 | // Shift internal by the target offset so its UTC fields become the target-zone |
| 163 | // wall-clock fields for the external timestamp. |
| 164 | // |
| 165 | // o internal UTC fields: 2024-02-11 00:00 |
| 166 | // | |
| 167 | // | + Asia/Singapore offset (+08:00) |
| 168 | // v |
| 169 | // x internal UTC fields: 2024-02-11 08:00 |
| 170 | // |
| 171 | date.internal.setUTCSeconds( |
| 172 | date.internal.getUTCSeconds() - |
| 173 | // Round after converting minutes to seconds to avoid fractional offset |
| 174 | // precision errors from historical offsets. |
| 175 | Math.round(-tzOffset(date.timeZone, date) * 60), |
| 176 | ); |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * @internal |
no test coverage detected