| Project: | ProjectPier |
| Version: | 0.8.6-beta3 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | phpfreak |
| Status: | closed - fixed |
Jump to:
Description
On my installation of 8.6 beta 3, when logging time with the time plugin the date for each log returns 01/01/1970 even though I entered the correct date to begin with.
Confirmed. Solution will be in Release Candidate 1 (tomorrow).
Fix /application/plugins/time/TimeController.class.php
In function add() and function edit() replace
$time_data['done_date'] = DateTimeValueLib::make(0, 0, 0, array_var($_POST, 'time_done_date_month', 1), array_var($_POST, 'time_done_date_day', 1), array_var($_POST, 'time_done_date_year', 1970));with
if (isset($_POST['time_done_date'])) {$time_data['done_date'] = DateTimeValueLib::makeFromString($_POST['time_done_date']);
} else {
$time_data['done_date'] = DateTimeValueLib::make(0, 0, 0, array_var($_POST, 'time_done_date_month', 1), array_var($_POST, 'time_done_date_day', 1), array_var($_POST, 'time_done_date_year', 1970));
}
( ABOUT PP0.8.8 stable )
I would like to point out that in the time plugin, add() method, if the date format is dd - mm - yyyy ( when lang is "it", for example ) , the strtotime() fails and returns a null timestamp, which causes an error and method return a null value!!!
CODE: ( start row 43, Time controller class )
static function makeFromString($str) {
$timestamp = strtotime($str);// + date('Z'); //ERROR FOR gg-mm-aaaa format!
$date = (($timestamp === false) || ($timestamp === -1)) ? null : new DateTimeValue($timestamp);
return $date;
} // makeFromString
And yet, if I am creating a new time, and current language is Italian, when I choose a date from the form calendar , this value is entered in the date field:
it_it(input 13ate f13r1at)
How can I fix this bug? Thank you.
So, I analyzed the problem.
The dates error in Time plugin is generated when I create and / or modify a project time.
Everything starts from the client side date format .
In practice, the date format is well-managed client side, but not server-side ( when try to save the $_POST['done_date'] value in the Time controller ( add/edit methods ).
To solve ( with a simple patch ;) ) the problem of wrong time creation , I changed the following lines of code
( row 143 Time plugin controller, add() method )
$time_data = array(
'done_date' => DateTimeValueLib::now(),
with:
$time_data = array(
'done_date' => '',
and in my general lang file I have replaced the italian translation of short months with english short months
'month short 1' => 'Jan',
'month short 2' => 'Feb',
'month short 3' => 'Mar',
'month short 4' => 'Apr',
'month short 5' => 'May',
'month short 6' => 'Jun',
'month short 7' => 'Jul',
'month short 8' => 'Aug',
'month short 9' => 'Sep',
'month short 10' => 'Oct',
'month short 11' => 'Nov',
'month short 12' => 'Dec',
so the server-side date localization functions sounds good!
If you have better solutions, join this discussion! ;-)
Thanks.
I have the same problem described here about date entry when the locale is not the default one (i am using french translatation).
The Date Picker leads to fr_fr(input 25ate f17r1at) instead of 25 Jan 2012.
I am using version 0.8.8
I'have tried your hack, but no success...
0.8.8 added language item 'input date format' to control date input format.
This text fr_fr(input 25ate f17r1at) tells me that the fr_fr language files is missing this item. Simply add an item using the characters mentioned here: http://nl3.php.net/manual/en/function.date.php. Check the en_us files (general.php i think) for an example.