19#ifndef INCLUDED_TOOLS_DATE_HXX
20#define INCLUDED_TOOLS_DATE_HXX
26#include <com/sun/star/util/Date.hpp>
58 void setDateFromDMY( sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear );
72 explicit Date( DateInitSystem );
73 explicit Date( sal_Int32 nDate ) : mnDate(nDate) {}
74 Date(
const Date& rDate ) : mnDate(rDate.mnDate) {}
77 Date( sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear )
78 { setDateFromDMY(nDay, nMonth, nYear); }
80 Date(
const css::util::Date& rUDate )
82 setDateFromDMY(rUDate.Day, rUDate.Month, rUDate.Year);
84 Date(
const css::util::DateTime& _rDateTime );
86 bool IsEmpty()
const {
return mnDate == 0; }
88 void SetDate( sal_Int32 nNewDate );
89 sal_Int32
GetDate()
const {
return mnDate; }
91 sal_uInt32
GetDateUnsigned()
const {
return static_cast<sal_uInt32
>(mnDate < 0 ? -mnDate : mnDate); }
92 css::util::Date
GetUNODate()
const {
return css::util::Date(GetDay(), GetMonth(), GetYear()); }
95 void SetDay( sal_uInt16 nNewDay );
97 void SetMonth( sal_uInt16 nNewMonth );
99 void SetYear( sal_Int16 nNewYear );
104 static_cast<sal_uInt16
>(-mnDate % 100) :
105 static_cast<sal_uInt16
>( mnDate % 100);
110 static_cast<sal_uInt16
>((-mnDate / 100) % 100) :
111 static_cast<sal_uInt16
>(( mnDate / 100) % 100);
113 sal_Int16
GetYear()
const {
return static_cast<sal_Int16
>(mnDate / 10000); }
115 sal_uInt16
GetYearUnsigned()
const {
return static_cast<sal_uInt16
>((mnDate < 0 ? -mnDate : mnDate) / 10000); }
116 sal_Int16
GetNextYear()
const { sal_Int16 nY = GetYear();
return nY == -1 ? 1 : nY + 1; }
117 sal_Int16
GetPrevYear()
const { sal_Int16 nY = GetYear();
return nY == 1 ? -1 : nY - 1; }
123 void AddYears( sal_Int16 nAddYears );
129 void AddMonths( sal_Int32 nAddMonths );
133 void AddDays( sal_Int32 nAddDays );
149 sal_uInt16 GetDayOfYear()
const;
161 sal_Int16 nMinimumNumberOfDaysInWeek = 4 )
const;
176 sal_uInt16 GetDaysInMonth()
const;
185 bool IsValidAndGregorian()
const;
189 bool IsValidDate()
const;
192 bool IsEndOfMonth()
const;
207 {
return ((mnDate >= rFrom.
mnDate) &&
208 (mnDate <= rTo.
mnDate)); }
211 {
return (mnDate == rDate.
mnDate); }
213 {
return (mnDate != rDate.
mnDate); }
215 {
return (mnDate > rDate.
mnDate); }
217 {
return (mnDate < rDate.
mnDate); }
219 {
return (mnDate >= rDate.
mnDate); }
221 {
return (mnDate <= rDate.
mnDate); }
224 { mnDate = rDate.
mnDate;
return *
this; }
225 Date& operator =(
const css::util::Date& rUDate )
226 { setDateFromDMY( rUDate.Day, rUDate.Month, rUDate.Year);
return *
this; }
239 static sal_uInt16 GetDaysInMonth( sal_uInt16 nMonth, sal_Int16 nYear );
242 static sal_Int32
DateToDays( sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear );
244 static bool IsValidDate( sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear );
246 static bool IsEndOfMonth(sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear);
248 static bool Normalize( sal_uInt16 & rDay, sal_uInt16 & rMonth, sal_Int16 & rYear );
252 sal_Int32 GetAsNormalizedDays()
const;
bool operator==(const BigInt &rVal1, const BigInt &rVal2)
bool operator<(const BigInt &rVal1, const BigInt &rVal2)
Represents a date in the proleptic Gregorian calendar.
sal_Int32 GetDate() const
sal_uInt16 GetDaysInYear() const
sal_Int16 GetNextYear() const
css::util::Date GetUNODate() const
bool IsBetween(const Date &rFrom, const Date &rTo) const
Date(const css::util::Date &rUDate)
Date(sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear)
nDay and nMonth both must be <100, nYear must be != 0
sal_Int16 GetYear() const
sal_uInt16 GetDay() const
sal_Int16 GetPrevYear() const
sal_uInt32 GetDateUnsigned() const
Type safe access for values that are guaranteed to be unsigned, like Date::SYSTEM.
sal_uInt16 GetYearUnsigned() const
Type safe access for values that are guaranteed to be unsigned, like Date::SYSTEM.
sal_uInt16 GetMonth() const
TOOLS_DLLPUBLIC std::ostream & operator<<(std::ostream &os, const Date &rDate)
DateTime operator-(const DateTime &rDateTime, sal_Int32 nDays)
DateTime operator+(const DateTime &rDateTime, sal_Int32 nDays)
bool operator>(const Fraction &rVal1, const Fraction &rVal2)
bool operator>=(const Fraction &rVal1, const Fraction &rVal2)
bool operator!=(const Fraction &rVal1, const Fraction &rVal2)
bool operator<=(const Fraction &rVal1, const Fraction &rVal2)
sal_Int16 GetDayOfWeek(sal_Int32 nDate)
constexpr OUStringLiteral EMPTY