Skip to content

Commit e9608cd

Browse files
committed
chore: format stdlib
1 parent e9367b8 commit e9608cd

5 files changed

Lines changed: 54 additions & 38 deletions

File tree

‎CSV.ark‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@
1212
(let read (fun (_data _sep) ()))
1313
(let headers (fun (_csv) _csv.headers))
1414
(let rows (fun (_csv) _csv.rows))
15-
(let get (fun (_csv _column _row)
16-
(@@ _csv.rows _row (dict:get _csv._headers_to_index _column))))
15+
(let get (fun (_csv _column _row) (@@ _csv.rows _row (dict:get _csv._headers_to_index _column))))

‎Datetime.ark‎

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -367,18 +367,29 @@
367367
(set _year (+ _year (floordiv _month 12)))
368368

369369
(mut _result (+ (* (- _year 1970) 365) (@ _cumulativeDays (mod _month 12))))
370-
(set _result (+
371-
_result
372-
(floordiv (- _year 1968) 4)
373-
(* -1 (floordiv (- _year 1900) 100))
374-
(floordiv (- _year 1600) 400)))
375-
(if (and
376-
(= 0 (mod _year 4))
377-
(or (!= 0 (mod _year 100)) (= 0 (mod _year 400)))
378-
(< (mod _month 12) 2))
370+
(set _result (+ _result (floordiv (- _year 1968) 4) (* -1 (floordiv (- _year 1900) 100)) (floordiv (- _year 1600) 400)))
371+
(if (and (= 0 (mod _year 4)) (or (!= 0 (mod _year 100)) (= 0 (mod _year 400))) (< (mod _month 12) 2))
379372
(set _result (- _result 1)))
380-
(let _tzOffset (if (nil? _tz) 0 (* -1 (utcOffsetMinutes _tz))))
381-
(+ (* (+ (* (+ (* (+ _result _day -1) 24) _hour (if _dst? -1 0)) 60) _minute _tzOffset) 60) _second (/ _millisecond 1000)) }))
373+
(let _tzOffset
374+
(if (nil? _tz)
375+
0
376+
(* -1 (utcOffsetMinutes _tz))))
377+
(+
378+
(*
379+
(+
380+
(*
381+
(+
382+
(* (+ _result _day -1) 24)
383+
_hour
384+
(if _dst?
385+
-1
386+
0))
387+
60)
388+
_minute
389+
_tzOffset)
390+
60)
391+
_second
392+
(/ _millisecond 1000)) }))
382393

