File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ function Dwoo_Plugin_time_range (Dwoo_Core $ dwoo , $ start , $ end , $ showDate = false )
4
+ {
5
+ $ string = '' ;
6
+
7
+ $ startDate = strftime ('%b %e ' , $ start );
8
+ $ startHour = (int )strftime ('%l ' , $ start );
9
+ $ startMinute = strftime ('%M ' , $ start );
10
+ $ startAmPm = strftime ('%P ' , $ start );
11
+
12
+ $ endDate = strftime ('%b %e ' , $ end );
13
+ $ endHour = (int )strftime ('%l ' , $ end );
14
+ $ endMinute = strftime ('%M ' , $ end );
15
+ $ endAmPm = strftime ('%P ' , $ end );
16
+
17
+ // start time
18
+ if ($ showDate ) {
19
+ $ string .= $ startDate .' ' ;
20
+ }
21
+
22
+ $ string .= $ startHour ;
23
+
24
+ if ($ startMinute && $ startMinute != '00 ' ) {
25
+ $ string .= ': ' .$ startMinute ;
26
+ }
27
+
28
+ if ($ end && $ start != $ end ) { // check that there is actually a range
29
+ if ($ startAmPm != $ endAmPm ) {
30
+ $ string .= $ startAmPm ;
31
+ }
32
+
33
+ // glue
34
+ $ string .= '– ' ;
35
+
36
+ // end time
37
+ if ($ showDate && ($ endDate != $ startDate )) {
38
+ $ string .= $ endDate .' ' ;
39
+ }
40
+
41
+ $ string .= $ endHour ;
42
+
43
+ if ($ endMinute && $ endMinute != '00 ' ) {
44
+ $ string .= ': ' .$ endMinute ;
45
+ }
46
+
47
+ $ string .= $ endAmPm ;
48
+ } else { // otherwise append am/pm and be done
49
+ $ string .= $ startAmPm ;
50
+ }
51
+
52
+ return $ string ;
53
+ }
You can’t perform that action at this time.
0 commit comments