refactor: unify date handling with utility functions
- Replaced direct date manipulations with utility functions like `getToday`, `parseDate`, and `createDateFromParts` across various components and services for consistency. - Updated date initialization in `JiraAnalyticsService`, `BackupService`, and `DailyClient` to improve clarity and maintainability. - Enhanced date parsing in forms and API routes to ensure proper handling of date strings.
This commit is contained in:
@@ -3,7 +3,7 @@ import { exec } from 'child_process';
|
||||
import { promisify } from 'util';
|
||||
import path from 'path';
|
||||
import { createHash } from 'crypto';
|
||||
import { formatDateForDisplay, getToday } from './date-utils';
|
||||
import { formatDateForDisplay, getToday, parseDate } from './date-utils';
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
@@ -160,7 +160,7 @@ export class BackupUtils {
|
||||
// Format: 2025-09-18T14-12-05-737Z -> 2025-09-18T14:12:05.737Z
|
||||
const isoString = dateMatch[2]
|
||||
.replace(/T(\d{2})-(\d{2})-(\d{2})-(\d{3})Z/, 'T$1:$2:$3.$4Z');
|
||||
date = new Date(isoString);
|
||||
date = parseDate(isoString);
|
||||
}
|
||||
|
||||
return { type, date };
|
||||
@@ -170,7 +170,7 @@ export class BackupUtils {
|
||||
* Génère un nom de fichier de backup
|
||||
*/
|
||||
static generateBackupFilename(type: 'manual' | 'automatic'): string {
|
||||
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
||||
const timestamp = getToday().toISOString().replace(/[:.]/g, '-');
|
||||
return `towercontrol_${type}_${timestamp}.db`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user