383394
# @brief Precomputed timestamp of 1/1/0000 at 00H 00M 00.000s
384395
# @author https://github.com/SuperFola
@@ -416,8 +427,7 @@
416427
# (print (datetime:toUTCTimestamp (datetime:asUTCDate t)) # 1779908523.389
417428
# =end
418429
# @author https://github.com/SuperFola
419-
(let toUTCTimestamp (fun (_date)
420-
(makeUTCTimestamp
430+
(let toUTCTimestamp (fun (_date) (makeUTCTimestamp
421431
(dict:get _date "year")
422432
(dict:get _date "month")
423433
(dict:get _date "day")
@@ -448,8 +458,7 @@
448458
# # {millisecond: 913, second: 24, minute: 15, hour: 17, day: 26, month: 5, year: 2026, week_day: 2, year_day: 145, is_dst: false}
449459
# =end
450460
# @author https://github.com/SuperFola
451-
(let asUTCDate (fun (_time)
452-
(builtin__time:asUTCDate _time)))
461+
(let asUTCDate (fun (_time) (builtin__time:asUTCDate _time)))
453462

454463
# @brief Add a number of seconds to a timestamp
455464
# @param _time Number, timestamp
@@ -544,15 +553,27 @@
544553
# @author https://github.com/SuperFola
545554
(let atStartOfDay (fun (_time) {
546555
(let _date (asUTCDate _time))
547-
(dict:update! _date (dict "millisecond" 0 "second" 0 "minute" 0 "hour" 0))
556+
(dict:update!
557+
_date
558+
(dict
559+
"millisecond" 0
560+
"second" 0
561+
"minute" 0
562+
"hour" 0))
548563
(toUTCTimestamp _date) }))
549564

550565
# @brief Put a given timestamp at the end of the day, at 23H 59M 59.999s
551566
# @param _time Number, timestamp
552567
# @author https://github.com/SuperFola
553568
(let atEndOfDay (fun (_time) {
554569
(let _date (asUTCDate _time))
555-
(dict:update! _date (dict "millisecond" 999 "second" 59 "minute" 59 "hour" 23))
570+
(dict:update!
571+
_date
572+
(dict
573+
"millisecond" 999
574+
"second" 59
575+
"minute" 59
576+
"hour" 23))
556577
(toUTCTimestamp _date) }))
557578

558579
# @brief Compute today's date, at 00H 00M 00s
@@ -609,8 +630,7 @@
609630
# @brief Create a delta from a number of seconds, as a Dict with the same shape as `datetime:asUTCDate`
610631
# @param _time Number, number of seconds
611632
# @author https://github.com/SuperFola
612-
(let asDelta (fun (_time)
613-
(delta 0 _time)))
633+
(let asDelta (fun (_time) (delta 0 _time)))
614634

615635
# @brief Convert a delta or a date to a number of seconds
616636
# @param _date Dict, with the same shape as `datetime:asUTCDate`
@@ -630,15 +650,13 @@
630650
# @param _time Number, timestamp
631651
# @param _delta Dict, with the same shape as `datetime:asUTCDate`
632652
# @author https://github.com/SuperFola
633-
(let plusDelta (fun (_time _delta)
634-
(+ _time (asSeconds _delta))))
653+
(let plusDelta (fun (_time _delta) (+ _time (asSeconds _delta))))
635654

636655
# @brief Subtract a delta to a timestamp
637656
# @param _time Number, timestamp
638657
# @param _delta Dict, with the same shape as `datetime:asUTCDate`
639658
# @author https://github.com/SuperFola
640-
(let minusDelta (fun (_time _delta)
641-
(- _time (asSeconds _delta))))
659+
(let minusDelta (fun (_time _delta) (- _time (asSeconds _delta))))
642660

643661
# @brief Return the year component of a timestamp
644662
# @param _time Number, timestamp
@@ -689,9 +707,7 @@
689707
# @param _year Number, year
690708
# @author https://github.com/SuperFola
691709
(let leapYear? (fun (_year) {
692-
(or
693-
(and (= 0 (mod _year 4)) (!= 0 (mod _year 100)))
694-
(= 0 (mod _year 400))) }))
710+
(or (and (= 0 (mod _year 4)) (!= 0 (mod _year 100))) (= 0 (mod _year 400))) }))
695711

696712
# @brief Return the number of days in the month a timestamp is at
697713
# @param _time Number, timestamp
@@ -723,7 +739,13 @@
723739
(assert (not (nil? _minutes)) "Unknown timezone")
724740
(let _hoursToUtc (abs (floordiv _minutes 60)))
725741
(let _minToUtc (mod _minutes 60))
726-
(format "{}{:02}:{:02}" (if (< _minutes 0) "-" "+") _hoursToUtc _minToUtc) }))
742+
(format
743+
"{}{:02}:{:02}"
744+
(if (< _minutes 0)
745+
"-"
746+
"+")
747+
_hoursToUtc
748+
_minToUtc) }))
727749

728750
# @brief Convert a timestamp to its ISO8601 representation: 2007-04-05T12:34:56.789Z
729751
# @param _time Number, timestamp

‎List.ark‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@
444444
(let _val (@ _L _index))
445445

446446
(if (or (nil? _min) (< _val _min))
447-
(set _min _val))
447+
(set _min _val))
448448
(if (or (nil? _max) (> _val _max))
449449
(set _max _val))
450450

@@ -506,8 +506,7 @@
506506

507507
(while (< _index (len _L)) {
508508
(let _result (_f (@ _L _index)))
509-
(if (not (nil? _result))
510-
(append! _output _result))
509+
(if (not (nil? _result)) (append! _output _result))
511510
(set _index (+ 1 _index)) })
512511
_output }))
513512

‎Macros.ark‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@
135135
# internal, do not use
136136
(macro __unpack (data idx name ...names) {
137137
(let name (@ data idx))
138-
($if (> ($len names) 0)
139-
(__unpack data (+ 1 idx) ...names)) })
138+
($if (> ($len names) 0) (__unpack data (+ 1 idx) ...names)) })
140139

141140
# @brief Unpack a list into multiple variables
142141
# @param data list of elements to unpack

‎String.ark‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,7 @@
155155
(let privateUse? (fun (_str) {
156156
(assert (= 1 (utf8len _str)) "Expected a single character")
157157
(let _c (ord _str))
158-
(or
159-
(and (<= 57344 _c) (<= _c 63743))
160-
(and (<= 983040 _c) (<= _c 1048573))
161-
(and (<= 1048576 _c) (<= _c 1114109))) }))
158+
(or (and (<= 57344 _c) (<= _c 63743)) (and (<= 983040 _c) (<= _c 1048573)) (and (<= 1048576 _c) (<= _c 1114109))) }))
162159

163160
# @brief Check if a string contains a word
164161
# @param _str String where the lookup occurs

0 commit comments

Comments
 (0)