prefer official EKAP detail deadline
This commit is contained in:
@@ -48,3 +48,50 @@ export function announcementFields(text) {
|
||||
if (/hizmet alımı\s+4734/i.test(content)) result.alimTuru = 'Kiralama ve Hizmet Alımı';
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* EKAP ihale detayındaki tarih-saat alanını liste ve takvim alanlarına ayırır.
|
||||
* Ayrıştırılamayan/eksik değerler için varsayılan tarih veya saat üretmez.
|
||||
*/
|
||||
export function officialDateFields(value) {
|
||||
const raw = String(value || '').trim();
|
||||
if (!raw) return {};
|
||||
const dotted = raw.match(/(\d{2})\.(\d{2})\.(\d{4})\s*(?:[-–T]|\s)\s*(\d{1,2}):(\d{2})/);
|
||||
if (dotted) return {
|
||||
tarih: `${dotted[1]}.${dotted[2]}.${dotted[3]}`,
|
||||
saat: `${dotted[4].padStart(2, '0')}:${dotted[5]}`,
|
||||
sourceDateTime: raw,
|
||||
};
|
||||
const iso = raw.match(/(\d{4})-(\d{2})-(\d{2})[T\s]+(\d{1,2}):(\d{2})/);
|
||||
if (iso) return {
|
||||
tarih: `${iso[3]}.${iso[2]}.${iso[1]}`,
|
||||
saat: `${iso[4].padStart(2, '0')}:${iso[5]}`,
|
||||
sourceDateTime: raw,
|
||||
};
|
||||
return { sourceDateTime: raw };
|
||||
}
|
||||
|
||||
/**
|
||||
* İlan metninden çıkarılan alanları, resmî EKAP ihale detayındaki alanlarla
|
||||
* birleştirir. Resmî detay tarihi ilan HTML'inden eski/çelişkili bir tarih
|
||||
* gelirse üstün tutulur; fark kullanıcıya açık bir uyarı olarak taşınır.
|
||||
*/
|
||||
export function mergeAnnouncementFields(text, authoritative = {}) {
|
||||
const parsed = announcementFields(text);
|
||||
const sourceTarih = String(authoritative.tarih || '').trim();
|
||||
const sourceSaat = String(authoritative.saat || '').trim();
|
||||
const dateConflict = Boolean(
|
||||
(sourceTarih && parsed.tarih && sourceTarih !== parsed.tarih) ||
|
||||
(sourceSaat && parsed.saat && sourceSaat !== parsed.saat),
|
||||
);
|
||||
const merged = {
|
||||
...parsed,
|
||||
...(sourceTarih ? { tarih: sourceTarih } : {}),
|
||||
...(sourceSaat ? { saat: sourceSaat } : {}),
|
||||
...(authoritative.sourceDateTime ? { sourceDateTime: authoritative.sourceDateTime } : {}),
|
||||
};
|
||||
if (dateConflict) {
|
||||
merged.sourceDateWarning = 'Resmî ihale detay tarihi ile ilan metnindeki tarih farklı; güncel detay tarihi esas alındı.';
|
||||
}
|
||||
return merged;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user