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

Add time zone handling APIs #337

Merged
merged 21 commits into from
Nov 30, 2021
Merged

Add time zone handling APIs #337

merged 21 commits into from
Nov 30, 2021

Conversation

BuddhiWathsala
Copy link
Contributor

Purpose

Fixes ballerina-platform/ballerina-library#1059

Examples

Checklist

  • Linked to an issue
  • Updated the changelog
  • Added tests

@BuddhiWathsala BuddhiWathsala marked this pull request as draft November 25, 2021 14:33
@codecov
Copy link

codecov bot commented Nov 25, 2021

Codecov Report

Merging #337 (851aca6) into master (5353449) will increase coverage by 2.91%.
The diff coverage is 92.85%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #337      +/-   ##
============================================
+ Coverage     88.81%   91.73%   +2.91%     
- Complexity       44       61      +17     
============================================
  Files            10       13       +3     
  Lines           304      363      +59     
  Branches         69       89      +20     
============================================
+ Hits            270      333      +63     
+ Misses           23       22       -1     
+ Partials         11        8       -3     
Impacted Files Coverage Δ
...o/ballerina/stdlib/time/util/TimeValueHandler.java 50.00% <80.00%> (-26.20%) ⬇️
...main/java/io/ballerina/stdlib/time/util/Utils.java 85.10% <85.10%> (ø)
...na/stdlib/time/nativeimpl/TimeZoneExternUtils.java 87.50% <87.50%> (ø)
ballerina/time_apis.bal 100.00% <100.00%> (ø)
ballerina/time_types.bal 100.00% <100.00%> (ø)
...ava/io/ballerina/stdlib/time/nativeimpl/Civil.java 100.00% <100.00%> (+15.38%) ⬆️
...allerina/stdlib/time/nativeimpl/ExternMethods.java 98.43% <100.00%> (ø)
...java/io/ballerina/stdlib/time/nativeimpl/Zone.java 100.00% <100.00%> (ø)
.../java/io/ballerina/stdlib/time/util/Constants.java 100.00% <100.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5353449...851aca6. Read the comment docs.

@BuddhiWathsala BuddhiWathsala marked this pull request as ready for review November 26, 2021 06:11
isolated function testGetZone() returns Error? {
Zone? systemZone1 = getZone("Asia/Colombo");
if systemZone1 is Zone {
test:assertTrue(systemZone1.fixedOffset() is ());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this a fixed offset?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially thought that too. But seems it is not a fixed offset.

ZoneId.of("Asia/Colombo").normalized().getRules().isFixedOffset(); // Returns false

And even the IANA time zone dataset has these changes as well.

# Sri Lanka

# From Paul Eggert (2013-02-21):
# Milne says "Madras mean time use from May 1, 1898.  Prior to this Colombo
# mean time, 5h. 4m. 21.9s. F., was used."  But 5:04:21.9 differs considerably
# from Colombo's meridian 5:19:24, so for now ignore Milne and stick with
# Shanks and Pottenger.

# From Paul Eggert (1996-09-03):
# "Sri Lanka advances clock by an hour to avoid blackout"
# (<http://www.virtual-pc.com/lankaweb/news/items/240596-2.html>, 1996-05-24,
# no longer available as of 1999-08-17)
# reported "the country's standard time will be put forward by one hour at
# midnight Friday (1830 GMT) 'in the light of the present power crisis'."
#
# From Dharmasiri Senanayake, Sri Lanka Media Minister (1996-10-24), as quoted
# by Shamindra in Daily News - Hot News Section
# <news:[email protected]> (1996-10-26):
# With effect from 12.30 a.m. on 26th October 1996
# Sri Lanka will be six (06) hours ahead of GMT.

# From Jesper Nørgaard Welen (2006-04-14), quoting Sri Lanka News Online
# <http://news.sinhalaya.com/wmview.php?ArtID=11002> (2006-04-13):
# 0030 hrs on April 15, 2006 (midnight of April 14, 2006 +30 minutes)
# at present, become 2400 hours of April 14, 2006 (midnight of April 14, 2006).

# From Peter Apps and Ranga Sirila of Reuters (2006-04-12) in:
# http://today.reuters.co.uk/news/newsArticle.aspx?type=scienceNews&storyID=2006-04-12T172228Z_01_COL295762_RTRIDST_0_SCIENCE-SRILANKA-TIME-DC.XML
# [The Tamil Tigers] never accepted the original 1996 time change and simply
# kept their clocks set five and a half hours ahead of Greenwich Mean
# Time (GMT), in line with neighbor India.
# From Paul Eggert (2006-04-18):
# People who live in regions under Tamil control can use [TZ='Asia/Kolkata'],
# as that zone has agreed with the Tamil areas since our cutoff date of 1970.

# From Sadika Sumanapala (2016-10-19):
# According to http://www.sltime.org (maintained by Measurement Units,
# Standards & Services Department, Sri Lanka) abbreviation for Sri Lanka
# standard time is SLST.
#
# From Paul Eggert (2016-10-18):
# "SLST" seems to be reasonably recent and rarely-used outside time
# zone nerd sources.  I searched Google News and found three uses of
# it in the International Business Times of India in February and
# March of this year when discussing cricket match times, but nothing
# since then (though there has been a lot of cricket) and nothing in
# other English-language news sources.  Our old abbreviation "LKT" is
# even worse.  For now, let's use a numeric abbreviation; we can
# switch to "SLST" if it catches on.

# Zone	NAME		STDOFF	RULES	FORMAT	[UNTIL]
Zone	Asia/Colombo	5:19:24 -	LMT	1880
			5:19:32	-	MMT	1906        # Moratuwa Mean Time
			5:30	-	+0530	1942 Jan  5
			5:30	0:30	+06	1942 Sep
			5:30	1:00	+0630	1945 Oct 16  2:00
			5:30	-	+0530	1996 May 25  0:00
			6:30	-	+0630	1996 Oct 26  0:30
			6:00	-	+06	2006 Apr 15  0:30
			5:30	-	+0530

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Design and implementation of phase 02
2 participants