KaliVeda
Toolkit for HIC analysis
KVDatime Class Reference

Detailed Description

Extension of TDatime to handle various useful date formats.

This class can 'read' and 'write' date and timestamps in many different formats:

  • old VAX GANIL acquisition (INDRA) run-sheet format 29-SEP-2005 09:42:17.00
  • 2010 GANIL acquisition runfile format 27Nov10_02h07m40s
  • current GANIL Narval acquisition runfile format 12-04-18_17h09m41s
  • SQL format date 2007-05-02 14:52:18
  • SRB format date 2008-12-19-15.21
  • IRODS format date 2008-12-19.15:21
  • DMY format date 19/12/2008

Definition at line 34 of file KVDatime.h.

#include <KVDatime.h>

Inheritance diagram for KVDatime:

Public Types

enum  EKVDateFormat {
  kCTIME , kGANACQ , kSQL , kSRB ,
  kIRODS , kDMY , kGANACQ2010 , kGANACQNarval
}
 

Public Member Functions

 KVDatime ()
 
 KVDatime (const Char_t *DateString, EKVDateFormat f=kGANACQ)
 
 KVDatime (const KVDatime &d)
 
 KVDatime (const TDatime &d)
 
 KVDatime (Int_t date, Int_t time)
 
 KVDatime (Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec)
 
 KVDatime (UInt_t tloc, Bool_t dosDate=kFALSE)
 
const Char_tAsDMYDateString () const
 
const Char_tAsGanacqDateString () const
 
Double_t GetDureeInSeconds (KVDatime from)
 
Double_t GetNumberOfSeconds (Int_t ref_year=0)
 
KVDatimeoperator= (const KVDatime &)
 copy assignment operator More...
 
void SetDMYDate (const Char_t *DMYString)
 Set date from string in format "DD/MM/YYYY". More...
 
void SetGanacq2010Date (const Char_t *GanacqDateString)
 
void SetGanacqDate (const Char_t *GanacqDateString)
 
void SetGanacqNarvalDate (const Char_t *GanacqDateString)
 
void SetIRODSDate (const Char_t *IRODSDateString)
 
void SetSQLDate (const Char_t *SQLDateString)
 
void SetSRBDate (const Char_t *SRBDateString)
 
const Char_tString (EKVDateFormat fmt=kCTIME)
 
- Public Member Functions inherited from TDatime
 TDatime ()
 
 TDatime (const char *sqlDateTime)
 
 TDatime (const TDatime &d)
 
 TDatime (Int_t date, Int_t time)
 
 TDatime (Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec)
 
 TDatime (UInt_t tloc, Bool_t dosDate=kFALSE)
 
virtual ~TDatime ()
 
const char * AsSQLString () const
 
const char * AsString () const
 
const char * AsString (char *out) const
 
UInt_t Convert (Bool_t toGMT=kFALSE) const
 
void Copy (TDatime &datime) const
 
void FillBuffer (char *&buffer)
 
UInt_t Get () const
 
Int_t GetDate () const
 
Int_t GetDay () const
 
Int_t GetDayOfWeek () const
 
Int_t GetHour () const
 
Int_t GetMinute () const
 
Int_t GetMonth () const
 
Int_t GetSecond () const
 
Int_t GetTime () const
 
Int_t GetYear () const
 
virtual TClassIsA () const
 
TDatimeoperator= (const TDatime &d)
 
void Print (Option_t *option="") const
 
void ReadBuffer (char *&buffer)
 
void Set ()
 
void Set (const char *sqlDateTime)
 
void Set (Int_t date, Int_t time)
 
void Set (Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec)
 
void Set (UInt_t tloc, Bool_t dosDate=kFALSE)
 
Int_t Sizeof () const
 
virtual void Streamer (TBuffer &)
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 

Static Public Member Functions

static Bool_t IsGANACQ2010Format (const Char_t *date)
 
static Bool_t IsGANACQFormat (const Char_t *date)
 
static Bool_t IsGANACQNarvalFormat (const Char_t *date)
 
static Bool_t IsIRODSFormat (const Char_t *date)
 
static Bool_t IsSQLFormat (const Char_t *date)
 
static Bool_t IsSRBFormat (const Char_t *date)
 
static const Char_tMonth (Int_t m)
 
- Static Public Member Functions inherited from TDatime
static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
static Int_t GetDateFromGlobalDay (Int_t day)
 
static void GetDateTime (UInt_t datetime, Int_t &date, Int_t &time)
 
static Int_t GetGlobalDayFromDate (Int_t date)
 
static Int_t GetLegalGlobalDayFromDate (Int_t date)
 

Private Member Functions

