Re: r30398 - docs/Perl6/Spec/S32-setting-library

2010-04-21 Thread Moritz Lenz

Am 20.04.2010 16:59, schrieb Dave Rolsky:

On Fri, 16 Apr 2010, pugs-comm...@feather.perl6.nl wrote:


+=head2 Semi-internal methods
+
+[This section is severely conjectural]
+
+For efficient implementation of arithmetics on CDate objects, two more
+methods are exposed:
+
+ $d.daycount
+ Date.new-from-daycount(Int $daycount)


I'd _really_ like to see this be based on Rata Die, which is January 1,
0001. See http://en.wikipedia.org/wiki/Rata_Die


Your answer made it clear to me that people are not going to like the 
daycount (or day-count) accessor. I consciously did not specify an epoch 
on which daycount was based because I didn't want to force the 
implemntor's hand more than absolutely necessary.


Since number-of-days-relative-to-a-fixed-epoch is still available 
trivially as $date - $start-of-epoch I've now removed the daycount 
related methods.


Cheers,
Moritz


Re: r30398 - docs/Perl6/Spec/S32-setting-library

2010-04-20 Thread Dave Rolsky

On Fri, 16 Apr 2010, pugs-comm...@feather.perl6.nl wrote:


+=head2 Semi-internal methods
+
+[This section is severely conjectural]
+
+For efficient implementation of arithmetics on CDate objects, two more
+methods are exposed:
+
+$d.daycount
+Date.new-from-daycount(Int $daycount)


I'd _really_ like to see this be based on Rata Die, which is January 1, 
0001. See http://en.wikipedia.org/wiki/Rata_Die


This epoch value is used as the basis for many calendrical calculations in 
the Calendarical Calculations book, and has in turn been used as the 
method for calendar conversion in the Perl 5 DateTime sweet.


Exposing this value explicitly (rata-die-day-count) would be a wise 
decision, IMO.


Also, day-count, not daycount ;)


-dave

/*
http://VegGuide.org   http://blog.urth.org
Your guide to all that's veg  House Absolute(ly Pointless)
*/


Re: r30398 - docs/Perl6/Spec/S32-setting-library

2010-04-20 Thread Mark J. Reed
On Tue, Apr 20, 2010 at 10:59 AM, Dave Rolsky auta...@urth.org wrote:

 I'd _really_ like to see this be based on Rata Die, which is January 1,
 0001. See http://en.wikipedia.org/wiki/Rata_Die


To be clear, that's specifically January 1, 1 CE in the retrojected
Gregorian calendar, which is the same day as January 1, 3 CE in the
retrojected Julian calendar; noon UTC began Julian Day 1,721,426.

You could also use the JD directly, but there's a subtle design decision
lurking there. The JD is tied to UTC, and refers to a specific 24-hour
period that is the same across the planet: JD 2,455,307 began 4 hours and 45
minutes ago as I write this, and will be over in 19 hours and 15 minutes,
and that is a universal fact no matter whether it's currently Tuesday the
20th or already Wednesday the 21st where you are.   An RD, in contrast, is
not tied to a specific time zone, but is simply a numerical way to represent
exactly the same concept as the date: whatever the Gregorian date April 20,
2010 means, RD 733,882 means the same thing.  So on some parts of the
planet its RD 733,882 and in others it's already RD 733,883.

The RD is thus a better fit for the Date class, which is a representation of
an abstract date, unanchored in spacetime.  An integral JD number may be
used to fit the same bill, but opens the possibility of confusion with the
more typical anchored JD values (which might even be available from DateTime
objects).

The difference between them, or with any other epoch choice, is mostly just
a matter of a constant which can be added or subtracted as needed, and to
the degree that's true this is just bikeshed painting.   But the part that
isn't is important:

I don't want to dilute what I see as the primary benefit of a Date object
over a DateTime object that simply has its time fields zeroed, which is
flexibility.  The latter is still by implication tied to a specific swath of
spacetime (e.g. midnight to midnight in some time zone), whereas the former
is free to refer to whatever the human date designation can.

