Ignore:
Timestamp:
Nov 8, 2005, 5:13:56 PM (20 years ago)
Author:
ansari
Message:

Amelioration classe TimeStamp - prise en charge format YYYY-MM-DDThh:mm:ss
et TimeStamp rendu PPersist - Reza 8/11/2005

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/BaseTools/timestamp.h

    r2826 r2830  
    1111
    1212#include "machdefs.h"
     13#include "objfio.h"
    1314#include <string>
    1415#include <iostream>
     
    1718 
    1819//! Class representing date and time
    19 class TimeStamp {
     20class TimeStamp : public AnyDataObj {
    2021public:
    2122  /*  Pour utilisation ulterieure
     
    2627  enum Month {month_January=1, month_February, month_March, month_April, month_May, month_June, month_July,
    2728             month_August, month_September, month_October, month_November, month_December}; 
     29
     30  enum StrFmt { FmtPackedDateTime , FmtDateOnly, FmtTimeOnly, FmtDateTime };
    2831
    2932  //! Default Constructor : current date and time (GMT)
     
    3639  //! Constructor with specification of day,month,year,hour,minutes,seconds
    3740  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 
    4044  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);
    4149
    4250  //! Set the value of the time stamp copying from "ts"
     
    4654  //! Sets the value of the time stamp from the number of days and seconds
    4755  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()); }
    4860  //! initialize with current date and time (GMT)
    4961  void SetNow();
     
    7890
    7991  //! Return the timestamp in string format
    80   string ToString(bool fgday=true, bool fghour=true) const;
     92  string ToString(StrFmt fmt=FmtPackedDateTime) const;
    8193 
    8294  //! Return the integral number of days since 0 Jan 1901
     
    8698
    8799  //! Prints the date/time in string format on \b cout
    88   inline  void    Print(bool fgday=true, bool fghour=true) const 
    89      { Print(cout, fgday, fghour); } 
     100  inline  void    Print(StrFmt fmt=FmtDateTime) const 
     101     { Print(cout, fmt); } 
    90102  //! 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;
    92104
    93105  //! Number of days in a given month 
     
    108120  {  ts.Print(s);  return(s);  }
    109121
     122/*! Writes the object in the POutPersist stream \b os */
     123inline 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 */
     126inline PInPersist& operator >> (PInPersist& is, TimeStamp & obj)
     127{ ObjFileIO<TimeStamp> fio(&obj); is.SkipToNextObject(); fio.Read(is); return(is); }
     128
    110129} // namespace SOPHYA
    111130
Note: See TracChangeset for help on using the changeset viewer.