diff --git a/benchmarks/datetime.js b/benchmarks/datetime.js index 39d6bf07..5def68fa 100644 --- a/benchmarks/datetime.js +++ b/benchmarks/datetime.js @@ -9,7 +9,7 @@ function runDateTimeSuite() { const dt = DateTime.now(); suite - .add("DateTime.local", () => { + .add("DateTime.now", () => { DateTime.now(); }) .add("DateTime.fromObject with locale", () => { @@ -18,6 +18,9 @@ function runDateTimeSuite() { .add("DateTime.local with numbers", () => { DateTime.local(2017, 5, 15); }) + .add("DateTime.local with numbers and zone", () => { + DateTime.local(2017, 5, 15, 11, 7, 35, { zone: "America/New_York" }); + }) .add("DateTime.fromISO", () => { DateTime.fromISO("1982-05-25T09:10:11.445Z"); }) diff --git a/src/datetime.js b/src/datetime.js index 9472cb53..06c8b775 100644 --- a/src/datetime.js +++ b/src/datetime.js @@ -487,7 +487,9 @@ export default class DateTime { if (unchanged) { [c, o] = [config.old.c, config.old.o]; } else { - const ot = zone.offset(this.ts); + // If an offset has been passed and we have not been called from + // clone(), we can trust it and avoid the offset calculation. + const ot = isNumber(config.o) && !config.old ? config.o : zone.offset(this.ts); c = tsToObj(this.ts, ot); invalid = Number.isNaN(c.year) ? new Invalid("invalid input") : null; c = invalid ? null : c;