Commit ebc6c5a5 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Merge in from VM / WC: Provide more date/time variables

parent ffc9c5b2
......@@ -226,18 +226,33 @@ class OrdernumberHelper {
}
return self::randomString ($alphabet, $len);
}
public function getDateTime($utime) {
$time = new DateTime();
$time->setTimestamp($utime);
return $time;
}
public function setupDateTimeReplacements (&$reps, $details, $nrtype) {
$utime = microtime(true);
$reps["[year]"] = date ("Y", $utime);
$reps["[year2]"] = date ("y", $utime);
$reps["[month]"] = date("m", $utime);
$reps["[day]"] = date("d", $utime);
$reps["[hour]"] = date("H", $utime);
$reps["[hour12]"] = date("h", $utime);
$reps["[ampm]"] = date("a", $utime);
$reps["[minute]"] = date("i", $utime);
$reps["[second]"] = date("s", $utime);
$time = $this->getDateTime($utime);
$reps["[year]"] = $time->format ("Y");
$reps["[year2]"] = $time->format ("y");
$reps["[month]"] = $time->format("m");
$reps["[monthname]"] = $time->format("F");
$reps["[monthname3]"] = $time->format("M");
$reps["[week]"] = $time->format("W");
$reps["[weeknumberyear]"] = $time->format("o");
$reps["[day]"] = $time->format("d");
$reps["[dayofyear]"] = $time->format("z")+1;
$reps["[weekday]"] = $time->format("N");
$reps["[weekdayname3]"] = $time->format("D");
$reps["[weekdayname]"] = $time->format("l");
$reps["[hour]"] = $time->format("H");
$reps["[hour12]"] = $time->format("h");
$reps["[ampm]"] = $time->format("a");
$reps["[minute]"] = $time->format("i");
$reps["[second]"] = $time->format("s");
$milliseconds = (int)(1000*($utime - (int)$utime));
$millisecondsstring = sprintf('%03d', $milliseconds);
$reps["[decisecond]"] = $millisecondsstring[0];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment