irongut / EDlib

A .Net Standard library for creating companion apps for the game Elite Dangerous by Frontier Developments.
MIT License
4 stars 0 forks source link

Errors with non-Western calendars #51

Closed irongut closed 3 years ago

irongut commented 3 years ago

Bug Report

EliteALD error reports include several exceptions related to dates from devices using Thai language settings. Exceptions have been seen from several services including Priorities, EDSM & Standings.

DateTime.Parse(System.String s) ArgumentNullException: Value cannot be null. Parameter name: s AppCenter #3972984053 AppCenter #2803695455

DateTimeFormatInfo.set_Calendar(System.Globalization.Calendar value) ArgumentOutOfRangeException: Not a valid calendar for the given culture. Parameter name: value AppCenter #1582563134 AppCenter #3618643846

Stack Trace

DateTime.Parse (System.String s)
EdsmService.GetData (System.String method, System.Collections.Generic.Dictionary`2[TKey,TValue] parameters, System.String dataKey, System.String lastUpdatedKey, System.TimeSpan expiry, System.Boolean ignoreCache)
EliteStatusService.GetData (System.Boolean ignoreCache)
MenuViewModel.GetEliteStatusAsync (System.Boolean ignoreCache)
DateTimeFormatInfo.set_Calendar (System.Globalization.Calendar value)
System.Globalization.DateTimeFormatInfo..ctor (System.Globalization.CultureData cultureData, System.Globalization.Calendar cal) [0x00022] in <9ec1698a2c964b1abc090676996703e7>:0
CultureInfo.get_DateTimeFormat ()
CultureInfo.GetFormat (System.Type formatType)
DateTimeFormatInfo.get_CurrentInfo ()
DateTimeFormatInfo.GetInstance (System.IFormatProvider provider)
DateTimeFormat.Format (System.DateTime dateTime, System.String format, System.IFormatProvider provider, System.TimeSpan offset)
DateTimeFormat.Format (System.DateTime dateTime, System.String format, System.IFormatProvider provider)
DateTime.ToString ()
DownloadService.GetData (System.String url, System.String dataKey, System.String lastUpdatedKey, System.TimeSpan expiry, System.Threading.CancellationTokenSource cancelToken, System.Boolean ignoreCache)
StandingsService.GetData (System.Threading.CancellationTokenSource cancelToken, System.Boolean ignoreCache)
StandingsViewModel.GetStandingsAsync (System.Boolean ignoreCache)

To Reproduce

Parse a DateTime from a string. Convert a DateTime to a string using string.Format() or equivalent code.

Additional Context

Similar reports have been seen in the past for devices with Arabic language settings. Will require fixing in irongut/EliteALD as well as EDlib.

Linked To

irongut/EliteALD Issue 286 Errors with non-Western calendars.

irongut commented 3 years ago

Most of these errors are because Xamarin Android doesn't include some calendars unless they are specifically added in Android Options. So the main problem is with the app. See irongut/EliteALD issue 286 for fix.

There is an issue with BgsTickService returning DateTime.MinValue & Unknown for the latest tick. This is probably because the Thai calendar uses a different initial year making it 2564 in 2021. DateTime values store the western date but String.Format uses the Thai date. So the query url sent to phelbore.com will ask for data 543 years in the future! See query url.