Debian Codegraph @

cmd/utc/README

raw
1 utc: convert times to UTC
2
3 Usage: utc [-f format] [-o format] [-q] [-t] [-u] [-z zone] [time(s)...]
4 utc -h | utc help
5
6
7 utc converts times to UTC. If no arguments are provided, prints the
8 current time in UTC. If the only argument provided is "-", utc reads
9 newline-separated timestamps from standard input. If the argument is
10 "help", it will print an extended help message with examples. If both
11 the input and output timezones are the same (e.g., the local time zone
12 is UTC), a warning message will be printed on standard error. This can
13 be suppressed with the -q option.
14
15 Flags:
16
17 -f format Go timestamp format for input times. See the Go docs
18 (e.g. https://golang.org/pkg/time/#pkg-constants)
19 for an explanation of this format.
20
21 Default value: 2006-01-02 15:04
22
23 -h Print this help message.
24
25 -o format Go timestamp format for outputting times.
26 It uses the same format as the '-f' argument.
27
28 Default value: 2006-01-02 15:04 MST
29
30 -q Suppress the timezone check warning message.
31
32 -t Input times are Unix timestamps. Use with
33 -u to convert the timestamp to the timezone
34 specified by the -z option (which defaults
35 to Local).
36
37 -u Timestamps are in UTC format and should be
38 converted to the timezone specified by the
39 -z argument (which defaults to 'Local'). Note
40 that this isn't particularly useful with
41 no arguments.
42
43 -z zone Text form of the time zone; this can be in short
44 time zone abbreviation (e.g. MST) or a
45 location (e.g. America/Los_Angeles). This
46 has no effect when printing the current
47 time.
48
49 Default value: Local
50
51 Examples (note that the examples are done in the America/Los_Angeles /
52 PST8PDT time zone):
53
54 + Getting the current time in UTC:
55 $ utc
56 2016-06-14 14:30 PDT = 2016-06-14 21:30 UTC
57 + Converting a local timestamp to UTC:
58 $ utc '2016-06-14 21:30'
59 2016-06-14 21:30 PDT = 2016-06-15 04:30 UTC
60 + Converting a local EST timestamp to UTC (on a machine set to
61 PST8PDT):
62 $ utc -z EST '2016-06-14 21:30'
63 2016-06-14 21:30 EST = 2016-06-15 02:30 UTC
64 + Converting timestamps in the form '14-06-2016 3:04PM':
65 $ utc -f '02-01-2006 3:04PM' '14-06-2016 9:30PM'
66 2016-06-14 21:30 PDT = 2016-06-15 04:30 UTC
67 + Converting timestamps from standard input:
68 $ printf "2016-06-14 14:42\n2016-06-13 11:01" | utc -
69 2016-06-14 14:42 PDT = 2016-06-14 21:42 UTC
70 2016-06-13 11:01 PDT = 2016-06-13 18:01 UTC
71 + Converting a UTC timestamp to the local time zone:
72 $ utc -u '2016-06-14 21:30'
73 2016-06-14 21:30 UTC = 2016-06-14 14:30 PDT
74 + Converting a UTC timestamp to EST (on a machine set to
75 PST8PDT):
76 $ utc -u -z EST '2016-06-14 21:30'
77 2016-06-14 21:30 UTC = 2016-06-14 16:30 EST
78 + Using a different output format:
79 $ utc -o '2006-01-02T15:03:04-0700' '2016-06-14 21:30'
80 2016-06-14T21:09:30-0700 = 2016-06-15T04:04:30+0000
81 + Converting a Unix timestamp to a UTC time:
82 $ utc -t 1466052938
83 2016-06-15 21:55 PDT = 2016-06-16 04:55 UTC
84 + Converting a Unix timestamp to local time:
85 $ utc -t -u 1466052938
86 2016-06-16 04:55 UTC = 2016-06-15 21:55 PDT
87 + Converting a Unix timestamp to EST:
88 $ utc -t -u -z EST 1466052938
89 2016-06-16 04:55 UTC = 2016-06-15 23:55 EST
90 + Example of the warning message when running utc on a machine
91 where the local time zone is UTC:
92 $ utc
93
94 ==================================================================
95 Note: both input and output timezone offsets are the same --- this
96 program may not do what you expect it to.
97
98 (Converting from UTC (offset +0000) to UTC (offset +0000).)
99 ==================================================================
100 2016-06-14 23:44 = 2016-06-14 23:44
101 + Example of the warning message when running utc on a machine
102 where the local time zone is GMT:
103 $ utc
104
105 ==================================================================
106 Note: both input and output timezone offsets are the same --- this
107 program may not do what you expect it to.
108
109 (Converting from GMT (offset +0000) to UTC (offset +0000).)
110 ==================================================================
111 2016-06-14 23:46 = 2016-06-14 23:46
112