@wtfalch/email 0.6.0 → 0.6.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.
@@ -10,14 +10,27 @@ import { useCallback, useEffect, useRef } from 'react';
10
10
  * time is the thing they do not know. */
11
11
  export function shortTime(iso, now = new Date()) {
12
12
  const then = new Date(iso);
13
+ /* Before the elapsed-time branches, not after them, and that ordering is
14
+ the whole of this function's only sharp edge.
15
+
16
+ Elapsed time and calendar day disagree for one hour out of every
17
+ twenty-four. Just after midnight a message sent forty-five minutes ago
18
+ was sent yesterday, so the row said "45m" under a heading that said
19
+ "Yesterday" -- both true, and together they read as a fault. Checking
20
+ elapsed time first is what let that through; the version before this one
21
+ only reached the clock after the hour was up, so the hour where it
22
+ mattered was the hour it never covered.
23
+
24
+ The heading wins, because the heading is the thing the eye has already
25
+ read. A row under "Yesterday" says a time of day, always. */
26
+ if (dayGroup(iso, now) === 'Yesterday') {
27
+ return then.toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit' });
28
+ }
13
29
  const minutes = Math.max(0, Math.round((now.getTime() - then.getTime()) / 60_000));
14
30
  if (minutes < 1)
15
31
  return 'now';
16
32
  if (minutes < 60)
17
33
  return `${minutes}m`;
18
- if (dayGroup(iso, now) === 'Yesterday') {
19
- return then.toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit' });
20
- }
21
34
  const hours = Math.round(minutes / 60);
22
35
  if (hours < 24)
23
36
  return `${hours}h`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtfalch/email",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "The wtfalch estate: reading a mailbox over JMAP, and administering the Stalwart server it lives on. Two entries with no code in common.",
5
5
  "license": "MIT",
6
6
  "type": "module",