birthday-struct

Crates.iobirthday-struct
lib.rsbirthday-struct
version
sourcesrc
created_at2024-12-11 21:41:21.361854
updated_at2024-12-11 21:44:26.544187
descriptionA crate for representing and manipulating birthdays, with support for time zones, age calculations, and integration with zodiac signs.
homepage
repositoryhttps://github.com/klebs6/klebs-general
max_upload_size
id1480554
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`
size0
(klebs6)

documentation

https://docs.rs/birthday-struct

README

birthday-struct

birthday-struct is a Rust library designed for working with birthdays. It supports:

  • Representing birthdays with an associated time zone.
  • Calculating age based on the current date.
  • Checking how many days until the next birthday or since the last one.
  • Determining if today is the user's birthday.
  • Identifying the zodiac sign corresponding to a given birthday.
  • Providing localized birthday greetings in various languages.
  • Efficient serialization and deserialization of birthday and timezone data via Serde.

Features

  • 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.

Example

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);
}

Installation

Add birthday-struct to your Cargo.toml:

[dependencies]
birthday-struct = "0.1.0"

License

This project is licensed under the MIT license. See the LICENSE file for details.

Commit count: 248

cargo fmt