myPIM

Check-in [cfa7cd865f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Factor out day-of-week calc so it gets it right for monthly *and* yearly.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:cfa7cd865f16e6ec030ac569eae238ef4fae77e229bbfea1a58e03cb69e657d8
User & Date: ajv-899-334-8894@vsta.org 2013-11-27 00:23:04
Context
2018-05-29
04:56
Use Tauthon check-in: 1a11e25196 user: ajv-899-334-8894@vsta.org tags: master, trunk
2013-11-27
00:23
Factor out day-of-week calc so it gets it right for monthly *and* yearly. check-in: cfa7cd865f user: ajv-899-334-8894@vsta.org tags: master, trunk
2012-05-18
16:01
Let // find phone numbers too check-in: 89b0122618 user: ajv-899-334-8894@vsta.org tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to pimtime.py.

2
3
4
5
6
7
8














9
10
11
12
13
14
15
..
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
...
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# pimtime.py
#	Time handling for PIM events of all sorts
#
# Parts of the logic here were gleaned from the "month" utility version 8.7
#  written by James Hull.
#
import xcal















#
# Event is a private class, representing one single event.  In the case of
#  repetition, it also records this and provides operations to interact with
#  this repetition.
#
# start - Start time, as a localtime tuple
................................................................................

	# Once monthly and once yearly events
	if self.rept == 3:
	    return e.d == date.d

	# Monthly on nth occurrence of this day of week
	if self.rept == 4:
	    if e.weekday() <> date.weekday():
		return False
	    d1 = e.d
	    assert (d1 > 0) and (d1 < 32)
	    d1 -= 1
	    d2 = date.d
	    assert (d2 > 0) and (d2 < 32)
	    d2 -= 1
	    return (d1/7) == (d2/7)

	# Yearly; must match month
	if e.m <> date.m:
	    return False

	# Yearly on nth day of week in this month,
	#  counting from end
................................................................................

	# Yearly on this day of the month
	if self.rept == 6:
	    return e.d == date.d

	# Yearly on nth day of week in this month
	assert self.rept == 7
	if e.weekday() <> date.weekday():
	    return False
	return (e.d / 7) == (date.d / 7)

    # Tell how many times our event occurs from its start until
    #  reaching the "date".
    # Our count is number of *repetitions*, so if the event has
    #  a starting date, and then happens two more times, we return 2.
    def countEvents(self, date):
	nevent = 0







>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







<
|
<
<
<
<
<
<
<







 







<
|
<







2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
...
113
114
115
116
117
118
119

120







121
122
123
124
125
126
127
...
134
135
136
137
138
139
140

141

142
143
144
145
146
147
148
# pimtime.py
#	Time handling for PIM events of all sorts
#
# Parts of the logic here were gleaned from the "month" utility version 8.7
#  written by James Hull.
#
import xcal

# Check "dow" modifier type between event date
#  and given date.
def dow(e, date):
    if e.weekday() <> date.weekday():
        return False
    d1 = e.d
    assert (d1 > 0) and (d1 < 32)
    d1 -= 1
    d2 = date.d
    assert (d2 > 0) and (d2 < 32)
    d2 -= 1
    return (d1/7) == (d2/7)


#
# Event is a private class, representing one single event.  In the case of
#  repetition, it also records this and provides operations to interact with
#  this repetition.
#
# start - Start time, as a localtime tuple
................................................................................

	# Once monthly and once yearly events
	if self.rept == 3:
	    return e.d == date.d

	# Monthly on nth occurrence of this day of week
	if self.rept == 4:

            return dow(e, date)








	# Yearly; must match month
	if e.m <> date.m:
	    return False

	# Yearly on nth day of week in this month,
	#  counting from end
................................................................................

	# Yearly on this day of the month
	if self.rept == 6:
	    return e.d == date.d

	# Yearly on nth day of week in this month
	assert self.rept == 7

        return dow(e, date)


    # Tell how many times our event occurs from its start until
    #  reaching the "date".
    # Our count is number of *repetitions*, so if the event has
    #  a starting date, and then happens two more times, we return 2.
    def countEvents(self, date):
	nevent = 0