fix(compliance): Improve compliance

This commit is contained in:
2025-05-26 10:17:50 +00:00
parent 113ae22c42
commit e7c3a774a3
26 changed files with 2435 additions and 2010 deletions

View File

@ -34,4 +34,33 @@ export abstract class BaseDecoder {
public getXml(): string {
return this.xml;
}
/**
* Parses a CII date string based on format code
* @param dateStr Date string
* @param format Format code (e.g., '102' for YYYYMMDD)
* @returns Timestamp in milliseconds
*/
protected parseCIIDate(dateStr: string, format?: string): number {
if (!dateStr) return Date.now();
// Format 102 is YYYYMMDD
if (format === '102' && dateStr.length === 8) {
const year = parseInt(dateStr.substring(0, 4));
const month = parseInt(dateStr.substring(4, 6)) - 1; // Month is 0-indexed in JS
const day = parseInt(dateStr.substring(6, 8));
return new Date(year, month, day).getTime();
}
// Format 610 is YYYYMM
if (format === '610' && dateStr.length === 6) {
const year = parseInt(dateStr.substring(0, 4));
const month = parseInt(dateStr.substring(4, 6)) - 1;
return new Date(year, month, 1).getTime();
}
// Try to parse as ISO date or other standard formats
const parsed = Date.parse(dateStr);
return isNaN(parsed) ? Date.now() : parsed;
}
}