Archives

Categories

Flexi hours calculator (online and for Excel)

I have tidied up and moved my ancient flexi hours calculator which now lives at http://www.aurochs.org/flexi/flexi.html. Several people have emailed me out of the blue recently about setting up an Excel version, which I have done and which now lives at http://www.aurochs.org/flexi/flexi.xlsx.

This is a version of one of the oldest useful programmes I ever wrote. My dad used to manage an office where everyone filled in paper flexi-time forms. My dad then had to add them all up at the end of every week, which he did manually. I wrote something in AmigaBasic to make it easier for him. The main point of it was that it had to be easy and quick to enter the times in, which is why it uses the simple four figure times and no drop downs (although I’m not sure how or if you can do drop down lists in AmigaBasic (nor do I intend to find out now)). Eventually my dad got the IT people at work to replace their version of a flexi calculator with something based instead on mine, which is silly considering how simple this was. Sometime after starting at my current employer (1997), I thought it would be a useful exercise to convert the programme to work on the web as I was learning Javascript at the time. It still exists and hasn’t changed a lot since then, barring a bit of explanation and some atrocious styling: the last time that file was touched was in 2003.

Although it is really hard to find (I can never remember where I left it and it seems impossible to Google), people do seem to come across it quite often and find it useful. I’ve been emailed a couple of times about getting bespoke versions done in Excel which led me to create a version initially to record multiple users, and another with additional days and more complicated working patterns. I’ve put a more standard version up with seven days and two sessions per day. It can easily be altered if you’re into Excel or, if you have something particular in mind, do let me know and I might be able to do something with it.

The original online version is written in Javascript. If you’re learning Javascript, please don’t look at it as it is a most outdated and inefficient way of adding Javascript to a webpage. However, it works, and the effort of making it all elegant would I think be counterproductive. It works on the idea that the first two digits of a four digit time (HHMM) are hours, the second two digits minutes. It converts these both to minutes (HH * 60 + MM) and does all the necessary maths. The slightly more tricky bit is converting a total of minutes back into hours and minutes. This is one rare (for me) real life use of the modulo (%) operation (although looking at the code source I seem to have invented my own weird convoluted version of the same thing). If you have x number of minutes, the number of hours will be x divided by 60 with any remainder taken off, i.e. Math.floor(x / 60); the number of minutes will be that remainder, i.e. x % 60. These can be put together into a pretty string.

I’m always interested to know if people find this useful, come across problems with it, or would find a slightly different version useful.

Comments are closed.