From attila.lendvai at gmail.com Sat Mar 1 12:29:33 2008 From: attila.lendvai at gmail.com (Attila Lendvai) Date: Sat, 1 Mar 2008 13:29:33 +0100 Subject: [local-time-devel] patches Message-ID: Daniel, there are several pending patches in our repo: darcs pull http://www.common-lisp.net/project/cl-dwim/darcs/local-time i don't feel the authority to push them to the official repo without your approval, so please take a look at them. -- attila From attila.lendvai at gmail.com Sat Mar 1 12:34:27 2008 From: attila.lendvai at gmail.com (Attila Lendvai) Date: Sat, 1 Mar 2008 13:34:27 +0100 Subject: [local-time-devel] why no arithmetic In-Reply-To: <6fb33c150710212211r25aa41a7md774f9e79c055cae@mail.gmail.com> References: <6fb33c150710212211r25aa41a7md774f9e79c055cae@mail.gmail.com> Message-ID: > I read the paper from Eric and thought this would include support for > doing date arithmetic and duration representation. > > Although looking back at the paper I see that the Common Lisp > implementation parts in the paper did not mention date arithmetic even > though the paper did talk about it. there's a patch waiting for approval in our branch that implements arithmetic: darcs pull http://www.common-lisp.net/project/cl-dwim/darcs/local-time -- attila From dlowe at bitmuse.com Sat Mar 1 13:52:48 2008 From: dlowe at bitmuse.com (Daniel Lowe) Date: Sat, 01 Mar 2008 08:52:48 -0500 Subject: [local-time-devel] patches In-Reply-To: References: Message-ID: <47C95FB0.2060409@bitmuse.com> Attila Lendvai wrote: > i don't feel the authority to push them to the official repo without > your approval, so please take a look at them. I'd like to see documentation changes before accepting the patches, especially with an incompatible change to the API. Thanks : Daniel : From attila.lendvai at gmail.com Sat Mar 1 13:59:59 2008 From: attila.lendvai at gmail.com (Attila Lendvai) Date: Sat, 1 Mar 2008 14:59:59 +0100 Subject: [local-time-devel] patches In-Reply-To: <47C95FB0.2060409@bitmuse.com> References: <47C95FB0.2060409@bitmuse.com> Message-ID: > > i don't feel the authority to push them to the official repo without > > your approval, so please take a look at them. > > I'd like to see documentation changes before accepting the patches, especially > with an incompatible change to the API. there's not documentation in the source control. if there are external sources for the doc, then could you please check in the sources to the repo? or is the manual.html the primary source? -- attila From dlowe at bitmuse.com Sat Mar 1 14:02:17 2008 From: dlowe at bitmuse.com (Daniel Lowe) Date: Sat, 01 Mar 2008 09:02:17 -0500 Subject: [local-time-devel] patches In-Reply-To: References: <47C95FB0.2060409@bitmuse.com> Message-ID: <47C961E9.6000105@bitmuse.com> Attila Lendvai wrote: >> > i don't feel the authority to push them to the official repo without >> > your approval, so please take a look at them. >> >> I'd like to see documentation changes before accepting the patches, especially >> with an incompatible change to the API. > > there's not documentation in the source control. if there are external > sources for the doc, then could you please check in the sources to the > repo? or is the manual.html the primary source? > manual.html is taken from the README file in the project directory. I guess the README is the canonical documentation. It's a lame documentation format, but I'm not sure that a more heavyweight solution is required. It's not a large library, after all. From attila.lendvai at gmail.com Sat Mar 1 19:07:52 2008 From: attila.lendvai at gmail.com (Attila Lendvai) Date: Sat, 1 Mar 2008 20:07:52 +0100 Subject: [local-time-devel] patches In-Reply-To: <47C961E9.6000105@bitmuse.com> References: <47C95FB0.2060409@bitmuse.com> <47C961E9.6000105@bitmuse.com> Message-ID: > manual.html is taken from the README file in the project directory. I guess the > README is the canonical documentation. > > It's a lame documentation format, but I'm not sure that a more heavyweight > solution is required. It's not a large library, after all. i've added a texinfo doc and updated to the current state. http://common-lisp.net/project/local-time/manual/ -- attila ps: what a waste of time it was... i still think that this documentation is hopelessly useless compared to M-. in slime, fuzzy completion and some comments in a well-written code with a lot of unit tests. but anyway, if everybody else wants to read static pdf's instead, who am i to argue... :) From dlowe at bitmuse.com Tue Mar 4 21:37:43 2008 From: dlowe at bitmuse.com (Daniel Lowe) Date: Tue, 04 Mar 2008 16:37:43 -0500 Subject: [local-time-devel] patches In-Reply-To: References: <47C95FB0.2060409@bitmuse.com> <47C961E9.6000105@bitmuse.com> Message-ID: <47CDC127.9020105@bitmuse.com> Attila Lendvai wrote: > i've added a texinfo doc and updated to the current state. > > http://common-lisp.net/project/local-time/manual/ > The texinfo doc looks great. It looks like it took quite a bit of time -- thanks for the effort. I'm willing to bump up the version at this point. I wanted to ask if you had any thoughts on 1.0 milestones. : Daniel : From attila.lendvai at gmail.com Wed Mar 5 10:10:57 2008 From: attila.lendvai at gmail.com (Attila Lendvai) Date: Wed, 5 Mar 2008 11:10:57 +0100 Subject: [local-time-devel] patches In-Reply-To: <47CDC127.9020105@bitmuse.com> References: <47C95FB0.2060409@bitmuse.com> <47C961E9.6000105@bitmuse.com> <47CDC127.9020105@bitmuse.com> Message-ID: > > http://common-lisp.net/project/local-time/manual/ > > The texinfo doc looks great. It looks like it took quite a bit of time -- > thanks for the effort. a few hours, it wasn't that bad, most of it was learning texinfo stuff... but it just reassured me that docs are useless, will be out of sync and the time spent on them is worth much more when spent on the code, but i guess i've pushed my opinion enough. i shouldn't try to change the world... :) > I'm willing to bump up the version at this point. I wanted to ask if you had > any thoughts on 1.0 milestones. i consider version numbers as some kind of psychological message that has not much to do with the software itself. but in the lights of this, i'm all in for advertising local-time as _the_ common-lisp date/time handling library. so that people will grab this instead of rolling their own. and if something is missing then consider sending patches. -- attila From dlowe at bitmuse.com Tue Mar 11 18:19:40 2008 From: dlowe at bitmuse.com (Daniel Lowe) Date: Tue, 11 Mar 2008 14:19:40 -0400 Subject: [local-time-devel] Proposed local-time 1.0 API (revision 1) Message-ID: <47D6CD3C.5050901@bitmuse.com> Please look over the proposed API and make criticisms and suggestions. CLASSES timestamp A timestamp is a value indicating a particular point in time. Arithmetic is not possible with timestamps, but they may be compared. Internally, timestamps are always encoded as UTC. duration A duration is a value indicating a particular duration. Arithmetic is possible with durations, and they may be also be added to timestamps to produce another timestamp. Duration slots are entirely seperate from each other - no rollover is applied during arithmetic. A one day duration is treated differently from a 24 hour duration. Duration slots must be always be positive integers. When adding durations to each other, each slot is added to the corresponding slot. When adding a duration to a timestamp, the slots are added to the timestamp in order of increasing resolution. The timestamp is modified in such a way that each duration slot affects only the decoded values of equal or less resolution. Illegal dates will signal an error. Example: (+ @D1M @2008-03-05) => @2008-04-05 ; adding one month (+ @D30D @2008-03-05) => @2008-04-04 ; adding 30 days (+ @D1M60D @2008-03-05) => @2008-06-05 ; adding one month and 60 days ;; Adding one day and five minutes (+ @D1D5M @2008-03-05T23:59:00) => @2008-03-07T00:04:00 timezone Timezones are local modifications to UTC. They are only applied when encoding or decoding a timestamp. CONSTANTS +day-names+ +short-day-names+ +month-names+ +short-month-names+ +days-per-week+ +hours-per-day+ +seconds-per-day+ +seconds-per-hour+ +seconds-per-minute+ +minutes-per-day+ +minutes-per-hour+ SPECIAL VARIABLES *default-timezone* When an encoding or decoding timestamp function is called without an explicit timezone, the timezone stored here is used. MACROS with-decoded-timestamp ((&key nsec sec minute hour day month year day-of-week daylight-p timezone) timestamp &body body) Binds various parts of the timestamp to variables in the body. TIMESTAMP ENCODING make-timestamp (&rest args) Creates an instance of a timestamp, given the raw timestamp data. Do we even want this as an exported API? The internal representation of timestamps should probably be opaque. Might be necessary for efficient serialization, though. clone-timestamp (timestamp) Given a timestamp, returns another timestamp of the same value. universal-to-timestamp (&key universal nsec timezone) Converts a universal time into a timestamp with the given nanosecond field. If timezone is omitted, the default timezone is used. unix-to-timestamp (&key unix nsec timezone) Converts the unix time to a timestamp with the given nanosecond field. If timezone is omitted, the default timezone is used. parse-duration (durationstr &key (date-separator #\-) (date-time-separator #\T)) Parses a duration in ISO format. parse-timestring (timestring &rest args) Parses a timestamp in ISO format. This function may raise an error if the string is not in ISO format, or if an attempt to create an invalid timestamp is detected. encode-timestamp (nsec sec minute hour day month year &key (timezone *default-timezone*) into) Encodes a timestamp with the given time values. This function may raise an error if an invalid timestamp is specified. now () Returns a timestamp corresponding to the current instant in time. today () Returns a timestamp corresponding to midnight UTC of the current date. first-day-of-year (timestamp-or-year &key into timezone) last-day-of-year (timestamp-or-year &key into timezone) first-day-of-month (timestamp &key into timezone) last-day-of-month (timestamp &key into timezone) first-day-of-week (timestamp &key into timezone) last-day-of-week (timestamp &key into timezone) Returns the first or last days of various time periods. If a timestamp is passed as INTO, the value is altered and the timestamp returned. Otherwise, a new timestamp is returned. TIMESTAMP DECODING timestamp-to-unix (timestamp &key timezone) timestamp-to-universal (timestamp &key timezone) decode-timestamp (timestamp &key timezone) format-timestamp (format timestamp &key timezone) format-datestring (date &key timezone) format-duration (duration &key (omit-date-part-p nil) (omit-time-part-p nil) format-timestring (timestamp &key destination timezone (omit-date-part-p nil) timestamp-century timestamp-day timestamp-day-of-week (timestamp &key timezone) timestamp-day-of-year timestamp-decade timestamp-decode-date (time &key timezone) timestamp-decode-time (timestamp &key timezone) timestamp-hour timestamp-iso-day-of-week timestamp-iso-year timestamp-microseconds timestamp-millennium timestamp-milliseconds timestamp-minute timestamp-month timestamp-quarter timestamp-second timestamp-week timestamp-year TIMESTAMP MANIPULATION age (time &key from (unit :seconds)) Returns an integer (not a duration) representing the time difference in the given units timestamp+ (time duration &rest durations) timestamp- (time duration &rest durations) Timestamp/duration arithmetic functions. timestamp> (time &rest times) timestamp< (time &rest times) timestamp>= (time &rest times) timestamp<= (time &rest times) timestamp= (time &rest times) timestamp/= (time &rest times) Comparison between timestamps. timestamp-max (time &rest times) timestamp-min (time &rest times) Returns the earliest (min) or the latest (max) timestamp. timestamp-ceiling (time unit &key timezone) timestamp-floor (time unit &key timezone) Truncates the timestamp to the given unit. timestamp-ceiling truncates to the maximum possible value, timestamp-floor truncates to the minimum possible value. DURATION FUNCTIONS make-duration (&key (nsec 0) (usec 0) (msec 0) (sec 0) (minute 0) (hour 0) (day 0) (week 0) (months 0) (years 0)) duration+ (duration &rest durations) duration- (duration &rest durations) duration* (duration &rest numbers) TIMEZONE FUNCTIONS reread-timezone-repository () define-timezone (zone-name zone-file &key (load nil)) timezone= (timezone-1 timezone-2) UTILITY FUNCTIONS interval-overlaps-p (time-a duration-a time-b duration-b) Returns T if the intervals overlap in time. Otherwise returns NIL. astronomical-julian-date (timestamp) modified-julian-date (timestamp) Returns the julian dates as a floating-point value. days-in-month (month year) Returns the number of days in the current month. days-to-years (days) years-to-days (years) These functions are of dubious utility. Should we keep them at all? enable-read-macros () Enables the reader macros for reading literal timestamps and durations. From dlowe at bitmuse.com Tue Mar 11 18:20:38 2008 From: dlowe at bitmuse.com (Daniel Lowe) Date: Tue, 11 Mar 2008 14:20:38 -0400 Subject: [local-time-devel] Proposed local-time 1.0 API (revision 1) Message-ID: <47D6CD76.5060703@bitmuse.com> Please look over the proposed API and make criticisms and suggestions. CLASSES timestamp A timestamp is a value indicating a particular point in time. Arithmetic is not possible with timestamps, but they may be compared. Internally, timestamps are always encoded as UTC. duration A duration is a value indicating a particular duration. Arithmetic is possible with durations, and they may be also be added to timestamps to produce another timestamp. Duration slots are entirely seperate from each other - no rollover is applied during arithmetic. A one day duration is treated differently from a 24 hour duration. Duration slots must be always be positive integers. When adding durations to each other, each slot is added to the corresponding slot. When adding a duration to a timestamp, the slots are added to the timestamp in order of increasing resolution. The timestamp is modified in such a way that each duration slot affects only the decoded values of equal or less resolution. Illegal dates will signal an error. Example: (+ @D1M @2008-03-05) => @2008-04-05 ; adding one month (+ @D30D @2008-03-05) => @2008-04-04 ; adding 30 days (+ @D1M60D @2008-03-05) => @2008-06-05 ; adding one month and 60 days ;; Adding one day and five minutes (+ @D1D5M @2008-03-05T23:59:00) => @2008-03-07T00:04:00 timezone Timezones are local modifications to UTC. They are only applied when encoding or decoding a timestamp. CONSTANTS +day-names+ +short-day-names+ +month-names+ +short-month-names+ +days-per-week+ +hours-per-day+ +seconds-per-day+ +seconds-per-hour+ +seconds-per-minute+ +minutes-per-day+ +minutes-per-hour+ SPECIAL VARIABLES *default-timezone* When an encoding or decoding timestamp function is called without an explicit timezone, the timezone stored here is used. MACROS with-decoded-timestamp ((&key nsec sec minute hour day month year day-of-week daylight-p timezone) timestamp &body body) Binds various parts of the timestamp to variables in the body. TIMESTAMP ENCODING make-timestamp (&rest args) Creates an instance of a timestamp, given the raw timestamp data. Do we even want this as an exported API? The internal representation of timestamps should probably be opaque. Might be necessary for efficient serialization, though. clone-timestamp (timestamp) Given a timestamp, returns another timestamp of the same value. universal-to-timestamp (&key universal nsec timezone) Converts a universal time into a timestamp with the given nanosecond field. If timezone is omitted, the default timezone is used. unix-to-timestamp (&key unix nsec timezone) Converts the unix time to a timestamp with the given nanosecond field. If timezone is omitted, the default timezone is used. parse-duration (durationstr &key (date-separator #\-) (date-time-separator #\T)) Parses a duration in ISO format. parse-timestring (timestring &rest args) Parses a timestamp in ISO format. This function may raise an error if the string is not in ISO format, or if an attempt to create an invalid timestamp is detected. encode-timestamp (nsec sec minute hour day month year &key (timezone *default-timezone*) into) Encodes a timestamp with the given time values. This function may raise an error if an invalid timestamp is specified. now () Returns a timestamp corresponding to the current instant in time. today () Returns a timestamp corresponding to midnight UTC of the current date. first-day-of-year (timestamp-or-year &key into timezone) last-day-of-year (timestamp-or-year &key into timezone) first-day-of-month (timestamp &key into timezone) last-day-of-month (timestamp &key into timezone) first-day-of-week (timestamp &key into timezone) last-day-of-week (timestamp &key into timezone) Returns the first or last days of various time periods. If a timestamp is passed as INTO, the value is altered and the timestamp returned. Otherwise, a new timestamp is returned. TIMESTAMP DECODING timestamp-to-unix (timestamp &key timezone) timestamp-to-universal (timestamp &key timezone) decode-timestamp (timestamp &key timezone) format-timestamp (format timestamp &key timezone) format-datestring (date &key timezone) format-duration (duration &key (omit-date-part-p nil) (omit-time-part-p nil) format-timestring (timestamp &key destination timezone (omit-date-part-p nil) timestamp-century timestamp-day timestamp-day-of-week (timestamp &key timezone) timestamp-day-of-year timestamp-decade timestamp-decode-date (time &key timezone) timestamp-decode-time (timestamp &key timezone) timestamp-hour timestamp-iso-day-of-week timestamp-iso-year timestamp-microseconds timestamp-millennium timestamp-milliseconds timestamp-minute timestamp-month timestamp-quarter timestamp-second timestamp-week timestamp-year TIMESTAMP MANIPULATION age (time &key from (unit :seconds)) Returns an integer (not a duration) representing the time difference in the given units timestamp+ (time duration &rest durations) timestamp- (time duration &rest durations) Timestamp/duration arithmetic functions. timestamp> (time &rest times) timestamp< (time &rest times) timestamp>= (time &rest times) timestamp<= (time &rest times) timestamp= (time &rest times) timestamp/= (time &rest times) Comparison between timestamps. timestamp-max (time &rest times) timestamp-min (time &rest times) Returns the earliest (min) or the latest (max) timestamp. timestamp-ceiling (time unit &key timezone) timestamp-floor (time unit &key timezone) Truncates the timestamp to the given unit. timestamp-ceiling truncates to the maximum possible value, timestamp-floor truncates to the minimum possible value. DURATION FUNCTIONS make-duration (&key (nsec 0) (usec 0) (msec 0) (sec 0) (minute 0) (hour 0) (day 0) (week 0) (months 0) (years 0)) duration+ (duration &rest durations) duration- (duration &rest durations) duration* (duration &rest numbers) TIMEZONE FUNCTIONS reread-timezone-repository () define-timezone (zone-name zone-file &key (load nil)) timezone= (timezone-1 timezone-2) UTILITY FUNCTIONS interval-overlaps-p (time-a duration-a time-b duration-b) Returns T if the intervals overlap in time. Otherwise returns NIL. astronomical-julian-date (timestamp) modified-julian-date (timestamp) Returns the julian dates as a floating-point value. days-in-month (month year) Returns the number of days in the current month. days-to-years (days) years-to-days (years) These functions are of dubious utility. Should we keep them at all? enable-read-macros () Enables the reader macros for reading literal timestamps and durations. From attila.lendvai at gmail.com Sun Mar 16 17:17:02 2008 From: attila.lendvai at gmail.com (Attila Lendvai) Date: Sun, 16 Mar 2008 18:17:02 +0100 Subject: [local-time-devel] postmodern integration Message-ID: dear lists, i've pushed changes into our local-time branch that contains an asdf-system-connection to cl-postgres: darcs pull http://www.common-lisp.net/project/cl-dwim/darcs/local-time Daniel, if you don't mind the extra dependency then please push it into the official. now it's possible to use postmodern so that it returns local-time values and at the same time does not interfere with other softwares that use its simple-date lib. the approach is similar to cl's readtables: (defparameter *custom-sql-readtable* (local-time:set-local-time-cl-postgres-readers (cl-postgres:copy-sql-readtable))) (let ((cl-postgres:*sql-readtable* *custom-sql-readtable*)) (cl-postgres:exec-prepared ...)) at the time of writing our postmodern branch contains a few extra patches. Marijn, please take a look at them and push to the official if you have no concerns with it. darcs pull http://www.common-lisp.net/project/cl-dwim/darcs/postmodern/ -- attila -------------- next part -------------- An HTML attachment was scrubbed... URL: From kiuma72 at gmail.com Tue Mar 25 13:16:28 2008 From: kiuma72 at gmail.com (Andrea Chiumenti) Date: Tue, 25 Mar 2008 14:16:28 +0100 Subject: [local-time-devel] Adding java Calendar 'like' math to local-time Message-ID: <4d3bc9370803250616j5b834717nb092e10788ce055f@mail.gmail.com> Hello ppl, I've added the following functionality to local time, I only wonder if it's not the case to render the internal *-add-* functions as methods. Have a nice day, kiuma (defgeneric local-time-add (local-time field value) (:documentation "Adds the specified amount of VALUE to the LOCAL_TIME. FIELD may be any of: * 'NSEC nano-seconds * 'MSEC milli-seconds * 'SEC seconds * 'MIN minutes * 'HR hours * 'DAY days * 'MONTH monthes * 'YEARS years. And other FIELD value will produce an error condition.")) (defun local-time-add-year (local-time value) (multiple-value-bind (ns ss mm hh day month year) (decode-local-time local-time) (encode-local-time ns ss mm hh day month (+ year value)))) (defun local-time-add-month (local-time value) (multiple-value-bind (d-month d-year) (floor (abs value) 12) (when (< value 0) (setf d-month (- d-month) d-year (- d-year)) (multiple-value-bind (ns ss mm hh day month year) (decode-local-time local-time) (multiple-value-bind (ns ss mm hh day month-ignore year) (decode-local-time (encode-local-time ns ss mm hh day 1 (+ year d-year))) (encode-local-time ns ss mm hh day month year)))))) (defun local-time-add-day (local-time value) (let* ((curr-day (day-of local-time)) (local-time-result (make-instance 'local-time :day curr-day :sec (sec-of local-time) :nsec (nsec-of local-time) :time-zone (timezone-of local-time)))) (setf (day-of local-time-result) (+ curr-day value)) local-time-result)) (defun local-time-add-hour (local-time value) (multiple-value-bind (ns ss mm hh day month year) (decode-local-time local-time) (multiple-value-bind (d-hour d-day) (floor (abs value) 24) (when (< value 0) (setf d-hour (- d-hour) d-day (- d-day))) (let ((local-time-result (local-time-add-day local-time d-day))) (multiple-value-bind (ns2 ss2 mm2 hh2 day2 month2 year2) (decode-local-time local-time-result) (encode-local-time ns2 ss2 mm2 (+ hh d-hour) day2 month2 year2)))))) (defun local-time-add-min (local-time value) (multiple-value-bind (ns ss mm hh day month year) (decode-local-time local-time) (multiple-value-bind (d-min d-hour) (floor (abs value) 60) (when (< value 0) (setf d-min (- d-min) d-hour (- d-hour))) (let ((local-time-result (local-time-add-hour local-time d-hour))) (multiple-value-bind (ns2 ss2 mm2 hh2 day2 month2 year2) (decode-local-time local-time-result) (encode-local-time ns2 ss2 (+ mm d-min) hh2 day2 month2 year2)))))) (defun local-time-add-sec (local-time value) (multiple-value-bind (ns ss mm hh day month year) (decode-local-time local-time) (multiple-value-bind (d-sec d-min) (floor (abs value) 60) (when (< value 0) (setf d-sec (- d-sec) d-min (- d-min))) (let ((local-time-result (local-time-add-min local-time d-min))) (multiple-value-bind (ns2 ss2 mm2 hh2 day2 month2 year2) (decode-local-time local-time-result) (encode-local-time ns2 (+ ss d-sec) mm2 hh2 day2 month2 year2)))))) (defun local-time-add-nsec (local-time value) (multiple-value-bind (ns ss mm hh day month year) (decode-local-time local-time) (multiple-value-bind (d-nsec d-sec) (floor (abs value) 10000000) (when (< value 0) (setf d-nsec (- d-nsec) d-sec (- d-sec))) (let ((local-time-result (local-time-add-sec local-time d-sec))) (multiple-value-bind (ns2 ss2 mm2 hh2 day2 month2 year2) (decode-local-time local-time-result) (encode-local-time (+ ns d-nsec) ss2 mm2 hh2 day2 month2 year2)))))) ;;; make this extern <<----------------------------- (defmethod local-time-add ((local-time local-time) field value) (ccase field (NSEC (local-time-add-nsec local-time value)) (SEC (local-time-add-sec local-time value)) (MIN (local-time-add-min local-time value)) (HR (local-time-add-hour local-time value)) (DAY (local-time-add-day local-time value)) (MONTH (local-time-add-month local-time value)) (YEAR (local-time-add-year local-time value))))