Dates should not default to US-style M/D/Y #138

Closed
opened 2021-08-06 16:45:59 +00:00 by sarah · 3 comments
Owner
No description provided.
sarah added this to the Cwtch Beta 1.2 project 2021-08-06 16:45:59 +00:00
Contributor

In particular I would suggest that dates be internally stored in ISO-8601 format, in UTC, and then switched "at the last possible moment" to whatever time zone and date format (mm/dd/yyyy, dd/mm/yyyy, et al.) the user has chosen in their OS

In particular I would suggest that dates be internally stored in ISO-8601 format, in UTC, and then switched "at the last possible moment" to whatever time zone and date format (mm/dd/yyyy, dd/mm/yyyy, et al.) the user has chosen in their OS
Author
Owner

In particular I would suggest that dates be internally stored in ISO-8601 format, in UTC

This is already the case.

The main issue seems to be that the flutter API doesn't take locale into account.

The actual code we use to format dates is:

DateFormat.yMd().add_jm().format(messageDate.toLocal());

Which calls the Flutter internal formatting function, which seems incomplete in regards to locale.

 /// Return a string representing [date] formatted according to our locale
  /// and internal format.
  String format(DateTime date) {
    // TODO(efortuna): read optional TimeZone argument (or similar)?
    var result = StringBuffer();
    for (var field in _formatFields) {
      result.write(field.format(date));
    }
    return result.toString();
  }

There is probably a way around this, but this might also just get fixed as flutter matures.

> In particular I would suggest that dates be internally stored in ISO-8601 format, in UTC This is already the case. The main issue seems to be that the flutter API doesn't take locale into account. The actual code we use to format dates is: `DateFormat.yMd().add_jm().format(messageDate.toLocal());` Which calls the Flutter internal formatting function, which seems incomplete in regards to locale. /// Return a string representing [date] formatted according to our locale /// and internal format. String format(DateTime date) { // TODO(efortuna): read optional TimeZone argument (or similar)? var result = StringBuffer(); for (var field in _formatFields) { result.write(field.format(date)); } return result.toString(); } There is probably a way around this, but this might also just get fixed as flutter matures.
Contributor

If I read this correctly, we need to call initializeDateFormatting() with the user's preferred locale and then Flutter will use that locale for further DateFormat method calls

If I read [this](https://api.flutter.dev/flutter/intl/DateFormat-class.html) correctly, we need to call `initializeDateFormatting()` with the user's preferred locale and then Flutter will use that locale for further `DateFormat` method calls
erinn closed this issue 2021-08-16 23:40:42 +00:00
sarah added the
cwtch-beta-1.2
label 2021-08-30 21:31:17 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cwtch.im/cwtch-ui#138
No description provided.