zone 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +114 -14
- data/exe/zone +14 -2
- data/lib/zone/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 48ffc5f23c1380e609e45c5f5a934b73663f697ca2a42326db020abafe1b73d4
|
|
4
|
+
data.tar.gz: d0c55e0563de05b15b01ca129476f59fe2c61129c997dc3c505bf7f9c40d8b5c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a9dd64f6fe00be2fd8999e6dbc20310c266ef2089ce81e367c34cc7f39e38fc9cf1d70471eff3f70f18d2ad0e37d4b68d3fc57019cd1ee289135bb7751864a10
|
|
7
|
+
data.tar.gz: 6c99b5f7ca51350827e6bea1c7dee0b0226069679f79c1f16685517ad0b7565b1cea9ecc89a7c556ae0121ec20998ff71126328c905e13357aa6f14832050156
|
data/README.md
CHANGED
|
@@ -1,39 +1,139 @@
|
|
|
1
1
|
# Zone
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Timezone conversion and datetime formatting for the command line
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```bash
|
|
6
|
+
# Fuzzy timezone matching
|
|
7
|
+
zone --zone tokyo 2025-11-05T02:40:32+00:00
|
|
8
|
+
# => 2025-11-05T11:40:32+09:00
|
|
9
|
+
|
|
10
|
+
# Process CSV timestamps
|
|
11
|
+
cat data.csv | zone --index 3 --zone pacific --pretty
|
|
12
|
+
# => customer,purchase_date,amount
|
|
13
|
+
# => alice,42.00,Nov 04 - 06:40 PM PST
|
|
14
|
+
|
|
15
|
+
# Make logs readable
|
|
16
|
+
tail -f app.log | zone --pretty --zone local
|
|
17
|
+
# => Nov 04 - 09:15 PM EST [ERROR] Database connection timeout
|
|
18
|
+
```
|
|
6
19
|
|
|
7
20
|
## Installation
|
|
8
21
|
|
|
9
|
-
|
|
22
|
+
```bash
|
|
23
|
+
gem install zone
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or with Bundler:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
bundle add zone
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
10
33
|
|
|
11
|
-
|
|
34
|
+
Convert timezones:
|
|
12
35
|
|
|
13
36
|
```bash
|
|
14
|
-
|
|
37
|
+
zone --zone 'New York' '2025-11-05T02:40:32+00:00'
|
|
38
|
+
# => 2025-11-04T21:40:32-05:00
|
|
15
39
|
```
|
|
16
40
|
|
|
17
|
-
|
|
41
|
+
Change formats:
|
|
18
42
|
|
|
19
43
|
```bash
|
|
20
|
-
|
|
44
|
+
zone --unix 'Nov 04 - 06:42 PM PST'
|
|
45
|
+
# => 1730775720
|
|
46
|
+
|
|
47
|
+
zone --strftime '%Y-%m-%d %H:%M' '2025-11-05T02:40:32+00:00'
|
|
48
|
+
# => 2025-11-05 02:40
|
|
21
49
|
```
|
|
22
50
|
|
|
23
|
-
|
|
51
|
+
Process structured data:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Convert column 2, auto-detect delimiter
|
|
55
|
+
cat events.csv | zone --index 2 --zone UTC
|
|
56
|
+
|
|
57
|
+
# Skip header row
|
|
58
|
+
zone --headers --delimiter '\t' < data.tsv
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Multiple timestamps:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
zone 1730772120 1730858520 1730944920 --zone tokyo --pretty
|
|
65
|
+
# => Nov 05 - 11:42 AM JST
|
|
66
|
+
# => Nov 06 - 11:42 AM JST
|
|
67
|
+
# => Nov 07 - 11:42 AM JST
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Options
|
|
71
|
+
|
|
72
|
+
**Output Formats**
|
|
73
|
+
|
|
74
|
+
- `--iso8601` - ISO 8601 format (default)
|
|
75
|
+
- `--unix` - Unix timestamp
|
|
76
|
+
- `--pretty` - Human-readable (e.g., "Nov 04 - 06:40 PM PST")
|
|
77
|
+
- `--strftime FORMAT` - Custom format
|
|
24
78
|
|
|
25
|
-
|
|
79
|
+
**Timezones**
|
|
26
80
|
|
|
27
|
-
|
|
81
|
+
- `--zone TZ` - Convert to timezone (fuzzy matching)
|
|
82
|
+
- `--utc` - Convert to UTC
|
|
83
|
+
- `--local` - Convert to local time
|
|
28
84
|
|
|
29
|
-
|
|
85
|
+
**Data Processing**
|
|
86
|
+
|
|
87
|
+
- `--index N` - Column to convert (default: 1)
|
|
88
|
+
- `--delimiter PATTERN` - Field separator (auto-detected)
|
|
89
|
+
- `--headers` - Skip first line
|
|
90
|
+
|
|
91
|
+
**Other**
|
|
92
|
+
|
|
93
|
+
- `--verbose` - Show debug output
|
|
94
|
+
- `--help` - Show help
|
|
95
|
+
|
|
96
|
+
## Examples
|
|
97
|
+
|
|
98
|
+
Analyze logs across timezones:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
grep "ERROR" app.log | zone --zone local --pretty
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Convert trading data:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
zone --zone 'New York' --strftime '%H:%M:%S' < trades.csv
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Quick conversions:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
zone --zone berlin "3pm PST"
|
|
114
|
+
# => 2025-11-05T00:00:00+01:00
|
|
115
|
+
|
|
116
|
+
zone --zone pacific now
|
|
117
|
+
# => 2025-11-04T16:42:15-08:00
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Timezone Matching
|
|
121
|
+
|
|
122
|
+
Zone uses fuzzy matching for timezone names:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
zone --zone pacific # => US/Pacific
|
|
126
|
+
zone --zone tokyo # => Asia/Tokyo
|
|
127
|
+
zone --zone europe # => Europe/London (first match)
|
|
128
|
+
zone --zone 'US/Eastern' # => US/Eastern (exact match)
|
|
129
|
+
```
|
|
30
130
|
|
|
31
|
-
|
|
131
|
+
Use `--verbose` to see which timezone was matched.
|
|
32
132
|
|
|
33
133
|
## Contributing
|
|
34
134
|
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub
|
|
135
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/gillisd/zone).
|
|
36
136
|
|
|
37
137
|
## License
|
|
38
138
|
|
|
39
|
-
|
|
139
|
+
[MIT License](https://opensource.org/licenses/MIT)
|
data/exe/zone
CHANGED
|
@@ -11,16 +11,28 @@ require 'date'
|
|
|
11
11
|
|
|
12
12
|
options = { delimiter: nil, strftime: nil, iso8601: false, pretty: false, headers: false, unix: false, index: 1, zone: nil, utc: false, local: false }
|
|
13
13
|
parser = OptionParser.new do |parser|
|
|
14
|
-
parser.
|
|
15
|
-
parser.
|
|
14
|
+
parser.banner = "Usage: zone [options] [timestamps...]"
|
|
15
|
+
parser.separator ""
|
|
16
|
+
parser.separator "Output Formats:"
|
|
16
17
|
parser.on '--iso8601', 'Output in ISO 8601 (default: true)'
|
|
17
18
|
parser.on '--strftime FORMAT', '-f', 'Output format using strftime (default: none)'
|
|
18
19
|
parser.on '--pretty', 'Output in pretty format (e.g., "Jan 02 - 03:04 PM")'
|
|
19
20
|
parser.on '--unix', 'Output as Unix timestamp (default: false)'
|
|
21
|
+
|
|
22
|
+
parser.separator ""
|
|
23
|
+
parser.separator "Timezones:"
|
|
20
24
|
parser.on '--zone TZ', 'Convert to time zone (default: local time zone)'
|
|
21
25
|
parser.on '--local', 'Convert to local time zone (alias for --zone local)'
|
|
22
26
|
parser.on '--utc', 'Convert to UTC time zone (alias for --zone UTC)'
|
|
27
|
+
|
|
28
|
+
parser.separator ""
|
|
29
|
+
parser.separator "Data Processing:"
|
|
30
|
+
parser.on '--index N', '-i N', Integer, 'Index of the field to convert (default: 1)'
|
|
31
|
+
parser.on '--delimiter PATTERN', '-d', 'Field delimiter (default: space)'
|
|
23
32
|
parser.on '--headers', 'Skip the first line as headers'
|
|
33
|
+
|
|
34
|
+
parser.separator ""
|
|
35
|
+
parser.separator "Other:"
|
|
24
36
|
parser.on '--verbose', '-v', 'Enable verbose/debug output'
|
|
25
37
|
parser.on '--help', '-h', 'Show this help message' do
|
|
26
38
|
puts parser
|
data/lib/zone/version.rb
CHANGED