Example #1
0
 /**
  * @param $format
  * @param $date
  * @param $y
  * @param $m
  * @param $d
  * @param $h
  * @param $i
  * @param $s
  *
  * @dataProvider provideJDateTimeFormats
  */
 public function test_format_string_to_JDateTime($format, $date, $y, $m, $d, $h, $i, $s)
 {
     $j1 = JalaliParser::createJalaliFromFormat($format, $date, true);
     $j2 = JalaliParser::createJDateTimeFromFormat($format, $date);
     $j3 = new JDateTime($y, $m, $d, $h, $i, $s);
     $j4 = JDateTime::fromFormat($format, $date);
     $this->assertEquals($j3, $j1);
     $this->assertEquals($j3, $j2);
     $this->assertEquals($j3, $j4);
 }
Example #2
0
 /**
  * @param string $format
  * @param string $rule
  *
  * @return string
  */
 protected function defaultSampleDate($format, $rule)
 {
     return preg_match('/^jalali/', $rule) ? JalaliDate::fromDateTime(new DateTime())->format($format, false) : JDateTime::fromDateTime(new DateTime())->format($format, false);
 }
Example #3
0
 /**
  * @param DateTime  $dateTime
  * @param JDateTime $jDateTime
  *
  * @dataProvider provideDateTimeJDateTime
  */
 public function test_j_date_time_from_date_time(DateTime $dateTime, JDateTime $jDateTime)
 {
     $this->assertEquals($jDateTime, JDateTime::fromDateTime($dateTime));
     $this->assertEquals($jDateTime, DateConverter::dateTimeToJDateTime($dateTime));
 }
Example #4
0
 public function test_convert_to_date_time_with_time_being_set()
 {
     $jDate = new JDateTime('1394', '9', '9', 15, 25, 56);
     $this->assertEquals('2015-11-30 15:25:56', $jDate->toDateTime()->format('Y-m-d H:i:s'));
     $this->assertEquals('2015-11-30 15:25:56', DateConverter::jalaliToDateTime($jDate)->format('Y-m-d H:i:s'));
 }