aboutsummaryrefslogtreecommitdiff
path: root/module/datetime
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-06-23 03:23:44 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-06-23 03:48:22 +0200
commit1976980d4a272fb7fc3694c734bfc6825edfc721 (patch)
tree8460db1176c64895e9968447588953fac85fe7d6 /module/datetime
parentRemove all inline use-modules. (diff)
downloadcalp-1976980d4a272fb7fc3694c734bfc6825edfc721.tar.gz
calp-1976980d4a272fb7fc3694c734bfc6825edfc721.tar.xz
Centralize (almost) all exports to :export in define-module.
Diffstat (limited to 'module/datetime')
-rw-r--r--module/datetime/timespec.scm21
-rw-r--r--module/datetime/zic.scm40
2 files changed, 42 insertions, 19 deletions
diff --git a/module/datetime/timespec.scm b/module/datetime/timespec.scm
index 9bfcc402..03e8dd10 100644
--- a/module/datetime/timespec.scm
+++ b/module/datetime/timespec.scm
@@ -4,16 +4,23 @@
;;; Code:
(define-module (datetime timespec)
- :export (make-timespec
- timespec? timespec-time timespec-sign timespec-type)
- :use-module ((hnh util) :select (set define*-public unless))
+ :use-module ((hnh util) :select (set unless))
:use-module ((hnh util exceptions) :select (warning))
:use-module (datetime)
:use-module (srfi srfi-1)
:use-module (srfi srfi-71)
:use-module (srfi srfi-9 gnu)
:use-module (calp translation)
- )
+ :export (make-timespec
+ timespec?
+ timespec-time
+ timespec-sign
+ timespec-type
+
+ timespec-zero
+ timespec-add
+ parse-time-spec
+ ))
;; timespec as defined by the TZ-database
@@ -30,10 +37,10 @@
;; u, g, z - Universal time
(type timespec-type)) ; char
-(define-public (timespec-zero)
+(define (timespec-zero)
(make-timespec (time) '+ #\w))
-(define-public (timespec-add . specs)
+(define (timespec-add . specs)
(unless (apply eqv? (map timespec-type specs))
(warning (_ "Adding timespecs of differing types")))
@@ -70,7 +77,7 @@
specs))
-(define*-public (parse-time-spec
+(define* (parse-time-spec
string optional: (suffixes '(#\s #\w #\u #\g #\z)))
(let ((type string
(cond [(string-rindex string (list->char-set suffixes))
diff --git a/module/datetime/zic.scm b/module/datetime/zic.scm
index 393b4ba2..66c0ba06 100644
--- a/module/datetime/zic.scm
+++ b/module/datetime/zic.scm
@@ -25,11 +25,32 @@
:use-module ((vcomponent recurrence internal)
:select (byday make-recur-rule bymonthday))
:use-module (calp translation)
- )
+ :export (read-zoneinfo
+
+ #| note that make-rule isn't exported |#
+ rule?
+ rule-name rule-from rule-to rule-in
+ rule-on rule-at rule-save rule-letters
+
+ #| note that make-zone-entry isn't exported |#
+ zone-entry?
+ zone-entry-stdoff zone-entry-rule
+ zone-entry-format zone-entry-until
+
+ zoneinfo?
+
+ get-zone
+ get-rule
+
+ rule->dtstart
+ rule->rrule
+
+ zone-format
+ ))
;; returns a <zoneinfo> object
-(define-public (read-zoneinfo ports-or-filenames)
+(define (read-zoneinfo ports-or-filenames)
(parsed-zic->zoneinfo
(concatenate
(map (lambda (port-or-filename)
@@ -57,7 +78,6 @@
(letters rule-letters) ; string
)
-(export rule? rule-name rule-from rule-to rule-in rule-on rule-at rule-save rule-letters)
(define-immutable-record-type <zone-entry> ; EXPORTED
(make-zone-entry stdoff rule format until)
@@ -67,8 +87,6 @@
(format zone-entry-format) ; string
(until zone-entry-until)) ; <datetime> | #f
-(export zone-entry? zone-entry-stdoff zone-entry-rule zone-entry-format zone-entry-until)
-
(define-immutable-record-type <zone> ; INTERNAL
(make-zone name entries)
@@ -88,19 +106,17 @@
(rules zoneinfo-rules) ; (map symbol (list <rule>))
(zones zoneinfo-zones)) ; (map string (list <zone-entry>))
-(export zoneinfo?)
-
;; @example
;; (get-zone zoneinfo "Europe/Stockholm")
;; @end example
-(define-public (get-zone zoneinfo name)
+(define (get-zone zoneinfo name)
(or (hash-ref (zoneinfo-zones zoneinfo) name)
(scm-error 'misc-error "get-zone" "No zone ~a" (list name) #f)))
;; @example
;; (get-rule zoneinfo 'EU)
;; @end example
-(define-public (get-rule zoneinfo name)
+(define (get-rule zoneinfo name)
(or (hashq-ref (zoneinfo-rules zoneinfo) name)
(scm-error 'misc-error "get-rule" "No rule ~a" (list name) #f)))
@@ -310,7 +326,7 @@
;; The first time this rule was/will be applied
-(define-public (rule->dtstart rule)
+(define (rule->dtstart rule)
;; NOTE 'minimum and 'maximum represent the begining and end of time.
;; since I don't have a way to represent those ideas I just set a very
;; high and a very low year here. What 'maximum even entails for a start
@@ -350,7 +366,7 @@
(datetime time: (timespec-time timespec)))
))
-(define-public (rule->rrule rule)
+(define (rule->rrule rule)
(if (eq? 'only (rule-to rule))
#f
(let ((base (make-recur-rule
@@ -388,7 +404,7 @@
wday))))))))
;; special case of format which works with %s and %z
-(define-public (zone-format fmt-string arg)
+(define (zone-format fmt-string arg)
(let ((idx (string-index fmt-string #\%)))
(case (string-ref fmt-string (1+ idx))
[(#\s) (string-replace fmt-string arg