Ejemplo n.º 1
0
 def get_date_time(self, obj):
     __date_time_null_value__ = 2**64 - 1
     if obj.time == __date_time_null_value__:
         return ""
     if obj.HasField('date'):
         return timestamp_to_str(obj.date + obj.time)
     return datetime.utcfromtimestamp(obj.time).strftime('%H%M%S')
Ejemplo n.º 2
0
 def _add_prev_link(self, resp, params, clockwise):
     journeys = self.filter_journeys(resp.journeys)
     if not journeys:
         return None
     next_journey = max(journeys, key=lambda j: j.arrival_date_time)
     params['datetime'] = timestamp_to_str(next_journey.arrival_date_time -
                                           60)
     params['datetime_represents'] = 'arrival'
     add_link(resp, rel='prev', **params)
Ejemplo n.º 3
0
 def _add_next_link(self, resp, params, clockwise):
     journeys = self.filter_journeys(resp.journeys)
     if not journeys:
         return None
     next_journey = max(journeys, key=lambda j: j.departure_date_time)
     params['datetime'] = timestamp_to_str(
         next_journey.departure_date_time + 60)
     params['datetime_represents'] = 'departure'
     add_link(resp, rel='next', **params)
Ejemplo n.º 4
0
 def _add_next_link(self, resp, params, clockwise):
     next_dt = self.next_journey_datetime(resp.journeys, clockwise)
     if next_dt is not None:
         params['datetime'] = timestamp_to_str(next_dt)
         params['datetime_represents'] = 'departure'
         add_link(resp, rel='next', **params)
Ejemplo n.º 5
0
 def _add_prev_link(self, resp, params, clockwise):
     prev_dt = self.previous_journey_datetime(resp.journeys, clockwise)
     if prev_dt is not None:
         params['datetime'] = timestamp_to_str(prev_dt)
         params['datetime_represents'] = 'arrival'
         add_link(resp, rel='prev', **params)
Ejemplo n.º 6
0
 def format(self, value):
     return timestamp_to_str(value)
Ejemplo n.º 7
0
 def to_value(self, value):
     return timestamp_to_str(value)
Ejemplo n.º 8
0
 def to_value(self, value):
     return timestamp_to_str(value) if value else None
     super(DateTimeDictField,
           self).__init__(schema_type=str,
                          schema_metadata=schema_metadata,
                          **kwargs)
Ejemplo n.º 9
0
 def to_value(self, value):
     return timestamp_to_str(value) if value else None