Dynamically build rebar3 if needed
Also tweaked `tz-erl` with some proposed updates from https://github.com/choptastic/qdate_localtime/pull/1
This commit is contained in:
parent
cf9e726d1b
commit
3127dcddfb
6 changed files with 43 additions and 19 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@ _build/
|
|||
*~
|
||||
src/tz_index.erl
|
||||
*.sw?
|
||||
rebar3
|
||||
|
|
21
Makefile
21
Makefile
|
@ -1,11 +1,24 @@
|
|||
all:
|
||||
all: rebar3
|
||||
./rebar3 compile
|
||||
|
||||
check:
|
||||
check: rebar3
|
||||
./rebar3 eunit
|
||||
|
||||
dialyzer:
|
||||
dialyzer: rebar3
|
||||
./rebar3 dialyzer
|
||||
|
||||
publish:
|
||||
publish: rebar3
|
||||
./rebar3 hex publish
|
||||
|
||||
rebar3:
|
||||
@(echo "Building rebar3...")
|
||||
@(rm -fr tmp)
|
||||
@(mkdir -p tmp)
|
||||
@(cd tmp && \
|
||||
git clone https://github.com/erlang/rebar3 && \
|
||||
cd rebar3 && \
|
||||
./bootstrap)
|
||||
@(echo "Moving rebar3 executable locally (NOT installing system-wide)")
|
||||
@(mv tmp/rebar3/rebar3 .)
|
||||
@(echo "Cleaning up rebar3 remnants")
|
||||
@(rm -fr tmp)
|
||||
|
|
24
README.md
24
README.md
|
@ -1,21 +1,21 @@
|
|||
## NOTE
|
||||
|
||||
This is a fork of
|
||||
[erlang_localtime](https://github.com/dmitryme/erlang_localtime), modified
|
||||
specifically for compatibility with
|
||||
This is a fork of the excellent library,
|
||||
[erlang_localtime](https://github.com/dmitryme/erlang_localtime). The purpose
|
||||
of this fork is specifically for compatibility with
|
||||
[qdate](https://github.com/choptastic/qdate). The two are mostly compatible,
|
||||
but have diverged a bit over the years. The qdate tests will not pass if the
|
||||
original erlang_localtime dependency is used due to some subtle differences to
|
||||
attempt to make qdate a little bit smarter.
|
||||
but have diverged slightly over the years. The qdate tests will not pass if the
|
||||
original `erlang_localtime dependency` is used due to some subtle differences
|
||||
to attempt to make qdate a little bit smarter.
|
||||
|
||||
#### Public exports
|
||||
|
||||
* utc_to_local(DateTime, Timezone) - converts UTC time to local according to specified Timezone
|
||||
* local_to_utc(DateTime, Timezone) - converts local time to UTC
|
||||
* local_to_local(DateTime, TimezoneFrom, TimezoneTo) - converts local time to local
|
||||
* tz_name(DateTime, Timezone) - returns a timezone name (E.g. MSK, MSD, etc)
|
||||
* tz_shift(DateTime, Timezone) - returns time difference between local datetime and GMT
|
||||
* tz_shift(DateTime, TimezoneFrom, TimezoneTo) - returns time difference between local datetime and required timezone
|
||||
* `utc_to_local(DateTime, Timezone)` - converts UTC time to local according to specified Timezone
|
||||
* `local_to_utc(DateTime, Timezone)` - converts local time to UTC
|
||||
* `local_to_local(DateTime, TimezoneFrom, TimezoneTo)` - converts local time to local
|
||||
* `tz_name(DateTime, Timezone)` - returns a timezone name (E.g. MSK, MSD, etc)
|
||||
* `tz_shift(DateTime, Timezone)` - returns time difference between local datetime and GMT
|
||||
* `tz_shift(DateTime, TimezoneFrom, TimezoneTo)` - returns time difference between local datetime and required timezone
|
||||
Where
|
||||
DateTime = {date(), time()}
|
||||
TimeZone(To, From) = String(). E.g. “Europe/Moscow”, “America/NewYork”. Or abbreviations "MSK", "MSD", etc. Note:
|
||||
|
|
15
db/tz-erl
15
db/tz-erl
|
@ -459,11 +459,16 @@ sub on_to_day_of_month {
|
|||
my $day;
|
||||
if ($on =~ m/^\d+$/) {
|
||||
$day = $on;
|
||||
print "Day extracted via regex to: $day\n";
|
||||
} else {
|
||||
my ($desired_dow, $time_base);
|
||||
if ($on =~ m/^(\w+)>=(\d+)$/) {
|
||||
$desired_dow = $dow_from_name{$1}; my $desired_day = $2;
|
||||
$time_base = timelocal(0, 0, 0, $desired_day, $month, $year);
|
||||
print "Regex: $on => desired_dow: $desired_dow. Time_base: $time_base\n";
|
||||
} elsif ($on =~ m/^(\w+)<=(\d+)$/) {
|
||||
$desired_dow = $dow_from_name{$1}; my $desired_day = $2;
|
||||
$time_base = timelocal(0, 0, 0, $desired_day, $month, $year);
|
||||
} elsif ($on =~ m/^last(\w+)$/) {
|
||||
$desired_dow = $dow_from_name{$1};
|
||||
# One week before the beginning of the next month.
|
||||
|
@ -472,7 +477,12 @@ sub on_to_day_of_month {
|
|||
die "match $on failed";
|
||||
}
|
||||
($day, my $dow) = (localtime($time_base))[3,6];
|
||||
if ($dow != $desired_dow) { $day += (DPW + $desired_dow - $dow) % DPW; }
|
||||
print "Current Day: $day\n";
|
||||
print "Comparing $dow = $desired_dow\n";
|
||||
if ($dow != $desired_dow) {
|
||||
$day += (DPW + $desired_dow - $dow) % DPW;
|
||||
}
|
||||
print "After comparison: Current Day: $day\n";
|
||||
}
|
||||
|
||||
return $day;
|
||||
|
@ -511,6 +521,7 @@ sub last_active_epoch {
|
|||
}
|
||||
|
||||
my $day = on_to_day_of_month($on, $year, $month);
|
||||
return timelocal(0, 0, 0, $day, $month, $year);
|
||||
print "On=$on, Year=$year, Month=$month ====> Day=$day\n";
|
||||
return timelocal_nocheck(0, 0, 0, $day, $month, $year);
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
[].
|
BIN
rebar3
BIN
rebar3
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue