-
Notifications
You must be signed in to change notification settings - Fork 0
/
dutchclock
executable file
·65 lines (55 loc) · 1.42 KB
/
dutchclock
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/php
<?php
date_default_timezone_set(@date_default_timezone_get());
if (PHP_SAPI !== 'cli')
{
die('this is a CLI script.');
}
$hour = (int) strftime("%I");
$minute = (int) strftime("%M");
$words = explode(',', 'null,een,twee,drie,vier,vijf,zes,zeven,acht,negen,tien,elf,twaalf,dertien,veertien');
foreach($words as $k => $v) {
$words[$k] = "\033[0;36m".strtolower($v)."\033[0m";
}
// intervals of 5 minutes
$minute = (int) round($minute/5)*5;
if($minute == 60) {
$hour++;
}
if ($hour > 12)
{
$hour = $hour - 12;
}
ob_start();
switch($minute)
{
case 60:
case 0:
echo $words[$hour == 0 ? 12 : $hour], strtolower(' uur'), PHP_EOL;
break;
case 5:
case 10:
echo $words[$minute], strtolower(' over '), $words[$hour == 0 ? 12 : $hour], PHP_EOL;
break;
case 15:
echo strtolower('kwart over '), $words[$hour == 0 ? 12 : $hour], PHP_EOL;
break;
case 20:
case 25:
echo $words[30 - $minute], strtolower(' voor half '), $words[$hour == 12 ? 1 : $hour + 1], PHP_EOL;
break;
case 30:
echo strtolower('half '), $words[$hour == 12 ? 1 : $hour + 1], PHP_EOL;
break;
case 35:
case 40:
echo $words[$minute - 30], strtolower(' over half '), $words[$hour == 12 ? 1 : $hour + 1], PHP_EOL;
break;
case 45:
echo strtolower('kwart voor '), $words[$hour == 12 ? 1 : $hour + 1], PHP_EOL;
break;
case 50:
case 55:
echo $words[60 - $minute], strtolower(' voor '), $words[$hour == 12 ? 1 : $hour + 1], PHP_EOL;
break;
}