1.0.1 • Published 7 years ago
exif-date-regex v1.0.1
exif-date-regex
A regular expression to validate and parse Exif date format
import exifDateRegex from 'exif-date-regex';
exifDateRegex.exec('2018:06:27 14:05:28').groups; /*=> {
year: '2018',
month: '06',
date: '27',
hours: '14',
minutes: '05',
seconds: '28'
} */According to the Exif specification (PDF), the format of DateTime, DateTimeOriginal and DateTimeDigitaized is:
"YYYY:MM:DD HH:MM:SS" with time shown in 24-hour format, and the date and time separated by one blank character
Installation
npm install exif-date-regexAPI
import exifDateRegex from 'exif-date-regex';exifDateRegex
Type: RegExp
The regular expression has 6 capture groups year, month, date, hours, minutes and seconds.
'2016:07:29 00:00:00'.replace(exifDateRegex, '$<year>/$<month>/$<date>'); //=> '2016/07/29'Leap years are taken into consideration.
exifDateRegex.test('2016:02:29 12:30:00'); //=> true
exifDateRegex.test('2017:02:29 12:30:00'); //=> falseLicense
MIT No Attribution © 2019 Shinnosuke Watanabe