1
+ =========
1
2
when 🌐🕐
2
3
=========
3
4
@@ -17,64 +18,113 @@ Scenario
17
18
--------
18
19
19
20
Your favorite sporting event, concert, performance, conference, or symposium is happening
20
- in Ulan Bator and all you know is the time of event is relative to the location city or time zone.
21
- But wait! You need to know when that occurs relative to you while traveling to Seoul or Paris.
21
+ in Ulan Bator and all you know is the time of event relative to the city or time zone.
22
+ So what time is that for you in your local time? What time did it or will it occur at some
23
+ other time? What about for your friends in other locations around the world?
24
+
25
+ Features
26
+ --------
27
+
28
+ ``when `` can refer to source and target locations via the ``--source `` and ``--target `` specifiers.
29
+
30
+ * ``when `` can download a GeoNames _ cities database for referencing locations by city name
31
+ * All IANA time zone definitions are available, as well as the most common time zone aliases (i.e.: ``EST `` => ``US/Eastern ``)
32
+ * Display current lunar state
33
+ * List common holidays for a given country and/or year (US or configurable)
34
+ * Show dates for full moons
35
+ * Extensive configuration options for results
36
+ * JSON output
22
37
23
38
Installation
24
- ------------
39
+ ============
40
+
41
+ Install from PyPI:
25
42
26
- Install from PyPI::
43
+ .. code :: bash
27
44
28
45
$ pip install when
29
46
30
- or using pipx _::
47
+ or using pipx _:
48
+
49
+ .. code :: bash
31
50
32
51
$ pipx install when
33
52
34
- or::
53
+ or:
54
+
55
+ .. code :: bash
35
56
36
57
$ pipx install git+https://github.com/dakrauth/when.git
37
58
38
- .. _pipx : https://pypa.github.io/pipx/
59
+ .. note ::
60
+
61
+ Once installed, if you wish to utilize ``when ``'s full capabilities, you should
62
+ install the GeoNames cities database as describe next.
39
63
40
- To access city names, you must install the cities database::
64
+
65
+
66
+ Database installation
67
+ ---------------------
68
+
69
+ To access city names, you need to install the cities database after installing the ``when `` application:
70
+
71
+ .. code :: bash
41
72
42
73
when --db [options]
43
74
44
- For ``options ``:
75
+ Where ``options `` are:
76
+
77
+ * ``--db-size ``: You can specify a database down size by using one of the following:
78
+
79
+ * ``sm `` - cities with population > 15,000 + country capitals (~2.9M download, ~2M DB)
80
+ * ``md `` - **default **, same as ``sm ``, plus:
81
+
82
+ * cities with population > 5,000 (~4.8M download, ~3.1M DB)
83
+ * seat of first-order admin division, i.e. US state
84
+
85
+ * ``lg `` - same as ``md ``, plus:
86
+
87
+ * cities with population > 1,000 (~9.5M download, ~5.8M DB)
88
+ * seat of admin division down to third level (counties)
89
+
90
+ * ``xl `` - same as ``lg ``, plus:
91
+
92
+ * cities with population > 500 (~12.1M download, ~7.2M DB)
93
+ * seat of admin division down to fourth order
45
94
46
- You can specify minimum city size by adding ``--size SIZE ``, where *SIZE * can be one of:
95
+ * ``--db-pop ``: Filter non-admin division seats providing a minimum city population size
96
+ * ``--db-force ``: Force an existing database to be overwritten
47
97
48
- - ``15000 `` - cities with population > 15000 or country capitals
49
- - ``5000 `` - cities with population > 5000 or seat of first-order admin division, i.e. US state
50
- - ``1000 `` - cities with population > 1000 or seat of third order admin division
51
- - ``500 `` - cities with population > 500 or seat of fourth-order admin division
98
+ Database Usage
99
+ ==============
52
100
53
- Additionally, you can filter non-admin division seats using ``--pop POP ``.
101
+ * Search: ``--db-search ``
54
102
55
- The appropriate GeoNames Gazetteer is downloaded and a Sqlite database generated.
103
+ Once installed, you can search the database:
56
104
57
- Usage
58
- -----
105
+ .. code :: bash
59
106
60
- Once installed, you can search the database::
107
+ $ when --db-search New York
108
+ 5106292, West New York, West New York, US, New Jersey, America/New_York
109
+ 5128581, New York City, New York City, US, New York, America/New_York
61
110
62
- $ when --db-search New York
63
- 5106292, West New York, West New York, US, New Jersey, America/New_York
64
- 5128581, New York City, New York City, US, New York, America/New_York
111
+ * Aliases: ``--db-alias ``
65
112
113
+ You can add aliases for easier search. In the example directly above, we see that New York City has
114
+ a GeoNames ID of 5128581. Pass that to the ``--db-alias `` option along with another name that
115
+ you would like to use:
66
116
67
- Additionally, you can add aliases. In the example directly above, we see that New York City has
68
- a GeoNames ID of 5128581. Pass that to the ``--db-alias `` option along with another name that
69
- you would like to use::
117
+ .. code :: bash
70
118
71
- $ when --db-alias 5128581 NYC
72
- $ when --source NYC
73
- 2023-07-06 07:58:33-0400 (EDT, America/New_York) 187d27w (New York City, New York, US)[🌕 Full Moon]
119
+ $ when --db-alias 5128581 NYC
120
+ $ when --source NYC
121
+ 2023-07-06 07:58:33-0400 (EDT, America/New_York) 187d27w (New York City, New York, US)[🌕 Full Moon]
74
122
123
+ * Alias listing: ``--db-aliases ``
75
124
76
- Example
77
- -------
125
+
126
+ Examples
127
+ ========
78
128
79
129
For the sake of clarity, in the following examples I am in Seoul, Korea.
80
130
@@ -101,24 +151,100 @@ For the sake of clarity, in the following examples I am in Seoul, Korea.
101
151
1945-03-07 22:00:00-0400 (EWT, America/New_York) 066d10w [🌘 Waning Crescent]
102
152
103
153
104
- Develop
105
- -------
154
+ Development
155
+ ===========
106
156
107
- Requirements Python 3.10+. Also, [just](https://github.com/casey/just) for convenience.
157
+ Requires Python 3.10+ and just _ for convenience.
108
158
109
159
.. code :: bash
110
160
111
161
$ git clone git@github.com:dakrauth/when.git
112
162
$ cd when
113
- $ just
114
- $ just venv
163
+ $ just # or just help
164
+
165
+ Set up dev env:
166
+
167
+ .. code :: bash
168
+
169
+ $ just init
170
+
171
+ Test, and code coverage:
172
+
173
+ .. code :: bash
174
+
115
175
$ just test
176
+ $ just cov
177
+
178
+ Only run a test matching matching a given substring:
179
+
180
+ .. code :: bash
181
+
182
+ $ just test -k test_sometest
183
+
184
+ Interactive development:
185
+
186
+ .. code :: bash
187
+
116
188
$ . ./venv/bin/activate
117
189
$ when --help
118
190
$ when --db
119
191
120
192
Further Reading
121
- ---------------
193
+ ===============
194
+
195
+ `Time Zones Aren’t Offsets – Offsets Aren’t Time Zones `_
196
+
197
+ .. _pipx : https://pypa.github.io/pipx/
198
+ .. _just : https://github.com/casey/just
199
+ .. _`Time Zones Aren’t Offsets – Offsets Aren’t Time Zones` : https://spin.atomicobject.com/time-zones-offsets/)
200
+ .. _GeoNames : https://www.geonames.org/export/
201
+
202
+ Complete Usage
203
+ ==============
204
+
205
+ .. code :: bash
206
+
207
+ usage: when [--delta {long,short}] [--offset [+-]? (\d +wdhm)+] [-h] [--prefix] [-s SOURCE] [-t TARGET] [-f FORMAT] [-g] [--all]
208
+ [--holidays COUNTRY_CODE] [-v] [-V] [--json] [--config] [--db] [--db-force] [--db-search] [--exact] [--db-alias DB_ALIAS]
209
+ [--db-aliases] [--db-size DB_SIZE] [--db-pop DB_POP] [--tz-alias] [--fullmoon]
210
+ [timestr ...]
211
+
212
+ Convert times to and from time zones or cities
213
+
214
+ positional arguments:
215
+ timestr Timestamp to parse, defaults to local time
216
+
217
+ options:
218
+ --delta {long,short} Show the delta to the given timestamp
219
+ --offset [+-]? (\d +wdhm)+
220
+ Show the difference from a given offset
221
+ -h, --help Show helpful usage information
222
+ --prefix Show when' s directory
223
+ -s SOURCE, --source SOURCE
224
+ Timezone / city to convert the timestr from, defaulting to local time
225
+ -t TARGET, --target TARGET
226
+ Timezone / city to convert the timestr to (globbing patterns allowed, can be comma delimited), defaulting to local
227
+ time
228
+ -f FORMAT, --format FORMAT
229
+ Output formatting. Additional formats can be shown using the -v option with -h
230
+ -g, --group Group sources together under same target results
231
+ --all Show times in all common timezones
232
+ --holidays COUNTRY_CODE
233
+ Show holidays for given country code.
234
+ -v, --verbosity Verbosity (-v, -vv, etc). Use -v to show `when` extension detailed help
235
+ -V, --version show program' s version number and exit
236
+ --json Output results in nicely formatted JSON
237
+ --config Toggle config mode. With no other option, dump current configuration settings
238
+ --db Create cities database, used with --db-size and --db-pop
239
+ --db-force Force an existing database to be overwritten
240
+ --db-search Search database for the given city
241
+ --exact DB searches must be exact
242
+ --db-alias DB_ALIAS Create a new alias from the city id
243
+ --db-aliases Show all DB aliases
244
+ --db-size DB_SIZE Geonames file size. Can be one of ' xl' (' xlarge' ), ' lg' (' large' ), ' md' (' medium' ), ' sm' (' small' ).
245
+ --db-pop DB_POP City population minimum.
246
+ --tz-alias Search for a time zone alias
247
+ --fullmoon Show full moon(s) for given year or month. Can be in the format of: ' next' | ' prev' | YYYY[-MM]
248
+
249
+ Use -v option for details
122
250
123
- [Time Zones Aren’t Offsets – Offsets Aren’t Time Zones
124
- ](https://spin.atomicobject.com/time-zones-offsets/)
0 commit comments