Webseite der LUG Frankfurt mit Hugo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

30 lines
1.0 KiB

<?php
// read vor.txt and generate vor.md, inserting dates if missing
date_default_timezone_set("CET");
$lo = array_filter(ResourceBundle::getLocales(''), function ($l) {return strpos(strtolower($l), 'de');});
setlocale(LC_TIME, 'de_DE');
$file_txt = 'vor.txt';
$file_md = 'vor.md';
$fil = file($file_txt, FILE_IGNORE_NEW_LINES);
// Copy header
$arr = ['| | | |', '|:------|:------|:------|'];
$ts=(new DateTime('first day of this month'))->getTimeStamp();
foreach ($fil as $line) {
$fields = array_filter(explode('|', $line));
if (count($fields) == 2) {
// Date missing, insert
$tuesday = strftime('%A, %d.%m.%Y ', strtotime('fourth tuesday of this month', $ts));
array_unshift($fields, $tuesday);
}
$ts=strtotime('+1 month', $ts);
$li = implode('|', $fields);
if ($li[0] != ' ') {
$li = ' ' . $li;
}
if (substr($li, -1) != ' ') {
$li = $li . ' ';
}
array_push($arr, '|' . $li . '|');
}
file_put_contents($file_md, implode(PHP_EOL, $arr) . PHP_EOL);
?>