From 4a67c1c3331da5a2ec439e0112d3a5f18c06ee45 Mon Sep 17 00:00:00 2001 From: Sasha Mitchell Date: Sun, 27 Sep 2026 03:31:13 +0700 Subject: [PATCH] Format a shipping week with the week year. 30 December 2024 was encoded as 202401. That Monday is ISO week 1 of 2025, so the code is 202501. 1 January 2020 stays 202001. --- src/Generator/EdifactDate.php | 2 +- tests/GeneratorTest/EdifactDateTest.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Generator/EdifactDate.php b/src/Generator/EdifactDate.php index 7b23986..c7856a1 100755 --- a/src/Generator/EdifactDate.php +++ b/src/Generator/EdifactDate.php @@ -16,7 +16,7 @@ class EdifactDate public const DATETIME_FORMAT = 'YmdHi'; public const SHIPPING_WEEK = 616; - public const SHIPPING_WEEK_FORMAT = 'YW'; + public const SHIPPING_WEEK_FORMAT = 'oW'; public const SHIPPING_UNDEFINED = 999; public const SHIPPING_UNDEFINED_FORMAT = ""; diff --git a/tests/GeneratorTest/EdifactDateTest.php b/tests/GeneratorTest/EdifactDateTest.php index 52e7a81..650ae43 100755 --- a/tests/GeneratorTest/EdifactDateTest.php +++ b/tests/GeneratorTest/EdifactDateTest.php @@ -61,4 +61,17 @@ public function testParseTimeFormat() EdifactDate::parseFormat('2018-01-23 10:00', EdifactDate::DATETIME) ); } + + public function testShippingWeekUsesTheWeekYear() + { + // 30 December 2024 is a Monday in ISO week 1 of 2025. + $this->assertEquals( + '202501', + EdifactDate::get('2024-12-30', EdifactDate::SHIPPING_WEEK) + ); + $this->assertEquals( + '202001', + EdifactDate::get('2020-01-01', EdifactDate::SHIPPING_WEEK) + ); + } }