Browse code

Cleaned up the trash

Jaidyn Lev authored on 2019-01-07 01:43:07
Showing 3 changed files
1 1
deleted file mode 100644
... ...
@@ -1,51 +0,0 @@
1
-(in-package :nih)
2
-
3
-;; UNIVERSAL-TIME --> STRING
4
-(defun iso-time (universal-time)
5
-  "Return `universal-time` in ISO 8601 format. :)"
6
-
7
-  (multiple-value-bind
8
-    (second minute hour date month year)
9
-    (decode-universal-time universal-time)
10
-
11
-    (format nil "~A-~A-~A"
12
-	    year
13
-	    (min-string-length month 2 :prefix "0")
14
-	    (min-string-length date 2 :prefix "0"))))
15
-
16
-
17
-;; NIL --> STRING
18
-(defun get-iso-time ()
19
-  "Return the ISO 8601 time of immediately, right here, right now."
20
-
21
-  (iso-time (get-universal-time)))
22
-
23
-
24
-;; STRING STRING --> INTEGER
25
-(defun iso-date-distance (iso-date-a iso-date-b)
26
-  "Return the number of days between date-a and date-b."
27
-
28
-  (let* ((a (mapcar #'read-from-string (nih:char-split "-" iso-date-a)))
29
-	 (year-a (car a)) (month-a (cadr a)) (day-a (caddr a))
30
-
31
-	 (b (mapcar #'read-from-string (nih:char-split "-" iso-date-b)))
32
-	 (year-b (car b)) (month-b (cadr b)) (day-b (caddr b)))
33
-
34
-    (+
35
-      (* 365 (- year-b year-a))
36
-      (- (day-number month-b day-b) (day-number month-a day-a)))))
37
-
38
-
39
-(defvar month-length
40
-  '(31 28 31 30 31 30 31 31 30 31 30 30))
41
-
42
-
43
-;; INTEGER [INTEGER] --> INTEGER
44
-(defun day-number (month &optional (date 1))
45
-  "Return the day-number (of a year) of a month/day combo."
46
-
47
-  (let ((month-days (reduce #'+ (nih:up-to (- month 2) month-length)))
48
-	(date-days date))
49
-
50
-    (+ month-days date-days)))
51
-
52 0
deleted file mode 100644
... ...
@@ -1,35 +0,0 @@
1
-(in-package :nih)
2
-
3
-;; PATH --> STRING
4
-(defun read-file-string (path)
5
-  "Read all lines from a file into a string."
6
-
7
-  (if (file-exists path)
8
-    (let ((encoding (asdf-encodings:detect-file-encoding path)))
9
-      
10
-      (with-open-file (fstream path
11
-			       :direction :input
12
-			       :external-format encoding)
13
-	(line-string
14
-	  (loop
15
-	    :for line = (read-line fstream nil)
16
-	    :while line
17
-	    :collect line))))))
18
-
19
-
20
-(defun write-file-string (path string &key
21
-			       (if-exists :append)
22
-			       (if-does-not-exist :create))
23
-  "Write a string to a file."
24
-
25
-  (let ((encoding :utf-8))
26
-
27
-    (if (file-exists path)
28
-      (setq encoding (asdf-encodings:detect-file-encoding path)))
29
-
30
-    (with-open-file (fstream path
31
-			     :direction :output
32
-			     :external-format encoding
33
-			     :if-exists if-exists
34
-			     :if-does-not-exist if-does-not-exist)
35
-      (format fstream "~A" string))))
... ...
@@ -10,6 +10,7 @@
10 10
     :manip-name
11 11
 
12 12
     :string-combine
13
+    :string+
13 14
     :intern-combine
14 15
 
15 16
     :regex-get
... ...
@@ -132,16 +133,6 @@
132 133
     :property-list-merge
133 134
 
134 135
 
135
-    ;; DATE
136
-    ;; =======================
137
-    :iso-time  ;; see (local-time:format-timestring nil timestamp)
138
-    :get-iso-time
139
-    ;; see (local-time:format-timestring nil (local-time:universal-to-timestamp)
140
-    :iso-date-distance ;; see #'local-time:timestamp-difference
141
-    :day-number ;; see #'local-time:format-timestring
142
-    :week-number ;; see #'local-time:format-timestring
143
-
144
-
145 136
     ;; FILE
146 137
     ;; =======================
147 138
     :read-file-string ;; see #'alexandria:read-file-into-string
... ...
@@ -155,8 +146,6 @@
155 146
     :iso-time
156 147
     :list-or-real
157 148
     :value-or
158
-    :file-exists
159
-    :read-line-entire
160 149
     :parse-keys))
161 150
 
162 151