rustymyers / warranty

Bash script to check Apple Warranty for Mac* and iP* models
48 stars 16 forks source link

date conversion international (problem and solution) #10

Closed RobertJansson closed 10 years ago

RobertJansson commented 10 years ago

Excellent script! It's my first post here so I'm not familiar with code of conduct. The date function on line #418 is only compatible with the US language. The date string recieved from the webserver is US but if OS X is set to use another language the /bin/date command doesn't understand the ${WarrantyExpires} variable. "Illegal time format-error" if run locally or "awk: i/o error occurred while closing /dev/stdout" when run from ARD. It should also apply to line #420. Don't want to disturb my ubuntu machines so please verify.

RobertJansson commented 10 years ago

I suggest the following change: LC_ALL=C in front of /bin/date to set the date function to interpret it as US no matter what the locale is set to. Here is line #418 but you might also want to address line #420: WarrantyExpires=$(GetWarrantyExp| LC_ALL=C /bin/date -jf "%B %d, %Y" "${WarrantyExpires}" +"%Y-%m-%d") > /dev/null 2>&1 ## corrects Apple's change to "Month Day, Year" format for HW_END_DATE