Skip to content

Commit

Permalink
ready to check for release
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrowder committed Feb 16, 2024
1 parent 7e3965f commit 096ffdc
Show file tree
Hide file tree
Showing 22 changed files with 90 additions and 66 deletions.
8 changes: 8 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{{$NEXT}}
- Clean up and remove lots of language about
possible changes.
- Add phrase 'The Year' for all languages to use
on a cover sheet for a calendar. (The initial
translation will come from Google.) For
example: The Year 2024
+ the value is accessed by the class attribute .the-year
+ add tests for the value

2.3.0 2024-01-22T21:14:34-06:00
- For a language without a valid dow2 or dow3 or mon2 or mon3 array,
Expand Down
33 changes: 13 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,55 @@ Date::Names

Module **Date::Names** - Provides month and weekday names for numbers (multilingual)

This is Version 2 with significant differences and more features compared to Version 1:

### Changes:

* language-specific data set hashes have changed to arrays

* no symbols are exported; direct access is available, but not recommended—use the new class instead

* `@lang` renamed to `@langs`

* added class **Date::Names** for primary data access

SYNOPSIS
========

use Date::Names;
# choose the German language (English is the default)
my $d = Date::Names.new: :lang<de>;

# default is to show full names
# Default is to show full names
say $d.dow(3); # OUTPUT: «Mittwoch␤»
say $d.mon(3); # OUTPUT: «März␤»

# what abbreviations are available?
# What abbreviations are available?
$d.sets; # OUTPUT: «name sets with values:␤ dow dow2 mon mon3␤»

# choose the desired sets
# Choose the desired sets
$d = Date::Names.new: :lang<de>, :mset<mon3>, :dset<dow2>;
say $d.dow(4); # OUTPUT: «Do␤»
say $d.mon(4); # OUTPUT: «Apr␤»

# arbitrarily truncate a word
# Arbitrarily truncate a word
say $d.mon(8,2); # OUTPUT: «Au␤»

# given a name, return the number of month of year or day of week
# Given a name, return the number of month of year or day of week
say $d.mon2num('März'); # OUTPUT: «3␤»
say $d.dow2num('Mittwoch'); # OUTPUT: «3␤»

# How to say "The Year 2030"
say "{$d.the-year} 2030"; # OUTPUT: «Das Jahr 2030␤»

DESCRIPTION
===========

Module **Date::Names** provides the full name of months and days of the week for the numbers 1..12 and 1..7, respectively, primarily for use with **Raku**'s date functions.

Full names of the months and weekdays are currently available in the following thirteen languages:

### Table 1. Language ISO codes (lower-case)
### Table 1. Language ISO codes (lower-case) and '.this-year' value

<table class="pod-table">
<thead><tr>
<th>Language</th> <th>ISO code</th>
<th>Language</th> <th>ISO code</th> <th>.the-year</th>
</tr></thead>
<tbody>
<tr> <td>Dutch</td> <td>nl</td> </tr> <tr> <td>English</td> <td>en</td> </tr> <tr> <td>French</td> <td>fr</td> </tr> <tr> <td>German</td> <td>de</td> </tr> <tr> <td>Indonesian</td> <td>id</td> </tr> <tr> <td>Italian</td> <td>it</td> </tr> <tr> <td>Norwegian (Bokmål)</td> <td>nb</td> </tr> <tr> <td>Norwegian (Nynorsk)</td> <td>nn</td> </tr> <tr> <td>Polish</td> <td>pl</td> </tr> <tr> <td>Romanian</td> <td>ro</td> </tr> <tr> <td>Russian</td> <td>ru</td> </tr> <tr> <td>Spanish</td> <td>es</td> </tr> <tr> <td>Ukranian</td> <td>uk</td> </tr>
<tr> <td>Dutch</td> <td>nl</td> <td>&#39;Het jaar&#39;</td> </tr> <tr> <td>English</td> <td>en</td> <td>&#39;The Year&#39;</td> </tr> <tr> <td>French</td> <td>fr</td> <td>&quot;L&#39;année&quot;</td> </tr> <tr> <td>German</td> <td>de</td> <td>&#39;Das Jahr&#39;</td> </tr> <tr> <td>Indonesian</td> <td>id</td> <td>&#39;Tahun&#39;</td> </tr> <tr> <td>Italian</td> <td>it</td> <td>&quot;L&#39;anno&quot;</td> </tr> <tr> <td>Norwegian (Bokmål)</td> <td>nb</td> <td>&#39;Год» да бокмал&#39;</td> </tr> <tr> <td>Norwegian (Nynorsk)</td> <td>nn</td> <td>&#39;Год» на нюнорск&#39;</td> </tr> <tr> <td>Polish</td> <td>pl</td> <td>&#39;Rok&#39;</td> </tr> <tr> <td>Romanian</td> <td>ro</td> <td>&#39;Anul&#39;</td> </tr> <tr> <td>Russian</td> <td>ru</td> <td>&#39;Год&#39;</td> </tr> <tr> <td>Spanish</td> <td>es</td> <td>&#39;El año&#39;</td> </tr> <tr> <td>Ukranian</td> <td>uk</td> <td>&#39;Рік&#39;</td> </tr>
</tbody>
</table>

