Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
YesToDafT
//g++ 7.4.0 ////////////////////////////////////////////////////////////////////////////////YesToDafT: understanding std::chrono library,demonstration of conversion from std::chrono::time_point to std::time_t, use of localtime(&t) and ctime(&t),use of std::ratio etc //this code is created by Rezaul Hoque on June 02,2022; //contact:jewelmrh@yahoo.com;Dhaka,Bangladesh;https://rezaulhoque.wordpress.com,https://hoquestake.blogspot.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; ////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <iomanip> #include <chrono> #include <ctime> #include <ratio> int main() { using namespace std::literals; std::chrono:: duration<int,std::ratio<60*60*24>> Two (2); std::chrono:: duration<int,std::ratio<60*60*24>> One (1); std::chrono::system_clock::time_point curDay=std::chrono:: system_clock::now(); std::chrono::system_clock::time_point DafTom=curDay+Two; std::chrono::system_clock::time_point Tom=curDay+One; std::time_t t; t=std::chrono::system_clock::to_time_t(curDay); std::cout<<"Today is "<<ctime(&t)<<" \n"; std::cout<<"Another way to say today is "<<std::put_time(std::localtime(&t),"%F %T\n"); t=std::chrono::system_clock::to_time_t(curDay -24h); std::cout<<"\nYesterday was "<<ctime(&t)<<" \n"; std::cout<<"Another way to say yesterday was "<<std::put_time(std::localtime(&t),"%F %T\n"); t=std::chrono::system_clock::to_time_t(curDay -48h); std::cout<<"\nDay before yesterday was "<<ctime(&t)<<" \n"; std::cout<<"Another way to say day before yesterday was "<<std::put_time(std::localtime(&t),"%F %T\n"); t=std::chrono::system_clock::to_time_t(Tom); std::cout<<"\nTomorrow will be "<<ctime(&t)<<" \n"; std::cout<<"Another way to say tomorrow will be "<<std::put_time(std::localtime(&t),"%F %T\n"); t=std::chrono::system_clock::to_time_t(DafTom); std::cout<<"\nDay after tomorrow will be "<<ctime(&t)<<" \n"; std::cout<<"Another way to say day after tomorrow will be "<<std::put_time(std::localtime(&t),"%F %T\n"); return 0; }
run
|
edit
|
history
|
help
0
Base File.cpp
sort
DailyGroceryHisto
Boggle Game
hack qus
single_digit
adjacent_difference-30-Seconds-Of-CPP
project
completed
synowie abrahama