Set default timezone and datetime format for model
962474
public function init()
    {
        parent::init();

        $this->datetimeFormat = (empty(Yii::$app->params['site']->datetimeFormat)) ? $this->datetimeFormat : Yii::$app->params['site']->datetimeFormat;
        $this->timezone = (empty(Yii::$app->params['site']->timezone)) ? $this->timezone : Yii::$app->params['site']->timezone;
    }
2714
public static function store_default_php_timezone() {
        if ((defined('PHPUNIT_TEST') and PHPUNIT_TEST)
            or defined('BEHAT_SITE_RUNNING') or defined('BEHAT_TEST') or defined('BEHAT_UTIL')) {
            // We want all test sites to be consistent by default.
            self::$defaultphptimezone = 'Australia/Perth';
            return;
        }
        if (!isset(self::$defaultphptimezone)) {
            self::$defaultphptimezone = date_default_timezone_get();
        }
    }
1179963
def set_datetime(self, section, option, value):
        
        self[section][option] = value.strftime(self.DATETIME_FMT)
654929
@Override
  public void format(ZonedDateTime datetime, CalendarFormatOptions options, StringBuilder buffer) {
    String dateSkeleton = options.dateSkeleton() == null ? null : options.dateSkeleton().skeleton();
    String timeSkeleton = options.timeSkeleton() == null ? null : options.timeSkeleton().skeleton();

    CalendarFormat wrapperFormat = options.wrapperFormat();
    CalendarFormat dateFormat = options.dateFormat();
    CalendarFormat timeFormat = options.timeFormat();
    if (wrapperFormat != null) {
      // If wrapper is set it implies we want to output both a date and a time. If either is unset
      // we need to set it to the wrapper's format, unless a skeleton is defined.
      dateFormat = dateFormat != null ? dateFormat : (dateSkeleton == null ? wrapperFormat : null);
      timeFormat = timeFormat != null ? timeFormat : (timeSkeleton == null ? wrapperFormat : null);
    } else {
      // If wrapper is null, attempt to default it using the date's format or SHORT.
      if ((dateFormat != null || dateSkeleton != null) && (timeFormat != null || timeSkeleton != null)) {
        wrapperFormat = dateFormat != null ? dateFormat : CalendarFormat.SHORT;
      }
    }

    if (wrapperFormat != null) {
      formatWrapped(wrapperFormat, dateFormat, timeFormat, dateSkeleton, timeSkeleton, datetime, buffer);
      
    } else if (options.dateFormat() != null) {
      formatDate(options.dateFormat(), datetime, buffer);

    } else if (options.timeFormat() != null) {
      formatTime(options.timeFormat(), datetime, buffer);
    
    } else {
      String skeleton = dateSkeleton != null ? dateSkeleton : timeSkeleton;

      // If every property is null, fall back to this default "yMd"
      if (skeleton == null) {
        skeleton = CalendarSkeleton.yMd.skeleton();
      }
      formatSkeleton(skeleton, datetime, buffer);
    }
  }
1078256
function( dateString, format ) {

			this.clear();
			this.setFormat(format);

			var parts = [],
				tzArray = [],
				position = 0,
				datePart = '',
				timePart = '',
				timeZonePart = '';


			// discover date time separtor for auto profile
			// Set to 'T' by default
			if(dateString.indexOf('t') > -1) {
				this.autoProfile.sep = 't';
			}
			if(dateString.indexOf('z') > -1) {
				this.autoProfile.tzZulu = 'z';
			}
			if(dateString.indexOf('Z') > -1) {
				this.autoProfile.tzZulu = 'Z';
			}
			if(dateString.toUpperCase().indexOf('T') === -1) {
				this.autoProfile.sep = ' ';
			}


			dateString = dateString.toUpperCase().replace(' ','T');

			// break on 'T' divider or space
			if(dateString.indexOf('T') > -1) {
				parts = dateString.split('T');
				datePart = parts[0];
				timePart = parts[1];

				// zulu UTC
				if(timePart.indexOf( 'Z' ) > -1) {
					this.z = true;
				}

				// timezone
				if(timePart.indexOf( '+' ) > -1 || timePart.indexOf( '-' ) > -1) {
					tzArray = timePart.split( 'Z' ); // incase of incorrect use of Z
					timePart = tzArray[0];
					timeZonePart = tzArray[1];

					// timezone
					if(timePart.indexOf( '+' ) > -1 || timePart.indexOf( '-' ) > -1) {
						position = 0;

						if(timePart.indexOf( '+' ) > -1) {
							position = timePart.indexOf( '+' );
						} else {
							position = timePart.indexOf( '-' );
						}

						timeZonePart = timePart.substring( position, timePart.length );
						timePart = timePart.substring( 0, position );
					}
				}

			} else {
				datePart = dateString;
			}

			if(datePart !== '') {
				this.parseDate( datePart );
				if(timePart !== '') {
					this.parseTime( timePart );
					if(timeZonePart !== '') {
						this.parseTimeZone( timeZonePart );
					}
				}
			}
			return this.toString( this.format );
		}
