shift-timezone-offset
Advanced tools
Comparing version 0.0.2 to 0.0.3
var localOffset = new Date().getTimezoneOffset() | ||
var maxOffset = 14 * 60 | ||
var parseOffset = require('./parse-time-offset') | ||
@@ -43,3 +44,3 @@ | ||
if(typeof timezoneData == 'number') | ||
if(typeof timezoneData == 'number' && Math.abs(timezoneData) <= maxOffset) | ||
return timezoneData | ||
@@ -46,0 +47,0 @@ |
{ | ||
"name": "shift-timezone-offset", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Shift timezoned dates to local time or any other timezone.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,2 @@ | ||
# timezone-offsets | ||
# shift-timezone-offset | ||
@@ -64,3 +64,3 @@ Converts timezoned dates to local time or any other timezone. | ||
// shifting 5 hours | ||
// 5 hours timezone shift | ||
console.log(timezoneShift.convert(dateInfo, { from: '+03:00', to: '+08:00' })) | ||
@@ -70,11 +70,11 @@ // => 2017-01-01T04:00:00.000Z | ||
// to local (all 3 are similar) | ||
// local timezone is default: | ||
// "to" defaults to local timezone: | ||
console.log(timezoneShift.convert(dateInfo, { from: '+03:00' })) | ||
// => 2017-01-01T01:00:00.000Z | ||
// to check: | ||
// to be sure: | ||
console.log(timezoneShift.convert(dateInfo, { from: '+03:00', to: '+11:00' })) | ||
// => 2017-01-01T01:00:00.000Z | ||
// even simpler (from timezone is infered from date string): | ||
// even simpler ("from" timezone is infered from date string): | ||
console.log(timezoneShift.convert(dateInfo)) | ||
@@ -91,5 +91,5 @@ // => 2017-01-01T01:00:00.000Z | ||
### `var converter = timezoneShift(validTimezone)` | ||
## `var converter = timezoneShift(validTimezone)` | ||
* `validTimezone` - valid ISO 8601 date string or timezone string: `'+05:00'`, `'-1100'` or `'2017-01-01T12:00:00+05:00'`. | ||
* `validTimezone` - valid ISO 8601 date string or timezone string: `'+05:00'`, `'-1100'` or `'2017-01-01T12:00:00+05:00'`. An offset is valid as well: `-240` in place of `'+04:00`. | ||
@@ -127,2 +127,10 @@ ### `converter.toLocal(date)` | ||
## `timezoneShift.convert(date, zones)` | ||
* `date` - any valid value for the `Date` object constructor. | ||
* `zone` - object containing initial and final timezones: | ||
* `zones.from` - valid timezone info. Could be infered if `date` is an ISO date string. | ||
* `zones.to` - default: local timezone. Valid timezone info. | ||
# license | ||
@@ -129,0 +137,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
10
142
12937
241
1