public function testConvertToXpDateFormat() { $formatStr = 'Y-m-d'; $xpFormatStr = 'yyyy-MM-dd'; $this->assertEquals($xpFormatStr, LocaleUtil::convertToXpDateFormat($formatStr)); $formatStr = 'y-m-d'; $xpFormatStr = 'yy-MM-dd'; $this->assertEquals($xpFormatStr, LocaleUtil::convertToXpDateFormat($formatStr)); $formatStr = 'Y-n-d'; $xpFormatStr = 'yyyy-M-dd'; $this->assertEquals($xpFormatStr, LocaleUtil::convertToXpDateFormat($formatStr)); $formatStr = 'Y-m-j'; $xpFormatStr = 'yyyy-MM-d'; $this->assertEquals($xpFormatStr, LocaleUtil::convertToXpDateFormat($formatStr)); $formatStr = 'H:i:s'; $xpFormatStr = 'HH:mm:ss'; $this->assertEquals($xpFormatStr, LocaleUtil::convertToXpDateFormat($formatStr)); $formatStr = 'h:i:s'; $xpFormatStr = 'hh:mm:ss'; $this->assertEquals($xpFormatStr, LocaleUtil::convertToXpDateFormat($formatStr)); $formatStr = 'G:i:s'; $xpFormatStr = 'H:mm:ss'; $this->assertEquals($xpFormatStr, LocaleUtil::convertToXpDateFormat($formatStr)); $formatStr = 'g:i:s'; $xpFormatStr = 'h:mm:ss'; $this->assertEquals($xpFormatStr, LocaleUtil::convertToXpDateFormat($formatStr)); $formatStr = 'Y-m-d H:i'; $xpFormatStr = 'yyyy-MM-dd HH:mm'; $this->assertEquals($xpFormatStr, LocaleUtil::convertToXpDateFormat($formatStr)); }
break; case Timesheet::TIMESHEET_STATUS_APPROVED: $statusStr = $lang_Time_Timesheet_Status_Approved; break; case Timesheet::TIMESHEET_STATUS_REJECTED: $statusStr = $lang_Time_Timesheet_Status_Rejected; break; } $startDate = strtotime($timesheet->getStartDate() . " 00:00:00"); $endDate = strtotime($timesheet->getEndDate() . " 23:59:59"); $startDatePrint = LocaleUtil::getInstance()->formatDateTime(date("Y-m-d H:i", $startDate)); $endDatePrint = LocaleUtil::getInstance()->formatDateTime(date("Y-m-d H:i", $endDate)); $row = 0; $sysConf = new sysConf(); $dateFormat = LocaleUtil::convertToXpDateFormat($sysConf->getDateFormat()); $timeFormat = LocaleUtil::convertToXpDateFormat($sysConf->getTimeFormat()); ?> <style type="text/css"> .tableTopLeft { background: none; } .tableTopMiddle { background: none; } .tableTopRight { background: none; } .tableMiddleLeft { background: none; } .tableMiddleRight {
/** * String time will be converted from the custom format to YYY-mm-dd HH:MM * * Right now only English dates will be convered. * * @param String time * @param String customFormat (Optional) * @return String standardDate time */ public function convertToStandardDateTimeFormat($time, $customFormat = null) { if ($customFormat == null) { $format = LocaleUtil::convertToXpDateFormat("{$this->sysConf->getDateFormat()} {$this->sysConf->getTimeFormat()}"); } else { $format = LocaleUtil::convertToXpDateFormat($customFormat); } $timeStamp = $this->_customFormatStringToTimeStamp($time, $format); if (!$timeStamp) { return null; } $standardDate = date(self::STANDARD_DATETIME_FORMAT, $timeStamp); return $standardDate; }