Chris, the Young One (hedgee) wrote,
Chris, the Young One

  • Mood:

Celebrating the billennium

The time has come. Finally, today, time_t will reach one billion. And there will be celebration indeed, among Unix fans everywhere!

Here's a countdown program in C++ under Unix, just to be 1337. :-) Not tested yet, sadly, as I don't have a standard-conforming C++ implementation on my machine yet. (Compiling gcc 3.0.1 now, but I don't think it'll complete in time.)

#include <ctime>
#include <iostream>
#include <locale>
#include <unistd.h>

This bit is based on Appendix D of ``The C++ Programming Language'',
special edition, by Bjarne Stroustrup.
template<typename Ch, typename Tr>
std::basic_ostream<Ch, Tr>&
operator<<(std::basic_ostream<Ch, Tr>& s, std::tm const& t)
        std::basic_ostream<Ch, Tr>::sentry guard(s);
        if (!guard)
                return s;
        try {
                if (std::use_facet<std::time_put<char> >(s.getloc()).put(s,
                    s, s.fill(), &t, 'X').failed())
        } catch (...) {
                try {
                } catch (...) {}
                if (s.exceptions() & std::ios_base::badbit)
        return s;

main(int, char**)
        while (!sleep(1)) {
                std::time_t count = 1000000000 - std::time(0);
                std::cout << '\r' << *std::gmtime(&count) << std::flush;
        return 0;

  • Mystery meme

    Dear friends, If fate handed us different circumstances, I'd propose to you already…if, in those circumstances, you hadn't proposed first.…

  • Oldie but goodie

    Another meme from Special K! Reply to this post, and I'll tell you one reason why I like/love/adore you. Then put this in your own journal, and…

  • Quick question

    There are fairly decent type descriptions at Best-Fit Type, The Personality Page, TypeLogic, or the like, if you like an idea of what the…

  • Post a new comment


    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 1 comment