mirror of
https://github.com/Sea-Haven-Industries/afterhours-shift-manager.git
synced 2026-09-30 12:33:13 +00:00
Add dash 4-digit year format and pin year boundary
Dash inputs like 7-3-2026 previously returned None because only the slash variant had a 4-digit-year format. Add %m-%d-%Y so dash and slash behave alike, and pin the two-digit-year century boundary with a test. Refs: #133
This commit is contained in:
parent
d95e4ec3b5
commit
4c851d843b
2 changed files with 14 additions and 0 deletions
|
|
@ -62,6 +62,7 @@ _DATED_FORMATS = (
|
|||
"%Y-%m-%d",
|
||||
"%m/%d/%Y",
|
||||
"%m/%d/%y",
|
||||
"%m-%d-%Y",
|
||||
"%m-%d-%y",
|
||||
"%b %d %Y",
|
||||
"%B %d %Y",
|
||||
|
|
|
|||
|
|
@ -69,6 +69,19 @@ def test_two_digit_year_dash(slackbot_app):
|
|||
assert slackbot_app.parse_date("7-3-26").strftime("%Y-%m-%d") == "2026-07-03"
|
||||
|
||||
|
||||
@freeze_time(FROZEN)
|
||||
def test_four_digit_year_dash(slackbot_app):
|
||||
assert slackbot_app.parse_date("7-3-2026").strftime("%Y-%m-%d") == "2026-07-03"
|
||||
|
||||
|
||||
@freeze_time(FROZEN)
|
||||
def test_two_digit_year_century_boundary(slackbot_app):
|
||||
# Python's %y maps 00–68 → 2000s and 69–99 → 1900s. Pin it so nobody
|
||||
# "fixes" the ambiguity by accident later.
|
||||
assert slackbot_app.parse_date("12/31/99").year == 1999
|
||||
assert slackbot_app.parse_date("1/1/68").year == 2068
|
||||
|
||||
|
||||
@freeze_time(FROZEN)
|
||||
def test_two_digit_year_past_not_rolled(slackbot_app):
|
||||
# Explicit two-digit year in the past stays put — no roll-forward.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue