added additional testing support for couchdb docker in dev environment
[openemr.git] / library / date_functions.php
blobc595f886f98f4112afedd575829fffe1026f6ba8
1 <?php
2 // ============================================================
3 // dateformat
4 //
5 // return a formated string for date
6 // @args: string (date string), boolean (include day of week)
7 // (it uses $_SESSION['language_choice'] )
8 // @return: $date_string (string) - formated string
9 // Cristian Navalici lemonsoftware at gmail dot com
11 // For Hebrew must be implemented a special calendar functions
13 // 10.07.2007 - dateformat accepts now an argument
14 // ============================================================
16 function dateformat($strtime = '', $with_dow = false)
19 // without an argument, display current date
20 if (!$strtime) {
21 $strtime = strtotime('now');
24 // string date is formed by
25 // $dow + date(day) + $nom + date(year) or similar
27 // name the day of the week for different languages
28 $day = date("w", $strtime); // 0 sunday -> 6 saturday
30 switch ($day) {
31 case 0:
32 $dow = xl('Sunday');
33 break;
34 case 1:
35 $dow = xl('Monday');
36 break;
37 case 2:
38 $dow = xl('Tuesday');
39 break;
40 case 3:
41 $dow = xl('Wednesday');
42 break;
43 case 4:
44 $dow = xl('Thursday');
45 break;
46 case 5:
47 $dow = xl('Friday');
48 break;
49 case 6:
50 $dow = xl('Saturday');
51 break;
54 // name of the month in different languages
55 $month = (int) date('m', $strtime);
57 switch ($month) {
58 case 1:
59 $nom = xl('January');
60 break;
61 case 2:
62 $nom = xl('February');
63 break;
64 case 3:
65 $nom = xl('March');
66 break;
67 case 4:
68 $nom = xl('April');
69 break;
70 case 5:
71 $nom = xl('May');
72 break;
73 case 6:
74 $nom = xl('June');
75 break;
76 case 7:
77 $nom = xl('July');
78 break;
79 case 8:
80 $nom = xl('August');
81 break;
82 case 9:
83 $nom = xl('September');
84 break;
85 case 10:
86 $nom = xl('October');
87 break;
88 case 11:
89 $nom = xl('November');
90 break;
91 case 12:
92 $nom = xl('December');
93 break;
96 // Date string format
97 // First, get current language title
98 $languageTitle = getLanguageTitle($_SESSION['language_choice']);
99 switch ($languageTitle) {
100 // standard english first
101 case getLanguageTitle(1):
102 $dt = date("F j, Y", $strtime);
103 if ($with_dow) {
104 $dt = "$dow, $dt";
106 break;
107 case "Swedish":
108 $dt = date("Y", $strtime) . " $nom " . date("d", $strtime);
109 if ($with_dow) {
110 $dt = "$dow $dt";
112 break;
113 case "Spanish":
114 case "Spanish (Spain)":
115 case "Spanish (Latin American)":
116 $dt = date("d", $strtime) . " $nom " . date("Y", $strtime);
117 if ($with_dow) {
118 $dt = "$dow $dt";
120 break;
121 case "German":
122 $dt = date("d", $strtime) . " $nom " . date("Y", $strtime);
123 if ($with_dow) {
124 $dt = "$dow $dt";
126 break;
127 case "Dutch":
128 $dt = date("d", $strtime) . " $nom " . date("Y", $strtime);
129 if ($with_dow) {
130 $dt = "$dow $dt";
132 break;
133 // hebrew (israel) , display english NOT jewish calendar
134 case "Hebrew":
135 $dt = date("d", $strtime) . " $nom " . date("Y", $strtime);
136 if ($with_dow) {
137 $dt = "$dow, $dt";
139 break;
140 // default case
141 default:
142 $dt = "$nom " . date("d", $strtime) . ", " . date("Y", $strtime);
143 if ($with_dow) {
144 $dt = "$dow, $dt";
148 return $dt;