def test_year_2038_problem(self): """ See issue #805 """ dt = UTCDateTime(2004, 1, 10, 13, 37, 4) self.assertEqual(dt.__str__(), '2004-01-10T13:37:04.000000Z') dt = UTCDateTime(2038, 1, 19, 3, 14, 8) self.assertEqual(dt.__str__(), '2038-01-19T03:14:08.000000Z') dt = UTCDateTime(2106, 2, 7, 6, 28, 16) self.assertEqual(dt.__str__(), '2106-02-07T06:28:16.000000Z')
def stead_attributes_to_json(attrs): tconv = lambda x: None if x == 'None' else float(x) arrival_time = UTCDateTime( attrs['source_origin_time']) + attrs['p_arrival_sample'] / 100.0 event_type = attrs['trace_category'] if 'earthquake' in event_type: event_type = 'earthquake' # 'earthquake_local' -> just 'earthquake' info_dict = { 'event_type': event_type, 'event_type_certainty': 'known', 'origins': [{ 'resource_id': attrs['source_id'], 'time': attrs['source_origin_time'], 'time_errors': { 'uncertainty': tconv(attrs['source_origin_uncertainty_sec']) }, 'longitude': tconv(attrs['source_longitude']), 'latitude': tconv(attrs['source_longitude']), 'depth': tconv(attrs['source_depth_km']), 'depth_errors': { 'uncertainty': tconv(attrs['source_depth_uncertainty_km']) }, }], 'magnitudes': [{ 'mag': tconv(attrs['source_magnitude']), 'magnitude_type': attrs['source_magnitude_type'], }], # Arrival times in 'our' lingo 'est_arrivaltime_arces': arrival_time.__str__(), 'analyst_pick_time': arrival_time.__str__(), # Distance/direction to station 'dist_to_arces': tconv(attrs['source_distance_km']), 'baz_to_arces': tconv(attrs['back_azimuth_deg']), 'trace_stats': { 'starttime': attrs['trace_start_time'], 'sampling_rate': 100.0, 'station': attrs['network_code'] + '.' + attrs['receiver_code'], 'channels': ['East-West', 'North-South', 'Vertical'] } } return json.dumps(info_dict)