Ejemplo n.º 1
0
testStrs = [["0.2001", "1 Jan 2001"],
            ["3-.1979", "22 Jan 1979 - 28 Jan 1979"],
            ["0--.1988", "1 Jan 1988 - 18 Feb 1988"],
            ["0.1965 - 6.1965", "1 Jan 1965 - 7 Jan 1965"],
            ["0.2011 - 42.2011", "Jan 2011"],
            # This next case is weird, and I decided the
            # current string is best because it is true
            # (albeit redundant) and includes the idea that
            # the scope is abstractly more than a day.
            # In most cases, users will never see this.
            ["103-.2035", "31 Dec 2035 - 31 Dec 2035"],
            ["10--.2025", "10 Dec 2025 - 31 Dec 2025"]]
for testCase in testStrs:
  userStr = wj._userStrForMark(testCase[0])
  expectVsActual(testCase[1], userStr, comment=testCase[0])

# Tests for _fromDayToScope.

# Test that Greg weeks are Monday-Sunday.
dayMark = '633.2011'
mark = wj._fromDayToScope(dayMark, 'w')
expectVsActual('632.2011 - 641.2011', mark, comment=dayMark)

# Test that Greg months are right.
dayMark = '633.2011'
mark = wj._fromDayToScope(dayMark, 'm')
expectVsActual('613.2011 - 654.2011', mark, comment=dayMark)

print "fortune smiles upon you... for now - all tests passed"
exit(0)
Ejemplo n.º 2
0
  wj._setMessage(randomString(), timeMark)

wj._verbose = False

# Confirm the user wants to do this.
print "This will overwrite data in ~/.wj.  Are you sure?"
confirmStr = raw_input("Type 'Yes' to continue ")
if confirmStr != "Yes":
  sys.exit(0)

# Get a timestamp for Jan 1 of this year.
now = time.localtime()
year = now.tm_year
date = datetime.date(year, 1, 1)
startStamp = calendar.timegm(date.timetuple())
startStamp += time.timezone

# Set a message for every timemark in the year.
outputStringForTimeMark(str(year))
ts = startStamp
oneDay = 60 * 60 * 24
while time.localtime(ts).tm_year == year:
  dayMark = wj._7dateForTime(ts)
  outputStringForTimeMark(dayMark)
  weekMark = wj._fromDayToScope(dayMark, "w")
  outputStringForTimeMark(weekMark)
  monthMark = wj._fromDayToScope(dayMark, "m")
  outputStringForTimeMark(monthMark)
  ts += oneDay

Ejemplo n.º 3
0
    wj._setMessage(randomString(), timeMark)


wj._verbose = False

# Confirm the user wants to do this.
print "This will overwrite data in ~/.wj.  Are you sure?"
confirmStr = raw_input("Type 'Yes' to continue ")
if confirmStr != "Yes":
    sys.exit(0)

# Get a timestamp for Jan 1 of this year.
now = time.localtime()
year = now.tm_year
date = datetime.date(year, 1, 1)
startStamp = calendar.timegm(date.timetuple())
startStamp += time.timezone

# Set a message for every timemark in the year.
outputStringForTimeMark(str(year))
ts = startStamp
oneDay = 60 * 60 * 24
while time.localtime(ts).tm_year == year:
    dayMark = wj._7dateForTime(ts)
    outputStringForTimeMark(dayMark)
    weekMark = wj._fromDayToScope(dayMark, "w")
    outputStringForTimeMark(weekMark)
    monthMark = wj._fromDayToScope(dayMark, "m")
    outputStringForTimeMark(monthMark)
    ts += oneDay