Skip to content

Commit fa71136

Browse files
committed
Major refactor and rewrite. New formatters. New CLI flags. New tests. Updated README.md.
1 parent 95c4a39 commit fa71136

File tree

9 files changed

+1420
-394
lines changed

9 files changed

+1420
-394
lines changed

Cargo.toml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
[package]
2-
name = "holocene"
3-
version = "0.1.0"
4-
edition = "2021"
2+
name = "hedate"
3+
version = "0.1.1"
4+
edition = "2024"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
chrono = { version = "0.4.31", features = [] }
10-
chrono-tz = "0.8.4"
11-
clap = { version = "4.4.7", features = ["derive"] }
12-
regex = "1.10.2"
13-
14-
[build]
15-
rustc-wrapper = "/opt/homebrew/bin/sccache"
9+
chrono = { version = "0.4.42", features = [] }
10+
chrono-tz = "0.10.4"
11+
clap = { version = "4.5.53", features = ["derive"] }
12+
regex = "1.12.2"

README.md

Lines changed: 178 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,209 @@
1-
# holocene
1+
# hedate
22

3-
Takes advantage of the `chrono` crate to provide a GNU `date` like interface for convert dates to the Holocene calendar.
3+
`hedate` is a Holocene/Human Era-aware (_GNU_) `date`-like utility for
4+
converting, formatting, and expressing dates in the Holocene/Human Era calendar
5+
system.
46

5-
## Known issues
7+
> What is the Holocene calendar?
8+
>
9+
> https://en.wikipedia.org/wiki/Holocene_calendar
10+
>
11+
> According to Wikipedia: "The Holocene calendar, also known as the Holocene Era
12+
> or Human Era (HE), is a year numbering system that adds exactly 10,000 years
13+
> to the currently dominant (AD/BC or CE/BCE) numbering scheme, placing its
14+
> first year near the beginning of the Holocene geological epoch and the
15+
> Neolithic Revolution, when humans shifted from a hunter-gatherer lifestyle to
16+
> agriculture and fixed settlements."
617
7-
* Timezone support is not implemented yet. UTC is assumed.
8-
* Years must be zero padded to 4 digits. E.g. `0001` instead of `1`.
18+
The Holocene/Human Era calendar is a way to date the full span of human history
19+
by counting years from the beginning of the Holocenem, which marks the start of
20+
settled human civilization. It helps simplify mental models of human history.
921

10-
## Example usage
22+
Date examples:
23+
24+
| Event | Human Era Date | Gregorian Date |
25+
| -------------------------- | --------------- | -------------- |
26+
| Start of Holocene Era | 0 HE | 10 000 BCE |
27+
| Founding of Athens | 9492 HE | 508 BCE |
28+
| Founding of Rome | 9247 HE | 753 BCE |
29+
| Conquest of Constantinople | 29 May 11453 HE | 29 May 1453 CE |
30+
| Unix Epoch | 1 Jan 11970 HE | 1 Jan 1970 CE |
31+
| Present year | 12025 HE | 2025 CE |
32+
33+
Weekdays follow the proleptic Gregorian weekday cycle for all dates, both
34+
backward and forward in time.
35+
36+
## Usage
37+
38+
`hedate --help`
39+
40+
```
41+
Holocene/Human Era date command
42+
43+
Usage: hedate [OPTIONS] [format]...
44+
45+
Arguments:
46+
[format]... Format string (prefix with +)
47+
48+
Options:
49+
-d, --date <STRING> Date string
50+
--help Print help information
51+
-u, --utc Use Coordinated Universal Time
52+
-z, --timezone <OFFSET|TZ> Set timezone offset (e.g., -08:00, +05:30, 08:00) or common abbrev (PST, EST)
53+
--rfc-2822 Output date and time in RFC 2822 format
54+
--rfc-email Output date and time in RFC 5322 format (alias for --rfc-2822)
55+
--rfc-3339 [<TIMESPEC>] Output date and time in RFC 3339 format (TIMESPEC: date, seconds, ns) [possible values: date, seconds, ns]
56+
-I, --iso-8601 [<FMT>] Output date/time in ISO 8601 format (FMT: date, hours, minutes, seconds, ns) [possible values: date, hours, minutes, seconds, ns]
57+
-g, --gregorian Explicitly interpret -d/--date as Gregorian/CE
58+
-h, --holocene Explicitly interpret -d/--date as Holocene/Human Era
59+
-f, --file <DATEFILE> Read dates to parse from file, one per line
60+
--debug Annotate parsed date and warn about questionable usage
61+
--resolution Output available timestamp resolution
62+
-V, --version Print version
63+
64+
Format presets:
65+
--rfc-2822 / --rfc-email RFC 2822/5322
66+
--rfc-3339[=date|seconds|ns]
67+
--iso-8601[=date|hours|minutes|seconds|ns]
68+
69+
Formatting tokens (Holocene-aware replacements):
70+
%Y/%y/%C Holocene years (year+10000)
71+
%E Era marker: HE
72+
%s Seconds since Holocene epoch (-9999-01-01T00:00:00Z)
73+
%N/%<n>N Nanoseconds since Holocene epoch (n = digits precision)
74+
%Z Timezone abbreviation
75+
Other tokens are passed to chrono/strftime. Relative inputs like "+1 day" are supported.
76+
77+
Weekdays follow the proleptic Gregorian weekday cycle for all dates, both backward and forward in time.
78+
```
79+
80+
## Examples
81+
82+
**Current time (local tz)**
83+
84+
```shell
85+
hedate
86+
```
87+
88+
**Current time UTC**
89+
90+
```shell
91+
hedate --utc
92+
```
93+
94+
(alias `--universal`, `-u`)
95+
96+
**Custom timezone**
97+
98+
```shell
99+
hedate -z -08:00
100+
```
101+
102+
Supports offsets like `+05:30`, `08:00`, `-06:00`, common abbreviations:
103+
`PST`/`MST`/`CST`/`EST`/`BST`/`CET`/`EET`/`IST`/`UTC`/`GMT`, and IANA names such
104+
as `America/Los_Angeles` and `Europe/London`
105+
106+
**Specific date/time**
11107

