Skip to content

Commit df63c4b

Browse files
committed
Add eventToShortText shared formatter and formatEventDate helper
Replaces 4 duplicated event-to-text formatters across repos with a single shared function. Handles all item types: number+unit, checkbox (null content returns date), select (truncated labels), datasource-search (medication), date, string, boolean, and object fallbacks. Adds formatEventDate() for centralized date formatting. Includes 21 tests.
1 parent 37a9208 commit df63c4b

16 files changed

Lines changed: 619 additions & 9 deletions

js/HDSModel/eventToShortText.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Format a Unix timestamp (seconds) as a date string.
3+
* Centralized here so we can later hook into user locale/format preferences.
4+
*/
5+
export declare function formatEventDate(timeSec: number): string;
6+
/**
7+
* Convert an event's content to a short human-readable string.
8+
* Resolves itemDef from the model (streamId + eventType match).
9+
*
10+
* With itemDef: select → localized option label, checkbox → "Yes",
11+
* number → "60 Kg" (with unit symbol from eventType extras),
12+
* datasource-search → drug label + intake details, date → ISO date.
13+
*
14+
* Without itemDef (fallback): derives unit from eventType symbol if available,
15+
* for object content produces short textual representation.
16+
*/
17+
export declare function eventToShortText(event: any): string | null;
18+
//# sourceMappingURL=eventToShortText.d.ts.map

js/HDSModel/eventToShortText.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/HDSModel/eventToShortText.js

Lines changed: 174 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/HDSModel/eventToShortText.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/HDSModel/reminders.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface ReminderStatus {
1010
importance: 'may' | 'should' | 'must';
1111
lastEntry?: number;
1212
lastEventContent?: any;
13+
lastEvent?: any;
1314
dueDate?: number;
1415
sources: ReminderSource[];
1516
}

js/HDSModel/reminders.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/HDSModel/reminders.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)