std::optional< int > get_month_from_name (const char *)
 
void init_month_map ()
 set up static map of month names to month numbers if needed More...
 

Private Attributes

TString fStr
 internal buffer used by String method More...
 

Static Private Attributes

static std::unordered_map< std::string, int > fMonthToNum
 map month name to number More...
 
static const std::vector< std::string > fNumToMonth = {"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"}
 map month number to name More...
 

Additional Inherited Members

- Protected Attributes inherited from TDatime
UInt_t fDatime
 

Member Enumeration Documentation

◆ EKVDateFormat

Enumerator
kCTIME 
kGANACQ 
kSQL 
kSRB 
kIRODS 
kDMY 
kGANACQ2010 
kGANACQNarval 

Definition at line 45 of file KVDatime.h.

Constructor & Destructor Documentation

◆ KVDatime() [1/7]

KVDatime::KVDatime ( )

Definition at line 50 of file KVDatime.cpp.

◆ KVDatime() [2/7]

KVDatime::KVDatime ( const Char_t DateString,
EKVDateFormat  f = kGANACQ 
)

if f = KVDatime::kGANACQ:

Decodes GANIL acquisition (INDRA) run-sheet format date into a TDatime

Format of date string is: 29-SEP-2005 09:42:17.00

if f = KVDatime::kGANACQ2010:

Decodes GANIL acquisition runfile format date into a TDatime

Format of date string is: 27Nov10_02h07m40s

if f = KVDatime::kGANACQNarval:

Decodes GANIL Narval acquisition runfile format date into a TDatime

Format of date string is: 12-04-18_17h09m41s

if f = KVDatime::kSQL:

Decodes SQL format date into a TDatime (i.e. same format as returned by TDatime::AsSQLString(): 2007-05-02 14:52:18)

if f = KVDatime::kSRB:

Decodes SRB format date into a TDatime

Format of date string is: 2008-12-19-15.21

if f = KVDatime::kIRODS:

Decodes IRODS format date into a TDatime

Format of date string is: 2008-12-19.15:21

if f = KVDatime::kDMY:

Decodes DMY format date into a TDatime

Format of date string is: 19/12/2008

Definition at line 99 of file KVDatime.cpp.

◆ KVDatime() [3/7]

KVDatime::KVDatime ( const KVDatime d)

Definition at line 173 of file KVDatime.cpp.

◆ KVDatime() [4/7]

KVDatime::KVDatime ( const TDatime d)

Definition at line 177 of file KVDatime.cpp.

◆ KVDatime() [5/7]

KVDatime::KVDatime ( UInt_t  tloc,
Bool_t  dosDate = kFALSE 
)

Definition at line 181 of file KVDatime.cpp.

◆ KVDatime() [6/7]

KVDatime::KVDatime ( Int_t  date,
Int_t  time 
)

Definition at line 185 of file KVDatime.cpp.

◆ KVDatime() [7/7]

KVDatime::KVDatime ( Int_t  year,
Int_t  month,
Int_t  day,
Int_t  hour,
Int_t  min,
Int_t  sec 
)

Definition at line 189 of file KVDatime.cpp.

Member Function Documentation

◆ AsDMYDateString()

const Char_t * KVDatime::AsDMYDateString ( ) const

Definition at line 388 of file KVDatime.cpp.

◆ AsGanacqDateString()

const Char_t * KVDatime::AsGanacqDateString ( ) const

Return date and time string with format "29-SEP-2005 09:42:17.00" Copy the string immediately if you want to reuse/keep it

Definition at line 376 of file KVDatime.cpp.

◆ get_month_from_name()

std::optional< int > KVDatime::get_month_from_name ( const char *  Month)
private

Definition at line 35 of file KVDatime.cpp.

◆ GetDureeInSeconds()

Double_t KVDatime::GetDureeInSeconds ( KVDatime  from)

Definition at line 588 of file KVDatime.cpp.

◆ GetNumberOfSeconds()

Double_t KVDatime::GetNumberOfSeconds ( Int_t  ref_year = 0)

Definition at line 552 of file KVDatime.cpp.

◆ init_month_map()

void KVDatime::init_month_map ( )
private

set up static map of month names to month numbers if needed

Definition at line 20 of file KVDatime.cpp.

◆ IsGANACQ2010Format()

Bool_t KVDatime::IsGANACQ2010Format ( const Char_t date)
static

Static method, returns kTRUE if 'date' is in new (2010) format of GANIL acquisition run files, e.g. run_0058.dat.27Nov10_02h07m40s

Definition at line 453 of file KVDatime.cpp.

◆ IsGANACQFormat()

Bool_t KVDatime::IsGANACQFormat ( const Char_t date)
static

