{"id":24082433,"url":"https://github.com/web-atoms/date-time","last_synced_at":"2026-02-11T00:32:12.345Z","repository":{"id":50742077,"uuid":"207469332","full_name":"web-atoms/date-time","owner":"web-atoms","description":"DateTime library for Web Atoms","archived":false,"fork":false,"pushed_at":"2024-12-30T09:17:10.000Z","size":61,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-24T13:53:34.844Z","etag":null,"topics":["datetime","datetime-library","intellisense","javascript","timespan","typescript","web-atoms"],"latest_commit_sha":null,"homepage":"https://www.webatoms.in","language":"TypeScript","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/web-atoms.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-10T05:02:03.000Z","updated_at":"2024-12-30T09:17:13.000Z","dependencies_parsed_at":"2025-04-10T10:04:51.986Z","dependency_job_id":"01ea47be-704c-4edc-9365-468536406977","html_url":"https://github.com/web-atoms/date-time","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/web-atoms/date-time","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-atoms%2Fdate-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-atoms%2Fdate-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-atoms%2Fdate-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-atoms%2Fdate-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/web-atoms","download_url":"https://codeload.github.com/web-atoms/date-time/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-atoms%2Fdate-time/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29323584,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-10T20:44:44.282Z","status":"ssl_error","status_checked_at":"2026-02-10T20:44:43.393Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["datetime","datetime-library","intellisense","javascript","timespan","typescript","web-atoms"],"created_at":"2025-01-09T23:46:49.509Z","updated_at":"2026-02-11T00:32:12.317Z","avatar_url":"https://github.com/web-atoms.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Action Status](https://github.com/web-atoms/date-time/workflows/Build/badge.svg)](https://github.com/web-atoms/unit-test/actions) [![npm version](https://badge.fury.io/js/%40web-atoms%2Fdate-time.svg)](https://badge.fury.io/js/%40web-atoms%2Fdate-time)\r\n\r\n# @web-atoms/date-time\r\nImmutable DateTime library for Web Atoms in JavaScript similar to .Net DateTime and TimeSpan\r\n\r\n# Features\r\n1. Immutable DateTime\r\n2. Support for TimeSpan (differences between dates)\r\n3. Simple Add/Difference\r\n4. Support for properties\r\n5. Support for Comparison\r\n6. Support for `valueOf` which makes it easier to compare and sort dates\r\n7. Backward compatibility with JavaScript's Date\r\n\r\n# Compatibility\r\nIn order to make usage simple, you can pass DateTime to any method that uses `Date` and everything will still work. To prevent intellisense from listing all Date's methods, we have used a hack to create new Date object in constructor of DateTime.\r\n\r\nFor easy access, all `to*String` methods of `Date` are available in intellisense.\r\n\r\n```typescript\r\n   const d = DateTime.now();\r\n   console.log(d instance of Date); // prints true..\r\n\r\n   // however intellisense does not\r\n   // show up for Date methods except for toLocaleDateString etc\r\n   d.year\r\n```\r\n\r\n# Usage\r\n\r\n## Properties\r\nYear, Month, Day, Hour, Minute, Second and Millisecond are all properties.\r\n\r\n```typescript\r\n   const d = DateTime.now();\r\n\r\n   console.log(`${d.year}-${d.month}-${d.day}`);\r\n```\r\n\r\n## Trim Time\r\n```typescript\r\n   const d = DateTime.now();\r\n\r\n   // returns new instance of DateTime\r\n   // with time part trimmed...\r\n   const day = d.date;\r\n```\r\n\r\n## Comparison\r\n```typescript\r\n   const d1 = new DateTime(2010, 1, 1, 20, 50);\r\n   const d2 = new DateTime(2010, 2, 1, 20, 50);\r\n   const dt1 = new Date(d1.msSinceEpoch);\r\n   const dt2 = new Date(d1.msSinceEpoch);\r\n   // DateTime comparison works correctly\r\n   Assert.isTrue(d1 \u003c d2);\r\n   // Date comparison does not work as expected\r\n   Assert.isFalse(dt1 \u003c dt2);\r\n```\r\n\r\n## TimeSpan\r\n```typescript\r\n   const d = DateTime.now();\r\n\r\n   const t = d.time;\r\n\r\n   console.log(t); // prints 10.00 PM (local time)\r\n```\r\n\r\n## Difference in TimeSpan\r\n```typescript\r\n\r\n   const d1 = new DateTime(2010, 1, 1);\r\n   const d2 = new DateTime(2012, 1, 1);\r\n\r\n   // returns TimeSpan\r\n   const diff = d2.diff(d1);\r\n\r\n   // prints 730\r\n   console.log(diff.totalDays);\r\n\r\n```\r\n\r\n## Add TimeSpan\r\n```typescript\r\n   \r\n   const t = TimeSpan.fromDays(2);\r\n   const d1 = new DateTime(2010, 1, 1);\r\n\r\n   const d2 = d1.add(t);\r\n\r\n   // prints 2010-01-03\r\n   console.log(d2); \r\n\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb-atoms%2Fdate-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweb-atoms%2Fdate-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb-atoms%2Fdate-time/lists"}