Back to Spotube

TimeZone

website/src/content/docs/plugin-apis/timezone.mdx

5.1.1947 B
Original Source

The TimeZone API provides access to the current time zone of the device running Spotube. This can be useful for plugins that need to display or handle time-related information based on the user's local time zone.

Usage

To use the TimeZone API, you can import the spotube_plugin module and access the TimeZone class.

hetu_script
import "module:spotube_plugin" as spotube

var TimeZone = spotube.TimeZone

To get current local time zone for the device, you can use the getLocalTimeZone method:

hetu_script
TimeZone.getLocalTimeZone().then((timeZone) {
    print("Current local time zone: $timeZone") // e.g., "America/New_York"
})

To get all available time zones, you can use the getAvailableTimeZones method:

hetu_script
TimeZone.getAvailableTimeZones().then((timeZones) {
    for (var tz in timeZones) {
        print("Available time zone: $tz") // e.g., "America/New_York", "Europe/London", etc.
    }
})