The '.the-year' attribute values were obtained from Google and may not be the correct value. Please file an issue if you are a native language speaker and see an error.

CAPITALIZATION and PUNCTUATION
==============================

Expand Down
63 changes: 28 additions & 35 deletions docs/README.rakudoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,34 @@

Module B<Date::Names> - Provides month and weekday names for numbers (multilingual)

This is Version 2 with significant differences and more
features compared to Version 1:

=head3 Changes:

=item language-specific data set hashes have changed to arrays

=item no symbols are exported; direct access is available, but not
recommendedE<0x2014>use the new class instead

=item C<@lang> renamed to C<@langs>

=item added class B<Date::Names> for primary data access

=head1 SYNOPSIS

=begin code
use Date::Names;
# choose the German language (English is the default)
my $d = Date::Names.new: :lang<de>;

# default is to show full names
# Default is to show full names
say $d.dow(3); # OUTPUT: «Mittwoch␤»
say $d.mon(3); # OUTPUT: «März␤»

# what abbreviations are available?
# What abbreviations are available?
$d.sets; # OUTPUT: «name sets with values:␤ dow dow2 mon mon3␤»

# choose the desired sets
# Choose the desired sets
$d = Date::Names.new: :lang<de>, :mset<mon3>, :dset<dow2>;
say $d.dow(4); # OUTPUT: «Do␤»
say $d.mon(4); # OUTPUT: «Apr␤»

# arbitrarily truncate a word
# Arbitrarily truncate a word
say $d.mon(8,2); # OUTPUT: «Au␤»

# given a name, return the number of month of year or day of week
# Given a name, return the number of month of year or day of week
say $d.mon2num('März'); # OUTPUT: «3␤»
say $d.dow2num('Mittwoch'); # OUTPUT: «3␤»

# How to say "The Year 2030"
say "{$d.the-year} 2030"; # OUTPUT: «Das Jahr 2030␤»
=end code

=head1 DESCRIPTION
Expand All @@ -54,26 +43,30 @@ with B<Raku>'s date functions.
Full names of the months and weekdays are currently available in the
following thirteen languages:

=head3 Table 1. Language ISO codes (lower-case)
=head3 Table 1. Language ISO codes (lower-case) and '.this-year' value

=begin table
Language | ISO code
--------------------+---------
Dutch | nl
English | en
French | fr
German | de
Indonesian | id
Italian | it
Norwegian (Bokmål) | nb
Norwegian (Nynorsk) | nn
Polish | pl
Romanian | ro
Russian | ru
Spanish | es
Ukranian | uk
Language | ISO code | .the-year
--------------------+----------+----------
Dutch | nl | 'Het jaar'
English | en | 'The Year'
French | fr | "L'année"
German | de | 'Das Jahr'
Indonesian | id | 'Tahun'
Italian | it | "L'anno"
Norwegian (Bokmål) | nb | 'Год» да бокмал'
Norwegian (Nynorsk) | nn | 'Год» на нюнорск'
Polish | pl | 'Rok'
Romanian | ro | 'Anul'
Russian | ru | 'Год'
Spanish | es | 'El año'
Ukranian | uk | 'Рік'
=end table

The '.the-year' attribute values were obtained from Google and may not
be the correct value. Please file an issue if you are a native
language speaker and see an error.

=head1 CAPITALIZATION and PUNCTUATION

All English month and weekday names are always capitalized. Other
Expand Down
47 changes: 38 additions & 9 deletions lib/Date/Names.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@ ru => 'Russian',
uk => 'Ukrainian',
;

