From enaeher at gmail.com Fri Jan 3 20:58:55 2014 From: enaeher at gmail.com (Eli Naeher) Date: Fri, 3 Jan 2014 14:58:55 -0600 Subject: Durations and intervals Message-ID: Hello, I'm interested in adding durations, intervals, and some arithmetic support. I see that this stuff is all present in the TODO. Would such a patch be welcomed? Is there any particular way that the maintainers would prefer this be implemented? -Eli -------------- next part -------------- An HTML attachment was scrubbed... URL: From enaeher at gmail.com Tue Jan 7 18:49:32 2014 From: enaeher at gmail.com (Eli Naeher) Date: Tue, 7 Jan 2014 12:49:32 -0600 Subject: local-time-duration Message-ID: Hello, After looking at the time-interval package, I determined that it did some things that I didn't need (like handling intervals denominated in months and years) and wasn't able to do some things I did need (like comparing intervals expressed in different units), so I have written local-time-duration, available at https://github.com/enaeher/local-time-duration. There is room for optimization but it does what I need and may be useful to others. I re-used the %defcomparator macro from local-time to implement things like duration>, duration<, etc., but had to modify it slightly since the original asserts that its arguments are timestamps. Would a patch to local-time so that %defcomparator can be passed an expected argument type be accepted? If so, I will prepare a pull request. -Eli -------------- next part -------------- An HTML attachment was scrubbed... URL: From psilord at cs.wisc.edu Fri Jan 31 22:07:47 2014 From: psilord at cs.wisc.edu (Peter Keller) Date: Fri, 31 Jan 2014 16:07:47 -0600 Subject: Patch to support Allegro Common Lisp Message-ID: <20140131220747.GA21821@cs.wisc.edu> Hello, I have produced a patch which allows LOCAL-TIME to support subsecond resolution of time in Allegro Common Lisp. I produced it with git format-patch and attached it to this email. Hopefully, it'll be good enough without further changes. Let me know if you need anything else. Thank you. Peter Keller -------------- next part -------------- >From ae6325f7aadaf771f6ed86ad7c4893818351031e Mon Sep 17 00:00:00 2001 From: Peter Keller Date: Fri, 31 Jan 2014 15:57:26 -0600 Subject: [PATCH] Add support for subsecond resolution under Allegro. --- src/local-time.lisp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/local-time.lisp b/src/local-time.lisp index 831660d..508160a 100644 --- a/src/local-time.lisp +++ b/src/local-time.lisp @@ -947,8 +947,33 @@ elements." (declare (type timestamp timestamp)) (timestamp-values-to-unix (sec-of timestamp) (day-of timestamp))) +#+allegro +(eval-when (:compile-toplevel :load-toplevel :execute) + ;; Allegro common lisp requires some toplevel hoops through which to + ;; jump in order to call unix's gettimeofday properly. + (ff:def-foreign-type timeval + (:struct (tv_sec :long) + (tv_usec :long))) + + (ff:def-foreign-call + (allegro-ffi-gettimeofday "gettimeofday") + ((timeval (* timeval)) + ;; and do this to allow a 0 for NULL + (timezone :foreign-address)) + :returning (:int fixnum))) + (defun %get-current-time () "Cross-implementation abstraction to get the current time measured from the unix epoch (1/1/1970). Should return (values sec nano-sec)." + #+allegro + (flet ((allegro-gettimeofday () + (let ((tv (ff:allocate-fobject 'timeval :c))) + (allegro-ffi-gettimeofday tv 0) + (let ((sec (ff:fslot-value-typed 'timeval :c tv 'tv_sec)) + (usec (ff:fslot-value-typed 'timeval :c tv 'tv_usec))) + (ff:free-fobject tv) + (values sec usec))))) + (multiple-value-bind (sec usec) (allegro-gettimeofday) + (values sec (* 1000 usec)))) #+cmu (multiple-value-bind (success? sec usec) (unix:unix-gettimeofday) (assert success? () "unix:unix-gettimeofday reported failure?!") @@ -967,7 +992,7 @@ elements." (let ((err (ccl:external-call "gettimeofday" :address tv :address (ccl:%null-ptr) :int))) (assert (zerop err) nil "gettimeofday failed") (values (ccl:pref tv :timeval.tv_sec) (* 1000 (ccl:pref tv :timeval.tv_usec))))) - #-(or cmu sbcl (and ccl (not windows))) + #-(or allegro cmu sbcl (and ccl (not windows))) (values (- (get-universal-time) ;; CL's get-universal-time uses an epoch of 1/1/1900, so adjust the result to the Unix epoch #.(encode-universal-time 0 0 0 1 1 1970 0)) -- 1.8.1.2 From attila.lendvai at gmail.com Fri Jan 24 03:20:22 2014 From: attila.lendvai at gmail.com (Attila Lendvai) Date: Fri, 24 Jan 2014 09:20:22 +0600 Subject: local-time-duration In-Reply-To: References: Message-ID: > intervals expressed in different units), so I have written > local-time-duration, available at > https://github.com/enaeher/local-time-duration. There is room for > optimization but it does what I need and may be useful to others. thanks for the note, i've added this to the local-time readme/TODO. Daniel, can you please flip me the commit bit on github for local-time? i don't have any big plans, just small semantic-noop's like this... and even if i'll have some plans i'll open a discussion and a branch in my own fork. > I re-used the %defcomparator macro from local-time to implement things like > duration>, duration<, etc., but had to modify it slightly since the original > asserts that its arguments are timestamps. Would a patch to local-time so > that %defcomparator can be passed an expected argument type be accepted? If > so, I will prepare a pull request. that sounds like a reasonable change *in the current setup*, but i don't think it makes sense to have a separate library for your code; it should be part of local-time. but i can sympathize with your decision given the level of feedback you received... sorry for that! i personally will not have much time for local-time in the future either. -- ? attila lendvai ? PGP: 963F 5D5F 45C7 DFCD 0A39 -- ?Democracy: It's not freedom, it's just smarter human farming.? ? Stefan Molyneux From enaeher at gmail.com Fri Jan 3 21:31:00 2014 From: enaeher at gmail.com (Eli Naeher) Date: Fri, 3 Jan 2014 15:31:00 -0600 Subject: Durations and intervals In-Reply-To: References: Message-ID: I have been directed to the existing time-interval package which looks like it will do what I need to do. Thank you, -Eli On Fri, Jan 3, 2014 at 2:58 PM, Eli Naeher wrote: > Hello, > > I'm interested in adding durations, intervals, and some arithmetic > support. I see that this stuff is all present in the TODO. > > Would such a patch be welcomed? Is there any particular way that the > maintainers would prefer this be implemented? > > -Eli > -------------- next part -------------- An HTML attachment was scrubbed... URL: