2
# This file is part of GNU Enterprise.
4
# GNU Enterprise is free software; you can redistribute it
5
# and/or modify it under the terms of the GNU General Public
6
# License as published by the Free Software Foundation; either
7
# version 2, or (at your option) any later version.
9
# GNU Enterprise is distributed in the hope that it will be
10
# useful, but WITHOUT ANY WARRANTY; without even the implied
11
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
# PURPOSE. See the GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public
15
# License along with program; see the file COPYING. If not,
16
# write to the Free Software Foundation, Inc., 59 Temple Place
17
# - Suite 330, Boston, MA 02111-1307, USA.
19
# Copyright 2001-2005 Free Software Foundation
31
return divmod(year,400)[1] == 0 or \
32
(divmod(year,4)[1] == 0 and divmod(year,100)[1] != 0)
34
class InvalidDate(StandardError):
47
return "%04d/%02d/%02d %02d:%02d:%02d" % \
48
(self.year, self.month, self.day, self.hour, self.minute, self.second)
50
def getDayOfWeek(self):
51
# from the Calendar FAQ (http://www.pauahtun.org/CalendarFAQ/)
53
a = int((14 - self.month) / 12)
55
m = self.month + 12*a - 2
56
return divmod(self.day + y + int(y/4) - int(y/100) + int(y/400) + (31*m)/12,7)[1]
61
self.month >= 1 and self.month <= 12 and \
63
self.day >= 1 and self.day <= ( \
64
(self.month in (1,3,5,7,8,10,12) and 31) or \
65
(self.month == 2 and (28 + isLeapYear(self.year))) \
67
self.hour >= 0 and self.hour <= 23 and \
68
self.minute >= 0 and self.minute <= 59 and \
69
self.second >= 0 and self.second <= 59 ):
70
tmsg = _("Not a valid date")
71
raise InvalidDate, tmsg