Vim window logic, slimv

This commit is contained in:
Ian Keane 2020-02-24 20:27:04 -05:00
parent babcc9e44b
commit 515847d07e
791 changed files with 51552 additions and 86 deletions

View file

@ -0,0 +1,46 @@
(in-package :local-time)
(export 'set-local-time-cl-postgres-readers :local-time)
;; Postgresql days are measured from 2000-01-01, whereas local-time
;; uses 2000-03-01. We expect the database server to be in the UTC timezone.
(defconstant +postgres-day-offset-to-local-time+ -60)
(defun set-local-time-cl-postgres-readers (&optional (table cl-postgres:*sql-readtable*))
(flet ((timestamp-reader (usecs)
(multiple-value-bind (days usecs)
(floor usecs +usecs-per-day+)
(multiple-value-bind (secs usecs)
(floor usecs 1000000)
(local-time:make-timestamp :nsec (* usecs 1000)
:sec secs
:day (+ days +postgres-day-offset-to-local-time+))))))
(cl-postgres:set-sql-datetime-readers
:table table
:date (lambda (days)
(local-time:make-timestamp
:nsec 0 :sec 0
:day (+ days +postgres-day-offset-to-local-time+)))
:timestamp #'timestamp-reader
:timestamp-with-timezone #'timestamp-reader
:interval
(lambda (months days usecs)
(declare (ignore months days usecs))
(error "Intervals are not yet supported"))
:time
(lambda (usecs)
(multiple-value-bind (days usecs)
(floor usecs +usecs-per-day+)
(assert (= days 0))
(multiple-value-bind (secs usecs)
(floor usecs 1000000)
(let ((time-of-day (local-time:make-timestamp
:nsec (* usecs 1000)
:sec secs
:day 0)))
(check-type time-of-day time-of-day)
time-of-day)))))))
(defmethod cl-postgres:to-sql-string ((arg local-time:timestamp))
(format nil "'~a'"
(local-time:format-rfc3339-timestring nil arg :timezone +utc-zone+)))

View file

@ -0,0 +1,91 @@
(defpackage #:local-time
(:use #:cl)
(:export #:timestamp
#:date
#:time-of-day
#:make-timestamp
#:clone-timestamp
#:day-of
#:sec-of
#:nsec-of
#:timestamp<
#:timestamp<=
#:timestamp>
#:timestamp>=
#:timestamp=
#:timestamp/=
#:timestamp-maximum
#:timestamp-minimum
#:adjust-timestamp
#:adjust-timestamp!
#:timestamp-whole-year-difference
#:days-in-month
#:timestamp-
#:timestamp+
#:timestamp-difference
#:timestamp-minimize-part
#:timestamp-maximize-part
#:with-decoded-timestamp
#:decode-timestamp
#:timestamp-century
#:timestamp-day
#:timestamp-day-of-week
#:timestamp-decade
#:timestamp-hour
#:timestamp-microsecond
#:timestamp-millennium
#:timestamp-millisecond
#:timestamp-minute
#:timestamp-month
#:timestamp-second
#:timestamp-week
#:timestamp-year
#:parse-timestring
#:format-timestring
#:format-rfc1123-timestring
#:to-rfc1123-timestring
#:format-rfc3339-timestring
#:to-rfc3339-timestring
#:encode-timestamp
#:parse-rfc3339-timestring
#:universal-to-timestamp
#:timestamp-to-universal
#:unix-to-timestamp
#:timestamp-to-unix
#:timestamp-subtimezone
#:define-timezone
#:*default-timezone*
#:*clock*
#:leap-second-adjusted
#:clock-now
#:clock-today
#:find-timezone-by-location-name
#:reread-timezone-repository
#:now
#:today
#:enable-read-macros
#:+utc-zone+
#:+gmt-zone+
#:+month-names+
#:+short-month-names+
#:+day-names+
#:+short-day-names+
#:+seconds-per-day+
#:+seconds-per-hour+
#:+seconds-per-minute+
#:+minutes-per-day+
#:+minutes-per-hour+
#:+hours-per-day+
#:+days-per-week+
#:+months-per-year+
#:+iso-8601-format+
#:+iso-8601-date-format+
#:+iso-8601-time-format+
#:+rfc3339-format+
#:+rfc3339-format/date-only+
#:+asctime-format+
#:+rfc-1123-format+
#:+iso-week-date-format+
#:astronomical-julian-date
#:modified-julian-date
#:astronomical-modified-julian-date))