Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDate.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "JSystem/JDate.hh"
6 #include "Jeep/JParser.hh"
7 #include "Jeep/JMessage.hh"
8 #include "Jeep/JPrint.hh"
9 
10 
11 /**
12  * \file
13  *
14  * Example program to show system time.
15  * \author mdejong
16  */
17 int main(int argc, char* argv[])
18 {
19  using namespace std;
20  using namespace JPP;
21 
22  int option;
23 
24  try {
25 
26  JParser<> zap("Example program to show system time.");
27 
28  zap['O'] = make_field(option, "formatting option (0: human-readable; 1: ISO-8601");
29 
30  zap(argc, argv);
31  }
32  catch(const exception &error) {
33  FATAL(error.what() << endl);
34  }
35 
36  JDateAndTimeFormat format = (JDateAndTimeFormat)option;
37 
38  cout << getDate(format) << endl;
39  cout << getTime(format) << endl;
40  cout << getDateAndTime().toString(format) << endl;
41 
42  JDateAndTime cal;
43 
44  cout << cal.getYear() << '/' << FILL(2,'0') << cal.getMonth() << '/' << FILL(2,'0') << cal.getDay() << endl;
45 }
Utility class to parse command line options.
Definition: JParser.hh:1500
JDateAndTimeFormat
Date and time formats.
double getTime(const Hit &hit)
Get true time of hit.
Date and time functions.
static JDateAndTime getDateAndTime
Function object to get ASCII formatted date and time.
std::string toString(const JDateAndTimeFormat option=HUMAN_READABLE) const
Get ASCII formatted date and time.
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
General purpose messaging.
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:327
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
const char * getDate(const JDateAndTimeFormat option=HUMAN_READABLE)
Get ASCII formatted date.
int main(int argc, char *argv[])
Definition: Main.cpp:15