1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxDateSpan documentation
4 %% Author: Vadim Zeitlin
8 %% Copyright: (c) Vadim Zeitlin
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxDateSpan
}}\label{wxdatespan
}
14 This class is a "logical time span" and is useful for implementing program
15 logic for such things as "add one month to the date" which, in general,
16 doesn't mean to add $
60*
60*
24*
31$ seconds to it, but to take the same date
17 the next month (to understand that this is indeed different consider adding
18 one month to Feb,
15 -- we want to get Mar,
15, of course).
20 When adding a month to the date, all lesser components (days, hours, ...)
21 won't be changed unless the resulting date would be invalid: for example,
22 Jan
31 +
1 month will be Feb
28, not (non-existing) Feb
31.
24 Because of this feature, adding and subtracting back again the same
25 wxDateSpan will
{\bf not
}, in general give back the original date: Feb
28 -
1
26 month will be Jan
28, not Jan
31!
28 wxDateSpan objects can be either positive or negative. They may be
29 multiplied by scalars which multiply all deltas by the scalar: i.e.
30 $
2*(
1 \hbox{ month and
} 1 \hbox{ day
})$ is $
2$ months and $
2$ days. They can
31 be added together and with
\helpref{wxDateTime
}{wxdatetime
} or
32 \helpref{wxTimeSpan
}{wxtimespan
}, but the type of result is different for each
35 Beware about weeks: if you specify both weeks and days, the total number of
36 days added will be $
7*
\hbox{weeks
} +
\hbox{days
}$! See also GetTotalDays()
39 Equality operators are defined for wxDateSpans. Two datespans are equal if
40 and only if they both give the same target date when added to
{\bf every
}\rtfsp
41 source date. Thus wxDateSpan::Months(
1) is not equal to wxDateSpan::Days(
30),
42 because they don't give the same date when added to
1 Feb. But
43 wxDateSpan::Days(
14) is equal to wxDateSpan::Weeks(
2)
45 Finally, notice that for adding hours, minutes and so on you don't need this
46 class at all:
\helpref{wxTimeSpan
}{wxtimespan
} will do the job because there
47 are no subtleties associated with those (we don't support leap seconds).
49 \wxheading{Derived from
}
53 \wxheading{Include files
}
59 \helpref{wxBase
}{librarieslist
}
63 \helpref{Date classes overview
}{wxdatetimeoverview
},
\rtfsp
64 \helpref{wxDateTime
}{wxdatetime
}
67 \latexignore{\rtfignore{\wxheading{Members
}}}
70 \membersection{wxDateSpan::wxDateSpan
}\label{wxdatespanwxdatespan
}
72 \func{}{wxDateSpan
}{\param{int
}{years = $
0$
},
\param{int
}{months = $
0$
},
\param{int
}{weeks = $
0$
},
\param{int
}{days = $
0$
}}
74 Constructs the date span object for the given number of years, months, weeks
75 and days. Note that the weeks and days add together if both are given.
78 \membersection{wxDateSpan::Add
}\label{wxdatespanadd
}
80 \constfunc{wxDateSpan
}{Add
}{\param{const wxDateSpan\&
}{other
}}
82 \func{wxDateSpan\&
}{Add
}{\param{const wxDateSpan\&
}{other
}}
84 \func{wxDateSpan\&
}{operator$+=$
}{\param{const wxDateSpan\&
}{other
}}
86 Returns the sum of two date spans. The first version returns a new object, the
87 second and third ones modify this object in place.
90 \membersection{wxDateSpan::Day
}\label{wxdatespanday
}
92 \func{static wxDateSpan
}{Day
}{\void}
94 Returns a date span object corresponding to one day.
98 \helpref{Days
}{wxdatespandays
}
101 \membersection{wxDateSpan::Days
}\label{wxdatespandays
}
103 \func{static wxDateSpan
}{Days
}{\param{int
}{days
}}
105 Returns a date span object corresponding to the given number of days.
109 \helpref{Day
}{wxdatespanday
}
111 % wxDateSpan::GetDays
112 \membersection{wxDateSpan::GetDays
}\label{wxdatespangetdays
}
114 \constfunc{int
}{GetDays
}{\void}
116 Returns the number of days (only, that it not counting the weeks component!)
121 \helpref{GetTotalDays
}{wxdatespangettotaldays
}
123 % wxDateSpan::GetMonths
124 \membersection{wxDateSpan::GetMonths
}\label{wxdatespangetmonths
}
126 \constfunc{int
}{GetMonths
}{\void}
128 Returns the number of the months (not counting the years) in this date span.
130 % wxDateSpan::GetTotalDays
131 \membersection{wxDateSpan::GetTotalDays
}\label{wxdatespangettotaldays
}
133 \constfunc{int
}{GetTotalDays
}{\void}
135 Returns the combined number of days in this date span, counting both weeks and
136 days. It still doesn't take neither months nor years into the account.
140 \helpref{GetWeeks
}{wxdatespangetweeks
},
\helpref{GetDays
}{wxdatespangetdays
}
142 % wxDateSpan::GetWeeks
143 \membersection{wxDateSpan::GetWeeks
}\label{wxdatespangetweeks
}
145 \constfunc{int
}{GetWeeks
}{\void}
147 Returns the number of weeks in this date span.
151 \helpref{GetTotalDays
}{wxdatespangettotaldays
}
153 % wxDateSpan::GetYears
154 \membersection{wxDateSpan::GetYears
}\label{wxdatespangetyears
}
156 \constfunc{int
}{GetYears
}{\void}
158 Returns the number of years in this date span.
161 \membersection{wxDateSpan::Month
}\label{wxdatespanmonth
}
163 \func{static wxDateSpan
}{Month
}{\void}
165 Returns a date span object corresponding to one month.
169 \helpref{Months
}{wxdatespanmonths
}
172 \membersection{wxDateSpan::Months
}\label{wxdatespanmonths
}
174 \func{static wxDateSpan
}{Months
}{\param{int
}{mon
}}
176 Returns a date span object corresponding to the given number of months.
180 \helpref{Month
}{wxdatespanmonth
}
182 % wxDateSpan::Multiply
183 \membersection{wxDateSpan::Multiply
}\label{wxdatespanmultiply
}
185 \constfunc{wxDateSpan
}{Multiply
}{\param{int
}{factor
}}
187 \func{wxDateSpan\&
}{Multiply
}{\param{int
}{factor
}}
189 \func{wxDateSpan\&
}{operator$*=$
}{\param{int
}{factor
}}
191 Returns the product of the date span by the specified
{\it factor
}. The
192 product is computed by multiplying each of the components by the factor.
194 The first version returns a new object, the second and third ones modify this
198 \membersection{wxDateSpan::Negate
}\label{wxdatespannegate
}
200 \constfunc{wxDateSpan
}{Negate
}{\void}
202 Returns the date span with the opposite sign.
206 \helpref{Neg
}{wxdatespanneg
}
209 \membersection{wxDateSpan::Neg
}\label{wxdatespanneg
}
211 \func{wxDateSpan\&
}{Neg
}{\void}
213 \func{wxDateSpan\&
}{operator$-$
}{\void}
215 Changes the sign of this date span.
219 \helpref{Negate
}{wxdatespannegate
}
221 % wxDateSpan::SetDays
222 \membersection{wxDateSpan::SetDays
}\label{wxdatespansetdays
}
224 \func{wxDateSpan\&
}{SetDays
}{\param{int
}{n
}}
226 Sets the number of days (without modifying any other components) in this date
229 % wxDateSpan::SetYears
230 \membersection{wxDateSpan::SetYears
}\label{wxdatespansetyears
}
232 \func{wxDateSpan\&
}{SetYears
}{\param{int
}{n
}}
234 Sets the number of years (without modifying any other components) in this date
237 % wxDateSpan::SetMonths
238 \membersection{wxDateSpan::SetMonths
}\label{wxdatespansetmonths
}
240 \func{wxDateSpan\&
}{SetMonths
}{\param{int
}{n
}}
242 Sets the number of months (without modifying any other components) in this
245 % wxDateSpan::SetWeeks
246 \membersection{wxDateSpan::SetWeeks
}\label{wxdatespansetweeks
}
248 \func{wxDateSpan\&
}{SetWeeks
}{\param{int
}{n
}}
250 Sets the number of weeks (without modifying any other components) in this date
253 % wxDateSpan::Subtract
254 \membersection{wxDateSpan::Subtract
}\label{wxdatespansubtract
}
256 \constfunc{wxDateSpan
}{Subtract
}{\param{const wxDateSpan\&
}{other
}}
258 \func{wxDateSpan\&
}{Subtract
}{\param{const wxDateSpan\&
}{other
}}
260 \func{wxDateSpan\&
}{operator$+=$
}{\param{const wxDateSpan\&
}{other
}}
262 Returns the difference of two date spans. The first version returns a new
263 object, the second and third ones modify this object in place.
266 \membersection{wxDateSpan::Week
}\label{wxdatespanweek
}
268 \func{static wxDateSpan
}{Week
}{\void}
270 Returns a date span object corresponding to one week.
274 \helpref{Weeks
}{wxdatespanweeks
}
277 \membersection{wxDateSpan::Weeks
}\label{wxdatespanweeks
}
279 \func{static wxDateSpan
}{Weeks
}{\param{int
}{weeks
}}
281 Returns a date span object corresponding to the given number of weeks.
285 \helpref{Week
}{wxdatespanweek
}
288 \membersection{wxDateSpan::Year
}\label{wxdatespanyear
}
290 \func{static wxDateSpan
}{Year
}{\void}
292 Returns a date span object corresponding to one year.
296 \helpref{Years
}{wxdatespanyears
}
299 \membersection{wxDateSpan::Years
}\label{wxdatespanyears
}
301 \func{static wxDateSpan
}{Years
}{\param{int
}{years
}}
303 Returns a date span object corresponding to the given number of years.
307 \helpref{Year
}{wxdatespanyear
}
309 % wxDateSpan::operator==
310 \membersection{wxDateSpan::operator$==$
}\label{wxdatespanoperatorequal
}
312 \constfunc{bool
}{operator$==$
}{\param{wxDateSpan\&
}{ other
}}
314 Returns
{\tt true
} if this date span is equal to the other one. Two date spans
315 are considered equal if and only if they have the same number of years and
316 months and the same total number of days (counting both days and weeks).
318 % wxDateSpan::operator!=
319 \membersection{wxDateSpan::operator$!=$
}\label{wxdatespanoperatornotequal
}
321 \constfunc{bool
}{operator$!=$
}{\param{wxDateSpan\&
}{ other
}}
323 Returns
{\tt true
} if this date span is different from the other one.
327 \helpref{operator==
}{wxdatespanoperatorequal
}