Skip to content

Commit

Permalink
removed use of regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Fosse committed Apr 10, 2024
1 parent b629f09 commit 3410e83
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/adapters/defra.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,15 @@ let formatData = function (source, data) {

function sanitizeDate(dateString) {
log.debug(`Sanitizing date: ${dateString}`);
let adjustedDateString = dateString.replace(/(\d{2})(\d{2}:)/, '$1 $2');

try {
const date = DateTime.fromFormat(
adjustedDateString,
'dd/MM/yyyy HH:mm:ss',
dateString,
'dd/MM/yyyyHH:mm:ss',
{ zone: 'Europe/London' }
);

if (!date.isValid) {
log.debug('Invalid DateTime after adjustment:', adjustedDateString);
log.debug('Invalid DateTime after adjustment:', dateString);
return null;
}
return {
Expand Down

0 comments on commit 3410e83

Please sign in to comment.