{"id":14973424,"url":"https://github.com/eight04/angular-datetime","last_synced_at":"2025-04-13T06:41:42.830Z","repository":{"id":21395671,"uuid":"24713502","full_name":"eight04/angular-datetime","owner":"eight04","description":"A directive to add the behavior of datetime input on unsupported browsers.","archived":false,"fork":false,"pushed_at":"2019-06-05T07:25:50.000Z","size":437,"stargazers_count":92,"open_issues_count":4,"forks_count":28,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-26T09:18:52.225Z","etag":null,"topics":["angular1","angularjs","datetime","ie8","javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eight04.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-02T09:26:07.000Z","updated_at":"2025-03-04T07:54:07.000Z","dependencies_parsed_at":"2022-07-30T04:47:57.008Z","dependency_job_id":null,"html_url":"https://github.com/eight04/angular-datetime","commit_stats":null,"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eight04%2Fangular-datetime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eight04%2Fangular-datetime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eight04%2Fangular-datetime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eight04%2Fangular-datetime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eight04","download_url":"https://codeload.github.com/eight04/angular-datetime/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248675434,"owners_count":21143763,"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":["angular1","angularjs","datetime","ie8","javascript"],"created_at":"2024-09-24T13:48:41.939Z","updated_at":"2025-04-13T06:41:42.810Z","avatar_url":"https://github.com/eight04.png","language":"JavaScript","readme":"angular-datetime\n================\n\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/e65b981268564476bbecb04911e743be)](https://www.codacy.com/app/eight04/angular-datetime?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=eight04/angular-datetime\u0026utm_campaign=badger)\n[![Build Status](https://travis-ci.org/eight04/angular-datetime.svg?branch=master)](https://travis-ci.org/eight04/angular-datetime)\n[![codecov](https://codecov.io/gh/eight04/angular-datetime/branch/master/graph/badge.svg)](https://codecov.io/gh/eight04/angular-datetime)\n\nThis module includes a datetime directive and a parser service.\n\nFeatures\n--------\n* This module includes:\n\t- A directive which can simulate datetime input within a text field.\n\t- A service which can convert a string of date into a Date object, and vice versa.\n* Support IE8. Note that old browsers (including IE8-11) require [babel-polyfill](https://unpkg.com/babel-polyfill@6.23.0/dist/polyfill.js) to be installed.\n\nDependencies\n------------\n\n* Angular 1.2+\n* custom-input 0.2.1 - https://github.com/eight04/custom-input\n\nDate string format\n------------------\nApart from [the formats provided officially](https://docs.angularjs.org/api/ng/filter/date), angular-datetime support some new tokens:\n\n* ZZ - represent timezone with colon (e.g. +08:00)\n\nDemo\n----\n* With Angular 1.2.x: \u003chttps://rawgit.com/eight04/angular-datetime/master/example/demo.html\u003e\n* With Angular 1.5.x: \u003chttps://rawgit.com/eight04/angular-datetime/master/example/demo-1.5.html\u003e\n\nInstallation\n------------\nVia npm:\n\n```shell\nnpm install angular angular-datetime-input --save\n```\n```javascript\nrequire(\"angular-datetime-input\");\n```\n\t\nOr use pre-built dist:\n\n```html\n\u003cscript src=\"https://unpkg.com/angular-datetime-input\"\u003e\u003c/script\u003e\n```\n\nExample\n-------\n### datetime service\n```Javascript\n// Setup dependency\nangular.module(\"myApp\", [\"datetime\"]);\n\n// Use datetime parser\nangular.controller(\"myController\", function(datetime){\n\t// Create a parser\n\tvar parser = datetime(\"yyyy-MM-dd\");\n\n\t// Set to current date\n\tparser.setDate(new Date);\n\tparser.getText();\t// -\u003e \"2015-01-30\"\n\n\t// Parse a date string\n\tparser.parse(\"2015-01-30\");\n\tparser.getDate();\t// -\u003e Date object\n\t\n\t// Set working timezone. Changing timezone will not affect date object but\n\t// date string (i.e. parser.getText()).\n\tparser.setTimezone(\"+0800\");\n\t\n\t// Reset to default timezone.\n\tparser.setTimezone();\n\n\t// Catch the parsing error\n\ttry {\n\t\tparser.parse(\"2015-123-456\");\n\t} catch (err) {\n\t\tconsole.log(err);\t// -\u003e {code: \"...\", message: \"...\", ...}\n\t}\n});\n```\n\n### datetime directive\n\nCheck out the [demo page](https://rawgit.com/eight04/angular-datetime/master/example/demo.html) for details.\n\n```html\n\u003cinput type=\"text\" datetime=\"yyyy-MM-dd\" ng-model=\"myDate\"\u003e\n\u003cinput type=\"text\" datetime=\"yyyy-MM-dd\" ng-model=\"myDate\" required\u003e\n\u003cinput type=\"text\" datetime=\"yyyy-MM-dd\" ng-model=\"myDate\" datetime-timezone=\"+0300\"\u003e\n\u003cinput type=\"text\" datetime=\"yyyy-MM-dd\" ng-model=\"myDate\" min=\"Jan 1, 1990\" max=\"Dec 31, 2050\"\u003e\n\u003cinput type=\"text\" datetime=\"yyyy-MM-dd\" ng-model=\"myDate\" datetime-model=\"yyyy-MM-ddTHH:mm:ss\"\u003e\n\u003cinput type=\"text\" datetime=\"dd.MM.yyyy\" ng-model=\"myDate\" datetime-separator=\",\"\u003e\n```\n\nAPI reference\n-------------\n\nThis module exports:\n\n* `datetime` service - a function to create DatetimeParser object.\n* `datetimePlaceholder` constant - a map that define the placeholder of each element.\n\n#### datetimePlaceholder object\n\nJust a plain object. Edit it in config phase to specify different placeholder.\n\nDefault value:\n\n```js\n{\n\tyear: \"(year)\",\n\tyearShort: \"(year)\",\n\tmonth: \"(month)\",\n\tdate: \"(date)\",\n\tday: \"(day)\",\n\thour: \"(hour)\",\n\thour12: \"(hour12)\",\n\tminute: \"(minute)\",\n\tsecond: \"(second)\",\n\tmillisecond: \"(millisecond)\",\n\tampm: \"(AM/PM)\",\n\tweek: \"(week)\"\n}\n```\n\n#### datetime(format: String) =\u003e DatetimeParser\n\nA function to construct a date parser. format is a string containing date definition tokens defined by Angular: https://docs.angularjs.org/api/ng/filter/date\n\n#### DatetimeParser\n\nA parser object which can convert String to Date and vice versa.\n\n##### DatetimeParser.parse(text: String) =\u003e DatetimeParser\n\nParse text. This method might throw error.\n\n##### DatetimeParser.getText() =\u003e String\n\nReturn formatted text.\n\n##### DatetimeParser.setDate(date: Date) =\u003e DatetimeParser\n\nSet date and conver date to text.\n\n##### DatetimeParser.getDate() =\u003e Date\n\nReturn Date object.\n\nThese methods are usually used like:\n\n```js\ndate = parser.parse(text).getDate();\ntext = parser.setDate(date).getText();\n```\n\t\n##### DatetimeParser.setTimezone([timezone: String]) =\u003e DatetimeParser\n\nSet the timezone of the parser. timezone is a string matching `/[+-]\\d{2}:?\\d{2}/`.\n\nIf timezone is not provided, reset timezone to browser default.\n\nSetting timezone doesn't affect model value but update text.\n\n```js\ntime = parser.getDate().getTime();\nparser.setTimezone(newTimezone);\ntime2 = parser.getDate().getTime();\n\nconsole.assert(time == time2);\n```\n\t\n##### DatetimeParser.isEmpty() =\u003e boolean\n\nReturn true if there is any empty element.\n\n##### DatetimeParser.isInit() =\u003e boolean\n\nReturn true if all elements are set.\n\n##### DatetimeParser.unset() =\u003e DatetimeParser\n\nSet all elements to empty.\n\nKnown issues\n------------\n* 2 digit year 'yy' is ambiguous when converting datestring back to date object (Ex. 14 -\u003e 2014, 1914, ...). You should avoid it.\n\nNotes\n-----\n* Some info about getting selection range across all browsers:\n\t- https://github.com/acdvorak/jquery.caret\n\t- http://stackoverflow.com/questions/19814465/is-it-possible-to-insert-text-in-textarea-and-update-undo-redo-queue\n\nChangelog\n---------\n* 5.3.0 (Apr 19, 2018)\n\t- Add: `datetime-timezone` attribute. Now you can customize the timezone in the directive. #60 @andreyjkee\n* 5.2.1 (Sep 17, 2017)\n\t- Fix: use unpkg field in package.json.\n* 5.2.0 (Sep 17, 2017)\n\t- Fix: use explicit DI annotation. [#57](https://github.com/eight04/angular-datetime/issues/57)\n\t- Change: dist file is minimized. [#14](https://github.com/eight04/angular-datetime/issues/14)\n\t- **Change: pre-built dist now includes custom-input so there is no need to inject it manually.**\n\t- Update custom-input to 0.3.0 which uses event-lite for smaller file size.\n* 5.1.3 (Jul 24, 2017)\n\t- Fix overflowed day issue. [#52](https://github.com/eight04/angular-datetime/issues/52)\n* 5.1.2 (Apr 16, 2017)\n\t- Fix jQuery compat issue. [#45](https://github.com/eight04/angular-datetime/issues/45)\n* 5.1.1 (Mar 30, 2017)\n\t- Increase directive's priority. [#46](https://github.com/eight04/angular-datetime/issues/46)\n* 5.1.0 (Mar 9, 2017)\n\t- Switch to browserify.\n\t- Drop karma, switch to mocha + jsdom.\n\t- **Update custom-input to 0.2.0.**\n\t- Now this package is requirable, perhaps it works better in different bundlers.\n* 5.0.0 (Dec 23, 2016)\n\t- Rewritten in ES6.\n\t\t- The core part of the parser and the input mask are pulled out as [custom-input](https://github.com/eight04/custom-input)\n\t\t- Support IE8 by transpiling through babel and using polyfill for missing functions.\n\t- Add constant `datetimePlaceholder`.\n* 4.1.0 (Oct 5, 2016)\n\t- Refactor.\n\t- Fix day priority bug.\n\t- Add `parser.isEmpty`. Fix required issue.\n* 4.0.0 (Sep 1, 2016)\n\t- Change how parser work. It can represent \"undefined\" node now.\n\t- Use tab key to navigate between different parts.\n* 3.2.2 (Jun 30, 2016)\n\t- Return false if there is no ngModel.\n* 3.2.1 (Jun 18, 2016)\n\t- Fix a bug that empty `min`, `max` cause invalid date.\n* 3.2.0 (May 17, 2016)\n\t- Support dynamic datetime-utc. [#29](https://github.com/eight04/angular-datetime/issues/29)\n* 3.1.1 (Apr 17, 2016)\n\t- Deploy to npmjs/angular-datetime-input.\n\t- Drop grunt.\n* 3.1.0\n    - Jump on the next segment on pressing next separator key. ([#26](https://github.com/eight04/angular-datetime/pull/26))\n    - Add `datetime-separator` option.\n\t- Now it will try to fix NUMBER_TOOSHORT error when pressing left/right/separator key.\n* 3.0.1 (Apr 9, 2016)\n\t- Fix validator and datetime-model bug. [#27](https://github.com/eight04/angular-datetime/issues/27)\n* 3.0.0 (Apr 1, 2016)\n\t- Add token `ZZ`. [#24](https://github.com/eight04/angular-datetime/pull/24)\n\t- Fix datetime-utc issue. [#21](https://github.com/eight04/angular-datetime/issues/21)\n\t- Add `parser.setTimezone`. [#22](https://github.com/eight04/angular-datetime/issues/22)\n\t- Use PhantomJS for testing.\n\t- Change Angular dependency to ^1.2.0.\n\t- Fix [date overflow bug](http://stackoverflow.com/questions/14680396/the-date-getmonth-method-has-bug).\n* 2.2.1 (Mar 31, 2016)\n\t- Fix reference error with \"Z\" token. See [#20](https://github.com/eight04/angular-datetime/pull/20)\n* 2.2.0 (Feb 23, 2016)\n\t- Add new error type \"LEADING_ZERO\", \"NUMBER_TOOSMALL\".\n\t- Use the behavior introduced in #18.\n\t- Add `default` attribute.\n* 2.1.0 (Jan 12, 2016)\n\t- Add `datetime-utc` option.\n* 2.0.1 (Jan 1, 2016)\n\t- Add MIT License\n* 2.0\n\t- Add `min`, `max`, `datetime-model` directive.\n\t- Support `$validators` in angular 1.3.x.\n\t- Update Eslint to 1.x.\n\t- Fix timezone token `Z`.\n* 1.0\n\t- Added Karma test.\n\t- Changed source structure.\n\t- Now you can chain parser's methods.\n\t- Parsing error won't mess up modelValue anymore.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feight04%2Fangular-datetime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feight04%2Fangular-datetime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feight04%2Fangular-datetime/lists"}