Time and Date Rust API

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.

Cargo features

"async-client" can be enabled by disabling default features and adding "async-client" as a feature.

Astronomy API

Astro Event Service

Get astronomical events for multiple places and objects:

```rust ignore let client = ServiceClient::new("accesskey".into(), "secretkey".into()); let request = AstroEventRequest::new() .withobject(AstronomyObjectType::Sun) .withobject(AstronomyObjectType::Saturn) .withplaceid("3") .withplaceid("4") .set_startdt(DateTime::from("2021-08-18"));

let response = client.getastroevents(&request); ```

Astro Position Service

Get astronomical data for multiple places and objects:

```rust ignore let request = AstroPositionRequest::new() .withobject(AstronomyObjectType::Sun) .withplaceid("3") .withplaceid("norway/oslo") .withinterval(DateTime::from("2021-08-18")) .with_interval(DateTime::from("2021-08-25"));

let response = client.getastroposition(&request); ```

Date Calculator API

Business Date Service

Calculate a business date by adding days to a given date:

```rust ignore let request = BusinessDateRequest::new() .setplaceid("norway/stavanger") .setstartdt(DateTime::from("2021-04-04")) .with_days(4);

let response = client.calculatebusinessdate(&request); ```

Calculate a business date by subtracting days to a given date:

```rust ignore let request = BusinessDateRequest::new() .setplaceid("norway/stavanger") .setstartdt(DateTime::from("2021-04-04")) .withdays(4) .setsubtraction();

let response = client.calculatebusinessdate(&request); ```

Business Duration Service

Calculate duration between two timestamps:

```rust ignore let request = BusinessDurationRequest::new() .setplaceid("norway/stavanger") .setstartdt(DateTime::from("2021-04-04")) .set_enddt(DateTime::from("2021-04-21"));

let response = client.calculatebusinessduration(&request); ```

Holidays API

Holidays Service

Get all holidays for a year and one or multiple countries:

```rust ignore let request = HolidaysRequest::new() .withcountry("no") .withcountry("us") .set_year(2022);

let response = client.get_holidays(&request); ```

On This Day API

On This Day Service

Get events on this day:

```rust ignore let request = OnThisDayRequest::new();

let response = client.geteventsonthisday(&request); ```

Get events for a given month and day:

```rust ignore let request = OnThisDayRequest::new() .setmonth(4) .setday(24);

let response = client.geteventsonthisday(&request); ```

Filter events by event type:

```rust ignore let request = OnThisDayRequest::new() .withtype(EventType::Events) .withtype(EventType::Births);

let response = client.geteventsonthisday(&request); ```

Places API

Places Service

Get all places:

```rust ignore let request = PlacesRequest::new();

let response = client.get_places(&request); ```

Query for a place:

```rust ignore let request = PlacesRequest::new() .setquery("new york") .setqlimit(10);

let response = client.get_places(&request); ```

Time API

ConvertTime Service

Convert time from a location to multiple locations:

```rust ignore let request = ConvertTimeRequest::new() .setfromid("norway/oslo") .withtoid("usa/chicago") .withtoid("179") .setdatetime(DateTime::from("2021-04-05T16:45:02"));

let response = client.convert_time(&request).unwrap(); ```

DSTList Service

Get all daylight saving times:

```rust ignore let request = DSTListRequest::new();

let response = client.getdaylightsavings_time(&request).unwrap(); ```

Get daylight saving times for a specific year:

```rust ignore let request = DSTListRequest::new().set_year(2021);

let response = client.getdaylightsavings_time(&request).unwrap(); ```

Timeservice Service

Get current time for a place:

```rust ignore let request = TimeserviceRequest::new() .set_placeid("norway/oslo");

let response = client.getcurrenttime(&request); ```