-- 
Mark J. Reed markjr...@gmail.com


r30398 - docs/Perl6/Spec/S32-setting-library

2010-04-16 Thread pugs-commits
Author: moritz
Date: 2010-04-16 22:40:37 +0200 (Fri, 16 Apr 2010)
New Revision: 30398

Modified:
   docs/Perl6/Spec/S32-setting-library/Temporal.pod
Log:
[S32/Temporal] spec Date type

This is heavily inspired by Date::Simple on CPAN, and mostly implemented
at http://github.com/moritz/Date/ as an external module, that currently works
fine with Rakudo (but is really compiler agnostic).

Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod
===
--- docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-04-16 15:47:23 UTC 
(rev 30397)
+++ docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-04-16 20:40:37 UTC 
(rev 30398)
@@ -8,6 +8,7 @@
 
 Carl Mäsak cma...@gmail.com
 Martin Berends mbere...@autoexec.demon.nl
+Moritz Lenz mor...@faui2k3.org
 (and others named in FOOTNOTE at bottom)
 
 =head1 VERSION
@@ -74,6 +75,11 @@
 This has the same effect as doing CDateTime.now().truncate('day'); see
 'Set methods' below.
 
+Or if you want to extract the date as a CDate object (see below),
+you can use simple type coercion:
+
+my $today = $datetime.Date;
+
 General dates can be specified through the Cnew constructor:
 
 my $moonlanding = DateTime.new( :year(1969), :month(7), :day(16),
@@ -195,6 +201,62 @@
 Monday of the week in which it occurs, and the time components are all
 set to 0.
 
+=head1 Date
+
+CDate objects represent a day without a time component, and allow easier
+manipulation by assuming that integers always mean days.
+
+Days, Months and days of week are 1-based.
+
+=head2 Constructors
+
+Date.today();   # today's date
+Date.new('2010-12-24'); # -MM-DD format
+Date.new(:year(2010), :month(12), :day(24));
+Date.new(2010, 12, 24);
+
+The constructors die with a helpful error message if month or day are out of
+range.
+
+=head2 Accessors
+
+The following accessors are pretty obvious, and are defined by example only.
+See the test suite for more formal definitions.
+
+my $d = Date.new('2010-12-24');
+$d.year # 2010
+$d.month# 12
+$d.day  # 24
+$d.day-of-week  # 5 # Friday
+$d.is-leap-year # Bool::False
+$d.days-in-month# 31
+$d.Str  # '2010-12-24'
+
+=head2 Arithmetics
+
+$d.succ # Date.new('2010-12-25')
+$d.pred # Date.new('2010-12-23')
+$d - Date.new('1984-03-02') # 9793  # (difference in days)
+$d - 42 # Date.new('2010-11-12')
+$d + 3  # Date.new('2010-12-27')
+3  + $d # Date.new('2010-12-27')
+
+=head2 Semi-internal methods
+
+[This section is severely conjectural]
+
+For efficient implementation of arithmetics on CDate objects, two more
+methods are exposed:
+
+$d.daycount
+Date.new-from-daycount(Int $daycount)
+
+The Cdaycount method returns the difference of number of days between the
+current object and an arbitrary start of epoch. This epoch is arbitrary and
+implementation dependent, and is even allowed to change between invocations of
+the same program. The Cnew-from-daycount constructor creates a new CDate
+object with a given daycount.
+
 =head1 Additions
 
 Please post errors and feedback to Cperl6-language. If you are making



r30398 - docs/Perl6/Spec/S32-setting-library

2010-04-16 Thread Mark J. Reed
I would only add that I think the DateTime constructor should accept a
Date object:

my $bday = new Date.new(1968, 5, 5);
my $specifically = DateTime.new(:date($bday), :hour(20), :minute(47));

or at least, Date should have a method that returns it's value as
pairs suitable for passing to DateTime.new.

On Friday, April 16, 2010,  pugs-comm...@feather.perl6.nl wrote:
 Author: moritz
 Date: 2010-04-16 22:40:37 +0200 (Fri, 16 Apr 2010)
 New Revision: 30398

 Modified:
    docs/Perl6/Spec/S32-setting-library/Temporal.pod
 Log:
 [S32/Temporal] spec Date type

 This is heavily inspired by Date::Simple on CPAN, and mostly implemented
 at http://github.com/moritz/Date/ as an external module, that currently works
 fine with Rakudo (but is really compiler agnostic).

 Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod
 ===
 --- docs/Perl6/Spec/S32-setting-library/Temporal.pod    2010-04-16 15:47:23 
 UTC (rev 30397)
 +++ docs/Perl6/Spec/S32-setting-library/Temporal.pod    2010-04-16 20:40:37 
 UTC (rev 30398)
 @@ -8,6 +8,7 @@

      Carl Mäsak cma...@gmail.com
      Martin Berends mbere...@autoexec.demon.nl
 +    Moritz Lenz mor...@faui2k3.org
      (and others named in FOOTNOTE at bottom)

  =head1 VERSION
 @@ -74,6 +75,11 @@
  This has the same effect as doing CDateTime.now().truncate('day'); see
  'Set methods' below.

 +Or if you want to extract the date as a CDate object (see below),
 +you can use simple type coercion:
 +
 +    my $today = $datetime.Date;
 +
  General dates can be specified through the Cnew constructor:

      my $moonlanding = DateTime.new( :year(1969), :month(7), :day(16),
 @@ -195,6 +201,62 @@
  Monday of the week in which it occurs, and the time components are all
  set to 0.

 +=head1 Date
 +
 +CDate objects represent a day without a time component, and allow easier
 +manipulation by assuming that integers always mean days.
 +
 +Days, Months and days of week are 1-based.
 +
 +=head2 Constructors
 +
 +    Date.today();               # today's date
 +    Date.new('2010-12-24');     # -MM-DD format
 +    Date.new(:year(2010), :month(12), :day(24));
 +    Date.new(2010, 12, 24);
 +
 +The constructors die with a helpful error message if month or day are out of
 +range.
 +
 +=head2 Accessors
 +
 +The following accessors are pretty obvious, and are defined by example only.
 +See the test suite for more formal definitions.
 +
 +    my $d = Date.new('2010-12-24');
 +    $d.year             # 2010
 +    $d.month            # 12
 +    $d.day              # 24
 +    $d.day-of-week      # 5     # Friday
 +    $d.is-leap-year     # Bool::False
 +    $d.days-in-month    # 31
 +    $d.Str              # '2010-12-24'
 +
 +=head2 Arithmetics
 +
 +    $d.succ                     # Date.new('2010-12-25')
 +    $d.pred                     # Date.new('2010-12-23')
 +    $d - Date.new('1984-03-02') # 9793      # (difference in days)
 +    $d - 42                     # Date.new('2010-11-12')
 +    $d + 3                      # Date.new('2010-12-27')
 +    3  + $d                     # Date.new('2010-12-27')
 +
 +=head2 Semi-internal methods
 +
 +[This section is severely conjectural]
 +
 +For efficient implementation of arithmetics on CDate objects, two more
 +methods are exposed:
 +
 +    $d.daycount
 +    Date.new-from-daycount(Int $daycount)
 +
 +The Cdaycount method returns the difference of number of days between the
 +current object and an arbitrary start of epoch. This epoch is arbitrary and
 +implementation dependent, and is even allowed to change between invocations 
 of
 +the same program. The Cnew-from-daycount constructor creates a new CDate
 +object with a given daycount.
 +
  =head1 Additions

  Please post errors and feedback to Cperl6-language. If you are making




-- 
Mark J. Reed markjr...@gmail.com


Re: r30398 - docs/Perl6/Spec/S32-setting-library

2010-04-16 Thread Mark J. Reed


On Friday, April 16, 2010, Mark J. Reed markjr...@gmail.com wrote:
 or at least, Date should have a method that returns it's value as
 pairs suitable for passing to DateTime.new.

Obviously that should be its value.  Thank you, iPhone, for thinking
you know better than I how to punctuate. :)


-- 
Mark J. Reed markjr...@gmail.com