diff --git a/example/browser/example.js b/example/browser/example.js index df0b90a0..ecdf1dd6 100644 --- a/example/browser/example.js +++ b/example/browser/example.js @@ -3529,16 +3529,16 @@ module.exports = (() => { this.offsetExchange = null; const tzDdf = Timezones.parse(timezoneDdf); - const txExchange = Timezones.parse(timezoneExchange); + const tzExchange = Timezones.parse(timezoneExchange); if (tzDdf !== null) { this.timezoneDdf = tzDdf.code; this.offsetDdf = tzDdf.getUtcOffset(null, true); } - if (txExchange !== null) { - this.timezoneExchange = txExchange.code; - this.offsetExchange = txExchange.getUtcOffset(null, true); + if (tzExchange !== null) { + this.timezoneExchange = tzExchange.code; + this.offsetExchange = tzExchange.getUtcOffset(null, true); } } @@ -4548,7 +4548,7 @@ module.exports = (() => { 'use strict'; return { - version: '4.0.17' + version: '4.0.18' }; })(); @@ -5061,14 +5061,22 @@ module.exports = (() => { let t; let utc; - if (is.string(timezone) && quote.timeUtc !== null) { + if (quote.timeUtc !== null && (is.string(timezone) || quote.profile && quote.profile.exchangeRef && quote.profile.exchangeRef && quote.profile.exchangeRef.timezoneExchange)) { utc = true; + let tz; + + if (is.string(timezone)) { + tz = timezone; + } else { + tz = quote.profile.exchangeRef.timezoneExchange; + } + let epoch = quote.timeUtc.getTime(); - if (!offsets.hasOwnProperty(timezone)) { + if (!offsets.hasOwnProperty(tz)) { const offset = {}; offset.latest = epoch; - offset.timezone = Timezone.parse(timezone); + offset.timezone = Timezone.parse(tz); if (offset.timezone !== null) { offset.milliseconds = offset.timezone.getUtcOffset(null, true); @@ -5076,10 +5084,10 @@ module.exports = (() => { offset.milliseconds = null; } - offsets[timezone] = offset; + offsets[tz] = offset; } - const o = offsets[timezone]; + const o = offsets[tz]; if (o.milliseconds !== null) { t = new Date(epoch + o.milliseconds); @@ -7700,6 +7708,7 @@ module.exports = (() => { * Gets a list of names in the tz database (see https://en.wikipedia.org/wiki/Tz_database * and https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). * + * @public * @static * @returns {Array} */ @@ -7710,6 +7719,7 @@ module.exports = (() => { /** * Indicates if a timezone name exists. * + * @public * @static * @param {String} name - The timezone name to find. * @returns {Boolean} @@ -7724,6 +7734,8 @@ module.exports = (() => { /** * Attempts to guess the lock timezone. * + * @public + * @static * @returns {String|null} */ guessTimezone() { diff --git a/lib/meta.js b/lib/meta.js index b30ae754..4213b578 100644 --- a/lib/meta.js +++ b/lib/meta.js @@ -2,6 +2,6 @@ module.exports = (() => { 'use strict'; return { - version: '4.0.17' + version: '4.0.18' }; })(); \ No newline at end of file diff --git a/package.json b/package.json index dc3bfa9b..989ebbf2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@barchart/marketdata-api-js", - "version": "4.0.17", + "version": "4.0.18", "description": "Barchart client library for streaming market data from JERQ servers using JavaScript", "author": { "name": "Eero Pikat", diff --git a/test/dist/barchart-marketdata-api-tests-4.0.js b/test/dist/barchart-marketdata-api-tests-4.0.js index 81529f16..6a6c4f2c 100644 --- a/test/dist/barchart-marketdata-api-tests-4.0.js +++ b/test/dist/barchart-marketdata-api-tests-4.0.js @@ -1394,14 +1394,22 @@ module.exports = (() => { let t; let utc; - if (is.string(timezone) && quote.timeUtc !== null) { + if (quote.timeUtc !== null && (is.string(timezone) || quote.profile && quote.profile.exchangeRef && quote.profile.exchangeRef && quote.profile.exchangeRef.timezoneExchange)) { utc = true; + let tz; + + if (is.string(timezone)) { + tz = timezone; + } else { + tz = quote.profile.exchangeRef.timezoneExchange; + } + let epoch = quote.timeUtc.getTime(); - if (!offsets.hasOwnProperty(timezone)) { + if (!offsets.hasOwnProperty(tz)) { const offset = {}; offset.latest = epoch; - offset.timezone = Timezone.parse(timezone); + offset.timezone = Timezone.parse(tz); if (offset.timezone !== null) { offset.milliseconds = offset.timezone.getUtcOffset(null, true); @@ -1409,10 +1417,10 @@ module.exports = (() => { offset.milliseconds = null; } - offsets[timezone] = offset; + offsets[tz] = offset; } - const o = offsets[timezone]; + const o = offsets[tz]; if (o.milliseconds !== null) { t = new Date(epoch + o.milliseconds); @@ -4056,6 +4064,7 @@ module.exports = (() => { * Gets a list of names in the tz database (see https://en.wikipedia.org/wiki/Tz_database * and https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). * + * @public * @static * @returns {Array} */ @@ -4066,6 +4075,7 @@ module.exports = (() => { /** * Indicates if a timezone name exists. * + * @public * @static * @param {String} name - The timezone name to find. * @returns {Boolean} @@ -4080,6 +4090,8 @@ module.exports = (() => { /** * Attempts to guess the lock timezone. * + * @public + * @static * @returns {String|null} */ guessTimezone() {