📄 demo_date.cpp
字号:
/* Copyright is licensed under GNU LGPL. by I.J.Wang 2003 Build: make demo_date*/#include "../src/wydate.h"#include "../src/wy_uty.h"// Get the time zone string (once)//static const WyStr& tz_string(void){static const WyStr tzstr(Wy::local_tzname()); return tzstr;}static WyRet f(void)try { WyRet r; // present date in the time zone tz_string WyDate tm(tz_string(),Wy::now()); // print tm Wy::cout << "It is now " << Wy::wrd(tm) << '\n'; Wy::cout << "23 hours latter: " << Wy::wrd(tm+WyTimeSpec(23L*60*60,Wy_Nano())) << '\n'; // set tm to made date and write to standard output if((r=tm.set_date(2003,9,9,0,0,0))!=Ok) { WY_RETURN(r); } Wy::cout << "Made time: 2003-9-9. Read back= " << Wy::wrd(tm) << '\n'; return(Ok);}catch(const WyDate::Reply& e) { WY_RETURN(e);}catch(...) { WY_THROW( WyRet() );};int main(void)try { WyRet r=f(); if(r!=Ok) { WY_THROW(r); } // Print the result r // Wy::cout << Wy::wrd(r) << '\n'; return(0);}catch(const WyRet& e) { if(e!=Ok) { Wy::cerr << Wy::wrd(e) << '\n'; } return e->c_repcode();}catch(...) { Wy::cout << "main caught(...)\n"; return(-1);};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -