Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

toLocaleString long options do not seem to work on Android #340

@bitttttten

Description

@bitttttten

I am using this library to help with parsing strings on react native, with luxon. Android has some issues with toLocaleString so following this comment I am using this library which is super nice. Apart from I cannot get "long" to work in toLocaleString.

import { DateTime } from "luxon"
import { Platform } from "react-native"

if (Platform.OS === "android") {
  require("intl")
  require("intl/locale-data/jsonp/en")
  require("intl/locale-data/jsonp/nl")
}

const getPrettyDate = (date: DateTime) => {
  return date.toLocaleString({
    weekday: "long",
    month: "long",
    day: "2-digit",
  })
}

test("getPrettyDate", () => {
  expect(
    getPrettyDate(DateTime.fromRFC2822("Fri, 25 Nov 2016 12:00:00 +0000"))
  ).toBe(`Friday, November 25`)
})

This will fail on Android because it produces the string "Fri, Nov 25" instead of the "long" variant which should be "Friday, November 25". On iOS devices, the above test will pass.

The intl require statements are definitely working, since if I remove the require statements, then
getPrettyDate will produce something like "Friday, November 25, 2016, 12:00..".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions