Skip to content
This repository

fix issue #1467(JHtml::calendar does not format dates on output correctly) #1468

Closed
wants to merge 6 commits into from

4 participants

ramalama Rouven Weßling elinw Louis Landry
ramalama

No description provided.

Rouven Weßling
Collaborator

Is still still working with the JS calendar? With non-gregorian calendars?

elinw

Would you please change this title to something that describes the issue? The title is used for creating the changelog.

ramalama

@realityking It is still working with the DHTML JS Calendar, but I don't know how to check the non-gergorian calendars.
@elinw changed the title, hope that it's better now.

Rouven Weßling
Collaborator

I suggest you talk to JM about non-gregorian calendars, he knows most about it.

You also have code style issues and a unit test failure to address: http://developer.joomla.org/pulls/pulls/1468.html

added some commits August 21, 2012
ramalama Code Style Issues solved e9e62ac
ramalama Added correct format to test data
Input 2010-05-28 00:00:00 should result in  2010-05-28 if the format is
'%Y-%m-%d"
Input 2010-05-28 00:00:00 should result in  2010-05-28 00:00:00 if the
format is '%Y-%m-%d %H:%M:%i"
13101c0
ramalama Fixed mistake in format string
additionally changed the time string to a better value, where hour, min
and seconds values differ.
c13fd46
Louis Landry

@ramalama this pull request is no longer mergeable. It would be great if you could rebase it (and maybe squash some of the commits) so that it is mergeable again. Apologies for the long delay in response. Once you get it cleaned up we can take a quick look at the internationalization issues brought up and hopefully get it merged into the platform.

Note: I'm closing the pull request for now. This isn't because I'm rejecting it, but because in its current state it cannot be reviewed. Once you get it rebased and cleaned up please re-open the pull request and we'll finish the conversation on getting it merged. Thanks!

Louis Landry LouisLandry closed this October 09, 2012
ramalama

@LouisLandry I am sorry, I do not know how to rebase it and do not have time to do this these days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 6 unique commits by 1 author.

Aug 17, 2012
ramalama Merge pull request #1 from joomla/staging
Update Staging from joomla/staging
33a0adb
Aug 18, 2012
ramalama Update libraries/joomla/html/html.php 9e68613
ramalama Update libraries/joomla/html/html.php e1c7736
Aug 21, 2012
ramalama Code Style Issues solved e9e62ac
ramalama Added correct format to test data
Input 2010-05-28 00:00:00 should result in  2010-05-28 if the format is
'%Y-%m-%d"
Input 2010-05-28 00:00:00 should result in  2010-05-28 00:00:00 if the
format is '%Y-%m-%d %H:%M:%i"
13101c0
Aug 22, 2012
ramalama Fixed mistake in format string
additionally changed the time string to a better value, where hour, min
and seconds values differ.
c13fd46
This page is out of date. Refresh to see the latest.
18  libraries/joomla/html/html.php
@@ -821,7 +821,7 @@ public static function tooltip($tooltip, $title = '', $image = 'tooltip.png', $t
821 821
 	 * @param   string  $value    The date value
822 822
 	 * @param   string  $name     The name of the text field
823 823
 	 * @param   string  $id       The id of the text field
824  
-	 * @param   string  $format   The date format
  824
+	 * @param   string  $format   The date format (strftime)
825 825
 	 * @param   array   $attribs  Additional HTML attributes
826 826
 	 *
827 827
 	 * @return  string  HTML markup for a calendar field
@@ -844,6 +844,14 @@ public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attri
844 844
 			$attribs = JArrayHelper::toString($attribs);
845 845
 		}
846 846
 
  847
+		$timestamp = strtotime($value);
  848
+		if ($timestamp)
  849
+		{
  850
+			// JHtml::date() uses dateTime->format() and can't make use of the given strftime $format
  851
+			// As we still want to format the output date/time we use strftime here
  852
+			$value = strftime($format, $timestamp);
  853
+		}
  854
+
847 855
 		if (!$readonly && !$disabled)
848 856
 		{
849 857
 			// Load the calendar behavior
@@ -871,15 +879,15 @@ public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attri
871 879
 				);
872 880
 				$done[] = $id;
873 881
 			}
874  
-			return '<input type="text" title="' . (0 !== (int) $value ? self::_('date', $value, null, null) : '') . '" name="' . $name . '" id="' . $id
  882
+			return '<input type="text" title="' . $value . '" name="' . $name . '" id="' . $id
875 883
 				. '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" ' . $attribs . ' />'
876 884
 				. self::_('image', 'system/calendar.png', JText::_('JLIB_HTML_CALENDAR'), array('class' => 'calendar', 'id' => $id . '_img'), true);
877 885
 		}
878 886
 		else
879 887
 		{
880  
-			return '<input type="text" title="' . (0 !== (int) $value ? self::_('date', $value, null, null) : '')
881  
-				. '" value="' . (0 !== (int) $value ? self::_('date', $value, 'Y-m-d H:i:s', null) : '') . '" ' . $attribs
882  
-				. ' /><input type="hidden" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" />';
  888
+			return '<input type="text" title="' . $value
  889
+				. '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" ' . $attribs . ' />'
  890
+				. '<input type="hidden" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" />';
883 891
 		}
884 892
 	}
885 893
 	/**
4  tests/suites/unit/joomla/html/JHtmlTest.php
@@ -1367,8 +1367,8 @@ public function testCalendar()
1367 1367
 		$_SERVER['HTTP_USER_AGENT'] = 'Test Browser';
1368 1368
 
1369 1369
 		// two sets of test data
1370  
-		$test_data = array('date' => '2010-05-28 00:00:00', 'friendly_date' => 'Friday, 28 May 2010',
1371  
-					  'name' => 'cal1_name', 'id' => 'cal1_id', 'format' => '%Y-%m-%d',
  1370
+		$test_data = array('date' => '2010-05-28 14:12:34', 'friendly_date' => 'Friday, 28 May 2010',
  1371
+					  'name' => 'cal1_name', 'id' => 'cal1_id', 'format' => '%Y-%m-%d %H:%M:%S',
1372 1372
 					  'attribs' => array()
1373 1373
 				);
1374 1374
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.