Changeset 2830 in Sophya for trunk/SophyaLib/BaseTools/timestamp.h
- Timestamp:
- Nov 8, 2005, 5:13:56 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/BaseTools/timestamp.h
r2826 r2830 11 11 12 12 #include "machdefs.h" 13 #include "objfio.h" 13 14 #include <string> 14 15 #include <iostream> … … 17 18 18 19 //! Class representing date and time 19 class TimeStamp {20 class TimeStamp : public AnyDataObj { 20 21 public: 21 22 /* Pour utilisation ulterieure … … 26 27 enum Month {month_January=1, month_February, month_March, month_April, month_May, month_June, month_July, 27 28 month_August, month_September, month_October, month_November, month_December}; 29 30 enum StrFmt { FmtPackedDateTime , FmtDateOnly, FmtTimeOnly, FmtDateTime }; 28 31 29 32 //! Default Constructor : current date and time (GMT) … … 36 39 //! Constructor with specification of day,month,year,hour,minutes,seconds 37 40 TimeStamp(int year, int month, int day, int hour, int min, double sec); 38 //! Constructor with specification of date & time in the format YYYY/MM/DD hh:mm:ss 39 TimeStamp(string& date, string& hour); 41 //! Constructor with specification of date & time in the format YYYY/MM/DD hh:mm:ss 42 TimeStamp(string const & date, string const & hour); 43 //! Constructor with specification of date & time in the format YYYY/MM/DD hh:mm:ss 40 44 TimeStamp(const char* date, const char* hour); 45 //! Constructor with specification of date & time in the format YYYY-MM-DDThh:mm:ss 46 TimeStamp(string& datim); 47 //! Constructor with specification of date & time in the format YYYY-MM-DDThh:mm:ss 48 TimeStamp(const char* datim); 41 49 42 50 //! Set the value of the time stamp copying from "ts" … … 46 54 //! Sets the value of the time stamp from the number of days and seconds 47 55 void Set(int_8 days, r_8 seconds); 56 //! Sets the value of the time stamp from a string in the format YYYY-MM-DDThh:mm:ss 57 void Set(const char * datim); 58 //! Sets the value of the time stamp from a string in the format YYYY-MM-DDThh:mm:ss 59 inline void Set(string const & datim) { Set(datim.c_str()); } 48 60 //! initialize with current date and time (GMT) 49 61 void SetNow(); … … 78 90 79 91 //! Return the timestamp in string format 80 string ToString( bool fgday=true, bool fghour=true) const;92 string ToString(StrFmt fmt=FmtPackedDateTime) const; 81 93 82 94 //! Return the integral number of days since 0 Jan 1901 … … 86 98 87 99 //! Prints the date/time in string format on \b cout 88 inline void Print( bool fgday=true, bool fghour=true) const89 { Print(cout, f gday, fghour); }100 inline void Print(StrFmt fmt=FmtDateTime) const 101 { Print(cout, fmt); } 90 102 //! Prints the date/time in string format on stream \b os 91 virtual void Print(ostream& os, bool fgday=true, bool fghour=true) const;103 virtual void Print(ostream& os, StrFmt fmt=FmtDateTime) const; 92 104 93 105 //! Number of days in a given month … … 108 120 { ts.Print(s); return(s); } 109 121 122 /*! Writes the object in the POutPersist stream \b os */ 123 inline POutPersist& operator << (POutPersist& os, TimeStamp & obj) 124 { ObjFileIO<TimeStamp> fio(&obj); fio.Write(os); return(os); } 125 /*! Reads the object from the PInPersist stream \b is */ 126 inline PInPersist& operator >> (PInPersist& is, TimeStamp & obj) 127 { ObjFileIO<TimeStamp> fio(&obj); is.SkipToNextObject(); fio.Read(is); return(is); } 128 110 129 } // namespace SOPHYA 111 130
Note:
See TracChangeset
for help on using the changeset viewer.