September 9th, 2001

beachlands-200608

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())
                        s.setstate(std::ios_base::failbit);
        } catch (...) {
                try {
                        s.setstate(std::ios_base::badbit);
                } catch (...) {}
                if (s.exceptions() & std::ios_base::badbit)
                        throw;
        }
        return s;
}

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

Seeing red

Anyone who's reading my journal directly (i.e., not via someone else's friends page) will notice that I've picked a distinctly red/pink colour scheme. Of course red is my favourite colour, but I'm doing this as a political ‘gesture’ too.

A couple of days, heading back to the office after lunch, we spotted this red sports car with lots of flowers and bees painted over it. A workmate commented, ‘whoever drives that car must be so gay’.

Now, I know that they meant it in jest (because I have a friend who says that sort of thing all the time, even with full knowledge of my sexual preferences), but I can't help feeling that I have to poke my tongue out at that. So there. :-P

  • Current Mood
    amused amused