Entries by Kevin Godden

Simple Wrapper of boost::asio for receiving UDP datagrams

More easily receive UDP Data via boost::asio providing just IP address and port umber. The boost::asio classes provide a cross platform way to communicate via UDP without having to use the raw socket libraries, however they can be confusing and hard to use do to their designed-in flexibility. Sometimes I just want to provide an […]

mktime() always uses local time zone and converts from UTC

If you’re working with UTC times, you may be upset to find that mktime() always converts using your local time zone thus wrecking your UTC times.  Instead of mktime() use: Linux/Posix: timegm() Windows: _mkgmtime() For example, let’s use timegm() to make a UTC time which we will pass to SolarAzEl() to calculate the Solar Elevation […]

Creating time_t value from a UTC date and time in C

Programming with time is difficult and error prone, for this reason I usually try to keep things in UTC so that I don’t have to worry about time zones and daylight saving offsets etc. When in C++ I mostly use the boost::ptime library but I was surprised recently about tricky it seemed to be to […]