nhirschey / FSharp.Data.Fred

Wrapper for Federal Reserve Economic Data API https://nhirschey.github.io/FSharp.Data.Fred/
MIT License
2 stars 3 forks source link

Request fails if user date is after st louis date because of time zones #16

Closed nhirschey closed 11 months ago

nhirschey commented 12 months ago

If the user date is after St Louis date (b/c in europe after midnight) then the request fails.

Need to change some of the defaults that are using DateTime.Now. Perhaps just set to max real-time date of 9999-12-31.

> fred.Series.Search("10-year").Summary()

Error: System.Net.WebException: The remote server returned an error: (400) Bad Request.
Response from https://api.stlouisfed.org/fred/series/search?&search_text=10-year&search_type=full_text&realtime_start=2023-09-27&realtime_end=2023-09-27&limit=20&order_by=search_rank&sort_order=desc&api_key=dcad55219c8a9de0d22274de20bd4187&file_type=json:
{"error_code":400,"error_message":"Bad Request. Variable realtime_start can not be after today's date (2023-09-26) unless it's equal to the real-time max date 9999-12-31."}
nhirschey commented 12 months ago

@DavideGCosta do you have any interest in fixing this?

The API thinks it is in St. Louis and it won’t accept start or end dates after the current St. Louis date. So default start and ends of DateTime.Now can fail if you’re not in the St. Louis time zone (As is happening to me now).

DavideGCosta commented 12 months ago

@nhirschey yes! Will take a look and lyk

nhirschey commented 12 months ago

Great! I think .net 6 added some support that will be useful to set the default time to "DateTime.Now" except in St Louis timezone (I think timezone will be something like "US/Chicago"). https://devblogs.microsoft.com/dotnet/date-time-and-time-zone-enhancements-in-net-6/#time-zone-conversion-apis

nhirschey commented 12 months ago

BTW, no rush.

DavideGCosta commented 12 months ago

Will be out in NY till next Tuesday! Will have a look after that