Crates.io | libtad-rs |
lib.rs | libtad-rs |
version | 0.2.0 |
source | src |
created_at | 2021-08-31 11:14:25.966503 |
updated_at | 2021-09-08 08:24:17.695612 |
description | Rust library for accessing Time and Date APIs |
homepage | https://services.timeanddate.com |
repository | https://github.com/timeanddate/libtad-rs |
max_upload_size | |
id | 445061 |
size | 115,390 |
libtad-rs is a Rust library for accessing Time and Date API services.
An access key and a secret key is required to use the API. For more information, see our API Services page.
"async-client" can be enabled by disabling default features and adding "async-client" as a feature.
Get astronomical events for multiple places and objects:
let client = ServiceClient::new("access_key".into(), "secret_key".into());
let request = AstroEventRequest::new()
.with_object(AstronomyObjectType::Sun)
.with_object(AstronomyObjectType::Saturn)
.with_placeid("3")
.with_placeid("4")
.set_startdt(DateTime::from("2021-08-18"));
let response = client.get_astro_events(&request);
Get astronomical data for multiple places and objects:
let request = AstroPositionRequest::new()
.with_object(AstronomyObjectType::Sun)
.with_placeid("3")
.with_placeid("norway/oslo")
.with_interval(DateTime::from("2021-08-18"))
.with_interval(DateTime::from("2021-08-25"));
let response = client.get_astro_position(&request);
Calculate a business date by adding days to a given date:
let request = BusinessDateRequest::new()
.set_placeid("norway/stavanger")
.set_startdt(DateTime::from("2021-04-04"))
.with_days(4);
let response = client.calculate_business_date(&request);
Calculate a business date by subtracting days to a given date:
let request = BusinessDateRequest::new()
.set_placeid("norway/stavanger")
.set_startdt(DateTime::from("2021-04-04"))
.with_days(4)
.set_subtraction();
let response = client.calculate_business_date(&request);
Calculate duration between two timestamps:
let request = BusinessDurationRequest::new()
.set_placeid("norway/stavanger")
.set_startdt(DateTime::from("2021-04-04"))
.set_enddt(DateTime::from("2021-04-21"));
let response = client.calculate_business_duration(&request);
Get all holidays for a year and one or multiple countries:
let request = HolidaysRequest::new()
.with_country("no")
.with_country("us")
.set_year(2022);
let response = client.get_holidays(&request);
Get events on this day:
let request = OnThisDayRequest::new();
let response = client.get_events_on_this_day(&request);
Get events for a given month and day:
let request = OnThisDayRequest::new()
.set_month(4)
.set_day(24);
let response = client.get_events_on_this_day(&request);
Filter events by event type:
let request = OnThisDayRequest::new()
.with_type(EventType::Events)
.with_type(EventType::Births);
let response = client.get_events_on_this_day(&request);
Get all places:
let request = PlacesRequest::new();
let response = client.get_places(&request);
Query for a place:
let request = PlacesRequest::new()
.set_query("new york")
.set_qlimit(10);
let response = client.get_places(&request);
Get tidal data for one or multiple places:
let request = TidesRequest::new()
.with_placeid("norway/sola")
.with_placeid("norway/oslo");
let response = client.get_tidal_data(&request);
Convert time from a location to multiple locations:
let request = ConvertTimeRequest::new()
.set_fromid("norway/oslo")
.with_toid("usa/chicago")
.with_toid("179")
.set_datetime(DateTime::from("2021-04-05T16:45:02"));
let response = client.convert_time(&request);
Get all daylight saving times:
let request = DSTListRequest::new();
let response = client.get_daylight_savings_time(&request);
Get daylight saving times for a specific year:
let request = DSTListRequest::new().set_year(2021);
let response = client.get_daylight_savings_time(&request);
Get current time for a place:
let request = TimeserviceRequest::new()
.set_placeid("norway/oslo");
let response = client.get_current_time(&request);