Fix spacing issues with WebGUI::DateTime->webguiDate.
This commit is contained in:
parent
2bcda0c9f5
commit
7e8ae8fe9a
3 changed files with 12 additions and 10 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
- fixed #12179: DataTable Field types get reset to "Text" in Edit Schema (Amir Plivatsky)
|
- fixed #12179: DataTable Field types get reset to "Text" in Edit Schema (Amir Plivatsky)
|
||||||
- added: FormField macro for rendering Form objects directly from templates
|
- added: FormField macro for rendering Form objects directly from templates
|
||||||
- fixed: Generic Tax driver does not like spaces around commas
|
- fixed: Generic Tax driver does not like spaces around commas
|
||||||
|
- fixed: Date formatting with WebGUI::DateTime has extra spaces for single digit months and days.
|
||||||
|
|
||||||
7.10.19
|
7.10.19
|
||||||
- fixed #12169: extras uploads symlink export
|
- fixed #12169: extras uploads symlink export
|
||||||
|
|
|
||||||
|
|
@ -491,7 +491,9 @@ sub session {
|
||||||
Change a WebGUI format into a Strftime format.
|
Change a WebGUI format into a Strftime format.
|
||||||
|
|
||||||
NOTE: %M in WebGUI's format has no equivalent in strftime format, so it will
|
NOTE: %M in WebGUI's format has no equivalent in strftime format, so it will
|
||||||
be replaced with "_varmonth_". Do something with it.
|
be replaced with "{month}". Single digit hours are handled similarly. DateTime's
|
||||||
|
strftime will use {method} to call a method on the object to fill in that part of
|
||||||
|
the format.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
|
@ -514,13 +516,13 @@ sub webguiToStrftime {
|
||||||
"c" => "B",
|
"c" => "B",
|
||||||
"C" => "b",
|
"C" => "b",
|
||||||
"d" => "d",
|
"d" => "d",
|
||||||
"D" => "e",
|
"D" => "{day}",
|
||||||
"h" => "I",
|
"h" => "I",
|
||||||
"H" => "l",
|
"H" => "l",
|
||||||
"j" => "H",
|
"j" => "H",
|
||||||
"J" => "k",
|
"J" => "k",
|
||||||
"m" => "m",
|
"m" => "m",
|
||||||
"M" => "_varmonth_",
|
"M" => "{month}",
|
||||||
"n" => "M",
|
"n" => "M",
|
||||||
"t" => "Z",
|
"t" => "Z",
|
||||||
"O" => "z",
|
"O" => "z",
|
||||||
|
|
@ -587,12 +589,7 @@ sub webguiDate {
|
||||||
|
|
||||||
my $format = $self->webguiToStrftime( shift || "%z %Z" );
|
my $format = $self->webguiToStrftime( shift || "%z %Z" );
|
||||||
|
|
||||||
#--- %M
|
|
||||||
my $datestr = $self->strftime($format);
|
my $datestr = $self->strftime($format);
|
||||||
my $temp = int($self->month);
|
|
||||||
$datestr =~ s/\%_varmonth_/$temp/g;
|
|
||||||
|
|
||||||
#--- return
|
|
||||||
return $datestr;
|
return $datestr;
|
||||||
}
|
}
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
# put your tests here
|
# put your tests here
|
||||||
|
|
||||||
plan tests => 30;
|
plan tests => 32;
|
||||||
|
|
||||||
my $timeZoneUser = addUser($session);
|
my $timeZoneUser = addUser($session);
|
||||||
|
|
||||||
|
|
@ -98,11 +98,15 @@ is( $nowDt->webguiToStrftime('%y-%m-%d'), '%Y-%m-%d', 'webgui to strftime conver
|
||||||
|
|
||||||
$timeZoneUser->update({ 'dateFormat' => '%y-%M-%D' });
|
$timeZoneUser->update({ 'dateFormat' => '%y-%M-%D' });
|
||||||
$timeZoneUser->update({ 'timeFormat' => '%H:%n %p' });
|
$timeZoneUser->update({ 'timeFormat' => '%H:%n %p' });
|
||||||
is( $nowDt->webguiToStrftime, '%Y-%_varmonth_-%e %l:%M %P', 'default datetime string' );
|
is( $nowDt->webguiToStrftime, '%Y-%{month}-%{day} %l:%M %P', 'default datetime string' );
|
||||||
|
|
||||||
|
my $single_digit = WebGUI::DateTime->new($session, '2011-07-04 15:00:00');
|
||||||
|
is $single_digit->webguiDate("%z"), '2011-7-4', 'single digit month and day check';
|
||||||
|
is $single_digit->webguiDate("%z"), $session->datetime->epochToHuman($single_digit->epoch, '%z'), 'webguiDate, an exact match to session->datetime';
|
||||||
|
|
||||||
sub addUser {
|
sub addUser {
|
||||||
my $session = shift;
|
my $session = shift;
|
||||||
|
|
||||||
my $user = WebGUI::User->new($session, "new");
|
my $user = WebGUI::User->new($session, "new");
|
||||||
|
|
||||||
##From my research, this particular time zone does NOT follow daylight savings,
|
##From my research, this particular time zone does NOT follow daylight savings,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue