@nekm/svelte-core 1.0.22 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ <script lang="ts">
2
+ import {onMount} from "svelte";
3
+ import {localeFormatDate} from "./locale.js";
4
+
5
+ interface Props {
6
+ readonly date: Date;
7
+ }
8
+
9
+ const { date }: Props = $props();
10
+
11
+ const isoString = date.toISOString();
12
+ let formatted = $state(isoString);
13
+
14
+ onMount(() => {
15
+ formatted = localeFormatDate(date);
16
+ })
17
+ </script>
18
+
19
+ <time datetime={isoString}>
20
+ {formatted}
21
+ </time>
@@ -0,0 +1,6 @@
1
+ interface Props {
2
+ readonly date: Date;
3
+ }
4
+ declare const DateTime: import("svelte").Component<Props, {}, "">;
5
+ type DateTime = ReturnType<typeof DateTime>;
6
+ export default DateTime;
@@ -0,0 +1 @@
1
+ export declare function localeFormatDate(date: Date, locale?: string): string;
package/dist/locale.js ADDED
@@ -0,0 +1,7 @@
1
+ export function localeFormatDate(date, locale) {
2
+ const intl = Intl.DateTimeFormat(locale, {
3
+ dateStyle: "medium",
4
+ timeStyle: "short"
5
+ });
6
+ return intl.format(date);
7
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nekm/svelte-core",
3
3
  "description": "Code I find myself re-writing over-and-over, Svelte edition.",
4
- "version": "1.0.22",
4
+ "version": "1.1.0",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
7
7
  "build": "vite build && npm run prepack",