Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computing > NZ Computing > Seconds From Now Till Then

Reply
Thread Tools

Seconds From Now Till Then

 
 
Lawrence D'Oliveiro
Guest
Posts: n/a
 
      04-01-2010
The following Bash function returns the number of seconds from now until the
specified time:

till() { echo $(($(date -d "$1" +%s) - $(date +%s))); }

For example, how long is it until 6 o’clock:

ldo@theon:~> till 06:00
20932

What’s the value of this? You can delay until a particular time before
performing an action, e.g.

sleep $(till 07:30); echo 'Wakey! Wakey!'


 
Reply With Quote
 
 
 
 
Enkidu
Guest
Posts: n/a
 
      04-01-2010
Lawrence D'Oliveiro wrote:
> The following Bash function returns the number of seconds from now until the
> specified time:
>
> till() { echo $(($(date -d "$1" +%s) - $(date +%s))); }
>
> For example, how long is it until 6 o’clock:
>
> ldo@theon:~> till 06:00
> 20932
>
> What’s the value of this? You can delay until a particular time before
> performing an action, e.g.
>
> sleep $(till 07:30); echo 'Wakey! Wakey!'
>

Why not just use 'at'? Otherwise you have your bash script hanging
around until 7:30, doing nothing.

Cheers,

Cliff

--

The ends justifies the means - Niccolò di Bernardo dei Machiavelli.

The end excuses any evil - Sophocles
 
Reply With Quote
 
 
 
 
AD.
Guest
Posts: n/a
 
      04-01-2010
On Apr 2, 12:15*am, Lawrence D'Oliveiro <l...@geek-
central.gen.new_zealand> wrote:
> The following Bash function returns the number of seconds from now until the
> specified time:
>
> * * till() { echo $(($(date -d "$1" +%s) - $(date +%s))); }
>
> For example, how long is it until 6 o’clock:
>
> * * ldo@theon:~> till 06:00
> * * 20932
>
> What’s the value of this? You can delay until a particular time before
> performing an action, e.g.
>
> * * sleep $(till 07:30); echo 'Wakey! Wakey!'


better:

! sleep $(till hammersmith)

or if you prefer a different genre:

! sleep $(till brooklyn)

--
Cheers
Anton
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert Seconds to X Hours Y Minutes Z Seconds? 00_CP_D12 ASP .Net 3 02-22-2008 10:37 AM
Help. SessionID is x then y then x then y BodiKlamph@gmail.com ASP General 0 09-03-2005 03:02 PM
1. Ruby result: 101 seconds , 2. Java result:9.8 seconds, 3. Perl result:62 seconds Michael Tan Ruby 32 07-21-2005 03:23 PM
Convert seconds to minutes and seconds tshad ASP .Net 7 03-11-2005 11:27 PM
Converting seconds to (Days, Hours, Minutes, seconds) Stu C Programming 7 03-07-2005 08:44 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57