Convert a datetime from one chronology to another.
348050
private static long convertByYear(long instant, Chronology from, Chronology to) {
        return to.getDateTimeMillis
            (from.year().get(instant),
             from.monthOfYear().get(instant),
             from.dayOfMonth().get(instant),
             from.millisOfDay().get(instant));
    }
182596
def ms_to_datetime(ms, tzinfo=None):
    """"""
    if not isinstance(ms, (int, long)):
        raise TypeError('expected integer, not %s' % type(ms))

    if tzinfo is None:
        tzinfo = mktz()

    return datetime.datetime.fromtimestamp(ms * 1e-3, tzinfo)
68317
public static final <T extends Date> Function<T, LocalDate> dateToLocalDate(Chronology chronology) {
		return new DateToLocalDate<T>(chronology);
	}
233633
def from_bs_date(cls, year, month, day):
        
        return NepDate(year, month, day).update()
1161540
def timestamp_to_datetime(cls, dt, dt_format=DATETIME_FORMAT):
        """"""
        return cls.convert_datetime(cls.get_datetime(dt), dt_format=dt_format)
168308
public static final <T extends Calendar> Function<T, DateMidnight> calendarToDateMidnight(Chronology chronology) {
		return FnDateMidnight.calendarToDateMidnight(chronology);
	}
377430
public static final <T extends Date> Function<T, DateMidnight> dateToDateMidnight(Chronology chronology) {
		return FnDateMidnight.dateToDateMidnight(chronology);
	}
520581
def datetimes(self):
        """"""
        if self._timestamps_data is None:
            self._calculate_timestamps()
        return tuple(DateTime.from_moy(moy, self.is_leap_year)
                     for moy in self._timestamps_data)
806988
def datetime_to_ms(d):
    """"""
    try:
        millisecond = d.microsecond // 1000
        return calendar.timegm(_add_tzone(d).utctimetuple()) * 1000 + millisecond
    except AttributeError:
        raise TypeError('expect Python datetime object, not %s' % type(d))
1157549
private static long dateTimeDifference(final Temporal d1, final Temporal d2) {
      return ChronoUnit.SECONDS.between(d1, d2);
  }
238716
def _strip_datetime(self, sub_line):
        """"""
        try:
            begin = sub_line.index(']')
        except ValueError:
            return sub_line
        else:
            # create a "" in place character for the beginnings..
            # needed when interleaving the lists
            sub = sub_line[begin + 1:]
            return sub
757869
public static final <T extends Calendar> Function<T, LocalDate> calendarToLocalDate(Chronology chronology) {
		return new CalendarToLocalDate<T>(chronology);
	}
635483
def convert_rtc(cls, timestamp):
        """"""

        if timestamp & (1  << 31):
            timestamp &= ~(1 << 31)

        delta = datetime.timedelta(seconds=timestamp)
        return cls._Y2KReference + delta
32652
private static long convertByWeekyear(final long instant, Chronology from, Chronology to) {
        long newInstant;
        newInstant = to.weekyear().set(0, from.weekyear().get(instant));
        newInstant = to.weekOfWeekyear().set(newInstant, from.weekOfWeekyear().get(instant));
        newInstant = to.dayOfWeek().set(newInstant, from.dayOfWeek().get(instant));
        newInstant = to.millisOfDay().set(newInstant, from.millisOfDay().get(instant));
        return newInstant;
    }
649792
def date_to_datetime(d):
    
    if not isinstance(d, datetime):
        d = datetime.combine(d, datetime.min.time())
    return d
192539
def datetime2ole(dt):
    """"""
    delta = dt - OLE_TIME_ZERO
    delta_float = delta / datetime.timedelta(days=1)  # trick from SO
    return delta_float
584583
def to_datetime(timestamp):
    """"""
    return dt.fromtimestamp(time.mktime(
        time.localtime(int(str(timestamp)[:10]))))