Static method, returns kTRUE if 'date' is in format of GANIL acquisition e.g. 29-SEP-2005 09:42:17.00

Definition at line 436 of file KVDatime.cpp.

◆ IsGANACQNarvalFormat()

Bool_t KVDatime::IsGANACQNarvalFormat ( const Char_t date)
static

Static method, returns kTRUE if 'date' is in format of GANIL Narval acquisition run files, e.g. run_0058.dat.27-11-10_02h07m40s

Definition at line 474 of file KVDatime.cpp.

◆ IsIRODSFormat()

Bool_t KVDatime::IsIRODSFormat ( const Char_t date)
static

Static method, returns kTRUE if 'date' is in IRODS format e.g. 2008-12-19.15:21

Definition at line 528 of file KVDatime.cpp.

◆ IsSQLFormat()

Bool_t KVDatime::IsSQLFormat ( const Char_t date)
static

Static method, returns kTRUE if 'date' is in SQL format e.g. 2007-05-02 14:52:18

Definition at line 494 of file KVDatime.cpp.

◆ IsSRBFormat()

Bool_t KVDatime::IsSRBFormat ( const Char_t date)
static

Static method, returns kTRUE if 'date' is in SRB format e.g. 2008-12-19-15.21

Definition at line 511 of file KVDatime.cpp.

◆ Month()

const Char_t * KVDatime::Month ( Int_t  m)
static

Definition at line 543 of file KVDatime.cpp.

◆ operator=()

KVDatime & KVDatime::operator= ( const KVDatime d)

copy assignment operator

Definition at line 197 of file KVDatime.cpp.

◆ SetDMYDate()

void KVDatime::SetDMYDate ( const Char_t DMYString)

Set date from string in format "DD/MM/YYYY".

Definition at line 264 of file KVDatime.cpp.

◆ SetGanacq2010Date()

void KVDatime::SetGanacq2010Date ( const Char_t GanacqDateString)

Decodes dates in new (2010) format of GANIL acquisition run files, e.g. run_0058.dat.27Nov10_02h07m40s

Definition at line 278 of file KVDatime.cpp.

◆ SetGanacqDate()

void KVDatime::SetGanacqDate ( const Char_t GanacqDateString)

Decodes GANIL acquisition (INDRA) run-sheet format date into a TDatime Format of date string is: 29-SEP-2005 09:42:17.00 or 29-SEP-2005 09:42:17 or 29-SEP-05 09:42:17.00 or 29-SEP-05 09:42:17

If format is not respected, we set to current time & date

Definition at line 331 of file KVDatime.cpp.

◆ SetGanacqNarvalDate()

void KVDatime::SetGanacqNarvalDate ( const Char_t GanacqDateString)

Decodes dates in format of GANIL Narval acquisition run files, e.g. run_0058.dat.27-11-10_02h07m40s

Definition at line 305 of file KVDatime.cpp.

◆ SetIRODSDate()

void KVDatime::SetIRODSDate ( const Char_t DateString)

Decodes IRODS format date into a TDatime Format of date string is: 2008-12-19.15:21

Definition at line 246 of file KVDatime.cpp.

◆ SetSQLDate()

void KVDatime::SetSQLDate ( const Char_t DateString)

Decodes SQL format date into a TDatime (i.e. same format as returned by TDatime::AsSQLString(): "2007-05-02 14:52:18")

Definition at line 209 of file KVDatime.cpp.

◆ SetSRBDate()

void KVDatime::SetSRBDate ( const Char_t DateString)

Decodes SRB format date into a TDatime Format of date string is: 2008-12-19-15.21

Definition at line 226 of file KVDatime.cpp.

◆ String()

const Char_t * KVDatime::String ( EKVDateFormat  fmt = kCTIME)

Returns date & time as a string in required format: fmt = kCTIME (default) : ctime format e.g. Thu Apr 10 10:48:34 2008 fmt = kSQL : SQL format e.g. 1997-01-15 20:16:28 fmt = kGANACQ : GANIL acquisition format e.g. 29-SEP-2005 09:42:17.00 fmt = kDMY : DD/MM/YYYY

Definition at line 404 of file KVDatime.cpp.

Member Data Documentation

◆ fMonthToNum

std::unordered_map< std::string, int > KVDatime::fMonthToNum
staticprivate

map month name to number

Definition at line 37 of file KVDatime.h.

◆ fNumToMonth

const std::vector< std::string > KVDatime::fNumToMonth = {"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"}
staticprivate

map month number to name

Definition at line 36 of file KVDatime.h.

◆ fStr

TString KVDatime::fStr
private

internal buffer used by String method

Definition at line 38 of file KVDatime.h.