[phobos] std.gregorian [was phobos commit, revision 1919]

Lars Tandle Kyllingstad lars at kyllingen.net
Wed Aug 25 09:34:10 PDT 2010

I've had the chance to look at your date lib now, and (without being
anywhere near an expert on the matter) I think it seems rather good.

Some comments:

1. I'm not sure I agree that DayOfWeek should be a named enum.
Personally, I'd prefer if the weekdays were enumerated like the months,

  alias int DayOfWeek;
  enum : DayOfWeek { Monday, Tuesday, ... }

That way you can get rid of the DOW alias.  In general, I'm not fond of
aliases that are just abbreviations, so I suggest removing WeekNo as
well. ;)

2. The month enum should have the Month type, I guess?

  enum : Month { January, February, ... }

3. I found it rather strange that the doc comment says that
DatePeriod.last() returns the day *after* the period, while
DatePeriod.end() is the last day of the period.  I checked
boost::date_time, and indeed it seems you've switched the two -- at
least in the documentation.

4. The doc comments need a bit of cleaning up.  Examples:
  - There should be some ///ditto comments for the Month,
    Day, and DayOfYear types.
  - The docs for DateRange.this() refer to WeekRange.
  - The docs for Date.toIso8601() mention IsoFormat.Normal,
    rather than IsoFormat.Basic.

5. Is there any reason why you define the trivial opEquals() for
DateCount?  I think the compiler takes care of that for you.

I'm looking forward to seeing the time stuff as well!


On Tue, 2010-08-24 at 22:32 -0500, Yao G. wrote:
> 2010/8/24 SHOO <zan77137 at nifty.com>:
> > [snip]
> >
> > In particular, std.gregorian seem to be still insufficient about  
> > functions
> > and designs.
> > I think waiting for other modules to mature then to unify is good.
> >
> > [snip]
> I did an almost complete implementation of std.gregorian and posted about  
> this on the news group. But it seems that nobody was interested  :D
> Here's the code: http://ideone.com/uyuZ9
> And the original post:  
> http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=115980
> Obviously the code can be improved. I was in a haste (I needed this for a  
> small project I'm working on). But maybe something from this  
> implementation can be used to improve the original gregorian.
> --
> Yao G.
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos

More information about the phobos mailing list