Skip to content

Commit 48e62fd

Browse files
authored
Add some notes on usage and build (#1)
* Fix a typo in the Makefile * Print out the unknown timezone in the example * Add some more details on usage and the build * More notes on the build and the IANA tz db * Remove unnecessary spaces in the Makefile
1 parent fe59e2a commit 48e62fd

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
CC=gcc
22
CFLAGS=-I.
3-
DEPS = zones.h
3+
DEPS=zones.h
44
TAG=posix-tz-db
55

66
.PHONY: all clean example docker
77

88
all: zones.o zones.h zones.json zones.csv
99

10-
# zones.o intentionally does not depend on making zones.c, since zones.c requires the
11-
# consistent build environment provided by Docker or Arch Linux, and would only get
12-
# actually need an update a couple times a year or so. zones.c is checked in to source
13-
# control though, so build it once when it gets updated, commit it, and you're good.
10+
# `zones.o` intentionally does not depend on making `zones.c`, since `zones.c` requires the
11+
# consistent build environment provided by Docker or the latest Arch Linux, and would only
12+
# actually need an update a few times a year or so. `zones.c` is checked in to source
13+
# control though, so build it when it gets updated, commit it, and you're good.
1414
zones.o: zones.h
1515
$(CC) -c -o zones.o $(CFLAGS) zones.c
1616

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,14 @@ An embeddable mapping between [IANA Time Zone Database](https://www.iana.org/tim
55
In this way, more user-friendly names can be used in a timezone-setting API, and
66
timezone rules can be easily updated with a firmware upgrade.
77

8+
### Usage
9+
10+
See `example/example.c` for an embedded use case.
11+
812
Provide user-facing clients with `zones.json` to have a shared timezone vocabulary with the embedded library.
13+
14+
### Build
15+
16+
Since the build is heavily environment-dependant, the Dockerfile provides a consistent build environment — latest Arch Linux. When the IANA timezone database updates (a few times a year, usually: see the latest version [here](https://www.iana.org/time-zones) and compare to the release name/date), just run `make` in the root directory to rebuild all the "data" build artifacts (`zones.c` etc.). These data build artifacts can be checked in to source control since they change so infrequently.
17+
18+
If the IANA timezone database hasn't changed, you can just build `zones.o`, which isn't as sensitive to the build environment.

example/example.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void print_local_time(const char *name) {
2727
strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
2828
printf("The current date/time in %s is: %s\n", name, strftime_buf);
2929
} else {
30-
printf("Unknown timezone!\n");
30+
printf("%s is not a known timezone!\n", name);
3131
}
3232

3333
}
@@ -37,4 +37,4 @@ int main() {
3737
print_local_time("Asia/Shanghai");
3838
print_local_time("Europe/Lisbon");
3939
print_local_time("亚洲/武汉");
40-
}
40+
}

0 commit comments

Comments
 (0)