exif-date-regex

1.0.1 • Public • Published

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

Package Sidebar

Install

npm i exif-date-regex

Weekly Downloads

2

Version

1.0.1

License

MIT-0

Unpacked Size

4.63 kB

Total Files

5

Last publish

Collaborators

  • shinnn