Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
wants to merge 6 commits into from

4 participants

@ramalama

No description provided.

@realityking
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.

@realityking
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

ramalama added some commits
@ramalama ramalama Code Style Issues solved e9e62ac
@ramalama 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 ramalama Fixed mistake in format string
additionally changed the time string to a better value, where hour, min
and seconds values differ.
c13fd46
@LouisLandry

@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!

@LouisLandry LouisLandry closed this
@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
Commits on Aug 17, 2012
  1. @ramalama

    Merge pull request #1 from joomla/staging

    ramalama authored
    Update Staging from joomla/staging
Commits on Aug 18, 2012
  1. @ramalama
  2. @ramalama
Commits on Aug 21, 2012
  1. @ramalama

    Code Style Issues solved

    ramalama authored
  2. @ramalama

    Added correct format to test data

    ramalama authored
    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"
Commits on Aug 22, 2012
  1. @ramalama

    Fixed mistake in format string

    ramalama authored
    additionally changed the time string to a better value, where hour, min
    and seconds values differ.
This page is out of date. Refresh to see the latest.
View
18 libraries/joomla/html/html.php
@@ -821,7 +821,7 @@ public static function tooltip($tooltip, $title = '', $image = 'tooltip.png', $t
* @param string $value The date value
* @param string $name The name of the text field
* @param string $id The id of the text field
- * @param string $format The date format
+ * @param string $format The date format (strftime)
* @param array $attribs Additional HTML attributes
*
* @return string HTML markup for a calendar field
@@ -844,6 +844,14 @@ public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attri
$attribs = JArrayHelper::toString($attribs);
}
+ $timestamp = strtotime($value);
+ if ($timestamp)
+ {
+ // JHtml::date() uses dateTime->format() and can't make use of the given strftime $format
+ // As we still want to format the output date/time we use strftime here
+ $value = strftime($format, $timestamp);
+ }
+
if (!$readonly && !$disabled)
{
// Load the calendar behavior
@@ -871,15 +879,15 @@ public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attri
);
$done[] = $id;
}
- return '<input type="text" title="' . (0 !== (int) $value ? self::_('date', $value, null, null) : '') . '" name="' . $name . '" id="' . $id
+ return '<input type="text" title="' . $value . '" name="' . $name . '" id="' . $id
. '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" ' . $attribs . ' />'
. self::_('image', 'system/calendar.png', JText::_('JLIB_HTML_CALENDAR'), array('class' => 'calendar', 'id' => $id . '_img'), true);
}
else
{
- return '<input type="text" title="' . (0 !== (int) $value ? self::_('date', $value, null, null) : '')
- . '" value="' . (0 !== (int) $value ? self::_('date', $value, 'Y-m-d H:i:s', null) : '') . '" ' . $attribs
- . ' /><input type="hidden" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" />';
+ return '<input type="text" title="' . $value
+ . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" ' . $attribs . ' />'
+ . '<input type="hidden" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" />';
}
}
/**
View
4 tests/suites/unit/joomla/html/JHtmlTest.php
@@ -1367,8 +1367,8 @@ public function testCalendar()
$_SERVER['HTTP_USER_AGENT'] = 'Test Browser';
// two sets of test data
- $test_data = array('date' => '2010-05-28 00:00:00', 'friendly_date' => 'Friday, 28 May 2010',
- 'name' => 'cal1_name', 'id' => 'cal1_id', 'format' => '%Y-%m-%d',
+ $test_data = array('date' => '2010-05-28 14:12:34', 'friendly_date' => 'Friday, 28 May 2010',
+ 'name' => 'cal1_name', 'id' => 'cal1_id', 'format' => '%Y-%m-%d %H:%M:%S',
'attribs' => array()
);
Something went wrong with that request. Please try again.