Skip to content

Commit f6561ab

Browse files
committed
defs
1 parent f580501 commit f6561ab

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

Makefile

+22-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ updatenightly: local/bin/pmbp.pl
1111
$(GIT) add config
1212
$(CURL) -sSLf https://raw.githubusercontent.com/wakaba/ciconfig/master/ciconfig | RUN_GIT=1 REMOVE_UNUSED=1 perl
1313

14+
clean: clean-json-ps
15+
1416
## ------ Setup ------
1517

16-
deps: git-submodules pmbp-install
18+
deps: git-submodules pmbp-install build
1719

1820
git-submodules:
1921
$(GIT) submodule update --init
@@ -32,10 +34,28 @@ pmbp-install: pmbp-upgrade
3234
--create-perl-command-shortcut @perl \
3335
--create-perl-command-shortcut @prove
3436

35-
## ------ Tests ------
37+
json-ps: local/perl-latest/pm/lib/perl5/JSON/PS.pm
38+
clean-json-ps:
39+
rm -fr local/perl-latest/pm/lib/perl5/JSON/PS.pm
40+
local/perl-latest/pm/lib/perl5/JSON/PS.pm:
41+
mkdir -p local/perl-latest/pm/lib/perl5/JSON
42+
$(WGET) -O $@ https://raw.githubusercontent.com/wakaba/perl-json-ps/master/lib/JSON/PS.pm
43+
44+
build: json-ps build-main
45+
46+
build-main: src/time.js
3647

3748
PERL = ./perl
3849

50+
local/dts.json:
51+
$(WGET) -O $@ https://raw.githubusercontent.com/manakai/data-locale/master/data/calendar/dts.json
52+
local/dts-defs.js: bin/dts-defs.pl local/dts.json
53+
$(PERL) $< > $@
54+
src/time.js: src/time-main.js local/dts-defs.js
55+
cat src/time-main.js local/dts-defs.js > $@
56+
57+
## ------ Tests ------
58+
3959
test: test-deps test-main
4060

4161
test-deps: deps

bin/dts-defs.pl

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use strict;
2+
use warnings;
3+
use Path::Tiny;
4+
use JSON::PS;
5+
6+
my $RootPath = path (__FILE__)->parent->parent;
7+
8+
my $DTSes = [];
9+
{
10+
my $DefsPath = $RootPath->child ('local/dts.json');
11+
my $defs = json_bytes2perl $DefsPath->slurp;
12+
for my $key (qw(dtsjp1 dtsjp2)) {
13+
my $v = $defs->{dts}->{$key}->{patterns};
14+
for (@$v) {
15+
$_->[0] = ($_->[0] - 2440587.5) #* 24 * 60 * 60 * 1000
16+
if defined $_->[0];
17+
}
18+
push @$DTSes, '"' . $key . '":' . perl2json_bytes $v;
19+
}
20+
}
21+
22+
print 'TER.defs = {"dts":{', (join ',', @$DTSes), '}};';
23+
24+
## License: Public Domain.

src/time.js

+1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)