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

Design and implementation of phase 02 #1059

Closed
Tracked by #1057
BuddhiWathsala opened this issue Mar 7, 2021 · 3 comments · Fixed by ballerina-platform/module-ballerina-time#337
Closed
Tracked by #1057
Assignees
Labels
module/time Points/7 Team/DIU Data, IO, and Util packages related issues Type/Task

Comments

@BuddhiWathsala
Copy link
Contributor

BuddhiWathsala commented Mar 7, 2021

@BuddhiWathsala
Copy link
Contributor Author

In the second phase, we can implement the following APIs according to the initial design. @daneshk FYI.

// Time zones

type Zone readonly & object {
  // if always at a fixed offset from Utc, then this
  // function returns it; otherwise nil
  function fixedOffset() returns ZoneOffset?;
  // this does not pay attention to timeZoneOffset nor dayOfWeek
  // it does pay attention to utc
  function utcFromCivil(Civil civilTime) returns Utc|Error;
  function utcToCivil(Utc utc) returns Civil;
};

final Zone systemZone = check loadSystemZone();

// Get a time zone from Ballerina's internal database
// of time zones.
// id is  of form "Continent/City"
function getZone(string id) returns Zone?;

@BuddhiWathsala
Copy link
Contributor Author

The design phase 02 in this doc mentioned that,

  // this does not pay attention to timeZoneOffset nor dayOfWeek
  // it does pay attention to utc
  function utcFromCivil(Civil civilTime) returns Utc|Error;

Should this be rephrased as it does pay attention to time zone?.

And why we don't need to return an error from the getZone like we did in loadSystemZone. @jclark @daneshk

@daneshk
Copy link
Member

daneshk commented Nov 30, 2021

The design phase 02 in this doc mentioned that,

  // this does not pay attention to timeZoneOffset nor dayOfWeek
  // it does pay attention to utc
  function utcFromCivil(Civil civilTime) returns Utc|Error;

Should this be rephrased as it does pay attention to time zone?.

Yes, It does pay attention to the time zone, not for the timeZoneOffset in the Civil record passed as input.

And why we don't need to return an error from the getZone like we did in loadSystemZone.

IMO, the getZone method is similar to maps where we have zone ids as keys and Zone as values. nonexistent entries should return nil rather than errors similar to maps. On the other hand, the loadSystemZone method should always return value unless there is a system error which is okay to return an error.

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

Successfully merging a pull request may close this issue.

2 participants