Changes regarding standard_conforming_strings in postgres
[clsql.git] / sql / time.lisp
index a7674a89277594218dc6c15b8f02b22701a253ea..38ad86f12f577676c2e959649a971205a0e86f0a 100644 (file)
       (declare (ignore _sec _min _hour _day _month _year _day-of-week))
       (when dst?
         (incf tz -1))
-      (values (- (* tz 60 60)) tz))))
+      (values (* tz 60 60) tz))))
 
 (defun time-to-utc (in)
   "Ensures that if we have a time thats not in UTC, treat it as a localtime,
         (setf (time-is-utc? newt) T)
         newt)))
 
+(defun time-to-localtime (in)
+  "Ensures that if we have a time thats not in UTC, treat it as a localtime,
+   and convert to UTC"
+  (if (not (time-is-utc? in))
+      in
+      (let ((newt
+              (time+ in (make-duration :second (- (%universal-ts-offset in))))))
+        (setf (time-is-utc? newt) nil)
+        newt)))
+
 (defun make-time (&key (year 0) (month 1) (day 1) (hour 0) (minute 0)
                   (second 0) (usec 0) (offset nil))
   (let* ((mjd (gregorian-to-mjd month day year))