{"_id":"@beezeelinx/d3-time-format","name":"@beezeelinx/d3-time-format","dist-tags":{"latest":"3.0.0"},"versions":{"3.0.0":{"name":"@beezeelinx/d3-time-format","version":"3.0.0","description":"A JavaScript time formatter and parser inspired by strftime and strptime.","keywords":["d3","d3-module","time","format","strftime","strptime"],"homepage":"https://d3js.org/d3-time-format/","license":"BSD-3-Clause","author":{"name":"Mike Bostock","url":"http://bost.ocks.org/mike"},"main":"dist/d3-time-format.js","unpkg":"dist/d3-time-format.min.js","jsdelivr":"dist/d3-time-format.min.js","module":"src/index.js","repository":{"type":"git","url":"git+https://github.com/beezeelinx/d3-time-format.git"},"scripts":{"pretest":"rollup -c","test":"TZ=America/Los_Angeles tape 'test/**/*-test.js' && eslint src","no:prepublishOnly":"rm -rf dist && yarn test","no:postpublish":"git push && git push --tags && cd ../d3.github.com && git pull && cp ../${npm_package_name}/dist/${npm_package_name}.js ${npm_package_name}.v${npm_package_version%%.*}.js && cp ../${npm_package_name}/dist/${npm_package_name}.min.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git add ${npm_package_name}.v${npm_package_version%%.*}.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git commit -m \"${npm_package_name} ${npm_package_version}\" && git push && cd - && zip -j dist/${npm_package_name}.zip -- LICENSE README.md dist/${npm_package_name}.js dist/${npm_package_name}.min.js"},"dependencies":{"d3-time":"1 - 2"},"sideEffects":["./src/defaultLocale.js"],"devDependencies":{"eslint":"6","rollup":"1","rollup-plugin-terser":"5","tape":"4"},"gitHead":"3070147d0a131b3808b36cba7ae15e319bce7d17","bugs":{"url":"https://github.com/beezeelinx/d3-time-format/issues"},"_id":"@beezeelinx/d3-time-format@3.0.0","_nodeVersion":"14.18.3","_npmVersion":"6.14.17","dist":{"integrity":"sha512-MuTiH4fx3rHaeEkPh/rJ6Y1zjM49/0DQuc7BdNjXgyxCjSNJ9ep+2iz3MLgsX403gdrNQeQJfd0ntEpAXg+6Uw==","shasum":"545247d5606c74c4726ab6e73874bcb57db04b37","tarball":"https://registry.npmjs.org/@beezeelinx/d3-time-format/-/d3-time-format-3.0.0.tgz","fileCount":41,"unpackedSize":84967,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGnNYn6uVZDOcjlaEyjQ07VuWbueIxkoEw3ppL/rln6fAiEAjrcsfEBU5vW6gySOK1s33goEogkd2xeEzPHimTryJzE="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjtuOAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr28g//QZIdIDztqKnh2Ol3ng16Ia2m5bKdcpvw9e6KG08e9oh1sbPu\r\nL5rZjRHRJAHCJsErxPVIk8m9PsfMWX1MY/82Sgw0DxBRQvgU0GOCIvZbKnWG\r\n6SAavRXYFihpFNDIfKacOMTPPAaZXLTPr8EZmrkSe2HG7GNhO+xSopGcZ3dC\r\nlAvFxgEQiBZYwhd0xJ8NN6i3i8oGiIsrI4XL297AKzpWwo6EdytIZpmkk2le\r\n3JPAfv4d76qkqcLQfXtpwKXnt/uh0Eh4gVIicVQs9Qb7AUSqV6TEX4JET2Jj\r\nevohVulXpvxrvVX3xYY0hBgutI0sKdja25G/aOfx9Wc9DQQcsac5+TP+Vl7o\r\nzgGg4aWOIzbEs9FovTiC0nLArCIM7D//KZf5qr9Ygecussgb+517jD0AaXh8\r\nz99VCGKTaYtZtVXGmHx2PZYvpWHZQAXu2LxiRwdHE0xRMjJe3aP9OVG5QXPD\r\nTjRhpispw8MhDlvk1T4wcV2yBlcoDWem+DNVJqqpJgdCehoqJvOpf4N5MgS7\r\nzNH6eqhESBbP+1zhI1sMtYSbd2LKHgpfIrrISirr0QS4jS5qjDuuYxNP5BtL\r\n4xtYlrsp9fcrRohIWnqFMikx+BTSaZdD4UkEN6Y/eJpAJYtztVuBE1m23I4z\r\n0dalQ/MGXQQC25b41S9SWmURnq9GBVmcS8g=\r\n=3CZq\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"beezeelinx","email":"ips-admin@beezeelinx.com"},"directories":{},"maintainers":[{"name":"beezeelinx","email":"ips-admin@beezeelinx.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/d3-time-format_3.0.0_1672930176071_0.7464132886238461"},"_hasShrinkwrap":false}},"time":{"created":"2023-01-05T14:49:36.014Z","3.0.0":"2023-01-05T14:49:36.236Z","modified":"2023-01-05T14:49:36.360Z"},"maintainers":[{"name":"beezeelinx","email":"ips-admin@beezeelinx.com"}],"description":"A JavaScript time formatter and parser inspired by strftime and strptime.","homepage":"https://d3js.org/d3-time-format/","keywords":["d3","d3-module","time","format","strftime","strptime"],"repository":{"type":"git","url":"git+https://github.com/beezeelinx/d3-time-format.git"},"author":{"name":"Mike Bostock","url":"http://bost.ocks.org/mike"},"bugs":{"url":"https://github.com/beezeelinx/d3-time-format/issues"},"license":"BSD-3-Clause","readme":"# d3-time-format\n\nThis module provides a JavaScript implementation of the venerable [strptime](http://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html) and [strftime](http://pubs.opengroup.org/onlinepubs/007908799/xsh/strftime.html) functions from the C standard library, and can be used to parse or format [dates](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) in a variety of locale-specific representations. To format a date, create a [formatter](#locale_format) from a specifier (a string with the desired format *directives*, indicated by `%`); then pass a date to the formatter, which returns a string. For example, to convert the current date to a human-readable string:\n\n```js\nvar formatTime = d3.timeFormat(\"%B %d, %Y\");\nformatTime(new Date); // \"June 30, 2015\"\n```\n\nLikewise, to convert a string back to a date, create a [parser](#locale_parse):\n\n```js\nvar parseTime = d3.timeParse(\"%B %d, %Y\");\nparseTime(\"June 30, 2015\"); // Tue Jun 30 2015 00:00:00 GMT-0700 (PDT)\n```\n\nYou can implement more elaborate conditional time formats, too. For example, here’s a [multi-scale time format](https://bl.ocks.org/mbostock/4149176) using [time intervals](https://github.com/d3/d3-time):\n\n```js\nvar formatMillisecond = d3.timeFormat(\".%L\"),\n    formatSecond = d3.timeFormat(\":%S\"),\n    formatMinute = d3.timeFormat(\"%I:%M\"),\n    formatHour = d3.timeFormat(\"%I %p\"),\n    formatDay = d3.timeFormat(\"%a %d\"),\n    formatWeek = d3.timeFormat(\"%b %d\"),\n    formatMonth = d3.timeFormat(\"%B\"),\n    formatYear = d3.timeFormat(\"%Y\");\n\nfunction multiFormat(date) {\n  return (d3.timeSecond(date) < date ? formatMillisecond\n      : d3.timeMinute(date) < date ? formatSecond\n      : d3.timeHour(date) < date ? formatMinute\n      : d3.timeDay(date) < date ? formatHour\n      : d3.timeMonth(date) < date ? (d3.timeWeek(date) < date ? formatDay : formatWeek)\n      : d3.timeYear(date) < date ? formatMonth\n      : formatYear)(date);\n}\n```\n\nThis module is used by D3 [time scales](https://github.com/d3/d3-scale/blob/master/README.md#time-scales) to generate human-readable ticks.\n\n## Installing\n\nIf 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:\n\n```html\n<script src=\"https://d3js.org/d3-time.v2.min.js\"></script>\n<script src=\"https://d3js.org/d3-time-format.v3.min.js\"></script>\n<script>\n\nvar format = d3.timeFormat(\"%x\");\n\n</script>\n```\n\nLocale 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:\n\n```js\nd3.json(\"https://cdn.jsdelivr.net/npm/d3-time-format@3/locale/ru-RU.json\", function(error, locale) {\n  if (error) throw error;\n\n  d3.timeFormatDefaultLocale(locale);\n\n  var format = d3.timeFormat(\"%c\");\n\n  console.log(format(new Date)); // понедельник,  5 декабря 2016 г. 10:31:59\n});\n```\n\n## API Reference\n\n<a name=\"timeFormat\" href=\"#timeFormat\">#</a> d3.<b>timeFormat</b>(<i>specifier</i>) · [Source](https://github.com/d3/d3-time-format/blob/master/src/defaultLocale.js)\n\nAn alias for [*locale*.format](#locale_format) on the [default locale](#timeFormatDefaultLocale).\n\n<a name=\"timeParse\" href=\"#timeParse\">#</a> d3.<b>timeParse</b>(<i>specifier</i>) · [Source](https://github.com/d3/d3-time-format/blob/master/src/defaultLocale.js)\n\nAn alias for [*locale*.parse](#locale_parse) on the [default locale](#timeFormatDefaultLocale).\n\n<a name=\"utcFormat\" href=\"#utcFormat\">#</a> d3.<b>utcFormat</b>(<i>specifier</i>) · [Source](https://github.com/d3/d3-time-format/blob/master/src/defaultLocale.js)\n\nAn alias for [*locale*.utcFormat](#locale_utcFormat) on the [default locale](#timeFormatDefaultLocale).\n\n<a name=\"utcParse\" href=\"#utcParse\">#</a> d3.<b>utcParse</b>(<i>specifier</i>) · [Source](https://github.com/d3/d3-time-format/blob/master/src/defaultLocale.js)\n\nAn alias for [*locale*.utcParse](#locale_utcParse) on the [default locale](#timeFormatDefaultLocale).\n\n<a name=\"isoFormat\" href=\"#isoFormat\">#</a> d3.<b>isoFormat</b> · [Source](https://github.com/d3/d3-time-format/blob/master/src/isoFormat.js)\n\nThe full [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) UTC time formatter. Where available, this method will use [Date.toISOString](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toISOString) to format.\n\n<a name=\"isoParse\" href=\"#isoParse\">#</a> d3.<b>isoParse</b> · [Source](https://github.com/d3/d3-time-format/blob/master/src/isoParse.js)\n\nThe full [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) UTC time parser. Where available, this method will use the [Date constructor](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date) to parse strings. If you depend on strict validation of the input format according to ISO 8601, you should construct a [UTC parser function](#utcParse):\n\n```js\nvar strictIsoParse = d3.utcParse(\"%Y-%m-%dT%H:%M:%S.%LZ\");\n```\n\n<a name=\"locale_format\" href=\"#locale_format\">#</a> <i>locale</i>.<b>format</b>(<i>specifier</i>) · [Source](https://github.com/d3/d3-time-format/blob/master/src/locale.js)\n\nReturns a new formatter for the given string *specifier*. The specifier string may contain the following directives:\n\n* `%a` - abbreviated weekday name.*\n* `%A` - full weekday name.*\n* `%b` - abbreviated month name.*\n* `%B` - full month name.*\n* `%c` - the locale’s date and time, such as `%x, %X`.*\n* `%d` - zero-padded day of the month as a decimal number [01,31].\n* `%e` - space-padded day of the month as a decimal number [ 1,31]; equivalent to `%_d`.\n* `%f` - microseconds as a decimal number [000000, 999999].\n* `%g` - ISO 8601 week-based year without century as a decimal number [00,99].\n* `%G` - ISO 8601 week-based year with century as a decimal number.\n* `%H` - hour (24-hour clock) as a decimal number [00,23].\n* `%I` - hour (12-hour clock) as a decimal number [01,12].\n* `%j` - day of the year as a decimal number [001,366].\n* `%m` - month as a decimal number [01,12].\n* `%M` - minute as a decimal number [00,59].\n* `%L` - milliseconds as a decimal number [000, 999].\n* `%p` - either AM or PM.*\n* `%q` - quarter of the year as a decimal number [1,4].\n* `%Q` - milliseconds since UNIX epoch.\n* `%s` - seconds since UNIX epoch.\n* `%S` - second as a decimal number [00,61].\n* `%u` - Monday-based (ISO 8601) weekday as a decimal number [1,7].\n* `%U` - Sunday-based week of the year as a decimal number [00,53].\n* `%V` - ISO 8601 week of the year as a decimal number [01, 53].\n* `%w` - Sunday-based weekday as a decimal number [0,6].\n* `%W` - Monday-based week of the year as a decimal number [00,53].\n* `%x` - the locale’s date, such as `%-m/%-d/%Y`.*\n* `%X` - the locale’s time, such as `%-I:%M:%S %p`.*\n* `%y` - year without century as a decimal number [00,99].\n* `%Y` - year with century as a decimal number, such as `1999`.\n* `%Z` - time zone offset, such as `-0700`, `-07:00`, `-07`, or `Z`.\n* `%%` - a literal percent sign (`%`).\n\nDirectives marked with an asterisk (\\*) may be affected by the [locale definition](#locales).\n\nFor `%U`, all days in a new year preceding the first Sunday are considered to be in week 0. For `%W`, all days in a new year preceding the first Monday are considered to be in week 0. Week numbers are computed using [*interval*.count](https://github.com/d3/d3-time/blob/master/README.md#interval_count). For example, 2015-52 and 2016-00 represent Monday, December 28, 2015, while 2015-53 and 2016-01 represent Monday, January 4, 2016. This differs from the [ISO week date](https://en.wikipedia.org/wiki/ISO_week_date) specification (`%V`), which uses a more complicated definition!\n\nFor `%V`,`%g` and `%G`, per the [strftime man page](http://man7.org/linux/man-pages/man3/strftime.3.html):\n\n> In this system, weeks start on a Monday, and are numbered from 01, for the first week, up to 52 or 53, for the last week.  Week 1 is the first week where four or more days fall within the new year (or, synonymously, week 01 is: the first week of the year that contains a Thursday; or, the week that has 4 January in it). If the ISO week number belongs to the previous or next year, that year is used instead.\n\nThe `%` sign indicating a directive may be immediately followed by a padding modifier:\n\n* `0` - zero-padding\n* `_` - space-padding\n* `-` - disable padding\n\nIf no padding modifier is specified, the default is `0` for all directives except `%e`, which defaults to `_`. (In some implementations of strftime and strptime, a directive may include an optional field width or precision; this feature is not yet implemented.)\n\nThe returned function formats a specified *[date](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date)*, returning the corresponding string.\n\n```js\nvar formatMonth = d3.timeFormat(\"%B\"),\n    formatDay = d3.timeFormat(\"%A\"),\n    date = new Date(2014, 4, 1); // Thu May 01 2014 00:00:00 GMT-0700 (PDT)\n\nformatMonth(date); // \"May\"\nformatDay(date); // \"Thursday\"\n```\n\n<a name=\"locale_parse\" href=\"#locale_parse\">#</a> <i>locale</i>.<b>parse</b>(<i>specifier</i>) · [Source](https://github.com/d3/d3-time-format/blob/master/src/locale.js)\n\nReturns a new parser for the given string *specifier*. The specifier string may contain the same directives as [*locale*.format](#locale_format). The `%d` and `%e` directives are considered equivalent for parsing.\n\nThe returned function parses a specified *string*, returning the corresponding [date](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date) or null if the string could not be parsed according to this format’s specifier. Parsing is strict: if the specified <i>string</i> does not exactly match the associated specifier, this method returns null. For example, if the associated specifier is `%Y-%m-%dT%H:%M:%SZ`, then the string `\"2011-07-01T19:15:28Z\"` will be parsed as expected, but `\"2011-07-01T19:15:28\"`, `\"2011-07-01 19:15:28\"` and `\"2011-07-01\"` will return null. (Note that the literal `Z` here is different from the time zone offset directive `%Z`.) If a more flexible parser is desired, try multiple formats sequentially until one returns non-null.\n\n<a name=\"locale_utcFormat\" href=\"#locale_utcFormat\">#</a> <i>locale</i>.<b>utcFormat</b>(<i>specifier</i>) · [Source](https://github.com/d3/d3-time-format/blob/master/src/locale.js)\n\nEquivalent to [*locale*.format](#locale_format), except all directives are interpreted as [Coordinated Universal Time (UTC)](https://en.wikipedia.org/wiki/Coordinated_Universal_Time) rather than local time.\n\n<a name=\"locale_utcParse\" href=\"#locale_utcParse\">#</a> <i>locale</i>.<b>utcParse</b>(<i>specifier</i>) · [Source](https://github.com/d3/d3-time-format/blob/master/src/locale.js)\n\nEquivalent to [*locale*.parse](#locale_parse), except all directives are interpreted as [Coordinated Universal Time (UTC)](https://en.wikipedia.org/wiki/Coordinated_Universal_Time) rather than local time.\n\n### Locales\n\n<a name=\"timeFormatLocale\" href=\"#timeFormatLocale\">#</a> d3.<b>timeFormatLocale</b>(<i>definition</i>) · [Source](https://github.com/d3/d3-time-format/blob/master/src/locale.js)\n\nReturns a *locale* object for the specified *definition* with [*locale*.format](#locale_format), [*locale*.parse](#locale_parse), [*locale*.utcFormat](#locale_utcFormat), [*locale*.utcParse](#locale_utcParse) methods. The *definition* must include the following properties:\n\n* `dateTime` - the date and time (`%c`) format specifier (<i>e.g.</i>, `\"%a %b %e %X %Y\"`).\n* `date` - the date (`%x`) format specifier (<i>e.g.</i>, `\"%m/%d/%Y\"`).\n* `time` - the time (`%X`) format specifier (<i>e.g.</i>, `\"%H:%M:%S\"`).\n* `periods` - the A.M. and P.M. equivalents (<i>e.g.</i>, `[\"AM\", \"PM\"]`).\n* `days` - the full names of the weekdays, starting with Sunday.\n* `shortDays` - the abbreviated names of the weekdays, starting with Sunday.\n* `months` - the full names of the months (starting with January).\n* `shortMonths` - the abbreviated names of the months (starting with January).\n\nFor an example, see [Localized Time Axis II](https://bl.ocks.org/mbostock/805115ebaa574e771db1875a6d828949).\n\n<a name=\"timeFormatDefaultLocale\" href=\"#timeFormatDefaultLocale\">#</a> d3.<b>timeFormatDefaultLocale</b>(<i>definition</i>) · [Source](https://github.com/d3/d3-time-format/blob/master/src/defaultLocale.js)\n\nEquivalent to [d3.timeFormatLocale](#timeFormatLocale), except it also redefines [d3.timeFormat](#timeFormat), [d3.timeParse](#timeParse), [d3.utcFormat](#utcFormat) and [d3.utcParse](#utcParse) to the new locale’s [*locale*.format](#locale_format), [*locale*.parse](#locale_parse), [*locale*.utcFormat](#locale_utcFormat) and [*locale*.utcParse](#locale_utcParse). If you do not set a default locale, it defaults to [U.S. English](https://github.com/d3/d3-time-format/blob/master/locale/en-US.json).\n\nFor an example, see [Localized Time Axis](https://bl.ocks.org/mbostock/6f1cc065d4d172bcaf322e399aa8d62f).\n","readmeFilename":"README.md"}