Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling next_drink results in an error #7

Closed
andrewladd opened this issue Feb 25, 2017 · 3 comments
Closed

Calling next_drink results in an error #7

andrewladd opened this issue Feb 25, 2017 · 3 comments

Comments

@andrewladd
Copy link
Contributor

When calling next_drink, I'm greeted by an error related to the usage of the date function:

$ next_drink
usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
Next drink at

My solution was changing thirsty.sh's call to the date function like so:

next_drink() {
   next_time=$(($(cat $DRINK_WATER_CONF) + $WATER_TIME))
-  echo "Next drink at $(date --date="@$next_time")"
+  echo "Next drink at $(date -r $next_time)"
 }

Calling next_drink now works:

$ next_drink
Next drink at Sat 25 Feb 2017 18:44:29 EST

Fun script 👍 :)

@kalbhor
Copy link
Owner

kalbhor commented Feb 25, 2017

Makes sense, could you send a pull request?

@lfkeitel
Copy link
Contributor

lfkeitel commented Mar 3, 2017

If you would rather me put in a new issue I can.

What version of date are you using and what OS? On my Ubuntu 16.04 machine the -r flag displays the modification time of a file and errors when using the latest commit with this change. If it's an issue with the version of date or the OS there should be some check to determine the correct usage. Here's what date --version outputs for me:

date (GNU coreutils) 8.25
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.

@andrewladd
Copy link
Contributor Author

@lfkeitel I'm running MacOS, which likely explains the difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants