1.0.1 • Published 5 years ago

exif-date-regex v1.0.1

Weekly downloads
1
License
MIT-0
Repository
github
Last release
5 years ago

exif-date-regex

npm version Build Status

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

Use npm.

npm install exif-date-regex

API

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'); //=> false

License

MIT No Attribution © 2019 Shinnosuke Watanabe