{"id":17209333,"url":"https://github.com/de-vri-es/gregorian-rs","last_synced_at":"2025-08-21T15:15:12.247Z","repository":{"id":42081503,"uuid":"273762577","full_name":"de-vri-es/gregorian-rs","owner":"de-vri-es","description":"easy to use date library for Rust","archived":false,"fork":false,"pushed_at":"2023-03-29T17:54:09.000Z","size":48,"stargazers_count":4,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T23:48:08.430Z","etag":null,"topics":["date","gregorian","hacktoberfest","rust-library"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/de-vri-es.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2020-06-20T18:24:46.000Z","updated_at":"2022-12-02T15:18:39.000Z","dependencies_parsed_at":"2024-10-15T02:51:25.995Z","dependency_job_id":"fcb97826-7531-4960-ab01-65993611287e","html_url":"https://github.com/de-vri-es/gregorian-rs","commit_stats":{"total_commits":53,"total_committers":3,"mean_commits":"17.666666666666668","dds":0.07547169811320753,"last_synced_commit":"8d1f590d71167f1bee2f7d5f129ef86c9357c320"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/de-vri-es%2Fgregorian-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/de-vri-es%2Fgregorian-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/de-vri-es%2Fgregorian-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/de-vri-es%2Fgregorian-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/de-vri-es","download_url":"https://codeload.github.com/de-vri-es/gregorian-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248792202,"owners_count":21162331,"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":["date","gregorian","hacktoberfest","rust-library"],"created_at":"2024-10-15T02:51:21.073Z","updated_at":"2025-04-13T22:36:16.010Z","avatar_url":"https://github.com/de-vri-es.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gregorian [![docs][docs-badge]][docs] [![tests][tests-badge]][tests]\n[docs]: https://docs.rs/gregorian/\n[tests]: https://github.com/de-vri-es/gregorian-rs/actions?query=workflow%3Atests\n[docs-badge]: https://docs.rs/gregorian/badge.svg\n[tests-badge]: https://github.com/de-vri-es/gregorian-rs/workflows/tests/badge.svg\n\nAn implementation of the proleptic Gregorian calendar, compatible with ISO 8601.\nAmongst others, that means that the calendar has a year zero preceeding the year 1.\n\nThis create does not deal with times or time zones.\n\nThe [`Date`] type represents a date (year, month and day),\nthe [`Year`] type represents a calendar year,\nthe [`Month`] type represents a calendar month,\nand the [`YearMonth`] type represents a month of a specific year.\n\nWhere possible, things are implemented as `const fn`.\nCurrently, this excludes trait implementations and functions that rely on traits.\n\n## Example\n```rust\nuse gregorian::{Date, Month::*, Year, YearMonth};\n\nassert!(Year::new(2020).has_leap_day(), true);\nassert!(YearMonth::new(1900, February).total_days() == 28);\nassert!(YearMonth::new(2000, February).total_days() == 29);\n\nassert!(Year::new(2020).with_month(March).first_day() == Date::new(2020, March, 1).unwrap());\nassert!(Year::new(2020).with_month(March).last_day() == Date::new(2020, March, 31).unwrap());\n\nassert!(Year::new(2020).first_day() == Date::new(2020, 1, 1).unwrap());\nassert!(Year::new(2020).last_day() == Date::new(2020, 12, 31).unwrap());\n\nassert!(Date::new(2020, 2, 1).unwrap().day_of_year() == 32);\n```\n\n## Rounding invalid dates\nWhen you use [`Date::add_years()`] or [`Date::add_months()`], you can get invalid dates.\nThese are reported with an [`InvalidDayOfMonth`] error which has the\n[`next_valid()`][InvalidDayOfMonth::next_valid] and [`prev_valid()`][InvalidDayOfMonth::prev_valid] methods.\nThose can be used to get the next or previous valid date instead.\n\nAdditionally, there is an extension trait for `Result\u003cDate, InvalidDayOfMonth\u003e` with the\n[`or_next_valid()`][DateResultExt::or_next_valid] and [`or_prev_valid()`][DateResultExt::or_prev_valid] methods.\nThis allows you to directly round the date on the `Result` object.\n\n```rust\nuse gregorian::{Date, DateResultExt};\nlet date = Date::new(2020, 1, 31).unwrap();\nassert!(date.add_months(1).or_next_valid() == Date::new(2020, 3, 1).unwrap());\nassert!(date.add_months(1).or_prev_valid() == Date::new(2020, 2, 29).unwrap());\n```\n\n[`Date`]: https://docs.rs/gregorian/latest/gregorian/struct.Date.html\n[`Year`]: https://docs.rs/gregorian/latest/gregorian/struct.Year.html\n[`YearMonth`]: https://docs.rs/gregorian/latest/gregorian/struct.YearMonth.html\n[`Month`]: https://docs.rs/gregorian/latest/gregorian/struct.Month.html\n[`InvalidDayOfMonth`]: https://docs.rs/gregorian/latest/gregorian/struct.InvalidDayOfMonth.html\n\n[`Date::add_years()`]: https://docs.rs/gregorian/latest/gregorian/struct.Date.html#method.add_years\n[`Date::add_months()`]: https://docs.rs/gregorian/latest/gregorian/struct.Date.html#method.add_months\n[DateResultExt::or_next_valid]: https://docs.rs/gregorian/latest/gregorian/trait.DateResultExt.html#method.or_next_valid\n[DateResultExt::or_prev_valid]: https://docs.rs/gregorian/latest/gregorian/trait.DateResultExt.html#method.or_prev_valid\n[InvalidDayOfMonth::next_valid]: https://docs.rs/gregorian/latest/gregorian/struct.InvalidDayOfMonth.html#method.next_valid\n[InvalidDayOfMonth::prev_valid]: https://docs.rs/gregorian/latest/gregorian/struct.InvalidDayOfMonth.html#method.prev_valid\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fde-vri-es%2Fgregorian-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fde-vri-es%2Fgregorian-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fde-vri-es%2Fgregorian-rs/lists"}