mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-24 13:54:31 +00:00
Major additions: - Complete Next.js studio application with 1600+ components - Docker support (Dockerfile.combined, docker-compose.yml) - GCP deployment documentation and benchmarks - SQL benchmark scripts for performance testing - Sentry integration for monitoring - Comprehensive test suite and mocks Studio features: - Dashboard and admin interfaces - Data visualization components - Authentication and user management - API integration with RuVector backend - Static data and public assets 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
29 lines
1 KiB
TypeScript
29 lines
1 KiB
TypeScript
import dayjs, { Dayjs } from 'dayjs'
|
|
|
|
/**
|
|
* Safely parses a migration version string as a date.
|
|
* Migration versions are typically in the format YYYYMMDDHHmmss (e.g., "20231128095400").
|
|
* However, some projects may have custom version formats (e.g., "001", "002") that cannot be parsed as dates.
|
|
*
|
|
* @param version - Migration version string
|
|
* @returns Dayjs object if the version is a valid datetime, null otherwise
|
|
*
|
|
* @example
|
|
* const parsed = parseMigrationVersion('20231128095400')
|
|
* if (parsed) {
|
|
* console.log(parsed.fromNow()) // "2 hours ago"
|
|
* console.log(parsed.format('DD MMM YYYY')) // "28 Nov 2023"
|
|
* }
|
|
*
|
|
* @example
|
|
* const invalid = parseMigrationVersion('001') // returns null
|
|
*/
|
|
export function parseMigrationVersion(version: string | null | undefined): Dayjs | undefined {
|
|
if (!version) return undefined
|
|
|
|
// Must contain only digits
|
|
if (!/^\d{14}$/.test(version)) return undefined
|
|
|
|
const parsed = dayjs(version, 'YYYYMMDDHHmmss', true)
|
|
return parsed.isValid() ? parsed : undefined
|
|
}
|