-
Notifications
You must be signed in to change notification settings - Fork 203
Description
A reopening of this issue #478 which precisely outlines the scenario.
This is definitely still an issue in regions other than US, as per the original issue, GB in my case. It was very difficult to get hold of a machine in a broken state as the vast majority are set to 24-hour time and those that were suffering from this issue where immediately coerced into updating...
This page - https://www.nsdateformatter.com/#best-practices - suggests that the user's locale/Date & Time settings will be used in this case which suggests to "Always use the en_US_POSIX locale for fixed formats" :-
If you don't force the locale to en_US_POSIX, there are risks that your code might seem to work in some regions (like the US), but will fail to parse your API responses if the user has its phone set in another region (e.g. en_GB, es_ES or fr_FR), where date formatting is different, or use 12-hour time and not 24-hour time.
With that in mind I wondered if adding: -
formatter.locale = Locale(identifier: "en_US_POSIX")
here
nudge/Nudge/Utilities/Utils.swift
Line 556 in 533186b
| let dateFormatterLocalTime: DateFormatter = { |
would help fix the 12-hour time issue outlined above and in my testing it did.
I'm not entirely sure of the wider implications of this change but it does fix the issue and doesn't affect machines where the user has their time set to 24-hour time which is the vast majority. I have chacked against some other random European regions and this holds true there too.