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

Standings broken with some Arabic calendars #63

Closed irongut closed 3 years ago

irongut commented 3 years ago

Bug Report

Galactic Standings does not work with Arabic, Saudi Arabia (ar_sa) calendar.

CycleService.CurrentCycle()
System.FormatException: String was not recognized as a valid DateTime.

App Center Issue 4242207755

Stack Trace

System    DateTimeParse.Parse (System.ReadOnlySpan`1[T] s, System.Globalization.DateTimeFormatInfo dtfi, System.Globalization.DateTimeStyles styles)
System    DateTime.Parse (System.String s)
EDlib.Powerplay    CycleService.CurrentCycle ()
EDlib.Powerplay    StandingsService.GetData (System.Threading.CancellationTokenSource cancelToken, System.Boolean ignoreCache)
EliteALD.ViewModels    StandingsViewModel.GetStandingsAsync (System.Boolean ignoreCache)

To Reproduce

Steps to reproduce the behavior:

  1. Set calendar to Arabic, Saudi Arabia (ar_sa).
  2. Run app.
  3. Open Galactic Standings.

Expected Behavior

Galactic Standings parses & displays correctly.

Additional Context

Priorities, server status, BGS tick & CGs have no date issues but year is 42.

Arabic (ar_ar) & Arabic, United Arab Emirates (ar_ua) do not have these issues. Other Arabic calendars should be tested.

Firebase Screenshots

Linked To

51 Errors with non-Western calendars

64 GalNet broken with some Arabic calendars

irongut/EliteALD Issue 304 GalNet & Standings broken with some Arabic calendars

irongut commented 3 years ago

Broken (12)

Arabic, Comoros (ar_KM) Arabic, World (ar_001) Arabic, Djibouti (ar_DJ) Arabic, Western Sahara (ar_EH) Arabic, Eritrea (ar_ER) Arabic, Mauritania Arabic, Palestine Arabic, Saudi Arabia (ar_SA) Arabic, Somalia Arabic, South Sudan Arabic, Sudan Arabic, Chad

Working (16)

Arabic (ar) Arabic, United Arab Emirates (ar_AE) Arabic, Bahrain (ar_BH) Arabic, Algeria (ar_DZ) Arabic, Egypt (ar_EG) Arabic, Iraq (ar_IQ) Arabic, Jordan (ar_JO) Arabic, Kuwait (ar_KW) Arabic, Lebanon (ar_LB) Arabic, Libya (ar_LY) Arabic, Morocco (ar_MA) Arabic, Oman Arabic, Qatar Arabic, Syria Arabic, Tunisia Arabic, Yemen

irongut commented 3 years ago

CycleService.cs line 108 parses the date & time of the start of Powerplay to work out the current cycle. Adding culture to the DateTime.Parse() call should fix the issue. Similar to earlier fix for BGS Tick.

irongut commented 3 years ago

The Islamic Hijri calendar is the official calendar in countries around the Gulf, especially Saudi Arabia. Based on a lunar cycle and dates from the Prophet Muhammad's flight from Makkah to Madinah. The Islamic year (AH) averages 354 days and recedes by about 11 days a year against the Gregorian calendar.

Calendar Date
Hijri 08 / 09 / 1442
GREGORIAN 20 / 04 / 2021