moment-timezone
Advanced tools
Comparing version 0.0.6 to 0.1.0
@@ -1,2 +0,2 @@ | ||
module.exports = require("./moment-timezone"); | ||
module.exports.tz.add(require('./moment-timezone.json')); | ||
var moment = module.exports = require("./moment-timezone"); | ||
moment.tz.load(require('./data/packed/latest.json')); |
@@ -1,540 +0,330 @@ | ||
// moment-timezone.js | ||
// version : 0.0.6 | ||
// author : Tim Wood | ||
// license : MIT | ||
// github.com/timrwood/moment-timezone | ||
//! moment-timezone.js | ||
//! version : 0.1.0 | ||
//! author : Tim Wood | ||
//! license : MIT | ||
//! github.com/moment/moment-timezone | ||
(function () { | ||
(function (root, factory) { | ||
"use strict"; | ||
var VERSION = "0.0.6"; | ||
/*global define*/ | ||
if (typeof define === 'function' && define.amd) { | ||
define(['moment'], factory); // AMD | ||
} else if (typeof exports === 'object') { | ||
module.exports = factory(require('moment')); // Node | ||
} else { | ||
factory(root.moment); // Browser | ||
} | ||
}(this, function (moment) { | ||
"use strict"; | ||
function onload(moment) { | ||
var oldZoneName = moment.fn.zoneName, | ||
oldZoneAbbr = moment.fn.zoneAbbr, | ||
// Do not load moment-timezone a second time. | ||
if (moment.tz !== undefined) { return moment; } | ||
defaultRule, | ||
rules = {}, | ||
ruleSets = {}, | ||
zones = {}, | ||
zoneSets = {}, | ||
links = {}, | ||
var VERSION = "0.1.0", | ||
zones = {}, | ||
links = {}; | ||
TIME_RULE_WALL_CLOCK = 0, | ||
TIME_RULE_UTC = 1, | ||
TIME_RULE_STANDARD = 2, | ||
/************************************ | ||
Unpacking | ||
************************************/ | ||
DAY_RULE_DAY_OF_MONTH = 7, | ||
DAY_RULE_LAST_WEEKDAY = 8; | ||
if (moment.tz !== undefined) { | ||
// Do not load moment-timezone a second time. | ||
return moment; | ||
function charCodeToInt(charCode) { | ||
if (charCode > 96) { | ||
return charCode - 87; | ||
} else if (charCode > 64) { | ||
return charCode - 29; | ||
} | ||
return charCode - 48; | ||
} | ||
// converts time in the HH:mm:ss format to absolute number of minutes | ||
function parseMinutes (input) { | ||
input = input + ''; | ||
var output = input.split(':'), | ||
sign = ~input.indexOf('-') ? -1 : 1, | ||
hour = Math.abs(+output[0]), | ||
minute = parseInt(output[1], 10) || 0, | ||
second = parseInt(output[2], 10) || 0; | ||
function unpackBase60(string) { | ||
var i = 0, | ||
parts = string.split('.'), | ||
whole = parts[0], | ||
fractional = parts[1] || '', | ||
multiplier = 1, | ||
num, | ||
out = 0, | ||
sign = 1; | ||
return sign * ((hour * 60) + (minute) + (second / 60)); | ||
// handle negative numbers | ||
if (string.charCodeAt(0) === 45) { | ||
i = 1; | ||
sign = -1; | ||
} | ||
/************************************ | ||
Rules | ||
************************************/ | ||
function Rule (name, startYear, endYear, month, day, dayRule, time, timeRule, offset, letters) { | ||
this.name = name; | ||
this.startYear = +startYear; | ||
this.endYear = +endYear; | ||
this.month = +month; | ||
this.day = +day; | ||
this.dayRule = +dayRule; | ||
this.time = parseMinutes(time); | ||
this.timeRule = +timeRule; | ||
this.offset = parseMinutes(offset); | ||
this.letters = letters || ''; | ||
this.date = memoize(this.date); | ||
this.weekdayAfter = memoize(this.weekdayAfter); | ||
this.lastWeekday = memoize(this.lastWeekday); | ||
// handle digits before the decimal | ||
for (i; i < whole.length; i++) { | ||
num = charCodeToInt(whole.charCodeAt(i)); | ||
out = 60 * out + num; | ||
} | ||
Rule.prototype = { | ||
contains : function (year) { | ||
return (year >= this.startYear && year <= this.endYear); | ||
}, | ||
start : function (year) { | ||
year = Math.min(Math.max(year, this.startYear), this.endYear); | ||
return moment.utc([year, this.month, this.date(year), 0, this.time]); | ||
}, | ||
date : function (year) { | ||
if (this.dayRule === DAY_RULE_DAY_OF_MONTH) { | ||
return this.day; | ||
} else if (this.dayRule === DAY_RULE_LAST_WEEKDAY) { | ||
return this.lastWeekday(year); | ||
} | ||
return this.weekdayAfter(year); | ||
}, | ||
weekdayAfter : function (year) { | ||
var day = this.day, | ||
firstDayOfWeek = moment([year, this.month, 1]).day(), | ||
output = this.dayRule + 1 - firstDayOfWeek; | ||
while (output < day) { | ||
output += 7; | ||
} | ||
return output; | ||
}, | ||
lastWeekday : function (year) { | ||
var day = this.day, | ||
dow = day % 7, | ||
lastDowOfMonth = moment([year, this.month + 1, 1]).day(), | ||
daysInMonth = moment([year, this.month, 1]).daysInMonth(), | ||
output = daysInMonth + (dow - (lastDowOfMonth - 1)) - (~~(day / 7) * 7); | ||
if (dow >= lastDowOfMonth) { | ||
output -= 7; | ||
} | ||
return output; | ||
} | ||
}; | ||
/************************************ | ||
Rule Year | ||
************************************/ | ||
function RuleYear (year, rule) { | ||
this.rule = rule; | ||
this.start = rule.start(year); | ||
// handle digits after the decimal | ||
for (i = 0; i < fractional.length; i++) { | ||
multiplier = multiplier / 60; | ||
num = charCodeToInt(fractional.charCodeAt(i)); | ||
out += num * multiplier; | ||
} | ||
RuleYear.prototype = { | ||
equals : function (other) { | ||
if (!other || other.rule !== this.rule) { | ||
return false; | ||
} | ||
return Math.abs(other.start - this.start) < 86400000; // 24 * 60 * 60 * 1000 | ||
} | ||
}; | ||
return out * sign; | ||
} | ||
function sortRuleYears (a, b) { | ||
if (a.isLast) { | ||
return -1; | ||
} | ||
if (b.isLast) { | ||
return 1; | ||
} | ||
return b.start - a.start; | ||
function arrayToInt (array) { | ||
for (var i = 0; i < array.length; i++) { | ||
array[i] = unpackBase60(array[i]); | ||
} | ||
} | ||
/************************************ | ||
Rule Sets | ||
************************************/ | ||
function RuleSet (name) { | ||
this.name = name; | ||
this.rules = []; | ||
this.lastYearRule = memoize(this.lastYearRule); | ||
function intToUntil (array, length) { | ||
for (var i = 0; i < length; i++) { | ||
array[i] = Math.round((array[i - 1] || 0) + (array[i] * 60000)); // minutes to milliseconds | ||
} | ||
RuleSet.prototype = { | ||
add : function (rule) { | ||
this.rules.push(rule); | ||
}, | ||
array[length - 1] = Infinity; | ||
} | ||
ruleYears : function (mom, lastZone) { | ||
var i, j, | ||
year = mom.year(), | ||
rule, | ||
lastZoneRule, | ||
rules = []; | ||
function mapIndices (source, indices) { | ||
var out = [], i; | ||
for (i = 0; i < this.rules.length; i++) { | ||
rule = this.rules[i]; | ||
if (rule.contains(year)) { | ||
rules.push(new RuleYear(year, rule)); | ||
} else if (rule.contains(year + 1)) { | ||
rules.push(new RuleYear(year + 1, rule)); | ||
} | ||
} | ||
rules.push(new RuleYear(year - 1, this.lastYearRule(year - 1))); | ||
for (i = 0; i < indices.length; i++) { | ||
out[i] = source[indices[i]]; | ||
} | ||
if (lastZone) { | ||
lastZoneRule = new RuleYear(year - 1, lastZone.lastRule()); | ||
lastZoneRule.start = lastZone.until.clone().utc(); | ||
lastZoneRule.isLast = lastZone.ruleSet !== this; | ||
rules.push(lastZoneRule); | ||
} | ||
return out; | ||
} | ||
rules.sort(sortRuleYears); | ||
return rules; | ||
}, | ||
function unpack (string) { | ||
var data = string.split('|'), | ||
offsets = data[2].split(' '), | ||
indices = data[3].split(''), | ||
untils = data[4].split(' '); | ||
rule : function (mom, offset, lastZone) { | ||
var rules = this.ruleYears(mom, lastZone), | ||
lastOffset = 0, | ||
rule, | ||
lastZoneOffset, | ||
lastZoneOffsetAbs, | ||
lastRule, | ||
i; | ||
arrayToInt(offsets); | ||
arrayToInt(indices); | ||
arrayToInt(untils); | ||
if (lastZone) { | ||
lastZoneOffset = lastZone.offset + lastZone.lastRule().offset; | ||
lastZoneOffsetAbs = Math.abs(lastZoneOffset) * 90000; | ||
} | ||
intToUntil(untils, indices.length); | ||
// make sure to include the previous rule's offset | ||
for (i = rules.length - 1; i > -1; i--) { | ||
lastRule = rule; | ||
rule = rules[i]; | ||
return { | ||
name : data[0], | ||
abbrs : mapIndices(data[1].split(' '), indices), | ||
offsets : mapIndices(offsets, indices), | ||
untils : untils | ||
}; | ||
} | ||
if (rule.equals(lastRule)) { | ||
continue; | ||
} | ||
/************************************ | ||
Zone object | ||
************************************/ | ||
if (lastZone && !rule.isLast && Math.abs(rule.start - lastZone.until) <= lastZoneOffsetAbs) { | ||
lastOffset += lastZoneOffset - offset; | ||
} | ||
function Zone (packedString) { | ||
var unpacked = unpack(packedString); | ||
this.name = unpacked.name; | ||
this.abbrs = unpacked.abbrs; | ||
this.untils = unpacked.untils; | ||
this.offsets = unpacked.offsets; | ||
} | ||
if (rule.rule.timeRule === TIME_RULE_STANDARD) { | ||
lastOffset = offset; | ||
} | ||
Zone.prototype = { | ||
_index : function (timestamp) { | ||
var target = +timestamp, | ||
untils = this.untils, | ||
i; | ||
if (rule.rule.timeRule !== TIME_RULE_UTC) { | ||
rule.start.add('m', -lastOffset); | ||
} | ||
lastOffset = rule.rule.offset + offset; | ||
for (i = 0; i < untils.length; i++) { | ||
if (target < untils[i]) { | ||
return i; | ||
} | ||
} | ||
}, | ||
for (i = 0; i < rules.length; i++) { | ||
rule = rules[i]; | ||
if (mom >= rule.start && !rule.isLast) { | ||
return rule.rule; | ||
} | ||
} | ||
parse : function (timestamp) { | ||
var target = +timestamp, | ||
offsets = this.offsets, | ||
untils = this.untils, | ||
i; | ||
return defaultRule; | ||
}, | ||
lastYearRule : function (year) { | ||
var i, | ||
rule, | ||
start, | ||
bestRule = defaultRule, | ||
largest = -1e30; | ||
for (i = 0; i < this.rules.length; i++) { | ||
rule = this.rules[i]; | ||
if (year >= rule.startYear) { | ||
start = rule.start(year); | ||
if (start > largest) { | ||
largest = start; | ||
bestRule = rule; | ||
} | ||
} | ||
for (i = 0; i < untils.length; i++) { | ||
if (target < untils[i] - (offsets[i] * 60000)) { | ||
return offsets[i]; | ||
} | ||
return bestRule; | ||
} | ||
}; | ||
}, | ||
/************************************ | ||
Zone | ||
************************************/ | ||
abbr : function (mom) { | ||
return this.abbrs[this._index(mom)]; | ||
}, | ||
function Zone (name, offset, ruleSet, letters, until, untilOffset) { | ||
var i, | ||
untilArray = typeof until === 'string' ? until.split('_') : [9999]; | ||
this.name = name; | ||
this.offset = parseMinutes(offset); | ||
this.ruleSet = ruleSet; | ||
this.letters = letters; | ||
this.lastRule = memoize(this.lastRule); | ||
for (i = 0; i < untilArray.length; i++) { | ||
untilArray[i] = +untilArray[i]; | ||
} | ||
this.until = moment.utc(untilArray).subtract('m', parseMinutes(untilOffset)); | ||
offset : function (mom) { | ||
return this.offsets[this._index(mom)]; | ||
} | ||
}; | ||
Zone.prototype = { | ||
rule : function (mom, lastZone) { | ||
return this.ruleSet.rule(mom, this.offset, lastZone); | ||
}, | ||
/************************************ | ||
Global Methods | ||
************************************/ | ||
lastRule : function () { | ||
return this.rule(this.until); | ||
}, | ||
function normalizeName (name) { | ||
return (name || '').toLowerCase().replace(/\//g, '_'); | ||
} | ||
format : function (rule) { | ||
return this.letters.replace("%s", rule.letters); | ||
} | ||
}; | ||
function addZone (packed) { | ||
var i, zone; | ||
/************************************ | ||
Zone Set | ||
************************************/ | ||
function sortZones (a, b) { | ||
return a.until - b.until; | ||
if (typeof packed === "string") { | ||
packed = [packed]; | ||
} | ||
function ZoneSet (name) { | ||
this.name = normalizeName(name); | ||
this.displayName = name; | ||
this.zones = []; | ||
this.zoneAndRule = memoize(this.zoneAndRule, function (mom) { | ||
return +mom; | ||
}); | ||
for (i = 0; i < packed.length; i++) { | ||
zone = new Zone(packed[i]); | ||
zones[normalizeName(zone.name)] = zone; | ||
} | ||
} | ||
ZoneSet.prototype = { | ||
zoneAndRule : function (mom) { | ||
var i, | ||
zone, | ||
lastZone; | ||
function getZone (name) { | ||
name = normalizeName(name); | ||
var linkName = links[name]; | ||
mom = mom.clone().utc(); | ||
for (i = 0; i < this.zones.length; i++) { | ||
zone = this.zones[i]; | ||
if (mom < zone.until) { | ||
break; | ||
} | ||
lastZone = zone; | ||
} | ||
if (linkName && zones[linkName]) { | ||
name = linkName; | ||
} | ||
return [zone, zone.rule(mom, lastZone)]; | ||
}, | ||
return zones[name] || null; | ||
} | ||
add : function (zone) { | ||
this.zones.push(zone); | ||
this.zones.sort(sortZones); | ||
}, | ||
function getNames () { | ||
var i, out = []; | ||
format : function (mom) { | ||
var zoneAndRule = this.zoneAndRule(mom); | ||
return zoneAndRule[0].format(zoneAndRule[1]); | ||
}, | ||
offset : function (mom) { | ||
var zoneAndRule = this.zoneAndRule(mom); | ||
return -(zoneAndRule[0].offset + zoneAndRule[1].offset); | ||
for (i in zones) { | ||
if (zones.hasOwnProperty(i) && zones[i]) { | ||
out.push(zones[i].name); | ||
} | ||
}; | ||
/************************************ | ||
Global Methods | ||
************************************/ | ||
function memoize (fn, keyFn) { | ||
var cache = {}; | ||
return function (first) { | ||
var key = keyFn ? keyFn.apply(this, arguments) : first; | ||
return key in cache ? | ||
cache[key] : | ||
(cache[key] = fn.apply(this, arguments)); | ||
}; | ||
} | ||
function addRules (rules) { | ||
var i, j, rule; | ||
for (i in rules) { | ||
rule = rules[i]; | ||
for (j = 0; j < rule.length; j++) { | ||
addRule(i + '\t' + rule[j]); | ||
} | ||
} | ||
} | ||
return out.sort(); | ||
} | ||
function addRule (ruleString) { | ||
// don't duplicate rules | ||
if (rules[ruleString]) { | ||
return rules[ruleString]; | ||
} | ||
function addLink (aliases) { | ||
var i, alias; | ||
var p = ruleString.split(/\s/), | ||
name = normalizeName(p[0]), | ||
rule = new Rule(name, p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10]); | ||
// cache the rule so we don't add it again | ||
rules[ruleString] = rule; | ||
// add to the ruleset | ||
getRuleSet(name).add(rule); | ||
return rule; | ||
if (typeof aliases === "string") { | ||
aliases = [aliases]; | ||
} | ||
function normalizeName (name) { | ||
return (name || '').toLowerCase().replace(/\//g, '_'); | ||
for (i = 0; i < aliases.length; i++) { | ||
alias = normalizeName(aliases[i]).split('|'); | ||
links[alias[0]] = alias[1]; | ||
links[alias[1]] = alias[0]; | ||
} | ||
} | ||
function addZones (zones) { | ||
var i, j, zone; | ||
for (i in zones) { | ||
zone = zones[i]; | ||
for (j = 0; j < zone.length; j++) { | ||
addZone(i + '\t' + zone[j]); | ||
} | ||
} | ||
} | ||
function loadData (data) { | ||
addZone(data.zones); | ||
addLink(data.links); | ||
tz.dataVersion = data.version; | ||
} | ||
function addLinks (linksToAdd) { | ||
var i; | ||
for (i in linksToAdd) { | ||
links[normalizeName(i)] = normalizeName(linksToAdd[i]); | ||
function zoneExists (name) { | ||
if (!zoneExists.didShowError) { | ||
zoneExists.didShowError = true; | ||
if (typeof console !== 'undefined' && typeof console.error === 'function') { | ||
console.error("moment.tz.zoneExists('" + name + "') has been deprecated in favor of !moment.tz.zone('" + name + "')"); | ||
} | ||
} | ||
return !!getZone(name); | ||
} | ||
function addZone (zoneString) { | ||
// don't duplicate zones | ||
if (zones[zoneString]) { | ||
return zones[zoneString]; | ||
} | ||
function needsOffset (m) { | ||
return !!(m._a && (m._tzm === undefined)); | ||
} | ||
var p = zoneString.split(/\s/), | ||
name = normalizeName(p[0]), | ||
zone = new Zone(name, p[1], getRuleSet(p[2]), p[3], p[4], p[5]); | ||
/************************************ | ||
moment.tz namespace | ||
************************************/ | ||
// cache the zone so we don't add it again | ||
zones[zoneString] = zone; | ||
function tz () { | ||
var args = Array.prototype.slice.call(arguments, 0, -1), | ||
name = arguments[arguments.length - 1], | ||
zone = getZone(name), | ||
out = moment.utc.apply(null, args); | ||
// add to the zoneset | ||
getZoneSet(p[0]).add(zone); | ||
return zone; | ||
if (zone && needsOffset(out)) { | ||
out.add('minutes', zone.parse(out)); | ||
} | ||
function getRuleSet (name) { | ||
name = normalizeName(name); | ||
if (!ruleSets[name]) { | ||
ruleSets[name] = new RuleSet(name); | ||
} | ||
return ruleSets[name]; | ||
} | ||
out.tz(name); | ||
function getZoneSet (name) { | ||
var machineName = normalizeName(name); | ||
if (links[machineName]) { | ||
machineName = links[machineName]; | ||
} | ||
if (!zoneSets[machineName]) { | ||
zoneSets[machineName] = new ZoneSet(name); | ||
} | ||
return zoneSets[machineName]; | ||
} | ||
return out; | ||
} | ||
function add (data) { | ||
if (!data) { | ||
return; | ||
} | ||
if (data.zones) { | ||
addZones(data.zones); | ||
} | ||
if (data.rules) { | ||
addRules(data.rules); | ||
} | ||
if (data.links) { | ||
addLinks(data.links); | ||
} | ||
} | ||
tz.version = VERSION; | ||
tz.dataVersion = ''; | ||
tz._zones = zones; | ||
tz._links = links; | ||
tz.add = addZone; | ||
tz.link = addLink; | ||
tz.load = loadData; | ||
tz.zone = getZone; | ||
tz.zoneExists = zoneExists; // deprecated in 0.1.0 | ||
tz.names = getNames; | ||
tz.Zone = Zone; | ||
tz.unpack = unpack; | ||
tz.unpackBase60 = unpackBase60; | ||
tz.needsOffset = needsOffset; | ||
// overwrite moment.updateOffset | ||
moment.updateOffset = function (mom, keepTime) { | ||
var offset; | ||
if (mom._z) { | ||
offset = mom._z.offset(mom); | ||
if (Math.abs(offset) < 16) { | ||
offset = offset / 60; | ||
} | ||
mom.zone(offset, keepTime); | ||
} | ||
}; | ||
/************************************ | ||
Interface with Moment.js | ||
************************************/ | ||
function getZoneSets() { | ||
var sets = [], | ||
zoneName; | ||
for (zoneName in zoneSets) { | ||
sets.push(zoneSets[zoneName]); | ||
var fn = moment.fn; | ||
moment.tz = tz; | ||
moment.updateOffset = function (mom, keepTime) { | ||
var offset; | ||
if (mom._z) { | ||
offset = mom._z.offset(mom); | ||
if (Math.abs(offset) < 16) { | ||
offset = offset / 60; | ||
} | ||
return sets; | ||
mom.zone(offset, keepTime); | ||
} | ||
}; | ||
moment.fn.tz = function (name) { | ||
if (name) { | ||
this._z = getZoneSet(name); | ||
if (this._z) { | ||
moment.updateOffset(this); | ||
} | ||
return this; | ||
} | ||
fn.tz = function (name) { | ||
if (name) { | ||
this._z = getZone(name); | ||
if (this._z) { | ||
return this._z.displayName; | ||
moment.updateOffset(this); | ||
} | ||
}; | ||
return this; | ||
} | ||
if (this._z) { return this._z.name; } | ||
}; | ||
moment.fn.zoneName = function () { | ||
if (this._z) { | ||
return this._z.format(this); | ||
} | ||
return oldZoneName.call(this); | ||
function abbrWrap (old) { | ||
return function () { | ||
if (this._z) { return this._z.abbr(this); } | ||
return old.call(this); | ||
}; | ||
} | ||
moment.fn.zoneAbbr = function () { | ||
if (this._z) { | ||
return this._z.format(this); | ||
} | ||
return oldZoneAbbr.call(this); | ||
function resetZoneWrap (old) { | ||
return function () { | ||
this._z = null; | ||
return old.call(this); | ||
}; | ||
} | ||
// Make sure moment's clone includes the newly added properties | ||
moment.momentProperties._z = null; | ||
fn.zoneName = abbrWrap(fn.zoneName); | ||
fn.zoneAbbr = abbrWrap(fn.zoneAbbr); | ||
fn.utc = resetZoneWrap(fn.utc); | ||
moment.tz = function () { | ||
var args = [], i, len = arguments.length - 1; | ||
for (i = 0; i < len; i++) { | ||
args[i] = arguments[i]; | ||
} | ||
var m = moment.apply(null, args); | ||
var preTzOffset = m.zone(); | ||
m.tz(arguments[len]); | ||
return m.add('minutes', m.zone() - preTzOffset); | ||
}; | ||
// Cloning a moment should include the _z property. | ||
moment.momentProperties._z = null; | ||
moment.tz.add = add; | ||
moment.tz.addRule = addRule; | ||
moment.tz.addZone = addZone; | ||
moment.tz.zones = getZoneSets; | ||
// INJECT DATA | ||
moment.tz.version = VERSION; | ||
moment.tz.zoneExists = function (name) { | ||
return getZoneSet(name).zones.length > 0; | ||
}; | ||
// add default rule | ||
defaultRule = addRule("- 0 9999 0 0 0 0 0 0"); | ||
return moment; | ||
} | ||
if (typeof define === "function" && define.amd) { | ||
define("moment-timezone", ["moment"], onload); | ||
} else if (typeof module !== 'undefined') { | ||
module.exports = onload(require('moment')); | ||
} else if (typeof window !== "undefined" && window.moment) { | ||
onload(window.moment); | ||
} | ||
}).apply(this); | ||
return moment; | ||
})); |
{ | ||
"name": "moment-timezone", | ||
"version": "0.0.6", | ||
"description": "Timezone plugin for Moment.js.", | ||
"homepage": "http://momentjs.com", | ||
"version": "0.1.0", | ||
"description": "Parse and display moments in any timezone.", | ||
"homepage": "http://momentjs.com/timezone/", | ||
"author": "Tim Wood <washwithcare@gmail.com> (http://timwoodcreates.com/)", | ||
@@ -13,2 +13,4 @@ "keywords": [ | ||
"olson", | ||
"iana", | ||
"zone", | ||
"tz" | ||
@@ -22,12 +24,8 @@ ], | ||
"type": "git", | ||
"url": "https://github.com/timrwood/moment-timezone.git" | ||
"url": "https://github.com/moment/moment-timezone.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/timrwood/moment-timezone/issues" | ||
"url": "https://github.com/moment/moment-timezone/issues" | ||
}, | ||
"licenses" : [ | ||
{ | ||
"type" : "MIT" | ||
} | ||
], | ||
"license" : "MIT", | ||
"dependencies" : { | ||
@@ -38,2 +36,3 @@ "moment" : ">= 2.6.0" | ||
"grunt" : "0.4.4", | ||
"grunt-contrib-clean" : "0.5.0", | ||
"grunt-contrib-nodeunit" : "0.3.3", | ||
@@ -40,0 +39,0 @@ "grunt-contrib-jshint" : "0.10.0", |
@@ -1,51 +0,34 @@ | ||
moment-timezone | ||
=============== | ||
# [Moment Timezone](http://momentjs.com/timezone) | ||
[![Build Status](https://travis-ci.org/moment/moment-timezone.png)](https://travis-ci.org/moment/moment-timezone) | ||
[![NPM version][npm-version-image]][npm-url] [![NPM downloads][npm-downloads-image]][npm-url] [![MIT License][license-image]][license-url] [![Build Status][travis-image]][travis-url] | ||
Timezone information for moment.js. | ||
IANA Time Zone Database + [Moment.js](http://momentjs.com). | ||
## After cloning repo | ||
```js | ||
var june = moment("2014-06-01T12:00:00Z"); | ||
june.tz('America/Los_Angeles').format('ha z'); // 5am PDT | ||
june.tz('America/New_York').format('ha z'); // 8am EDT | ||
june.tz('Asia/Tokyo').format('ha z'); // 9pm JST | ||
june.tz('Australia/Sydney').format('ha z'); // 10pm EST | ||
var dec = moment("2014-12-01T12:00:00Z"); | ||
dec.tz('America/Los_Angeles').format('ha z'); // 4am PST | ||
dec.tz('America/New_York').format('ha z'); // 7am EST | ||
dec.tz('Asia/Tokyo').format('ha z'); // 9pm JST | ||
dec.tz('Australia/Sydney').format('ha z'); // 11pm EST | ||
``` | ||
git submodule update --init | ||
``` | ||
## Updating timezone info | ||
#### [Contribute code or compile time zone data](contributing.md) | ||
``` | ||
git submodule update | ||
#### [Read the changelog](changelog.md) | ||
sudo zic tz/africa | ||
sudo zic tz/antarctica | ||
sudo zic tz/asia | ||
sudo zic tz/australasia | ||
sudo zic tz/europe | ||
sudo zic tz/northamerica | ||
sudo zic tz/southamerica | ||
grunt zdump | ||
grunt zones | ||
[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat | ||
[license-url]: LICENSE | ||
grunt test | ||
``` | ||
[npm-url]: https://npmjs.org/package/moment-timezone | ||
[npm-version-image]: http://img.shields.io/npm/v/moment-timezone.svg?style=flat | ||
[npm-downloads-image]: http://img.shields.io/npm/dm/moment-timezone.svg?style=flat | ||
## changelog | ||
### 0.0.6 | ||
* fix double loading issue introduced in 0.0.5 | ||
### 0.0.5 | ||
* [#39](https://github.com/moment/moment-timezone/issues/39) improve performance with memoize | ||
* [#46](https://github.com/moment/moment-timezone/issues/46) publish only necessary files to npm | ||
* [#53](https://github.com/moment/moment-timezone/issues/53), [#61](https://github.com/moment/moment-timezone/issues/61), [#70](https://github.com/moment/moment-timezone/issues/70), better handling of timezones around DST | ||
* [#41](https://github.com/moment/moment-timezone/issues/41) support browserify | ||
* [#71](https://github.com/moment/moment-timezone/issues/71) fix cloning zone-d moments | ||
* [#73](https://github.com/moment/moment-timezone/issues/73) add moment.tz.zoneExists method | ||
* [#74](https://github.com/moment/moment-timezone/issues/74) prevent double loading | ||
### 0.0.3 | ||
* added bower support | ||
* support newer versions of moment | ||
* construction with string and zone respects zone | ||
* added more links and timezone names in moment-timezone.json | ||
[travis-url]: http://travis-ci.org/moment/moment-timezone | ||
[travis-image]: http://img.shields.io/travis/moment/moment-timezone/develop.svg?style=flat |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1
2334438
5
11
127643
35
1