1 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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: datespan.tex
%% Purpose: wxDateSpan documentation
%% Author: Vadim Zeitlin
%% Modified by:
%% Created: 04.04.00
%% RCS-ID: $Id: datespan.tex 39409 2006-05-28 23:56:51Z VZ $
%% Copyright: (c) Vadim Zeitlin
%% License: wxWindows license
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{\class{wxDateSpan}}\label{wxdatespan}
This class is a "logical time span" and is useful for implementing program
logic for such things as "add one month to the date" which, in general,
doesn't mean to add $60*60*24*31$ seconds to it, but to take the same date
the next month (to understand that this is indeed different consider adding
one month to Feb, 15 -- we want to get Mar, 15, of course).
When adding a month to the date, all lesser components (days, hours, ...)
won't be changed unless the resulting date would be invalid: for example,
Jan 31 + 1 month will be Feb 28, not (non-existing) Feb 31.
Because of this feature, adding and subtracting back again the same
wxDateSpan will {\bf not}, in general give back the original date: Feb 28 - 1
month will be Jan 28, not Jan 31!
wxDateSpan objects can be either positive or negative. They may be
multiplied by scalars which multiply all deltas by the scalar: i.e.
$2*(1 \hbox{ month and } 1 \hbox{ day})$ is $2$ months and $2$ days. They can
be added together and with \helpref{wxDateTime}{wxdatetime} or
\helpref{wxTimeSpan}{wxtimespan}, but the type of result is different for each
case.
Beware about weeks: if you specify both weeks and days, the total number of
days added will be $7*\hbox{weeks} + \hbox{days}$! See also GetTotalDays()
function.
Equality operators are defined for wxDateSpans. Two datespans are equal if
and only if they both give the same target date when added to {\bf every}\rtfsp
source date. Thus wxDateSpan::Months(1) is not equal to wxDateSpan::Days(30),
because they don't give the same date when added to 1 Feb. But
wxDateSpan::Days(14) is equal to wxDateSpan::Weeks(2)
Finally, notice that for adding hours, minutes and so on you don't need this
class at all: \helpref{wxTimeSpan}{wxtimespan} will do the job because there
are no subtleties associated with those (we don't support leap seconds).
\wxheading{Derived from}
No base class
\wxheading{Include files}
<wx/datetime.h>
\wxheading{See also}
\helpref{Date classes overview}{wxdatetimeoverview},\rtfsp
\helpref{wxDateTime}{wxdatetime}
\latexignore{\rtfignore{\wxheading{Members}}}
% wxDateSpan ctor
\membersection{wxDateSpan::wxDateSpan}\label{wxdatespanwxdatespan}
\func{}{wxDateSpan}{\param{int }{years = $0$}, \param{int }{months = $0$}, \param{int }{weeks = $0$}, \param{int }{days = $0$}}
Constructs the date span object for the given number of years, months, weeks
and days. Note that the weeks and days add together if both are given.
% wxDateSpan::Add
\membersection{wxDateSpan::Add}\label{wxdatespanadd}
\constfunc{wxDateSpan}{Add}{\param{const wxDateSpan\& }{other}}
\func{wxDateSpan\&}{Add}{\param{const wxDateSpan\& }{other}}
\func{wxDateSpan\&}{operator$+=$}{\param{const wxDateSpan\& }{other}}
Returns the sum of two date spans. The first version returns a new object, the
second and third ones modify this object in place.
% wxDateSpan::Day
\membersection{wxDateSpan::Day}\label{wxdatespanday}
\func{static wxDateSpan}{Day}{\void}
Returns a date span object corresponding to one day.
\wxheading{See also}
\helpref{Days}{wxdatespandays}
% wxDateSpan::Days
\membersection{wxDateSpan::Days}\label{wxdatespandays}
\func{static wxDateSpan}{Days}{\param{int }{days}}
Returns a date span object corresponding to the given number of days.
\wxheading{See also}
\helpref{Day}{wxdatespanday}
% wxDateSpan::GetDays
\membersection{wxDateSpan::GetDays}\label{wxdatespangetdays}
\constfunc{int}{GetDays}{\void}
Returns the number of days (only, that it not counting the weeks component!)
in this date span.
\wxheading{See also}
\helpref{GetTotalDays}{wxdatespangettotaldays}
% wxDateSpan::GetMonths
\membersection{wxDateSpan::GetMonths}\label{wxdatespangetmonths}
\constfunc{int}{GetMonths}{\void}
Returns the number of the months (not counting the years) in this date span.
% wxDateSpan::GetTotalDays
\membersection{wxDateSpan::GetTotalDays}\label{wxdatespangettotaldays}
\constfunc{int}{GetTotalDays}{\void}
Returns the combined number of days in this date span, counting both weeks and
days. It still doesn't take neither months nor years into the account.
\wxheading{See also}
\helpref{GetWeeks}{wxdatespangetweeks}, \helpref{GetDays}{wxdatespangetdays}
% wxDateSpan::GetWeeks
\membersection{wxDateSpan::GetWeeks}\label{wxdatespangetweeks}
\constfunc{int}{GetWeeks}{\void}
Returns the number of weeks in this date span.
\wxheading{See also}
\helpref{GetTotalDays}{wxdatespangettotaldays}
% wxDateSpan::GetYears
\membersection{wxDateSpan::GetYears}\label{wxdatespangetyears}
\constfunc{int}{GetYears}{\void}
Returns the number of years in this date span.
% wxDateSpan::Month
\membersection{wxDateSpan::Month}\label{wxdatespanmonth}
\func{static wxDateSpan}{Month}{\void}
Returns a date span object corresponding to one month.
\wxheading{See also}
\helpref{Months}{wxdatespanmonths}
% wxDateSpan::Months
\membersection{wxDateSpan::Months}\label{wxdatespanmonths}
\func{static wxDateSpan}{Months}{\param{int }{mon}}
Returns a date span object corresponding to the given number of months.
\wxheading{See also}
\helpref{Month}{wxdatespanmonth}
% wxDateSpan::Multiply
\membersection{wxDateSpan::Multiply}\label{wxdatespanmultiply}
\constfunc{wxDateSpan}{Multiply}{\param{int }{factor}}
\func{wxDateSpan\&}{Multiply}{\param{int }{factor}}
\func{wxDateSpan\&}{operator$*=$}{\param{int }{factor}}
Returns the product of the date span by the specified {\it factor}. The
product is computed by multiplying each of the components by the factor.
The first version returns a new object, the second and third ones modify this
object in place.
% wxDateSpan::Negate
\membersection{wxDateSpan::Negate}\label{wxdatespannegate}
\constfunc{wxDateSpan}{Negate}{\void}
Returns the date span with the opposite sign.
\wxheading{See also}
\helpref{Neg}{wxdatespanneg}
% wxDateSpan::Neg
\membersection{wxDateSpan::Neg}\label{wxdatespanneg}
\func{wxDateSpan\&}{Neg}{\void}
\func{wxDateSpan\&}{operator$-$}{\void}
Changes the sign of this date span.
\wxheading{See also}
\helpref{Negate}{wxdatespannegate}
% wxDateSpan::SetDays
\membersection{wxDateSpan::SetDays}\label{wxdatespansetdays}
\func{wxDateSpan\&}{SetDays}{\param{int }{n}}
Sets the number of days (without modifying any other components) in this date
span.
% wxDateSpan::SetYears
\membersection{wxDateSpan::SetYears}\label{wxdatespansetyears}
\func{wxDateSpan\&}{SetYears}{\param{int }{n}}
Sets the number of years (without modifying any other components) in this date
span.
% wxDateSpan::SetMonths
\membersection{wxDateSpan::SetMonths}\label{wxdatespansetmonths}
\func{wxDateSpan\&}{SetMonths}{\param{int }{n}}
Sets the number of months (without modifying any other components) in this
date span.
% wxDateSpan::SetWeeks
\membersection{wxDateSpan::SetWeeks}\label{wxdatespansetweeks}
\func{wxDateSpan\&}{SetWeeks}{\param{int }{n}}
Sets the number of weeks (without modifying any other components) in this date
span.
% wxDateSpan::Subtract
\membersection{wxDateSpan::Subtract}\label{wxdatespansubtract}
\constfunc{wxDateSpan}{Subtract}{\param{const wxDateSpan\& }{other}}
\func{wxDateSpan\&}{Subtract}{\param{const wxDateSpan\& }{other}}
\func{wxDateSpan\&}{operator$+=$}{\param{const wxDateSpan\& }{other}}
Returns the difference of two date spans. The first version returns a new
object, the second and third ones modify this object in place.
% wxDateSpan::Week
\membersection{wxDateSpan::Week}\label{wxdatespanweek}
\func{static wxDateSpan}{Week}{\void}
Returns a date span object corresponding to one week.
\wxheading{See also}
\helpref{Weeks}{wxdatespanweeks}
% wxDateSpan::Weeks
\membersection{wxDateSpan::Weeks}\label{wxdatespanweeks}
\func{static wxDateSpan}{Weeks}{\param{int }{weeks}}
Returns a date span object corresponding to the given number of weeks.
\wxheading{See also}
\helpref{Week}{wxdatespanweek}
% wxDateSpan::Year
\membersection{wxDateSpan::Year}\label{wxdatespanyear}
\func{static wxDateSpan}{Year}{\void}
Returns a date span object corresponding to one year.
\wxheading{See also}
\helpref{Years}{wxdatespanyears}
% wxDateSpan::Years
\membersection{wxDateSpan::Years}\label{wxdatespanyears}
\func{static wxDateSpan}{Years}{\param{int }{years}}
Returns a date span object corresponding to the given number of years.
\wxheading{See also}
\helpref{Year}{wxdatespanyear}
% wxDateSpan::operator==
\membersection{wxDateSpan::operator$==$}\label{wxdatespanoperatorequal}
\constfunc{bool}{operator$==$}{\param{wxDateSpan\&}{ other}}
Returns {\tt true} if this date span is equal to the other one. Two date spans
are considered equal if and only if they have the same number of years and
months and the same total number of days (counting both days and weeks).
% wxDateSpan::operator!=
\membersection{wxDateSpan::operator$!=$}\label{wxdatespanoperatornotequal}
\constfunc{bool}{operator$!=$}{\param{wxDateSpan\&}{ other}}
Returns {\tt true} if this date span is different from the other one.
\wxheading{See also}
\helpref{operator==}{wxdatespanoperatorequal}
|