Esempio n. 1
0
def datetime64_to_date(dt64: np.datetime64) -> datetime.date:
    """Convert a np.datetime64('D') to a datetime.date"""
    return dt64.astype(datetime.date)
Esempio n. 2
0
def _represent_numpy_datetime(self, data: numpy.datetime64):
    return _represent_datetime(self, data.astype("M8[ms]").tolist())
Esempio n. 3
0
 def _get_datetime(time: np.datetime64) -> date:
     return datetime.strptime(time.astype(str)[:10], "%Y-%m-%d").date()
Esempio n. 4
0
 def offset_from_center(v: numpy.datetime64):
     return p.datetime + timedelta(microseconds=v.astype(float) *
                                   1_000_000.0)
Esempio n. 5
0
 def _grid_date(self, date: np.datetime64, shift: int):
     """Calculates the grid date immediately before or after the date
     provided"""
     if date.astype("int64") % self.dt.astype("int64") != 0:
         return date + self.dt * shift
     return date
Esempio n. 6
0
def date_to_str(d: np.datetime64) -> str:
    """Convert from np.datetime64 to str without hyphens"""
    return d.astype(str).replace("-", "")
Esempio n. 7
0
def datetime64_to_date(dt64: np.datetime64) -> datetime.date:
    """Convert a np.datetime64('D') to a datetime.date"""
    return dt64.astype(datetime.date)
 def _iso_date(date: np.datetime64) -> str:
     """Return the time formatted according to ISO."""
     return datetime.datetime.utcfromtimestamp(
         date.astype("datetime64[us]").astype("int64") *
         1e-6).isoformat() + "Z"
Esempio n. 9
0
def _iso_date(date: np.datetime64) -> str:
    """Return the time formatted according to ISO."""
    epoch = date.astype("datetime64[us]").astype(
        "int64") * 1e-6  # type: ignore
    return datetime.datetime.utcfromtimestamp(epoch).strftime(
        "%Y-%m-%dT%H:%M:%S.%fZ")
Esempio n. 10
0
 def _floor_to_dt(value: np.datetime64) -> np.datetime64:
     """Floor a datetime64 to the nearest dt."""
     integral = int(value.astype("<M8[h]").astype("int64") /
                    3)  # type: ignore
     return np.datetime64(integral * 3, "h")