summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-01-04 23:02:14 +0000
committerAndrew Tridgell <tridge@samba.org>2002-01-04 23:02:14 +0000
commitfaa1b222f170abe34f6930bb3493cbe8b4df4082 (patch)
tree23ccfe14b8ce7d7f133ee930a23b5f7404dd7396
parent2db99fa49b538e230f2c606d1004871111ea2bf6 (diff)
downloadsamba-faa1b222f170abe34f6930bb3493cbe8b4df4082.tar.gz
print the timezone in the same format as 'date +%z' - much better for scripting
-rw-r--r--source/utils/net_time.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/source/utils/net_time.c b/source/utils/net_time.c
index dea1bcd6776..02007c32ec5 100644
--- a/source/utils/net_time.c
+++ b/source/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;
}