225971
def timezone(self, value):
        """"""
        self._timezone = (value if isinstance(value, datetime.tzinfo)
                          else tz.gettz(value))
1112270
def formfield(self, **kwargs):
        """"""

        defaults = {'form_class': forms.TimeZoneField}
        defaults.update(**kwargs)
        return super(TimeZoneField, self).formfield(**defaults)
889517
def set_time_zone(time_zone)
      time_response = rest_get('/redfish/v1/Managers/1/DateTime/')
      new_time_zone = response_handler(time_response)['TimeZoneList'].select { |timezone| timezone['Name'] == time_zone }
      new_action = { 'TimeZone' => { 'Index' => new_time_zone[0]['Index'] } }
      response = rest_patch('/redfish/v1/Managers/1/DateTime/', body: new_action)
      response_handler(response)
      true
    end
1364930
function formatDate(date) {
            let settings = dateFormat || defaultAxisSettings;
            let format = null;
            let localeOptions = {month:'short', day:'numeric'};

            if (settings === axisTimeCombinations.DAY_MONTH || settings === axisTimeCombinations.MONTH_YEAR) {
                format = monthDayYearFormat;
                localeOptions.year = 'numeric';
            } else if (settings === axisTimeCombinations.HOUR_DAY || settings === axisTimeCombinations.MINUTE_HOUR) {
                format = monthDayHourFormat;
                localeOptions.hour = 'numeric';
            } else if (settings === axisTimeCombinations.CUSTOM && typeof dateCustomFormat === 'string') {
                format = d3TimeFormat.timeFormat(dateCustomFormat);
            }

            if (locale && ((typeof Intl !== 'undefined') && (typeof Intl === 'object' && Intl.DateTimeFormat))) {
                let f = Intl.DateTimeFormat(locale, localeOptions);

                return f.format(date);
            }

            return format(date);
        }
612988
private void populateDateTimeSettings(Record record, ProjectProperties properties)
   {
      properties.setDateOrder(record.getDateOrder(0));
      properties.setTimeFormat(record.getTimeFormat(1));

      Date time = getTimeFromInteger(record.getInteger(2));
      if (time != null)
      {
         properties.setDefaultStartTime(time);
      }

      Character c = record.getCharacter(3);
      if (c != null)
      {
         properties.setDateSeparator(c.charValue());
      }

      c = record.getCharacter(4);
      if (c != null)
      {
         properties.setTimeSeparator(c.charValue());
      }

      properties.setAMText(record.getString(5));
      properties.setPMText(record.getString(6));
      properties.setDateFormat(record.getDateFormat(7));
      properties.setBarTextDateFormat(record.getDateFormat(8));
   }
70114
def localize(self, dt, is_dst=False):
        """"""
        if dt.tzinfo is not None:
            raise ValueError('Not naive datetime (tzinfo is already set)')
        return dt.replace(tzinfo=self)
653374
function parseDataToDateTime(parsed, parsedZone, opts, format, text) {
  const { setZone, zone } = opts;
  if (parsed && Object.keys(parsed).length !== 0) {
    const interpretationZone = parsedZone || zone,
      inst = DateTime.fromObject(
        Object.assign(parsed, opts, {
          zone: interpretationZone,
          // setZone is a valid option in the calling methods, but not in fromObject
          setZone: undefined
        })
      );
    return setZone ? inst : inst.setZone(zone);
  } else {
    return DateTime.invalid(
      new Invalid("unparsable", `the input "${text}" can't be parsed as ${format}`)
    );
  }
}
981383
def store(self, value, context=None):
        
        if isinstance(value, datetime.datetime):
            # ensure we have some timezone information before converting to UTC time
            if value.tzinfo is None:
                # match the server information
                tz = pytz.timezone(orb.system.settings().server_timezone)
                value = tz.localize(value)
            value = value.astimezone(pytz.utc).replace(tzinfo=None)
        return super(DatetimeWithTimezoneColumn, self).store(value, context=context)
