MCPcopy
hub / github.com/date-fns/date-fns / syncFromInternal

Function syncFromInternal

pkgs/tz/src/date/mini.js:185–205  ·  view source on GitHub ↗

* @internal * Function syncs internal wall-clock fields into the external date. * * @param {Date} date - The date to sync

(date)

Source from the content-addressed store, hash-verified

183 * @param {Date} date - The date to sync
184 */
185function syncFromInternal(date) {
186 // Copy target-zone wall-clock fields from internal into external using native
187 // local setters. At this point external holds the right field values but they
188 // are interpreted in the system time zone; `adjustToSystemTZ` fixes that.
189 Date.prototype.setFullYear.call(
190 date,
191 date.internal.getUTCFullYear(),
192 date.internal.getUTCMonth(),
193 date.internal.getUTCDate(),
194 );
195 Date.prototype.setHours.call(
196 date,
197 date.internal.getUTCHours(),
198 date.internal.getUTCMinutes(),
199 date.internal.getUTCSeconds(),
200 date.internal.getUTCMilliseconds(),
201 );
202
203 // Now we have to adjust the date to the system time zone
204 adjustToSystemTZ(date);
205}
206
207/**
208 * @internal

Callers 1

mini.jsFile · 0.85

Calls 1

adjustToSystemTZFunction · 0.85

Tested by

no test coverage detected