Skip to content

Commit 2e67472

Browse files
committed
feat: UtcDateTime
1 parent 16874a1 commit 2e67472

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/time.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ impl FormatTime for () {
3333

3434
////////////////////////////////////////////////////////////////////////////////////////////////////
3535

36+
/// Retrieve and print the current wall-clock time in UTC timezone.
37+
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
38+
pub struct UtcDateTime;
39+
40+
impl FormatTime for UtcDateTime {
41+
fn format_time(&self, w: &mut impl std::fmt::Write) -> std::fmt::Result {
42+
let time = time::OffsetDateTime::now_utc();
43+
write!(w, "{} {}", time.date(), time.time())
44+
}
45+
}
46+
47+
////////////////////////////////////////////////////////////////////////////////////////////////////
48+
3649
/// Retrieve and print the current wall-clock time.
3750
///
3851
/// # Panics

0 commit comments

Comments
 (0)