Something went wrong. Try again.
A single hub to check all of my ATProto activity
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556import { STAR_SCALE } from "./config";import { cleanTitle, starsHtml } from "./format";import type { EventExtra, Interval, TimelineEvent } from "./types";
// Build a timeline event, or null when there's no usable date (so the caller// can `.filter(notNull)` it out rather than dump it at the epoch).export function evt( rawDate: string | Date | undefined, verb: string, title: string | undefined, extra: EventExtra = {},): TimelineEvent | null { if (!rawDate) return null; const date = new Date(rawDate); if (Number.isNaN(date.getTime())) return null; return { date, verb, colorVerb: extra.colorVerb || verb, // pill colour (topic) can differ from pill text title: cleanTitle(title || ""), stars: starsHtml(extra.rating, extra.ratingScale || STAR_SCALE), meta: extra.meta || "", note: extra.note || "", image: extra.image || "", photos: extra.photos || [], url: extra.url || "", thread: extra.thread || [], seriesId: extra.seriesId, seriesName: extra.seriesName, };}
// A job/degree span (null end ⇒ ongoing), or null if the start date is bad.export function toInterval( startRaw: string | undefined, endRaw: string | undefined, verb: Interval["verb"], org?: string, role?: string,): Interval | null { if (!startRaw) return null; const start = new Date(startRaw); if (Number.isNaN(start.getTime())) return null; const end = endRaw ? new Date(endRaw) : null; if (end && Number.isNaN(end.getTime())) return null; return { start, end, verb, org: org || "", role: role || "" };}
// The clause after "started/finished/is/was", e.g.// "working at Carto as a Senior Data Scientist" or "studying BSc CS at UC3M".export function intervalPredicate(iv: Interval): string { return iv.verb === "studying" ? `studying ${iv.role ? iv.role + " " : ""}at ${iv.org}` : `${iv.verb} at ${iv.org}${iv.role ? ` as a ${iv.role}` : ""}`;}