@marktiderman/genesis-ui-native 2.8.0 → 2.8.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marktiderman/genesis-ui-native",
3
- "version": "2.8.0",
3
+ "version": "2.8.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -69,7 +69,7 @@
69
69
  "@expo/ui": ">=58.0.0",
70
70
  "@gorhom/bottom-sheet": ">=5.0.0",
71
71
  "@hookform/resolvers": "^3.0.0 || ^4.0.0 || ^5.0.0",
72
- "@marktiderman/genesis-core": "^1.16.0",
72
+ "@marktiderman/genesis-core": "^1.16.1",
73
73
  "@marktiderman/genesis-design-system": "^1.5.0",
74
74
  "@react-native-community/datetimepicker": ">=8.0.0",
75
75
  "@shopify/flash-list": ">=2.0.0",
@@ -697,6 +697,9 @@ describe("calendar days", () => {
697
697
  // Only a whole day: a timestamp or trailing text isn't one.
698
698
  expect(dayToDate("2026-01-02T00:00:00Z")).toBeNull();
699
699
  expect(formatDay("2026-01-02junk")).toBe("2026-01-02junk");
700
+ // A timestamp is the day on the clock asked for, not its UTC day: 8pm in New York on Jan 2.
701
+ expect(formatDay("2026-01-03T01:00:00Z", "America/New_York")).toBe(new Intl.DateTimeFormat(undefined, { dateStyle: "medium" }).format(new Date(2026, 0, 2)));
702
+ expect(formatDay("2026-01-03T01:00:00Z", "UTC")).toBe(new Intl.DateTimeFormat(undefined, { dateStyle: "medium" }).format(new Date(2026, 0, 3)));
700
703
  // What `new Date(day)` would have shown here: the day before.
701
704
  expect(new Date("2026-01-02").getDate()).toBe(1);
702
705
  });
@@ -62,9 +62,18 @@ export function dateToDay(date: Date): string {
62
62
  }
63
63
 
64
64
  /** A calendar day, the same day on every clock. */
65
- export function formatDay(value: unknown): string {
65
+ /**
66
+ * A day. A calendar day (`YYYY-MM-DD`) from its parts; a timestamp as the day it is on `zone`'s
67
+ * clock (core's `wallClock`), so an 8pm edit in New York isn't tomorrow's (its UTC day).
68
+ */
69
+ export function formatDay(value: unknown, zone: string = personTimeZone()): string {
66
70
  const date = dayToDate(value);
67
- return date ? DAY.format(date) : String(value);
71
+ if (date) return DAY.format(date);
72
+ const text = String(value);
73
+ const at = /^\d{4}-\d{2}-\d{2}[T ]/.test(text) ? new Date(text) : null;
74
+ if (!at || Number.isNaN(at.getTime()) || !isTimeZone(zone)) return text;
75
+ const wall = wallClock(zone, at);
76
+ return DAY.format(new Date(wall.year, wall.month - 1, wall.day));
68
77
  }
69
78
 
70
79
  /** A column's clock: "viewer" (the default) and "practice" from `zones`, else a valid IANA name. */
@@ -116,7 +125,7 @@ export function displayText(
116
125
  case "badge":
117
126
  return titleCase(String(value));
118
127
  case "date":
119
- return formatDay(value);
128
+ return formatDay(value, timeZone);
120
129
  case "datetime":
121
130
  return formatInstant(value, timeZone);
122
131
  case "url": {