Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-time-format

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-time-format - npm Package Compare versions

Comparing version 2.1.3 to 2.2.0

65

dist/d3-time-format.js

@@ -1,7 +0,7 @@

// https://d3js.org/d3-time-format/ v2.1.3 Copyright 2018 Mike Bostock
// https://d3js.org/d3-time-format/ v2.2.0 Copyright 2019 Mike Bostock
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-time')) :
typeof define === 'function' && define.amd ? define(['exports', 'd3-time'], factory) :
(factory((global.d3 = global.d3 || {}),global.d3));
}(this, (function (exports,d3Time) { 'use strict';
(global = global || self, factory(global.d3 = global.d3 || {}, global.d3));
}(this, function (exports, d3Time) { 'use strict';

@@ -26,4 +26,4 @@ function localDate(d) {

function newYear(y) {
return {y: y, m: 0, d: 1, H: 0, M: 0, S: 0, L: 0};
function newDate(y, m, d) {
return {y: y, m: m, d: d, H: 0, M: 0, S: 0, L: 0};
}

@@ -68,2 +68,3 @@

"p": formatPeriod,
"q": formatQuarter,
"Q": formatUnixTimestamp,

@@ -101,2 +102,3 @@ "s": formatUnixTimestampSeconds,

"p": formatUTCPeriod,
"q": formatUTCQuarter,
"Q": formatUnixTimestamp,

@@ -134,2 +136,3 @@ "s": formatUnixTimestampSeconds,

"p": parsePeriod,
"q": parseQuarter,
"Q": parseUnixTimestamp,

@@ -187,5 +190,5 @@ "s": parseUnixTimestampSeconds,

function newParse(specifier, newDate) {
function newParse(specifier, Z) {
return function(string) {
var d = newYear(1900),
var d = newDate(1900, undefined, 1),
i = parseSpecifier(d, specifier, string += "", 0),

@@ -197,6 +200,13 @@ week, day;

if ("Q" in d) return new Date(d.Q);
if ("s" in d) return new Date(d.s * 1000 + ("L" in d ? d.L : 0));
// If this is utcParse, never use the local timezone.
if (Z && !("Z" in d)) d.Z = 0;
// The am-pm flag is 0 for AM, and 1 for PM.
if ("p" in d) d.H = d.H % 12 + d.p * 12;
// If the month was not specified, inherit from the quarter.
if (d.m === undefined) d.m = "q" in d ? d.q : 0;
// Convert day-of-week and week-of-year to day-of-year.

@@ -207,3 +217,3 @@ if ("V" in d) {

if ("Z" in d) {
week = utcDate(newYear(d.y)), day = week.getUTCDay();
week = utcDate(newDate(d.y, 0, 1)), day = week.getUTCDay();
week = day > 4 || day === 0 ? d3Time.utcMonday.ceil(week) : d3Time.utcMonday(week);

@@ -215,3 +225,3 @@ week = d3Time.utcDay.offset(week, (d.V - 1) * 7);

} else {
week = newDate(newYear(d.y)), day = week.getDay();
week = localDate(newDate(d.y, 0, 1)), day = week.getDay();
week = day > 4 || day === 0 ? d3Time.timeMonday.ceil(week) : d3Time.timeMonday(week);

@@ -225,3 +235,3 @@ week = d3Time.timeDay.offset(week, (d.V - 1) * 7);

if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0;
day = "Z" in d ? utcDate(newYear(d.y)).getUTCDay() : newDate(newYear(d.y)).getDay();
day = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay();
d.m = 0;

@@ -240,3 +250,3 @@ d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day + 5) % 7 : d.w + d.U * 7 - (day + 6) % 7;

// Otherwise, all fields are in local time.
return newDate(d);
return localDate(d);
};

@@ -324,2 +334,6 @@ }

function formatQuarter(d) {
return 1 + ~~(d.getMonth() / 3);
}
function formatUTCShortWeekday(d) {

@@ -345,2 +359,6 @@ return locale_shortWeekdays[d.getUTCDay()];

function formatUTCQuarter(d) {
return 1 + ~~(d.getUTCMonth() / 3);
}
return {

@@ -353,3 +371,3 @@ format: function(specifier) {

parse: function(specifier) {
var p = newParse(specifier += "", localDate);
var p = newParse(specifier += "", false);
p.toString = function() { return specifier; };

@@ -364,3 +382,3 @@ return p;

utcParse: function(specifier) {
var p = newParse(specifier, utcDate);
var p = newParse(specifier += "", true);
p.toString = function() { return specifier; };

@@ -438,2 +456,7 @@ return p;

function parseQuarter(d, string, i) {
var n = numberRe.exec(string.slice(i, i + 1));
return n ? (d.q = n[0] * 3 - 3, i + n[0].length) : -1;
}
function parseMonthNumber(d, string, i) {

@@ -491,3 +514,3 @@ var n = numberRe.exec(string.slice(i, i + 2));

var n = numberRe.exec(string.slice(i));
return n ? (d.Q = (+n[0]) * 1000, i + n[0].length) : -1;
return n ? (d.s = +n[0], i + n[0].length) : -1;
}

@@ -537,3 +560,3 @@

function formatWeekNumberSunday(d, p) {
return pad(d3Time.timeSunday.count(d3Time.timeYear(d), d), p, 2);
return pad(d3Time.timeSunday.count(d3Time.timeYear(d) - 1, d), p, 2);
}

@@ -552,3 +575,3 @@

function formatWeekNumberMonday(d, p) {
return pad(d3Time.timeMonday.count(d3Time.timeYear(d), d), p, 2);
return pad(d3Time.timeMonday.count(d3Time.timeYear(d) - 1, d), p, 2);
}

@@ -613,3 +636,3 @@

function formatUTCWeekNumberSunday(d, p) {
return pad(d3Time.utcSunday.count(d3Time.utcYear(d), d), p, 2);
return pad(d3Time.utcSunday.count(d3Time.utcYear(d) - 1, d), p, 2);
}

@@ -628,3 +651,3 @@

function formatUTCWeekNumberMonday(d, p) {
return pad(d3Time.utcMonday.count(d3Time.utcYear(d), d), p, 2);
return pad(d3Time.utcMonday.count(d3Time.utcYear(d) - 1, d), p, 2);
}

@@ -697,9 +720,9 @@

exports.isoFormat = formatIso;
exports.isoParse = parseIso;
exports.timeFormatDefaultLocale = defaultLocale;
exports.timeFormatLocale = formatLocale;
exports.isoFormat = formatIso;
exports.isoParse = parseIso;
Object.defineProperty(exports, '__esModule', { value: true });
})));
}));

@@ -1,2 +0,2 @@

// https://d3js.org/d3-time-format/ v2.1.3 Copyright 2018 Mike Bostock
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-time")):"function"==typeof define&&define.amd?define(["exports","d3-time"],t):t(e.d3=e.d3||{},e.d3)}(this,function(e,t){"use strict";function n(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function r(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function u(e){return{y:e,m:0,d:1,H:0,M:0,S:0,L:0}}function c(e){var c=e.dateTime,i=e.date,a=e.time,f=e.periods,l=e.days,s=e.shortDays,g=e.months,ve=e.shortMonths,Me=y(f),Te=d(f),De=y(l),Ce=d(l),xe=y(s),Ue=d(s),pe=y(g),we=d(g),Se=y(ve),Ye=d(ve),Fe={a:function(e){return s[e.getDay()]},A:function(e){return l[e.getDay()]},b:function(e){return ve[e.getMonth()]},B:function(e){return g[e.getMonth()]},c:null,d:W,e:W,f:I,H:V,I:j,j:P,L:Q,m:J,M:O,p:function(e){return f[+(e.getHours()>=12)]},Q:he,s:me,S:X,u:N,U:B,V:_,w:$,W:q,x:null,X:null,y:z,Y:E,Z:R,"%":de},He={a:function(e){return s[e.getUTCDay()]},A:function(e){return l[e.getUTCDay()]},b:function(e){return ve[e.getUTCMonth()]},B:function(e){return g[e.getUTCMonth()]},c:null,d:k,e:k,f:ne,H:G,I:K,j:ee,L:te,m:re,M:ue,p:function(e){return f[+(e.getUTCHours()>=12)]},Q:he,s:me,S:ce,u:ie,U:oe,V:ae,w:fe,W:le,x:null,X:null,y:se,Y:ge,Z:ye,"%":de},Le={a:function(e,t,n){var r=xe.exec(t.slice(n));return r?(e.w=Ue[r[0].toLowerCase()],n+r[0].length):-1},A:function(e,t,n){var r=De.exec(t.slice(n));return r?(e.w=Ce[r[0].toLowerCase()],n+r[0].length):-1},b:function(e,t,n){var r=Se.exec(t.slice(n));return r?(e.m=Ye[r[0].toLowerCase()],n+r[0].length):-1},B:function(e,t,n){var r=pe.exec(t.slice(n));return r?(e.m=we[r[0].toLowerCase()],n+r[0].length):-1},c:function(e,t,n){return be(e,c,t,n)},d:p,e:p,f:L,H:S,I:S,j:w,L:H,m:U,M:Y,p:function(e,t,n){var r=Me.exec(t.slice(n));return r?(e.p=Te[r[0].toLowerCase()],n+r[0].length):-1},Q:Z,s:b,S:F,u:m,U:v,V:M,w:h,W:T,x:function(e,t,n){return be(e,i,t,n)},X:function(e,t,n){return be(e,a,t,n)},y:C,Y:D,Z:x,"%":A};function Ae(e,t){return function(n){var r,u,c,i=[],a=-1,f=0,l=e.length;for(n instanceof Date||(n=new Date(+n));++a<l;)37===e.charCodeAt(a)&&(i.push(e.slice(f,a)),null!=(u=o[r=e.charAt(++a)])?r=e.charAt(++a):u="e"===r?" ":"0",(c=t[r])&&(r=c(n,u)),i.push(r),f=a+1);return i.push(e.slice(f,a)),i.join("")}}function Ze(e,n){return function(c){var i,o,a=u(1900);if(be(a,e,c+="",0)!=c.length)return null;if("Q"in a)return new Date(a.Q);if("p"in a&&(a.H=a.H%12+12*a.p),"V"in a){if(a.V<1||a.V>53)return null;"w"in a||(a.w=1),"Z"in a?(o=(i=r(u(a.y))).getUTCDay(),i=o>4||0===o?t.utcMonday.ceil(i):t.utcMonday(i),i=t.utcDay.offset(i,7*(a.V-1)),a.y=i.getUTCFullYear(),a.m=i.getUTCMonth(),a.d=i.getUTCDate()+(a.w+6)%7):(o=(i=n(u(a.y))).getDay(),i=o>4||0===o?t.timeMonday.ceil(i):t.timeMonday(i),i=t.timeDay.offset(i,7*(a.V-1)),a.y=i.getFullYear(),a.m=i.getMonth(),a.d=i.getDate()+(a.w+6)%7)}else("W"in a||"U"in a)&&("w"in a||(a.w="u"in a?a.u%7:"W"in a?1:0),o="Z"in a?r(u(a.y)).getUTCDay():n(u(a.y)).getDay(),a.m=0,a.d="W"in a?(a.w+6)%7+7*a.W-(o+5)%7:a.w+7*a.U-(o+6)%7);return"Z"in a?(a.H+=a.Z/100|0,a.M+=a.Z%100,r(a)):n(a)}}function be(e,t,n,r){for(var u,c,i=0,a=t.length,f=n.length;i<a;){if(r>=f)return-1;if(37===(u=t.charCodeAt(i++))){if(u=t.charAt(i++),!(c=Le[u in o?t.charAt(i++):u])||(r=c(e,n,r))<0)return-1}else if(u!=n.charCodeAt(r++))return-1}return r}return Fe.x=Ae(i,Fe),Fe.X=Ae(a,Fe),Fe.c=Ae(c,Fe),He.x=Ae(i,He),He.X=Ae(a,He),He.c=Ae(c,He),{format:function(e){var t=Ae(e+="",Fe);return t.toString=function(){return e},t},parse:function(e){var t=Ze(e+="",n);return t.toString=function(){return e},t},utcFormat:function(e){var t=Ae(e+="",He);return t.toString=function(){return e},t},utcParse:function(e){var t=Ze(e,r);return t.toString=function(){return e},t}}}var i,o={"-":"",_:" ",0:"0"},a=/^\s*\d+/,f=/^%/,l=/[\\^$*+?|[\]().{}]/g;function s(e,t,n){var r=e<0?"-":"",u=(r?-e:e)+"",c=u.length;return r+(c<n?new Array(n-c+1).join(t)+u:u)}function g(e){return e.replace(l,"\\$&")}function y(e){return new RegExp("^(?:"+e.map(g).join("|")+")","i")}function d(e){for(var t={},n=-1,r=e.length;++n<r;)t[e[n].toLowerCase()]=n;return t}function h(e,t,n){var r=a.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function m(e,t,n){var r=a.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function v(e,t,n){var r=a.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function M(e,t,n){var r=a.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function T(e,t,n){var r=a.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function D(e,t,n){var r=a.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function C(e,t,n){var r=a.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function x(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function U(e,t,n){var r=a.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function p(e,t,n){var r=a.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function w(e,t,n){var r=a.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function S(e,t,n){var r=a.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function Y(e,t,n){var r=a.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function F(e,t,n){var r=a.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function H(e,t,n){var r=a.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function L(e,t,n){var r=a.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function A(e,t,n){var r=f.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function Z(e,t,n){var r=a.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function b(e,t,n){var r=a.exec(t.slice(n));return r?(e.Q=1e3*+r[0],n+r[0].length):-1}function W(e,t){return s(e.getDate(),t,2)}function V(e,t){return s(e.getHours(),t,2)}function j(e,t){return s(e.getHours()%12||12,t,2)}function P(e,n){return s(1+t.timeDay.count(t.timeYear(e),e),n,3)}function Q(e,t){return s(e.getMilliseconds(),t,3)}function I(e,t){return Q(e,t)+"000"}function J(e,t){return s(e.getMonth()+1,t,2)}function O(e,t){return s(e.getMinutes(),t,2)}function X(e,t){return s(e.getSeconds(),t,2)}function N(e){var t=e.getDay();return 0===t?7:t}function B(e,n){return s(t.timeSunday.count(t.timeYear(e),e),n,2)}function _(e,n){var r=e.getDay();return e=r>=4||0===r?t.timeThursday(e):t.timeThursday.ceil(e),s(t.timeThursday.count(t.timeYear(e),e)+(4===t.timeYear(e).getDay()),n,2)}function $(e){return e.getDay()}function q(e,n){return s(t.timeMonday.count(t.timeYear(e),e),n,2)}function z(e,t){return s(e.getFullYear()%100,t,2)}function E(e,t){return s(e.getFullYear()%1e4,t,4)}function R(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+s(t/60|0,"0",2)+s(t%60,"0",2)}function k(e,t){return s(e.getUTCDate(),t,2)}function G(e,t){return s(e.getUTCHours(),t,2)}function K(e,t){return s(e.getUTCHours()%12||12,t,2)}function ee(e,n){return s(1+t.utcDay.count(t.utcYear(e),e),n,3)}function te(e,t){return s(e.getUTCMilliseconds(),t,3)}function ne(e,t){return te(e,t)+"000"}function re(e,t){return s(e.getUTCMonth()+1,t,2)}function ue(e,t){return s(e.getUTCMinutes(),t,2)}function ce(e,t){return s(e.getUTCSeconds(),t,2)}function ie(e){var t=e.getUTCDay();return 0===t?7:t}function oe(e,n){return s(t.utcSunday.count(t.utcYear(e),e),n,2)}function ae(e,n){var r=e.getUTCDay();return e=r>=4||0===r?t.utcThursday(e):t.utcThursday.ceil(e),s(t.utcThursday.count(t.utcYear(e),e)+(4===t.utcYear(e).getUTCDay()),n,2)}function fe(e){return e.getUTCDay()}function le(e,n){return s(t.utcMonday.count(t.utcYear(e),e),n,2)}function se(e,t){return s(e.getUTCFullYear()%100,t,2)}function ge(e,t){return s(e.getUTCFullYear()%1e4,t,4)}function ye(){return"+0000"}function de(){return"%"}function he(e){return+e}function me(e){return Math.floor(+e/1e3)}function ve(t){return i=c(t),e.timeFormat=i.format,e.timeParse=i.parse,e.utcFormat=i.utcFormat,e.utcParse=i.utcParse,i}ve({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});var Me=Date.prototype.toISOString?function(e){return e.toISOString()}:e.utcFormat("%Y-%m-%dT%H:%M:%S.%LZ");var Te=+new Date("2000-01-01T00:00:00.000Z")?function(e){var t=new Date(e);return isNaN(t)?null:t}:e.utcParse("%Y-%m-%dT%H:%M:%S.%LZ");e.timeFormatDefaultLocale=ve,e.timeFormatLocale=c,e.isoFormat=Me,e.isoParse=Te,Object.defineProperty(e,"__esModule",{value:!0})});
// https://d3js.org/d3-time-format/ v2.2.0 Copyright 2019 Mike Bostock
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("d3-time")):"function"==typeof define&&define.amd?define(["exports","d3-time"],n):n((e=e||self).d3=e.d3||{},e.d3)}(this,function(e,n){"use strict";function t(e){if(0<=e.y&&e.y<100){var n=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return n.setFullYear(e.y),n}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function r(e){if(0<=e.y&&e.y<100){var n=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return n.setUTCFullYear(e.y),n}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function u(e,n,t){return{y:e,m:n,d:t,H:0,M:0,S:0,L:0}}function i(e){var i=e.dateTime,c=e.date,a=e.time,f=e.periods,l=e.days,s=e.shortDays,g=e.months,Me=e.shortMonths,Te=y(f),De=d(f),Ce=y(l),xe=d(l),Ue=y(s),we=d(s),pe=y(g),Se=d(g),Ye=y(Me),Le=d(Me),Fe={a:function(e){return s[e.getDay()]},A:function(e){return l[e.getDay()]},b:function(e){return Me[e.getMonth()]},B:function(e){return g[e.getMonth()]},c:null,d:V,e:V,f:J,H:j,I:P,j:q,L:I,m:O,M:Q,p:function(e){return f[+(e.getHours()>=12)]},q:function(e){return 1+~~(e.getMonth()/3)},Q:me,s:ve,S:X,u:N,U:B,V:_,w:$,W:z,x:null,X:null,y:E,Y:R,Z:k,"%":he},He={a:function(e){return s[e.getUTCDay()]},A:function(e){return l[e.getUTCDay()]},b:function(e){return Me[e.getUTCMonth()]},B:function(e){return g[e.getUTCMonth()]},c:null,d:G,e:G,f:re,H:K,I:ee,j:ne,L:te,m:ue,M:ie,p:function(e){return f[+(e.getUTCHours()>=12)]},q:function(e){return 1+~~(e.getUTCMonth()/3)},Q:me,s:ve,S:ce,u:oe,U:ae,V:fe,w:le,W:se,x:null,X:null,y:ge,Y:ye,Z:de,"%":he},Ae={a:function(e,n,t){var r=Ue.exec(n.slice(t));return r?(e.w=we[r[0].toLowerCase()],t+r[0].length):-1},A:function(e,n,t){var r=Ce.exec(n.slice(t));return r?(e.w=xe[r[0].toLowerCase()],t+r[0].length):-1},b:function(e,n,t){var r=Ye.exec(n.slice(t));return r?(e.m=Le[r[0].toLowerCase()],t+r[0].length):-1},B:function(e,n,t){var r=pe.exec(n.slice(t));return r?(e.m=Se[r[0].toLowerCase()],t+r[0].length):-1},c:function(e,n,t){return We(e,i,n,t)},d:p,e:p,f:A,H:Y,I:Y,j:S,L:H,m:w,M:L,p:function(e,n,t){var r=Te.exec(n.slice(t));return r?(e.p=De[r[0].toLowerCase()],t+r[0].length):-1},q:U,Q:b,s:W,S:F,u:m,U:v,V:M,w:h,W:T,x:function(e,n,t){return We(e,c,n,t)},X:function(e,n,t){return We(e,a,n,t)},y:C,Y:D,Z:x,"%":Z};function Ze(e,n){return function(t){var r,u,i,c=[],a=-1,f=0,l=e.length;for(t instanceof Date||(t=new Date(+t));++a<l;)37===e.charCodeAt(a)&&(c.push(e.slice(f,a)),null!=(u=o[r=e.charAt(++a)])?r=e.charAt(++a):u="e"===r?" ":"0",(i=n[r])&&(r=i(t,u)),c.push(r),f=a+1);return c.push(e.slice(f,a)),c.join("")}}function be(e,i){return function(c){var o,a,f=u(1900,void 0,1);if(We(f,e,c+="",0)!=c.length)return null;if("Q"in f)return new Date(f.Q);if("s"in f)return new Date(1e3*f.s+("L"in f?f.L:0));if(!i||"Z"in f||(f.Z=0),"p"in f&&(f.H=f.H%12+12*f.p),void 0===f.m&&(f.m="q"in f?f.q:0),"V"in f){if(f.V<1||f.V>53)return null;"w"in f||(f.w=1),"Z"in f?(a=(o=r(u(f.y,0,1))).getUTCDay(),o=a>4||0===a?n.utcMonday.ceil(o):n.utcMonday(o),o=n.utcDay.offset(o,7*(f.V-1)),f.y=o.getUTCFullYear(),f.m=o.getUTCMonth(),f.d=o.getUTCDate()+(f.w+6)%7):(a=(o=t(u(f.y,0,1))).getDay(),o=a>4||0===a?n.timeMonday.ceil(o):n.timeMonday(o),o=n.timeDay.offset(o,7*(f.V-1)),f.y=o.getFullYear(),f.m=o.getMonth(),f.d=o.getDate()+(f.w+6)%7)}else("W"in f||"U"in f)&&("w"in f||(f.w="u"in f?f.u%7:"W"in f?1:0),a="Z"in f?r(u(f.y,0,1)).getUTCDay():t(u(f.y,0,1)).getDay(),f.m=0,f.d="W"in f?(f.w+6)%7+7*f.W-(a+5)%7:f.w+7*f.U-(a+6)%7);return"Z"in f?(f.H+=f.Z/100|0,f.M+=f.Z%100,r(f)):t(f)}}function We(e,n,t,r){for(var u,i,c=0,a=n.length,f=t.length;c<a;){if(r>=f)return-1;if(37===(u=n.charCodeAt(c++))){if(u=n.charAt(c++),!(i=Ae[u in o?n.charAt(c++):u])||(r=i(e,t,r))<0)return-1}else if(u!=t.charCodeAt(r++))return-1}return r}return Fe.x=Ze(c,Fe),Fe.X=Ze(a,Fe),Fe.c=Ze(i,Fe),He.x=Ze(c,He),He.X=Ze(a,He),He.c=Ze(i,He),{format:function(e){var n=Ze(e+="",Fe);return n.toString=function(){return e},n},parse:function(e){var n=be(e+="",!1);return n.toString=function(){return e},n},utcFormat:function(e){var n=Ze(e+="",He);return n.toString=function(){return e},n},utcParse:function(e){var n=be(e+="",!0);return n.toString=function(){return e},n}}}var c,o={"-":"",_:" ",0:"0"},a=/^\s*\d+/,f=/^%/,l=/[\\^$*+?|[\]().{}]/g;function s(e,n,t){var r=e<0?"-":"",u=(r?-e:e)+"",i=u.length;return r+(i<t?new Array(t-i+1).join(n)+u:u)}function g(e){return e.replace(l,"\\$&")}function y(e){return new RegExp("^(?:"+e.map(g).join("|")+")","i")}function d(e){for(var n={},t=-1,r=e.length;++t<r;)n[e[t].toLowerCase()]=t;return n}function h(e,n,t){var r=a.exec(n.slice(t,t+1));return r?(e.w=+r[0],t+r[0].length):-1}function m(e,n,t){var r=a.exec(n.slice(t,t+1));return r?(e.u=+r[0],t+r[0].length):-1}function v(e,n,t){var r=a.exec(n.slice(t,t+2));return r?(e.U=+r[0],t+r[0].length):-1}function M(e,n,t){var r=a.exec(n.slice(t,t+2));return r?(e.V=+r[0],t+r[0].length):-1}function T(e,n,t){var r=a.exec(n.slice(t,t+2));return r?(e.W=+r[0],t+r[0].length):-1}function D(e,n,t){var r=a.exec(n.slice(t,t+4));return r?(e.y=+r[0],t+r[0].length):-1}function C(e,n,t){var r=a.exec(n.slice(t,t+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),t+r[0].length):-1}function x(e,n,t){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(n.slice(t,t+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),t+r[0].length):-1}function U(e,n,t){var r=a.exec(n.slice(t,t+1));return r?(e.q=3*r[0]-3,t+r[0].length):-1}function w(e,n,t){var r=a.exec(n.slice(t,t+2));return r?(e.m=r[0]-1,t+r[0].length):-1}function p(e,n,t){var r=a.exec(n.slice(t,t+2));return r?(e.d=+r[0],t+r[0].length):-1}function S(e,n,t){var r=a.exec(n.slice(t,t+3));return r?(e.m=0,e.d=+r[0],t+r[0].length):-1}function Y(e,n,t){var r=a.exec(n.slice(t,t+2));return r?(e.H=+r[0],t+r[0].length):-1}function L(e,n,t){var r=a.exec(n.slice(t,t+2));return r?(e.M=+r[0],t+r[0].length):-1}function F(e,n,t){var r=a.exec(n.slice(t,t+2));return r?(e.S=+r[0],t+r[0].length):-1}function H(e,n,t){var r=a.exec(n.slice(t,t+3));return r?(e.L=+r[0],t+r[0].length):-1}function A(e,n,t){var r=a.exec(n.slice(t,t+6));return r?(e.L=Math.floor(r[0]/1e3),t+r[0].length):-1}function Z(e,n,t){var r=f.exec(n.slice(t,t+1));return r?t+r[0].length:-1}function b(e,n,t){var r=a.exec(n.slice(t));return r?(e.Q=+r[0],t+r[0].length):-1}function W(e,n,t){var r=a.exec(n.slice(t));return r?(e.s=+r[0],t+r[0].length):-1}function V(e,n){return s(e.getDate(),n,2)}function j(e,n){return s(e.getHours(),n,2)}function P(e,n){return s(e.getHours()%12||12,n,2)}function q(e,t){return s(1+n.timeDay.count(n.timeYear(e),e),t,3)}function I(e,n){return s(e.getMilliseconds(),n,3)}function J(e,n){return I(e,n)+"000"}function O(e,n){return s(e.getMonth()+1,n,2)}function Q(e,n){return s(e.getMinutes(),n,2)}function X(e,n){return s(e.getSeconds(),n,2)}function N(e){var n=e.getDay();return 0===n?7:n}function B(e,t){return s(n.timeSunday.count(n.timeYear(e)-1,e),t,2)}function _(e,t){var r=e.getDay();return e=r>=4||0===r?n.timeThursday(e):n.timeThursday.ceil(e),s(n.timeThursday.count(n.timeYear(e),e)+(4===n.timeYear(e).getDay()),t,2)}function $(e){return e.getDay()}function z(e,t){return s(n.timeMonday.count(n.timeYear(e)-1,e),t,2)}function E(e,n){return s(e.getFullYear()%100,n,2)}function R(e,n){return s(e.getFullYear()%1e4,n,4)}function k(e){var n=e.getTimezoneOffset();return(n>0?"-":(n*=-1,"+"))+s(n/60|0,"0",2)+s(n%60,"0",2)}function G(e,n){return s(e.getUTCDate(),n,2)}function K(e,n){return s(e.getUTCHours(),n,2)}function ee(e,n){return s(e.getUTCHours()%12||12,n,2)}function ne(e,t){return s(1+n.utcDay.count(n.utcYear(e),e),t,3)}function te(e,n){return s(e.getUTCMilliseconds(),n,3)}function re(e,n){return te(e,n)+"000"}function ue(e,n){return s(e.getUTCMonth()+1,n,2)}function ie(e,n){return s(e.getUTCMinutes(),n,2)}function ce(e,n){return s(e.getUTCSeconds(),n,2)}function oe(e){var n=e.getUTCDay();return 0===n?7:n}function ae(e,t){return s(n.utcSunday.count(n.utcYear(e)-1,e),t,2)}function fe(e,t){var r=e.getUTCDay();return e=r>=4||0===r?n.utcThursday(e):n.utcThursday.ceil(e),s(n.utcThursday.count(n.utcYear(e),e)+(4===n.utcYear(e).getUTCDay()),t,2)}function le(e){return e.getUTCDay()}function se(e,t){return s(n.utcMonday.count(n.utcYear(e)-1,e),t,2)}function ge(e,n){return s(e.getUTCFullYear()%100,n,2)}function ye(e,n){return s(e.getUTCFullYear()%1e4,n,4)}function de(){return"+0000"}function he(){return"%"}function me(e){return+e}function ve(e){return Math.floor(+e/1e3)}function Me(n){return c=i(n),e.timeFormat=c.format,e.timeParse=c.parse,e.utcFormat=c.utcFormat,e.utcParse=c.utcParse,c}Me({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});var Te=Date.prototype.toISOString?function(e){return e.toISOString()}:e.utcFormat("%Y-%m-%dT%H:%M:%S.%LZ");var De=+new Date("2000-01-01T00:00:00.000Z")?function(e){var n=new Date(e);return isNaN(n)?null:n}:e.utcParse("%Y-%m-%dT%H:%M:%S.%LZ");e.isoFormat=Te,e.isoParse=De,e.timeFormatDefaultLocale=Me,e.timeFormatLocale=i,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "d3-time-format",
"version": "2.1.3",
"version": "2.2.0",
"description": "A JavaScript time formatter and parser inspired by strftime and strptime.",

@@ -27,2 +27,6 @@ "keywords": [

},
"files": [
"dist/**/*.js",
"src/**/*.js"
],
"scripts": {

@@ -37,9 +41,10 @@ "pretest": "rollup -c",

},
"sideEffects": false,
"devDependencies": {
"d3-queue": "3",
"eslint": "5",
"rollup": "0.64",
"rollup-plugin-terser": "1",
"eslint": "6",
"rollup": "1",
"rollup-plugin-terser": "5",
"tape": "4"
}
}

@@ -44,3 +44,3 @@ # d3-time-format

If you use NPM, `npm install d3-time-format`. Otherwise, download the [latest release](https://github.com/d3/d3-time-format/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-time-format.v2.min.js) or as part of [D3 4.0](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:
If you use NPM, `npm install d3-time-format`. Otherwise, download the [latest release](https://github.com/d3/d3-time-format/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-time-format.v2.min.js) or as part of [D3](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:

@@ -57,6 +57,6 @@ ```html

Locale files are hosted on [unpkg](https://unpkg.com/) and can be loaded using [d3.json](https://github.com/d3/d3-request/blob/master/README.md#json). For example, to set Russian as the default locale:
Locale files are published to npm and can be loaded using [d3.json](https://github.com/d3/d3-request/blob/master/README.md#json). For example, to set Russian as the default locale:
```js
d3.json("https://unpkg.com/d3-time-format@2/locale/ru-RU.json", function(error, locale) {
d3.json("https://cdn.jsdelivr.net/npm/d3-time-format@2/locale/ru-RU.json", function(error, locale) {
if (error) throw error;

@@ -72,4 +72,2 @@

[Try d3-time-format in your browser.](https://tonicdev.com/npm/d3-time-format)
## API Reference

@@ -124,2 +122,3 @@

* `%p` - either AM or PM.*
* `%q` - quarter of the year as a decimal number [1,4].
* `%Q` - milliseconds since UNIX epoch.

@@ -136,3 +135,3 @@ * `%s` - seconds since UNIX epoch.

* `%y` - year without century as a decimal number [00,99].
* `%Y` - year with century as a decimal number.
* `%Y` - year with century as a decimal number, such as `1999`.
* `%Z` - time zone offset, such as `-0700`, `-07:00`, `-07`, or `Z`.

@@ -139,0 +138,0 @@ * `%%` - a literal percent sign (`%`).

@@ -1,2 +0,2 @@

import formatLocale from "./locale";
import formatLocale from "./locale.js";

@@ -3,0 +3,0 @@ var locale;

@@ -1,4 +0,4 @@

export {default as timeFormatDefaultLocale, timeFormat, timeParse, utcFormat, utcParse} from "./defaultLocale";
export {default as timeFormatLocale} from "./locale";
export {default as isoFormat} from "./isoFormat";
export {default as isoParse} from "./isoParse";
export {default as timeFormatDefaultLocale, timeFormat, timeParse, utcFormat, utcParse} from "./defaultLocale.js";
export {default as timeFormatLocale} from "./locale.js";
export {default as isoFormat} from "./isoFormat.js";
export {default as isoParse} from "./isoParse.js";

@@ -1,2 +0,2 @@

import {utcFormat} from "./defaultLocale";
import {utcFormat} from "./defaultLocale.js";

@@ -3,0 +3,0 @@ export var isoSpecifier = "%Y-%m-%dT%H:%M:%S.%LZ";

@@ -1,3 +0,3 @@

import {isoSpecifier} from "./isoFormat";
import {utcParse} from "./defaultLocale";
import {isoSpecifier} from "./isoFormat.js";
import {utcParse} from "./defaultLocale.js";

@@ -4,0 +4,0 @@ function parseIsoNative(string) {

@@ -32,4 +32,4 @@ import {

function newYear(y) {
return {y: y, m: 0, d: 1, H: 0, M: 0, S: 0, L: 0};
function newDate(y, m, d) {
return {y: y, m: m, d: d, H: 0, M: 0, S: 0, L: 0};
}

@@ -74,2 +74,3 @@

"p": formatPeriod,
"q": formatQuarter,
"Q": formatUnixTimestamp,

@@ -107,2 +108,3 @@ "s": formatUnixTimestampSeconds,

"p": formatUTCPeriod,
"q": formatUTCQuarter,
"Q": formatUnixTimestamp,

@@ -140,2 +142,3 @@ "s": formatUnixTimestampSeconds,

"p": parsePeriod,
"q": parseQuarter,
"Q": parseUnixTimestamp,

@@ -193,5 +196,5 @@ "s": parseUnixTimestampSeconds,

function newParse(specifier, newDate) {
function newParse(specifier, Z) {
return function(string) {
var d = newYear(1900),
var d = newDate(1900, undefined, 1),
i = parseSpecifier(d, specifier, string += "", 0),

@@ -203,6 +206,13 @@ week, day;

if ("Q" in d) return new Date(d.Q);
if ("s" in d) return new Date(d.s * 1000 + ("L" in d ? d.L : 0));
// If this is utcParse, never use the local timezone.
if (Z && !("Z" in d)) d.Z = 0;
// The am-pm flag is 0 for AM, and 1 for PM.
if ("p" in d) d.H = d.H % 12 + d.p * 12;
// If the month was not specified, inherit from the quarter.
if (d.m === undefined) d.m = "q" in d ? d.q : 0;
// Convert day-of-week and week-of-year to day-of-year.

@@ -213,3 +223,3 @@ if ("V" in d) {

if ("Z" in d) {
week = utcDate(newYear(d.y)), day = week.getUTCDay();
week = utcDate(newDate(d.y, 0, 1)), day = week.getUTCDay();
week = day > 4 || day === 0 ? utcMonday.ceil(week) : utcMonday(week);

@@ -221,3 +231,3 @@ week = utcDay.offset(week, (d.V - 1) * 7);

} else {
week = newDate(newYear(d.y)), day = week.getDay();
week = localDate(newDate(d.y, 0, 1)), day = week.getDay();
week = day > 4 || day === 0 ? timeMonday.ceil(week) : timeMonday(week);

@@ -231,3 +241,3 @@ week = timeDay.offset(week, (d.V - 1) * 7);

if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0;
day = "Z" in d ? utcDate(newYear(d.y)).getUTCDay() : newDate(newYear(d.y)).getDay();
day = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay();
d.m = 0;

@@ -246,3 +256,3 @@ d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day + 5) % 7 : d.w + d.U * 7 - (day + 6) % 7;

// Otherwise, all fields are in local time.
return newDate(d);
return localDate(d);
};

@@ -330,2 +340,6 @@ }

function formatQuarter(d) {
return 1 + ~~(d.getMonth() / 3);
}
function formatUTCShortWeekday(d) {

@@ -351,2 +365,6 @@ return locale_shortWeekdays[d.getUTCDay()];

function formatUTCQuarter(d) {
return 1 + ~~(d.getUTCMonth() / 3);
}
return {

@@ -359,3 +377,3 @@ format: function(specifier) {

parse: function(specifier) {
var p = newParse(specifier += "", localDate);
var p = newParse(specifier += "", false);
p.toString = function() { return specifier; };

@@ -370,3 +388,3 @@ return p;

utcParse: function(specifier) {
var p = newParse(specifier, utcDate);
var p = newParse(specifier += "", true);
p.toString = function() { return specifier; };

@@ -444,2 +462,7 @@ return p;

function parseQuarter(d, string, i) {
var n = numberRe.exec(string.slice(i, i + 1));
return n ? (d.q = n[0] * 3 - 3, i + n[0].length) : -1;
}
function parseMonthNumber(d, string, i) {

@@ -497,3 +520,3 @@ var n = numberRe.exec(string.slice(i, i + 2));

var n = numberRe.exec(string.slice(i));
return n ? (d.Q = (+n[0]) * 1000, i + n[0].length) : -1;
return n ? (d.s = +n[0], i + n[0].length) : -1;
}

@@ -543,3 +566,3 @@

function formatWeekNumberSunday(d, p) {
return pad(timeSunday.count(timeYear(d), d), p, 2);
return pad(timeSunday.count(timeYear(d) - 1, d), p, 2);
}

@@ -558,3 +581,3 @@

function formatWeekNumberMonday(d, p) {
return pad(timeMonday.count(timeYear(d), d), p, 2);
return pad(timeMonday.count(timeYear(d) - 1, d), p, 2);
}

@@ -619,3 +642,3 @@

function formatUTCWeekNumberSunday(d, p) {
return pad(utcSunday.count(utcYear(d), d), p, 2);
return pad(utcSunday.count(utcYear(d) - 1, d), p, 2);
}

@@ -634,3 +657,3 @@

function formatUTCWeekNumberMonday(d, p) {
return pad(utcMonday.count(utcYear(d), d), p, 2);
return pad(utcMonday.count(utcYear(d) - 1, d), p, 2);
}

@@ -637,0 +660,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc