Skip to content
Snippets Groups Projects
Commit 6ad0d914 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-244: added method convenience urls for todays sun rise/set at the corep

parent 3bec3e06
No related branches found
No related tags found
1 merge request!252Resolve TMSS-190
......@@ -112,11 +112,15 @@ def lst(request):
# todo: do we want to return a dict, so users can make sure their parameters were parsed correctly instead?
return HttpResponse(str(lst_lon), content_type='text/plain')
def get_sun_rise_and_set_at_lofar_center(request, timestamp:str=None):
def get_todays_sun_rise_and_set_at_lofar_center(request) -> JsonResponse:
return get_sun_rise_and_set_at_lofar_center(request, datetime.utcnow())
def get_sun_rise_and_set_at_lofar_center(request, timestamp:None) -> JsonResponse:
if timestamp is None:
timestamp = datetime.utcnow()
else:
timestamp = dateutil.parser.parse(timestamp) # isot to datetime
if isinstance(timestamp, str):
timestamp = dateutil.parser.parse(timestamp)
sun_rise, sun_set = sun_rise_and_set_at_lofar_center(timestamp)
return JsonResponse({'sun_rise': formatDatetime(sun_rise),
......
......@@ -67,6 +67,7 @@ urlpatterns = [
path('station_groups/<str:template_name>/<str:template_version>/<str:station_group>', views.get_stations_in_group, name='get_stations_in_group'), #TODO: how to make trailing slash optional?
path('station_groups/<str:template_name>/<str:template_version>/<str:station_group>/', views.get_stations_in_group, name='get_stations_in_group'),
path('sun_rise_and_set/<str:timestamp>', views.get_sun_rise_and_set_at_lofar_center, name='get_sun_rise_and_set_at_lofar_center'),
path('todays_sun_rise_and_set', views.get_todays_sun_rise_and_set_at_lofar_center, name='get_todays_sun_rise_and_set_at_lofar_center'),
path(r'util/utc', views.utc, name="system-utc"),
path(r'util/lst', views.lst, name="conversion-lst"),
path('__debug__/', include(debug_toolbar.urls)),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment