File tree Expand file tree Collapse file tree 1 file changed +6
-14
lines changed Expand file tree Collapse file tree 1 file changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -244,24 +244,16 @@ function convertTimeFormat($time) {
244244 * @return string
245245 */
246246function normalizeOrdinalDate ($ dtValue ) {
247- try {
248- $ parts = explode ('- ' , $ dtValue );
249-
250- if ($ parts [1 ] > 366 ) {
251- throw new \Exception ('Day of year can never be greater than 366 ' );
252- }
253-
247+ list ($ year , $ day ) = explode ('- ' , $ dtValue , 2 );
248+ $ day = intval ($ day );
249+ if ($ day < 367 && $ day > 0 ) {
254250 $ date = \DateTime::createFromFormat ('Y-z ' , $ dtValue );
255251 $ date ->modify ('-1 day ' ); # 'z' format is zero-based so need to adjust
256-
257- if ($ date ->format ('Y ' ) != $ parts [0 ]) {
258- throw new \Exception ('Day of year cannot be greater than 365 in non-leap years ' );
252+ if ($ date ->format ('Y ' ) === $ year ) {
253+ return $ date ->format ('Y-m-d ' );
259254 }
260-
261- return $ date ->format ('Y-m-d ' );
262- } catch (\Exception $ e ) {
263- return '' ;
264255 }
256+ return '' ;
265257}
266258
267259/**
You can’t perform that action at this time.
0 commit comments