Re: date +%s ignores TZ

2008-03-01 Thread Philip Rowlands
On Fri, 29 Feb 2008, Bob Proulx wrote: Jan Engelhardt wrote: I wanted to get the number of seconds since the start of the day. echo $[`date +%s` % 86400]; unfortunately does not do the right thing ÿÿ it would show 82800 instead of 0 when it is (local) midnight. I can't think of

Re: date +%s ignores TZ

2008-03-01 Thread Andreas Schwab
Philip Rowlands [EMAIL PROTECTED] writes: I might be misunderstanding the problem, but it seems easy enough to do this calling date only once: $ date +%T | awk -F: '{ print $1 * 3600 + $2 * 60 + $3 }' 67652 This will fail during the day after a DST transition. Andreas. -- Andreas Schwab,

Re: date +%s ignores TZ

2008-03-01 Thread Bob Proulx
Andreas Schwab wrote: This will fail during the day after a DST transition. Which points out a terrible bug in my suggestion of how to map the range of 0-(N-1) to the range of 1-N! Bob wrote this buggy code: case $secondssincedaystart in (0) secondssincedaystart=86400 ;; esac That will

Re: date +%s ignores TZ

2008-03-01 Thread Jan Engelhardt
On Feb 29 2008 15:26, Bob Proulx wrote: echo $[`date +%s` % 86400]; Note that the $[expression] syntax is deprecated and is scheduled for removal from a future version of the shell. Please convert to using the now standard $((expression)) syntax. echo $(( $(date +%s) % 86400 ));

Re: date +%s ignores TZ

2008-03-01 Thread Bob Proulx
Jan Engelhardt wrote: $(()) is easily confusable with $(), I therefore ask $[] to be not removed, more like the reverse actually. I am not able to influence the decision. I am just reporting how it is documented. Bob ___ Bug-coreutils mailing list

date +%s ignores TZ

2008-02-29 Thread Jan Engelhardt
Hi, this is probably all correct behavior as it is right now (coreutils 6.9): $ date +%s 120433 $ TZ=GMT date +%s 120433 $ TZ=PDT date +%s 120433 but is there actually a way to do $ TZ=anything date +%s -d `date '+%Y-%m-%d

Re: date +%s ignores TZ

2008-02-29 Thread Bob Proulx
Jan Engelhardt wrote: $ date +%s 120433 %s seconds since 1970-01-01 00:00:00 UTC $ TZ=GMT date +%s 120433 $ TZ=PDT date +%s 120433 Right. I assume you were *very fast* typing in that data and that seconds did not move on while you were

Re: date +%s ignores TZ

2008-02-29 Thread Jan Engelhardt
On Feb 29 2008 14:20, Bob Proulx wrote: Right. I assume you were *very fast* typing in that data and that seconds did not move on while you were doing it. :-) I get the point though. That value is a timezone independent value. but is there actually a way to do $ TZ=anything date +%s

Re: date +%s ignores TZ

2008-02-29 Thread Andreas Schwab
Jan Engelhardt [EMAIL PROTECTED] writes: this is probably all correct behavior as it is right now (coreutils 6.9): $ date +%s 120433 $ TZ=GMT date +%s 120433 $ TZ=PDT date +%s 120433 %s is defined as seconds since 1970-01-01 00:00:00 UTC

Re: date +%s ignores TZ

2008-02-29 Thread Brian Dessent
Jan Engelhardt wrote: I wanted to get the number of seconds since the start of the day. echo $[`date +%s` % 86400]; How about: echo $[$(date +%s) - $(date -d '' +%s)] Brian ___ Bug-coreutils mailing list Bug-coreutils@gnu.org

Re: date +%s ignores TZ

2008-02-29 Thread Bob Proulx
Jan Engelhardt wrote: There is (my default zone is /etc/localtime - /usr/share/zoneinfo/Europe/Berlin): $ TZ=GMT date +%s -d `date '+%Y-%m-%d %H:%M:%S'` 1204325194 $ date +%s 1204321595 (now with not-so-fast typing! :) :-) I wanted to get the number of

Re: date +%s ignores TZ

2008-02-29 Thread Bob Proulx
Brian Dessent wrote: Jan Engelhardt wrote: I wanted to get the number of seconds since the start of the day. echo $[`date +%s` % 86400]; How about: echo $[$(date +%s) - $(date -d '' +%s)] That works most of the time and if I were never to run this at midnight I would do just