Crates.io | birthday-struct |
lib.rs | birthday-struct |
version | |
source | src |
created_at | 2024-12-11 21:41:21.361854 |
updated_at | 2024-12-11 21:44:26.544187 |
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 |
Cargo.toml error: | TOML parse error at line 24, column 1 | 24 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
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.