Files
Goa-gel-fullstack/backend/src/common/utils/date.util.ts
Mahi d9de183e51 feat: Runtime configuration and Docker deployment improvements
Frontend:
- Add runtime configuration service for deployment-time API URL injection
- Create docker-entrypoint.sh to generate config.json from environment variables
- Update ApiService, ApprovalService, and DocumentViewer to use RuntimeConfigService
- Add APP_INITIALIZER to load runtime config before app starts

Backend:
- Fix init-blockchain.js to properly quote mnemonic phrases in .env file
- Improve docker-entrypoint.sh with health checks and better error handling

Docker:
- Add API_BASE_URL environment variable to frontend container
- Update docker-compose.yml with clear documentation for remote deployment
- Reorganize .env.example with clear categories (REQUIRED FOR REMOTE, PRODUCTION, AUTO-GENERATED)

Workflow fixes:
- Fix DepartmentApproval interface to match backend schema
- Fix stage transformation for 0-indexed stageOrder
- Fix workflow list to show correct stage count from definition.stages

Cleanup:
- Move development artifacts to .trash directory
- Remove root-level package.json (was only for utility scripts)
- Add .trash/ to .gitignore
2026-02-08 18:45:01 -04:00

95 lines
2.6 KiB
TypeScript

export class DateUtil {
static getCurrentTimestamp(): Date {
return new Date();
}
static getTimestampInSeconds(): number {
return Math.floor(Date.now() / 1000);
}
static addDays(date: Date, days: number): Date {
const result = new Date(date);
result.setDate(result.getDate() + days);
return result;
}
static addHours(date: Date, hours: number): Date {
const result = new Date(date);
result.setHours(result.getHours() + hours);
return result;
}
static addMinutes(date: Date, minutes: number): Date {
const result = new Date(date);
result.setMinutes(result.getMinutes() + minutes);
return result;
}
static addSeconds(date: Date, seconds: number): Date {
const result = new Date(date);
result.setSeconds(result.getSeconds() + seconds);
return result;
}
static isExpired(date: Date): boolean {
return date < this.getCurrentTimestamp();
}
static getDifferenceInSeconds(date1: Date, date2: Date): number {
return Math.floor((date1.getTime() - date2.getTime()) / 1000);
}
static getDifferenceInMinutes(date1: Date, date2: Date): number {
return Math.floor(this.getDifferenceInSeconds(date1, date2) / 60);
}
static getDifferenceInHours(date1: Date, date2: Date): number {
return Math.floor(this.getDifferenceInMinutes(date1, date2) / 60);
}
static getDifferenceInDays(date1: Date, date2: Date): number {
return Math.floor(this.getDifferenceInHours(date1, date2) / 24);
}
static startOfDay(date: Date = new Date()): Date {
const result = new Date(date);
result.setHours(0, 0, 0, 0);
return result;
}
static endOfDay(date: Date = new Date()): Date {
const result = new Date(date);
result.setHours(23, 59, 59, 999);
return result;
}
static startOfMonth(date: Date = new Date()): Date {
const result = new Date(date);
result.setDate(1);
result.setHours(0, 0, 0, 0);
return result;
}
static endOfMonth(date: Date = new Date()): Date {
const result = new Date(date.getFullYear(), date.getMonth() + 1, 0);
result.setHours(23, 59, 59, 999);
return result;
}
static formatISO(date: Date): string {
return date.toISOString();
}
static formatDate(date: Date, format: string = 'DD/MM/YYYY'): string {
const day = String(date.getDate()).padStart(2, '0');
const month = String(date.getMonth() + 1).padStart(2, '0');
const year = date.getFullYear();
return format.replace('DD', day).replace('MM', month).replace('YYYY', year.toString());
}
static parseISO(dateString: string): Date {
return new Date(dateString);
}
}