93407
private function setTimezones()
    {
        foreach(\DateTimeZone::listIdentifiers() as $identifier) {
            $key = strtolower(str_replace('/', '_', $identifier));
            $this->valueOptions[] = new Option($key, $identifier);
        }
    }
1279262
public function setTimeZone() {
        $timezone = \Yii::$app->session->get($this->timezoneSessionKey);
        if ($timezone === null) {
            $timezone = \Yii::$app->request->cookies->getValue($this->timezoneCookieName);
            \Yii::$app->formatter->timeZone = $timezone;
        } else {
            \Yii::$app->formatter->timeZone = $timezone;
        }

    }
697180
protected function changeTimezone()
    {
        $this->previousTimezone=false;
        if ($this->timezone) {
            $this->previousTimezone=date_default_timezone_get();
            date_default_timezone_set($this->timezone);
        }
    }
16018
public static DateTime toDateTime(Locale locale, String str, TimeZone tz, DateTime defaultValue, boolean useCommomDateParserAsWell) {
	str = str.trim();
	tz = ThreadLocalPageContext.getTimeZone(tz);
	DateFormat[] df;

	// get Calendar
	Calendar c = JREDateTimeUtil.getThreadCalendar(locale, tz);

	// datetime
	ParsePosition pp = new ParsePosition(0);
	df = FormatUtil.getDateTimeFormats(locale, tz, false);// dfc[FORMATS_DATE_TIME];
	Date d;
	for (int i = 0; i < df.length; i++) {
	    SimpleDateFormat sdf = (SimpleDateFormat) df[i];
	    // print.e(sdf.format(new Date(108,3,6,1,2,1)) + " : "+sdf.toPattern());
	    pp.setErrorIndex(-1);
	    pp.setIndex(0);
	    sdf.setTimeZone(tz);
	    d = sdf.parse(str, pp);
	    if (pp.getIndex() == 0 || d == null || pp.getIndex() < str.length()) continue;

	    optimzeDate(c, tz, d);
	    return new DateTimeImpl(c.getTime());
	}

	// date
	df = FormatUtil.getDateFormats(locale, tz, false);
	for (int i = 0; i < df.length; i++) {
	    SimpleDateFormat sdf = (SimpleDateFormat) df[i];
	    // print.e(sdf.format(new Date(108,3,6,1,2,1)) + " : "+sdf.toPattern());
	    pp.setErrorIndex(-1);
	    pp.setIndex(0);
	    sdf.setTimeZone(tz);
	    d = sdf.parse(str, pp);
	    if (pp.getIndex() == 0 || d == null || pp.getIndex() < str.length()) continue;
	    optimzeDate(c, tz, d);
	    return new DateTimeImpl(c.getTime());
	}

	// time
	df = FormatUtil.getTimeFormats(locale, tz, false);// dfc[FORMATS_TIME];
	for (int i = 0; i < df.length; i++) {
	    SimpleDateFormat sdf = (SimpleDateFormat) df[i];
	    // print.e(sdf.format(new Date(108,3,6,1,2,1))+ " : "+sdf.toPattern());
	    pp.setErrorIndex(-1);
	    pp.setIndex(0);
	    sdf.setTimeZone(tz);
	    d = sdf.parse(str, pp);
	    if (pp.getIndex() == 0 || d == null || pp.getIndex() < str.length()) continue;
	    c.setTimeZone(tz);
	    c.setTime(d);
	    c.set(Calendar.YEAR, 1899);
	    c.set(Calendar.MONTH, 11);
	    c.set(Calendar.DAY_OF_MONTH, 30);
	    c.setTimeZone(tz);
	    return new DateTimeImpl(c.getTime());
	}

	if (useCommomDateParserAsWell) return DateCaster.toDateSimple(str, CONVERTING_TYPE_NONE, true, tz, defaultValue);
	return defaultValue;
    }