# datetime-default ## DateTime NewType set for default time [![Latest Version](https://img.shields.io/crates/v/datetime-default.svg?color=green&style=flat-square)](https://crates.io/crates/datetime-default) [![GitHub license](https://badgen.net/github/license/Naereen/Strapdown.js?style=flat-square)](https://github.com/Naereen/StrapDown.js/blob/master/LICENSE) When you want to use `#[derive(Default)]` to a struct, you may want the current time to be the default for `DateTime`. For this purpose, we have provided NewType that overrides the default value. ### Features #### DateTimeDefaultNow DateTime with current time as default. ```rust use chrono::{Local, TimeZone}; use datetime_default::DateTimeDefaultNow; assert_eq!( DateTimeDefaultNow::::default(), Local.datetime_from_str("2022/10/10 23:40:11.695164300", "%Y/%m/%d %H:%M:%S%.9f").unwrap() ); ``` #### DateTimeDefaultUnix DateTime with UNIX epoch as default. ```rust use chrono::{Utc, TimeZone}; use datetime_default::DateTimeDefaultUnix; assert_eq!( DateTimeDefaultUnix::::default(), Utc.datetime_from_str("1970/1/1 00:00:00", "%Y/%m/%d %H:%M:%S").unwrap() ); ``` #### Default Datetime with TimeZone ```rust use chrono::{DateTime, FixedOffset, TimeZone}; use datetime_default::DateTimeDefaultUnix; assert_eq!( DateTimeDefaultUnix::::default(), DateTime::parse_from_rfc3339("1970-01-01T09:00:00+09:00").unwrap() ); ``` License: MIT