How to get current time and date in C++?

Is there a cross-platform way to get the current date and time in C++? 26 s 26 In C++ 11 you can use std::chrono::system_clock::now() Example (copied from en.cppreference.com): #include <iostream> #include <chrono> #include <ctime> int main() { auto start = std::chrono::system_clock::now(); // Some computation here auto end = std::chrono::system_clock::now(); std::chrono::duration<double> elapsed_seconds = end-start; std::time_t end_time … Read more

What’s the strategy for handling CRLF (carriage return, line feed) with Git?

I tried committing files with CRLF-ending lines, but it failed. I spent a whole work day on my Windows computer trying different strategies and was almost drawn to stop trying to use Git and instead try Mercurial. How to properly handle CRLF line endings? 9 s 9 Almost four years after asking this question, I … Read more

Python: What OS am I running on?

What do I need to look at to see whether I’m on Windows or Unix, etc? 26 s 26 >>> import os >>> os.name ‘posix’ >>> import platform >>> platform.system() ‘Linux’ >>> platform.release() ‘2.6.22-15-generic’ The output of platform.system() is as follows: Linux: Linux Mac: Darwin Windows: Windows See: platform — Access to underlying platform’s identifying … Read more