chore: merging back release v0.3.0 back to main (#636) (#655)

Co-authored-by: Sangamesh Kulkarni <59434228+Sangamesh26@users.noreply.github.com>
Co-authored-by: ItsMeShashank <shashank.attarde@juspay.in>
Co-authored-by: Abhishek <abhishek.marrivagu@juspay.in>
Co-authored-by: Jagan <jaganelavarasan@gmail.com>
Co-authored-by: SamraatBansal <55536657+SamraatBansal@users.noreply.github.com>
Co-authored-by: Sampras Lopes <lsampras@protonmail.com>
This commit is contained in:
Arun Raj M
2023-02-26 13:55:17 +05:30
committed by GitHub
parent 7792de55ef
commit f3224cc4df
74 changed files with 5979 additions and 355 deletions

View File

@ -49,6 +49,28 @@ pub mod date_time {
(result, start.elapsed().as_seconds_f64() * 1000f64)
}
/// Prefix the date field with zero if it has single digit Eg: 1 -> 01
fn prefix_zero(input: u8) -> String {
if input < 10 {
return "0".to_owned() + input.to_string().as_str();
}
input.to_string()
}
/// Return the current date and time in UTC with the format YYYYMMDDHHmmss Eg: 20191105081132
pub fn date_as_yyyymmddhhmmss() -> String {
let now = OffsetDateTime::now_utc();
format!(
"{}{}{}{}{}{}",
now.year(),
prefix_zero(u8::from(now.month())),
prefix_zero(now.day()),
prefix_zero(now.hour()),
prefix_zero(now.minute()),
prefix_zero(now.second())
)
}
/// Return the current date and time in UTC with the format [year]-[month]-[day]T[hour]:[minute]:[second].mmmZ Eg: 2023-02-15T13:33:18.898Z
pub fn date_as_yyyymmddthhmmssmmmz() -> Result<String, time::error::Format> {
const ISO_CONFIG: EncodedConfig = Config::DEFAULT