| Paste number 55071: | portable date patch for arc0 |
| Pasted by: | rcoder |
| 9 months, 3 weeks ago | |
| None | |
| Paste contents: |
| diff -U3 -r ./ac.scm ../arc0/ac.scm --- ./ac.scm 2008-01-29 10:06:37.000000000 -0800 +++ ../arc0/ac.scm 2008-01-29 16:34:09.000000000 -0800 @@ -1047,6 +1047,15 @@ (xdef 'seconds current-seconds) +(define n-s number->string) + +(define (fmt-date secs) + (let ((d (seconds->date secs))) + (string-append + (n-s (date-year d)) "-" (n-s (date-month d)) "-" (n-s (date-day d))))) + +(xdef 'fmt-date fmt-date) + (print-hash-table #t) (xdef 'client-ip (lambda (port) Only in ../arc0: arc diff -U3 -r ./arc.arc ../arc0/arc.arc --- ./arc.arc 2008-01-29 10:01:27.000000000 -0800 +++ ../arc0/arc.arc 2008-01-30 10:01:30.000000000 -0800 @@ -1201,9 +1201,20 @@ (unless (dir-exists path) (system (string "mkdir " path)))) +; works as perl's chomp operator +(def chomp (str) + (if (is (str (- (len str) 1)) + #\newline) + (subseq str 0 (- (len str) 1)) + str)) + +; returns the operating system name, as generated by uname -s +(def os-name () + (let val (tostring (system "uname -s")) + (chomp val))) + (def date ((o time (seconds))) - (let val (tostring (system (string "date -u -r " time " \"+%Y-%m-%d\""))) - (subseq val 0 (- (len val) 1)))) + (fmt-date time)) (def since (t1) (- (seconds) t1)) |
This paste has no annotations.