date-vir 0.2.5 → 0.2.6

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.
@@ -22,13 +22,21 @@ function toIsoString(fullDate) {
22
22
  return isoString;
23
23
  }
24
24
  exports.toIsoString = toIsoString;
25
+ /**
26
+ * Chromium has a weird behavior where the "NARROW NO-BREAK SPACE" character (code 8239) is used
27
+ * instead of a space (code 32) before AM/PM.
28
+ */
29
+ function fixChromiumSpace(original) {
30
+ return original.replace(new RegExp(String.fromCharCode(8239), 'g'), ' ');
31
+ }
25
32
  /** Converts the given FullDate into a string in the user's locale, or the given localeOverride. */
26
33
  function toLocaleString(fullDate, formatOptions) {
27
- return (0, luxon_date_time_conversion_1.toLuxonDateTime)(fullDate).toLocaleString({
34
+ const localeString = (0, luxon_date_time_conversion_1.toLuxonDateTime)(fullDate).toLocaleString({
28
35
  ...formatOptions,
29
36
  }, {
30
37
  locale: formatOptions?.locale ?? locales_1.userLocale,
31
38
  });
39
+ return fixChromiumSpace(localeString);
32
40
  }
33
41
  exports.toLocaleString = toLocaleString;
34
42
  /**
@@ -39,7 +47,10 @@ exports.toLocaleString = toLocaleString;
39
47
  * already has many formatting options.
40
48
  */
41
49
  function toFormattedString(fullDate, format, localeOverride = locales_1.userLocale) {
42
- return (0, luxon_date_time_conversion_1.toLuxonDateTime)(fullDate).toFormat(format, { locale: localeOverride });
50
+ const formattedString = (0, luxon_date_time_conversion_1.toLuxonDateTime)(fullDate)
51
+ .toFormat(format, { locale: localeOverride })
52
+ .replace(/ /g, ' ');
53
+ return fixChromiumSpace(formattedString);
43
54
  }
44
55
  exports.toFormattedString = toFormattedString;
45
56
  function toHtmlInputString(fullDate, inputType, includeSeconds) {
@@ -17,13 +17,21 @@ export function toIsoString(fullDate) {
17
17
  }
18
18
  return isoString;
19
19
  }
20
+ /**
21
+ * Chromium has a weird behavior where the "NARROW NO-BREAK SPACE" character (code 8239) is used
22
+ * instead of a space (code 32) before AM/PM.
23
+ */
24
+ function fixChromiumSpace(original) {
25
+ return original.replace(new RegExp(String.fromCharCode(8239), 'g'), ' ');
26
+ }
20
27
  /** Converts the given FullDate into a string in the user's locale, or the given localeOverride. */
21
28
  export function toLocaleString(fullDate, formatOptions) {
22
- return toLuxonDateTime(fullDate).toLocaleString({
29
+ const localeString = toLuxonDateTime(fullDate).toLocaleString({
23
30
  ...formatOptions,
24
31
  }, {
25
32
  locale: formatOptions?.locale ?? userLocale,
26
33
  });
34
+ return fixChromiumSpace(localeString);
27
35
  }
28
36
  /**
29
37
  * Provides arbitrary date formatting using Luxon. For full details on the options for the format
@@ -33,7 +41,10 @@ export function toLocaleString(fullDate, formatOptions) {
33
41
  * already has many formatting options.
34
42
  */
35
43
  export function toFormattedString(fullDate, format, localeOverride = userLocale) {
36
- return toLuxonDateTime(fullDate).toFormat(format, { locale: localeOverride });
44
+ const formattedString = toLuxonDateTime(fullDate)
45
+ .toFormat(format, { locale: localeOverride })
46
+ .replace(/ /g, ' ');
47
+ return fixChromiumSpace(formattedString);
37
48
  }
38
49
  export function toHtmlInputString(fullDate, inputType, includeSeconds) {
39
50
  if (inputType === FullDatePartEnum.Date) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "date-vir",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Easy and explicit dates and times",
5
5
  "keywords": [
6
6
  "date",