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

Need an API to get the current local time #1690

Closed
madhukaw opened this issue Jul 22, 2021 · 1 comment
Closed

Need an API to get the current local time #1690

madhukaw opened this issue Jul 22, 2021 · 1 comment
Assignees
Labels
module/time Points/1 Team/DIU Data, IO, and Util packages related issues Type/Improvement

Comments

@madhukaw
Copy link
Contributor

Description:
ATM, time module has an API to get the current UTC time but not the current local time. However, in log module the current local time is printed in log messages. Since there is no Ballerina API to get the current local time, a Java native function[1] is being used as a workaround. It would be better if there was a Ballerina API this since we are planning to remove all Java native code from log module.

[1] https://github.com/ballerina-platform/module-ballerina-log/blob/master/native/src/main/java/io/ballerina/stdlib/log/Utils.java#L59

@madhukaw madhukaw added Type/Improvement module/time Team/DIU Data, IO, and Util packages related issues labels Jul 22, 2021
@BuddhiWathsala
Copy link
Contributor

This issue is resolved with this fix ballerina-platform/module-ballerina-time#337.

You can use the following sample to obtain the current local time.

import ballerina/time;

public function main() returns error? {

    time:Zone systemZone = check time:loadSystemZone();
    time:Civil currentSystemCivil = systemZone.utcToCivil(time:utcNow());
}

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

No branches or pull requests

2 participants