• R/O
  • SSH

kink: Commit

Kink runtime


Commit MetaInfo

Revisionc0eef9211858fdbda3de16dceec80bf30d6886a1 (tree)
Zeit2020-11-23 01:04:01
Autormiyakawataku
Commitermiyakawataku

Log Message

add Dt.show

Ändern Zusammenfassung

Diff

diff -r 72c4fa758d3d -r c0eef9211858 src/main/resources/kink-mods/kink/datetime/DATETIME.kn
--- a/src/main/resources/kink-mods/kink/datetime/DATETIME.kn Mon Nov 23 00:55:03 2020 +0900
+++ b/src/main/resources/kink-mods/kink/datetime/DATETIME.kn Mon Nov 23 01:04:01 2020 +0900
@@ -122,6 +122,17 @@
122122 DAY_OF_WEEK.from_num(Num)
123123 }
124124
125+ 'show' {[:Dt](:Config_fun.opt)
126+ '{%04d}-{%02d}-{%02d}T{%02d}:{%02d}:{%02d}'.format(
127+ Dt.year
128+ Dt.month
129+ Dt.day
130+ Dt.hour
131+ Dt.minute
132+ Dt.second
133+ )
134+ }
135+
125136 ## Dt1 < Dt2, Dt1 <= Dt2, Dt1 != Dt2, Dt1 == Dt2, Dt1 >= Dt2, Dt1 > Dt2
126137 #
127138 # `datetime` values can be compared each other by comparison operators.
diff -r 72c4fa758d3d -r c0eef9211858 src/test/kink/datetime/DATETIME_test.kn
--- a/src/test/kink/datetime/DATETIME_test.kn Mon Nov 23 00:55:03 2020 +0900
+++ b/src/test/kink/datetime/DATETIME_test.kn Mon Nov 23 01:04:01 2020 +0900
@@ -56,6 +56,22 @@
5656 Result == 56.123456789 || raise('got {}'.format(Result.repr))
5757 }
5858
59+ TEST.group('.show'){ # {{{
60+
61+ TEST.test('without config'){
62+ :Dt = DATETIME.new(2020 1 12 15 20 56.123456789)
63+ :Result = Dt.show
64+ Result == '2020-01-12T15:20:56.123456789' || raise('got {}'.format(Result.repr))
65+ }
66+
67+ TEST.test('with empty config'){
68+ :Dt = DATETIME.new(2020 1 12 15 20 56.123456789)
69+ :Result = Dt.show{}
70+ Result == '2020-01-12T15:20:56.123456789' || raise('got {}'.format(Result.repr))
71+ }
72+
73+ } # }}}
74+
5975 TEST.group('equality'){
6076 [ [ DATETIME.new(1 1 1 0 0 0.000000000)
6177 DATETIME.new(2019 7 26 12 34 56.123456789)
Show on old repository browser