• R/O
  • SSH

kink: Commit

Kink runtime


Commit MetaInfo

Revisionf27b63b6f176ce4d03f40093cc8e9a1baa0d2834 (tree)
Time2020-11-25 01:50:27
Authormiyakawataku
Commitermiyakawataku

Log Message

remove DATETIME.parse and OFFSET.parse

Change Summary

Incremental Difference

diff -r 0639595a0679 -r f27b63b6f176 src/main/resources/kink-mods/kink/datetime/DATETIME.kn
--- a/src/main/resources/kink-mods/kink/datetime/DATETIME.kn Wed Nov 25 01:44:16 2020 +0900
+++ b/src/main/resources/kink-mods/kink/datetime/DATETIME.kn Wed Nov 25 01:50:27 2020 +0900
@@ -207,61 +207,9 @@
207207 Val.var_syms.have_all?(Date_time_syms)
208208 }
209209
210-## DATETIME.parse(Str)
211-#
212-# `parse` parses a datetime from `Str`.
213-#
214-# Precondition:
215-#
216-# • `Str` must be a str
217-#
218-# Result:
219-#
220-# • If `Str` is accepted by the syntax and the limiting condition below,
221-# `parse` returns a single-element vec [Datetime] where `Datetime` is the extracted datetime val.
222-#
223-# • If `Str` is not accepted by the syntax and the limiting condition below,
224-# `parse` returns an empty vec [].
225-#
226-# Syntax: `{Year}-{Month}-{Day}T{Hour}:{Minute}:{Second}`, where:
227-#
228-# • `Year` is four decimal digits from `0001` to `9999`
229-#
230-# • `Month` is two decimal digits from `01` to `12`
231-#
232-# • `Day` is two decimal digits from `01` to `31`
233-#
234-# • `Hour` is two decimal digits from `00` to `23`
235-#
236-# • `Minute` is two decimal digits from `00` to `59`
237-#
238-# • `Second` is two decimal digits from `00` to `59`,
239-# or `{Int}.{Frac}` where `Int`is two decimal digits from `00` to `59`
240-# and `Frac` is 1 to 9 decimal digits.
241-#
242-# Limiting condition:
243-#
244-# • `Year`, `Month`, and `Day` must constitute a valid date in ISO 8601 calendar system.
245-#
246-# Example:
247-#
248-# :DATETIME.require_from('kink/datetime/')
249-#
250-# stdout.print_line(DATETIME.parse('2020-11-04T12:34:56').repr)
251-# # => [(datetime 2020-11-04T12:34:56.000000000)]
252-#
253-# stdout.print_line(DATETIME.parse('2020-11-04T12:34:56.123456789').repr)
254-# # => [(datetime 2020-11-04T12:34:56.123456789)]
255-#
256-# # scale of the second must not exceed 9
257-# stdout.print_line(DATETIME.parse('2020-11-04T12:34:56.1234567890').repr)
258-# # => []
259-#
260-# # at least one digit is required after the fraction point
261-# stdout.print_line(DATETIME.parse('2020-11-04T12:34:56.').repr)
262-# # => []
263-:parse <- {(:Str)
264- STR.is?(Str) || raise('DATETIME.parse(Str): Str must be a str, but got {}'.format(Str.repr))
210+# parse a datetime from `Str`.
211+:_parse <- {(:Str)
212+ STR.is?(Str) || raise('DATETIME._parse(Str): Str must be a str, but got {}'.format(Str.repr))
265213 CONTROL.with_break{(:return)
266214 :Match = Parse_regex.match(Str).just_or{ return([]) }
267215
diff -r 0639595a0679 -r f27b63b6f176 src/main/resources/kink-mods/kink/datetime/OFFSET.kn
--- a/src/main/resources/kink-mods/kink/datetime/OFFSET.kn Wed Nov 25 01:44:16 2020 +0900
+++ b/src/main/resources/kink-mods/kink/datetime/OFFSET.kn Wed Nov 25 01:50:27 2020 +0900
@@ -180,51 +180,9 @@
180180
181181 :Offset_var_syms <- Offset_trait.chunk(2).map{([:Sym :V]) Sym }
182182
183-## OFFSET.parse(Str) {{{
184-#
185-# `parse` parses `Str` as an offset.
186-#
187-# Precondition:
188-#
189-# • `Str` must be a str.
190-#
191-# Result:
192-#
193-# • If `Str` is accepted by the syntax,
194-# `parse` returns a single-element vec [Offset] where `Offset` is the extracted offset.
195-#
196-# • If `Str` is not accepted by the syntax, `parse` returns an empty vec [].
197-#
198-#
199-# The syntax of is as follows:
200-#
201-# • One uppercase ASCII letter `Z`, which represents +00:00, or
202-#
203-# • `{Sign}{Hour}:{Minute}`
204-#
205-# Where:
206-#
207-# • `Sign` is either `-` or `+`
208-#
209-# • `Hour` is two decimal digits from `00` to `18`
210-#
211-# • `Minute` is `00` if `Hour` is ``18`,
212-# otherwise two decimal digits from `00` to `59`
213-#
214-# Example:
215-#
216-# :OFFSET.require_from('kink/datetime/')
217-#
218-# stdout.print_line(OFFSET.parse('Z').repr) # => [(offset +00:00)]
219-# stdout.print_line(OFFSET.parse('+00:00').repr) # => [(offset +00:00)]
220-# stdout.print_line(OFFSET.parse('-00:00').repr) # => [(offset +00:00)]
221-# stdout.print_line(OFFSET.parse('+12:34').repr) # => [(offset +12:34)]
222-# stdout.print_line(OFFSET.parse('+18:00').repr) # max => [(offset +18:00)]
223-# stdout.print_line(OFFSET.parse('-18:00').repr) # min => [(offset -18:00)]
224-# stdout.print_line(OFFSET.parse('+18:01').repr) # => []
225-# stdout.print_line(OFFSET.parse('-18:01').repr) # => []
226-:parse <- {(:Str)
227- STR.is?(Str) || raise('OFFSET.parse(Str): Str must be a str, but got {}'.format(Str.repr))
183+# pars str as an offset. {{{
184+:_parse <- {(:Str)
185+ STR.is?(Str) || raise('OFFSET._parse(Str): Str must be a str, but got {}'.format(Str.repr))
228186
229187 CONTROL.with_break{(:return)
230188 Str == 'Z' && return([new(0)])
diff -r 0639595a0679 -r f27b63b6f176 src/main/resources/kink-mods/kink/datetime/OFFSET_DATETIME.kn
--- a/src/main/resources/kink-mods/kink/datetime/OFFSET_DATETIME.kn Wed Nov 25 01:44:16 2020 +0900
+++ b/src/main/resources/kink-mods/kink/datetime/OFFSET_DATETIME.kn Wed Nov 25 01:50:27 2020 +0900
@@ -883,8 +883,8 @@
883883 :parse <- {(:Str)
884884 STR.is?(Str) || raise('OFFSET_DATETIME.parse(Str): Str must be a str, but got {}'.format(Str.repr))
885885 Parse_regex.match(Str).concat_map{(:Match)
886- DATETIME.parse(Match.group('Datetime').slice).concat_map{(:Datetime)
887- OFFSET.parse(Match.group('Offset').slice).map{(:Offset)
886+ DATETIME._parse(Match.group('Datetime').slice).concat_map{(:Datetime)
887+ OFFSET._parse(Match.group('Offset').slice).map{(:Offset)
888888 from_datetime_and_offset(Datetime Offset)
889889 }
890890 }
diff -r 0639595a0679 -r f27b63b6f176 src/test/kink/datetime/DATETIME_test.kn
--- a/src/test/kink/datetime/DATETIME_test.kn Wed Nov 25 01:44:16 2020 +0900
+++ b/src/test/kink/datetime/DATETIME_test.kn Wed Nov 25 01:50:27 2020 +0900
@@ -443,7 +443,7 @@
443443 }
444444 } # }}}1
445445
446-TEST.group('DATETIME.parse'){ # {{{
446+TEST.group('DATETIME._parse'){ # {{{
447447 [ ['2020-02-01T12:34:56' [DATETIME.new(2020 2 1 12 34 56)]]
448448 ['2020-02-29T12:34:56' [DATETIME.new(2020 2 29 12 34 56)]]
449449 ['0001-01-01T00:00:00' [DATETIME.new(1 1 1 0 0 0)]]
@@ -465,17 +465,17 @@
465465 ['boo' []]
466466 ].each{([:Str :Expected])
467467 TEST.test('{} => {}'.format(Str.repr Expected.repr)){
468- :Result = DATETIME.parse(Str)
468+ :Result = DATETIME._parse(Str)
469469 Result == Expected || raise('got {}'.format(Result.repr))
470470 }
471471 }
472472
473473 TEST.test('Str must be a str'){
474474 CONTROL.try(
475- { DATETIME.parse(nada) }
475+ { DATETIME._parse(nada) }
476476 {(:R) raise('got {}'.format(R.repr)) }
477477 {(:Msg :Traces)
478- Msg.have_slice?('.parse') && Msg.have_slice?('nada') || reraise(Msg Traces)
478+ Msg.have_slice?('._parse') && Msg.have_slice?('nada') || reraise(Msg Traces)
479479 }
480480 )
481481 }
diff -r 0639595a0679 -r f27b63b6f176 src/test/kink/datetime/OFFSET_test.kn
--- a/src/test/kink/datetime/OFFSET_test.kn Wed Nov 25 01:44:16 2020 +0900
+++ b/src/test/kink/datetime/OFFSET_test.kn Wed Nov 25 01:50:27 2020 +0900
@@ -184,58 +184,58 @@
184184
185185 } # }}}
186186
187-TEST.group('OFFSET.parse'){ # {{{
187+TEST.group('OFFSET._parse'){ # {{{
188188 TEST.test('prase "Z"'){
189- [:Offset] = OFFSET.parse('Z')
189+ [:Offset] = OFFSET._parse('Z')
190190 Offset == OFFSET.new(0) || raise('got {}'.format(Offset.repr))
191191 }
192192
193193 TEST.test('ordinary plus offset'){
194- [:Offset] = OFFSET.parse('+12:34')
194+ [:Offset] = OFFSET._parse('+12:34')
195195 Offset == OFFSET.new(12 * 60 + 34) || raise('got {}'.format(Offset.repr))
196196 }
197197
198198 TEST.test('ordinary minus offset'){
199- [:Offset] = OFFSET.parse('-12:34')
199+ [:Offset] = OFFSET._parse('-12:34')
200200 Offset == OFFSET.new(-(12 * 60 + 34)) || raise('got {}'.format(Offset.repr))
201201 }
202202
203203 TEST.test('min'){
204- [:Offset] = OFFSET.parse('+00:00')
204+ [:Offset] = OFFSET._parse('+00:00')
205205 Offset == OFFSET.new(0) || raise('got {}'.format(Offset.repr))
206206 }
207207
208208 TEST.test('max'){
209- [:Offset] = OFFSET.parse('+18:00')
209+ [:Offset] = OFFSET._parse('+18:00')
210210 Offset == OFFSET.new(18 * 60) || raise('got {}'.format(Offset.repr))
211211 }
212212
213213 TEST.test('max minute'){
214- [:Offset] = OFFSET.parse('+12:59')
214+ [:Offset] = OFFSET._parse('+12:59')
215215 Offset == OFFSET.new(12 * 60 + 59) || raise('got {}'.format(Offset.repr))
216216 }
217217
218218 TEST.test('cannot exceed max minute 59'){
219- :Result = OFFSET.parse('+12:60')
219+ :Result = OFFSET._parse('+12:60')
220220 Result == [] || raise('got {}'.format(Result.repr))
221221 }
222222
223223 TEST.test('cannot exceed max 18:00'){
224- :Result = OFFSET.parse('+18:01')
224+ :Result = OFFSET._parse('+18:01')
225225 Result == [] || raise('got {}'.format(Result.repr))
226226 }
227227
228228 TEST.test('return empty for invalid syntax'){
229- :Result = OFFSET.parse('boo')
229+ :Result = OFFSET._parse('boo')
230230 Result == [] || raise('got {}'.format(Result.repr))
231231 }
232232
233233 TEST.test('Str must be a str'){
234234 CONTROL.try(
235- { OFFSET.parse(nada) }
235+ { OFFSET._parse(nada) }
236236 {(:R) raise('got {}'.format(R.repr)) }
237237 {(:Msg :Traces)
238- Msg.have_slice?('nada') && Msg.have_slice?('.parse') || reraise(Msg Traces)
238+ Msg.have_slice?('nada') && Msg.have_slice?('._parse') || reraise(Msg Traces)
239239 }
240240 )
241241 }
Show on old repository browser