Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jama5262 committed Jan 8, 2020
1 parent 05ed008 commit 26b75cf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lib/src/jiffy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class Jiffy {
.parse(replaceParseInput(input));
} else if (matchHyphenStringDateTime(input)) {
dateTime = DateFormat("yyyy-MM-dd").parse(input);
} else if (matchDartStringDateTime(input) || matchISOStringDateTime(input)) {
} else if (matchDartStringDateTime(input) ||
matchISOStringDateTime(input)) {
dateTime = DateTime.parse(input).toLocal();
} else if (matchSlashStringDateTime(input)) {
dateTime = DateFormat("yyyy/MM/dd").parse(input);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/utils/regex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ bool matchDartStringDateTime(String input) {

bool matchISOStringDateTime(String input) {
return RegExp(
r"\d{4}-\d{1,2}-\d{1,2}T\d{1,2}(:\d{1,2})?(:\d{1,2})?(.\d+)?(Z?)")
r"\d{4}-\d{1,2}-\d{1,2}T\d{1,2}(:\d{1,2})?(:\d{1,2})?(.\d+)?(Z?)")
.hasMatch(input);
}

Expand Down
10 changes: 4 additions & 6 deletions test/jiffy_display_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import 'package:test/test.dart';
void main() {
group('Test format and default format datetime methods', () {
test("Test format method", () {
expect(Jiffy("2019, 10, 16", "yyyy, MM, dd").format("MMMM dd, yyyy"),
"October 16, 2019");
expect(Jiffy("2019, 10, 16", "yyyy, MM, dd").format("'Today is' dd MMM"),
expect(Jiffy("20191016").format("MMMM dd, yyyy"), "October 16, 2019");
expect(Jiffy("2019-10-16 12:00").format("'Today is' dd MMM"),
"Today is 16 Oct");
expect(Jiffy("2019, 10, 16", "yyyy, MM, dd").format("MMMMEEEEd"),
expect(Jiffy("2019-10-16T00:00:00.000").format("MMMMEEEEd"),
"Wednesday, October 16");
expect(Jiffy("2019, 10, 16", "yyyy, MM, dd").format(),
"2019-10-16T00:00:00.000");
expect(Jiffy("2019/10/16").format(), "2019-10-16T00:00:00.000");
});
test("Test from method", () {
expect(Jiffy([2019, 10, 16]).E, "Wed");
Expand Down

0 comments on commit 26b75cf

Please sign in to comment.