Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Java
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
.gitignore
.travis.yml
README.md
build.gradle
sample1.csv

README.md

Datediff

Build Status

This is a coding exercise I once did. It's a tool to calculate the difference between two dates in the Gregorian calendar. And it's capable of handling leap years.

Yes you can use some excellent libraries such as joda time to achieve the same, but this coding exercise asked me not to use them. It was an interesting experience reading up on the Gregorian calendar (thanks Wikipedia!), and really understanding leap years. Thankfully I've forgotten all the details now!

Here's how you run it, and some sample output: (You'll need gradle)

$ gradle installApp

$ ./build/install/datediff/bin/datediff  < sample1.csv
01 01 2011, 02 01 2011, 1
13 11 2011, 11 11 2011, 2
13 11 2011, 12 11 2011, 1
13 11 2011, 13 11 2011, 0
13 11 2011, 14 11 2011, 1
13 11 2011, 15 11 2011, 2
01 01 2000, 01 01 2010, 3652

My other coding exercises

Something went wrong with that request. Please try again.