Skip to content

TimeZone of UTC+5:30 #102

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

Closed
sshikalgar opened this issue Mar 12, 2021 · 10 comments
Closed

TimeZone of UTC+5:30 #102

sshikalgar opened this issue Mar 12, 2021 · 10 comments
Milestone

Comments

@sshikalgar
Copy link

val localDateTime = Clock.System.now().toLocalDateTime(TimeZone.of("UTC+5:30"))
above code is not working I try to use +5:30 but work fine if I used +5. How can I fetch time for +5:30 GMT?

error I received:

Uncaught Kotlin exception: kotlinx.datetime.IllegalTimeZoneException: Invalid ID for ZoneOffset, non numeric characters found: +5:30

@dkhalanskyjb
Copy link
Collaborator

dkhalanskyjb commented Mar 12, 2021

UTC+05:30 should work (note the leading zero).

That said, a reminder is in order that using fixed-offset time zones (probably aside from UTC) is very rarely what one actually needs; instead, in the majority of cases, region-based time zones, like TimeZone.of("Asia/Kolkata") or TimeZone.of("Asia/Colombo"), should be used to make the code more reliable in case of future changes to the time zones.

@sshikalgar
Copy link
Author

Hi, @dkhalanskyjb

I have already tried for "Asia/Kolkata"

val localDateTime = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault())

Uncaught Kotlin exception: kotlinx.datetime.IllegalTimeZoneException: No timezone found with zone ID 'Asia/Kolkata'

@dkhalanskyjb
Copy link
Collaborator

Huh, this is a bug. What platform does this happen on?

@sshikalgar
Copy link
Author

I am using Xcode 12.4 and Simulator to test iosApp project

@dkhalanskyjb
Copy link
Collaborator

I see, thanks! This looks like a duplicate of #94, and if so, the issue is fixed in the current master. So, I would suggest either using the code from the master branch or sticking to the +05:30 solution until the next release of our library.

@dkhalanskyjb dkhalanskyjb added this to the 0.2.0 milestone Mar 12, 2021
@sshikalgar
Copy link
Author

I see, thanks! This looks like a duplicate of #94, and if so, the issue is fixed in the current master. So, I would suggest either using the code from the master branch or sticking to the +05:30 solution until the next release of our library.

+05:30 also won't work as I have mentioned in my first comment.

@dkhalanskyjb
Copy link
Collaborator

dkhalanskyjb commented Mar 12, 2021

In the first comment, you talked about +5:30, not +05:30 (with the zero), right? +05:30 should work.

@dkhalanskyjb
Copy link
Collaborator

The TimeZone.currentSystemDefault() issue does not reproduce for me for 0.2.0. Feel free to reopen this issue if the problem persists!

@vymarkov
Copy link

vymarkov commented Feb 1, 2025

Unfortunately, using a literal name for timezones like "Asia/Colombo" in the code leads to an IllegalTimeZoneException when targeting the JavaScript platform.

TimeZone.of("Asia/Colombo")

for IOS/Android platforms it works fine

@dkhalanskyjb
Copy link
Collaborator

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

No branches or pull requests

3 participants