Fixed detection of GNU date so it works on Linux
Fixed use of date() function