Exemple #1
0
    def __init__(self, x, unit=None, timezone=None, casting='same_kind'):
        # Get the unit from the dtype
        if unit is None:
            if x.dtype.kind == 'M':
                unit = datetime_data(x.dtype)[0]
            else:
                unit = 's'

        # If timezone is default, make it 'naive' or 'UTC' depending on
        # the numpy version
        if timezone is None and numpy.__version__ >= LooseVersion("1.11"):
            timezone = "naive"
        else:
            timezone = "UTC"
        self.timezone = timezone
        self.unit = unit
        self.casting = casting
Exemple #2
0
    def __init__(self, x, unit=None, timezone=None, casting='same_kind'):
        # Get the unit from the dtype
        if unit is None:
            if x.dtype.kind == 'M':
                unit = datetime_data(x.dtype)[0]
            else:
                unit = 's'

        # If timezone is default, make it 'naive' or 'UTC' depending on
        # the numpy version
        if timezone is None and numpy.__version__ >= LooseVersion("1.11"):
            timezone = "naive"
        else:
            timezone = "UTC"
        self.timezone = timezone
        self.unit = unit
        self.casting = casting
Exemple #3
0
    def __init__(self, x, unit=None, timezone=None, casting='same_kind'):
        # Get the unit from the dtype
        if unit is None:
            if x.dtype.kind == 'M':
                unit = datetime_data(x.dtype)[0]
            else:
                unit = 's'

        # If timezone is default, make it 'local' or 'UTC' based on the unit
        if timezone is None:
            # Date units -> UTC, time units -> local
            if unit in ('Y', 'M', 'W', 'D'):
                self.timezone = 'UTC'
            else:
                self.timezone = 'local'
        else:
            self.timezone = timezone
        self.unit = unit
        self.casting = casting
Exemple #4
0
    def __init__(self, x, unit=None,
                 timezone=None, casting='same_kind'):
        # Get the unit from the dtype
        if unit is None:
            if x.dtype.kind == 'M':
                unit = datetime_data(x.dtype)[0]
            else:
                unit = 's'

        # If timezone is default, make it 'local' or 'UTC' based on the unit
        if timezone is None:
            # Date units -> UTC, time units -> local
            if unit in ('Y', 'M', 'W', 'D'):
                self.timezone = 'UTC'
            else:
                self.timezone = 'local'
        else:
            self.timezone = timezone
        self.unit = unit
        self.casting = casting