From rtvd at mail.ru Mon Oct 1 12:35:35 2007 From: rtvd at mail.ru (Denys Rtveliashvili) Date: Mon, 01 Oct 2007 16:35:35 +0400 Subject: [local-time-devel] proper way to "travel in time"(?) In-Reply-To: References: <46F68D83.6010405@mail.ru> <46F94EB1.1000209@mail.ru> Message-ID: <4700E997.9020809@mail.ru> I have written a function which returns a local-time object with a time, shifted from the specified one by a necessary offset. It is possible to call it like this: (adjusted-local-time :day 15 (now)) (adjusted-local-time :month -1 *important-date*) When shifting usec/sec/../days it works with the local-time object directly (as there can be no overflows). The only exceptions are shifts by months and years. In such cases the time stamp is decomposed by decode-local-time and then it is shifted. However, before the date is finally composed with the encode-local-time an additional test is made: the day of month should be not larger than the number of days in that month. If it is larger, the day of month is set to the last one available. Any comments are welcome. Please find a patch attached to this email. With kind regards, Denys Rtveliashvili > > I am going to try doing something like that myself and if the > result is > nice I will send it to this maillist. > > > sounds good, looking forward to it! > > -- > attila From attila.lendvai at gmail.com Mon Oct 1 12:55:11 2007 From: attila.lendvai at gmail.com (Attila Lendvai) Date: Mon, 1 Oct 2007 14:55:11 +0200 Subject: [local-time-devel] proper way to "travel in time"(?) In-Reply-To: <4700E997.9020809@mail.ru> References: <46F68D83.6010405@mail.ru> <46F94EB1.1000209@mail.ru> <4700E997.9020809@mail.ru> Message-ID: > (adjusted-local-time :day 15 (now)) a _very_ preliminary comment: you fogot the attachment... ;) but other than that, is there any reason why the input local-time object in the arg list is not the first one? maybe due to &optional? would it be useful if the local-time arg were optional defaulting to (now)? -- attila From rtvd at mail.ru Mon Oct 1 14:01:31 2007 From: rtvd at mail.ru (Denys Rtveliashvili) Date: Mon, 01 Oct 2007 18:01:31 +0400 Subject: [local-time-devel] proper way to "travel in time"(?) In-Reply-To: References: <46F68D83.6010405@mail.ru> <46F94EB1.1000209@mail.ru> <4700E997.9020809@mail.ru> Message-ID: <4700FDBB.7000103@mail.ru> Ops.. Indeed, I have forgotten to attach it. %( Sending it with this email. There was no particular reason for making the input local-time the last argument. And I like your idea on making it optional. Regards, Denys Rtveliashvili > a _very_ preliminary comment: you fogot the attachment... ;) > > but other than that, is there any reason why the input local-time > object in the arg list is not the first one? maybe due to &optional? > would it be useful if the local-time arg were optional defaulting to > (now)? > > -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: patch URL: From rtvd at mail.ru Thu Oct 11 16:50:52 2007 From: rtvd at mail.ru (Denys Rtveliashvili) Date: Thu, 11 Oct 2007 20:50:52 +0400 Subject: [local-time-devel] one more patch with two new functions Message-ID: <470E546C.3030104@mail.ru> Hi Here is another patch with two functions I find useful. The first one returns number the of days in month and another one (modified-local-time) returns the local-time object with a required modification made. It is similar to adjusted-local-time. However, adjusted-local-time shifts the date when the modified-local-time sets the specified field to the required value. The functions modified-local-time and adjusted-local-time resemble the *|set(f, value)|* and *|add(f, delta)|* methods in Java's Calendar class. The main difference is that the former functions do not modify the original time. Regards, Denys Rtveliashvili -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: patch2 URL: From antony.sequeira at gmail.com Mon Oct 22 05:11:59 2007 From: antony.sequeira at gmail.com (Antony Sequeira) Date: Sun, 21 Oct 2007 22:11:59 -0700 Subject: [local-time-devel] why no arithmetic Message-ID: <6fb33c150710212211r25aa41a7md774f9e79c055cae@mail.gmail.com> Hi, 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. So I was wondering how I should go about it. Am I missing something. Am I supposed to get some components (like the paper says days, seconds and milliseconds) and add to them or am I completely off track here. I have very little real CL experience, please keep that in mind when you reply. I hope I do get some replies :) BTW, I installed the lib and ran tests and got the following Test FORMAT-TIMESTRING-2 failed for value 0! Expected value: "2008-06-05T04:03:02.001-5:00" Actual value: "2008-06-05T04:03:02.001-7:00" Test UNIVERSAL-TIME-1 failed for value 8! Expected value: 6 Actual value: 8 67/69 tests passed. NIL FWIW (now) (decode-local-time (now)) show correct stuff. My system is Fedora 6 and it is in the Pacific Daylight Savings time zone. Anyway these failures are not my issues right now, but I thought I'll share them. Thank you, -Antony Sequeira