12-
View the built-in help message.
13108
```shell
14-
holocene --help
109+
hedate -d "1970/12/31 23:59:59"
15110
```
16111

17-
Get the current holocene date and time (UTC.)
112+
**Holocene input**
113+
18114
```shell
19-
holocene
115+
hedate -h -d "0337/12/31 12:01:57"
20116
```
21117

22-
Get the current holocene date and time (UTC) with custom formatting.
118+
or suffix: `-d "0337/12/31 12:01:57 HE"`
119+
120+
**BCE input**
121+
23122
```shell
24-
holocene "+%m-%d-%Y %H:%M:%S %z %Z %E"
123+
hedate -d "0337/12/31 BCE"
25124
```
26125

27-
Get the holocene date for a specific date.
126+
**Custom format**
127+
28128
```shell
29-
holocene -d "12/31/1970"
129+
hedate "+%m-%d-%Y %H:%M:%S %z %Z %E"
30130
```
131+
132+
**RFC/ISO presets**
133+
31134
```shell
32-
holocene -d "1970/12/31"
135+
hedate --rfc-3339
33136
```
34137

35-
Get the holocene date for a specific date and time (UTC.)
138+
`--rfc-2822`, `--rfc-email`, `--rfc-3339[=date|seconds|ns]`,
139+
`--iso-8601[=date|hours|minutes|seconds|ns]`
140+
141+
**Relative**
142+
36143
```shell
37-
holocene -d "12/31/1970 23:59:59"
144+
hedate -d "+1 day"`, `hedate -d "last week"`, `hedate -d "tomorrow"
38145
```
146+
147+
**File input**
148+
39149
```shell
40-
holocene -d "1970/12/31 23:59:59"
150+
hedate -f dates.txt
41151
```
42152

43-
Get a holocene date for a specific BCE date.
153+
**Resolution**
154+
44155
```shell
45-
holocene -d "12/31/0337 BCE"
156+
hedate --resolution
46157
```
47158

159+
**Debug parsing**
160+
48161
```shell
49-
holocene -d "0337/12/31 12:01:57 BCE"
162+
hedate --debug -d "12/31/1970"
50163
```
51164

52-
Get the holocene date for a specific date and time (UTC) with custom formatting.
165+
## Real World Examples
166+
167+
**Get the founding of Rome in the Human Era**
168+
53169
```shell
54-
holocene -d "12/31/1970 23:59:59" "+%m-%d-%Y %H:%M:%S %z %Z %E"
55-
```
170+
hedate -d "0753/04/21 BCE" # yyyy/mm/dd
171+
hedate -d "04/21/0753 BCE" # mm/dd/yyyy
172+
```
173+
174+
**Use the Human Era as a timestamp**
175+
176+
```shell
177+
hedate +%s # seconds
178+
hedate +%s%3N # miliseconds
179+
hedate +%s%N # nanoseconds
180+
```
181+
182+
## Behavior
183+
184+
- Calendars: auto-detect `-d` inputs (Gregorian, BCE/BC, Holocene with
185+
`HE`/`human`); force with `-g/--gregorian` or `-h/--holocene/--human`.
186+
- Timezone: local by default; `--utc/--universal/-u` for UTC; custom offsets
187+
with `-z/--timezone/--tz` (e.g., `-08:00`, `+05:30`, `08:00`) plus a few
188+
common abbreviations
189+
(`PST`/`MST`/`CST`/`EST`/`BST`/`CET`/`EET`/`IST`/`UTC`/`GMT`).
190+
- Holocene conversion: uses proleptic Gregorian with astronomical year numbering
191+
(year 0 exists); Holocene year = astronomical year + 10,000.
192+
- Epoch-based formatters: `%s`/`%N` report seconds/nanoseconds since the
193+
Holocene epoch (10,000 BCE start), not Unix epoch.
194+
- Era/year replacements: `%Y/%y/%C` emit Holocene year values; `%E` emits `HE`;
195+
`%Z` uses tz abbreviation.
196+
- Other format tokens are passed through to chrono/strftime; padding flags are
197+
handled by chrono when not overridden.
198+
199+
## Building
200+
201+
```shell
202+
cargo build --release
203+
```
204+
205+
## Testing
206+
207+
```shell
208+
cargo test
209+
```

0 commit comments

Comments
 (0)