From 5328dabad16732a8b9c655cb51e1fd119c1005a5 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sun, 22 May 2022 21:09:49 +0300 Subject: [PATCH] time: simplify some very commonly used t.format methods --- vlib/time/format.v | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vlib/time/format.v b/vlib/time/format.v index 5dd51d6ae2..aca3a7a50d 100644 --- a/vlib/time/format.v +++ b/vlib/time/format.v @@ -7,32 +7,32 @@ import strings // format returns a date string in "YYYY-MM-DD HH:mm" format (24h). pub fn (t Time) format() string { - return t.get_fmt_str(.hyphen, .hhmm24, .yyyymmdd) + return '${t.year:04d}-${t.month:02d}-${t.day:02d} ${t.hour:02d}:${t.minute:02d}' } // format_ss returns a date string in "YYYY-MM-DD HH:mm:ss" format (24h). pub fn (t Time) format_ss() string { - return t.get_fmt_str(.hyphen, .hhmmss24, .yyyymmdd) + return '${t.year:04d}-${t.month:02d}-${t.day:02d} ${t.hour:02d}:${t.minute:02d}:${t.second:02d}' } // format_ss_milli returns a date string in "YYYY-MM-DD HH:mm:ss.123" format (24h). pub fn (t Time) format_ss_milli() string { - return t.get_fmt_str(.hyphen, .hhmmss24_milli, .yyyymmdd) + return '${t.year:04d}-${t.month:02d}-${t.day:02d} ${t.hour:02d}:${t.minute:02d}:${t.second:02d}.${(t.microsecond / 1000):03d}' } // format_ss_micro returns a date string in "YYYY-MM-DD HH:mm:ss.123456" format (24h). pub fn (t Time) format_ss_micro() string { - return t.get_fmt_str(.hyphen, .hhmmss24_micro, .yyyymmdd) + return '${t.year:04d}-${t.month:02d}-${t.day:02d} ${t.hour:02d}:${t.minute:02d}:${t.second:02d}.${t.microsecond:06d}' } // hhmm returns a date string in "HH:mm" format (24h). pub fn (t Time) hhmm() string { - return t.get_fmt_time_str(.hhmm24) + return '${t.hour:02d}:${t.minute:02d}' } // hhmmss returns a date string in "HH:mm:ss" format (24h). pub fn (t Time) hhmmss() string { - return t.get_fmt_time_str(.hhmmss24) + return '${t.hour:02d}:${t.minute:02d}:${t.second:02d}' } // hhmm12 returns a date string in "hh:mm" format (12h).