| Crates.io | birthday-struct |
| lib.rs | birthday-struct |
| version | 0.2.0 |
| created_at | 2024-12-11 21:41:21.361854+00 |
| updated_at | 2024-12-11 21:44:26.544187+00 |
| description | A crate for representing and manipulating birthdays, with support for time zones, age calculations, and integration with zodiac signs. |
| homepage | |
| repository | https://github.com/klebs6/klebs-general |
| max_upload_size | |
| id | 1480554 |
| size | 32,529 |
birthday-struct is a Rust library designed for working with birthdays. It supports:
Age Calculation:
Compute a person's age from their birth date and today's date.
Next and Last Birthday:
Find out how many days remain until the next birthday, or how many days have passed since the last one.
Is Today Their Birthday?:
Quickly check if a birthday matches today's date.
Zodiac Sign Integration:
Convert birthdays to their corresponding zodiac signs using the zodiac-sign crate.
Multilingual Greetings:
Retrieve a birthday greeting in several languages via the language-enum crate.
Serialization and Time Zones:
Serialize and deserialize birthday information, including time zones provided by chrono-tz.
use birthday_struct::{BirthdayBuilder, Tz, birthday_greeting};
use language_enum::Language;
fn main() {
let birthday = BirthdayBuilder::default()
.day(10)
.month(8)
.year(1990)
.time_zone(Tz::utc())
.build()
.unwrap();
println!("Is today their birthday? {}", birthday.is_today());
println!("They are {} years old.", birthday.age().unwrap_or(0));
println!("Days until next birthday: {}", birthday.days_until_next());
println!("Days since last birthday: {}", birthday.days_since_last());
let greeting = birthday_greeting(&Language::English).unwrap_or("Hello!");
println!("{}", greeting);
let zodiac: zodiac_sign::ZodiacSign = birthday.clone().into();
println!("Their zodiac sign is: {}", zodiac);
}
Add birthday-struct to your Cargo.toml:
[dependencies]
birthday-struct = "0.1.0"
This project is licensed under the MIT license. See the LICENSE file for details.