Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

yesterday's date

572 views
Skip to first unread message

Dave Malhotra

unread,
Aug 2, 2002, 12:14:49 PM8/2/02
to
How do I calculate yesterday's date in TCL? Need to take into account
if the day is 01! someone please give me the code if you have it.

-dave

Daniel Fackrell

unread,
Aug 2, 2002, 12:23:27 PM8/2/02
to
"Dave Malhotra" <dave_m...@yahoo.com> wrote in message
news:33fd9aa.02080...@posting.google.com...

> How do I calculate yesterday's date in TCL? Need to take into account
> if the day is 01! someone please give me the code if you have it.
>
> -dave

Does this do what you want?

proc yesterday {} {
set day [expr 24 * 60 * 60] # seconds in one day
set now [clock seconds]
return [expr $now - $day]
}

puts [clock format [yesterday] -format "%Y.%m.%d"]

--
Daniel Fackrell (unle...@learn2think.org)
When we attempt the impossible, we can experience true growth.


Ken Jones

unread,
Aug 2, 2002, 12:28:59 PM8/2/02
to
"Daniel Fackrell" <unle...@DELETETHIS.learn2think.org> wrote in message
news:3d4ab200$1...@hpb10302.boi.hp.com...

> "Dave Malhotra" <dave_m...@yahoo.com> wrote in message
> news:33fd9aa.02080...@posting.google.com...
> > How do I calculate yesterday's date in TCL? Need to take into account
> > if the day is 01! someone please give me the code if you have it.
>
> Does this do what you want?
>
> proc yesterday {} {
> set day [expr 24 * 60 * 60] # seconds in one day
> set now [clock seconds]
> return [expr $now - $day]
> }
>
> puts [clock format [yesterday] -format "%Y.%m.%d"]

Actually, you can probably get by just with:

clock format [clock scan "yesterday"]

Along with whatever [clock format ... -format] option you want.

- Ken Jones, President
Avia Training and Consulting
www.avia-training.com
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax


Joe English

unread,
Aug 2, 2002, 6:08:11 PM8/2/02
to
Daniel Fackrell wrote:

>"Dave Malhotra" wrote:
>> How do I calculate yesterday's date in TCL? Need to take into account
>> if the day is 01! someone please give me the code if you have it.
>
>Does this do what you want?
>
>proc yesterday {} {
> set day [expr 24 * 60 * 60] # seconds in one day
> set now [clock seconds]
> return [expr $now - $day]
>}


Beware! This will do strange things on the days that
daylight savings time begins and ends.

--Joe English, who has been bitten by this before...

jeng...@flightlab.com

Mike Hoegeman

unread,
Aug 3, 2002, 11:49:26 AM8/3/02
to
Joe English wrote:
>
> Daniel Fackrell wrote:
> >"Dave Malhotra" wrote:
> >> How do I calculate yesterday's date in TCL? Need to take into account
> >> if the day is 01! someone please give me the code if you have it.

isn't

set yesterday [clock scan "1 day ago"]

better ??

> >
> >Does this do what you want?
> >
> >proc yesterday {} {
> > set day [expr 24 * 60 * 60] # seconds in one day
> > set now [clock seconds]
> > return [expr $now - $day]
> >}
>
> Beware! This will do strange things on the days that
> daylight savings time begins and ends.
>
> --Joe English, who has been bitten by this before...
>
> jeng...@flightlab.com

--
Mike Hoegeman Habanero Technologies, LLC
http://habanerotech.net/personal-pages/mh/contact.html

Daniel Fackrell

unread,
Aug 5, 2002, 10:05:31 AM8/5/02
to
"Joe English" <jeng...@flightlab.com> wrote in message
news:aievs...@enews2.newsguy.com...


Noted. I'll add this to my growing plethora of reasons to hate Daylight
Savings.

0 new messages