summaryrefslogtreecommitdiff
path: root/source3
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
commit9c7b042f31ee63a8b00aeeb9b530d1a405c715f5 (patch)
tree8dbac15f0f9f18f4339feeb86e0deedb8a97a406 /source3
parente86102e86804ec07d8dd704dac963b8b72cd0250 (diff)
downloadsamba-9c7b042f31ee63a8b00aeeb9b530d1a405c715f5.tar.gz
samba-9c7b042f31ee63a8b00aeeb9b530d1a405c715f5.tar.bz2
samba-9c7b042f31ee63a8b00aeeb9b530d1a405c715f5.zip
print the timezone in the same format as 'date +%z' - much better for scripting
(This used to be commit faa1b222f170abe34f6930bb3493cbe8b4df4082)
Diffstat (limited to 'source3')
-rw-r--r--source3/utils/net_time.c13
1 files changed, 8 insertions, 5 deletions
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;
}