Get modified time from storage, ensuring the result is a timezone-aware
    datetime.
482755
def get_modified_time(storage, name):
    
    try:
        try:
            # Prefer Django 1.10 API and fall back to old one
            modified_time = storage.get_modified_time(name)
        except AttributeError:
            modified_time = storage.modified_time(name)
    except OSError:
        return 0
    except NotImplementedError:
        return None
    if modified_time and timezone.is_naive(modified_time):
        if getattr(settings, 'USE_TZ', False):
            default_timezone = timezone.get_default_timezone()
            return timezone.make_aware(modified_time, default_timezone)
    return modified_time
615281
def ensure_timezone(dt, tz=None):
    
    if dt.tzinfo is None:
        return dt.replace(tzinfo=tz or tzlocal())
    else:
        return dt
1307570
def _get_offset_time(utc_offset):
    '''
    
    '''
    if utc_offset is not None:
        minutes = _offset_to_min(utc_offset)
        offset = timedelta(minutes=minutes)
        offset_time = datetime.utcnow() + offset
        offset_time = offset_time.replace(tzinfo=_FixedOffset(minutes))
    else:
        offset_time = datetime.now()
    return offset_time
573848
def getAwareDatetime(date, time, tz, timeDefault=dt.time.max):
    
    if time is None:
        time = timeDefault
    datetime = dt.datetime.combine(date, time)
    # arbitary rule to handle DST transitions:
    # if daylight savings causes an error then use standard time
    datetime = timezone.make_aware(datetime, tz, is_dst=False)
    return datetime
1199861
def utcfromtimestamp(cls, timestamp):
    """"""
    obj = datetime.datetime.utcfromtimestamp(timestamp)
    obj = pytz.utc.localize(obj)
    return cls(obj)
921025
def utc_to_tz(utc_datetime, tzinfo, keep_tzinfo=False):
    
    tz_awared_datetime = utc_datetime.replace(tzinfo=utc).astimezone(tzinfo)
    if keep_tzinfo is False:
        tz_awared_datetime = tz_awared_datetime.replace(tzinfo=None)
    return tz_awared_datetime
877005
def get_timestamp(timezone_name, year, month, day, hour=0, minute=0):
    """"""
    tz = pytz.timezone(timezone_name)
    tz_datetime = tz.localize(datetime(year, month, day, hour, minute))
    timestamp = calendar.timegm(tz_datetime.utctimetuple())
    return timestamp
913749
def datetime(self):
        """"""
        return datetime.fromtimestamp(int(self.timestamp) / 1000, tz=pytz.utc)
305711
def _getFromTime(self, atDate=None):
        
        return getLocalTime(self.except_date, self.time_from, self.tz)
807697
def get_timestamp(dt=None):
    '''
    
    '''

    if dt is None: dt = datetime.datetime.utcnow()
    t = dt.utctimetuple()

    return calendar.timegm(t)
149741
def getLocalDatetime(date, time, tz=None, timeDefault=dt.time.max):
    
    localTZ = timezone.get_current_timezone()
    if tz is None or tz == localTZ:
        localDt = getAwareDatetime(date, time, tz, timeDefault)
    else:
        # create in event's time zone
        eventDt = getAwareDatetime(date, time, tz, timeDefault)
        # convert to local time zone
        localDt = eventDt.astimezone(localTZ)
        if time is None:
            localDt = getAwareDatetime(localDt.date(), None, localTZ, timeDefault)
    return localDt
156573
def to_timezone(dt, tzinfo=None):
    
    if not dt:
        return dt
    tz = pick_timezone(tzinfo, __timezone__)
    if not tz:
        return dt
    dttz = getattr(dt, 'tzinfo', None)
    if not dttz:
        return dt.replace(tzinfo=tz)
    else:
        return dt.astimezone(tz)
492917
def change_time(self):
    """"""
    timestamp = self._fsntfs_file_entry.get_entry_modification_time_as_integer()
    return dfdatetime_filetime.Filetime(timestamp=timestamp)
205241
def _to_timezone(self, dt):
        """"""
        tz = self._get_tz()
        utc_dt = pytz.utc.localize(dt)
        return utc_dt.astimezone(tz)
355012
def modification_time(self):
    """"""
    timestamp = self._fsntfs_attribute.get_modification_time_as_integer()
    return dfdatetime_filetime.Filetime(timestamp=timestamp)
435905
def adjust_from_utc_fields(*args, **kwargs):
        """"""
        raw_ts = Timestamp(*args, **kwargs)
        offset = raw_ts.utcoffset()
        if offset is None or offset == timedelta():
            return raw_ts

        # XXX This returns a datetime, not a Timestamp (which has our precision if defined)
        adjusted = raw_ts + offset
        if raw_ts.precision is None:
            # No precision means we can just return a regular datetime
            return adjusted

        return Timestamp(
            adjusted.year,
            adjusted.month,
            adjusted.day,
            adjusted.hour,
            adjusted.minute,
            adjusted.second,
            adjusted.microsecond,
            raw_ts.tzinfo,
            precision=raw_ts.precision,
            fractional_precision=raw_ts.fractional_precision
        )
1286651
public long getModificationTime() {
    if (attributes.containsKey(FILE_MODIFICATION_TIMESTAMP_KEY)
        && attributes.get(FILE_MODIFICATION_TIMESTAMP_KEY) != null) {
      try {
        return Longs.fromByteArray(attributes.get(FILE_MODIFICATION_TIMESTAMP_KEY));
      } catch (IllegalArgumentException iae) {
        logger.atFine().log(
            "Failed to parse modification time '%s' millis for object %s",
            attributes.get(FILE_MODIFICATION_TIMESTAMP_KEY), itemInfo.getObjectName());
      }
    }
    return getCreationTime();
  }