timex

Crates.iotimex
lib.rstimex
version0.3.0-beta.1
sourcesrc
created_at2024-01-20 17:05:59.228102
updated_at2024-01-24 05:45:17.079079
descriptionGenerate date times as event similar to Microsoft calender or Google calender based on the given parameters.
homepagehttps://github.com/jawahar273/timex
repositoryhttps://github.com/jawahar273/timex
max_upload_size
id1106638
size92,504
Jawahar S (jawahar273)

documentation

README

Timex: Schedule Date Time Generator

This Rust library allows you to generate date times based on a start and end date, along with other parameters. It utilizes the chrono crate for date and time manipulations.

Demo

https://github.com/jawahar273/timex/assets/7668497/841621b1-6325-4804-8dc3-cb5124c42a96

For recreated demo check server/README.md.

Feature

  • Time range
  • Occurrence
  • Based on daily, weekly, monthly(WIP: end date) and yearly(soon)..
  • Web assembly support(Soon)

Limitation

  • Not good with nano second as this project rely on (Chrono) which has know limitation.
  • Recommenced to use a persistance database to store the schedule date and time.

Usage



use timex::{
    schedule_date_times,
    model::ScheduleDetails
};
use chrono::{DateTime, Utc};
use serde_json;


fn main() {
    
    // Start: Mock for schedule details
    let t = r#"
    {
        "scheduledStartDateTime": "2023-12-14T08:00:44.939Z",
        "repeatEveryNumber": 1,
        "repeatEvery": "day",
        "endOption": "never"
    }
    "#;
    let job_details: ScheduleDetails = serde_json::from_str(&t).unwrap();
    // END: Mock for schedule details
    
    
    let previous_scheduled_date = DateTime::parse_from_rfc3339("2024-01-03T00:00:00Z")
                        .unwrap()
                        .with_timezone(&Utc);
    let start_range = DateTime::parse_from_rfc3339("2024-01-01T00:00:00Z")
                        .unwrap()
                        .with_timezone(&Utc);
    let end_range = DateTime::parse_from_rfc3339("2024-01-07T00:00:00Z")
                        .unwrap()
                        .with_timezone(&Utc);
    let result = schedule_date_times(
        &job_details,
        previous_scheduled_date,
        start_range,
        end_range,
    );
    println!("{:?}",&result.unwrap());
    // [
    // 2024-01-04T00:00:00Z,
    // 2024-01-05T00:00:00Z,
    // 2024-01-06T00:00:00Z,
    // 2024-01-07T00:00:00Z
    // ]
}

License

This project is licensed under the MIT License.

About this project

This project will follow the conversion of semver versions and for the commit conventional commits to track change log.

Commit count: 0

cargo fmt