Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

d3-time-format.js 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. // https://d3js.org/d3-time-format/ v4.1.0 Copyright 2010-2021 Mike Bostock
  2. (function (global, factory) {
  3. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-time')) :
  4. typeof define === 'function' && define.amd ? define(['exports', 'd3-time'], factory) :
  5. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3 = global.d3 || {}, global.d3));
  6. })(this, (function (exports, d3Time) { 'use strict';
  7. function localDate(d) {
  8. if (0 <= d.y && d.y < 100) {
  9. var date = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L);
  10. date.setFullYear(d.y);
  11. return date;
  12. }
  13. return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L);
  14. }
  15. function utcDate(d) {
  16. if (0 <= d.y && d.y < 100) {
  17. var date = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L));
  18. date.setUTCFullYear(d.y);
  19. return date;
  20. }
  21. return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L));
  22. }
  23. function newDate(y, m, d) {
  24. return {y: y, m: m, d: d, H: 0, M: 0, S: 0, L: 0};
  25. }
  26. function formatLocale(locale) {
  27. var locale_dateTime = locale.dateTime,
  28. locale_date = locale.date,
  29. locale_time = locale.time,
  30. locale_periods = locale.periods,
  31. locale_weekdays = locale.days,
  32. locale_shortWeekdays = locale.shortDays,
  33. locale_months = locale.months,
  34. locale_shortMonths = locale.shortMonths;
  35. var periodRe = formatRe(locale_periods),
  36. periodLookup = formatLookup(locale_periods),
  37. weekdayRe = formatRe(locale_weekdays),
  38. weekdayLookup = formatLookup(locale_weekdays),
  39. shortWeekdayRe = formatRe(locale_shortWeekdays),
  40. shortWeekdayLookup = formatLookup(locale_shortWeekdays),
  41. monthRe = formatRe(locale_months),
  42. monthLookup = formatLookup(locale_months),
  43. shortMonthRe = formatRe(locale_shortMonths),
  44. shortMonthLookup = formatLookup(locale_shortMonths);
  45. var formats = {
  46. "a": formatShortWeekday,
  47. "A": formatWeekday,
  48. "b": formatShortMonth,
  49. "B": formatMonth,
  50. "c": null,
  51. "d": formatDayOfMonth,
  52. "e": formatDayOfMonth,
  53. "f": formatMicroseconds,
  54. "g": formatYearISO,
  55. "G": formatFullYearISO,
  56. "H": formatHour24,
  57. "I": formatHour12,
  58. "j": formatDayOfYear,
  59. "L": formatMilliseconds,
  60. "m": formatMonthNumber,
  61. "M": formatMinutes,
  62. "p": formatPeriod,
  63. "q": formatQuarter,
  64. "Q": formatUnixTimestamp,
  65. "s": formatUnixTimestampSeconds,
  66. "S": formatSeconds,
  67. "u": formatWeekdayNumberMonday,
  68. "U": formatWeekNumberSunday,
  69. "V": formatWeekNumberISO,
  70. "w": formatWeekdayNumberSunday,
  71. "W": formatWeekNumberMonday,
  72. "x": null,
  73. "X": null,
  74. "y": formatYear,
  75. "Y": formatFullYear,
  76. "Z": formatZone,
  77. "%": formatLiteralPercent
  78. };
  79. var utcFormats = {
  80. "a": formatUTCShortWeekday,
  81. "A": formatUTCWeekday,
  82. "b": formatUTCShortMonth,
  83. "B": formatUTCMonth,
  84. "c": null,
  85. "d": formatUTCDayOfMonth,
  86. "e": formatUTCDayOfMonth,
  87. "f": formatUTCMicroseconds,
  88. "g": formatUTCYearISO,
  89. "G": formatUTCFullYearISO,
  90. "H": formatUTCHour24,
  91. "I": formatUTCHour12,
  92. "j": formatUTCDayOfYear,
  93. "L": formatUTCMilliseconds,
  94. "m": formatUTCMonthNumber,
  95. "M": formatUTCMinutes,
  96. "p": formatUTCPeriod,
  97. "q": formatUTCQuarter,
  98. "Q": formatUnixTimestamp,
  99. "s": formatUnixTimestampSeconds,
  100. "S": formatUTCSeconds,
  101. "u": formatUTCWeekdayNumberMonday,
  102. "U": formatUTCWeekNumberSunday,
  103. "V": formatUTCWeekNumberISO,
  104. "w": formatUTCWeekdayNumberSunday,
  105. "W": formatUTCWeekNumberMonday,
  106. "x": null,
  107. "X": null,
  108. "y": formatUTCYear,
  109. "Y": formatUTCFullYear,
  110. "Z": formatUTCZone,
  111. "%": formatLiteralPercent
  112. };
  113. var parses = {
  114. "a": parseShortWeekday,
  115. "A": parseWeekday,
  116. "b": parseShortMonth,
  117. "B": parseMonth,
  118. "c": parseLocaleDateTime,
  119. "d": parseDayOfMonth,
  120. "e": parseDayOfMonth,
  121. "f": parseMicroseconds,
  122. "g": parseYear,
  123. "G": parseFullYear,
  124. "H": parseHour24,
  125. "I": parseHour24,
  126. "j": parseDayOfYear,
  127. "L": parseMilliseconds,
  128. "m": parseMonthNumber,
  129. "M": parseMinutes,
  130. "p": parsePeriod,
  131. "q": parseQuarter,
  132. "Q": parseUnixTimestamp,
  133. "s": parseUnixTimestampSeconds,
  134. "S": parseSeconds,
  135. "u": parseWeekdayNumberMonday,
  136. "U": parseWeekNumberSunday,
  137. "V": parseWeekNumberISO,
  138. "w": parseWeekdayNumberSunday,
  139. "W": parseWeekNumberMonday,
  140. "x": parseLocaleDate,
  141. "X": parseLocaleTime,
  142. "y": parseYear,
  143. "Y": parseFullYear,
  144. "Z": parseZone,
  145. "%": parseLiteralPercent
  146. };
  147. // These recursive directive definitions must be deferred.
  148. formats.x = newFormat(locale_date, formats);
  149. formats.X = newFormat(locale_time, formats);
  150. formats.c = newFormat(locale_dateTime, formats);
  151. utcFormats.x = newFormat(locale_date, utcFormats);
  152. utcFormats.X = newFormat(locale_time, utcFormats);
  153. utcFormats.c = newFormat(locale_dateTime, utcFormats);
  154. function newFormat(specifier, formats) {
  155. return function(date) {
  156. var string = [],
  157. i = -1,
  158. j = 0,
  159. n = specifier.length,
  160. c,
  161. pad,
  162. format;
  163. if (!(date instanceof Date)) date = new Date(+date);
  164. while (++i < n) {
  165. if (specifier.charCodeAt(i) === 37) {
  166. string.push(specifier.slice(j, i));
  167. if ((pad = pads[c = specifier.charAt(++i)]) != null) c = specifier.charAt(++i);
  168. else pad = c === "e" ? " " : "0";
  169. if (format = formats[c]) c = format(date, pad);
  170. string.push(c);
  171. j = i + 1;
  172. }
  173. }
  174. string.push(specifier.slice(j, i));
  175. return string.join("");
  176. };
  177. }
  178. function newParse(specifier, Z) {
  179. return function(string) {
  180. var d = newDate(1900, undefined, 1),
  181. i = parseSpecifier(d, specifier, string += "", 0),
  182. week, day;
  183. if (i != string.length) return null;
  184. // If a UNIX timestamp is specified, return it.
  185. if ("Q" in d) return new Date(d.Q);
  186. if ("s" in d) return new Date(d.s * 1000 + ("L" in d ? d.L : 0));
  187. // If this is utcParse, never use the local timezone.
  188. if (Z && !("Z" in d)) d.Z = 0;
  189. // The am-pm flag is 0 for AM, and 1 for PM.
  190. if ("p" in d) d.H = d.H % 12 + d.p * 12;
  191. // If the month was not specified, inherit from the quarter.
  192. if (d.m === undefined) d.m = "q" in d ? d.q : 0;
  193. // Convert day-of-week and week-of-year to day-of-year.
  194. if ("V" in d) {
  195. if (d.V < 1 || d.V > 53) return null;
  196. if (!("w" in d)) d.w = 1;
  197. if ("Z" in d) {
  198. week = utcDate(newDate(d.y, 0, 1)), day = week.getUTCDay();
  199. week = day > 4 || day === 0 ? d3Time.utcMonday.ceil(week) : d3Time.utcMonday(week);
  200. week = d3Time.utcDay.offset(week, (d.V - 1) * 7);
  201. d.y = week.getUTCFullYear();
  202. d.m = week.getUTCMonth();
  203. d.d = week.getUTCDate() + (d.w + 6) % 7;
  204. } else {
  205. week = localDate(newDate(d.y, 0, 1)), day = week.getDay();
  206. week = day > 4 || day === 0 ? d3Time.timeMonday.ceil(week) : d3Time.timeMonday(week);
  207. week = d3Time.timeDay.offset(week, (d.V - 1) * 7);
  208. d.y = week.getFullYear();
  209. d.m = week.getMonth();
  210. d.d = week.getDate() + (d.w + 6) % 7;
  211. }
  212. } else if ("W" in d || "U" in d) {
  213. if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0;
  214. day = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay();
  215. d.m = 0;
  216. d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day + 5) % 7 : d.w + d.U * 7 - (day + 6) % 7;
  217. }
  218. // If a time zone is specified, all fields are interpreted as UTC and then
  219. // offset according to the specified time zone.
  220. if ("Z" in d) {
  221. d.H += d.Z / 100 | 0;
  222. d.M += d.Z % 100;
  223. return utcDate(d);
  224. }
  225. // Otherwise, all fields are in local time.
  226. return localDate(d);
  227. };
  228. }
  229. function parseSpecifier(d, specifier, string, j) {
  230. var i = 0,
  231. n = specifier.length,
  232. m = string.length,
  233. c,
  234. parse;
  235. while (i < n) {
  236. if (j >= m) return -1;
  237. c = specifier.charCodeAt(i++);
  238. if (c === 37) {
  239. c = specifier.charAt(i++);
  240. parse = parses[c in pads ? specifier.charAt(i++) : c];
  241. if (!parse || ((j = parse(d, string, j)) < 0)) return -1;
  242. } else if (c != string.charCodeAt(j++)) {
  243. return -1;
  244. }
  245. }
  246. return j;
  247. }
  248. function parsePeriod(d, string, i) {
  249. var n = periodRe.exec(string.slice(i));
  250. return n ? (d.p = periodLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
  251. }
  252. function parseShortWeekday(d, string, i) {
  253. var n = shortWeekdayRe.exec(string.slice(i));
  254. return n ? (d.w = shortWeekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
  255. }
  256. function parseWeekday(d, string, i) {
  257. var n = weekdayRe.exec(string.slice(i));
  258. return n ? (d.w = weekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
  259. }
  260. function parseShortMonth(d, string, i) {
  261. var n = shortMonthRe.exec(string.slice(i));
  262. return n ? (d.m = shortMonthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
  263. }
  264. function parseMonth(d, string, i) {
  265. var n = monthRe.exec(string.slice(i));
  266. return n ? (d.m = monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
  267. }
  268. function parseLocaleDateTime(d, string, i) {
  269. return parseSpecifier(d, locale_dateTime, string, i);
  270. }
  271. function parseLocaleDate(d, string, i) {
  272. return parseSpecifier(d, locale_date, string, i);
  273. }
  274. function parseLocaleTime(d, string, i) {
  275. return parseSpecifier(d, locale_time, string, i);
  276. }
  277. function formatShortWeekday(d) {
  278. return locale_shortWeekdays[d.getDay()];
  279. }
  280. function formatWeekday(d) {
  281. return locale_weekdays[d.getDay()];
  282. }
  283. function formatShortMonth(d) {
  284. return locale_shortMonths[d.getMonth()];
  285. }
  286. function formatMonth(d) {
  287. return locale_months[d.getMonth()];
  288. }
  289. function formatPeriod(d) {
  290. return locale_periods[+(d.getHours() >= 12)];
  291. }
  292. function formatQuarter(d) {
  293. return 1 + ~~(d.getMonth() / 3);
  294. }
  295. function formatUTCShortWeekday(d) {
  296. return locale_shortWeekdays[d.getUTCDay()];
  297. }
  298. function formatUTCWeekday(d) {
  299. return locale_weekdays[d.getUTCDay()];
  300. }
  301. function formatUTCShortMonth(d) {
  302. return locale_shortMonths[d.getUTCMonth()];
  303. }
  304. function formatUTCMonth(d) {
  305. return locale_months[d.getUTCMonth()];
  306. }
  307. function formatUTCPeriod(d) {
  308. return locale_periods[+(d.getUTCHours() >= 12)];
  309. }
  310. function formatUTCQuarter(d) {
  311. return 1 + ~~(d.getUTCMonth() / 3);
  312. }
  313. return {
  314. format: function(specifier) {
  315. var f = newFormat(specifier += "", formats);
  316. f.toString = function() { return specifier; };
  317. return f;
  318. },
  319. parse: function(specifier) {
  320. var p = newParse(specifier += "", false);
  321. p.toString = function() { return specifier; };
  322. return p;
  323. },
  324. utcFormat: function(specifier) {
  325. var f = newFormat(specifier += "", utcFormats);
  326. f.toString = function() { return specifier; };
  327. return f;
  328. },
  329. utcParse: function(specifier) {
  330. var p = newParse(specifier += "", true);
  331. p.toString = function() { return specifier; };
  332. return p;
  333. }
  334. };
  335. }
  336. var pads = {"-": "", "_": " ", "0": "0"},
  337. numberRe = /^\s*\d+/, // note: ignores next directive
  338. percentRe = /^%/,
  339. requoteRe = /[\\^$*+?|[\]().{}]/g;
  340. function pad(value, fill, width) {
  341. var sign = value < 0 ? "-" : "",
  342. string = (sign ? -value : value) + "",
  343. length = string.length;
  344. return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string);
  345. }
  346. function requote(s) {
  347. return s.replace(requoteRe, "\\$&");
  348. }
  349. function formatRe(names) {
  350. return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i");
  351. }
  352. function formatLookup(names) {
  353. return new Map(names.map((name, i) => [name.toLowerCase(), i]));
  354. }
  355. function parseWeekdayNumberSunday(d, string, i) {
  356. var n = numberRe.exec(string.slice(i, i + 1));
  357. return n ? (d.w = +n[0], i + n[0].length) : -1;
  358. }
  359. function parseWeekdayNumberMonday(d, string, i) {
  360. var n = numberRe.exec(string.slice(i, i + 1));
  361. return n ? (d.u = +n[0], i + n[0].length) : -1;
  362. }
  363. function parseWeekNumberSunday(d, string, i) {
  364. var n = numberRe.exec(string.slice(i, i + 2));
  365. return n ? (d.U = +n[0], i + n[0].length) : -1;
  366. }
  367. function parseWeekNumberISO(d, string, i) {
  368. var n = numberRe.exec(string.slice(i, i + 2));
  369. return n ? (d.V = +n[0], i + n[0].length) : -1;
  370. }
  371. function parseWeekNumberMonday(d, string, i) {
  372. var n = numberRe.exec(string.slice(i, i + 2));
  373. return n ? (d.W = +n[0], i + n[0].length) : -1;
  374. }
  375. function parseFullYear(d, string, i) {
  376. var n = numberRe.exec(string.slice(i, i + 4));
  377. return n ? (d.y = +n[0], i + n[0].length) : -1;
  378. }
  379. function parseYear(d, string, i) {
  380. var n = numberRe.exec(string.slice(i, i + 2));
  381. return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2000), i + n[0].length) : -1;
  382. }
  383. function parseZone(d, string, i) {
  384. var n = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i, i + 6));
  385. return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1;
  386. }
  387. function parseQuarter(d, string, i) {
  388. var n = numberRe.exec(string.slice(i, i + 1));
  389. return n ? (d.q = n[0] * 3 - 3, i + n[0].length) : -1;
  390. }
  391. function parseMonthNumber(d, string, i) {
  392. var n = numberRe.exec(string.slice(i, i + 2));
  393. return n ? (d.m = n[0] - 1, i + n[0].length) : -1;
  394. }
  395. function parseDayOfMonth(d, string, i) {
  396. var n = numberRe.exec(string.slice(i, i + 2));
  397. return n ? (d.d = +n[0], i + n[0].length) : -1;
  398. }
  399. function parseDayOfYear(d, string, i) {
  400. var n = numberRe.exec(string.slice(i, i + 3));
  401. return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1;
  402. }
  403. function parseHour24(d, string, i) {
  404. var n = numberRe.exec(string.slice(i, i + 2));
  405. return n ? (d.H = +n[0], i + n[0].length) : -1;
  406. }
  407. function parseMinutes(d, string, i) {
  408. var n = numberRe.exec(string.slice(i, i + 2));
  409. return n ? (d.M = +n[0], i + n[0].length) : -1;
  410. }
  411. function parseSeconds(d, string, i) {
  412. var n = numberRe.exec(string.slice(i, i + 2));
  413. return n ? (d.S = +n[0], i + n[0].length) : -1;
  414. }
  415. function parseMilliseconds(d, string, i) {
  416. var n = numberRe.exec(string.slice(i, i + 3));
  417. return n ? (d.L = +n[0], i + n[0].length) : -1;
  418. }
  419. function parseMicroseconds(d, string, i) {
  420. var n = numberRe.exec(string.slice(i, i + 6));
  421. return n ? (d.L = Math.floor(n[0] / 1000), i + n[0].length) : -1;
  422. }
  423. function parseLiteralPercent(d, string, i) {
  424. var n = percentRe.exec(string.slice(i, i + 1));
  425. return n ? i + n[0].length : -1;
  426. }
  427. function parseUnixTimestamp(d, string, i) {
  428. var n = numberRe.exec(string.slice(i));
  429. return n ? (d.Q = +n[0], i + n[0].length) : -1;
  430. }
  431. function parseUnixTimestampSeconds(d, string, i) {
  432. var n = numberRe.exec(string.slice(i));
  433. return n ? (d.s = +n[0], i + n[0].length) : -1;
  434. }
  435. function formatDayOfMonth(d, p) {
  436. return pad(d.getDate(), p, 2);
  437. }
  438. function formatHour24(d, p) {
  439. return pad(d.getHours(), p, 2);
  440. }
  441. function formatHour12(d, p) {
  442. return pad(d.getHours() % 12 || 12, p, 2);
  443. }
  444. function formatDayOfYear(d, p) {
  445. return pad(1 + d3Time.timeDay.count(d3Time.timeYear(d), d), p, 3);
  446. }
  447. function formatMilliseconds(d, p) {
  448. return pad(d.getMilliseconds(), p, 3);
  449. }
  450. function formatMicroseconds(d, p) {
  451. return formatMilliseconds(d, p) + "000";
  452. }
  453. function formatMonthNumber(d, p) {
  454. return pad(d.getMonth() + 1, p, 2);
  455. }
  456. function formatMinutes(d, p) {
  457. return pad(d.getMinutes(), p, 2);
  458. }
  459. function formatSeconds(d, p) {
  460. return pad(d.getSeconds(), p, 2);
  461. }
  462. function formatWeekdayNumberMonday(d) {
  463. var day = d.getDay();
  464. return day === 0 ? 7 : day;
  465. }
  466. function formatWeekNumberSunday(d, p) {
  467. return pad(d3Time.timeSunday.count(d3Time.timeYear(d) - 1, d), p, 2);
  468. }
  469. function dISO(d) {
  470. var day = d.getDay();
  471. return (day >= 4 || day === 0) ? d3Time.timeThursday(d) : d3Time.timeThursday.ceil(d);
  472. }
  473. function formatWeekNumberISO(d, p) {
  474. d = dISO(d);
  475. return pad(d3Time.timeThursday.count(d3Time.timeYear(d), d) + (d3Time.timeYear(d).getDay() === 4), p, 2);
  476. }
  477. function formatWeekdayNumberSunday(d) {
  478. return d.getDay();
  479. }
  480. function formatWeekNumberMonday(d, p) {
  481. return pad(d3Time.timeMonday.count(d3Time.timeYear(d) - 1, d), p, 2);
  482. }
  483. function formatYear(d, p) {
  484. return pad(d.getFullYear() % 100, p, 2);
  485. }
  486. function formatYearISO(d, p) {
  487. d = dISO(d);
  488. return pad(d.getFullYear() % 100, p, 2);
  489. }
  490. function formatFullYear(d, p) {
  491. return pad(d.getFullYear() % 10000, p, 4);
  492. }
  493. function formatFullYearISO(d, p) {
  494. var day = d.getDay();
  495. d = (day >= 4 || day === 0) ? d3Time.timeThursday(d) : d3Time.timeThursday.ceil(d);
  496. return pad(d.getFullYear() % 10000, p, 4);
  497. }
  498. function formatZone(d) {
  499. var z = d.getTimezoneOffset();
  500. return (z > 0 ? "-" : (z *= -1, "+"))
  501. + pad(z / 60 | 0, "0", 2)
  502. + pad(z % 60, "0", 2);
  503. }
  504. function formatUTCDayOfMonth(d, p) {
  505. return pad(d.getUTCDate(), p, 2);
  506. }
  507. function formatUTCHour24(d, p) {
  508. return pad(d.getUTCHours(), p, 2);
  509. }
  510. function formatUTCHour12(d, p) {
  511. return pad(d.getUTCHours() % 12 || 12, p, 2);
  512. }
  513. function formatUTCDayOfYear(d, p) {
  514. return pad(1 + d3Time.utcDay.count(d3Time.utcYear(d), d), p, 3);
  515. }
  516. function formatUTCMilliseconds(d, p) {
  517. return pad(d.getUTCMilliseconds(), p, 3);
  518. }
  519. function formatUTCMicroseconds(d, p) {
  520. return formatUTCMilliseconds(d, p) + "000";
  521. }
  522. function formatUTCMonthNumber(d, p) {
  523. return pad(d.getUTCMonth() + 1, p, 2);
  524. }
  525. function formatUTCMinutes(d, p) {
  526. return pad(d.getUTCMinutes(), p, 2);
  527. }
  528. function formatUTCSeconds(d, p) {
  529. return pad(d.getUTCSeconds(), p, 2);
  530. }
  531. function formatUTCWeekdayNumberMonday(d) {
  532. var dow = d.getUTCDay();
  533. return dow === 0 ? 7 : dow;
  534. }
  535. function formatUTCWeekNumberSunday(d, p) {
  536. return pad(d3Time.utcSunday.count(d3Time.utcYear(d) - 1, d), p, 2);
  537. }
  538. function UTCdISO(d) {
  539. var day = d.getUTCDay();
  540. return (day >= 4 || day === 0) ? d3Time.utcThursday(d) : d3Time.utcThursday.ceil(d);
  541. }
  542. function formatUTCWeekNumberISO(d, p) {
  543. d = UTCdISO(d);
  544. return pad(d3Time.utcThursday.count(d3Time.utcYear(d), d) + (d3Time.utcYear(d).getUTCDay() === 4), p, 2);
  545. }
  546. function formatUTCWeekdayNumberSunday(d) {
  547. return d.getUTCDay();
  548. }
  549. function formatUTCWeekNumberMonday(d, p) {
  550. return pad(d3Time.utcMonday.count(d3Time.utcYear(d) - 1, d), p, 2);
  551. }
  552. function formatUTCYear(d, p) {
  553. return pad(d.getUTCFullYear() % 100, p, 2);
  554. }
  555. function formatUTCYearISO(d, p) {
  556. d = UTCdISO(d);
  557. return pad(d.getUTCFullYear() % 100, p, 2);
  558. }
  559. function formatUTCFullYear(d, p) {
  560. return pad(d.getUTCFullYear() % 10000, p, 4);
  561. }
  562. function formatUTCFullYearISO(d, p) {
  563. var day = d.getUTCDay();
  564. d = (day >= 4 || day === 0) ? d3Time.utcThursday(d) : d3Time.utcThursday.ceil(d);
  565. return pad(d.getUTCFullYear() % 10000, p, 4);
  566. }
  567. function formatUTCZone() {
  568. return "+0000";
  569. }
  570. function formatLiteralPercent() {
  571. return "%";
  572. }
  573. function formatUnixTimestamp(d) {
  574. return +d;
  575. }
  576. function formatUnixTimestampSeconds(d) {
  577. return Math.floor(+d / 1000);
  578. }
  579. var locale;
  580. exports.timeFormat = void 0;
  581. exports.timeParse = void 0;
  582. exports.utcFormat = void 0;
  583. exports.utcParse = void 0;
  584. defaultLocale({
  585. dateTime: "%x, %X",
  586. date: "%-m/%-d/%Y",
  587. time: "%-I:%M:%S %p",
  588. periods: ["AM", "PM"],
  589. days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
  590. shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
  591. months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
  592. shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
  593. });
  594. function defaultLocale(definition) {
  595. locale = formatLocale(definition);
  596. exports.timeFormat = locale.format;
  597. exports.timeParse = locale.parse;
  598. exports.utcFormat = locale.utcFormat;
  599. exports.utcParse = locale.utcParse;
  600. return locale;
  601. }
  602. var isoSpecifier = "%Y-%m-%dT%H:%M:%S.%LZ";
  603. function formatIsoNative(date) {
  604. return date.toISOString();
  605. }
  606. var formatIso = Date.prototype.toISOString
  607. ? formatIsoNative
  608. : exports.utcFormat(isoSpecifier);
  609. function parseIsoNative(string) {
  610. var date = new Date(string);
  611. return isNaN(date) ? null : date;
  612. }
  613. var parseIso = +new Date("2000-01-01T00:00:00.000Z")
  614. ? parseIsoNative
  615. : exports.utcParse(isoSpecifier);
  616. exports.isoFormat = formatIso;
  617. exports.isoParse = parseIso;
  618. exports.timeFormatDefaultLocale = defaultLocale;
  619. exports.timeFormatLocale = formatLocale;
  620. Object.defineProperty(exports, '__esModule', { value: true });
  621. }));