Overview
Comment: | Handle 19xx dates correctly when passed as DD/MM/YY |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA3-256: |
a386f31c530d4be63ce7a746abf7dd6c |
User & Date: | bohwaz on 2023-05-10 19:40:17 |
Other Links: | branch diff | manifest | tags |
Context
2023-05-10
| ||
19:41 | Normalize line breaks in user data, and also trim all values check-in: cbbcfb1e51 user: bohwaz tags: dev | |
19:40 | Handle 19xx dates correctly when passed as DD/MM/YY check-in: a386f31c53 user: bohwaz tags: dev | |
15:15 | Implement delete selected users from list check-in: 8b9124bc51 user: bohwaz tags: dev | |
Changes
Modified src/include/lib/Garradin/Entity.php from [f2feecdbe4] to [620eaeef49].
︙ | ︙ | |||
37 38 39 40 41 42 43 | $value = trim((string) $value); if (!$value) { return null; } if (preg_match('!^\d{2}/\d{2}/\d{2}$!', $value)) { | > > > > > > > > > > > | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | $value = trim((string) $value); if (!$value) { return null; } if (preg_match('!^\d{2}/\d{2}/\d{2}$!', $value)) { $year = substr($value, -2); // Make sure recent years are in the 21st century if ($year < date('y') + 10) { $year = sprintf('20%02d', $year); } // while old dates remain in the old one else { $year = sprintf('19%02d', $year); } return Date::createFromFormat('d/m/Y', substr($value, 0, -2) . $year); } elseif (preg_match('!^\d{2}/\d{2}/\d{4}$!', $value)) { return Date::createFromFormat('d/m/Y', $value); } elseif (preg_match('!^\d{4}/\d{2}/\d{2}$!', $value)) { return Date::createFromFormat('Y/m/d', $value); } |
︙ | ︙ |