π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Fix Photos date query parsing test
Neeraj Guptac73f444f9778
diff --git a/mobile/apps/photos/lib/services/date_parse_service.dart b/mobile/apps/photos/lib/services/date_parse_service.dartindex 86a4b54896..d13dbd942b 100644--- a/mobile/apps/photos/lib/services/date_parse_service.dart+++ b/mobile/apps/photos/lib/services/date_parse_service.dart@@ -355,12 +355,16 @@ class DateParseService {final n1 = numbers[0];final n2 = numbers[1];- if (n1 >= 1 && n1 <= 31 && n2 >= _MIN_YEAR && n2 <= _MAX_YEAR) {- day = n1;- year = n2;- } else if (n2 >= 1 && n2 <= 31 && n1 >= _MIN_YEAR && n1 <= _MAX_YEAR) {- day = n2;+ if (n1 >= _MIN_YEAR && n1 <= _MAX_YEAR) {year = n1;+ if (n2 >= 1 && n2 <= 31) {+ day = n2;+ }+ } else if (n2 >= _MIN_YEAR && n2 <= _MAX_YEAR) {+ year = n2;+ if (n1 >= 1 && n1 <= 31) {+ day = n1;+ }}} else if (numbers.length == 1) {final n = numbers.first;diff --git a/mobile/apps/photos/test/utils/date_query_parsing_test.dart b/mobile/apps/photos/test/utils/date_query_parsing_test.dartindex b013a448b6..55b5a58162 100644--- a/mobile/apps/photos/test/utils/date_query_parsing_test.dart+++ b/mobile/apps/photos/test/utils/date_query_parsing_test.dart@@ -215,11 +215,11 @@ void main() {expect(parsedDate.year, 2025);});- test('should parse ambiguous "01/02/2024" as MM/DD/YYYY (Jan 2)', () {- // Test your specific heuristic for ambiguous cases+ test('should parse ambiguous "01/02/2024" as DD/MM/YYYY (Feb 1)', () {+ // The parser prefers DD/MM when both day and month are plausible.final PartialDate parsedDate = dateParseService.parse('01/02/2024');expect(parsedDate.day, 1);- expect(parsedDate.month, 1);+ expect(parsedDate.month, 2);expect(parsedDate.year, 2024);});