Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into cint
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Aug 10, 2016
2 parents 86203ec + 7c2f0e4 commit e535339
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
16 changes: 9 additions & 7 deletions application/helpers/common_helper.php
Expand Up @@ -3867,13 +3867,17 @@ function convertDateTimeFormat($value, $fromdateformat, $todateformat)

/**
* This is a convenience function to convert any date, in any date format, to the global setting date format
*
* Check if the time shoul be rendered also
*
* @param string $sDate
* @param boolean withTime
* @return string
*/
function convertToGlobalSettingFormat($sDate)
function convertToGlobalSettingFormat($sDate,$withTime=false)
{

$sDateformatdata = getDateFormatData(Yii::app()->session['dateformat']); // We get the Global Setting date format
$usedDatetime = ($withTime===true ? $sDateformatdata['phpdate']." H:i" : $sDateformatdata['phpdate']); //return also hours and minutes if asked for
try
{
// Workaround for bug in older PHP version (confirmed for 5.5.9)
Expand All @@ -3882,14 +3886,12 @@ function convertToGlobalSettingFormat($sDate)
throw new Exception("Failed to parse date string ({$sDate})");
}
$oDate = new DateTime($sDate); // We generate the Date object (PHP will deal with the format of the string)
$sDateformatdata = getDateFormatData(Yii::app()->session['dateformat']); // We get the Global Setting date format
$sDate = $oDate->format($sDateformatdata['phpdate']); // We apply it to the Date object to generate a string date
$sDate = $oDate->format($usedDatetime); // We apply it to the Date object to generate a string date
return $sDate; // We return the string date
}
catch(Exception $e) {
$oDate = new DateTime('1/1/1980'); // We generate the Date object (PHP will deal with the format of the string)
$sDateformatdata = getDateFormatData(Yii::app()->session['dateformat']); // We get the Global Setting date format
$sDate = $oDate->format($sDateformatdata['phpdate']); // We apply it to the Date object to generate a string date
$oDate = new DateTime('1/1/1980 00:00'); // We generate the Date object (PHP will deal with the format of the string)
$sDate = $oDate->format($usedDatetime); // We apply it to the Date object to generate a string date
return $sDate; // We return the string date

}
Expand Down
14 changes: 7 additions & 7 deletions application/views/admin/token/tokenform.php
Expand Up @@ -156,7 +156,7 @@ class="YesNoDatePicker form-control"
type="text"
value="<?php echo isset($completed) ? $completed : ''?>"
name="completed-date"
data-date-format="<?php echo $dateformatdetails['jsdate'];?> HH:MM"
data-date-format="<?php echo $dateformatdetails['jsdate'];?> HH:mm"
>
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
</div>
Expand Down Expand Up @@ -289,7 +289,7 @@ class="YesNoDatePicker form-control"
type="text"
value="<?php echo isset($sent) ? $sent : ''?>"
name="sent-date"
data-date-format="<?php echo $dateformatdetails['jsdate'];?> HH:MM"
data-date-format="<?php echo $dateformatdetails['jsdate'];?> HH:mm"
>
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
</div>
Expand Down Expand Up @@ -339,7 +339,7 @@ class="YesNoDatePicker form-control"
type="text"
value="<?php echo isset($remindersent) ? $remindersent : ''?>"
name="remind-date"
data-date-format="<?php echo $dateformatdetails['jsdate'];?> HH:MM"
data-date-format="<?php echo $dateformatdetails['jsdate'];?> HH:mm"
>
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
</div>
Expand Down Expand Up @@ -374,12 +374,12 @@ class="YesNoDatePicker form-control"
<?php
if( isset($validfrom) && $validfrom!='N')
{
$validfrom = convertToGlobalSettingFormat($validfrom);
$validfrom = convertToGlobalSettingFormat($validfrom,true);
}

if( isset($validuntil) && $validuntil!='N')
{
$validuntil = convertToGlobalSettingFormat($validuntil);
$validuntil = convertToGlobalSettingFormat($validuntil,true);
}

?>
Expand All @@ -394,7 +394,7 @@ class="YesNoDatePicker form-control"
type="text"
value="<?php echo isset($validfrom) ? $validfrom : ''?>"
name="validfrom"
data-date-format="<?php echo $dateformatdetails['jsdate'];?> HH:MM"
data-date-format="<?php echo $dateformatdetails['jsdate'];?> HH:mm"
data-locale="<?php echo convertLStoDateTimePickerLocale(Yii::app()->session['adminlang']);?>"
>
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
Expand All @@ -411,7 +411,7 @@ class="YesNoDatePicker form-control"
type="text"
value="<?php echo isset($validuntil) ? $validuntil : ''?>"
name="validuntil"
data-date-format="<?php echo $dateformatdetails['jsdate'];?> HH:MM"
data-date-format="<?php echo $dateformatdetails['jsdate'];?> HH:mm"
data-locale="<?php echo convertLStoDateTimePickerLocale(Yii::app()->session['adminlang']);?>"
>
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
Expand Down

0 comments on commit e535339

Please sign in to comment.