git.shiar.nl
/
minimedit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
nieuws: parse date using single regexp
[minimedit.git]
/
nieuws.inc.php
diff --git
a/nieuws.inc.php
b/nieuws.inc.php
index 7e723e4095e68febd3abde4fcc957217320168f8..f9fec6ad3f4b0ebd290d9241c8d488cd371f88b6 100644
(file)
--- a/
nieuws.inc.php
+++ b/
nieuws.inc.php
@@
-6,12
+6,11
@@
$monthname = ['?',
function shownewsdate($url)
{
function shownewsdate($url)
{
- $parts = pathinfo($url);
- $year = pathinfo($parts['dirname'], PATHINFO_FILENAME);
- @list ($month, $day) = explode('-', $parts['filename'], 3);
+ if (!preg_match('</(\d{4})/(\d{2})/(\d{2})->', $url, $parts)) return;
global $monthname;
global $monthname;
- return sprintf('<small class="date">%s %s %s</small>',
- intval($day), $monthname[intval($month)], $year);
+ return implode(' ', array_filter([
+ intval($parts[3]), $monthname[intval($parts[2])], $parts[1],
+ ]));
}
function shownewsarticle($url, $link = TRUE, $title = NULL)
}
function shownewsarticle($url, $link = TRUE, $title = NULL)