mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
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:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user