forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdate_functions.php
executable file
·149 lines (140 loc) · 3.93 KB
/
date_functions.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
// ============================================================
// dateformat
//
// return a formated string for date
// @args: string (date string), boolean (include day of week)
// (it uses $_SESSION['language_choice'] )
// @return: $date_string (string) - formated string
// Cristian Navalici lemonsoftware at gmail dot com
//
// For Hebrew must be implemented a special calendar functions
//
// 10.07.2007 - dateformat accepts now an argument
// ============================================================
function dateformat($strtime = '', $with_dow = false)
{
// without an argument, display current date
if (!$strtime) {
$strtime = strtotime('now');
}
// string date is formed by
// $dow + date(day) + $nom + date(year) or similar
// name the day of the week for different languages
$day = date("w", $strtime); // 0 sunday -> 6 saturday
switch ($day) {
case 0:
$dow = xl('Sunday');
break;
case 1:
$dow = xl('Monday');
break;
case 2:
$dow = xl('Tuesday');
break;
case 3:
$dow = xl('Wednesday');
break;
case 4:
$dow = xl('Thursday');
break;
case 5:
$dow = xl('Friday');
break;
case 6:
$dow = xl('Saturday');
break;
}
// name of the month in different languages
$month = (int) date('m', $strtime);
switch ($month) {
case 1:
$nom = xl('January');
break;
case 2:
$nom = xl('February');
break;
case 3:
$nom = xl('March');
break;
case 4:
$nom = xl('April');
break;
case 5:
$nom = xl('May');
break;
case 6:
$nom = xl('June');
break;
case 7:
$nom = xl('July');
break;
case 8:
$nom = xl('August');
break;
case 9:
$nom = xl('September');
break;
case 10:
$nom = xl('October');
break;
case 11:
$nom = xl('November');
break;
case 12:
$nom = xl('December');
break;
}
// Date string format
// First, get current language title
$languageTitle = getLanguageTitle($_SESSION['language_choice']);
switch ($languageTitle) {
// standard english first
case getLanguageTitle(1):
$dt = date("F j, Y", $strtime);
if ($with_dow) {
$dt = "$dow, $dt";
}
break;
case "Swedish":
$dt = date("Y", $strtime) . " $nom " . date("d", $strtime);
if ($with_dow) {
$dt = "$dow $dt";
}
break;
case "Spanish":
case "Spanish (Spain)":
case "Spanish (Latin American)":
$dt = date("d", $strtime) . " $nom " . date("Y", $strtime);
if ($with_dow) {
$dt = "$dow $dt";
}
break;
case "German":
$dt = date("d", $strtime) . " $nom " . date("Y", $strtime);
if ($with_dow) {
$dt = "$dow $dt";
}
break;
case "Dutch":
$dt = date("d", $strtime) . " $nom " . date("Y", $strtime);
if ($with_dow) {
$dt = "$dow $dt";
}
break;
// hebrew (israel) , display english NOT jewish calendar
case "Hebrew":
$dt = date("d", $strtime) . " $nom " . date("Y", $strtime);
if ($with_dow) {
$dt = "$dow, $dt";
}
break;
// default case
default:
$dt = "$nom " . date("d", $strtime) . ", " . date("Y", $strtime);
if ($with_dow) {
$dt = "$dow, $dt";
}
}
return $dt;
}