Skip to content

Commit

Permalink
fixed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
chanthornsp committed Sep 1, 2023
1 parent 6ee7678 commit 9eb79f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
echo khmerDate('2024-01-01')->format();

print_r(khmerDate('2024-01-01')::khNewYear());

// or
print_r(KhmerNewYearDate(2024));
5 changes: 5 additions & 0 deletions src/ToKhmerDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public static function format(string $format = ''): string
},
];
$result = preg_replace_callback('/[a-zA-Z]/', function ($matches) use ($formatRules) {

// fix Undefined array key
if (!isset($formatRules[$matches[0]])) {
return $matches[0];
}
return $formatRules[$matches[0]]();
}, $format);
return Constant::postformat($result);
Expand Down

0 comments on commit 9eb79f0

Please sign in to comment.