atoomic / perl-TimeDate

time & date parsing and formatting perl library
http://search.cpan.org/dist/TimeDate/
1 stars 3 forks source link

Portuguese [rt.cpan.org #94905] #31

Open atoomic opened 4 years ago

atoomic commented 4 years ago

Migrated from rt.cpan.org#94905 (status was 'open')

Requestors:

From honir999@gmail.com on 2014-04-21 09:55:49 :

Please will you add Portuguese as a supported language?
Thanks

Something like this (although I'm not a native speaker):

++++++++++++++++++++++++++++++++++
##
## Portuguese tables
##

package Date::Language::Portuguese;

use Date::Language ();
use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION);
@ISA = qw(Date::Language);
$VERSION = "1.00";

@DoW = qw(domingo segunda terça quarta quinta sexta sábado);
@MoY = qw(janeiro fevereiro março abril maio junho
      julho agosto setembro outubro novembro dezembro);
@DoWs = map { substr($_,0,3) } @DoW;
@MoYs = map { substr($_,0,3) } @MoY;
@AMPM = qw(AM PM);

@Dsuf = ((qw(0)) x 31);

@MoY{@MoY}  = (0 .. scalar(@MoY));
@MoY{@MoYs} = (0 .. scalar(@MoYs));
@DoW{@DoW}  = (0 .. scalar(@DoW));
@DoW{@DoWs} = (0 .. scalar(@DoWs));

# Formatting routines

sub format_a { $DoWs[$_[0]->[6]] }
sub format_A { $DoW[$_[0]->[6]] }
sub format_b { $MoYs[$_[0]->[4]] }
sub format_B { $MoY[$_[0]->[4]] }
sub format_h { $MoYs[$_[0]->[4]] }
sub format_p { $_[0]->[2] >= 12 ?  $AMPM[1] : $AMPM[0] }

1;

++++++++++++++++++++++++++++++++++

c.f. http://publib.boulder.ibm.com/infocenter/forms/v3r0m0/index.jsp?topic=/com.ibm.help.forms.doc/locale_spec/i_xfdl_r_formats_pt_BR.html

From mbethke@cpan.org on 2016-05-16 04:41:09 :

I second that. Considering that about Icelandic is supported and there are almost 700 native speakers of Portuguese to one of Icelandic in the world, that should be pretty high priority.

However, the days of the week in the provided example need fixing: "segunda", "terça" etc. is colloquial usage, the full names are

domingo
segunda-feira
terça-feira
quarta-feira
quinta-feira
sexta-feira
sábado