svelte-copyright 2.0.0 → 2.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.
@@ -1,3 +1,4 @@
1
+ import type { Format } from '../types.js';
1
2
  export declare function today(): Date;
2
3
  export declare function toYear(date?: Date): string;
3
4
  /**
@@ -6,7 +7,7 @@ export declare function toYear(date?: Date): string;
6
7
  * @param {Date} date - Date to format
7
8
  * @param {'numeric' | '2-digit'} format - Format for the date.
8
9
  */
9
- export declare function formatDate(date?: Date, format?: import("../types.js").Format): string;
10
+ export declare function formatDate(date?: Date, format?: Format): string;
10
11
  /**
11
12
  * Returns the "range string", unless the dates are the same.
12
13
  *
@@ -17,7 +18,7 @@ export declare function getRange(date1: string, date2: string): string;
17
18
  type GetDisplayDateProps = {
18
19
  showRange?: boolean;
19
20
  date?: Date;
20
- format?: string;
21
+ format?: Format;
21
22
  };
22
23
  /**
23
24
  * Returns the displayed date for the component.
@@ -14,12 +14,10 @@ export function toYear(date = today()) {
14
14
  * @param {'numeric' | '2-digit'} format - Format for the date.
15
15
  */
16
16
  export function formatDate(date = today(), format = FORMAT.NUMERIC) {
17
- if (format === FORMAT.NUMERIC) {
18
- return toYear(date);
19
- }
20
17
  if (format === FORMAT.TWO_DIGIT) {
21
18
  return `’${toYear(date).slice(-2)}`;
22
19
  }
20
+ return toYear(date);
23
21
  }
24
22
  /**
25
23
  * Returns the "range string", unless the dates are the same.
@@ -49,5 +47,8 @@ export function getDisplayDate({ showRange = false, date = today(), format = FOR
49
47
  }
50
48
  // Get today's year, formatted correctly.
51
49
  const formattedToday = formatDate(today(), format);
50
+ if (!formattedToday || formattedToday === 'NaN') {
51
+ return today().toLocaleDateString();
52
+ }
52
53
  return getRange(formatted, formattedToday);
53
54
  }
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "svelte-copyright",
3
3
  "description": "A Svelte component to format and display a copyright notice.",
4
- "version": "2.0.0",
4
+ "version": "2.1.0",
5
5
  "author": {
6
6
  "name": "himynameisdave",
7
7
  "email": "d@velunny.com",
8
8
  "url": "https://himynameisdave.com"
9
9
  },
10
10
  "type": "module",
11
+ "main": "./dist/index.js",
11
12
  "svelte": "./dist/index.js",
12
13
  "types": "./dist/index.d.ts",
13
14
  "scripts": {
@@ -29,7 +30,8 @@
29
30
  "exports": {
30
31
  ".": {
31
32
  "types": "./dist/index.d.ts",
32
- "svelte": "./dist/index.js"
33
+ "svelte": "./dist/index.js",
34
+ "default": "./dist/index.js"
33
35
  }
34
36
  },
35
37
  "files": [