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

The year from date wrong after convert to string with Calendar is Japanese which was set on device setting #107

Open
LesuPower opened this issue Jun 30, 2021 · 1 comment

Comments

@LesuPower
Copy link

LesuPower commented Jun 30, 2021

The year from date wrong after convert to string with Calendar is Japanese which was set on the device setting. Please add the static Calendar which will use when convert date to string (Don't use Calendar. current when converting)
For example, I only want to use Calendar Gregorian for the application despite the user setting other Calendar in setting (Japanese in this example).

Date().toString(.custom("yyyy/MM/dd")) -> "0003/01/01". But the result i wish is: "2021/01/01"

@qtisan
Copy link

qtisan commented Nov 2, 2021

i try this:

let time = Date(fromString: "1730-01-01T00:00:00+08:00", format: .isoDateTimeSec)!

print(time)
print(time.component(.year)!)
print(time.component(.month)!)
print(time.component(.day)!)
print(time.component(.hour)!)
print(time.component(.minute)!)
print(time.component(.second)!)

it prints:

1729-12-31 16:00:00 +0000
1730
1
1
0
5
43

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

2 participants