~emersion/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 3

[PATCH gamja v0 0/1] [PATCH gamja] Use browser locale for date-separator

Details
Message ID
<164210599224.2414.1099031025001790888-0@git.sr.ht>
DKIM signature
missing
Download raw message
Current date-separator is formatted as YYYY-MM-DD.
navigator.language
looks fairly well supported.
note that i'm leaving slash as separator
instead of doing like `.replaceAll('/', '-')`

ressources:
https://developer.mozilla.org/en-
US/docs/Web/API/Navigator/languages#browser_compatibility
https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString
https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat

xse (1):
  components/buffer: use browser locale for date-separator

 components/buffer.js | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

-- 
2.32.0

[PATCH gamja v0 1/1] components/buffer: use browser locale for date-separator

Details
Message ID
<164210599224.2414.1099031025001790888-1@git.sr.ht>
In-Reply-To
<164210599224.2414.1099031025001790888-0@git.sr.ht> (view parent)
DKIM signature
missing
Download raw message
Patch: +2 -4
From: xse <xse@riseup.net>

---
 components/buffer.js | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/components/buffer.js b/components/buffer.js
index f312c17..b970e30 100644
--- a/components/buffer.js
+++ b/components/buffer.js
@@ -527,10 +527,8 @@ class DateSeparator extends Component {

	render() {
		let date = this.props.date;
		let YYYY = date.getFullYear().toString().padStart(4, "0");
		let MM = (date.getMonth() + 1).toString().padStart(2, "0");
		let DD = date.getDate().toString().padStart(2, "0");
		let text = `${YYYY}-${MM}-${DD}`;
		let lang = navigator.language || 'en';
		let text = date.toLocaleDateString(lang, { year: "numeric", month: "2-digit", day: "2-digit" });
		return html`
			<div class="separator date-separator">
				${text}
-- 
2.32.0

[gamja/patches/.build.yml] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CH4U0WIU08HM.1C8VX3Q0WNDPB@cirno2>
In-Reply-To
<164210599224.2414.1099031025001790888-1@git.sr.ht> (view parent)
DKIM signature
missing
Download raw message
gamja/patches/.build.yml: SUCCESS in 1m28s

[Use browser locale for date-separator][0] v0 from [~xse][1]

[0]: https://lists.sr.ht/~emersion/public-inbox/patches/28262
[1]: xse@riseup.net

✓ #671594 SUCCESS gamja/patches/.build.yml https://builds.sr.ht/~emersion/job/671594

Re: [PATCH gamja v0 1/1] components/buffer: use browser locale for date-separator

Details
Message ID
<qArze4CXIJakMpzIdu2hohgVE2e6gB2Xr4ogsBLZgNDSUHQAq-I4d3NpgXz0hqRqLUmvJFXgK6_SDZoP2XG2_NCxhr8BNqjL_s4sF_bWfOM=@emersion.fr>
In-Reply-To
<164210599224.2414.1099031025001790888-1@git.sr.ht> (view parent)
DKIM signature
pass
Download raw message
Thanks for your patch! The idea sounds good, a nit comment below.

On Thursday, January 13th, 2022 at 21:00, ~xse <xse@git.sr.ht> wrote:

> -		let YYYY = date.getFullYear().toString().padStart(4, "0");
> -		let MM = (date.getMonth() + 1).toString().padStart(2, "0");
> -		let DD = date.getDate().toString().padStart(2, "0");
> -		let text = `${YYYY}-${MM}-${DD}`;
> +		let lang = navigator.language || 'en';
> +		let text = date.toLocaleDateString(lang, { year: "numeric", month: "2-digit", day: "2-digit" });

MDN states [1]:

> To use the browser's default locale, pass an empty array.

So maybe we can simplify this to `date.toLocaleDateString([], …)`?

[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#parameters
Reply to thread Export thread (mbox)