Date._pike
Go to the documentation of this file.
1 /* Copyright (C) 2000-2008 Thomas Bopp, Thorsten Hampel, Ludger Merkens, Martin Baehr
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  */
17 inherit "/classes/Object";
18 #include <macros.h>
19 #include <classes.h>
20 #include <assert.h>
21 #include <database.h>
22 #include <exception.h>
23 #include <attributes.h>
24 #include <types.h>
25 //! The Date class features some DATE specific attributes. Dates are
26 //! usually found inside Calendars.
27 class Date : public Object{
28 public:
29 
30 
31 
32 
33 
34 int get_object_class()
35 {
36  return ::get_object_class() | CLASS_DATE;
37 }
38 
39 string execute(mapping variables)
40 {
41  return "Date";
42 }
43 
44 string describe()
45 {
46  return "Date()";
47 }
48 
49 protected:
50  void delete_object()
51 {
52  if ( mappingp(mReferences) ) {
53  foreach(indices(mReferences), object o) {
54  if ( !objectp(o) ) continue;
55 
56  o->removed_link();
57  }
58  }
59  ::delete_object();
60 }
61 
62 public:
63 
64 bool match(int start, int end)
65 {
66  int startdate, enddate;
67  startdate = (int)do_query_attribute(DATE_START_DATE);
68  enddate = (int)do_query_attribute(DATE_END_DATE);
69  if ( (startdate >= start && startdate <= end ) ||
70  (enddate >= start && enddate <= end) ||
71  ( start <= enddate && end >= startdate) )
72  return true;
73  return false;
74 }
75 
76 bool match_time(int starttime, int endtime)
77 {
78  int startdate, enddate;
79  startdate = (int)do_query_attribute(DATE_START_TIME);
80  enddate = (int)do_query_attribute(DATE_END_TIME);
81 
82  if ( (startdate >= starttime && startdate <= endtime) ||
83  (enddate >= starttime && enddate <= endtime) ||
84  ( starttime <= enddate && endtime >= startdate ) )
85  return true;
86  return false;
87 }
88 
89 
90 
91 
92 
93 };