{"id":13439165,"url":"https://github.com/yaa110/rust-persian-calendar","last_synced_at":"2025-03-16T07:31:54.800Z","repository":{"id":62443067,"uuid":"79639782","full_name":"yaa110/rust-persian-calendar","owner":"yaa110","description":"The implementation of the Persian (Solar Hijri) Calendar in Rust","archived":false,"fork":false,"pushed_at":"2023-10-23T13:38:55.000Z","size":13,"stargazers_count":30,"open_issues_count":1,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-27T05:49:28.838Z","etag":null,"topics":["persian-calendar","rust","rust-crate"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/ptime","language":"Rust","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/yaa110.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}},"created_at":"2017-01-21T10:43:21.000Z","updated_at":"2024-12-21T06:02:35.000Z","dependencies_parsed_at":"2024-01-15T15:15:15.613Z","dependency_job_id":null,"html_url":"https://github.com/yaa110/rust-persian-calendar","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/yaa110%2Frust-persian-calendar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaa110%2Frust-persian-calendar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaa110%2Frust-persian-calendar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaa110%2Frust-persian-calendar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yaa110","download_url":"https://codeload.github.com/yaa110/rust-persian-calendar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806045,"owners_count":20350775,"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":["persian-calendar","rust","rust-crate"],"created_at":"2024-07-31T03:01:11.695Z","updated_at":"2025-03-16T07:31:54.467Z","avatar_url":"https://github.com/yaa110.png","language":"Rust","funding_links":[],"categories":["Libraries","Jalali Date","库","库 Libraries"],"sub_categories":["Date and time","日期和时间","日期和时间 Date and time"],"readme":"Rust Persian Calendar\n=====================\n\n[![crates.io](https://img.shields.io/crates/v/ptime.svg)](https://crates.io/crates/ptime) [![Documentation](https://img.shields.io/badge/Docs-ptime-blue.svg)](https://docs.rs/ptime/0.1.1/ptime) [![Build Status](https://travis-ci.org/yaa110/rust-persian-calendar.svg)](https://travis-ci.org/yaa110/rust-persian-calendar) [![License](http://img.shields.io/:license-mit-blue.svg)](https://github.com/yaa110/rust-persian-calendar/blob/master/LICENSE)\n\n**Rust Persian Calendar v0.1.1** provides functionality for conversion among Persian (Solar Hijri) and Gregorian calendars. A Julian calendar is used as an interface for all conversions. The crate name is `ptime` and it is compatible with the crate [time](https://crates.io/crates/time). This source code is licensed under MIT license that can be found in the LICENSE file.\n\n## Installation\nAdd `ptime = \"0.1\"` to `dependencies` section of `Cargo.toml`:\n\n```toml\n[dependencies]\ntime = \"0.1\"\nptime = \"0.1\"\n```\n\n## Getting started\n1- Import the crate `ptime`. Most of the time you need to import `time` crate, too.\n\n```rust\nextern crate ptime;\nextern crate time;\n```\n\n2- Convert Gregorian calendar to Persian calendar.\n\n```rust\nlet p_tm = ptime::from_gregorian_date(2016, 2, 21).unwrap();\n\nassert_eq!(p_tm.tm_year, 1395);\nassert_eq!(p_tm.tm_mon, 0);\nassert_eq!(p_tm.tm_mday, 2);\n```\n\n3- Convert Persian calendar to Gregorian calendar.\n\n```rust\nlet g_tm = ptime::from_persian_date(1395, 0, 2).unwrap().to_gregorian();\n\nassert_eq!(g_tm.tm_year, 2016);\nassert_eq!(g_tm.tm_mon, 2);\nassert_eq!(g_tm.tm_mday, 21);\n```\n\n4- Get the current time.\n\n```rust\nlet p_tm = ptime::now();\nprintln!(\"Current time: {}\", p_tm);\n\nlet p_tm_utc = ptime::now_utc();\nprintln!(\"Current time at UTC: {}\", p_tm_utc);\n```\n\n5- Format the time.\n\n```rust\nlet p_tm = ptime::from_gregorian(time::now());\nprintln!(\"{}\", p_tm.to_string(\"yyyy-MM-dd HH:mm:ss.ns\"));\n\n///     yyyy, yyy, y     year (e.g. 1394)\n///     yy               2-digits representation of year (e.g. 94)\n///     MMM              the Persian name of month (e.g. فروردین)\n///     MM               2-digits representation of month (e.g. 01)\n///     M                month (e.g. 1)\n///     DD               day of year (starting from 1)\n///     D                day of year (starting from 0)\n///     dd               2-digits representation of day (e.g. 01)\n///     d                day (e.g. 1)\n///     E                the Persian name of weekday (e.g. شنبه)\n///     e                the Persian short name of weekday (e.g. ش)\n///     A                the Persian name of 12-Hour marker (e.g. قبل از ظهر)\n///     a                the Persian short name of 12-Hour marker (e.g. ق.ظ)\n///     HH               2-digits representation of hour [00-23]\n///     H                hour [0-23]\n///     kk               2-digits representation of hour [01-24]\n///     k                hour [1-24]\n///     hh               2-digits representation of hour [01-12]\n///     h                hour [1-12]\n///     KK               2-digits representation of hour [00-11]\n///     K                hour [0-11]\n///     mm               2-digits representation of minute [00-59]\n///     m                minute [0-59]\n///     ss               2-digits representation of seconds [00-59]\n///     s                seconds [0-59]\n///     ns               nanoseconds\n```\n\nFor more information, please check the test files in `tests` folder.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaa110%2Frust-persian-calendar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyaa110%2Frust-persian-calendar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaa110%2Frust-persian-calendar/lists"}