Skip to content
New issue

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

ReactiveDate.toLocaleString ignores arguments #10810

Closed
brunnerh opened this issue Mar 15, 2024 · 1 comment · Fixed by #10813
Closed

ReactiveDate.toLocaleString ignores arguments #10810

brunnerh opened this issue Mar 15, 2024 · 1 comment · Fixed by #10813

Comments

@brunnerh
Copy link
Member

Describe the bug

It just don't care.

Also applies to toLocaleDateString & toLocaleTimeString.

Reproduction

<script>
	import { Date as ReactiveDate } from 'svelte/reactivity';

	const regular = new Date();
	const reactive = new ReactiveDate();
</script>

{regular.toLocaleString()} <br>
{regular.toLocaleString(undefined, { month: 'short' })} <br>
{regular.toLocaleString('fr-FR')} <br>
{regular.toLocaleString('fr-FR', { month: 'short' })} <br>
<br>
{reactive.toLocaleString()} <br>
{reactive.toLocaleString(undefined, { month: 'short' })} <br>
{reactive.toLocaleString('fr-FR')} <br>
{reactive.toLocaleString('fr-FR', { month: 'short' })} <br>

Output:

3/15/2024, 3:59:01 PM
Mar
15/03/2024 15:59:01
mars

3/15/2024, 3:59:01 PM
3/15/2024, 3:59:01 PM
3/15/2024, 3:59:01 PM
3/15/2024, 3:59:01 PM

REPL

Logs

No response

System Info

REPL - Svelte v5.0.0-next.79

Severity

annoyance

@Conduitry
Copy link
Member

for (const method of read) {
// @ts-ignore
proto[method] = function () {
get(this.#raw_time);
// @ts-ignore
return date_proto[method].call(this);
};
}
for (const method of write) {
// @ts-ignore
proto[method] = function (/** @type {any} */ ...args) {
// @ts-ignore
const v = date_proto[method].apply(this, args);
const time = date_proto.getTime.call(this);
if (time !== this.#raw_time.v) {
set(this.#raw_time, time);
}
return v;
};
}

Presumably the read methods we define here will also need to accept ...args like the write ones do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants