diff --git a/benchmarks/datetime.js b/benchmarks/datetime.js index 32839ad2..f4dffda7 100644 --- a/benchmarks/datetime.js +++ b/benchmarks/datetime.js @@ -11,7 +11,7 @@ function runDateTimeSuite() { const formatParser = DateTime.buildFormatParser("yyyy/MM/dd HH:mm:ss.SSS"); suite - .add("DateTime.local", () => { + .add("DateTime.now", () => { DateTime.now(); }) .add("DateTime.fromObject with locale", () => { @@ -20,6 +20,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 a3dde952..5314a9b3 100644 --- a/src/datetime.js +++ b/src/datetime.js @@ -492,7 +492,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;