Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 Jun 2016 18:10:00 +0900
From:      Hajimu UMEMOTO <ume@FreeBSD.org>
To:        Eric van Gyzen <vangyzen@FreeBSD.org>
Cc:        Baptiste Daroussin <bapt@FreeBSD.org>, freebsd-current@freebsd.org
Subject:   Re: Date formatting with en_US locale
Message-ID:  <ygefusazwuv.wl-ume@FreeBSD.org>
In-Reply-To: <6d8f5e72-b3ab-9aa6-4fb6-1986b7b4f19b@FreeBSD.org>
References:  <499d8ddd-06c8-5184-68cb-4be19764b318@FreeBSD.org> <20160526144944.GD977@ivaldir.etoilebsd.net> <e096b663-ed6b-3211-4559-74ddcf54050a@bsd.com.br> <20160526151508.GE977@ivaldir.etoilebsd.net> <6d8f5e72-b3ab-9aa6-4fb6-1986b7b4f19b@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--Multipart_Sat_Jun_18_18:10:00_2016-1
Content-Type: text/plain; charset=US-ASCII

Hi,

vangyzen> Above, I mentioned two issues.  The other one is, the date format for
vangyzen> en_US pads the month with a zero, but the day with a space.  So, June 7 is:

vangyzen>         06/ 7/16

vangyzen> That looks weird.  It should pad both with zeros.  I'd be happy to fix
vangyzen> it, but I don't see how:  There isn't an "xformat" callback in the
vangyzen> cldr2def.pl script, and it's not clear how to add one.  If you can
vangyzen> explain, I'll do it.  If you can fix it, I'll be grateful.  ;)

Does the attached patch fix your issue?
Though there are many locales it should be fixed, I've included only
en_US one, in this time.

Sincerely,


--Multipart_Sat_Jun_18_18:10:00_2016-1
Content-Type: text/x-patch; type=patch; charset=US-ASCII
Content-Disposition: attachment; filename="x_fmt-zerofill.diff"
Content-Transfer-Encoding: 7bit

Index: share/timedef/en_US.UTF-8.src
===================================================================
--- share/timedef/en_US.UTF-8.src	(revision 302002)
+++ share/timedef/en_US.UTF-8.src	(working copy)
@@ -53,7 +53,7 @@
 %I:%M:%S %p
 #
 # x_fmt
-%m/%e/%y
+%m/%d/%y
 #
 # c_fmt
 %A, %B %e, %Y at %I:%M:%S %p
@@ -80,7 +80,7 @@
 December
 #
 # md_order
-m
+md
 #
 # ampm_fmt
 %I:%M:%S %p
Index: tools/tools/locale/tools/cldr2def.pl
===================================================================
--- tools/tools/locale/tools/cldr2def.pl	(revision 302002)
+++ tools/tools/locale/tools/cldr2def.pl	(working copy)
@@ -68,6 +68,7 @@
 	mdorder => \&callback_mdorder,
 	altmon => \&callback_altmon,
 	cformat => \&callback_cformat,
+	dformat => \&callback_dformat,
 	dtformat => \&callback_dtformat,
 	cbabmon => \&callback_abmon,
 	cbampm => \&callback_ampm,
@@ -183,10 +184,9 @@
 	    "abday"		=> "as",
 	    "day"		=> "as",
 	    "t_fmt"		=> "s",
-	    "d_fmt"		=> "s",
+	    "d_fmt"		=> "<dformat<d_fmt<s",
 	    "c_fmt"		=> "<cformat<d_t_fmt<s",
 	    "am_pm"		=> "<cbampm<am_pm<as",
-	    "d_fmt"		=> "s",
 	    "d_t_fmt"		=> "<dtformat<d_t_fmt<s",
 	    "altmon"		=> "<altmon<mon<as",
 	    "md_order"		=> "<mdorder<d_fmt<s",
@@ -225,6 +225,14 @@
 	return $s;
 };
 
+sub callback_dformat {
+	my $s = shift;
+
+	$s =~ s/(%m(<SOLIDUS>|[-.]))%e/$1%d/;
+	$s =~ s/%e((<SOLIDUS>|[-.])%m)/%d$1/;
+	return $s;
+};
+
 sub callback_dtformat {
 	my $s = shift;
 	my $nl = $callback{data}{l} . "_" . $callback{data}{c};
@@ -241,7 +249,8 @@
 sub callback_mdorder {
 	my $s = shift;
 	return undef if (!defined $s);
-	$s =~ s/[^dm]//g;
+	$s =~ s/[^dem]//g;
+	$s =~ s/e/d/g;
 	return $s;
 };
 

--Multipart_Sat_Jun_18_18:10:00_2016-1
Content-Type: text/plain; charset=US-ASCII


--
Hajimu UMEMOTO
ume@mahoroba.org  ume@FreeBSD.org
http://www.mahoroba.org/~ume/

--Multipart_Sat_Jun_18_18:10:00_2016-1--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ygefusazwuv.wl-ume>