This commit is contained in:
Thibault Deckers 2022-08-26 00:15:19 +02:00
parent a05c8ad7d5
commit 726c8a76a5
2 changed files with 3 additions and 1 deletions

View file

@ -23,7 +23,7 @@ import 'package:flutter/foundation.dart';
class VideoMetadataFormatter {
static final _dateY4M2D2H2m2s2Pattern = RegExp(r'(\d{4})[-/](\d{2})[-/](\d{2}) (\d{2}):(\d{2}):(\d{2})');
static final _dateY4M2D2H2m2s2APmPattern = RegExp(r'(\d{4})[-/](\d{1,2})[-/](\d{1,2})T(\d+):(\d+):(\d+)( ([ap]m))?Z');
static final _dateY4M2D2H2m2s2APmPattern = RegExp(r'(\d{4})[-/](\d{1,2})[-/](\d{1,2})T(\d+):(\d+):(\d+)( ([ap]\.? ?m\.?))?Z');
static final _ambiguousDatePatterns = {
RegExp(r'^\d{2}[-/]\d{2}[-/]\d{4}$'),
};
@ -124,6 +124,7 @@ class VideoMetadataFormatter {
// - `UTC 2021-05-30 19:14:21`
// - `2021/10/31 21:23:17`
// - `2021-09-10T7:14:49 pmZ`
// - `2022-01-28T5:07:46 p. m.Z`
// - `2012-1-1T12:00:00Z`
// - `2021` (not enough to build a date)

View file

@ -9,6 +9,7 @@ void main() {
expect(VideoMetadataFormatter.parseVideoDate('UTC 2021-05-30 19:14:21'), DateTime(2021, 5, 30, 19, 14, 21).millisecondsSinceEpoch);
expect(VideoMetadataFormatter.parseVideoDate('2021/10/31 21:23:17'), DateTime(2021, 10, 31, 21, 23, 17).millisecondsSinceEpoch);
expect(VideoMetadataFormatter.parseVideoDate('2021-09-10T7:14:49 pmZ'), DateTime(2021, 9, 10, 19, 14, 49).millisecondsSinceEpoch);
expect(VideoMetadataFormatter.parseVideoDate('2022-01-28T5:07:46 p. m.Z'), DateTime(2022, 1, 28, 5, 7, 46).millisecondsSinceEpoch);
expect(VideoMetadataFormatter.parseVideoDate('2012-1-1T12:00:00Z'), DateTime(2012, 1, 1, 12, 0, 0).millisecondsSinceEpoch);
});