sebastienrousseau / dtt

A Rust library for parsing, validating, manipulating, and formatting dates and times 🦀
https://dttlib.com/
Apache License 2.0
6 stars 0 forks source link

DateTime.now doc description and running result do not match #63

Closed xBINj closed 2 weeks ago

xBINj commented 4 months ago

dtt version: 0.0.6

in doc description: https://docs.rs/dtt/latest/dtt/struct.DateTime.html now: String Now object: (e.g. “2023-01-01”)

but in running result: fn main() { let v1 = DateTime::new_with_tz("HKT").unwrap().now; println!("v1: {}", v1); }

it show: Finished dev profile [unoptimized + debuginfo] target(s) in 2.36s Running target\debug\dtt01.exe v1: 2024-05-16 19:17:58.8611592 +08:00:00

it include time and offset info.

sebastienrousseau commented 2 weeks ago

@xBINj

This issue has been resolved in PR #70 (https://github.com/sebastienrousseau/dtt/pull/70) and coming up v0.0.7.

The now() method has been updated to return a DateTime instance representing the current date and time, rather than a String or a "Now object". The DateTime struct now implements the Display trait, which formats the datetime as an RFC 3339 string when printed, including the date, time, and offset information.

Current behavior:

fn main() {
    let v1 = DateTime::new_with_tz("HKT").unwrap().now();
    println!("v1: {}", v1);
}

Output: v1: 2024-05-16 19:17:58.8611592 +08:00:00

Many thanks!