Changeset 316
- Timestamp:
- 02/20/12 17:42:29 (13 years ago)
- Location:
- XIOS/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/bld.cfg
r314 r316 25 25 search_src true 26 26 src::zzz . 27 src::date $PWD/extern/boost/src/date_time 27 28 bld::lib xios 28 29 bld::target libxios.a 29 bld::target generate_fortran_interface.exe 30 #bld::target test.exe 31 #bld::target generate_fortran_interface.exe 30 32 bld::target xios_server.exe test_cs.exe 31 33 bld::exe_dep -
XIOS/trunk/src/date.cpp
r231 r316 1 1 #include "date.hpp" 2 2 #include "calendar.hpp" 3 #include <boost/date_time/gregorian/gregorian.hpp> 4 #include <boost/date_time/posix_time/posix_time.hpp> 5 6 using namespace boost::posix_time ; 7 using namespace boost::gregorian ; 3 8 4 9 namespace xmlioserver … … 48 53 StdOStream & operator<<(StdOStream & out, const CDate & date) 49 54 { 50 std::streamsize s = out.width (2); 51 char c = out.fill ('0'); 52 out << date.day << '/'; 53 s = out.width (2); c = out.fill ('0'); 54 out << date.month << '/'; 55 s = out.width (4); c = out.fill ('0'); 56 out << date.year << '-'; 57 s = out.width (2); c = out.fill ('0'); 58 out << date.hour << ':'; 59 s = out.width (2); c = out.fill ('0'); 60 out << date.minute << ':'; 61 s = out.width (2); c = out.fill ('0'); 62 out << date.second; 55 std::streamsize s ; 56 char c ; 63 57 58 s = out.width (4); c = out.fill ('0') ; out << date.year << '-'; 59 s = out.width (2); c = out.fill ('0') ; out << date.month << '-'; 60 s = out.width (2); c = out.fill ('0') ; out << date.day << ' '; 61 s = out.width (2); c = out.fill ('0') ; out << date.hour << ':'; 62 s = out.width (2); c = out.fill ('0') ; out << date.minute << ':'; 63 s = out.width (2); c = out.fill ('0') ; out << date.second ; 64 64 65 return (out); 65 66 } … … 67 68 StdIStream & operator>>(StdIStream & in, CDate & date) // Non testée. 68 69 { 69 char c = '/'; // Le caractÚre c est utilisé pour "recueillir" les séparateurs "/" et ":". 70 in >> date.day >> c >> date.month >> c >> date.year >> c; 71 in >> date.hour >> c >> date.minute >> c >> date.second; 72 if(!date.checkDate()) 73 { 74 DEBUG("La date initialisée (depuis une chaîne de caractÚres) " 75 << "a été modifiée car elle était incorrecte " 76 << "par rapport au calendrier souhaité."); 77 } 78 return (in); 70 char sep = '-'; // Le caractÚre c est utilisé pour "recueillir" les séparateurs "/" et ":". 71 char c ; 72 73 in >> date.year >> c ; 74 if (c==sep) 75 { 76 in >> date.month >> c ; 77 if (c==sep) 78 { 79 in >> date.day ; 80 c=in.get(); 81 sep=' ' ; 82 if (c==sep) 83 { 84 in >> date.hour >> c ; 85 sep=':' ; 86 if (c==sep) 87 { 88 in>>date.minute >> c; 89 if (c==sep) 90 { 91 in>>date.second ; 92 if(!date.checkDate()) 93 ERROR("StdIStream & operator >> (StdIStream & in, CDate & date)",<<"Bad date format or not conform to calendar" ); 94 return (in); 95 } 96 } 97 } 98 } 99 } 100 ERROR("StdIStream & operator >> (StdIStream & in, CDate & date)",<<"Bad date format or not conform to calendar" ); 101 return (in); 79 102 } 80 103 -
XIOS/trunk/src/output/nc4_data_output.cpp
r314 r316 563 563 SuperClassWriter::addVariable(axisid, NC_DOUBLE, dims); 564 564 date::CDate initDate=cal->getInitDate() ; 565 StdOStringStream oss2; 566 oss2<<initDate.getYear()<<"-"<<initDate.getMonth()<<"-"<<initDate.getDay()<<" " 567 <<initDate.getHour()<<"-"<<initDate.getMinute()<<"-"<<initDate.getSecond() ; 568 StdString strInitdate=oss2.str() ; 565 // StdOStringStream oss2; 566 // oss2<<initDate.getYear()<<"-"<<initDate.getMonth()<<"-"<<initDate.getDay()<<" " 567 // <<initDate.getHour()<<"-"<<initDate.getMinute()<<"-"<<initDate.getSecond() ; 568 // StdString strInitdate=oss2.str() ; 569 StdString strInitdate=initDate.toString() ; 569 570 this->writeTimeAxisAttributes 570 571 (axisid, cal->getType(), -
XIOS/trunk/src/test/test.cpp
r300 r316 3 3 #include <string> 4 4 5 #include <boost/date_time/gregorian/gregorian.hpp> 6 #include <boost/date_time/posix_time/posix_time.hpp> 7 5 8 using namespace std ; 6 7 8 class CLog : public ostream 9 { 10 public : 11 CLog() : ostream(NULL),level(0) {} 12 CLog& operator()(int l) {if (l<=level) rdbuf(cout.rdbuf()) ; else rdbuf(NULL) ; return *this;} 13 void setLevel(int l) {level=l; } 14 int level ; 15 // ostringstream& getStream() { return *(ostringstream*)(this) ; } 16 // ~CLog(void) { cout<<"info message "<< this->str();} 17 }; 18 9 using namespace boost::posix_time ; 10 using namespace boost::gregorian ; 19 11 20 12 int main(void) 21 13 { 22 CLog out ; 23 cout<<string("toto")<<endl ; 24 out<<"123"<<endl ; 25 out.setLevel(5) ; 26 out(7)<<"coucou 1"<<endl ; 27 out(3)<<"coucou 2"<<endl<<"i23"<<endl ; 28 14 ptime t(time_from_string("2012-02-30 15:24")) ; 15 16 17 std::cout << to_simple_string(t) << std::endl; 18 19 return 1 ; 29 20 } -
XIOS/trunk/src/test/test_cs.f90
r313 r316 77 77 CALL xios_set_context_attr("test",calendar_type="Gregorian") 78 78 CALL xios_set_context_attr("test",calendar_type="Gregorian") 79 CALL xios_set_context_attr("test",start_date="01/01/2000 - 00:00:00")79 ! CALL xios_set_context_attr("test",start_date="01/01/2000 - 00:00:00") 80 80 CALL xios_set_context_attr("test",calendar_type="Gregorian") 81 81 CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj)
Note: See TracChangeset
for help on using the changeset viewer.