# Start with Google's translation
# translate "The Year" to lang
# note some these are suspect
our %the-year is export =
de => 'Das Jahr', # ok
en => 'The Year', # ok
es => 'El año', # ok
fr => "L'année", # ok
id => 'Tahun', # ok
it => "L'anno", # ok
nb => 'Год» да бокмал', # ok bokmal
nn => 'Год» на нюнорск', # ok nynorsk
nl => 'Het jaar', # ok
pl => 'Rok', # ok
ro => 'Anul', # ok
ru => 'Год', # ok
uk => 'Рік', # ok
;

# Lists of the eight standard data set names for each language:
our @msets = <mon mon2 mon3 mona>;
Expand Down Expand Up @@ -69,6 +87,7 @@ has Str $.mset is rw = 'mon'; # default: full names
has Str $.dset is rw = 'dow'; # default: full names
has Str $.msetF = 'mon'; # constant: full names
has Str $.dsetF = 'dow'; # constant: full names
has Str $.the-year = 'The Year'; # default

has Period $.period = keep; # add, remove, or keep a period to end abbreviations
has UInt $.trunc = 0; # truncate to N chars if N > 0
Expand All @@ -86,6 +105,8 @@ has $.mfull;
# this an auto-generated hash of the names of
# all non-empty data sets and values of that array
has %.s is rw;
# this is the string "This Year" translated to the language class
has $.ty is rw;

submethod TWEAK() {
# This sets the class var to the desired
Expand All @@ -98,9 +119,10 @@ submethod TWEAK() {
my $MF = $!msetF;
my $DF = $!dsetF;

$!m = self!define-attr-mset($L, $M);
$!d = self!define-attr-dset($L, $D);
%!s = self!define-attr-sets($L);
$!m = self!define-attr-mset($L, $M);
$!d = self!define-attr-dset($L, $D);
%!s = self!define-attr-sets($L);
$!ty = %the-year{$L};

$!mfull = self!define-attr-mset($L, $MF);
$!dfull = self!define-attr-mset($L, $DF);
Expand Down Expand Up @@ -166,7 +188,7 @@ submethod TWEAK() {
my $nreq = $n eq 'mon' ?? 12 !! 7;
if $nhas != $nreq {
note qq:to/HERE/;
WARNING: lang {$!lang}, data set '$n' has $nhas elements,
WARNING: lang {$!lang}, data set '$n' has $nhas elements,
but it should have $nreq
HERE
}
Expand All @@ -187,6 +209,13 @@ submethod TWEAK() {
}

# private methods ================================
=begin comment
method !define-attr-ty() {
my $ty = %the-year{$!lang};
return $ty;
}
=end comment

method !define-attr-mset($L, $M) {
my $mm = "Date::Names::{$L}::{$M}";
my $m = $::($mm);
Expand Down Expand Up @@ -292,8 +321,8 @@ method clone {
}
=end comment

method dow(UInt $n is copy where { 0 < $n < 8 },
$trunc = 0,
method dow(UInt $n is copy where { 0 < $n < 8 },
$trunc = 0,
:$debug
) {

Expand Down Expand Up @@ -328,7 +357,7 @@ method dow(UInt $n is copy where { 0 < $n < 8 },
val is NOT defined
lang: $!lang
dset: $!dset
index: $n
index: $n
HERE
}

Expand Down Expand Up @@ -411,7 +440,7 @@ method dow2num($s, :$debug) {
$ret
}

method mon(UInt $n is copy where { 0 < $n < 13 },
method mon(UInt $n is copy where { 0 < $n < 13 },
$trunc = 0,
:$debug
) {
Expand Down Expand Up @@ -446,7 +475,7 @@ method mon(UInt $n is copy where { 0 < $n < 13 },
val is NOT defined
lang: $!lang
dset: $!mset
index: $n
index: $n
HERE
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions t/006-check-all-langs.t → t/6-check-all-langs.t
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ constant %min-abbrev = [

my $ntests = @langs.elems * 19 + %min-abbrev.elems * 19;

plan $ntests;
plan $ntests + @langs.elems;

for @langs -> $L {
$dn = Date::Names.new: :lang($L);
my $s = $dn.ty;
is $s, %the-year{$L};

if %min-abbrev{$L}:exists {
# check all months (min-abbrevs)
Expand Down Expand Up @@ -58,4 +60,3 @@ for @langs -> $L {
}

}

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 096ffdc

Please sign in to comment.