From 9c7b042f31ee63a8b00aeeb9b530d1a405c715f5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 4 Jan 2002 23:02:14 +0000 Subject: print the timezone in the same format as 'date +%z' - much better for scripting (This used to be commit faa1b222f170abe34f6930bb3493cbe8b4df4082) --- source3/utils/net_time.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'source3/utils/net_time.c') diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c index dea1bcd677..02007c32ec 100644 --- a/source3/utils/net_time.c +++ b/source3/utils/net_time.c @@ -133,19 +133,22 @@ static int net_time_system(int argc, const char **argv) static int net_time_zone(int argc, const char **argv) { int zone = 0; + int hours, mins; + char zsign; time_t t; t = nettime(&zone); if (t == 0) return -1; + zsign = (zone > 0) ? '-' : '+'; + if (zone < 0) zone = -zone; + zone /= 60; + hours = zone / 60; + mins = zone % 60; - if (zone % 60 == 0) { - printf("%+d\n", -zone / 60); - } else { - printf("%+.1f\n", ((double)-zone) / 60); - } + printf("%c%02d%02d\n", zsign, hours, mins); return 0; } -- cgit