mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
* add documentation for ai agents * docs: consolidate CLAUDE.md and CONTRIBUTING.md, add style guidelines - Refactor CLAUDE.md to reference CONTRIBUTING.md for build/test/format info - Expand CONTRIBUTING.md with comprehensive build targets, env vars, and testing - Add code style guidelines section with conventional commits - Standardize SDK prettier config to use single quotes (matching web) - Add project-level Claude Code settings to disable co-author attribution * style(sdk): apply prettier with single quotes Run prettier across sdk/base and sdk/package to apply the standardized quote style (single quotes matching web). * docs: add USER.md for per-developer TODO filtering - Add agents/USER.md to .gitignore (contains user identifier) - Document session startup flow in CLAUDE.md: - Create USER.md if missing, prompting for identifier - Filter TODOs by @username tags - Offer relevant TODOs on session start * docs: add i18n documentation task to agent TODOs * docs: document i18n ID patterns in core/ Add agents/i18n-patterns.md covering rust-i18n setup, translation file format, t!() macro usage, key naming conventions, and locale selection. Remove completed TODO item and add reference in CLAUDE.md. * chore: clarify that all builds work on any OS with Docker
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
const matchTimeRegex = /^\s*(\d+)?(\.\d+)?\s*(ms|s|m|h|d)/
|
|
|
|
const unitMultiplier = (unit?: string) => {
|
|
if (!unit) return 1
|
|
if (unit === 'ms') return 1
|
|
if (unit === 's') return 1000
|
|
if (unit === 'm') return 1000 * 60
|
|
if (unit === 'h') return 1000 * 60 * 60
|
|
if (unit === 'd') return 1000 * 60 * 60 * 24
|
|
throw new Error(`Invalid unit: ${unit}`)
|
|
}
|
|
const digitsMs = (digits: string | null, multiplier: number) => {
|
|
if (!digits) return 0
|
|
const value = parseInt(digits.slice(1))
|
|
const divideBy = multiplier / Math.pow(10, digits.length - 1)
|
|
return Math.round(value * divideBy)
|
|
}
|
|
export const inMs = (time?: string | number) => {
|
|
if (typeof time === 'number') return time
|
|
if (!time) return undefined
|
|
const matches = time.match(matchTimeRegex)
|
|
if (!matches) throw new Error(`Invalid time format: ${time}`)
|
|
const [_, leftHandSide, digits, unit] = matches
|
|
const multiplier = unitMultiplier(unit)
|
|
const firstValue = parseInt(leftHandSide || '0') * multiplier
|
|
const secondValue = digitsMs(digits, multiplier)
|
|
|
|
return firstValue + secondValue
|
|
}
|