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 run
command 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 (ConnectionConfig config, string serviceUrl)
- config ConnectionConfig {} - 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|error
a listing of all timezones.
Return Type
- ListJsonResponse|error - the list of available timezones in JSON format
listTimezonesAsText
function listTimezonesAsText() returns ListTextResponse|error
a 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|error
a 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|error
request 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|error
request 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|error
request 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|error
request 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|error
request 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|error
request 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|error
request 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|error
request 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: ClientHttp1Settings
Provides settings related to HTTP/1.x protocol.
Fields
- keepAlive KeepAlive(default http:KEEPALIVE_AUTO) - Specifies whether to reuse a connection for multiple requests
- chunking Chunking(default http:CHUNKING_AUTO) - The chunking behaviour of the request
- proxy ProxyConfig? - Proxy server related options
worldtimeapi: ConnectionConfig
Provides a set of configurations for controlling the behaviours when communicating with a remote HTTP endpoint.
Fields
- httpVersion HttpVersion(default http:HTTP_2_0) - The HTTP version understood by the client
- http1Settings ClientHttp1Settings? - Configurations related to HTTP/1.x protocol
- http2Settings ClientHttp2Settings? - Configurations related to HTTP/2 protocol
- timeout decimal(default 60) - The maximum time to wait (in seconds) for a response before closing the connection
- forwarded string(default "disable") - The choice of setting
forwarded
/x-forwarded
header
- poolConfig PoolConfiguration? - Configurations associated with request pooling
- cache CacheConfig? - HTTP caching related configurations
- compression Compression(default http:COMPRESSION_AUTO) - Specifies the way of handling compression (
accept-encoding
) header
- circuitBreaker CircuitBreakerConfig? - Configurations associated with the behaviour of the Circuit Breaker
- retryConfig RetryConfig? - Configurations associated with retrying
- responseLimits ResponseLimitConfigs? - Configurations associated with inbound response size limits
- secureSocket ClientSecureSocket? - SSL/TLS-related options
- proxy ProxyConfig? - Proxy server related options
- validation boolean(default true) - Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
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/Location
orArea/Location/Region
format
- 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
worldtimeapi: ProxyConfig
Proxy server configurations to be used with the HTTP client endpoint.
Fields
- host string(default "") - Host name of the proxy server
- port int(default 0) - Proxy server port
- userName string(default "") - Proxy server username
- password string(default "") - Proxy server password
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: over 1 year ago
Version: 1.5.1
License: Apache-2.0
Compatibility
Platform: any
Ballerina version: 2201.4.1
GraalVM compatible: Yes
Pull count
Total: 8
Current verison: 3
Weekly downloads
Keywords
IT Operations/Cloud Services
Cost/Free
Contributors
Dependencies