File dsl/standard/StandardDate.class.php
Last commit: Tue Jul 19 00:10:39 2022 +0200 Jan Dankert Fetched from upstream.
1 <?php 2 namespace dsl\standard; 3 4 use dsl\context\BaseScriptableObject; 5 6 class StandardDate extends BaseScriptableObject 7 { 8 /** 9 * Date.now() 10 * 11 * milliseconds since 1970. 12 * 13 * @return int 14 */ 15 public function now() { 16 17 return floor(microtime(true) * 1000); 18 } 19 20 21 /** 22 * @param int $year year 23 * @param int $month month 0-based 24 * @param int $day day of month 25 * @param int $hour hour 26 * @param int $minute minute 27 * @param int $second second 28 * @return Date 29 */ 30 public function __invoke( $year = 0,$month = 0,$day = 0,$hour = 0,$minute = 0,$second = 0 ) 31 { 32 if ( is_string($year) ) 33 return new Date( strtotime($year) ); 34 35 if ( is_numeric($year) && $year && !$month ) 36 return new Date( floor($year/1000) ); 37 38 $month++; // month in JS is 0-based, but in PHP 1-based. 39 40 if ( is_numeric($year) && $year ) 41 return new Date( mktime( $hour, $minute, $second, $month, $day, $year ) ); 42 43 return new Date(); 44 } 45 46 /** 47 * Gets the current date object. 48 * @return Date 49 */ 50 public function getDate( $date = null ) { 51 52 return new Date( $date ); 53 } 54 55 56 57 public function __toString() 58 { 59 return "Date"; 60 } 61 62 public function help() 63 { 64 return Helper::getHelp($this); 65 } 66 67 68 public function parse( $dateAsString ) { 69 70 return strtotime( $dateAsString ) * 1000; 71 } 72 }
Downloaddsl/standard/StandardDate.class.php
History Tue, 19 Jul 2022 00:10:39 +0200 Jan Dankert Fetched from upstream. Mon, 27 Jun 2022 00:41:50 +0200 Jan Dankert Fetched from upstream. Mon, 6 Jun 2022 14:06:46 +0200 Jan Dankert First commit after fetching from upstream repo.