{"id":15449061,"url":"https://github.com/hogart/datef","last_synced_at":"2025-04-19T21:39:18.261Z","repository":{"id":4269796,"uuid":"5397517","full_name":"hogart/datef","owner":"hogart","description":"datef is a Javascript date formatting library, both for browser and node.js","archived":false,"fork":false,"pushed_at":"2017-02-02T13:17:46.000Z","size":54,"stargazers_count":37,"open_issues_count":2,"forks_count":4,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-18T16:17:51.425Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hogart.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-08-13T10:14:49.000Z","updated_at":"2023-06-09T11:09:15.000Z","dependencies_parsed_at":"2022-08-29T14:52:02.682Z","dependency_job_id":null,"html_url":"https://github.com/hogart/datef","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hogart%2Fdatef","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hogart%2Fdatef/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hogart%2Fdatef/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hogart%2Fdatef/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hogart","download_url":"https://codeload.github.com/hogart/datef/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249528285,"owners_count":21286386,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T20:42:27.658Z","updated_at":"2025-04-19T21:39:18.242Z","avatar_url":"https://github.com/hogart.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# datef [![NPM version](https://badge.fury.io/js/datef.svg)](http://badge.fury.io/js/datef) [![Build Status](https://travis-ci.org/maxvipon/datef.svg)](https://travis-ci.org/maxvipon/datef) [![Coverage Status](https://coveralls.io/repos/maxvipon/datef/badge.png)](https://coveralls.io/r/maxvipon/datef)\n\n**datef** is a Javascript date formatting library, both for browser and node.js.\n\n## Features\n\n* Can output: year, full year, month, day, hour, minutes, seconds, milliseconds and timezone — both zero padded and not\n* Simple localization\n* Built-in formats and easyly extensible\n* Doesn't mess with built-in prototypes\n* Acts as node.js and requirejs/amd module, and have `.noConflict` method in case no module system is present (e.g. plain browser environment)\n* No external dependencies\n* Contains predefined formats for some ISO8601 date and time representation\n* Thoroughly annotated with jsdoc, so if your IDE/editor supports it, you may never need interrupt yourself from code\n\n## Usage\n\n**Node.js**\n```bash\nnpm install datef\n```\n```js\nvar datef = require('datef');\ndatef('MM.YYYY');\n```\n\n**Require.js**\n```js\nrequire.config({\n    paths: {\n        'datef': 'path/to/datef'\n    }\n})\nrequire(['datef'], function(datef){\n    datef('MM.YYYY');\n});\n```\n\n**Browser**\n```html\n\u003cscript src=\"datef.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    datef('MM.YYYY');\n\u003c/script\u003e\n```\n\n### Basic usage\n\n```js\ndatef('dd.MM.YY', new Date()); // \"13.08.13\"\ndatef('dd.MM.YY'); // second argument is optional; datef takes Date.now() if no date is provided\n\nvar d = new Date();\nd.setFullYear(2045);\ndatef('dd.MM.YYYY', d); // \"13.08.2045\"\n```\n\n### Languages\n\n**Node.js**\n```js\ndatef.lang('ru');\ndatef('dd MMMM'); // 13 августа\n```\n\n**Require.js**\n```js\nrequire.config({\n    paths: {\n        'datef': 'path/to/datef',\n        'datef_ru': 'path/to/datef_lang/ru'\n    }\n})\n\nrequire(['datef', 'datef_ru'], function(datef){\n    datef.lang('ru');\n    datef('dd MMMM'); // 13 августа\n});\n```\n\n**Browser**\n```html\n\u003cscript src=\"datef.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"lang/ru.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    datef.lang('ru');\n    datef('dd MMMM'); // 13 августа\n\u003c/script\u003e\n```\n\n### Custom formatters\n```js\n// predefined formats\ndatef.formatters(); // ['ISODate','ISOTime','ISODateTime','ISODateTimeTZ']\ndatef('ISODateTimeTZ', d); // \"2013-08-13T15:01:29 -04:00\"\n\n// defining your own simple format\ndatef.register('myFormat', 'd.M.YY');\ndatef('myFormat', d); // \"13.8.13\"\n\n// defining your own format with i10n\ndatef.register('myI10nFormat', {\n    'en': 'MMMM dd, DD',\n    'ru': 'DD, dd MMMM',\n    'default': 'dd MMMM'\n});\ndatef('myI10nFormat', d); // \"August 13, Tuesday\"\ndatef.lang('ru');\ndatef('myI10nFormat', d); // \"Вторник, 13 августа\"\ndatef.lang('uk');\ndatef('myI10nFormat', d); // \"13 жніўня\"\n```\n\n### Cleaning global namespace\n\nThis is similar to [`Backbone.noConflict()`](http://backbonejs.org/#Utility-noConflict)\n\n```html\n\u003cscript\u003evar datef = 'My very important data';\u003c/script\u003e\n…\n\u003cscript src=\"datef.js\"\u003e\u003c/script\u003e\n\n\u003cscript\u003e\nconsole.log(typeof datef); // \"function\"\nvar formattingLib = datef.noConflict();\nconsole.log(datef); // 'My very important data'\n\u003c/script\u003e\n```\n\n## Tokens\n\nFull list of tokens possible in format string include:\n\n* **YYYY**: 4-digit year\n* **YY**: last 2 digit of year\n* **MMMM**: full name of month\n* **MMM**: short name of month\n* **MM**: ISO8601-compatible number of month (i.e. zero-padded) in year (with January being 1st month)\n* **M**: number of month in year without zero-padding (with January being 1st month)\n* **DDD**: full name of day\n* **DD**: short name of day\n* **D**: min name of day\n* **dd**: zero-padded number of day in month\n* **d**: number of day in month\n* **HH**: zero-padded 24 hour time\n* **H**: 24 hour time\n* **hh**: zero-padded 12 hour time\n* **h**: 12 hour time\n* **mm**: zero-padded minutes\n* **m**: minutes\n* **ss**: zero-padded seconds\n* **s**: seconds\n* **ff**: zero-padded milliseconds, 3 digits\n* **f**: milliseconds\n* **A**: AM/PM\n* **a**: am/pm\n* **ZZ**: time-zone in ISO8601-compatible basic format (i.e. \"-0400\")\n* **Z**: time-zone in ISO8601-compatible extended format (i.e. \"-04:00\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhogart%2Fdatef","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhogart%2Fdatef","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhogart%2Fdatef/lists"}