ident
All repositories: gitoria
1.3 KB
// lib/usedin-helpers.hl — what lib/usedin.hl shows (ident#26): a day as "Oct 22", a past time as "4 min ago". No table// access. Statics only.import { timestamp } from 'hl:time'static months = ['Jan' 'Feb' 'Mar' 'Apr' 'May' 'Jun' 'Jul' 'Aug' 'Sep' 'Oct' 'Nov' 'Dec']// "Oct 22" (UTC; hl:time knows no zones, hybriel #11) — with the year when it is not the current onestatic dayText = (ms, nowMs) => {if (ms == null) { return '' }t = timestamp(ms)m = toNumber(t.slice(5, 7))d = toNumber(t.slice(8, 10))y = t.slice(0, 4)let out = months[m - 1] + ' ' + dif (y != timestamp(nowMs).slice(0, 4)) { out = out + ' ' + y }return out}// no floor without hl:math: the whole part of a positive numberstatic whole = (x) => { return x - x % 1 }// "just now" · "4 min ago" · "2 h ago" · "3 d ago"static agoText = (ms, nowMs) => {if (ms == null) { return '' }secs = (nowMs - ms) / 1000if (secs < 60) { return 'just now' }m = whole(secs / 60)if (m < 60) { return m + ' min ago' }h = whole(m / 60)if (h < 24) { return h + ' h ago' }return whole(h / 24) + ' d ago'}// the row's second line: "since Oct 22 · last use 4 min ago" (a connection older than the recording: "last use not recorded")static usedLine = (since, lastLogin, nowMs) => {last = lastLogin == null ? 'last use not recorded' : 'last use ' + agoText(lastLogin, nowMs)return 'since ' + dayText(since, nowMs) + ' · ' + last}
Branches
Latest commits
- 67cf016d|||PR ident: vendor Hybriel day59mre
- 600c043dMerge branch 'v58-day58' into mainIdent
- 365f8c80|||PR ident: vendor Hybriel day58mre
- 585126e5Merge branch 'f16-setf' into mainIdent
- 953bf03a|||PR ident setF mirror dropped (hybriel#370)mre
- a1419d9cMerge branch 'f15-navigate' into mainIdent
- 3b3e451f|||PR ident#36 navigate to the app instead of location.assignmre
- e36f4516Merge branch 'f14-online' into mainIdent
- 2c5eac91|||PR ident#38 online state without probe timermre
- bf1980f2Merge branch 'v56-day56' into mainIdent
- 62ae0adf|||PR ident: vendor Hybriel day56mre
- 0d18abc4Merge branch 'f13-avatar' into mainIdent
- 2a99730a|||PR ident#37 avatar in hlmre
- fa4ed25bMerge branch 'f11-upsert' into mainIdent
- 8f3d9bc9|||PR ident#42 keyed upsert and removemre
- 675493b1ident#42: editing an identity upserts the one edited row (face editIdentity answers { identity, row }); a create or delete keeps the whole list because the rows' position-dependent parts (default, Delete, Identity n) changemre
- 45e55303ident#42: an app write patches one row: upsert on create, edit and new secret, one-argument remove on delete; the faces answer the changed app (or the deleted id), not the whole listmre
- 991641d4Merge branch 'f10-access' into mainIdent
- e56d8273|||PR ident#34 part 4: access and inbox fixed classesmre
- df7696dbident#34: tests: access ticks selector quoting fixmre