]> Creatis software - bbtk.git/blob - packages/std/src/bbstdDateTime.cxx
#3476 DateTime box std
[bbtk.git] / packages / std / src / bbstdDateTime.cxx
1 //===== 
2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
3 //===== 
4 #include "bbstdDateTime.h"
5 #include "bbstdPackage.h"
6
7 #include <iostream>
8 #include <iomanip>
9 #include <ctime>
10
11
12 namespace bbstd
13 {
14
15 BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,DateTime)
16 BBTK_BLACK_BOX_IMPLEMENTATION(DateTime,bbtk::AtomicBlackBox);
17 //===== 
18 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
19 //===== 
20 void DateTime::Process()
21 {
22
23 // THE MAIN PROCESSING METHOD BODY
24 //   Here we simply set the input 'In' value to the output 'Out'
25 //   And print out the output value
26 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
27 //    void bbSet{Input|Output}NAME(const TYPE&)
28 //    const TYPE& bbGet{Input|Output}NAME() const 
29 //    Where :
30 //    * NAME is the name of the input/output
31 //      (the one provided in the attribute 'name' of the tag 'input')
32 //    * TYPE is the C++ type of the input/output
33 //      (the one provided in the attribute 'type' of the tag 'input')
34 //    bbSetOutputOut( bbGetInputIn() );
35 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
36   
37     std::time_t t = std::time(nullptr);
38     std::tm tm = *std::localtime(&t);
39
40     std::stringstream ssDate;
41     ssDate << std::put_time(&tm, "%Y/%m/%d");
42     std::string date = ssDate.str();
43     
44     std::stringstream ssTime;
45     ssTime << std::put_time(&tm, "%H:%M");
46     std::string time = ssTime.str();
47     bbSetOutputDate( date );
48     bbSetOutputTime( time );
49 }
50 //===== 
51 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
52 //===== 
53 void DateTime::bbUserSetDefaultValues()
54 {
55
56 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
57 //    Here we initialize the input 'In' to 0
58 //   bbSetInputIn(0);
59   
60 }
61 //===== 
62 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
63 //===== 
64 void DateTime::bbUserInitializeProcessing()
65 {
66
67 //  THE INITIALIZATION METHOD BODY :
68 //    Here does nothing 
69 //    but this is where you should allocate the internal/output pointers 
70 //    if any 
71
72   
73 }
74 //===== 
75 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
76 //===== 
77 void DateTime::bbUserFinalizeProcessing()
78 {
79
80 //  THE FINALIZATION METHOD BODY :
81 //    Here does nothing 
82 //    but this is where you should desallocate the internal/output pointers 
83 //    if any
84   
85 }
86 }
87 // EO namespace bbstd
88
89