You are here

public function DatexObject::__construct in Datex 7

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

Constructor for DatexObject.

Parameters

mixed $datetime: Given date/time

bool $is_gregorian: Indicates wheter given date to constructor is Gregorian or not, default is set by a constant in module file.

DateTimezone $tz: DateTimeZone to use.

string $format: format used for formatting date.

File

datex_api/datex_api_classes.inc, line 642
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 __construct($datetime = NULL, $is_gregorian = DATEX_GREGORIAN, $tz = NULL, $format = NULL) {
  $this->hasError = FALSE;
  $this->error = '';
  $this->errorMessage = '';
  $this
    ->setDatetime($datetime, $is_gregorian, $tz);
  $format = $format ? $format : 'Y-m-d';
  $this
    ->setFormat($format);
  $tz = DatexFormatter::getTzObject($tz);
  if ($tz instanceof DateTimeZone) {
    $this->dateobj
      ->setTimezone($tz);
  }
  return $this;
}