aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2018-12-22 18:20:41 -0200
committerEuAndreh <eu@euandre.org>2018-12-22 18:20:41 -0200
commit09d0598347522ce376d9c1be13795e7179896de9 (patch)
tree581c3a0242cd9b7d3dbca27665e1f138e02aed27
parentMove external scripts to bin/. (diff)
downloaddotfiles-09d0598347522ce376d9c1be13795e7179896de9.tar.gz
dotfiles-09d0598347522ce376d9c1be13795e7179896de9.tar.xz
Remove autotime script.
-rwxr-xr-xscripts/autotime76
1 files changed, 0 insertions, 76 deletions
diff --git a/scripts/autotime b/scripts/autotime
deleted file mode 100755
index fb01392..0000000
--- a/scripts/autotime
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/usr/bin/env perl6
-
-# FIXME: stdin support with lines()
-# FIXME: --help and -h support
-
-sub from-timestamp(Int \timestamp) {
- sub formatter($_) {
- sprintf '%04d-%02d-%02d %02d:%02d:%02d',
- .year, .month, .day,
- .hour, .minute, .second,
- }
- given DateTime.new(+timestamp, :&formatter) {
- when .Date.DateTime == $_ { return .Date }
- default { return $_ }
- }
-}
-
-sub from-date-string(Str $date, Str $time?) {
- my $d = Date.new($date);
- if $time {
- my ( $hour, $minute, $second ) = $time.split(':');
- return DateTime.new(date => $d, :$hour, :$minute, :$second);
- } else {
- return $d.DateTime;
- }
-}
-
-# FIXME: add test
-multi sub convert(Int \timestamp) {
- from-timestamp(+timestamp);
-}
-
-# FIXME: add test
-multi sub convert(Str $date where { try Date.new($_) }, Str $time?) {
- from-date-string($date, $time).posix;
-}
-
-# FIXME: add test
-#| Convert timestamp to ISO date
-multi sub MAIN(Int \timestamp) {
- say convert(+timestamp);
-}
-
-# FIXME: add test
-#| Convert ISO date to timestamp
-multi sub MAIN(Str $date where { try Date.new($_) }, Str $time?) {
- say convert($date, $time);
-}
-
-# multi sub MAIN() {
-# for lines() -> $line {
-
-# }
-# }
-
-#| Run internal tests
-multi sub MAIN('test') is hidden-from-USAGE {
- use Test;
- plan 2;
- subtest 'timestamp', {
- plan 2;
- is-deeply from-timestamp(1450915200), Date.new('2015-12-24'),
- 'Date';;
- my $dt = from-timestamp(1450915201);
- is $dt, "2015-12-24 00:00:01",
- 'DateTime with string formatting';
- };
- subtest 'from-date-string', {
- plan 2;
- is from-date-string('2015-12-24').posix, 1450915200,
- 'one argument';
- is from-date-string('2015-12-24', '00:00:01').posix,
- 1450915201,
- 'two arguments';
- };
-}