-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.php
82 lines (78 loc) · 2.52 KB
/
demo.php
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;" />
<meta charset="UTF-8">
<meta name="author" content="P.P. Foong">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Demo of birthday library functions</title>
</head>
<body>
<p><div style="text-align:center;">
<form action="" method="get">
<label for="birthday">Birthday:</label>
<input type="date" id="birthday" name="birthday">
<input type="submit">
</form>
<?php
require_once('lib_birthday.php');
if (!empty($_GET)) {
if (isset($_GET['birthday'])) {
$today = todayYMD();
$thisYear = $today[0];
$thisMonth = $today[1];
$thisDay = $today[2];
$date = date_parse($_GET['birthday']);
if($date['error_count'] > 0) {
echo "<p style=\"color:red;\"><b><i>Error: Invalid date detected. Defaulting the birthday to today...</i></b></p>";
$year = $thisYear;
$month = $thisMonth;
$day = $thisDay;
} else {
$year = $date['year'];
$month = $date['month'];
$day = $date['day'];
}
echo "<br>Today: ".$thisYear."-".$thisMonth."-".$thisDay;
echo "<br>Birthday: ".$year."-".$month."-".$day;
$cnyState = passedCNY($year,$month,$day)?"after":"before";
echo " (".$cnyState." Chinese New Year)";
$cny = getCNYday($thisYear);
if ($cny != -1) {
$mon = ($cny[0]==1)?"Jan ":"Feb ";
echo "<br>This year's Chinese New Year falls on: ".$mon.$cny[1];
} else {
echo "<br><i>Current year is out of Chinese New Year checking range.</i>";
}
$cny = getCNYday($year);
if ($cny != -1) {
$mon = ($cny[0]==1)?"Jan ":"Feb ";
echo "<br>Birth year's Chinese New Year falls on: ".$mon.$cny[1];
} else {
echo "<br><i>Birth year is out of Chinese New Year checking range.</i>";
}
echo "<br><br>Zodiac sign: ";
echo getZodiac($month,$day)." ";
echo getZodiac($month,$day,2);
echo "<br><br>Symbolic animal: ";
echo getAnimal($year,$month,$day)." ";
echo getAnimal($year,$month,$day,4);
echo "<br><br>Life path number: ";
echo getLifePathNumber($year,$month,$day);
echo "<br><br>Age: ";
echo getAge($year,$month,$day);
$age = getAge($year,$month,$day,1);
echo "<br>Age: ";
echo $age[0]." year(s) ".$age[1]." month(s) ".$age[2]." day(s)";
echo "<br><br>Has been living for: ";
echo getAge($year,$month,$day,2)." days";
echo "<br><br>Days from last birthday: ";
echo getDays2Bday($month,$day,1);
echo "<br><br>Days to next birthday: ";
echo getDays2Bday($month,$day);
}
}
?>
</div></p>
</body>
</html>