commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/gnue-common/src GDateTime.py FormatMasks/D...


From: Jason Cater
Subject: gnue/gnue-common/src GDateTime.py FormatMasks/D...
Date: Mon, 16 Jul 2001 13:24:55 -0700

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    01/07/16 13:24:54

Modified files:
        gnue-common/src: GDateTime.py 
        gnue-common/src/FormatMasks: DateMask.py 

Log message:
        Added 'day of week'/weekday name support; Fixed entry bug

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/GDateTime.py.diff?cvsroot=OldCVS&tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/FormatMasks/DateMask.py.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: gnue/gnue-common/src/FormatMasks/DateMask.py
diff -u gnue/gnue-common/src/FormatMasks/DateMask.py:1.2 
gnue/gnue-common/src/FormatMasks/DateMask.py:1.3
--- gnue/gnue-common/src/FormatMasks/DateMask.py:1.2    Mon Jul 16 13:03:07 2001
+++ gnue/gnue-common/src/FormatMasks/DateMask.py        Mon Jul 16 13:24:54 2001
@@ -52,7 +52,7 @@
 #
 
 from BaseMask import BaseMask, MaskSection, Literal
-from gnue.common, GDebug
+from gnue.common import GDebug
 from gnue.common.GDateTime import GDateTime
 from FormatExceptions import *
 
@@ -180,7 +180,7 @@
     rv = ""
     value = self._buildDate(self.entry, 0)
 
-    self.lastInputPos
+#    self.lastInputPos
 
     print self.inputMaskLen
 
@@ -226,7 +226,7 @@
     self.maxLength = 2
 
   def getFormattedValue(self, date): 
-    return "*" * self.maxLength
+    return weekdayAbbrevNames[date.getDayOfWeek()]
 
   def isValidEntry(self, value):
     return 0
@@ -237,7 +237,7 @@
 
 class _ASection(_aSection): 
   def getFormattedValue(self, date): 
-    return "*" * self.maxLength
+    return weekdayNames[date.getDayOfWeek()]
 
 
 class _bSection(_baseDateSection): 
@@ -289,7 +289,7 @@
   def isValidEntry(self, value):
     try: 
       v = int(value)
-      return (v >= 1) and (v <= 31)
+      return (v >= 0 and v <= 31) or (v == 0 and len(value) == 1)
     except ValueError: 
       return 0
 
@@ -377,7 +377,7 @@
   def isValidEntry(self, value):
     try: 
       v = int(value)
-      return (v >= 1) and (v <= 12)
+      return (v >= 0 and v <= 12) or (v == 0 and len(value) == 1)
     except ValueError: 
       return 0
 
@@ -402,7 +402,7 @@
   def isValidEntry(self, value):
     try: 
       v = int(value)
-      return v >= 0 and v <= 59
+      return (v >= 0 and v <= 59) or (v == 0 and len(value) == 1)
     except ValueError: 
       return 0
 
@@ -448,7 +448,7 @@
   def isValidEntry(self, value):
     try: 
       v = int(value)
-      return v >= 0 and v <= 59
+      return (v >= 0 and v <= 59) or (v == 0 and len(value) == 1)
     except ValueError: 
       return 0
 
@@ -587,8 +587,8 @@
 
 
 if __name__ == '__main__': 
-  dates = DateMask('\\D\\a\\t\\e: B d, Y  \\T\\i\\m\\e: h:i:s','m.d.y')
-  print "processEdit1 <= %s" % dates.processEdit('123197')
+  dates = DateMask('\\D\\a\\t\\e: A, B d, Y  \\T\\i\\m\\e: h:i:s','m.d.y')
+  print "processEdit1 <= %s" % dates.processEdit('071601')
   print dates.getFormattedInput("_")
   print dates.getFormattedOutput()
   print "processEdit2 <= %s" %dates.processEdit('27',2,4)
Index: gnue/gnue-common/src/GDateTime.py
diff -u gnue/gnue-common/src/GDateTime.py:1.1 
gnue/gnue-common/src/GDateTime.py:1.2
--- gnue/gnue-common/src/GDateTime.py:1.1       Mon Jul 16 13:03:07 2001
+++ gnue/gnue-common/src/GDateTime.py   Mon Jul 16 13:24:54 2001
@@ -35,3 +35,11 @@
     self.minute = 0
     self.second = 0
 
+  def getDayOfWeek(self):
+    # from the Calendar FAQ (http://www.pauahtun.org/CalendarFAQ/)
+    # 0 = Sunday
+    a = int((14 - self.month) / 12)
+    y = self.year - a
+    m = self.month + 12*a - 2
+    return divmod(self.day + y + int(y/4) - int(y/100) + int(y/400) + 
(31*m)/12,7)[1]
+



reply via email to

[Prev in Thread] Current Thread [Next in Thread]