Files
aliasvault/apps/mobile-app/utils/DateFormatter.ts
dependabot[bot] 423330c864 Upgrade mobile app Expo and browser extension WXT frameworks (#2067)
* Bump the npm_and_yarn group across 2 directories with 2 updates

Bumps the npm_and_yarn group with 1 update in the /apps/browser-extension directory: [ws](https://github.com/websockets/ws).
Bumps the npm_and_yarn group with 1 update in the /apps/mobile-app directory: [postcss](https://github.com/postcss/postcss).


Updates `ws` from 8.18.2 to 8.21.0
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.18.2...8.21.0)

Updates `ws` from 8.18.2 to 8.21.0
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.18.2...8.21.0)

Updates `postcss` from 8.4.49 to 8.5.15
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.4.49...8.5.15)

Updates `postcss` from 8.4.49 to 8.5.15
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.4.49...8.5.15)

---
updated-dependencies:
- dependency-name: postcss
  dependency-version: 8.5.15
  dependency-type: indirect
- dependency-name: ws
  dependency-version: 8.21.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update package-lock.json (#2067)

* Update NodeJS to latest 24.x LTS

* Revert Expo back to 53.x (#2067)

* Upgrade expo and react-native (#2067)

* Update mobile app to support Expo 56 (#2067)

* Update wxt (#2067)

* Change util filenames to be consistent PascalCase (#2067)

* Restore deep-linking behavior to work with new Expo Router (#2067)

* Update eslint.config.js (#2067)

* Update package-lock.json (#2067)

* Refactor linting (#2067)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Leendert de Borst <ldeborst@xivisoft.com>
2026-05-26 10:47:39 +02:00

43 lines
1.4 KiB
TypeScript

/**
* Centralized utility for formatting Date values consistently across the client application.
* All dates are stored in UTC with the format: "yyyy-MM-dd HH:mm:ss.fff" (23 characters).
* This format ensures:
* - SQLite native support for date functions
* - No timezone ambiguity (all dates are UTC)
* - Consistent precision with milliseconds for accurate sorting/comparison
* - Readable space separator instead of 'T'
* - Lexicographic sorting works correctly
*/
/**
* Formats a Date to the standard format string: "yyyy-MM-dd HH:mm:ss.fff" (23 characters).
* @param date - The Date to format
* @returns Formatted date-time string in format "yyyy-MM-dd HH:mm:ss.fff"
*/
export function toStandardFormat(date: Date): string {
return date.toISOString()
.replace('T', ' ')
.replace('Z', '')
.substring(0, 23);
}
/**
* Formats the current UTC time to the standard format string.
* @returns Formatted current UTC date-time string
*/
export function now(): string {
return toStandardFormat(new Date());
}
/**
* Formats a Date to the birth date format (no milliseconds, time set to 00:00:00).
* Format: "yyyy-MM-dd 00:00:00" (19 characters).
* @param date - The Date to format
* @returns Formatted date string in format "yyyy-MM-dd 00:00:00"
*/
export function toBirthDateFormat(date: Date): string {
const isoString = date.toISOString();
const datePart = isoString.substring(0, 10); // yyyy-MM-dd
return `${datePart} 00:00:00`;
}