mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-20781 lib/excellib: add write_date() function
This commit is contained in:
parent
b7f6d23553
commit
07ca3a4acf
1 changed files with 17 additions and 0 deletions
|
@ -197,6 +197,23 @@ class MoodleExcelWorksheet {
|
||||||
$this->pear_excel_worksheet->writeUrl($row, $col, $url, $format);
|
$this->pear_excel_worksheet->writeUrl($row, $col, $url, $format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write one date somewhere in the worksheet
|
||||||
|
* @param integer $row Zero indexed row
|
||||||
|
* @param integer $col Zero indexed column
|
||||||
|
* @param string $date The date to write in UNIX timestamp format
|
||||||
|
* @param mixed $format The XF format for the cell
|
||||||
|
*/
|
||||||
|
function write_date($row, $col, $date, $format=null) {
|
||||||
|
/// Calculate the internal PEAR format
|
||||||
|
$format = $this->MoodleExcelFormat2PearExcelFormat($format);
|
||||||
|
/// Convert the date to Excel format
|
||||||
|
$timezone = get_user_timezone_offset();
|
||||||
|
$value = ((usertime($date) + (int)($timezone * HOURSECS * 2)) / 86400) + 25569;
|
||||||
|
/// Add the date safely to the PEAR Worksheet
|
||||||
|
$this->pear_excel_worksheet->writeNumber($row, $col, $value, $format);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write one formula somewhere in the worksheet
|
* Write one formula somewhere in the worksheet
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue