diff --git a/src/convert/convert.js b/src/convert/convert.js index 6915275..db858d5 100644 --- a/src/convert/convert.js +++ b/src/convert/convert.js @@ -16,10 +16,6 @@ function getTransition (unixTime, timeZone) { return { abbreviation, offset } } -function attachEpoch (time, unixTime) { - Object.defineProperty(time, 'epoch', { value: unixTime }) -} - function setTimeZone (time, timeZone, options) { if (time instanceof Date) { const { useUTC } = options || {} @@ -39,7 +35,6 @@ function setTimeZone (time, timeZone, options) { const unixTime = getUnixTimeFromUTC(time) const { abbreviation, offset } = getTransition(unixTime, timeZone) time.zone = { abbreviation, offset } - attachEpoch(time, unixTime) return time } @@ -52,7 +47,7 @@ function getZonedTime (date, timeZone) { } const time = getUTCTime(date) time.zone = { abbreviation, offset } - attachEpoch(time, unixTime) + Object.defineProperty(time, 'epoch', { value: unixTime }) return time } diff --git a/test/setTimeZone.test.js b/test/setTimeZone.test.js index 123964a..4323347 100644 --- a/test/setTimeZone.test.js +++ b/test/setTimeZone.test.js @@ -5,7 +5,7 @@ const { findTimeZone, setTimeZone } = require('../dist/index') let berlin function checkTime (time, checkSeconds) { - const { year, month, day, hours, minutes, seconds, milliseconds, zone, epoch } = time + const { year, month, day, hours, minutes, seconds, milliseconds, zone } = time expect(year).toEqual(2018) expect(month).toEqual(1) expect(day).toEqual(2) @@ -14,11 +14,9 @@ function checkTime (time, checkSeconds) { if (checkSeconds) { expect(seconds).toEqual(40) expect(milliseconds).toEqual(50) - expect(epoch).toEqual(1514889040050) } else { expect(seconds).toEqual(0) expect(milliseconds).toEqual(0) - expect(epoch).toEqual(1514889000000) } expect(typeof zone === 'object').toBeTruthy() expect(zone.abbreviation).toEqual('CET')