From e22283e5e62cc0a80e1af2f6527f068d41bff188 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 11 Feb 2020 20:05:08 +0100 Subject: [PATCH] Userland: Use Core::DateTime --- Userland/date.cpp | 10 ++-------- Userland/ls.cpp | 10 ++-------- Userland/stat.cpp | 10 ++-------- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/Userland/date.cpp b/Userland/date.cpp index aa268666bb..7122cfa76d 100644 --- a/Userland/date.cpp +++ b/Userland/date.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -37,13 +38,6 @@ int main(int argc, char** argv) return 0; } - auto* tm = localtime(&now); - printf("%4u-%02u-%02u %02u:%02u:%02u\n", - tm->tm_year + 1900, - tm->tm_mon + 1, - tm->tm_mday, - tm->tm_hour, - tm->tm_min, - tm->tm_sec); + printf("%s\n", Core::DateTime::from_timestamp(now).to_string().characters()); return 0; } diff --git a/Userland/ls.cpp b/Userland/ls.cpp index 019bb042c8..c2804344e8 100644 --- a/Userland/ls.cpp +++ b/Userland/ls.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -271,14 +272,7 @@ bool print_filesystem_object(const String& path, const String& name, const struc } } - auto* tm = localtime(&st.st_mtime); - printf(" %4u-%02u-%02u %02u:%02u:%02u ", - tm->tm_year + 1900, - tm->tm_mon + 1, - tm->tm_mday, - tm->tm_hour, - tm->tm_min, - tm->tm_sec); + printf(" %s ", Core::DateTime::from_timestamp(st.st_mtime).to_string().characters()); print_name(st, name, path.characters()); diff --git a/Userland/stat.cpp b/Userland/stat.cpp index 703edb5cf6..e645ece153 100644 --- a/Userland/stat.cpp +++ b/Userland/stat.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -98,14 +99,7 @@ int main(int argc, char** argv) printf(")\n"); auto print_time = [](time_t t) { - auto* tm = localtime(&t); - printf("%4u-%02u-%02u %02u:%02u:%02u\n", - tm->tm_year + 1900, - tm->tm_mon + 1, - tm->tm_mday, - tm->tm_hour, - tm->tm_min, - tm->tm_sec); + printf("%s\n", Core::DateTime::from_timestamp(t).to_string().characters()); }; printf("Accessed: ");