The datetime this event first started in the local time zone, or None if
        it never did.
499913
def _first_datetime_from(self):
        
        myFromDt = self._getMyFirstDatetimeFrom()
        localTZ = timezone.get_current_timezone()
        return myFromDt.astimezone(localTZ)
221802
@SuppressWarnings("unchecked")
    public final SelfType startTime(final DateTime when, final TimeSpan jitter)
    {
        // Find the current week day in the same time zone as the "when" time passed in.
        final DateTime now = new DateTime().withZone(when.getZone());

        final int startWeekDay = when.getDayOfWeek();
        final int currentWeekDay = now.getDayOfWeek();

        // ( x + n ) % n is x for x > 0 and n - x for x < 0.
        final int daysTilStart = (startWeekDay - currentWeekDay + DAYS_PER_WEEK) % DAYS_PER_WEEK;
        Preconditions.checkState(daysTilStart >= 0 && daysTilStart < DAYS_PER_WEEK, "daysTilStart must be 0..%s, but is %s", DAYS_PER_WEEK, daysTilStart);

        // same trick as above, add a full week in millis and do the modulo.
        final long millisecondsTilStart = (when.getMillisOfDay() - now.getMillisOfDay() + daysTilStart * MILLIS_PER_DAY + MILLIS_PER_WEEK) % MILLIS_PER_WEEK;
        Preconditions.checkState(millisecondsTilStart >= 0 && millisecondsTilStart < MILLIS_PER_WEEK, "millisecondsTilStart must be 0..%s, but is %s", MILLIS_PER_WEEK, millisecondsTilStart);

        this.delay = Duration.millis((long)(ThreadLocalRandom.current().nextDouble() * jitter.getMillis()) + millisecondsTilStart);
        return (SelfType) this;
    }
713930
def local_time_to_online(dt=None):
    
    if dt is None:
        dt = datetime.datetime.now()

    is_dst = time.daylight and time.localtime().tm_isdst > 0
    utc_offset =  (time.altzone if is_dst else time.timezone)

    return (time.mktime(dt.timetuple())  * 1000) + (utc_offset *1000)
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)
678892
def date(self):
    ''' 
    '''
    localtime = datetime.date.today()
    return localtime + datetime.timedelta(hours = time.timezone/60/60 + self.TimeZone)
404695
public Interval withStartTime(LocalTime time) {
        requireNonNull(time);
        return new Interval(startDate, time, endDate, endTime, zoneId);
    }
834470
@Override  // for covariant return type
    @SuppressWarnings("unchecked")
    public ChronoLocalDateTime<InternationalFixedDate> atTime(LocalTime localTime) {
        return (ChronoLocalDateTime<InternationalFixedDate>) super.atTime(localTime);
    }
1095943
def timesince_or_never(dt, default=None):
    
    if default is None:
        default = _("Never")

    if isinstance(dt, datetime.date):
        return timesince(dt)
    else:
        return default
1285226
def utcnow(cls):
    """"""
    obj = datetime.datetime.utcnow()
    obj = cls(obj, tzinfo=pytz.utc)
    return obj
401671
def to_default_timezone_datetime(self, value):
        
        return timezone.localtime(self.to_utc_datetime(value), timezone.get_default_timezone())
880592
private TimeZoneRule findRuleInFinal(long time, boolean local, int NonExistingTimeOpt, int DuplicatedTimeOpt) {
        if (finalRules == null || finalRules.length != 2 || finalRules[0] == null || finalRules[1] == null) {
            return null;
        }

        Date start0, start1;
        long base;
        int localDelta;

        base = time;
        if (local) {
            localDelta = getLocalDelta(finalRules[1].getRawOffset(), finalRules[1].getDSTSavings(),
                    finalRules[0].getRawOffset(), finalRules[0].getDSTSavings(),
                    NonExistingTimeOpt, DuplicatedTimeOpt);
            base -= localDelta;
        }
        start0 = finalRules[0].getPreviousStart(base, finalRules[1].getRawOffset(), finalRules[1].getDSTSavings(), true);

        base = time;
        if (local) {
            localDelta = getLocalDelta(finalRules[0].getRawOffset(), finalRules[0].getDSTSavings(),
                    finalRules[1].getRawOffset(), finalRules[1].getDSTSavings(),
                    NonExistingTimeOpt, DuplicatedTimeOpt);
            base -= localDelta;
        }
        start1 = finalRules[1].getPreviousStart(base, finalRules[0].getRawOffset(), finalRules[0].getDSTSavings(), true);

        if (start0 == null || start1 == null) {
            if (start0 != null) {
                return finalRules[0];
            } else if (start1 != null) {
                return finalRules[1];
            }
            // Both rules take effect after the given time
            return null;
        }

        return start0.after(start1) ? finalRules[0] : finalRules[1];
    }
1321651
public static LocalDateTime from(long epochMillis) {
        return LocalDateTime.ofInstant(Instant.ofEpochMilli(epochMillis), ZoneOffset.UTC);
    }
821212
def ensure_timezone(dateTime,timeZone=None):
    '''
    
    '''

    if is_aware(dateTime) and not getattr(settings,'USE_TZ',False):
        return make_naive(dateTime,timezone=timeZone)
    if is_naive(dateTime) and getattr(settings,'USE_TZ',False):
        return make_aware(dateTime,timezone=timeZone)
    # If neither condition is met, then we can return what was passed
    return dateTime
991008
@Override
    @SuppressWarnings("unchecked")
    public ChronoLocalDateTime<InternationalFixedDate> localDateTime(TemporalAccessor temporal) {
        return (ChronoLocalDateTime<InternationalFixedDate>) super.localDateTime(temporal);
    }
615901
def _upcoming_datetime_from(self):
        
        nextDt = self.__localAfter(timezone.localtime(), dt.time.max,
                                   excludeCancellations=True,
                                   excludeExtraInfo=True)
        return nextDt
1151514
def start_of_day_local_time=(start_of_day_local_time)
      if start_of_day_local_time.nil?
        fail ArgumentError, "start_of_day_local_time cannot be nil"
      end

      if start_of_day_local_time.to_s.length < 1
        fail ArgumentError, "invalid value for 'start_of_day_local_time', the character length must be great than or equal to 1."
      end

      @start_of_day_local_time = start_of_day_local_time
    end
142812
def start_of_day(dtime_at=None):
    
    dtime_at = datetime_or_now(dtime_at)
    return datetime.datetime(dtime_at.year, dtime_at.month,
        dtime_at.day, tzinfo=tzlocal())