/*
A Symfony form sends datetime back in UTC timezone,
because no timezone string has been provided with the posted data.
358318
public function modifyTimezoneOffset(\DateTime $dateTime){
        $userTimezone = new \DateTimeZone($this->container->get('session')->get('campaignchain.timezone'));
        $offset = $userTimezone->getOffset($dateTime);
        return $dateTime->modify('-'.$offset.' sec');
    }
2136
private function getRFC1123DateString() {
        $date = new \DateTime(null, new \DateTimeZone("UTC"));
        return str_replace("+0000", "GMT", $date->format(\DateTime::RFC1123));
    }
257138
public function getSaveTimeZone()
    {
        if (empty($this->_saveTimeZone)) {
            if (!empty(Yii::$app->params['dateControlSaveTimezone'])) {
                $this->_saveTimeZone = Yii::$app->params['dateControlSaveTimezone'];
            } else {
                $this->_saveTimeZone = Yii::$app->getTimeZone();
            }
        }
        
        return $this->_saveTimeZone;
    }
155213
protected function _getUTCDate($time = null)
    {
        if ($time instanceof DateTimeInterface) {
            $result = clone $time;
        } elseif (is_int($time)) {
            $result = new DateTime(date('Y-m-d H:i:s', $time));
        } else {
            $result = new DateTime($time);
        }

        return $result->setTimezone(new DateTimeZone('UTC'));
    }
297790
public function getDeletedAtDatetime(string $timezone = null): ?DateTime
    {
        if (!$this->isDeleted()) {
            return null;
        }

        return new DateTime($this->getDeletedAt(), new DateTimeZone($timezone ?? 'UTC'));
    }
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;
    }
280232
def date_struct(year, month, day, tz = "UTC"):
    
    ymdtz = (year, month, day, tz)
    if None in ymdtz:
        #logger.debug("a year, month, day or tz value was empty: %s" % str(ymdtz))
        return None # return early if we have a bad value
    try:
        return time.strptime("%s-%s-%s %s" % ymdtz,  "%Y-%m-%d %Z")
    except(TypeError, ValueError):
        #logger.debug("date failed to convert: %s" % str(ymdtz))
        pass
1354184
public function getTimeZone() {
        $tzs = $this->user->getPropertyValues(GenerisRdf::PROPERTY_USER_TIMEZONE);
        $tz = empty($tzs) ? '' : (string)current($tzs);
        return empty($tz) ? TIME_ZONE : $tz;
    }
1328369
public function getUpdatedAtDatetime(string $timezone = null): ?DateTime
    {
        if (!$this->hasUpdatedAt()) {
            return null;
        }

        if ($timezone === null) {
            $timezone = 'UTC';
        }

        return new DateTime($this->getUpdatedAt(), new DateTimeZone($timezone));
    }
612428
public function setDateFromDateTime(DateTime $date = NULL, DateTimeZone $dateTimeZone = NULL) {
    $dateTimeZone = !empty($dateTimeZone) ? $dateTimeZone : new DateTimeZone('UTC');
    $this->date = !empty($date) ? $date : new DateTime($date);
    $this->date->setTimezone($dateTimeZone);
  }
460002
def date_to_long_form_string(dt, locale_ = 'en_US.utf8'):
    ''''''
    if locale_:
        old_locale = locale.getlocale()
        locale.setlocale(locale.LC_ALL, locale_)
    v = dt.strftime("%A %B %d %Y")
    if locale_:
        locale.setlocale(locale.LC_ALL, old_locale)
    return v
669458
public static function string2dateTime($string, \DateTimeZone $zone = null)
    {
        if (!$zone) {
            $zone = new \DateTimeZone('UTC');
        }

        $dt = new \DateTime('now', $zone);
        $dt->setTimestamp(self::string2timestamp($string));

        return $dt;
    }
219276
public function UTCTimeZoneOffset() : int
    {
        $originDateTime = new \DateTime('now', $this);

        $utcTimeZone = new \DateTimeZone('UTC');
        $utcDateTime = new \DateTime('now', $utcTimeZone);

        return $utcTimeZone->getOffset($utcDateTime) - $this->getOffset($originDateTime);
    }
940030
private void _serializeDateTime(DateTime dateTime, StringBuilder sb) {

	sb.append(StringUtil.escapeJS(JSONDateFormat.format(dateTime, null), '"', charsetEncoder));

	/*
	 * try { sb.append(goIn()); sb.append("createDateTime(");
	 * sb.append(DateFormat.call(null,dateTime,"yyyy,m,d")); sb.append(' ');
	 * sb.append(TimeFormat.call(null,dateTime,"HH:mm:ss")); sb.append(')'); } catch (PageException e) {
	 * throw new ConverterException(e); }
	 */
	// Januar, 01 2000 01:01:01
    }
591185
private String _serializeDateTime(DateTime dateTime) {
	// try {

	String strDate = new lucee.runtime.format.DateFormat(Locale.US).format(dateTime, "yyyy-m-d", TimeZoneConstants.UTC);
	String strTime = new lucee.runtime.format.TimeFormat(Locale.US).format(dateTime, "H:m:s", TimeZoneConstants.UTC);

	return goIn() + "<dateTime>" + strDate + "T" + strTime + "+0:0" + "</dateTime>";

	/*
	 * } catch (PageException e) { throw new ConverterException(e); }
	 */
    }
40068
function validateDateTimeHTTPInput( $day, $month, $year, $hour, $minute, $second, $contentObjectAttribute )
    {
        $state = eZDateTimeValidator::validateDate( $day, $month, $year );
        if ( $state == eZInputValidator::STATE_INVALID )
        {
            $contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes',
                                                                 'Date is not valid.' ) );
            return eZInputValidator::STATE_INVALID;
        }

        $state = eZDateTimeValidator::validateTime( $hour, $minute, $second );

        if ( $state == eZInputValidator::STATE_INVALID )
        {
            $contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes',
                                                                 'Time is not valid.' ) );
            return eZInputValidator::STATE_INVALID;
        }
        return $state;
    }
492826
function vtimezone( $timezonetype=FALSE ) {
    if( !$timezonetype )
      $this->timezonetype = 'VTIMEZONE';
    else
      $this->timezonetype = strtoupper( $timezonetype );
    $this->calendarComponent();
  }