Skip to content

Commit

Permalink
strftime add format (#31)
Browse files Browse the repository at this point in the history
Co-authored-by: vladimir.panivko <[email protected]>
  • Loading branch information
sveneld and sveneld authored Jan 17, 2024
1 parent 547040a commit ca2a3f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,8 @@ private function convertStrftimeFormatConverter(string $timeFormat): string
'%G', '%Y', '%y',
'%P', '%p', '%l', '%I', '%H', '%M', '%S',
'%z', '%Z',
'%s'
'%s',
'%x', '%X',
];

// http://php.net/manual/en/function.date.php
Expand All @@ -861,7 +862,8 @@ private function convertStrftimeFormatConverter(string $timeFormat): string
'o', 'Y', 'y',
'a', 'A', 'g', 'h', 'H', 'i', 's',
'O', 'T',
'U'
'U',
'm/d/Y', 'H:i:s',
];

$pattern = array_map(
Expand Down
3 changes: 3 additions & 0 deletions tests/formatTime.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ $tests = [
['timeFormat' => '%P %p %l %I %H %M %S', 'timeFormatter' => null, 'expectedResult' => 'pm PM 8 08 20 17 28'],
['timeFormat' => '%z %Z', 'timeFormatter' => null, 'expectedResult' => '+0000 UTC'],
['timeFormat' => '%s', 'timeFormatter' => null, 'expectedResult' => '1704658648'],
['timeFormat' => '%x %X', 'timeFormatter' => null, 'expectedResult' => '01/07/2024 20:17:28'],
['timeFormat' => 'Y-m-d H:i:s', 'timeFormatter' => function($timeFormat, $time) { return $time;}, 'expectedResult' => '1704658648'],
['timeFormat' => 'Y-m-d H:i:s', 'timeFormatter' => function($timeFormat, $time) { return $timeFormat;}, 'expectedResult' => 'Y-m-d H:i:s'],
];
Expand Down Expand Up @@ -55,5 +56,7 @@ Using strftime-style formatting is deprecated
+0000 UTC OK
Using strftime-style formatting is deprecated
1704658648 OK
Using strftime-style formatting is deprecated
01/07/2024 20:17:28 OK
1704658648 OK
Y-m-d H:i:s OK

0 comments on commit ca2a3f4

Please sign in to comment.