5 #include <boost/date_time/gregorian/gregorian.hpp>
6 #include <boost/date_time/posix_time/posix_time.hpp>
8 using namespace boost::posix_time;
9 using namespace boost::gregorian;
16 , year(0), month(1), day(1)
17 , hour(0), minute(0), second(0)
21 : relCalendar(&calendar)
22 , year(0), month(1), day(1)
23 , hour(0), minute(0), second(0)
27 int yr,
int mth,
int d,
28 int hr,
int min,
int sec)
29 : relCalendar(&calendar)
30 , year(yr), month(mth), day(d)
31 , hour(hr), minute(min), second(sec)
35 DEBUG(<<
"La date initialisée a été modifiée "
36 <<
"car elle était incorrecte par rapport au calendrier souhaité.");
41 : relCalendar(date.relCalendar)
42 , year(date.year), month(date.month), day(date.day)
43 , hour(date.hour), minute(date.minute), second(date.second)
48 DEBUG(<<
"La date initialisée a été modifiée "
49 <<
"car elle était incorrecte par rapport au calendrier souhaité.");
81 while (date.
year>=maxSize)
86 s = out.width(width); c = out.fill(
'0'); out << date.
year <<
'-';
88 s = out.width(2); c = out.fill(
'0'); out << date.
month <<
'-';
89 s = out.width(2); c = out.fill(
'0'); out << date.
day <<
' ';
90 s = out.width(2); c = out.fill(
'0'); out << date.
hour <<
':';
91 s = out.width(2); c = out.fill(
'0'); out << date.
minute <<
':';
92 s = out.width(2); c = out.fill(
'0'); out << date.
second;
107 CDate::operator
Time(
void) const
148 ERROR(
"const CCalendar& CDate::getRelCalendar(void) const",
149 "Invalid state: The date is not associated with any calendar.");
164 CDate yearStart(*
this);
241 this->
month += value;
243 if (this->
month == nbMonthsPerYear + 1) {
year++; this->
month = 1; }
274 s = oss.width(4); c = oss.fill(
'0'); oss <<
year;
275 s = oss.width(2); c = oss.fill(
'0'); oss <<
month;
276 s = oss.width(2); c = oss.fill(
'0'); oss <<
day;
287 for(string::const_iterator it=str.begin();it!=str.end();++it)
291 if (*it==
'%') level++;
299 oss.width(4); oss.fill(
'0'); oss <<
year;
306 oss.width(2); oss.fill(
'0'); oss <<
day;
310 oss.width(2); oss.fill(
'0'); oss <<
hour;
314 oss.width(2); oss.fill(
'0'); oss <<
second;
318 oss.width(0); oss <<
Time(*
this);
335 oss.width(2); oss.fill(
'0'); oss <<
month;
339 oss.width(2); oss.fill(
'0'); oss <<
minute;
virtual int getHourLength(void) const
static void parseDateDefault(StdIStream &in, CDate &date)
Parse a date using a generic parser.
int getSecondOfDay() const
Get the fraction of the current day as a real number between 0 and 1.
int getSecond(void) const
Get the calendar associated to the date.
std::istringstream StdIStringStream
double getFractionOfYear() const
Get the number of seconds since the beginning of the day.
void setDate(int yr, int mth, int d, int hr=0, int min=0, int sec=0)
virtual int getYearLength(void) const
const CCalendar & getRelCalendar(void) const
bool operator==(const CDate &date)
bool hasRelCalendar(void) const
Get the number of seconds since the beginning of the year.
void setMinute(int newminute)
virtual int getMonthLength(const CDate &date) const
static CDate FromString(const StdString &str, const CCalendar &calendar)
CDate & operator=(const CDate &date)
Opérateurs ///.
long long int Time
////////////////////// Déclarations ////////////////////// ///
virtual int getMinuteLength(void) const
CBufferOut & operator<<(CBufferOut &buffer, const CArray< T_numtype, N_rank > &array)
virtual int getYearTotalLength(const CDate &date) const
int getSecondOfYear() const
Get the number of days (expressed as a real number) since the beginning of the year.
CATCH CScalarAlgorithmReduceScalar::CScalarAlgorithmReduceScalar(CScalar *scalarDestination, CScalar *scalarSource, CReduceScalarToScalar *algo ERROR)("CScalarAlgorithmReduceScalar::CScalarAlgorithmReduceScalar(CScalar* scalarDestination, CScalar* scalarSource, CReduceScalarToScalar* algo)",<< "Operation must be defined."<< "Scalar source "<< scalarSource->getId()<< std::endl<< "Scalar destination "<< scalarDestination->getId())
string getStr(const string &str) const
int getMinute(void) const
const CDate & getTimeOrigin(void) const
virtual bool checkDate(CDate &date) const
Test if a date is valid with regard to the current calendar.
bool setRelCalendar(const CCalendar &relCalendar)
CBufferIn & operator>>(CBufferIn &buffer, CArray< T_numtype, N_rank > &array)
const CCalendar * relCalendar
Propriétés privées ///.
void addMonth(int value)
Set the calendar associated to the date.
virtual void parseDate(StdIStream &in, CDate &date) const
Parse a date using the calendar's parser.
CDate(void)
Create an empty date associated to the specified calendar.
virtual int getDayLengthInSeconds(void) const
Returns the day length expressed in seconds.
virtual bool hasLeapYear() const
Test if the calendar can have leap year.
StdString getStryyyymmdd(void) const
void setHour(int newhour)
void setMonth(int newmonth)
int getYear(void) const
Divers accesseurs ///.
void setYear(int newyear)
Mutateurs ///.
double getDayOfYear() const
Get the fraction of the current year as a real number between 0 and 1.
bool checkDate(void)
Traitements ///.
StdString toString(void) const
Autres ///.
double getFractionOfDay() const
Get the fraction of the current day as a real number between 0 and 1.
void setSecond(int newsecond)
std::ostringstream StdOStringStream
Définition de types (issus de la bibliothèque standard)///.
~CDate(void)
Destructeur ///.