Author: wayland Date: 2009-02-19 05:08:23 +0100 (Thu, 19 Feb 2009) New Revision: 25403
Modified: docs/Perl6/Spec/S16-io.pod docs/Perl6/Spec/S29-functions.pod docs/Perl6/Spec/S32-setting-library/Any.pod docs/Perl6/Spec/S32-setting-library/Containers.pod docs/Perl6/Spec/S32-setting-library/IO.pod docs/Perl6/Spec/S32-setting-library/Numeric.pod docs/Perl6/Spec/S32-setting-library/Scalar.pod docs/Perl6/Spec/S32-setting-library/String.pod docs/Perl6/Spec/S32-setting-library/Temporal.pod Log: S16/S32: Moved Temporal and Tree stuff from S16 to S32 S29: Added myself, because of last update Modified: docs/Perl6/Spec/S16-io.pod =================================================================== --- docs/Perl6/Spec/S16-io.pod 2009-02-19 03:46:06 UTC (rev 25402) +++ docs/Perl6/Spec/S16-io.pod 2009-02-19 04:08:23 UTC (rev 25403) @@ -13,8 +13,8 @@ Tim Nelson <wayl...@wayland.id.au> Daniel Ruoso <dan...@ruoso.com> Date: 12 Sep 2006 - Last Modified: 14 Feb 2009 - Version: 19 + Last Modified: 19 Feb 2009 + Version: 20 This is a draft document. Many of these functions will work as in Perl 5, except we're trying to rationalize everything into roles. For @@ -379,237 +379,8 @@ =back -=head2 Tree Roles and Classes - -To support the filesystem, it is also useful to define some generic tree roles, which -could equally well be used for XML or LDAP as well as filesystem representation. However, -while the roles are generic, the comments and documentation in this section refers -specifically to filesystems. - -=head3 Tree::Name - - class Tree::Name { - has $.namespace; - has $.prefix; - - # Call this for stringifying - method fullname() - } - - fullname for XML does "$namespace:$prefix" - -=head3 Tree::Node - -This should be an ancestor role to filesystems, their elements, their attributes, and the -like. - - role Tree::Node does Array { - has Tree::Name $.name; # would usually be File or Directory on a filesystem - has $.ownerNode; # This is the IO::FileSystem - has $.rootNode; This is the root of the entire tree - has $.parent; # linked with @parents[0] (see below) - has @.parents; # Tree::Node array - has @.children handles <Array List Container>; # This is all the child notes - has $.path is ro; # Accessor does a getpath - has $.depth is ro; # depth from $ownerNode - - method infix:<===>(...) - method infix:<==>(...) - multi method *infix:</>(Tree::Node @nodes: Matcher $test); - multi method postfix:<//>(Tree::Node @parents: Matcher $test); - method path(Str $.quitcriteria); # This allows the path call to quit eg. when it - # gets to the filesystem root, instead of the overall root - } - -Array operations on this are entirely capable of moving files and directories, - -=head3 Tree - - role Tree does Tree::Node { - has Tree::Node $root; # The root directory - has Tree::Node $cwn; # The current working directory (node) - has Bool $can_multiple_parent; # Nodes can have multiple parents - has Bool $can_link; # Unix links, Windows shortcuts, etc - } - -=head3 Tree::Element - - role Tree::Element does Tree::Node { - has %.attributes; # This is all the attributes, including Name - has Str $!defaultattributename; - method postcircumfix:<{ }>($selector, $node(s)); # Accesses stuff in %attributes - method pathelement(); - } - -=head3 Tree::Attribute - - role Tree::Attribute does Tree::Node { - has $.value; - - method pathelement(); - } - -=head2 Time and Date roles - -=head3 Date - -You probably want to use the DateTime object instead. - -role Date { - has Calendar $.calendar; # Gregorian, Secular, Julian, etc - has NumberName $.year; - has NumberName $.month; - has NumberName $.dayofmonth; - has NumberName $.dayofweek; - has NumberName $.dayofyear; - has NumberName $.dayofquarter; - has NumberName $.quarter; - has NumberName $.era; # 'Common', 'Christian', etc - has Str $.defaultformat; - - method toString($format); - method isLeapYear(); - - multi method DateTime infix:<+>(Date $self, Time $other); - multi method DateTime infix:<+>(Date $self, Duration $other); - - multi method infix:{'<=>'}(Date $self, Date $other); - multi method infix:{'<=>'}(Date $self, Duration $other); - - method get(Str $type, Str $of); - method last(Str $type, Str $of); -} - -Example: - -$date = new Date('2002/01/01'); -$date.month.name(); # January -$date.month.name('short'); # Jan -$date.get('day', of => 'year'); - -$date = new Date('2002/01/01'); -$date.convertcalendar('Chinese'); -$date.year.name(); # Snake - -A fair bit of initialisation of the NumberNames for day of the week and month will need to -be done. - -$format will naturally need to allow for eras. - -=over - -=item - - method toString($format = 'YYYY/MM/DD'); - -$format contains things like YYYY/MM/DD or whatever. - -=back - -=head3 Time - -You probably want to use the DateTime object instead. - -role Time { - has $.hour; - has $.minute; - has $.second; - - method toString($format?); - # This can't be right; how do we specify this - multi method infix:{'<=>'}(Time $self, Time $other); - multi method infix:{'<=>'}(Time $self, Duration $other); -} - -When created, recognises "today" as a possibility. - =head1 Classes -=head2 Time and Date classes - -=head3 NumberName - - class NumberName { - has $.number; - - method name($format?) { - ... - } - } - -=head3 Timezone - -role Timezone { - has $.number; - - method name($format); - method is_dst(); -} - -=head3 DateTime - -class DateTime does Date does Time does Timezone { - has $.locale; - has $.parser; - has $.formatter; # Only for output formats - - multi method DateTime infix:<+>(DateTime $self, Duration $other); - - multi method infix:<->(DateTime $self, Duration $other); - multi method infix:<->(DateTime $self, Duration $other); - - multi method infix:{'<=>'}(DateTime $self, DateTime $other); - multi method infix:{'<=>'}(DateTime $self, Duration $other); - - method new(:$String); - method truncate(Str $to); - method last(Str $type, Str $of); - method toString($format?); -} - -All formats are CLDR, although implementations may want to have another set of functions -that use the strftime functions instead. - -=over - -=item new - - method new(Str :$String) # parser defaults to 'strptime' or something similar - | (Str $parser, Str $String) # $parser = 'strptime' - | (Str $parser, Int $Epoch) # $parser = 'epoch' - | (Str $parser, Str $Timezone?) # $parser = 'today' [unless strptime does this] - ; - -Tries to parse the date and time specified using $parser. - -If $Epoch is passed in instead, then it interprets the time as being in seconds since the -epoch (which is determined on a system-by-system basis). - -If $parser is 'today', then the current time is gotten. Timezone would be useful for -simulating eg. gmtime(). - -=item truncate - -Can be used to truncate a function to the current day, or whatever. - -=item last - - $date.last('day', of => 'month'); - -=back - -=head3 Duration - -=head3 Repetition - -This class specifies when a repetitive action (eg. a cron job) happens. - -class DateTime::Recurring { -... -} - -Should allow creation from the format that cron uses (ie. */5 * * * * ). - =head2 IO::File This does file input and output. Modified: docs/Perl6/Spec/S29-functions.pod =================================================================== --- docs/Perl6/Spec/S29-functions.pod 2009-02-19 03:46:06 UTC (rev 25402) +++ docs/Perl6/Spec/S29-functions.pod 2009-02-19 04:08:23 UTC (rev 25403) @@ -13,9 +13,10 @@ Mark Stosberg <m...@summersault.com> Carl Mäsak <cma...@gmail.com> Moritz Lenz <mor...@faui2k3.org> + Tim Nelson <wayl...@wayland.id.au> Date: 12 Mar 2005 - Last Modified: 16 Feb 2009 - Version: 40 + Last Modified: 19 Feb 2009 + Version: 41 The document is a draft. Modified: docs/Perl6/Spec/S32-setting-library/Any.pod =================================================================== --- docs/Perl6/Spec/S32-setting-library/Any.pod 2009-02-19 03:46:06 UTC (rev 25402) +++ docs/Perl6/Spec/S32-setting-library/Any.pod 2009-02-19 04:08:23 UTC (rev 25403) @@ -3,7 +3,7 @@ =head1 Title -Synopsis 32: Setting Library - Any +DRAFT: Synopsis 32: Setting Library - Any =head1 Version @@ -13,7 +13,8 @@ Mark Stosberg <m...@summersault.com> Carl Mäsak <cma...@gmail.com> Moritz Lenz <mor...@faui2k3.org> - Date: 19 Mar 2009 abstracted from S29-functions.pod + Tim Nelson <wayl...@wayland.id.au> + Date: 19 Mar 2009 extracted from S29-functions.pod Last Modified: 19 Feb 2009 Version: 1 Modified: docs/Perl6/Spec/S32-setting-library/Containers.pod =================================================================== --- docs/Perl6/Spec/S32-setting-library/Containers.pod 2009-02-19 03:46:06 UTC (rev 25402) +++ docs/Perl6/Spec/S32-setting-library/Containers.pod 2009-02-19 04:08:23 UTC (rev 25403) @@ -3,7 +3,7 @@ =head1 Title -Synopsis 32: Setting Library - Containers.pod +DRAFT: Synopsis 32: Setting Library - Containers.pod =head1 Version @@ -13,7 +13,8 @@ Mark Stosberg <m...@summersault.com> Carl Mäsak <cma...@gmail.com> Moritz Lenz <mor...@faui2k3.org> - Date: 19 Mar 2009 abstracted from S29-functions.pod + Tim Nelson <wayl...@wayland.id.au> + Date: 19 Mar 2009 extracted from S29-functions.pod Last Modified: 19 Feb 2009 Version: 1 Modified: docs/Perl6/Spec/S32-setting-library/IO.pod =================================================================== --- docs/Perl6/Spec/S32-setting-library/IO.pod 2009-02-19 03:46:06 UTC (rev 25402) +++ docs/Perl6/Spec/S32-setting-library/IO.pod 2009-02-19 04:08:23 UTC (rev 25403) @@ -3,7 +3,7 @@ =head1 Title -Synopsis 32: Setting Library - IO +DRAFT: Synopsis 32: Setting Library - IO =head1 Version @@ -13,7 +13,8 @@ Mark Stosberg <m...@summersault.com> Carl Mäsak <cma...@gmail.com> Moritz Lenz <mor...@faui2k3.org> - Date: 19 Mar 2009 abstracted from S29-functions.pod + Tim Nelson <wayl...@wayland.id.au> + Date: 19 Mar 2009 extracted from S29-functions.pod Last Modified: 19 Feb 2009 Version: 1 Modified: docs/Perl6/Spec/S32-setting-library/Numeric.pod =================================================================== --- docs/Perl6/Spec/S32-setting-library/Numeric.pod 2009-02-19 03:46:06 UTC (rev 25402) +++ docs/Perl6/Spec/S32-setting-library/Numeric.pod 2009-02-19 04:08:23 UTC (rev 25403) @@ -3,7 +3,7 @@ =head1 Title -Synopsis 32: Setting Library - Numeric +DRAFT: Synopsis 32: Setting Library - Numeric =head1 Version @@ -13,7 +13,8 @@ Mark Stosberg <m...@summersault.com> Carl Mäsak <cma...@gmail.com> Moritz Lenz <mor...@faui2k3.org> - Date: 19 Mar 2009 abstracted from S29-functions.pod + Tim Nelson <wayl...@wayland.id.au> + Date: 19 Mar 2009 extracted from S29-functions.pod Last Modified: 19 Feb 2009 Version: 1 Modified: docs/Perl6/Spec/S32-setting-library/Scalar.pod =================================================================== --- docs/Perl6/Spec/S32-setting-library/Scalar.pod 2009-02-19 03:46:06 UTC (rev 25402) +++ docs/Perl6/Spec/S32-setting-library/Scalar.pod 2009-02-19 04:08:23 UTC (rev 25403) @@ -3,7 +3,7 @@ =head1 Title -Synopsis 32: Setting Library - Miscellaneous Scalars +DRAFT: Synopsis 32: Setting Library - Miscellaneous Scalars =head1 Version @@ -13,7 +13,8 @@ Mark Stosberg <m...@summersault.com> Carl Mäsak <cma...@gmail.com> Moritz Lenz <mor...@faui2k3.org> - Date: 19 Mar 2009 abstracted from S29-functions.pod + Tim Nelson <wayl...@wayland.id.au> + Date: 19 Mar 2009 extracted from S29-functions.pod Last Modified: 19 Feb 2009 Version: 1 Modified: docs/Perl6/Spec/S32-setting-library/String.pod =================================================================== --- docs/Perl6/Spec/S32-setting-library/String.pod 2009-02-19 03:46:06 UTC (rev 25402) +++ docs/Perl6/Spec/S32-setting-library/String.pod 2009-02-19 04:08:23 UTC (rev 25403) @@ -3,7 +3,7 @@ =head1 Title -Synopsis 32: Setting Library - Miscellaneous Scalars +DRAFT: Synopsis 32: Setting Library - Miscellaneous Scalars =head1 Version @@ -13,7 +13,8 @@ Mark Stosberg <m...@summersault.com> Carl Mäsak <cma...@gmail.com> Moritz Lenz <mor...@faui2k3.org> - Date: 19 Mar 2009 abstracted from S29-functions.pod + Tim Nelson <wayl...@wayland.id.au> + Date: 19 Mar 2009 extracted from S29-functions.pod Last Modified: 19 Feb 2009 Version: 1 Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod =================================================================== --- docs/Perl6/Spec/S32-setting-library/Temporal.pod 2009-02-19 03:46:06 UTC (rev 25402) +++ docs/Perl6/Spec/S32-setting-library/Temporal.pod 2009-02-19 04:08:23 UTC (rev 25403) @@ -3,17 +3,19 @@ =head1 Title -Synopsis 32: Setting Library - Temporal +DRAFT: Synopsis 32: Setting Library - Temporal =head1 Version - Author: Rod Adams <r...@rodadams.net> + Author: Rod Adams <r...@rodadams.net>, the authors of the related Perl 5 docs. Maintainer: Larry Wall <la...@wall.org> Contributions: Aaron Sherman <a...@ajs.com> Mark Stosberg <m...@summersault.com> Carl Mäsak <cma...@gmail.com> Moritz Lenz <mor...@faui2k3.org> - Date: 19 Mar 2009 abstracted from S29-functions.pod + Tim Nelson <wayl...@wayland.id.au> + Daniel Ruoso <dan...@ruoso.com> + Date: 19 Mar 2009 extracted from S29-functions.pod and S16-IO.pod Last Modified: 19 Feb 2009 Version: 1 @@ -62,10 +64,171 @@ =back +=head1 Roles + +=head2 Time and Date roles + +=head3 Date + +You probably want to use the DateTime object instead. + +role Date { + has Calendar $.calendar; # Gregorian, Secular, Julian, etc + has NumberName $.year; + has NumberName $.month; + has NumberName $.dayofmonth; + has NumberName $.dayofweek; + has NumberName $.dayofyear; + has NumberName $.dayofquarter; + has NumberName $.quarter; + has NumberName $.era; # 'Common', 'Christian', etc + has Str $.defaultformat; + + method toString($format); + method isLeapYear(); + + multi method DateTime infix:<+>(Date $self, Time $other); + multi method DateTime infix:<+>(Date $self, Duration $other); + + multi method infix:{'<=>'}(Date $self, Date $other); + multi method infix:{'<=>'}(Date $self, Duration $other); + + method get(Str $type, Str $of); + method last(Str $type, Str $of); +} + +Example: + +$date = new Date('2002/01/01'); +$date.month.name(); # January +$date.month.name('short'); # Jan +$date.get('day', of => 'year'); + +$date = new Date('2002/01/01'); +$date.convertcalendar('Chinese'); +$date.year.name(); # Snake + +A fair bit of initialisation of the NumberNames for day of the week and month will need to +be done. + +$format will naturally need to allow for eras. + +=over + +=item + + method toString($format = 'YYYY/MM/DD'); + +$format contains things like YYYY/MM/DD or whatever. + +=back + +=head3 Time + +You probably want to use the DateTime object instead. + +role Time { + has $.hour; + has $.minute; + has $.second; + + method toString($format?); + # This can't be right; how do we specify this + multi method infix:{'<=>'}(Time $self, Time $other); + multi method infix:{'<=>'}(Time $self, Duration $other); +} + +When created, recognises "today" as a possibility. + +=head1 Classes + +=head2 Time and Date classes + +=head3 NumberName + + class NumberName { + has $.number; + + method name($format?) { + ... + } + } + +=head3 Timezone + +role Timezone { + has $.number; + + method name($format); + method is_dst(); +} + +=head3 DateTime + +class DateTime does Date does Time does Timezone { + has $.locale; + has $.parser; + has $.formatter; # Only for output formats + + multi method DateTime infix:<+>(DateTime $self, Duration $other); + + multi method infix:<->(DateTime $self, Duration $other); + multi method infix:<->(DateTime $self, Duration $other); + + multi method infix:{'<=>'}(DateTime $self, DateTime $other); + multi method infix:{'<=>'}(DateTime $self, Duration $other); + + method new(:$String); + method truncate(Str $to); + method last(Str $type, Str $of); + method toString($format?); +} + +All formats are CLDR, although implementations may want to have another set of functions +that use the strftime functions instead. + +=over + +=item new + + method new(Str :$String) # parser defaults to 'strptime' or something similar + | (Str $parser, Str $String) # $parser = 'strptime' + | (Str $parser, Int $Epoch) # $parser = 'epoch' + | (Str $parser, Str $Timezone?) # $parser = 'today' [unless strptime does this] + ; + +Tries to parse the date and time specified using $parser. + +If $Epoch is passed in instead, then it interprets the time as being in seconds since the +epoch (which is determined on a system-by-system basis). + +If $parser is 'today', then the current time is gotten. Timezone would be useful for +simulating eg. gmtime(). + +=item truncate + +Can be used to truncate a function to the current day, or whatever. + +=item last + + $date.last('day', of => 'month'); + +=back + +=head3 Duration + +=head3 Repetition + +This class specifies when a repetitive action (eg. a cron job) happens. + +class DateTime::Recurring { +... +} + +Should allow creation from the format that cron uses (ie. */5 * * * * ). + =head1 Additions Please post errors and feedback to perl6-language. If you are making a general laundry list, please separate messages by topic. - -