Advertisement
Guest User

doConvertAgeToEpoch

a guest
Oct 21st, 2012
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.73 KB | None | 0 0
  1. function doConvertAgeToEpoch { # This function converts dates in YYYY-MM-DD_HHMMSS* format to seconds since epoch
  2.         local inputString=$1
  3. printf " inputString: $inputString"
  4.         local cutStringDate=$(echo $inputString | cut -c -10)
  5. printf " cutStringDate: $cutStringDate"
  6.         local cutStringTime=$(echo $inputString | cut -c 12-17 ) ## TODO: Why isn't this working?
  7. printf " cutStringTime: $cutStringTime"
  8.         local cutStringFormatted="${cutStringTime:0:2}:${cutStringTime:2:2}:${cutStringTime:4:2}" # Converts the HHMMSS string into a HH:MM:SS format, which date requires
  9.         local epochString=$(date +%s -d $cutStringFormatted)
  10. printf " epochString: $epochString"
  11. }
  12.  
  13. doConvertAgeToEpoch 2012-10-15_123456.tar
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement