Skip to content

Feature: implement advanced number and date formatting

Florian Werner requested to merge flo-wer/dart_pkpass:format into main

This Merge Request implements the number and date formatting according to the Apple docs. Specifically, the following features where implemented:

  • parse numberStyle and currencyCode from JSON and format number values accordingly
  • parse number values as num instead of int to support float values (for currency values etc.)
  • parse dateStyle and timeStyle from JSON and format date values accordingly
  • parse ignoresTimeZone from JSON and use it for the final value, also fixes the bug that all date values were in UTC instead of the local timezone

I moved the function to produce the final "localized" value from DictionaryValue.getLocalizedValue to DictionaryField.getLocalizedValue because the formatting needs the new introduced settings and the current code doesn't have access to these values.

Some features from the standard were not implemented and left out:

  • ignoresTimeZone should format the date in the original timezone, but dart discards the timezone and always uses UTC, so in this case the final value is in UTC instead of the original timezone
  • PKNumberStyleSpellOut seems rather unnecessary and dart has no native function to use this

Merge request reports