Hi avi
did you check whether this problem is fixed in 3.9? Stef On 13 avr. 06, at 09:37, Avi Bryant wrote: > > On Apr 13, 2006, at 12:08 AM, [hidden email] wrote: >> >> PS. But I do think the official Squeak should make a choice - there >> should be a "Squeak standard". And of course, we did that pretty >> recently - Chronology. Would be interesting to hear more about >> pros/cons. :) > > What I can contribute here is that the performance benefits are > more than just theoretical - the poor performance of the Chronology > package has been responsible for a significant percentage of the > bottlenecks in our production code recently. More than once, our > profiling has led us to some part of Chronology that was an order > of magnitude or two slower than it needed to be. The most recent > example of a couple of days ago was DateAndTime>>hash - try > sticking a few thousand dates into a Set and you'll see what I > mean. That can be sped up, in some cases, by a simple optimization > in DateAndTime>>asUTC: > > asUTC > ^ offset isZero > ifTrue: [self] > ifFalse: [self utcOffset: 0] > > Avi > |
In reply to this post by Alan L. Lovejoy
Hi Alan, Francisco,
we also created a model to deal with dates and time issues because of the same issues you and Brent mentioned. We uploaded last week to squeak source, it is named Chalten. Alan Lovejoy wrote: >Garau wrote: > >"- Starting on the 31Mar2006 generate a schedule of payments every month >until 31Mar2007. >That should return 30Apr06 31May06 30Jun06 ... 28Feb07 31Mar07" > >| schedule | >schedule := OrderedCollection new. >(Timeperiod from: (YearMonthDay year: 2006 month: 4 day: 1) duration: >(CalendarDuration years: 1 months: 0 days: 0)) > monthsDo: [:month | schedule add: month last]. >schedule => OrderedCollection (2006-04-30 2006-05-31 2006-06-30 2006-07-31 >2006-08-31 2006-09-30 2006-10-31 2006-11-30 2006-12-31 2007-01-31 2007-02-28 >2007-03-31) > > (April, 2006 to: March, 2007) collect: [ :aMonthOfYear | aMonthOfYear lastDate ] or: ((GregorianMonth april yearNumber: 2006) to: (GregorianMonth march yearNumber: 2007)) collect: [ :aMonthOfYear | aMonthOfYear lastDate ] >"- Adjust the previous schedule to the british and japanese calendar, making >sure all dates are 'good business days'. So, for example, if 30Apr06 falls >on Sunday or a british bank holiday, change it according to some rule. >Examples of such rules are: >next business day, next calendar day, etc. > >It gets more complicated when you think about DCC (day count conventions). >In the first example we were dealing with actual months. But under the >30/360 DCC, every month has 30 days." > >Chronos doesn't currently support the Japanese Imperial Calendar. I haven't >actually looked at that one, so I don't know how easy or hard it may be to >implement. However, once implemented, adding new calendars to Chronos is >quite easy. > >SemanticDatePolicy instances can be used to define holiday schedules using >any combination of supported calendars. Extensible observance rules are >supported. US Holidays (including all rule-based and >one-time-only-historical NYSE holidays) are predefined; others must be added >by the programmer. > >So, modifying the first example to handle US banking holidays would look >like this: > >| sdp holidays schedule dateSelector | >sdp := SemanticDatePolicy unitedStates. >holidays := SemanticDatePolicy usFederalHolidaySemanticKeys. >schedule := OrderedCollection new. >dateSelector := > [:date | > date dayOfWeekKey == #Sunday > ifTrue: [dateSelector value: (date addingDays: 1)] > ifFalse: > [(date annualDateSemanticKeyFrom: sdp satisfies: >[:semanticKey | holidays includes: semanticKey]) > ifTrue: [dateSelector value: (date >addingDays: 1)] > ifFalse: [date]]]. >(Timeperiod from: (YearMonthDay year: 2006 month: 4 day: 1) duration: >(CalendarDuration years: 1 months: 0 days: 0)) > monthsDo: [:month | schedule add: (dateSelector value: month last)]. >schedule => OrderedCollection (2006-05-01 2006-05-31 2006-06-30 2006-07-31 >2006-08-31 2006-09-30 2006-10-31 2006-11-30 2007-01-02 2007-01-31 2007-02-28 >2007-03-31) > >The 30/360 DCC is trivial to implement, using CalendarDurations and >Timeperiods. > > problem are easy to solved. There is an abstraction called "TimeLineFilter" that allows you to filter the time line of any granularity and walk over the filtered time points. So, to get due working days, the code would be: (April, 2006 to: March, 2007) collect: [ :aMonthOfYear | MonthBasedDueDate for: aMonthOfYear lastDate in: britishWorkingDays ] With this code you will get all the due date in as working days of the british working calendar. The britishWorkingDays object is a TimeLineFilter, that can be created this way: britishNonWorkingDays := TimeLineFilter new. britisNonWorkingDays addDayRule: GregorianDay saturday; addDayRule: GregorianDay sunday; addDayOfMonthRule: December twentyFifth. britishWorkingDays := britishNonWorkingDays negated. As you can see, you first create a filter that includes the non working days (because they are less that the working days) and the you the the "negated" filter, that is the working days. About the day count conventions like 30/360, 30/365, Actual/Actual, etc. that are used to calculate the "real" interest rate to pay for an investment, we also have objects to deal with that but they are not part of Chalten because that is a pure financial problem. But to deal with them we use an abstraction that we have in Aconcagua (the measure's model that we opened too) called "Evaluation". An Evaluation is an object that has a meaning by itself but it is used in arithmetic operations. A good example of Evaluation is a class we called Interest. For example: (Interest simpleFor: 1000 * dollar with: (InterestRate yearlyOf: 1/10) during: 2 * TimeUnits year) value --> This will return 200 dollars. (dollar is a unit, 1000 * dollar creates the measure 1000 dollars. 2 * TimeUnits year create the measure 2 years). Another example of Evaluation in the financial domain InterestRate, NetPayment, GrossPayment, etc. (In physics Speed, Aceleration, etc. are good examples). Hernan. >"Dates can be seen from many different points of view. In a financial system >we are certainly not interested in the duration of a date. Not in >nanoseconds, not in milliseconds or even hours. A date is a business date." > >The class Chronos YearMonthDay is implemented just that way, for just that >reason. > >Thanks for your questions. I'll be adding the second example to the website. > >--Alan > >-----Original Message----- >From: [hidden email] >[mailto:[hidden email]] On Behalf Of >Francisco Garau >Sent: Friday, April 14, 2006 3:31 AM >To: The general-purpose Squeak developers list; Alan Lovejoy >Subject: Re: The Timing of Time > >Hi Alan, > >As yourself, I am also interested in date and times. I tried loading the >Chronos package following the instructions from your website [1], but >something went awry. > >I succesfully loaded: > 1- Passport-Kernel > 2- Passport-Squeak > 3- Chronos-System-Squeak > 4- Chronos-System-Squeak-PostV3.6 > >The problem happens on step 3. The last two lines of that fileOut says: > > ChronosSqueakEnvironment initialize ! > ChronosEnvironment canonical install ! > >I guess that ChronosEnvironment should be a class and canonical a message. >But neither of them are in the image. > >My interest on dates is more biased towards dates than towards times. Dates, >months, years and calendars are central objects in financial systems. >Amongst the many problems that arises in such systems, here a couple of >examples: > >- Starting on the 31Mar2006 generate a schedule of payments every month >until 31Mar2007. >That should return 30Apr06 31May06 30Jun06 ... 28Feb07 31Mar07 > >- Adjust the previous schedule to the british and japanese calendar, making >sure all dates are 'good business days'. So, for example, if 30Apr06 falls >on Sunday or a british bank holiday, change it according to some rule. >Examples of such rules are: >next business day, next calendar day, etc. > >It gets more complicated when you think about DCC (day count conventions). >In the first example we were dealing with actual months. But under the >30/360 DCC, every month has 30 days. > >Dates can be seen from many different points of view. In a financial system >we are certainly not interested in the duration of a date. Not in >nanoseconds, not in milliseconds or even hours. A date is a business date. > >I agree with the Mercap guys that dates, months and years are views of the >same time-line at different levels of granularity. In financial systems we >don't need to go further down that date. For other type of systems requiring >global syncronization, you probably need to go down to the millisecond >level. Furthermore, you need every time to be expressed as an offset from a >central location (Greenwich?). > >That is my poor understanding of time-zones and the reason why I want to >play with the Chronos package. > >Cheers, >Francisco > >[1] http://chronos-st.org/frames/Squeak-Downloads.html >[2] http://article.gmane.org/gmane.comp.lang.smalltalk.squeak.general/100148 > > > > > > > > -- ______________________________ Lic. Hernán A. Wilkinson Gerente de Desarrollo y Tecnología Mercap S.R.L. Tacuari 202 - 7mo Piso - Tel: 54-11-4878-1118 Buenos Aires - Argentina http://www.mercapsoftware.com --------------------------------------------------------------------- Este mensaje es confidencial. Puede contener informacion amparada por el secreto profesional. Si usted ha recibido este e-mail por error, por favor comuniquenoslo inmediatamente via e-mail y tenga la amabilidad de eliminarlo de su sistema; no debera copiar el mensaje ni divulgar su contenido a ninguna persona. Muchas gracias. This message is confidential. It may also contain information that is privileged or otherwise legally exempt from disclosure. If you have received it by mistake please let us know by e-mail immediately and delete it from your system; you should also not copy the message nor disclose its contents to anyone. Thanks. --------------------------------------------------------------------- |
On Mon, Apr 17, 2006 at 11:30:02AM -0300, Hernan Wilkinson wrote:
> we also created a model to deal with dates and time issues because > of the same issues you and Brent mentioned. We uploaded last week to > squeak source, it is named Chalten. > Alan Lovejoy wrote: Hi Hernan, I should mention that we both have used "PointInTime" as a class name. In TimeZoneDatabase, the class PointInTime represents an absolute time magnitude, independent of Earth rotational representations of time (time zones, calendars, leap seconds, etc). I think that you have done something similar in Chalten. This would not be hard to change if someone wanted TimeZoneDatebase and Chalten in the same image, but I just wanted to let you know about it. Dave |
In reply to this post by stéphane ducasse-2
Stéphane: "Does it mean that you have an abstraction over the ugly FileDirectory and friends." Yes, Passport provides an abstraction layer over FileDirectory, in three different senses: 1. Like a VisualWorks Filename, a ResourcePath has behavior appropriate for handling file names as such, as opposed to String mangling. 2. ResourcePaths can also be used as URL objects--using the same API as when they represent "Filenames." Whether the String representation of a ResourcePath looks like a host-platform filename string, or like a File URL (or like an HTTP URL) is a function of which Strategy object is associated with the instance. 3. ResourcePaths provide cross-platform portability, in two different senses. Firstly, a single instance can represent the same relative path on any of Windows, UNIX, the classic MacOS or RiscOS. Absolute paths are necessarily host-platform specific, although the platform-specific part of the path can be represented as mutable data in the ResourcePathContext associated with each ResourcePath (the same ResourcePathContext can be bound to any number of ResourcePaths.) Secondly, Passport provides portability of the code that uses ResourcePaths to all Smalltalk environments to which Passport has been ported, which for now means VisualWorks and Squeak--although the Dolphin port will be available soon. Stéphane: "So we could have this kind of behavior File default recursivelyDo: [:each | where each would be a resourcepath] ?" | handleFile handleDirectory | handleFile := [:file | file extension = 'bak' ifTrue: [file delete]]. handleDirectory := [:directory | directory contentsDo: [:resourcePath | resourcePath isDirectory ifTrue: [handleDirectory value: resourcePath] ifFalse: [handleFile value: resourcePath]]] handleDirectory value: ResourcePath defaultDirectory -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of stéphane ducasse Sent: Sunday, April 16, 2006 11:48 PM To: The general-purpose Squeak developers list Subject: Re: The Timing of Time HI alan this sounds really interesting. Does it mean that you have an abstraction over the ugly FileDirectory and friends. > Passport provides the class ResourcePath, which is conceptually a > union of a VisualWorks Filename with a URL object. ResourcePaths > support HTTP URLs, File URLs and native filenames (in the latter case, > using native filename syntax--Windows, Unix or Classic MacOS.) In > VisualWorks, they also support FtpURLs and HttpsURLs (and it wouldn't > be all that hard to do the same in > Squeak.) Note that ResourcePaths can do all that without any > subclasses--they use the Strategy pattern instead. So we could have this kind of behavior File default recursivelyDo: [:each | where each would be a resourcepath] ? > > The Squeak implementation of Passport includes the classes > HttpRequest and > HttpResponse, which implement HTTP 1.1 with both client-side and > server side > functionality. You might find that to be of some interest, in view > of the > mess that is HTTPSocket. |
In reply to this post by Hernan Wilkinson
Hernan: Can a TimeLineFilter handle rules such as "the day after the fourth Thursday of November," "two days before Easter" or "Nisan 14 (Hebrew Calendar)"? What about one-of-a-kind non-business days, such as the closure of the NYSE due to a Presidential Funeral? A Chronos SemnticDatePolicy will handle rules like that (and could easily be extended for even more comples cases.) I like the syntax of the Domain-Specific Language you're developing. There might be some really good synergy achievable from implementing Chalten on top of Chronos. --Alan -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Hernan Wilkinson Sent: Monday, April 17, 2006 7:30 AM To: The general-purpose Squeak developers list Subject: Re: The Timing of Time Hi Alan, Francisco, we also created a model to deal with dates and time issues because of the same issues you and Brent mentioned. We uploaded last week to squeak source, it is named Chalten. Alan Lovejoy wrote: >Garau wrote: > >"- Starting on the 31Mar2006 generate a schedule of payments every >month until 31Mar2007. >That should return 30Apr06 31May06 30Jun06 ... 28Feb07 31Mar07" > >| schedule | >schedule := OrderedCollection new. >(Timeperiod from: (YearMonthDay year: 2006 month: 4 day: 1) duration: >(CalendarDuration years: 1 months: 0 days: 0)) > monthsDo: [:month | schedule add: month last]. >schedule => OrderedCollection (2006-04-30 2006-05-31 2006-06-30 >2006-07-31 >2006-08-31 2006-09-30 2006-10-31 2006-11-30 2006-12-31 2007-01-31 >2007-02-28 >2007-03-31) > > (April, 2006 to: March, 2007) collect: [ :aMonthOfYear | aMonthOfYear lastDate ] or: ((GregorianMonth april yearNumber: 2006) to: (GregorianMonth march yearNumber: 2007)) collect: [ :aMonthOfYear | aMonthOfYear lastDate ] >"- Adjust the previous schedule to the british and japanese calendar, >making sure all dates are 'good business days'. So, for example, if >30Apr06 falls on Sunday or a british bank holiday, change it according to some rule. >Examples of such rules are: >next business day, next calendar day, etc. > >It gets more complicated when you think about DCC (day count conventions). >In the first example we were dealing with actual months. But under the >30/360 DCC, every month has 30 days." > >Chronos doesn't currently support the Japanese Imperial Calendar. I >haven't actually looked at that one, so I don't know how easy or hard >it may be to implement. However, once implemented, adding new >calendars to Chronos is quite easy. > >SemanticDatePolicy instances can be used to define holiday schedules >using any combination of supported calendars. Extensible observance >rules are supported. US Holidays (including all rule-based and >one-time-only-historical NYSE holidays) are predefined; others must be >added by the programmer. > >So, modifying the first example to handle US banking holidays would >look like this: > >| sdp holidays schedule dateSelector | >sdp := SemanticDatePolicy unitedStates. >holidays := SemanticDatePolicy usFederalHolidaySemanticKeys. >schedule := OrderedCollection new. >dateSelector := > [:date | > date dayOfWeekKey == #Sunday > ifTrue: [dateSelector value: (date addingDays: 1)] > ifFalse: > [(date annualDateSemanticKeyFrom: sdp satisfies: >[:semanticKey | holidays includes: semanticKey]) > ifTrue: [dateSelector value: (date >addingDays: 1)] > ifFalse: [date]]]. >(Timeperiod from: (YearMonthDay year: 2006 month: 4 day: 1) duration: >(CalendarDuration years: 1 months: 0 days: 0)) > monthsDo: [:month | schedule add: (dateSelector value: month last)]. >schedule => OrderedCollection (2006-05-01 2006-05-31 2006-06-30 >2006-07-31 >2006-08-31 2006-09-30 2006-10-31 2006-11-30 2007-01-02 2007-01-31 >2007-02-28 >2007-03-31) > >The 30/360 DCC is trivial to implement, using CalendarDurations and >Timeperiods. > > problem are easy to solved. There is an abstraction called "TimeLineFilter" that allows you to filter the time line of any granularity and walk over the filtered time points. So, to get due working days, the code would be: (April, 2006 to: March, 2007) collect: [ :aMonthOfYear | MonthBasedDueDate for: aMonthOfYear lastDate in: britishWorkingDays ] With this code you will get all the due date in as working days of the british working calendar. The britishWorkingDays object is a TimeLineFilter, that can be created this way: britishNonWorkingDays := TimeLineFilter new. britisNonWorkingDays addDayRule: GregorianDay saturday; addDayRule: GregorianDay sunday; addDayOfMonthRule: December twentyFifth. britishWorkingDays := britishNonWorkingDays negated. As you can see, you first create a filter that includes the non working days (because they are less that the working days) and the you the the "negated" filter, that is the working days. About the day count conventions like 30/360, 30/365, Actual/Actual, etc. that are used to calculate the "real" interest rate to pay for an investment, we also have objects to deal with that but they are not part of Chalten because that is a pure financial problem. But to deal with them we use an abstraction that we have in Aconcagua (the measure's model that we opened too) called "Evaluation". An Evaluation is an object that has a meaning by itself but it is used in arithmetic operations. A good example of Evaluation is a class we called Interest. For example: (Interest simpleFor: 1000 * dollar with: (InterestRate yearlyOf: 1/10) during: 2 * TimeUnits year) value --> This will return 200 dollars. (dollar is a unit, 1000 * dollar creates the measure 1000 dollars. 2 * TimeUnits year create the measure 2 years). Another example of Evaluation in the financial domain InterestRate, NetPayment, GrossPayment, etc. (In physics Speed, Aceleration, etc. are good examples). Hernan. >"Dates can be seen from many different points of view. In a financial >system we are certainly not interested in the duration of a date. Not >in nanoseconds, not in milliseconds or even hours. A date is a business date." > >The class Chronos YearMonthDay is implemented just that way, for just >that reason. > >Thanks for your questions. I'll be adding the second example to the website. > >--Alan > >-----Original Message----- >From: [hidden email] >[mailto:[hidden email]] On Behalf Of >Francisco Garau >Sent: Friday, April 14, 2006 3:31 AM >To: The general-purpose Squeak developers list; Alan Lovejoy >Subject: Re: The Timing of Time > >Hi Alan, > >As yourself, I am also interested in date and times. I tried loading >the Chronos package following the instructions from your website [1], >but something went awry. > >I succesfully loaded: > 1- Passport-Kernel > 2- Passport-Squeak > 3- Chronos-System-Squeak > 4- Chronos-System-Squeak-PostV3.6 > >The problem happens on step 3. The last two lines of that fileOut says: > > ChronosSqueakEnvironment initialize ! > ChronosEnvironment canonical install ! > >I guess that ChronosEnvironment should be a class and canonical a message. >But neither of them are in the image. > >My interest on dates is more biased towards dates than towards times. >Dates, months, years and calendars are central objects in financial >Amongst the many problems that arises in such systems, here a couple of >examples: > >- Starting on the 31Mar2006 generate a schedule of payments every month >until 31Mar2007. >That should return 30Apr06 31May06 30Jun06 ... 28Feb07 31Mar07 > >- Adjust the previous schedule to the british and japanese calendar, >making sure all dates are 'good business days'. So, for example, if >30Apr06 falls on Sunday or a british bank holiday, change it according to >Examples of such rules are: >next business day, next calendar day, etc. > >It gets more complicated when you think about DCC (day count conventions). >In the first example we were dealing with actual months. But under the >30/360 DCC, every month has 30 days. > >Dates can be seen from many different points of view. In a financial >system we are certainly not interested in the duration of a date. Not >in nanoseconds, not in milliseconds or even hours. A date is a business > >I agree with the Mercap guys that dates, months and years are views of >the same time-line at different levels of granularity. In financial >systems we don't need to go further down that date. For other type of >systems requiring global syncronization, you probably need to go down >to the millisecond level. Furthermore, you need every time to be >expressed as an offset from a central location (Greenwich?). > >That is my poor understanding of time-zones and the reason why I want >to play with the Chronos package. > >Cheers, >Francisco > >[1] http://chronos-st.org/frames/Squeak-Downloads.html >[2] >http://article.gmane.org/gmane.comp.lang.smalltalk.squeak.general/10014 >8 > > > > > > > > -- ______________________________ Lic. Hernán A. Wilkinson Gerente de Desarrollo y Tecnología Mercap S.R.L. Tacuari 202 - 7mo Piso - Tel: 54-11-4878-1118 Buenos Aires - Argentina http://www.mercapsoftware.com --------------------------------------------------------------------- Este mensaje es confidencial. Puede contener informacion amparada por el secreto profesional. Si usted ha recibido este e-mail por error, por favor comuniquenoslo inmediatamente via e-mail y tenga la amabilidad de eliminarlo de su sistema; no debera copiar el mensaje ni divulgar su contenido a ninguna persona. Muchas gracias. This message is confidential. It may also contain information that is privileged or otherwise legally exempt from disclosure. If you have received it by mistake please let us know by e-mail immediately and delete it from your system; you should also not copy the message nor disclose its contents to anyone. Thanks. --------------------------------------------------------------------- |
In reply to this post by Alan L. Lovejoy
Hi Alan
Exxxcellllent!!! this sounds really exciting to me (may be I'm the only one :)) but this means that based on Passport we could built much easier "files" manipulation. Really cool. I will definitively look at it. Stef > Stéphane: "Does it mean that you have an abstraction over the ugly > FileDirectory and friends." > > Yes, Passport provides an abstraction layer over FileDirectory, in > three > different senses: > > 1. Like a VisualWorks Filename, a ResourcePath has behavior > appropriate for > handling file names as such, as opposed to String mangling. > > 2. ResourcePaths can also be used as URL objects--using the same > API as when > they represent "Filenames." Whether the String representation of a > ResourcePath looks like a host-platform filename string, or like a > File URL > (or like an HTTP URL) is a function of which Strategy object is > associated > with the instance. > > 3. ResourcePaths provide cross-platform portability, in two different > senses. Firstly, a single instance can represent the same relative > path on > any of Windows, UNIX, the classic MacOS or RiscOS. Absolute paths are > necessarily host-platform specific, although the platform-specific > part of > the path can be represented as mutable data in the ResourcePathContext > associated with each ResourcePath (the same ResourcePathContext can > be bound > to any number of ResourcePaths.) Secondly, Passport provides > portability of > the code that uses ResourcePaths to all Smalltalk environments to > which > Passport has been ported, which for now means VisualWorks and > Squeak--although the Dolphin port will be available soon. > > Stéphane: "So we could have this kind of behavior > File default recursivelyDo: [:each | where each would be a > resourcepath] ?" > > | handleFile handleDirectory | > handleFile := [:file | file extension = 'bak' ifTrue: [file delete]]. > handleDirectory := > [:directory | > directory contentsDo: > [:resourcePath | > resourcePath isDirectory > ifTrue: [handleDirectory value: > resourcePath] > ifFalse: [handleFile value: > resourcePath]]] > handleDirectory value: ResourcePath defaultDirectory > > -----Original Message----- > From: [hidden email] > [mailto:[hidden email]] On Behalf Of > stéphane > ducasse > Sent: Sunday, April 16, 2006 11:48 PM > To: The general-purpose Squeak developers list > Subject: Re: The Timing of Time > > HI alan > > this sounds really interesting. > Does it mean that you have an abstraction over the ugly > FileDirectory and > friends. > >> Passport provides the class ResourcePath, which is conceptually a >> union of a VisualWorks Filename with a URL object. ResourcePaths >> support HTTP URLs, File URLs and native filenames (in the latter >> case, >> using native filename syntax--Windows, Unix or Classic MacOS.) In >> VisualWorks, they also support FtpURLs and HttpsURLs (and it wouldn't >> be all that hard to do the same in >> Squeak.) Note that ResourcePaths can do all that without any >> subclasses--they use the Strategy pattern instead. > > So we could have this kind of behavior > File default recursivelyDo: [:each | where each would be a > resourcepath] ? > >> >> The Squeak implementation of Passport includes the classes >> HttpRequest and >> HttpResponse, which implement HTTP 1.1 with both client-side and >> server side >> functionality. You might find that to be of some interest, in view >> of the >> mess that is HTTPSocket. > > > > |
In reply to this post by Hernan Wilkinson
Hernan, Garau:
It seems that, if I just rely on memory instead of actually looking at what methods are available, I don't always use my own code in the optimal manner. It turns out the last-day-of-the-month payment schedule can be coded in Chronos thusly: (Timeperiod from: (YearMonthDay year: 2006 month: 4 day: 1) duration: (CalendarDuration years: 1)) every: (CalendarDuration months: 1) collect: [:month | month last] Or even: ((YearMonthDay year: 2006 month: 4 day: 1) withDuration: (CalendarDuration years: 1)) every: (CalendarDuration months: 1) collect: [:month | month last] In VW or Dolphin, "(CalendarDuration years: 1)" could instead be "1 years" and "(CalendarDuration months: 1)" could instead be "1 months". But not in Squeak, since I didn't add the equivalent convenience methods. I also see that, although Chronology has already defined most of the convenience methods using Chronology classes/methods, it does leave a few unclaimed--such as #years and #months. Yet another example of the dangers of relying on memory instead of fully checking :-) Also, I should have shown the protocol for adding "holiday" rules to a Chronos SemanticDatePolicy instance. The following code snippet is derived from the method that initializes the instance of SemanticDatePolicy answered by "SemanticDatePolicy unitedStates": inaugurationDayObservanceRule := (SemanticDateObservanceRule yearBase: 1 period: 4 "Occurrence function: occur(year) = year - 1 \\ 4 = 0" dayOfWeekPolicy: #(0 -1 0 0 0 0 0)) "Shift observance to Monday if nominally occurs on Sunday". semanticAnnualDate := SemanticAnnualDateRule semanticKey: #InaugurationDay effectiveYear: 1789 nominalAnnualDate: (DayOfMonth month: March day: 4) observanceRule: inaugurationDayObservanceRule. "US Federal Holiday." aSemanticDatePolicy addSemanticAnnualDateRule: semanticAnnualDate. semanticAnnualDate := SemanticAnnualDateRule semanticKey: #InaugurationDay effectiveYear: 1933 nominalAnnualDate: (DayOfMonth month: January day: 20) observanceRule: inaugurationDayObservanceRule. "US Federal Holiday--date changed by Consitutional Ammendment." aSemanticDatePolicy addSemanticAnnualDateRule: semanticAnnualDate. semanticAnnualDate := SemanticAnnualDateRule semanticKey: #MartinLutherKingDay "Honoring Dr. Martin Luther King--actual birthday January 15" effectiveYear: 1986 nominalAnnualDate: (WeekOfMonthDayOfWeek month: January week: 3 dayOfWeek: Monday) observanceRule: nil. "Always observed on the nominal day" "Established as a Federal legal holiday by Act of Congress in 1983 (signed into law by President Reagan in a Rose Garden ceremony in that year,) but was not observed until 1986-Jan-20." aSemanticDatePolicy addSemanticAnnualDateRule: semanticAnnualDate. semanticAnnualDate := SemanticAnnualDateRule semanticKey: #GroundhogDay effectiveYear: 1841 "Earliest attested observance." nominalAnnualDate: (DayOfMonth month: February day: 2) observanceRule: nil. "Always observed on the nominal day" "Normal business day." aSemanticDatePolicy addSemanticAnnualDateRule: semanticAnnualDate. The concept represented by a SemanticDatePolicy is more general than "holidays," which is why it's not named "HolidayPolicy." A SemanticDatePolicy's job is to compute when semantically-significant dates nominally occur, and when they will be officially observed. Which of those dates will be "holidays" (and for whom) is a matter left to application software to determine. The date of a national election is set by the national legislature; the date of a religious observance is set by custom and/or religious authorities; but whether such dates are company holidays is usually a policy decision unique to each company. Eventually, I would like to have the "semantic date occurrence rules" defined and accessed as reference data from persistent storage (as is already the case for time zone rules,) and not "hard coded" in the client image. The rules that determine what dates "semantically-significant dates" officially occur are subject to change, after all. Also, note the ability to handle rule changes diachronically, just like Chronos time zones. Chronos' SemanticDatePolicy and Chalten's TimeLineFilter have only partial functional overlap--and the possibility of useful synergy between the two seems high. I was intrigued by the semantics/behavior of the #negated message. Here's another example of what a SemanticDatePolicy can do. Execution of the example causes every date on which the NYSE was closed for the whole day (other than on weekends,) from 1969-04-01 through 1973-09-30, to be displayed on the Transcript: | list | list := SortedCollection sortBlock: [:a :b | a key < b key]. SemanticDatePolicy nyse observedEventOccurenceDatesFrom: (YearMonthDay year: 1969 month: 4 day: 1) through: (YearMonthDay year: 1973 month: 9 day: 30) do: [:semanticKey :date :observanceType | semanticKey == #weekend ifFalse: [list add: date->(Array with: semanticKey with: observanceType)]. Transcript cr. list do: [:assoc | Transcript cr; show: (assoc key printStringUsing: #rfc2822); show: ':'; tab. assoc value do: [:key | key == #nominal ifFalse: [key == #observed ifTrue: [Transcript show: ' ('; show: key; show: ')'] ifFalse: [Transcript show: key]]]]] Here's the output (with added commentary): Fri, 04 Apr 1969: GoodFriday Fri, 30 May 1969: MemorialDay Fri, 04 Jul 1969: IndependenceDay Mon, 21 Jul 1969: FirstLunarLanding -- Not all NYSE closures are "rule based." Betcha didn't know this one! Mon, 01 Sep 1969: LaborDay Thu, 27 Nov 1969: Thanksgiving Thu, 25 Dec 1969: Christmas Thu, 01 Jan 1970: NewYearsDay Mon, 23 Feb 1970: WashingtonsBirthday (observed) Fri, 27 Mar 1970: GoodFriday Fri, 29 May 1970: MemorialDay (observed) Fri, 03 Jul 1970: IndependenceDay (observed) Mon, 07 Sep 1970: LaborDay Thu, 26 Nov 1970: Thanksgiving Fri, 25 Dec 1970: Christmas Fri, 01 Jan 1971: NewYearsDay Mon, 15 Feb 1971: WashingtonsBirthday Fri, 09 Apr 1971: GoodFriday Mon, 31 May 1971: MemorialDay Mon, 05 Jul 1971: IndependenceDay (observed) Mon, 06 Sep 1971: LaborDay Thu, 25 Nov 1971: Thanksgiving Fri, 24 Dec 1971: Christmas (observed) Mon, 21 Feb 1972: WashingtonsBirthday Fri, 31 Mar 1972: GoodFriday Mon, 29 May 1972: MemorialDay Tue, 04 Jul 1972: IndependenceDay Mon, 04 Sep 1972: LaborDay Tue, 07 Nov 1972: ElectionDay Thu, 23 Nov 1972: Thanksgiving Mon, 25 Dec 1972: Christmas Thu, 28 Dec 1972: PresidentialFuneral-HarryTruman -- Yet another unique event Mon, 01 Jan 1973: NewYearsDay Thu, 25 Jan 1973: PresidentialFuneral-LyndonJohnson -- A bad time for former US Presidents... Mon, 19 Feb 1973: WashingtonsBirthday Fri, 20 Apr 1973: GoodFriday Mon, 28 May 1973: MemorialDay Wed, 04 Jul 1973: IndependenceDay Mon, 03 Sep 1973: LaborDay Why this functionality? Certain forms of "technical analysis" depend on precise counts of the number of trading days between dates--and writing technical analysis software is one of the use cases motivating the design/implementation of Chronos. You get quite a bit more than simple "dates and times" from Chronos. -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Hernan Wilkinson Sent: Monday, April 17, 2006 7:30 AM To: The general-purpose Squeak developers list Subject: Re: The Timing of Time Hi Alan, Francisco, we also created a model to deal with dates and time issues because of the same issues you and Brent mentioned. We uploaded last week to squeak source, it is named Chalten. Alan Lovejoy wrote: >Garau wrote: > >"- Starting on the 31Mar2006 generate a schedule of payments every >month until 31Mar2007. >That should return 30Apr06 31May06 30Jun06 ... 28Feb07 31Mar07" > >| schedule | >schedule := OrderedCollection new. >(Timeperiod from: (YearMonthDay year: 2006 month: 4 day: 1) duration: >(CalendarDuration years: 1 months: 0 days: 0)) > monthsDo: [:month | schedule add: month last]. >schedule => OrderedCollection (2006-04-30 2006-05-31 2006-06-30 >2006-07-31 >2006-08-31 2006-09-30 2006-10-31 2006-11-30 2006-12-31 2007-01-31 >2007-02-28 >2007-03-31) > > (April, 2006 to: March, 2007) collect: [ :aMonthOfYear | aMonthOfYear lastDate ] or: ((GregorianMonth april yearNumber: 2006) to: (GregorianMonth march yearNumber: 2007)) collect: [ :aMonthOfYear | aMonthOfYear lastDate ] >"- Adjust the previous schedule to the british and japanese calendar, >making sure all dates are 'good business days'. So, for example, if >30Apr06 falls on Sunday or a british bank holiday, change it according to some rule. >Examples of such rules are: >next business day, next calendar day, etc. > >It gets more complicated when you think about DCC (day count conventions). >In the first example we were dealing with actual months. But under the >30/360 DCC, every month has 30 days." > >Chronos doesn't currently support the Japanese Imperial Calendar. I >haven't actually looked at that one, so I don't know how easy or hard >it may be to implement. However, once implemented, adding new >calendars to Chronos is quite easy. > >SemanticDatePolicy instances can be used to define holiday schedules >using any combination of supported calendars. Extensible observance >rules are supported. US Holidays (including all rule-based and >one-time-only-historical NYSE holidays) are predefined; others must be >added by the programmer. > >So, modifying the first example to handle US banking holidays would >look like this: > >| sdp holidays schedule dateSelector | >sdp := SemanticDatePolicy unitedStates. >holidays := SemanticDatePolicy usFederalHolidaySemanticKeys. >schedule := OrderedCollection new. >dateSelector := > [:date | > date dayOfWeekKey == #Sunday > ifTrue: [dateSelector value: (date addingDays: 1)] > ifFalse: > [(date annualDateSemanticKeyFrom: sdp satisfies: >[:semanticKey | holidays includes: semanticKey]) > ifTrue: [dateSelector value: (date >addingDays: 1)] > ifFalse: [date]]]. >(Timeperiod from: (YearMonthDay year: 2006 month: 4 day: 1) duration: >(CalendarDuration years: 1 months: 0 days: 0)) > monthsDo: [:month | schedule add: (dateSelector value: month last)]. >schedule => OrderedCollection (2006-05-01 2006-05-31 2006-06-30 >2006-07-31 >2006-08-31 2006-09-30 2006-10-31 2006-11-30 2007-01-02 2007-01-31 >2007-02-28 >2007-03-31) > >The 30/360 DCC is trivial to implement, using CalendarDurations and >Timeperiods. > > problem are easy to solved. There is an abstraction called "TimeLineFilter" that allows you to filter the time line of any granularity and walk over the filtered time points. So, to get due working days, the code would be: (April, 2006 to: March, 2007) collect: [ :aMonthOfYear | MonthBasedDueDate for: aMonthOfYear lastDate in: britishWorkingDays ] With this code you will get all the due date in as working days of the british working calendar. The britishWorkingDays object is a TimeLineFilter, that can be created this way: britishNonWorkingDays := TimeLineFilter new. britisNonWorkingDays addDayRule: GregorianDay saturday; addDayRule: GregorianDay sunday; addDayOfMonthRule: December twentyFifth. britishWorkingDays := britishNonWorkingDays negated. As you can see, you first create a filter that includes the non working days (because they are less that the working days) and the you the the "negated" filter, that is the working days. About the day count conventions like 30/360, 30/365, Actual/Actual, etc. that are used to calculate the "real" interest rate to pay for an investment, we also have objects to deal with that but they are not part of Chalten because that is a pure financial problem. But to deal with them we use an abstraction that we have in Aconcagua (the measure's model that we opened too) called "Evaluation". An Evaluation is an object that has a meaning by itself but it is used in arithmetic operations. A good example of Evaluation is a class we called Interest. For example: (Interest simpleFor: 1000 * dollar with: (InterestRate yearlyOf: 1/10) during: 2 * TimeUnits year) value --> This will return 200 dollars. (dollar is a unit, 1000 * dollar creates the measure 1000 dollars. 2 * TimeUnits year create the measure 2 years). Another example of Evaluation in the financial domain InterestRate, NetPayment, GrossPayment, etc. (In physics Speed, Aceleration, etc. are good examples). Hernan. >"Dates can be seen from many different points of view. In a financial >system we are certainly not interested in the duration of a date. Not >in nanoseconds, not in milliseconds or even hours. A date is a business date." > >The class Chronos YearMonthDay is implemented just that way, for just >that reason. > >Thanks for your questions. I'll be adding the second example to the website. > >--Alan > >-----Original Message----- >From: [hidden email] >[mailto:[hidden email]] On Behalf Of >Francisco Garau >Sent: Friday, April 14, 2006 3:31 AM >To: The general-purpose Squeak developers list; Alan Lovejoy >Subject: Re: The Timing of Time > >Hi Alan, > >As yourself, I am also interested in date and times. I tried loading >the Chronos package following the instructions from your website [1], >but something went awry. > >I succesfully loaded: > 1- Passport-Kernel > 2- Passport-Squeak > 3- Chronos-System-Squeak > 4- Chronos-System-Squeak-PostV3.6 > >The problem happens on step 3. The last two lines of that fileOut says: > > ChronosSqueakEnvironment initialize ! > ChronosEnvironment canonical install ! > >I guess that ChronosEnvironment should be a class and canonical a message. >But neither of them are in the image. > >My interest on dates is more biased towards dates than towards times. >Dates, months, years and calendars are central objects in financial >Amongst the many problems that arises in such systems, here a couple of >examples: > >- Starting on the 31Mar2006 generate a schedule of payments every month >until 31Mar2007. >That should return 30Apr06 31May06 30Jun06 ... 28Feb07 31Mar07 > >- Adjust the previous schedule to the british and japanese calendar, >making sure all dates are 'good business days'. So, for example, if >30Apr06 falls on Sunday or a british bank holiday, change it according to >Examples of such rules are: >next business day, next calendar day, etc. > >It gets more complicated when you think about DCC (day count conventions). >In the first example we were dealing with actual months. But under the >30/360 DCC, every month has 30 days. > >Dates can be seen from many different points of view. In a financial >system we are certainly not interested in the duration of a date. Not >in nanoseconds, not in milliseconds or even hours. A date is a business > >I agree with the Mercap guys that dates, months and years are views of >the same time-line at different levels of granularity. In financial >systems we don't need to go further down that date. For other type of >systems requiring global syncronization, you probably need to go down >to the millisecond level. Furthermore, you need every time to be >expressed as an offset from a central location (Greenwich?). > >That is my poor understanding of time-zones and the reason why I want >to play with the Chronos package. > >Cheers, >Francisco > >[1] http://chronos-st.org/frames/Squeak-Downloads.html >[2] >http://article.gmane.org/gmane.comp.lang.smalltalk.squeak.general/10014 >8 > > > > > > > > -- ______________________________ Lic. Hernán A. Wilkinson Gerente de Desarrollo y Tecnología Mercap S.R.L. Tacuari 202 - 7mo Piso - Tel: 54-11-4878-1118 Buenos Aires - Argentina http://www.mercapsoftware.com --------------------------------------------------------------------- Este mensaje es confidencial. Puede contener informacion amparada por el secreto profesional. Si usted ha recibido este e-mail por error, por favor comuniquenoslo inmediatamente via e-mail y tenga la amabilidad de eliminarlo de su sistema; no debera copiar el mensaje ni divulgar su contenido a ninguna persona. Muchas gracias. This message is confidential. It may also contain information that is privileged or otherwise legally exempt from disclosure. If you have received it by mistake please let us know by e-mail immediately and delete it from your system; you should also not copy the message nor disclose its contents to anyone. Thanks. --------------------------------------------------------------------- |
In reply to this post by Alan L. Lovejoy
Hi Alan,
Thanks for the explanation. Could you summarize Chronos by saying: "Historic dates on a global timeline"? I don't understand why you need so many different calendars. For the example that I first posted (adjust a schedule to the japanese calendar), you suggested that the Japanese imperial calendar would need to be implemented. I would like to know what kind of applications are you dealing with, in which expressing the dates in the original calendar is important. For a financial application, the japanese calendar is just another gregorian calendar with certain dates defined as bank holidays. Keep loving the joy, Francisco ----- Original Message ----- From: "Alan Lovejoy" <[hidden email]> To: "'The general-purpose Squeak developers list'" <[hidden email]> Sent: Tuesday, April 18, 2006 7:12 AM Subject: RE: The Timing of Time > Hernan, Garau: > > It seems that, if I just rely on memory instead of actually looking at > what > methods are available, I don't always use my own code in the optimal > manner. > It turns out the last-day-of-the-month payment schedule can be coded in > Chronos thusly: > > (Timeperiod > from: (YearMonthDay year: 2006 month: 4 day: 1) > duration: (CalendarDuration years: 1)) > every: (CalendarDuration months: 1) collect: [:month | month > last] > > Or even: > > ((YearMonthDay year: 2006 month: 4 day: 1) withDuration: (CalendarDuration > years: 1)) > every: (CalendarDuration months: 1) collect: [:month | month last] > > In VW or Dolphin, "(CalendarDuration years: 1)" could instead be "1 years" > and "(CalendarDuration months: 1)" could instead be "1 months". But not > in > Squeak, since I didn't add the equivalent convenience methods. I also see > that, although Chronology has already defined most of the convenience > methods using Chronology classes/methods, it does leave a few > unclaimed--such as #years and #months. Yet another example of the dangers > of > relying on memory instead of fully checking :-) > > Also, I should have shown the protocol for adding "holiday" rules to a > Chronos SemanticDatePolicy instance. The following code snippet is > derived > from the method that initializes the instance of SemanticDatePolicy > answered > by "SemanticDatePolicy unitedStates": > > inaugurationDayObservanceRule := > (SemanticDateObservanceRule > yearBase: 1 > period: 4 "Occurrence function: occur(year) = year - > 1 \\ 4 = 0" > dayOfWeekPolicy: #(0 -1 0 0 0 0 0)) "Shift > observance to Monday if nominally occurs on Sunday". > semanticAnnualDate := > SemanticAnnualDateRule > semanticKey: #InaugurationDay > effectiveYear: 1789 > nominalAnnualDate: (DayOfMonth month: March day: 4) > observanceRule: inaugurationDayObservanceRule. > "US Federal Holiday." > aSemanticDatePolicy addSemanticAnnualDateRule: semanticAnnualDate. > > semanticAnnualDate := > SemanticAnnualDateRule > semanticKey: #InaugurationDay > effectiveYear: 1933 > nominalAnnualDate: (DayOfMonth month: January day: > 20) > observanceRule: inaugurationDayObservanceRule. > "US Federal Holiday--date changed by Consitutional Ammendment." > aSemanticDatePolicy addSemanticAnnualDateRule: semanticAnnualDate. > > semanticAnnualDate := > SemanticAnnualDateRule > semanticKey: #MartinLutherKingDay "Honoring Dr. > Martin Luther King--actual birthday January 15" > effectiveYear: 1986 > nominalAnnualDate: (WeekOfMonthDayOfWeek month: > January week: 3 dayOfWeek: Monday) > observanceRule: nil. "Always observed on the nominal > day" > "Established as a Federal legal holiday by Act of Congress in 1983 > (signed into law by President Reagan in a Rose Garden ceremony in that > year,) but was not observed until 1986-Jan-20." > aSemanticDatePolicy addSemanticAnnualDateRule: semanticAnnualDate. > > semanticAnnualDate := > SemanticAnnualDateRule > semanticKey: #GroundhogDay > effectiveYear: 1841 "Earliest attested observance." > nominalAnnualDate: (DayOfMonth month: February day: > 2) > observanceRule: nil. "Always observed on the nominal > day" > "Normal business day." > aSemanticDatePolicy addSemanticAnnualDateRule: semanticAnnualDate. > > The concept represented by a SemanticDatePolicy is more general than > "holidays," which is why it's not named "HolidayPolicy." A > SemanticDatePolicy's job is to compute when semantically-significant dates > nominally occur, and when they will be officially observed. Which of > those > dates will be "holidays" (and for whom) is a matter left to application > software to determine. The date of a national election is set by the > national legislature; the date of a religious observance is set by custom > and/or religious authorities; but whether such dates are company holidays > is > usually a policy decision unique to each company. > > Eventually, I would like to have the "semantic date occurrence rules" > defined and accessed as reference data from persistent storage (as is > already the case for time zone rules,) and not "hard coded" in the client > image. The rules that determine what dates "semantically-significant > dates" > officially occur are subject to change, after all. Also, note the ability > to > handle rule changes diachronically, just like Chronos time zones. > > Chronos' SemanticDatePolicy and Chalten's TimeLineFilter have only partial > functional overlap--and the possibility of useful synergy between the two > seems high. I was intrigued by the semantics/behavior of the #negated > message. > > Here's another example of what a SemanticDatePolicy can do. Execution of > the > example causes every date on which the NYSE was closed for the whole day > (other than on weekends,) from 1969-04-01 through 1973-09-30, to be > displayed on the Transcript: > > | list | > list := SortedCollection sortBlock: [:a :b | a key < b key]. > SemanticDatePolicy nyse > observedEventOccurenceDatesFrom: (YearMonthDay year: 1969 month: 4 > day: 1) > through: (YearMonthDay year: 1973 month: 9 day: 30) > do: [:semanticKey :date :observanceType | > semanticKey == #weekend > ifFalse: [list add: date->(Array with: semanticKey > with: observanceType)]. > Transcript cr. > list do: [:assoc | > Transcript cr; show: (assoc key printStringUsing: #rfc2822); show: > ':'; tab. > assoc value do: [:key | > key == #nominal > ifFalse: > [key == #observed > ifTrue: > [Transcript show: ' ('; > show: key; show: ')'] > ifFalse: [Transcript show: key]]]]] > > Here's the output (with added commentary): > > Fri, 04 Apr 1969: GoodFriday > Fri, 30 May 1969: MemorialDay > Fri, 04 Jul 1969: IndependenceDay > Mon, 21 Jul 1969: FirstLunarLanding -- Not all NYSE closures are "rule > based." Betcha didn't know this one! > Mon, 01 Sep 1969: LaborDay > Thu, 27 Nov 1969: Thanksgiving > Thu, 25 Dec 1969: Christmas > Thu, 01 Jan 1970: NewYearsDay > Mon, 23 Feb 1970: WashingtonsBirthday (observed) > Fri, 27 Mar 1970: GoodFriday > Fri, 29 May 1970: MemorialDay (observed) > Fri, 03 Jul 1970: IndependenceDay (observed) > Mon, 07 Sep 1970: LaborDay > Thu, 26 Nov 1970: Thanksgiving > Fri, 25 Dec 1970: Christmas > Fri, 01 Jan 1971: NewYearsDay > Mon, 15 Feb 1971: WashingtonsBirthday > Fri, 09 Apr 1971: GoodFriday > Mon, 31 May 1971: MemorialDay > Mon, 05 Jul 1971: IndependenceDay (observed) > Mon, 06 Sep 1971: LaborDay > Thu, 25 Nov 1971: Thanksgiving > Fri, 24 Dec 1971: Christmas (observed) > Mon, 21 Feb 1972: WashingtonsBirthday > Fri, 31 Mar 1972: GoodFriday > Mon, 29 May 1972: MemorialDay > Tue, 04 Jul 1972: IndependenceDay > Mon, 04 Sep 1972: LaborDay > Tue, 07 Nov 1972: ElectionDay > Thu, 23 Nov 1972: Thanksgiving > Mon, 25 Dec 1972: Christmas > Thu, 28 Dec 1972: PresidentialFuneral-HarryTruman -- Yet another > unique event > Mon, 01 Jan 1973: NewYearsDay > Thu, 25 Jan 1973: PresidentialFuneral-LyndonJohnson -- A bad time for > former US Presidents... > Mon, 19 Feb 1973: WashingtonsBirthday > Fri, 20 Apr 1973: GoodFriday > Mon, 28 May 1973: MemorialDay > Wed, 04 Jul 1973: IndependenceDay > Mon, 03 Sep 1973: LaborDay > > Why this functionality? Certain forms of "technical analysis" depend on > precise counts of the number of trading days between dates--and writing > technical analysis software is one of the use cases motivating the > design/implementation of Chronos. > > You get quite a bit more than simple "dates and times" from Chronos. > > -----Original Message----- > From: [hidden email] > [mailto:[hidden email]] On Behalf Of Hernan > Wilkinson > Sent: Monday, April 17, 2006 7:30 AM > To: The general-purpose Squeak developers list > Subject: Re: The Timing of Time > > Hi Alan, Francisco, > we also created a model to deal with dates and time issues because of > the same issues you and Brent mentioned. We uploaded last week to squeak > source, it is named Chalten. > Alan Lovejoy wrote: > >>Garau wrote: >> >>"- Starting on the 31Mar2006 generate a schedule of payments every >>month until 31Mar2007. >>That should return 30Apr06 31May06 30Jun06 ... 28Feb07 31Mar07" >> >>| schedule | >>schedule := OrderedCollection new. >>(Timeperiod from: (YearMonthDay year: 2006 month: 4 day: 1) duration: >>(CalendarDuration years: 1 months: 0 days: 0)) >> monthsDo: [:month | schedule add: month last]. >>schedule => OrderedCollection (2006-04-30 2006-05-31 2006-06-30 >>2006-07-31 >>2006-08-31 2006-09-30 2006-10-31 2006-11-30 2006-12-31 2007-01-31 >>2007-02-28 >>2007-03-31) >> >> > With Chalten, the code would be: > (April, 2006 to: March, 2007) collect: [ :aMonthOfYear | aMonthOfYear > lastDate ] > > or: > > ((GregorianMonth april yearNumber: 2006) to: (GregorianMonth march > yearNumber: 2007)) collect: [ :aMonthOfYear | aMonthOfYear lastDate ] > >>"- Adjust the previous schedule to the british and japanese calendar, >>making sure all dates are 'good business days'. So, for example, if >>30Apr06 falls on Sunday or a british bank holiday, change it according to > some rule. >>Examples of such rules are: >>next business day, next calendar day, etc. >> >>It gets more complicated when you think about DCC (day count conventions). >>In the first example we were dealing with actual months. But under the >>30/360 DCC, every month has 30 days." >> >>Chronos doesn't currently support the Japanese Imperial Calendar. I >>haven't actually looked at that one, so I don't know how easy or hard >>it may be to implement. However, once implemented, adding new >>calendars to Chronos is quite easy. >> >>SemanticDatePolicy instances can be used to define holiday schedules >>using any combination of supported calendars. Extensible observance >>rules are supported. US Holidays (including all rule-based and >>one-time-only-historical NYSE holidays) are predefined; others must be >>added by the programmer. >> >>So, modifying the first example to handle US banking holidays would >>look like this: >> >>| sdp holidays schedule dateSelector | >>sdp := SemanticDatePolicy unitedStates. >>holidays := SemanticDatePolicy usFederalHolidaySemanticKeys. >>schedule := OrderedCollection new. >>dateSelector := >> [:date | >> date dayOfWeekKey == #Sunday >> ifTrue: [dateSelector value: (date addingDays: 1)] >> ifFalse: >> [(date annualDateSemanticKeyFrom: sdp satisfies: >>[:semanticKey | holidays includes: semanticKey]) >> ifTrue: [dateSelector value: (date >>addingDays: 1)] >> ifFalse: [date]]]. >>(Timeperiod from: (YearMonthDay year: 2006 month: 4 day: 1) duration: >>(CalendarDuration years: 1 months: 0 days: 0)) >> monthsDo: [:month | schedule add: (dateSelector value: month last)]. >>schedule => OrderedCollection (2006-05-01 2006-05-31 2006-06-30 >>2006-07-31 >>2006-08-31 2006-09-30 2006-10-31 2006-11-30 2007-01-02 2007-01-31 >>2007-02-28 >>2007-03-31) >> >>The 30/360 DCC is trivial to implement, using CalendarDurations and >>Timeperiods. >> >> > Because we created Chalten to deal with financial software, this kind of > problem are easy to solved. > There is an abstraction called "TimeLineFilter" that allows you to filter > the time line of any granularity and walk over the filtered time points. > So, to get due working days, the code would be: > > (April, 2006 to: March, 2007) collect: [ :aMonthOfYear | MonthBasedDueDate > for: aMonthOfYear lastDate in: britishWorkingDays ] > > With this code you will get all the due date in as working days of the > british working calendar. > The britishWorkingDays object is a TimeLineFilter, that can be created > this > way: > > britishNonWorkingDays := TimeLineFilter new. > britisNonWorkingDays > addDayRule: GregorianDay saturday; > addDayRule: GregorianDay sunday; > addDayOfMonthRule: December twentyFifth. > britishWorkingDays := britishNonWorkingDays negated. > > As you can see, you first create a filter that includes the non working > days > (because they are less that the working days) and the you the the > "negated" > filter, that is the working days. > > About the day count conventions like 30/360, 30/365, Actual/Actual, etc. > that are used to calculate the "real" interest rate to pay for an > investment, we also have objects to deal with that but they are not part > of > Chalten because that is a pure financial problem. But to deal with them we > use an abstraction that we have in Aconcagua (the measure's model that we > opened too) called "Evaluation". An Evaluation is an object that has a > meaning by itself but it is used in arithmetic operations. A good example > of > Evaluation is a class we called Interest. > For example: > > (Interest simpleFor: 1000 * dollar with: (InterestRate yearlyOf: 1/10) > during: 2 * TimeUnits year) value --> This will return 200 dollars. > (dollar is a unit, 1000 * dollar creates the measure 1000 dollars. 2 * > TimeUnits year create the measure 2 years). > > Another example of Evaluation in the financial domain InterestRate, > NetPayment, GrossPayment, etc. (In physics Speed, Aceleration, etc. are > good > examples). > > Hernan. > >>"Dates can be seen from many different points of view. In a financial >>system we are certainly not interested in the duration of a date. Not >>in nanoseconds, not in milliseconds or even hours. A date is a business > date." >> >>The class Chronos YearMonthDay is implemented just that way, for just >>that reason. >> >>Thanks for your questions. I'll be adding the second example to the > website. >> >>--Alan >> >>-----Original Message----- >>From: [hidden email] >>[mailto:[hidden email]] On Behalf Of >>Francisco Garau >>Sent: Friday, April 14, 2006 3:31 AM >>To: The general-purpose Squeak developers list; Alan Lovejoy >>Subject: Re: The Timing of Time >> >>Hi Alan, >> >>As yourself, I am also interested in date and times. I tried loading >>the Chronos package following the instructions from your website [1], >>but something went awry. >> >>I succesfully loaded: >> 1- Passport-Kernel >> 2- Passport-Squeak >> 3- Chronos-System-Squeak >> 4- Chronos-System-Squeak-PostV3.6 >> >>The problem happens on step 3. The last two lines of that fileOut says: >> >> ChronosSqueakEnvironment initialize ! >> ChronosEnvironment canonical install ! >> >>I guess that ChronosEnvironment should be a class and canonical a message. >>But neither of them are in the image. >> >>My interest on dates is more biased towards dates than towards times. >>Dates, months, years and calendars are central objects in financial > systems. >>Amongst the many problems that arises in such systems, here a couple of >>examples: >> >>- Starting on the 31Mar2006 generate a schedule of payments every month >>until 31Mar2007. >>That should return 30Apr06 31May06 30Jun06 ... 28Feb07 31Mar07 >> >>- Adjust the previous schedule to the british and japanese calendar, >>making sure all dates are 'good business days'. So, for example, if >>30Apr06 falls on Sunday or a british bank holiday, change it according to > some rule. >>Examples of such rules are: >>next business day, next calendar day, etc. >> >>It gets more complicated when you think about DCC (day count conventions). >>In the first example we were dealing with actual months. But under the >>30/360 DCC, every month has 30 days. >> >>Dates can be seen from many different points of view. In a financial >>system we are certainly not interested in the duration of a date. Not >>in nanoseconds, not in milliseconds or even hours. A date is a business > date. >> >>I agree with the Mercap guys that dates, months and years are views of >>the same time-line at different levels of granularity. In financial >>systems we don't need to go further down that date. For other type of >>systems requiring global syncronization, you probably need to go down >>to the millisecond level. Furthermore, you need every time to be >>expressed as an offset from a central location (Greenwich?). >> >>That is my poor understanding of time-zones and the reason why I want >>to play with the Chronos package. >> >>Cheers, >>Francisco >> >>[1] http://chronos-st.org/frames/Squeak-Downloads.html >>[2] >>http://article.gmane.org/gmane.comp.lang.smalltalk.squeak.general/10014 >>8 >> >> >> >> >> >> >> >> > > > -- > ______________________________ > Lic. Hernán A. Wilkinson > Gerente de Desarrollo y Tecnología > Mercap S.R.L. > Tacuari 202 - 7mo Piso - Tel: 54-11-4878-1118 Buenos Aires - Argentina > http://www.mercapsoftware.com > --------------------------------------------------------------------- > Este mensaje es confidencial. Puede contener informacion amparada por el > secreto profesional. Si usted ha recibido este e-mail por error, por favor > comuniquenoslo inmediatamente via e-mail y tenga la amabilidad de > eliminarlo > de su sistema; no debera copiar el mensaje ni divulgar su contenido a > ninguna persona. Muchas gracias. > > This message is confidential. It may also contain information that is > privileged or otherwise legally exempt from disclosure. If you have > received > it by mistake please let us know by e-mail immediately and delete it from > your system; you should also not copy the message nor disclose its > contents > to anyone. Thanks. > --------------------------------------------------------------------- > > > > |
In reply to this post by stéphane ducasse-2
I just wanted to say that with Chalten we already have a Gregorian Calendar
implementation, with very interesting features (imho) as you can see from the examples. We also have some agenda to improve it, mainly becuase Maxi Taborda (he ported Chalten from VisualAge 6.02 to VA Smalltalk 7.0, VisualWorks and Squeak) is going to use it for his masters thesis. So you can expect many improvements on Chalten during this year. This improvements includes: 1) Performance improvements (he did not release some of the performance code we already have because of lack of time) 2) Time zone support 3) Other calendars support 4) Translation between time points of different calendars All this work will be done keeping what I think makes Chalten a good choice: 1) Good abstractions 2) Easy of use (i.e.: sentences like "January second, 2006", etc) 3) Use of the measure model Anyway, I don't want to sound as a "comercial" person, but we are going to improve Chalten in many ways and it is going to be ports on Squeak, VisualAge, VisualWorks, GemStone and Dolphin.... Hernan > HI brent > > what is your take on this? > > On 14 avr. 06, at 03:37, Alan Lovejoy wrote: > > > As an alternative, perhaps Brent (or someone else) would be > > interested in > > using the Chronos code as inspiration to refactor Chronology into > > "Chronos > > Lite"--a Gregorian-only, current-year's-zone-offset-transition- > > rules-only > > subset of the Chronos API, using the Chronos logic where and as > > appropriate > > to achieve the desired degree of functionality/performance? > > > > > |
In reply to this post by Alan L. Lovejoy
Mensaje citado por Alan Lovejoy <[hidden email]>:
> > Hernan: > > Can a TimeLineFilter handle rules such as "the day after the fourth Thursday > of November," "two days before Easter" or "Nisan 14 (Hebrew Calendar)"? Well, a TimeLineFilter is a "set defined by rules". That means that it includes all the objects its rules includes. We provided rules like DayRule (for a certain day, i.e. Sunday), DateRule (for a specific date, i.e. 24/03/06) or an Argentine rule that makes all third Mondays of August non working days. Chalten does not currently support Lunar Calendars that is needed to know when Easter is, but the idea is to add support to those calendars (the Hebrew too). A rule used by the TimeLineFilter only needs to implement the message #includes: aPointInTime, so it is easy to create those rules you ask. > What about one-of-a-kind non-business days, such as the closure of the NYSE > due to a Presidential Funeral? Yes, that is supported. That is very important in financial applications. All rules also can be constrained by a date interval, for example in Argentina a new holiday was created last March twentyfourth. Here is an example on how to add this new holiday to a TimeLineFilter: argentineNonWorkingDays addDayOfMonthRule: March twentyFourth from: (March twentyFourth, 2006) to: TheEndOfTime TheEndOfTime is an abstractions that allows you to handle not-ended time intervals. There is a TheBeginingOfTime object too. >A Chronos SemnticDatePolicy will handle rules > like that (and could easily be extended for even more comples cases.) > I guess is very similar to what we have. I have not have the chance to see Chronos in detail, just a quick look... > I like the syntax of the Domain-Specific Language you're developing. Thanks! we always try to have a good design in the models we create and we beleive it is very important for the model's language to be very close to the natural language. That makes the model easy to understand, use, etc. >There > might be some really good synergy achievable from implementing Chalten on > top of Chronos. I think that's a good idea... as I mention in a previous mail, Maxi Taborda will improve Chalten because it is part of the work he has to do with his master's thesis... I think we should find a way to create a GREAT time model joining forces from Chronos, Chronology and Chalten, taken the best of them (and kick other languages ass!!! sorry for the last word, I could not contain myself...) What do you think? If we can doit without taking too much time from us, I think we can came up with a good model. Hernan > > --Alan > > -----Original Message----- > From: [hidden email] > [mailto:[hidden email]] On Behalf Of Hernan > Wilkinson > Sent: Monday, April 17, 2006 7:30 AM > To: The general-purpose Squeak developers list > Subject: Re: The Timing of Time > > Hi Alan, Francisco, > we also created a model to deal with dates and time issues because of > the same issues you and Brent mentioned. We uploaded last week to squeak > source, it is named Chalten. > Alan Lovejoy wrote: > > >Garau wrote: > > > >"- Starting on the 31Mar2006 generate a schedule of payments every > >month until 31Mar2007. > >That should return 30Apr06 31May06 30Jun06 ... 28Feb07 31Mar07" > > > >| schedule | > >schedule := OrderedCollection new. > >(Timeperiod from: (YearMonthDay year: 2006 month: 4 day: 1) duration: > >(CalendarDuration years: 1 months: 0 days: 0)) > > monthsDo: [:month | schedule add: month last]. > >schedule => OrderedCollection (2006-04-30 2006-05-31 2006-06-30 > >2006-07-31 > >2006-08-31 2006-09-30 2006-10-31 2006-11-30 2006-12-31 2007-01-31 > >2007-02-28 > >2007-03-31) > > > > > With Chalten, the code would be: > (April, 2006 to: March, 2007) collect: [ :aMonthOfYear | aMonthOfYear > lastDate ] > > or: > > ((GregorianMonth april yearNumber: 2006) to: (GregorianMonth march > yearNumber: 2007)) collect: [ :aMonthOfYear | aMonthOfYear lastDate ] > > >"- Adjust the previous schedule to the british and japanese calendar, > >making sure all dates are 'good business days'. So, for example, if > >30Apr06 falls on Sunday or a british bank holiday, change it according to > some rule. > >Examples of such rules are: > >next business day, next calendar day, etc. > > > >It gets more complicated when you think about DCC (day count conventions). > >In the first example we were dealing with actual months. But under the > >30/360 DCC, every month has 30 days." > > > >Chronos doesn't currently support the Japanese Imperial Calendar. I > >haven't actually looked at that one, so I don't know how easy or hard > >it may be to implement. However, once implemented, adding new > >calendars to Chronos is quite easy. > > > >SemanticDatePolicy instances can be used to define holiday schedules > >using any combination of supported calendars. Extensible observance > >rules are supported. US Holidays (including all rule-based and > >one-time-only-historical NYSE holidays) are predefined; others must be > >added by the programmer. > > > >So, modifying the first example to handle US banking holidays would > >look like this: > > > >| sdp holidays schedule dateSelector | > >sdp := SemanticDatePolicy unitedStates. > >holidays := SemanticDatePolicy usFederalHolidaySemanticKeys. > >schedule := OrderedCollection new. > >dateSelector := > > [:date | > > date dayOfWeekKey == #Sunday > > ifTrue: [dateSelector value: (date addingDays: 1)] > > ifFalse: > > [(date annualDateSemanticKeyFrom: sdp satisfies: > >[:semanticKey | holidays includes: semanticKey]) > > ifTrue: [dateSelector value: (date > >addingDays: 1)] > > ifFalse: [date]]]. > >(Timeperiod from: (YearMonthDay year: 2006 month: 4 day: 1) duration: > >(CalendarDuration years: 1 months: 0 days: 0)) > > monthsDo: [:month | schedule add: (dateSelector value: month last)]. > >schedule => OrderedCollection (2006-05-01 2006-05-31 2006-06-30 > >2006-07-31 > >2006-08-31 2006-09-30 2006-10-31 2006-11-30 2007-01-02 2007-01-31 > >2007-02-28 > >2007-03-31) > > > >The 30/360 DCC is trivial to implement, using CalendarDurations and > >Timeperiods. > > > > > Because we created Chalten to deal with financial software, this kind of > problem are easy to solved. > There is an abstraction called "TimeLineFilter" that allows you to filter > the time line of any granularity and walk over the filtered time points. > So, to get due working days, the code would be: > > (April, 2006 to: March, 2007) collect: [ :aMonthOfYear | MonthBasedDueDate > for: aMonthOfYear lastDate in: britishWorkingDays ] > > With this code you will get all the due date in as working days of the > british working calendar. > The britishWorkingDays object is a TimeLineFilter, that can be created this > way: > > britishNonWorkingDays := TimeLineFilter new. > britisNonWorkingDays > addDayRule: GregorianDay saturday; > addDayRule: GregorianDay sunday; > addDayOfMonthRule: December twentyFifth. > britishWorkingDays := britishNonWorkingDays negated. > > As you can see, you first create a filter that includes the non working days > (because they are less that the working days) and the you the the "negated" > filter, that is the working days. > > About the day count conventions like 30/360, 30/365, Actual/Actual, etc. > that are used to calculate the "real" interest rate to pay for an > investment, we also have objects to deal with that but they are not part of > Chalten because that is a pure financial problem. But to deal with them we > use an abstraction that we have in Aconcagua (the measure's model that we > opened too) called "Evaluation". An Evaluation is an object that has a > meaning by itself but it is used in arithmetic operations. A good example of > Evaluation is a class we called Interest. > For example: > > (Interest simpleFor: 1000 * dollar with: (InterestRate yearlyOf: 1/10) > during: 2 * TimeUnits year) value --> This will return 200 dollars. > (dollar is a unit, 1000 * dollar creates the measure 1000 dollars. 2 * > TimeUnits year create the measure 2 years). > > Another example of Evaluation in the financial domain InterestRate, > NetPayment, GrossPayment, etc. (In physics Speed, Aceleration, etc. are good > examples). > > Hernan. > > >"Dates can be seen from many different points of view. In a financial > >system we are certainly not interested in the duration of a date. Not > >in nanoseconds, not in milliseconds or even hours. A date is a business > date." > > > >The class Chronos YearMonthDay is implemented just that way, for just > >that reason. > > > >Thanks for your questions. I'll be adding the second example to the > website. > > > >--Alan > > > >-----Original Message----- > >From: [hidden email] > >[mailto:[hidden email]] On Behalf Of > >Francisco Garau > >Sent: Friday, April 14, 2006 3:31 AM > >To: The general-purpose Squeak developers list; Alan Lovejoy > >Subject: Re: The Timing of Time > > > >Hi Alan, > > > >As yourself, I am also interested in date and times. I tried loading > >the Chronos package following the instructions from your website [1], > >but something went awry. > > > >I succesfully loaded: > > 1- Passport-Kernel > > 2- Passport-Squeak > > 3- Chronos-System-Squeak > > 4- Chronos-System-Squeak-PostV3.6 > > > >The problem happens on step 3. The last two lines of that fileOut says: > > > > ChronosSqueakEnvironment initialize ! > > ChronosEnvironment canonical install ! > > > >I guess that ChronosEnvironment should be a class and canonical a message. > >But neither of them are in the image. > > > >My interest on dates is more biased towards dates than towards times. > >Dates, months, years and calendars are central objects in financial > systems. > >Amongst the many problems that arises in such systems, here a couple of > >examples: > > > >- Starting on the 31Mar2006 generate a schedule of payments every month > >until 31Mar2007. > >That should return 30Apr06 31May06 30Jun06 ... 28Feb07 31Mar07 > > > >- Adjust the previous schedule to the british and japanese calendar, > >making sure all dates are 'good business days'. So, for example, if > >30Apr06 falls on Sunday or a british bank holiday, change it according to > some rule. > >Examples of such rules are: > >next business day, next calendar day, etc. > > > >It gets more complicated when you think about DCC (day count conventions). > >In the first example we were dealing with actual months. But under the > >30/360 DCC, every month has 30 days. > > > >Dates can be seen from many different points of view. In a financial > >system we are certainly not interested in the duration of a date. Not > >in nanoseconds, not in milliseconds or even hours. A date is a business > date. > > > >I agree with the Mercap guys that dates, months and years are views of > >the same time-line at different levels of granularity. In financial > >systems we don't need to go further down that date. For other type of > >systems requiring global syncronization, you probably need to go down > >to the millisecond level. Furthermore, you need every time to be > >expressed as an offset from a central location (Greenwich?). > > > >That is my poor understanding of time-zones and the reason why I want > >to play with the Chronos package. > > > >Cheers, > >Francisco > > > >[1] http://chronos-st.org/frames/Squeak-Downloads.html > >[2] > >http://article.gmane.org/gmane.comp.lang.smalltalk.squeak.general/10014 > >8 > > > > > > > > > > > > > > > > > > > -- > ______________________________ > Lic. Hernán A. Wilkinson > Gerente de Desarrollo y Tecnología > Mercap S.R.L. > Tacuari 202 - 7mo Piso - Tel: 54-11-4878-1118 Buenos Aires - Argentina > http://www.mercapsoftware.com > --------------------------------------------------------------------- > Este mensaje es confidencial. Puede contener informacion amparada por el > secreto profesional. Si usted ha recibido este e-mail por error, por favor > comuniquenoslo inmediatamente via e-mail y tenga la amabilidad de eliminarlo > de su sistema; no debera copiar el mensaje ni divulgar su contenido a > ninguna persona. Muchas gracias. > > This message is confidential. It may also contain information that is > privileged or otherwise legally exempt from disclosure. If you have received > it by mistake please let us know by e-mail immediately and delete it from > your system; you should also not copy the message nor disclose its contents > to anyone. Thanks. > --------------------------------------------------------------------- > > > > > |
In reply to this post by Alan L. Lovejoy
Mensaje citado por Alan Lovejoy <[hidden email]>:
> Hernan, Garau: > > It seems that, if I just rely on memory instead of actually looking at what > methods are available, I don't always use my own code in the optimal manner. > It turns out the last-day-of-the-month payment schedule can be coded in > Chronos thusly: > > (Timeperiod > from: (YearMonthDay year: 2006 month: 4 day: 1) > duration: (CalendarDuration years: 1)) > every: (CalendarDuration months: 1) collect: [:month | month > last] > > Or even: > > ((YearMonthDay year: 2006 month: 4 day: 1) withDuration: (CalendarDuration > years: 1)) > every: (CalendarDuration months: 1) collect: [:month | month last] > > In VW or Dolphin, "(CalendarDuration years: 1)" could instead be "1 years" > and "(CalendarDuration months: 1)" could instead be "1 months". We used to have those convenience methods too, but because we use the measure model (Aconcagua) those entities (1 year, 1 month, etc) are created like this: 1 * Year (or 1 * TimeUnits year) 1 * Month I like the idea of using a Measure to represent these objects, I think it closes an important gap all the programming languages have (but that is another issue...) > The concept represented by a SemanticDatePolicy is more general than > "holidays," which is why it's not named "HolidayPolicy." A > SemanticDatePolicy's job is to compute when semantically-significant dates > nominally occur, and when they will be officially observed. Which of those > dates will be "holidays" (and for whom) is a matter left to application > software to determine. The date of a national election is set by the > national legislature; the date of a religious observance is set by custom > and/or religious authorities; but whether such dates are company holidays is > usually a policy decision unique to each company. I agree, that is why we call the abstraction TimeLineFilter. You can have an instance of a TimeLineFilter to include holidays, working days, election days, wherever you want to filter. The user gives the final meaning to that object. > > Eventually, I would like to have the "semantic date occurrence rules" > defined and accessed as reference data from persistent storage (as is > already the case for time zone rules,) and not "hard coded" in the client > image. The rules that determine what dates "semantically-significant dates" > officially occur are subject to change, after all. Also, note the ability to > handle rule changes diachronically, just like Chronos time zones. I agree. In our application we use GemStone for persistance, so all TimeLineFilters are stored in GemStone and are subject to change. > > Chronos' SemanticDatePolicy and Chalten's TimeLineFilter have only partial > functional overlap--and the possibility of useful synergy between the two > seems high. I was intrigued by the semantics/behavior of the #negated > message. I agree with you, like I wrote in the previous mail. The semantics of the the negated message is better understood if you think a TimeLineFilter as a Set. Sending a #negated to a TimeLineFilter returns a new TimeLineFilter where objects that are not included in the original one, are included in the negated one. It is useful to handle working and non working days. The user defines the non working days, but he also gets the working days... [snip] > > Why this functionality? Certain forms of "technical analysis" depend on > precise counts of the number of trading days between dates--and writing > technical analysis software is one of the use cases motivating the > design/implementation of Chronos. > > You get quite a bit more than simple "dates and times" from Chronos. Cool! Hernan. > > -----Original Message----- > From: [hidden email] > [mailto:[hidden email]] On Behalf Of Hernan > Wilkinson > Sent: Monday, April 17, 2006 7:30 AM > To: The general-purpose Squeak developers list > Subject: Re: The Timing of Time > > Hi Alan, Francisco, > we also created a model to deal with dates and time issues because of > the same issues you and Brent mentioned. We uploaded last week to squeak > source, it is named Chalten. > Alan Lovejoy wrote: > > >Garau wrote: > > > >"- Starting on the 31Mar2006 generate a schedule of payments every > >month until 31Mar2007. > >That should return 30Apr06 31May06 30Jun06 ... 28Feb07 31Mar07" > > > >| schedule | > >schedule := OrderedCollection new. > >(Timeperiod from: (YearMonthDay year: 2006 month: 4 day: 1) duration: > >(CalendarDuration years: 1 months: 0 days: 0)) > > monthsDo: [:month | schedule add: month last]. > >schedule => OrderedCollection (2006-04-30 2006-05-31 2006-06-30 > >2006-07-31 > >2006-08-31 2006-09-30 2006-10-31 2006-11-30 2006-12-31 2007-01-31 > >2007-02-28 > >2007-03-31) > > > > > With Chalten, the code would be: > (April, 2006 to: March, 2007) collect: [ :aMonthOfYear | aMonthOfYear > lastDate ] > > or: > > ((GregorianMonth april yearNumber: 2006) to: (GregorianMonth march > yearNumber: 2007)) collect: [ :aMonthOfYear | aMonthOfYear lastDate ] > > >"- Adjust the previous schedule to the british and japanese calendar, > >making sure all dates are 'good business days'. So, for example, if > >30Apr06 falls on Sunday or a british bank holiday, change it according to > some rule. > >Examples of such rules are: > >next business day, next calendar day, etc. > > > >It gets more complicated when you think about DCC (day count conventions). > >In the first example we were dealing with actual months. But under the > >30/360 DCC, every month has 30 days." > > > >Chronos doesn't currently support the Japanese Imperial Calendar. I > >haven't actually looked at that one, so I don't know how easy or hard > >it may be to implement. However, once implemented, adding new > >calendars to Chronos is quite easy. > > > >SemanticDatePolicy instances can be used to define holiday schedules > >using any combination of supported calendars. Extensible observance > >rules are supported. US Holidays (including all rule-based and > >one-time-only-historical NYSE holidays) are predefined; others must be > >added by the programmer. > > > >So, modifying the first example to handle US banking holidays would > >look like this: > > > >| sdp holidays schedule dateSelector | > >sdp := SemanticDatePolicy unitedStates. > >holidays := SemanticDatePolicy usFederalHolidaySemanticKeys. > >schedule := OrderedCollection new. > >dateSelector := > > [:date | > > date dayOfWeekKey == #Sunday > > ifTrue: [dateSelector value: (date addingDays: 1)] > > ifFalse: > > [(date annualDateSemanticKeyFrom: sdp satisfies: > >[:semanticKey | holidays includes: semanticKey]) > > ifTrue: [dateSelector value: (date > >addingDays: 1)] > > ifFalse: [date]]]. > >(Timeperiod from: (YearMonthDay year: 2006 month: 4 day: 1) duration: > >(CalendarDuration years: 1 months: 0 days: 0)) > > monthsDo: [:month | schedule add: (dateSelector value: month last)]. > >schedule => OrderedCollection (2006-05-01 2006-05-31 2006-06-30 > >2006-07-31 > >2006-08-31 2006-09-30 2006-10-31 2006-11-30 2007-01-02 2007-01-31 > >2007-02-28 > >2007-03-31) > > > >The 30/360 DCC is trivial to implement, using CalendarDurations and > >Timeperiods. > > > > > Because we created Chalten to deal with financial software, this kind of > problem are easy to solved. > There is an abstraction called "TimeLineFilter" that allows you to filter > the time line of any granularity and walk over the filtered time points. > So, to get due working days, the code would be: > > (April, 2006 to: March, 2007) collect: [ :aMonthOfYear | MonthBasedDueDate > for: aMonthOfYear lastDate in: britishWorkingDays ] > > With this code you will get all the due date in as working days of the > british working calendar. > The britishWorkingDays object is a TimeLineFilter, that can be created this > way: > > britishNonWorkingDays := TimeLineFilter new. > britisNonWorkingDays > addDayRule: GregorianDay saturday; > addDayRule: GregorianDay sunday; > addDayOfMonthRule: December twentyFifth. > britishWorkingDays := britishNonWorkingDays negated. > > As you can see, you first create a filter that includes the non working days > (because they are less that the working days) and the you the the "negated" > filter, that is the working days. > > About the day count conventions like 30/360, 30/365, Actual/Actual, etc. > that are used to calculate the "real" interest rate to pay for an > investment, we also have objects to deal with that but they are not part of > Chalten because that is a pure financial problem. But to deal with them we > use an abstraction that we have in Aconcagua (the measure's model that we > opened too) called "Evaluation". An Evaluation is an object that has a > meaning by itself but it is used in arithmetic operations. A good example of > Evaluation is a class we called Interest. > For example: > > (Interest simpleFor: 1000 * dollar with: (InterestRate yearlyOf: 1/10) > during: 2 * TimeUnits year) value --> This will return 200 dollars. > (dollar is a unit, 1000 * dollar creates the measure 1000 dollars. 2 * > TimeUnits year create the measure 2 years). > > Another example of Evaluation in the financial domain InterestRate, > NetPayment, GrossPayment, etc. (In physics Speed, Aceleration, etc. are good > examples). > > Hernan. > > >"Dates can be seen from many different points of view. In a financial > >system we are certainly not interested in the duration of a date. Not > >in nanoseconds, not in milliseconds or even hours. A date is a business > date." > > > >The class Chronos YearMonthDay is implemented just that way, for just > >that reason. > > > >Thanks for your questions. I'll be adding the second example to the > website. > > > >--Alan > > > >-----Original Message----- > >From: [hidden email] > >[mailto:[hidden email]] On Behalf Of > >Francisco Garau > >Sent: Friday, April 14, 2006 3:31 AM > >To: The general-purpose Squeak developers list; Alan Lovejoy > >Subject: Re: The Timing of Time > > > >Hi Alan, > > > >As yourself, I am also interested in date and times. I tried loading > >the Chronos package following the instructions from your website [1], > >but something went awry. > > > >I succesfully loaded: > > 1- Passport-Kernel > > 2- Passport-Squeak > > 3- Chronos-System-Squeak > > 4- Chronos-System-Squeak-PostV3.6 > > > >The problem happens on step 3. The last two lines of that fileOut says: > > > > ChronosSqueakEnvironment initialize ! > > ChronosEnvironment canonical install ! > > > >I guess that ChronosEnvironment should be a class and canonical a message. > >But neither of them are in the image. > > > >My interest on dates is more biased towards dates than towards times. > >Dates, months, years and calendars are central objects in financial > systems. > >Amongst the many problems that arises in such systems, here a couple of > >examples: > > > >- Starting on the 31Mar2006 generate a schedule of payments every month > >until 31Mar2007. > >That should return 30Apr06 31May06 30Jun06 ... 28Feb07 31Mar07 > > > >- Adjust the previous schedule to the british and japanese calendar, > >making sure all dates are 'good business days'. So, for example, if > >30Apr06 falls on Sunday or a british bank holiday, change it according to > some rule. > >Examples of such rules are: > >next business day, next calendar day, etc. > > > >It gets more complicated when you think about DCC (day count conventions). > >In the first example we were dealing with actual months. But under the > >30/360 DCC, every month has 30 days. > > > >Dates can be seen from many different points of view. In a financial > >system we are certainly not interested in the duration of a date. Not > >in nanoseconds, not in milliseconds or even hours. A date is a business > date. > > > >I agree with the Mercap guys that dates, months and years are views of > >the same time-line at different levels of granularity. In financial > >systems we don't need to go further down that date. For other type of > >systems requiring global syncronization, you probably need to go down > >to the millisecond level. Furthermore, you need every time to be > >expressed as an offset from a central location (Greenwich?). > > > >That is my poor understanding of time-zones and the reason why I want > >to play with the Chronos package. > > > >Cheers, > >Francisco > > > >[1] http://chronos-st.org/frames/Squeak-Downloads.html > >[2] > >http://article.gmane.org/gmane.comp.lang.smalltalk.squeak.general/10014 > >8 > > > > > > > > > > > > > > > > > > > -- > ______________________________ > Lic. Hernán A. Wilkinson > Gerente de Desarrollo y Tecnología > Mercap S.R.L. > Tacuari 202 - 7mo Piso - Tel: 54-11-4878-1118 Buenos Aires - Argentina > http://www.mercapsoftware.com > --------------------------------------------------------------------- > Este mensaje es confidencial. Puede contener informacion amparada por el > secreto profesional. Si usted ha recibido este e-mail por error, por favor > comuniquenoslo inmediatamente via e-mail y tenga la amabilidad de eliminarlo > de su sistema; no debera copiar el mensaje ni divulgar su contenido a > ninguna persona. Muchas gracias. > > This message is confidential. It may also contain information that is > privileged or otherwise legally exempt from disclosure. If you have received > it by mistake please let us know by e-mail immediately and delete it from > your system; you should also not copy the message nor disclose its contents > to anyone. Thanks. > --------------------------------------------------------------------- > > > > > |
In reply to this post by stéphane ducasse-2
It is interesting to me 1) how much interest there is in dates and 2)
how apologetic people seem to be about it. Date is a basic abstraction. Getting it right is important, and so far we (the entire programming community) haven't gotten it right. Discussions like this are important. You guys ought to write papers on your Date packages. Someone ought to write a paper comparing them. Maybe Maxi Taborda is going to do this for his MS thesis? My favorite book on calenders (I haven't read very many) is "Calendrical Calculations" by Reingold and Dershowitz. It is about dates and not time. -Ralph Johnson |
Ralph: "Date is a basic abstraction. Getting it right is important, and so
far we (the entire programming community) haven't gotten it right." Yes, exactly so. And the issue is becoming more important, not less, due to the ever-shrinking "global village." How many decades remain before the issues become interplanetery, and not just international, is an interesting question to ponder (I've considered the implications of interplanetary travel for date/time software, but haven't put much effort or code into any solutions yet--that might be premature at this point.) When all is said and done, it's usually the case that a lot more has been said than done. That's one reason I implemented Chronos according to my best understanding of how dates/times ought to work, instead of attempting to socialize a consensus in the Smalltalk community for the design of a date/time library. A picture of herding cats comes to mind. Or a camel. Nevertheless, one can always learn from others. In fact, I would greatly appreciate feedback on the design/implementation/API of Chronos. I'm sure that Hernan, Brent and David T. would like feedback on their work also. Ralph: "You guys ought to write papers on your Date packages. Someone ought to write a paper comparing them." Ayup. In fact, I've decided to put a halt to coding Chronos and start writing documentation. John Dougan and I started to write a paper several months ago about the model of time on which the Chronos architecture, design and implementation rests, but we both got sidetracked on/by other matters. It's "time" to put the theoretical/philosophical discussion back on the front burner. As for comparisons of the alternatives on offer, that's a job best left to some independent analyst, I would think. --Alan -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Ralph Johnson Sent: Tuesday, April 18, 2006 5:38 PM To: The general-purpose Squeak developers list Subject: Re: The Timing of Time It is interesting to me 1) how much interest there is in dates and 2) how apologetic people seem to be about it. Date is a basic abstraction. Getting it right is important, and so far we (the entire programming community) haven't gotten it right. Discussions like this are important. You guys ought to write papers on your Date packages. Someone ought to write a paper comparing them. Maybe Maxi Taborda is going to do this for his MS thesis? My favorite book on calenders (I haven't read very many) is "Calendrical Calculations" by Reingold and Dershowitz. It is about dates and not time. -Ralph Johnson |
In reply to this post by Francisco Garau-2
Francisco: "Could you summarize Chronos by saying: `Historic dates on a
global timeline`?" That would be a partial summary. Chronos is intended to provide both a scientifically-correct, a legally-correct and a culturally-correct model of time, to provide the ability to represent values in the date/time domain (dates, times-of-day, timestamps, durations, temporal intervals, etc,) to provide useful operations and functions on values in the date/time domain, to conform to relevant standards and conventions (e.g., ANSI Smalltalk, ISO 8601, etc.,) and to satisfy the requirements of all relevant Use Cases. Most date/time implementations don't properly distinguish between "civil time" and "scientific time." Most don't provide duration objects, let alone properly distinguish between civil and scientific durations (and provide for both.) Most don't properly distinguish between nominal-time invariance and Universal-Time invariance. Most don't properly distinguish between a time zone and a time scale (and the majority don't even have any time zone support at all, let alone provide any support for multiple time scales.) Most don't support leap seconds. Most support only one calendrical system. Francisco: "I don't understand why you need so many different calendars. For the example that I first posted (adjust a schedule to the japanese calendar), you suggested that the Japanese imperial calendar would need to be implemented. I would like to know what kind of applications are you dealing with, in which expressing the dates in the original calendar is important. For a financial application, the japanese calendar is just another gregorian calendar with certain dates defined as bank holidays." In many coutries, the laws of the land at least occasionally are expressed in terms of some non-Gregorian calendar. In some cases, all the laws, and the courts, only use some non-Gregorian calendar. Some countries specify time zone offset transition dates using some non-Gregorian calendar. Some countries have legal holidays whose annual occurrence rules are specified in some non-Gregorian calendar. The whole population of some countries prefers to use some non-Gregorian calendar in their daily lives. Of course, you are correct that it is quite possible to convert dates from one calendar to another, and to simply use a list of such converted dates instead of an annual recurrence rule. However, using that approach changes a simple annual-date recurrence rule as expressed in one calendar (e.g., 15 Nisan) to either a very complex formula (try open coding the algorithm that converts 15 Nisan to a Gregorian date--just for a single year,) or to a list of dates that must a) be computed somehow, and then b) managed and accessed as reference data by applications that can't natively handle Hebrew dates. So, if you're quite happy to just use a list of Japanese holiday dates expressed as Gregorian dates that someone has computed for you, then there's no reason you couldn't just use a Chronos SemanticDatePolicy without having to implement a Chronos Calendar class for the Japanese Imperial Calendar. Of course, adding the British holiday recurrence rules, and adding(and managing updates to) the list of Japanese holidays as list of absolute (Gregorian) dates, would be the responsibility of your application, since Chronos only predefines the US rules for you. --Alan |
In reply to this post by Alan L. Lovejoy
Alan said:
"In fact, I would greatly appreciate feedback on the design/implementation/API of Chronos" For someone that just needs dates and times, I found that Chronos is somewhat bigger than needed. >From the implementation point of view, I found that the Calendar object is quite fat (lots of instance variables). This might not be a problem at all, but suffering from overgrown objects in my every day job, makes me suspicious... Calendar is not the only object with many instance variables. There are severeal others: LeapSecond, ChronosParser, ConfigurableChronosPrintPolicy, LeapSecondSchedule, TimeZoneAnnualTransitionPolicyFactory, ResourcePathContext. More detail in the attached files: ChronosCalendar shows the printString of the a calendar and ChronosHierarchy shows the whole class hierarchy (assuming all the Chronos classes inherit from StandarObject). But please, don't be offended by this feedback - after all, you asked for it! As Ralph Jonhson said, we need to keep discussing this issues. And as you said, we need keep improving our models - otherwise, everything is lost in the sea of words. Cheers, Francisco PD: I like your poetic nature. The title of this thread is irresistible ----- Original Message ----- From: "Alan Lovejoy" <[hidden email]> To: "'The general-purpose Squeak developers list'" <[hidden email]> Sent: Wednesday, April 19, 2006 2:51 AM Subject: RE: The Timing of Time > Ralph: "Date is a basic abstraction. Getting it right is important, and > so > far we (the entire programming community) haven't gotten it right." > > Yes, exactly so. And the issue is becoming more important, not less, due > to > the ever-shrinking "global village." How many decades remain before the > issues become interplanetery, and not just international, is an > interesting > question to ponder (I've considered the implications of interplanetary > travel for date/time software, but haven't put much effort or code into > any > solutions yet--that might be premature at this point.) > > When all is said and done, it's usually the case that a lot more has been > said than done. That's one reason I implemented Chronos according to my > best understanding of how dates/times ought to work, instead of attempting > to socialize a consensus in the Smalltalk community for the design of a > date/time library. A picture of herding cats comes to mind. Or a camel. > > Nevertheless, one can always learn from others. In fact, I would greatly > appreciate feedback on the design/implementation/API of Chronos. I'm sure > that Hernan, Brent and David T. would like feedback on their work also. > > Ralph: "You guys ought to write papers on your Date packages. Someone > ought > to write a paper comparing them." > > Ayup. In fact, I've decided to put a halt to coding Chronos and start > writing documentation. John Dougan and I started to write a paper several > months ago about the model of time on which the Chronos architecture, > design > and implementation rests, but we both got sidetracked on/by other matters. > > It's "time" to put the theoretical/philosophical discussion back on the > front burner. As for comparisons of the alternatives on offer, that's a > job > best left to some independent analyst, I would think. > > --Alan > > -----Original Message----- > From: [hidden email] > [mailto:[hidden email]] On Behalf Of Ralph > Johnson > Sent: Tuesday, April 18, 2006 5:38 PM > To: The general-purpose Squeak developers list > Subject: Re: The Timing of Time > > It is interesting to me 1) how much interest there is in dates and 2) how > apologetic people seem to be about it. Date is a basic abstraction. > Getting it right is important, and so far we (the entire programming > community) haven't gotten it right. Discussions like this are important. > You guys ought to write papers on your Date packages. > Someone ought to write a paper comparing them. > > Maybe Maxi Taborda is going to do this for his MS thesis? > > My favorite book on calenders (I haven't read very many) is "Calendrical > Calculations" by Reingold and Dershowitz. It is about dates and not time. > > -Ralph Johnson > > > |
Franciso,
Thanks for your feedback! Francisco: "For someone that just needs dates and times, I found that Chronos is somewhat bigger than needed." Chronos is intended as an industrial strength date/time library that "covers the space" and meets or exceeds the functionality provided by the competition. That that will be more than what many people need (or think they need) is a foregone conclusion. There are many classes/packages in Squeak (and also in VisualWorks) which provide far more functionality than I need (and in many cases, I have no need of the function at all.) Not everyone needs a station wagon, a truck or an SUV. Some wouldn't consider anything less than a Lambourghini, and others can only afford a Yugo. The good news is that Moore's Law is relentlessly reducing the relative "cost" of a fixed amount of memory, and Craig and others are working on better modularization mechanisms and technologies to mitigate (or even eliminate) the monolithic image problem. Then there's Java, which provides a lot less than what I need :-) Over time I am sure I will find ways to put Chronos on a diet, and to modularize it so that it's not a monolithic "all or nothing" choice. It's definitely an issue on my "to do" list. First make it run, then make it right, then make it fast, then refactor, ... Francisco: "suffering from overgrown objects in my every day job, makes me suspicious..." Understood. Don't think I didn't consider the matter. In fact, I was expecting someone to voice this concern eventually. There are three cases: 1) The instance variables hold "computed values" for performance reasons. In my considerable experience, having many such instance variables is not indicative of a design or architectural flaw--provided they actually enhance performance, and provided there isn't a much better implementation where they wouldn't be needed. Obviously, I'd love to discover a better implementation where instance variables could be removed without sacrificing performance. 2) The instance variables hold policy decisions (this especially applies to ChronosParser and ConfigurableChronosPrintPolicy.) Each policy decision requires a slot to hold it. The design issue is simply whether storing such policy decisions is well motivated. I believe the answer is yes in all cases. The whole point to the design strategy of ConfigurableChronosPrintPolicy (for example) was to provide a single class whose functionality could be specified and controlled by configurable state, as opposed to requiring a maze of subclasses. Flexible, configurable printing of date/time values requires many different, independent policy decisions. The architectural issue is whether or not it would be better to refactor ConfigurableChronosPrintPolicy (for example) into a set of classes, each responsible for a subset of the functionality of the original class. My opinion is that the added code complexity (and added conceptual complexity) would not be worth the "brownie points" of having fewer instance variables. Nor do I see any benefit to be gained by having a DatePrintPolicy class, a TimePrintPolicy class, a DurationPrintPolicy class, etc. The behavior does not need to vary independently--partly because the variation in behavior is in fact a function of the instance variable values, and not so much a function of the instance methods. And the multiple-class approach adds classes without actually eliminating the universe of instance variables (although it disperses some of the instance variables among the classes, most of the same instance variables would still all need to be together in an abstract superclass.) 3) In the cases of ResourcePathContext and TimeZoneAnnualTransitionPolicyFactory, there are 10 or fewer instance variables--and points 1 and/or 2 often apply as well. Note also that almost all Chronos classes inherit from Immutable, which defines the single instance variable "lock." This instance variable serves as a flag to indicate whether the instance is mutable, and so deserves to be considered (and counted) as a metalevel construct separate from the "base level" instance variables of its subclasses. Note also that it is not at all likely (and in some cases unbelievable) that there would be all that many instances of most of the classes you mentioned. There should only be one instance of each Calendar class, for example. Even TimeZoneAnnualTransitionPolicyFactory should never need more than a thousand instances, and more typically there should only be 1 or 2 at any one time. "Architecture is not inflexible dogma." --Alan -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Francisco Garau Sent: Tuesday, April 18, 2006 11:57 PM To: The general-purpose Squeak developers list Subject: Re: The Timing of Time Alan said: "In fact, I would greatly appreciate feedback on the design/implementation/API of Chronos" For someone that just needs dates and times, I found that Chronos is somewhat bigger than needed. >From the implementation point of view, I found that the Calendar object >is quite fat (lots of instance variables). This might not be a problem at all, but suffering from overgrown objects in my every day job, makes me suspicious... Calendar is not the only object with many instance variables. There are severeal others: LeapSecond, ChronosParser, ConfigurableChronosPrintPolicy, LeapSecondSchedule, TimeZoneAnnualTransitionPolicyFactory, ResourcePathContext. More detail in the attached files: ChronosCalendar shows the printString of the a calendar and ChronosHierarchy shows the whole class hierarchy (assuming all the Chronos classes inherit from StandarObject). But please, don't be offended by this feedback - after all, you asked for it! As Ralph Jonhson said, we need to keep discussing this issues. And as you said, we need keep improving our models - otherwise, everything is lost in the sea of words. Cheers, Francisco PD: I like your poetic nature. The title of this thread is irresistible ----- Original Message ----- From: "Alan Lovejoy" <[hidden email]> To: "'The general-purpose Squeak developers list'" <[hidden email]> Sent: Wednesday, April 19, 2006 2:51 AM Subject: RE: The Timing of Time > Ralph: "Date is a basic abstraction. Getting it right is important, and > so > far we (the entire programming community) haven't gotten it right." > > Yes, exactly so. And the issue is becoming more important, not less, due > to > the ever-shrinking "global village." How many decades remain before the > issues become interplanetery, and not just international, is an > interesting > question to ponder (I've considered the implications of interplanetary > travel for date/time software, but haven't put much effort or code into > any > solutions yet--that might be premature at this point.) > > When all is said and done, it's usually the case that a lot more has been > said than done. That's one reason I implemented Chronos according to my > best understanding of how dates/times ought to work, instead of attempting > to socialize a consensus in the Smalltalk community for the design of a > date/time library. A picture of herding cats comes to mind. Or a camel. > > Nevertheless, one can always learn from others. In fact, I would greatly > appreciate feedback on the design/implementation/API of Chronos. I'm sure > that Hernan, Brent and David T. would like feedback on their work also. > > Ralph: "You guys ought to write papers on your Date packages. Someone > ought > to write a paper comparing them." > > Ayup. In fact, I've decided to put a halt to coding Chronos and start > writing documentation. John Dougan and I started to write a paper several > months ago about the model of time on which the Chronos architecture, > design > and implementation rests, but we both got sidetracked on/by other matters. > > It's "time" to put the theoretical/philosophical discussion back on the > front burner. As for comparisons of the alternatives on offer, that's a > job > best left to some independent analyst, I would think. > > --Alan > > -----Original Message----- > From: [hidden email] > [mailto:[hidden email]] On Behalf Of Ralph > Johnson > Sent: Tuesday, April 18, 2006 5:38 PM > To: The general-purpose Squeak developers list > Subject: Re: The Timing of Time > > It is interesting to me 1) how much interest there is in dates and 2) how > apologetic people seem to be about it. Date is a basic abstraction. > Getting it right is important, and so far we (the entire programming > community) haven't gotten it right. Discussions like this are important. > You guys ought to write papers on your Date packages. > Someone ought to write a paper comparing them. > > Maybe Maxi Taborda is going to do this for his MS thesis? > > My favorite book on calenders (I haven't read very many) is "Calendrical > Calculations" by Reingold and Dershowitz. It is about dates and not time. > > -Ralph Johnson > > > |
In reply to this post by Ralph Johnson
Ralph.
I'm going to compare some of the date packages in my thesis because i need to investigate about the state of the art. You can read, in the paper written by Hernan for ESUG 2005, a comparison between three models: the abstractions of dates and times of Smalltalk 80, Chronology, and Chalten (although still it was not called thus). The paper also talk about models in other languages but does not make a comparison with Chronos. You can download it from: http://www.iam.unibe.ch/publikationen/techreports/2005/iam-05-001/file/at_download At this moment I am reading that book. It's very interesting. Maxi. Ralph Johnson escribió: > It is interesting to me 1) how much interest there is in dates and 2) > how apologetic people seem to be about it. Date is a basic > abstraction. Getting it right is important, and so far we (the entire > programming community) haven't gotten it right. Discussions like this > are important. You guys ought to write papers on your Date packages. > Someone ought to write a paper comparing them. > > Maybe Maxi Taborda is going to do this for his MS thesis? > > My favorite book on calenders (I haven't read very many) is > "Calendrical Calculations" by Reingold and Dershowitz. It is about > dates and not time. > > -Ralph Johnson > > > > |
we wrote a paper about Chalten last year and it was presented at ESUG. It has been publish also in the Elsevier "Computer, Languages, Systems and Structures" journal.... We compared our solution to the one used by Java and .Net... we also compared it to other more academic solutions. There is a pdf with the presentation we gave at ESUG at http://prog2.vub.ac.be/~cderoove/esugtalks/Wilkinson.pdf The paper's version publish at Elsevier has more info that the one presented at ESUG... We are using the book you mention as the main bibliography. Thanks for your comments! Hernan Maximiliano Taborda wrote: Ralph. -- ______________________________ Lic. Hernán A. Wilkinson Gerente de Desarrollo y Tecnología Mercap S.R.L. Tacuari 202 - 7mo Piso - Tel: 54-11-4878-1118 Buenos Aires - Argentina http://www.mercapsoftware.com --------------------------------------------------------------------- Este mensaje es confidencial. Puede contener informacion amparada por el secreto profesional. Si usted ha recibido este e-mail por error, por favor comuniquenoslo inmediatamente via e-mail y tenga la amabilidad de eliminarlo de su sistema; no debera copiar el mensaje ni divulgar su contenido a ninguna persona. Muchas gracias. This message is confidential. It may also contain information that is privileged or otherwise legally exempt from disclosure. If you have received it by mistake please let us know by e-mail immediately and delete it from your system; you should also not copy the message nor disclose its contents to anyone. Thanks. --------------------------------------------------------------------- |
In reply to this post by Alan L. Lovejoy
You should send a paper to ESUG!!!!
This way we will have the one of hernan and yours. Stef On 19 avr. 06, at 03:51, Alan Lovejoy wrote: > Ralph: "Date is a basic abstraction. Getting it right is > important, and so > far we (the entire programming community) haven't gotten it right." > > Yes, exactly so. And the issue is becoming more important, not > less, due to > the ever-shrinking "global village." How many decades remain > before the > issues become interplanetery, and not just international, is an > interesting > question to ponder (I've considered the implications of interplanetary > travel for date/time software, but haven't put much effort or code > into any > solutions yet--that might be premature at this point.) > > When all is said and done, it's usually the case that a lot more > has been > said than done. That's one reason I implemented Chronos according > to my > best understanding of how dates/times ought to work, instead of > attempting > to socialize a consensus in the Smalltalk community for the design > of a > date/time library. A picture of herding cats comes to mind. Or a > camel. > > Nevertheless, one can always learn from others. In fact, I would > greatly > appreciate feedback on the design/implementation/API of Chronos. > I'm sure > that Hernan, Brent and David T. would like feedback on their work > also. > > Ralph: "You guys ought to write papers on your Date packages. > Someone ought > to write a paper comparing them." > > Ayup. In fact, I've decided to put a halt to coding Chronos and start > writing documentation. John Dougan and I started to write a paper > several > months ago about the model of time on which the Chronos > architecture, design > and implementation rests, but we both got sidetracked on/by other > matters. > > It's "time" to put the theoretical/philosophical discussion back on > the > front burner. As for comparisons of the alternatives on offer, > that's a job > best left to some independent analyst, I would think. > > --Alan > > -----Original Message----- > From: [hidden email] > [mailto:[hidden email]] On Behalf Of > Ralph > Johnson > Sent: Tuesday, April 18, 2006 5:38 PM > To: The general-purpose Squeak developers list > Subject: Re: The Timing of Time > > It is interesting to me 1) how much interest there is in dates and > 2) how > apologetic people seem to be about it. Date is a basic abstraction. > Getting it right is important, and so far we (the entire programming > community) haven't gotten it right. Discussions like this are > important. > You guys ought to write papers on your Date packages. > Someone ought to write a paper comparing them. > > Maybe Maxi Taborda is going to do this for his MS thesis? > > My favorite book on calenders (I haven't read very many) is > "Calendrical > Calculations" by Reingold and Dershowitz. It is about dates and > not time. > > -Ralph Johnson > > > |
In reply to this post by Alan L. Lovejoy
I'm enjoying the discussion about calendars and times, but I'd like to
direct some attention to the idea of a TimeIndex. I came at this from another direction, thinking of a TimeSeries as data indexed by time, which leads to the idea of a TimeIndex. In my current implementation, a TimeIndex has two instance variables: a freq symbol (such as #weeklyMonday, #monthly, #hourly, etc.) and an integer period, which represents the number of periods elapsed since the base period for that freq. TimeIndex understands '+' and '-', so if 'z' is the weeklyMonday time index for April 17 2006, then (z - 4) asYmd yields 20060320, and so on. My TimeSeries class is a subclass of Matrix with an additional instance variable called 'start' which is a TimeIndex, and has accessors like TimeSeries>>atTimeIndex: TimeSeries>>atTimeIndex:put: TimeSeries>>atTimeIndex:column: TimeSeries>>atTimeIndex:column:put: I've found this scheme works pretty well, and will probably generalize it a bit more by making TimeIndex an abstract class with subclasses for different kinds of sequences. I think a package that wants to handle date and time issues should have something like a TimeIndex in it that allows sequences of various frequencies to be defined. At the same time, the implementation should be simple enough to be easily understood, and indexing into a TimeSeries should be very fast. If indexing isn't fast, we'll end up with ugly code in every TimeSeries method that that converts TimeIndex'es to row numbers and back. Trust me, you really don't want that. So how do these various packages handle indexing data by time? A second issue is how to handle date arithmetic. Some durations are based on linear time (e.g., weeks, seconds, hours, etc.) and others are based on the calendar (months, years, etc.). The distinction between these two leads to questions like: What should happen if you start at January 28'th and advance by a month and then go back by a month? Jan28 --> Feb28 --> (Jan 28 or Jan 31?) Can we agree on some conventions? Jeff Hallman |
Free forum by Nabble | Edit this page |