{"id":17164013,"url":"https://github.com/colineberhardt/assemblyscript-temporal","last_synced_at":"2025-03-23T18:31:22.621Z","repository":{"id":44755579,"uuid":"344549658","full_name":"ColinEberhardt/assemblyscript-temporal","owner":"ColinEberhardt","description":"An implementation of TC39 temporal for AssemblyScript","archived":false,"fork":false,"pushed_at":"2022-01-26T16:45:42.000Z","size":1395,"stargazers_count":25,"open_issues_count":4,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-18T22:35:45.322Z","etag":null,"topics":["assemblyscript","calendar","date","datetime","temporal"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/ColinEberhardt.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":"2021-03-04T17:07:47.000Z","updated_at":"2024-12-03T19:22:49.000Z","dependencies_parsed_at":"2022-09-03T05:02:27.569Z","dependency_job_id":null,"html_url":"https://github.com/ColinEberhardt/assemblyscript-temporal","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ColinEberhardt%2Fassemblyscript-temporal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ColinEberhardt%2Fassemblyscript-temporal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ColinEberhardt%2Fassemblyscript-temporal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ColinEberhardt%2Fassemblyscript-temporal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ColinEberhardt","download_url":"https://codeload.github.com/ColinEberhardt/assemblyscript-temporal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245149224,"owners_count":20568851,"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":["assemblyscript","calendar","date","datetime","temporal"],"created_at":"2024-10-14T22:50:41.934Z","updated_at":"2025-03-23T18:31:22.304Z","avatar_url":"https://github.com/ColinEberhardt.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## assemblyscript-temporal\n\nAn implementation of [TC39 Temporal](https://github.com/tc39/proposal-temporal) for AssemblyScript, with an focus on non-timezone-aware classes and functionality.\n\n### Why?\n\nAssemblyScript has minimal `Date` support, however, the JS Date API itself is terrible and people tend not to use it that often. As a result libraries like moment / luxon have become staple replacements. However, there is now a [relatively mature TC39 proposal](https://github.com/tc39/proposal-temporal) that adds greatly improved date support to JS. \n\n### Usage\n\nThis library currently supports the following types:\n\n#### `PlainDateTime`\n\nA `PlainDateTime` represents a calendar date and wall-clock time that does not carry time zone information, e.g. December 7th, 1995 at 3:00 PM (in the Gregorian calendar). For detailed documentation see the [TC39 Temporal proposal website](https://tc39.es/proposal-temporal/docs/plaindatetime.html), this implementation follows the specification as closely as possible.\n\nYou can create a `PlainDateTime` from individual components, a string or an object literal:\n\n```javascript\ndatetime = new PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789);\ndatetime.year; // 2019;\ndatetime.month; // 11;\n// ...\ndatetime.nanosecond; // 789;\n\ndatetime = PlainDateTime.from(\"1976-11-18T12:34:56\");\ndatetime.toString(); // \"1976-11-18T12:34:56\"\n\ndatetime = PlainDateTime.from({ year: 1966, month: 3, day: 3 });\ndatetime.toString(); // \"1966-03-03T00:00:00\"\n```\n\nThere are various ways you can manipulate a date:\n\n```javascript\n// use 'with' to copy a date but with various property values overriden\ndatetime = new PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789);\ndatetime.with({ year: 2019 }).toString(); // \"2019-11-18T15:23:30.123456789\"\n\n// use 'add' or 'substract' to add / subtract a duration\ndatetime = PlainDateTime.from(\"2020-01-12T15:00\");\ndatetime.add({ months: 1 }).toString(); // \"2020-02-12T15:00:00\");\n\n// add /  subtract support Duration objects or object literals\ndatetime.add(new Duration(1)).toString(); // \"2021-01-12T15:00:00\");\n```\n\nYou can compare dates and check for equality\n\n```javascript\ndt1 = PlainDateTime.from(\"1976-11-18\");\ndt2 = PlainDateTime.from(\"2019-10-29\");\nPlainDateTime.compare(dt1, dt1); // 0\nPlainDateTime.compare(dt1, dt2); // -1\ndt1.equals(dt1); // true\n```\n\nCurrently `PlainDateTime` only supports the ISO 8601 (Gregorian) calendar.\n\n#### `PlainDate`\n\nA `PlainDate` object represents a calendar date that is not associated with a particular time or time zone, e.g. August 24th, 2006. For detailed documentation see the [TC39 Temporal proposal website](https://tc39.es/proposal-temporal/docs/plaindate.html), this implementation follows the specification as closely as possible.\n\nThe `PlainDate` API is almost identical to `PlainDateTime`, so see above for API usage examples.\n\n#### `PlainTime`\n\nA `PlainTime` object represents a wall-clock time that is not associated with a particular date or time zone, e.g. 7:39 PM. For detailed documentation see the [TC39 Temporal proposal website](https://tc39.es/proposal-temporal/docs/plaintime.html), this implementation follows the specification as closely as possible.\n\nThe `PlainTime` API is almost identical to `PlainDateTime`, so see above for API usage examples.\n\n#### `PlainMonthDay`\n\nA date without a year component. This is useful to express things like \"Bastille Day is on the 14th of July\".\nFor detailed documentation see the\n[TC39 Temporal proposal website](https://tc39.es/proposal-temporal/docs/plainmonthday.html)\n, this implementation follows the specification as closely as possible.\n\n```javascript\nconst monthDay = PlainMonthDay.from({ month: 7, day: 14 }); // =\u003e 07-14\nconst date = monthDay.toPlainDate({ year: 2030 }); // =\u003e 2030-07-14\ndate.dayOfWeek; // =\u003e 7\n```\n\nThe `PlainMonthDay` API is almost identical to `PlainDateTime`, so see above for more API usage examples.\n\n#### `PlainYearMonth`\n\nA date without a day component. This is useful to express things like \"the October 2020 meeting\".\nFor detailed documentation see the\n[TC39 Temporal proposal website](https://tc39.es/proposal-temporal/docs/plainyearmonth.html)\n, this implementation follows the specification as closely as possible.\n\nThe `PlainYearMonth` API is almost identical to `PlainDateTime`, so see above for API usage examples.\n\n#### `Duration`\n\nA `Duration` represents a duration of time which can be used in date/time arithmetic. For detailed documentation see the\n[TC39 Temporal proposal website](https://tc39.es/proposal-temporal/docs/duration.html)\n\nHere's a small example, showing just some of wha you can do with durations:\n\n```javascript\n// create a duration\nconst duration = Duration.from({ days: 1, minutes: 5 });\n// add another duration to the first one\nconst duration2 = duration.add({ days: 2, minutes: 5 })};\nduration2.toString(); // \"P3DT10M\"\n```\n\n\n#### `Now`\n\nThe `Now` object has several methods which give information about the current time and date.\n\n```javascript\ndateTime = Now.plainDateTimeISO();\ndateTime.toString(); // 2021-04-01T12:05:47.357\n```\n\n## Contributing\n\nThis project is open source, MIT licensed and your contributions are very much welcomed.\n\nThere is a [brief document that outlines implementation progress and priorities](./development.md). \n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolineberhardt%2Fassemblyscript-temporal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolineberhardt%2Fassemblyscript-temporal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolineberhardt%2Fassemblyscript-temporal/lists"}