worldtimeapi
Module worldtimeapi
API
ballerinax/worldtimeapi Ballerina library
Overview
This is a generated connector for WorldTimeAPI v0.6.1 OpenAPI Specification.
WorldTime API is a simple "microservice" which returns the local-time for a given timezone in both unixtime and ISO8601 format. The worldTimeAPI connector supports to get the current time based on a request with a timezone and additional information including whether that timezone is currently in Daylight Savings Time, when DST starts and ends, the UTC offset, etc.
Quickstart
- Listing all time zone as json
Step 1 - Import connector
ballerinax/worldtimeapi
Step 2 - Create a new connector instance
worldtimeapi:Client baseClient = check new Client();
Step 3 - Invoke connector operation
- Invoke connector operations using the client
worldtimeapi:ListJsonResponse output = check baseClient->listTimezones();
- Use
bal runcommand to compile and run the Ballerina program.
Clients
worldtimeapi: Client
This is a generated connector for WorldTimeAPI v0.6.1 OpenAPI Specification. WorldTime API is a simple "microservice" which returns the local-time for a given timezone in both unixtime and ISO8601 format. The worldTimeAPI connector supports to get the current time based on a request with a timezone and additional information including whether that timezone is currently in Daylight Savings Time, when DST starts and ends, the UTC offset, etc.
Constructor
Gets invoked to initialize the connector.
The connector initialization doesn't require setting the API credentials.
World Time API data is simple and free to access. Follow this link for more details.
init (ClientConfiguration clientConfig, string serviceUrl)- clientConfig ClientConfiguration {} - The configurations to be used when initializing the
connector
- serviceUrl string "http://worldtimeapi.org/api/" - URL of the target service
listTimezones
function listTimezones() returns ListJsonResponse|errora listing of all timezones.
Return Type
- ListJsonResponse|error - the list of available timezones in JSON format
listTimezonesAsText
function listTimezonesAsText() returns ListTextResponse|errora listing of all timezones.
Return Type
- ListTextResponse|error - the list of available timezones in plain text
getTimezoneByArea
a listing of all timezones available for that area.
Parameters
- area string - Area
Return Type
- ListJsonResponse|error - the list of available timezones in JSON format
getTimezoneByAreaAsText
function getTimezoneByAreaAsText(string area) returns ListTextResponse|errora listing of all timezones available for that area.
Parameters
- area string - Area
Return Type
- ListTextResponse|error - the list of available timezones in plain text
getCurrentTime
function getCurrentTime(string area, string location) returns DateTimeJsonResponse|errorrequest the current time for a timezone.
Return Type
- DateTimeJsonResponse|error - the current time for the timezone requested in JSON format
getCurrentTimeAsText
function getCurrentTimeAsText(string area, string location) returns DateTimeTextResponse|errorrequest the current time for a timezone.
Return Type
- DateTimeTextResponse|error - the current time for the timezone requested in plain text
getCurrentTimeByRegion
function getCurrentTimeByRegion(string area, string location, string region) returns DateTimeJsonResponse|errorrequest the current time for a timezone.
Return Type
- DateTimeJsonResponse|error - the current time for the timezone requested in JSON format
getCurrentTimeByRegionAsText
function getCurrentTimeByRegionAsText(string area, string location, string region) returns DateTimeTextResponse|errorrequest the current time for a timezone.
Return Type
- DateTimeTextResponse|error - the current time for the timezone requested in plain text
getCurrentTimeBasedOnIp
function getCurrentTimeBasedOnIp() returns DateTimeJsonResponse|errorrequest the current time based on the ip of the request. note: this is a "best guess" obtained from open-source data.
Return Type
- DateTimeJsonResponse|error - the current time for the timezone requested in JSON format
getCurrentTimeBasedOnIpAsText
function getCurrentTimeBasedOnIpAsText() returns DateTimeTextResponse|errorrequest the current time based on the ip of the request. note: this is a "best guess" obtained from open-source data.
Return Type
- DateTimeTextResponse|error - the current time for the timezone requested in plain text
getCurrentTimeBasedOnIpv4
function getCurrentTimeBasedOnIpv4(string ipv4) returns DateTimeJsonResponse|errorrequest the current time based on the ip of the request. note: this is a "best guess" obtained from open-source data.
Parameters
- ipv4 string - IPv4 address
Return Type
- DateTimeJsonResponse|error - the current time for the timezone requested in JSON format
getCurrentTimeBasedOnIpv4AsText
function getCurrentTimeBasedOnIpv4AsText(string ipv4) returns DateTimeTextResponse|errorrequest the current time based on the ip of the request. note: this is a "best guess" obtained from open-source data.
Parameters
- ipv4 string - IPv4 address
Return Type
- DateTimeTextResponse|error - the current time for the timezone requested in plain text
Records
worldtimeapi: DateTimeJsonResponse
Fields
- abbreviation string - the abbreviated name of the timezone
- client_ip string - the IP of the client making the request
- datetime string - an ISO8601-valid string representing the current, local date/time
- day_of_week int - current day number of the week, where sunday is 0
- day_of_year int - ordinal date of the current year
- dst boolean - flag indicating whether the local time is in daylight savings
- dst_from string? - an ISO8601-valid string representing the datetime when daylight savings started for this timezone
- dst_offset int - the difference in seconds between the current local time and daylight saving time for the location
- dst_until string? - an ISO8601-valid string representing the datetime when daylight savings will end for this timezone
- raw_offset int? - the difference in seconds between the current local time and the time in UTC, excluding any daylight saving difference (see dst_offset)
- timezone string - timezone in
Area/LocationorArea/Location/Regionformat
- unixtime int - number of seconds since the Epoch
- utc_datetime string - an ISO8601-valid string representing the current date/time in UTC
- utc_offset string - an ISO8601-valid string representing the offset from UTC
- week_number int - the current week number
worldtimeapi: ErrorJsonResponse
Fields
- _error string - details about the error encountered
String types
worldtimeapi: DateTimeTextResponse
DateTimeTextResponse
time zone details, as per the DateTimeJsonResponse response, in the format key: value, one item per line
worldtimeapi: ErrorTextResponse
ErrorTextResponse
details about the error encountered in plain text
worldtimeapi: ListTextResponse
ListTextResponse
a list of available timezones, one per line
Import
import ballerinax/worldtimeapi;Metadata
Released date: almost 4 years ago
Version: 1.1.0
License: Apache-2.0
Compatibility
Platform: any
Ballerina version: slbeta6
GraalVM compatible: Yes
Pull count
Total: 14
Current verison: 1
Weekly downloads
Keywords
IT Operations/Cloud Services
Cost/Free
Contributors
Dependencies