We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When porting some JVM code to JS I was hit by a method DateTimeFormatter.ofLocalizedDateTime not implemented. Would it be possible to add it?
What alternatives does one have without it to get locale dependent long or short time formats?
The text was updated successfully, but these errors were encountered:
I understand now this is a known limitation:
No Locale support.
My current workaround is using js.Date and Intl functionality:
js.Date
Intl
implicit class ZonedDateTimeOps(t: ZonedDateTime) { def toJSDate: js.Date = { val text = t.toString // (DateTimeFormatter.ISO_ZONED_DATE_TIME) new js.Date(js.Date.parse(text)) } } def locale: String = { import org.scalajs.dom val firstLanguage = dom.window.navigator.asInstanceOf[js.Dynamic].languages.asInstanceOf[js.Array[String]].headOption firstLanguage.getOrElse(dom.window.navigator.language) } def formatDateTime(t: js.Date): String = { new intl.DateTimeFormat( locale, intl.DateTimeFormatOptions( year = "numeric", month = "numeric", day = "numeric", hour = "numeric", minute = "numeric" ) ).format(t) } }
Used as:
val x: ZonedDateTime = ??? formatDateTime(x.toJSDate)
Sorry, something went wrong.
No branches or pull requests
When porting some JVM code to JS I was hit by a method DateTimeFormatter.ofLocalizedDateTime not implemented. Would it be possible to add it?
What alternatives does one have without it to get locale dependent long or short time formats?
The text was updated successfully, but these errors were encountered: