/[corp_html]/back/phormation/date_fcns.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /back/phormation/date_fcns.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Fri Jan 26 17:53:58 2001 UTC (23 years, 3 months ago) by dpavlin
Branch: MAIN
Branch point for: dbp
Initial revision

1 dpavlin 1.1 <?
2     /*
3     * Phormation
4     * - A library of PHP code to make development of database-driven
5     * html forms easy and quick
6     *
7     * Copyright (C) 2000 Jason D. Hildebrand
8     * PeaceWorks Computer Consulting
9     *
10     * jason@peaceworks.ca
11     *
12     * This program is free software; you can redistribute it and/or modify
13     * it under the terms of the GNU General Public License as published by
14     * the Free Software Foundation; either version 2 of the License, or
15     * (at your option) any later version.
16     *
17     * This program is distributed in the hope that it will be useful,
18     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20     * GNU General Public License for more details.
21     *
22     * You should have received a copy of the GNU General Public License
23     * along with this program; if not, write to the Free Software
24     * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
25     */
26    
27    
28     $full_months = array( 1 => 'January',
29     2 => 'February',
30     3 => 'March',
31     4 => 'April',
32     5 => 'May',
33     6 => 'June',
34     7 => 'July',
35     8 => 'August',
36     9 => 'September',
37     10 => 'October',
38     11 => 'November',
39     12 => 'December' );
40    
41     $short_months = array( 1 => 'Jan.',
42     2 => 'Feb.',
43     3 => 'Mar.',
44     4 => 'Apr.',
45     5 => 'May',
46     6 => 'June',
47     7 => 'July',
48     8 => 'Aug.',
49     9 => 'Sept.',
50     10 => 'Oct.',
51     11 => 'Nov.',
52     12 => 'Dec.' );
53    
54     // parses a PostgreSQL date in format YYYY/MM/DD or YYYY-MM-DD
55     // into month, day, year components
56     function parse_date( $date ) {
57     $array["year"] = strtok( $date, "/-" );
58     $array["month"] = strtok( "/-" );
59     $array["day"] = strtok( "/-" );
60     return $array;
61     }
62    
63     // outputs a month/day combo
64     function output_single_date( $date ) {
65     global $short_months;
66     $pdate = parse_date( $date );
67     echo $short_months[ (int) $pdate["month"] ] . " " . $pdate["day"];
68     }
69    
70     // outputs a month/day range which makes sense to humans
71     function output_date_range( $startdate, $enddate ) {
72     global $short_months;
73     $pstartdate = parse_date( $startdate );
74     $penddate = parse_date( $enddate );
75    
76     if( ((int)$pstartdate["month"]) == ((int)$penddate["month"]) ) {
77     echo $short_months[ (int)$pstartdate["month"] ] . " " . $pstartdate["day"] . "-" . $penddate["day"];
78     } else {
79     echo $short_months[ (int)$pstartdate["month"] ] . " " . $pstartdate["day"] . " - ";
80     echo $short_months[ (int)$penddate["month"] ] . " " . $penddate["day"];
81     }
82     }
83    
84     ?>

  ViewVC Help
Powered by ViewVC 1.1.26