[SGVLUG] timediff - my 1st ever C program that I have GPLd

John E. Kreznar jek at ininx.com
Wed Jan 5 02:58:15 PST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

#!/bin/sh

# NAME
#   datediff

# SYNOPSIS
#   datediff date2 date1

# DESCRIPTION
#   Prints to stdout the time difference between the two given dates.
#   The dates should be in double quotes and may be in any of the
#   formats recognized by date(1).  See info date input formats.

# EXAMPLES
# $ datediff "jan 6" "jan 5"
# 86400
# $ datediff "march 1" "2/28 23:59"
# 60
# $ datediff "mar 1 2008" "feb 28 2008"
# 172800
  
# One short line of code:

echo $(date +%s --date="$1") $(date +%s --date="$2") - p | dc

- -- 
 John E. Kreznar jek at ininx.com 9F1148454619A5F08550 705961A47CC541AFEF13

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8+ <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAk0kTrAACgkQYaR8xUGv7xPIawCfb8Nu08U0x1OZEOAhl2boSoq5
3YUAn35K576Bzg00z7LYcducr9zWVndh
=Ynkw
-----END PGP SIGNATURE-----



More information about the SGVLUG mailing list