You are here

public function DatexObject::setDate in Datex 7

Same name and namespace in other branches
  1. 7.2 datex_api/datex_api.class.inc \DatexObject::setDate()

Sets date and time zone.

File

datex_api/datex_api_classes.inc, line 725
API and helper functions used by other datex modules.

Class

DatexObject
This class is Jalali equivilant of php DateTime. It also has some functionallity from object defiend in Drupal's date module DateObject.

Code

public function setDate($year = NULL, $month = NULL, $day = NULL, $tz = NULL) {
  if (!$year) {
    $year = $this
      ->format('Y');
  }
  if (!$mont) {
    $month = $this
      ->format('n');
  }
  if (!$day) {
    $day = $this
      ->format('j');
  }
  $date = DatexFormatter::toGregorian($year, $month, $day);
  $this
    ->xsetDate($date['year'], $date['month'], $date['day']);
  if ($tz = DatexFormatter::getTzObject($tz)) {
    $this
      ->setTimezone($tz);
  }
  return $this;
}