()
| 10 | * Returns date as YYYY-MM-DD and minutes since midnight |
| 11 | */ |
| 12 | export function getNowPt(): NowPt { |
| 13 | const formatter = new Intl.DateTimeFormat("en-US", { |
| 14 | timeZone: "America/Los_Angeles", |
| 15 | year: "numeric", |
| 16 | month: "2-digit", |
| 17 | day: "2-digit", |
| 18 | hour: "2-digit", |
| 19 | minute: "2-digit", |
| 20 | hour12: false, |
| 21 | }) |
| 22 | |
| 23 | const parts = formatter.formatToParts(new Date()) |
| 24 | const get = (type: string) => parts.find((p) => p.type === type)?.value ?? "" |
| 25 | |
| 26 | const date = `${get("year")}-${get("month")}-${get("day")}` |
| 27 | const minutes = parseInt(get("hour"), 10) * 60 + parseInt(get("minute"), 10) |
| 28 | |
| 29 | return { date, minutes } |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Parse publish_time_pt string to minutes since midnight |
no test coverage detected