Exemple #1
0
 def local_time_to_julian_day(self, date):
   microseconds, _ = modf(zero_if_none(date.second) * 1000000)
   local_datetime = pytz.timezone(self.timezone_id).localize(
     datetime.datetime(date.year, date.month, date.day, zero_if_none(date.hour), zero_if_none(date.minute), int(zero_if_none(date.second)), int(microseconds)))
   tm = Time(local_datetime, format="datetime")
   tm.format = "jd"
   return tm.value
Exemple #2
0
 def to_datetime(self):
     return datetime.datetime(year=self.year,
                              month=self.month,
                              day=self.day,
                              hour=zero_if_none(self.hour),
                              minute=zero_if_none(self.minute),
                              second=int(zero_if_none(self.second)),
                              microsecond=self.get_microseconds())
Exemple #3
0
def utc_gregorian_to_jd(date):
    if date.hour is None:
        date.set_time_to_day_start()
    tm = Time(
        {
            "year": date.year,
            "month": date.month,
            "day": date.day,
            "hour": zero_if_none(date.hour),
            "minute": zero_if_none(date.minute),
            "second": zero_if_none(date.second)
        },
        format='ymdhms')
    tm.format = "jd"
    return tm.value
Exemple #4
0
 def get_microseconds(self):
     return int(zero_if_none(self.second) * 1e6 % 1e6)
Exemple #5
0
 def get_fractional_hour(self):
     return zero_if_none(self.hour) + zero_if_none(
         self.minute) / 60.0 + zero_if_none(self.second) / 3600.0