Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time zone APIs won’t work as expected #2489

Closed
BuddhiWathsala opened this issue Dec 13, 2021 · 1 comment
Closed

Time zone APIs won’t work as expected #2489

BuddhiWathsala opened this issue Dec 13, 2021 · 1 comment
Labels
module/time Team/DIU Data, IO, and Util packages related issues Type/Improvement

Comments

@BuddhiWathsala
Copy link
Contributor

Description:
The expected behaviour of the newly added time zone API is as follows.

import ballerina/time;
import ballerina/io;

public isolated function main() returns error? {

    time:Zone systemZone1 = check time:loadSystemZone();
    time:Civil currentSystemCivil = systemZone1.utcToCivil(time:utcNow());
    io:println(currentSystemCivil);

    time:Zone? systemZone2 = time:getZone("Asia/Colombo");
    if systemZone2 is time:Zone {
        time:Civil currentSystemCivil1 = systemZone2.utcToCivil(time:utcNow());
        io:println(currentSystemCivil1);
    }

}

But it won't work as above due to this lang level issue in swan lake beta 06.

However, it will work as the following workaround. When ballerina language fixes the abovementioned issue, this workaround won't break.

import ballerina/time;
import ballerina/io;

public isolated function main() returns error? {

    time:TimeZone systemZone1 = check time:loadSystemZone();
    time:Civil currentSystemCivil = systemZone1.utcToCivil(time:utcNow());
    io:println(currentSystemCivil);

    time:Zone? systemZone2 = time:getZone("Asia/Colombo");
    if systemZone2 is time:TimeZone {
        time:Civil currentSystemCivil1 = systemZone2.utcToCivil(time:utcNow());
        io:println(currentSystemCivil1);
    }

}

Affected Versions:

  • SL beta 06
  • Time version 2.1.0

Related Issues (optional):
ballerina-platform/ballerina-lang#34280

@daneshk daneshk added the Team/DIU Data, IO, and Util packages related issues label May 11, 2022
@TharmiganK
Copy link
Contributor

Closing this issue since it is working in the latest Ballerina version(2201.10.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/time Team/DIU Data, IO, and Util packages related issues Type/Improvement
Projects
None yet
Development

No branches or pull requests

3 participants