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

A tricky scripting problem. Any takers?

1 view
Skip to first unread message

Matthew Tovey

unread,
Aug 29, 1997, 3:00:00 AM8/29/97
to

How would you do this in a script (Bourne shell or similar)?

I need to get _yesterday's_ date (to analyse yesterday's logs). If today
is the 29th of August, then I need to get the string "28/08/97". If
today is the 1st of September I need to get the string "31/08/97".

The best solution I've found so far is to create and compile a one-line
C program to display yesterday's date, then delete the files, but this
is not really, umm..., nice.

Restrictions:
- cannot assume machine runs accounting.
- cannot assume that syslog file has not been rolled or that
it has entries on any given day.
- cannot assume that any file exists with a mod/create/access
date of yesterday.
- should be portable.

A big ugly case statement would work.
Consulting 'cal' on the first of each month would work, but still not
_really_ nice!

Any other ideas?

Matt
--
Matt Tovey http://wwwcn.cern.ch/~mtovey

Hello Cthulhu: world chaos through cuteness.

Dan Eble

unread,
Aug 29, 1997, 3:00:00 AM8/29/97
to Matthew Tovey

Matthew Tovey wrote:
>
> How would you do this in a script (Bourne shell or similar)?
>
> I need to get _yesterday's_ date (to analyse yesterday's logs). If today
> is the 29th of August, then I need to get the string "28/08/97". If
> today is the 1st of September I need to get the string "31/08/97".
>

Here's an excerpt from the GNU "date" man page:

EXAMPLES
To print the date of the day before yesterday

date --date ´2 days ago´

--------
Dan Eble (mailto:eb...@cis.ohio-state.edu)
(http://www.cis.ohio-state.edu/~eble)

Andrew Gierth

unread,
Aug 29, 1997, 3:00:00 AM8/29/97
to

>>>>> "Matthew" == Matthew Tovey <mto...@mail.cern.ch> writes:

Matthew> How would you do this in a script (Bourne shell or similar)?
Matthew> I need to get _yesterday's_ date (to analyse yesterday's
Matthew> logs). If today is the 29th of August, then I need to get
Matthew> the string "28/08/97". If today is the 1st of September I
Matthew> need to get the string "31/08/97".

Easy peasy. This needs a Posix shell, but you could hack the $((...))
evals to use `expr...` if you really want. Not Y2K compliant :-)

#!/bin/sh

set -- $(date +'%d %m %y')
case "$1$2" in
0101*) set -- 31 12 $(($3-1));;
01*) set -- 00 $(($2-1)) $3
case "$2" in
2) set -- $((28+($3%4==0))) 02 $3;;
[13578]) set -- 31 0$2 $3;;
[469]) set -- 30 0$2 $3;;
10) set -- 31 10 $3;;
11) set -- 30 11 $3;;
esac;;
0*|10*) set -- 0$(($1-1)) $2 $3;;
*) set -- $(($1-1)) $2 $3;;
esac
yesterday="$1/$2/$3"

--
Andrew.

Patrice Allais

unread,
Aug 29, 1997, 3:00:00 AM8/29/97
to

Matthew Tovey <mto...@mail.cern.ch> wrote in CyberSpace:

>How would you do this in a script (Bourne shell or similar)?

>I need to get _yesterday's_ date (to analyse yesterday's logs). If today
>is the 29th of August, then I need to get the string "28/08/97". If
>today is the 1st of September I need to get the string "31/08/97".

What about modifying the TZ variable to have it set with a 24 hours delay?

Example for France:

#!/bin/ksh
TZ=NFT+23DFT date

Hope this helps,
Patrice.

----------------------------------------------------------------------
| Patrice ALLAIS | E-mail : patrice...@octel.com |
| #include <disclaimer.h> | V-mail : (+33) [0]4 92 29 39 49 + 3902 |
----------------------------------------------------------------------


Matthew Tovey

unread,
Sep 1, 1997, 3:00:00 AM9/1/97
to

> I need to get _yesterday's_ date (to analyse yesterday's logs).
> If today is the 29th of August, then I need to get the string
> "28/08/97". If today is the 1st of September I need to get the
> string "31/08/97".

Thanks to everyone for your responses.
And I'd particularly like to thanks all those people who decided that
I'd also like to buy things or make money fast. No, I don't.

Anyway, I had lots of replys, mostly one of two methods:

- install and use GNU date.
- use PERL.

(I don't want to use PERL since this will be done within a TCL script,
so it'd seem rude to use PERL)

The clear winner, though, is the Bourne-type-shell line:

TZ=NFT+23DFT date

(It's so simple, it hurts!)

Cheers all,

Change is inevitable, except from a vending machine.

Andrew Gierth

unread,
Sep 1, 1997, 3:00:00 AM9/1/97
to

>>>>> "Matthew" == Matthew Tovey <mto...@mail.cern.ch> writes:

Matthew> The clear winner, though, is the Bourne-type-shell line:

Matthew> TZ=NFT+23DFT date

Matthew> (It's so simple, it hurts!)

It's also not guaranteed to work :-)

(+23 is not a valid timezone, and some systems just ignore impossible
settings for TZ.)

--
Andrew.

Dale Henderson

unread,
Sep 1, 1997, 3:00:00 AM9/1/97
to

>>>>> "Matthew" == Matthew Tovey <mto...@mail.cern.ch> writes:

Matthew> How would you do this in a script (Bourne shell or
Matthew> similar)? I need to get _yesterday's_ date (to analyse
Matthew> yesterday's logs). If today is the 29th of August, then I
Matthew> need to get the string "28/08/97". If today is the 1st of
Matthew> September I need to get the string "31/08/97".

[snip]

Matthew> Any other ideas?

If you have the GNU version of date you might try
date -d yesterday "+%d/%m/%y"

Hope this helps.


--
Dale Henderson <mailto:nil...@faeryland.tamu-commerce.edu>

"Imaginary universes are so much more beautiful than this stupidly-
constructed 'real' one..." -- G. H. Hardy

Roger Books

unread,
Sep 2, 1997, 3:00:00 AM9/2/97
to

Matthew Tovey (mto...@mail.cern.ch) wrote:
: How would you do this in a script (Bourne shell or similar)?

: I need to get _yesterday's_ date (to analyse yesterday's logs). If today
: is the 29th of August, then I need to get the string "28/08/97". If
: today is the 1st of September I need to get the string "31/08/97".

: The best solution I've found so far is to create and compile a one-line


: C program to display yesterday's date, then delete the files, but this
: is not really, umm..., nice.

Not nice? What about:

#include <stdio.h>
#include <time.h>

main() {
time_t clock;
int dom, month, year;
struct tm *ltime;

time( &clock );
clock -= ( 60 * 60 * 24 ); /* seconds in a day */
ltime = localtime( &clock );
dom = ltime->tm_mday;
month = (ltime->tm_mon) + 1;
year = (ltime->tm_year);

printf("%d/%d/%d\n", dom, month, year );
}

Roger
----------------------------------------------------------------------
The reply-to: address in the headers is a valid address, if you want
to send me e-mail just hit reply and it should work fine. If your
newsreader is broken and can't deal with that then send your e-mail
to: 970805022...@mail.state.fl.us
----------------------------------------------------------------------

Graham Broadbridge

unread,
Sep 5, 1997, 3:00:00 AM9/5/97
to

In comp.unix.admin Matthew Tovey <mto...@mail.cern.ch> wrote:
: How would you do this in a script (Bourne shell or similar)?

: I need to get _yesterday's_ date (to analyse yesterday's logs). If today
: is the 29th of August, then I need to get the string "28/08/97". If
: today is the 1st of September I need to get the string "31/08/97".

The easiest way is to set the TZ variable to your local timezone + or -
whatever offset is needed to take you back a day.

i.e. In Sydney Australia our offset is TZ=EST-10

so I set TZ=EST-14 (10 + 14 == 24 hours)

Then (in the same shell) execute the 'date' command. You'll end up with
the same time yesterday.

Grep, or whatever, the output to get the date. If you're using GNU date
you can just 'date +'%d%m%Y'

Example:

#!/bin/sh
TZ=EST+14; export TZ
date +'%d%m%Y'

peachy [/usr/spool/mail] # date
Sat Sep 6 02:29:08 EST 1997
peachy [/usr/spool/mail] # sh aa
05091997

Is that close enough???


Graham.

--
-------------------------------------------------------------------------------
Graham Broadbridge Home <gra...@peachy.apana.org.au>
Marsfield NSW Work <gra...@nsw.unilink.oz.au>
Australia AmprNet <vk2...@gw.vk2yui.ampr.org>
<vk2...@amsat.org>
-------------------------------------------------------------------------------

William R. Mattil

unread,
Sep 5, 1997, 3:00:00 AM9/5/97
to

Patrice Allais wrote:
>
> Matthew Tovey <mto...@mail.cern.ch> wrote in CyberSpace:
>
> >How would you do this in a script (Bourne shell or similar)?
> >I need to get _yesterday's_ date (to analyse yesterday's logs). If today
> >is the 29th of August, then I need to get the string "28/08/97". If
> >today is the 1st of September I need to get the string "31/08/97".
>
> What about modifying the TZ variable to have it set with a 24 hours delay?
>
> Example for France:
>
> #!/bin/ksh
> TZ=NFT+23DFT date
>
> Hope this helps,
> Patrice.
>
How about this?

#!/bin/ksh
mm=$(date +"%m")
dd=$(date +"%d")
yy=$(date +"%y")


let dd=dd-1
let mm=mm-1+1
let yy=yy-1+1

if ((dd == 0))
then
case $mm in
12) dd=30;;
11) dd=31;;
10) dd=30;;
9) dd=31;;
8) dd=31;;
7) dd=30;;
6) dd=31;;
5) dd=30;;
4) dd=31;;
3) dd=28
if ((yy%4==0))
then dd=29
fi;;
2) dd=31;;
1) dd=31;;
esac

let mm=mm-1
if ((mm==0))
then
mm=12
let yy=yy-1
fi
fi
if (($mm<10))
then mm="0$mm"
fi
if (($yy<10))
then yy="0$yy"
fi
if (($dd<10))
then dd="0$dd"
fi
print "$mm-$dd-$yy"

Not pretty but it works

Regards
Bill

--
William R. Mattil | Fred Astaire wasn't so great.
wrma...@ix.netcom.com | Ginger had to do it all backwards
(972) 256-3219 | and... in high heels.

J. Comstock

unread,
Sep 5, 1997, 3:00:00 AM9/5/97
to

In article <340694...@mail.cern.ch>,

Matthew Tovey <mto...@mail.cern.ch> wrote:
>How would you do this in a script (Bourne shell or similar)?
>
>I need to get _yesterday's_ date (to analyse yesterday's logs). If today
>is the 29th of August, then I need to get the string "28/08/97". If
>today is the 1st of September I need to get the string "31/08/97".

I wrote a C program to do this just about a month ago. This program
will generate as many days back as you want in any format you want:

gemini:/export/home/jrc> dateprint -h
usage: dateprint [-b {days back} -u -o {format}]

-o {format} is the format in strftime(3C) format.
-u Prints the UNIX time.
-b {days back} Print the time if {days back} in the past.
With no arguments, YYMMDD is the default format.
gemini:/export/home/jrc> dateprint -o "%C"
Fri Sep 5 23:19:29 CDT 1997
gemini:/export/home/jrc> dateprint -o "%C" -b 3
Tue Sep 2 23:19:38 CDT 1997
gemini:/export/home/jrc> dateprint -o "%m/%d.TEST_EXTENSION" -b 4
09/01.TEST_EXTENSION

-----CUT HERE---

static char *RCSID="@(#)$Id: dateprint.c,v 1.2 1997/09/03 21:41:13 jrc Exp $";
/******************************************************************************
* This program will print the date in the desired format. The default
* output is YYMMDD. A different output format will be displayed by passing an
* strftime(3C) format with the -o option. The difference between this program
* and the date(1) program is that it will display the date in the desired
* format for a previous day. This is done by passing the number of days
* back you want to display with the -b option. For example, if todays date
* is 970611 and you call 'dateprint -b 5', 970606 will be displayed.
******************************************************************************
* $Log: dateprint.c,v $
* Revision 1.2 1997/09/03 21:41:13 jrc
* Added printing of UNIX time, usage function.
*
* Revision 1.1 1997/07/18 15:22:09 jrc
* Initial revision
*
******************************************************************************/

#include <stdio.h>
#include <time.h>

extern char *optarg;
extern int optind;

usage() {
puts("usage: dateprint [-b {days back} -u -o {format}]\n");
puts("-o {format} is the format in strftime(3C) format.");
puts("-u Prints the UNIX time.");
puts("-b {days back} Print the time if {days back} in the past.");
puts("With no arguments, YYMMDD is the default format.");
}

main(int argc, char **argv) {
time_t ttNow;
time_t ttOld;
struct tm *tms;
int inC,
inUnix=0;
char szOutbuf[8192]; /* XXX */
char *szDefformat="%y%m%d";
char *szOfmt;

if ( (ttNow = time(&ttNow)) < 1L ) {
perror("time");
exit(1);
}

szOfmt = szDefformat;

while ((inC = getopt(argc, argv, "uo:b:?h")) != EOF) {

switch (inC) {

case 'h' :
case '?' :
usage();
exit(0);
break;

case 'o' :
szOfmt = optarg;
break;

case 'b' :
ttOld = ttNow - ( atol(optarg) * 60L * 60L * 24L );
ttNow = ttOld;
break;

case 'u' :
inUnix = 1;
break;
}
}

if ( (tms=localtime(&ttNow)) == (struct tm *)NULL ) {
perror("localtime");
exit(1);
}

if ( inUnix ) {
printf("%ld\n", ttNow);
}
else {
strftime( szOutbuf, 8192, szOfmt, tms);
printf("%s\n", szOutbuf);
}
exit(0);
}

-----CUT HERE-----

Steve van der Burg

unread,
Sep 8, 1997, 3:00:00 AM9/8/97
to

In article <3410C5EB...@ix.netcom.com>, "William R. Mattil" <wrma...@ix.netcom.com> wrote:
>> >How would you do this in a script (Bourne shell or similar)?
>> >I need to get _yesterday's_ date (to analyse yesterday's logs). If today
>> >is the 29th of August, then I need to get the string "28/08/97". If
>> >today is the 1st of September I need to get the string "31/08/97".

Do you want to start analyzing the logs shortly after midnight? My trick is
to call the script that starts the analysis from cron a minute _before_
midnight, grab the current date, sleep for a few minutes, and then use the
(now yesterday's) date where needed.

..Steve

Steve van der Burg
Technical Analyst, Information Services
London Health Sciences Centre
London, Ontario, Canada
Tel: +1 519 663-3300 x 5559 (work)
+1 519 472-6686 (home)
Email: steve.va...@lhsc.on.ca
WWW: http://www.lhsc.on.ca/~vanderbg/

Kirk Yarina

unread,
Sep 8, 1997, 3:00:00 AM9/8/97
to

Modify output format as needed:

/* return yesterday as Mmm dd */

#include <stdio.h>
#include <sys/types.h>
#include <time.h>

main()
{
time_t when;
char yesterday [8];
char *ctime_str;

when = time( (time_t *) 0) - 24*60*60 ;
ctime_str = ctime(&when);

strncpy(yesterday,ctime_str+4, 6);
yesterday[6] = '\0';

fputs(yesterday, stdout);
}

Steve van der Burg <steve.va...@lhsc.on.ca> wrote in article
<5v14ud$e...@falcon.ccs.uwo.ca>...

Dave Holland

unread,
Sep 8, 1997, 3:00:00 AM9/8/97
to

Steve van der Burg <steve.va...@lhsc.on.ca> wrote:
>Do you want to start analyzing the logs shortly after midnight? My trick is
>to call the script that starts the analysis from cron a minute _before_
>midnight, grab the current date, sleep for a few minutes, and then use the
>(now yesterday's) date where needed.

That works fine until your machine is under an unexpected heavy load
which delays the cron job's start until after midnight...

Dave

Nobody

unread,
Sep 8, 1997, 3:00:00 AM9/8/97
to mto...@mail.cern.ch

Matthew Tovey <mto...@mail.cern.ch> wrote in CyberSpace:

>How would you do this in a script (Bourne shell or similar)?


>I need to get _yesterday's_ date (to analyse yesterday's logs). If today
>is the 29th of August, then I need to get the string "28/08/97". If
>today is the 1st of September I need to get the string "31/08/97".

Well the EASY way is to use GNU's date (found in sh-utils).

I can just type: "date --date '2 days ago'"
and get the right date.

As an admin of a mixed environment, I've found that installing
some key gnu stuff is just a Good Thing to help maintain
sanity.


Other solutions that don't cause pain are to either do the
script in perl (get the localtime, subtract 24 hours, convert back
to a date format). Or just right a util in perl or C - subtracting
24 hours from $now. I should be about 15 perl lines with comments.

chuck

Jeffrey R. Drumm

unread,
Sep 9, 1997, 3:00:00 AM9/9/97
to

On 08 Sep 1997 18:17:10 -0500, Justin Banks
<jus...@springer.cray.com> wrote:

>#!/opt/local/bin/perl -w
>use Time::Local;
>$seconds_ina_day = 60*60*24;
>$current_time = time;
>$yesterday_time = $current_time - $seconds_ina_day;
>@yesterday = localtime($yesterday_time);
>$yesterday_date = "$yesterday[4]/$yesterday[3]/$yesterday[5]";
>print "$yesterday_date\n";
>
>And I'm sure it could be done in less.
>
>--
>Justin Banks \ If you spam me, I promise to go upstream from you until I
>Silicon Graphics \ find someone that cares. Then, I'll think about charging
>Eagan, Minnesota \ you for my time. Do it at your own risk

Umm, did you test this? localtime starts counting months at 0, so
$yesterday_date will be off by one month. Also, the code will provide
strangely formatted dates starting in the year 2000 (element 5 of
@yesterday is the number of years from 1900; 2000 will be 100).

So change:

$yesterday_date = "$yesterday[4]/$yesterday[3]/$yesterday[5]";

to

$yesterday_date = ($yesterday[4] + 1) . "/" . $yesterday[3] . "/" .
(1900 + $yesterday[5]);

Finally, I didn't see anywhere that you actually use methods from
Time::Local . . . time and localtime are builtins (or whatever they're
called in Perl). That, at least, saves you a line of code ;-)
--
Jeffrey R. Drumm, Systems Integration Specialist
Maine Medical Center - Medical Information Systems Group
420 Cumberland Ave, Portland, Maine 04101
Voice: 207-871-2150 Fax: 207-871-6501 Email: dru...@mail.mmc.org

Jeffrey R. Drumm

unread,
Sep 9, 1997, 3:00:00 AM9/9/97
to

On 09 Sep 1997 08:56:16 -0500, Justin Banks
<jus...@springer.cray.com> wrote:

>Test? Hey, this is Usenet!

Apologies for the somewhat humorless start to my reply, but I guess
I'd argue that if you don't have the time to test, don't bother to
take the time to post. There's a high enough noise level in these
news groups as it is. To your credit, most of your posts seem to be in
the "signal" (as opposed to "noise") category . . .

>Actually, given the target 'market', my testing
>consisted of :
>
>springer<justinb>28% /tmp/yesterday.pl
>8/7/97

Hmm. Looks like a human-readable date to me . . . though I think most
humans would interpret it as August 7. Most applications likely to
attempt to parse a date in this format are probably going to assume
that the month in question is August, too. That is, if they don't
come up with 0.01178203240059 instead.

>springer<justinb>29%
>
>At which point I considered that it was serviceable. I don't actually use
>it for anything, wrote it on the spur of the moment with no editing,
>and would (I think naturally) assume that anyone that chose to use it for
>anything would modify it for their own purposes.

Perhaps they would. But they _might_ just take that code and plop it
into whatever they're working on without doing a 'perldoc -f
localtime'. And wind up with unexpected results. Serves 'em right,
maybe . . . but I personally would err on the side of giving too much
information. It's by the graces of others who do this that I know what
little I do.

>It would obviously need to be modified to output the numbers according
> to your locale, but if I were to use it for anything, I would want the months to start at 0.

As would many individuals that need to do date math. However, your
example _appeared_ to print a date, ostensibly yesterday's date, in
m/d/y format. It didn't (well, at least in most commonly accepted
definitions of the term "yesterday's date" in the US). That's all I
was really trying to say . . . and offered an alternative that perhaps
made a little more sense, "given the target 'market'".

>
>Your point about the 2k thing, though, is taken.

Odd that you would think 0/1/98 is a valid date, yet 0/1/100 not. Of
course, neither of 'em make sense to me. Hmm . . . I must travel to
this land called Minnesota . . . things sound so different there <g> .
. .

>
>-justinb


>--
>Justin Banks \ If you spam me, I promise to go upstream from you until I
>Silicon Graphics \ find someone that cares. Then, I'll think about charging
>Eagan, Minnesota \ you for my time. Do it at your own risk

--

si...@msh.xs4all.nl

unread,
Sep 10, 1997, 3:00:00 AM9/10/97
to

[mostly deleted]

In article <34156292....@news.mmc.org>,


Jeffrey R. Drumm <dru...@mail.mmc.org> wrote:

>>Actually, given the target 'market', my testing
>>consisted of :
>>
>>springer<justinb>28% /tmp/yesterday.pl
>>8/7/97
>
>Hmm. Looks like a human-readable date to me . . . though I think most
>humans would interpret it as August 7. Most applications likely to
>attempt to parse a date in this format are probably going to assume
>that the month in question is August, too. That is, if they don't
>come up with 0.01178203240059 instead.

Most humans? Let's make that most americans (or somesuch), shall we?
I never really understood why anyone in his right mind would use
m/d/y instead of d/m/y. So to me, it looks like July 8...

CU, Sico.

robert

unread,
Sep 10, 1997, 3:00:00 AM9/10/97
to

Justin Banks <jus...@springer.cray.com>:

>#!/opt/local/bin/perl -w
>use Time::Local;
>$seconds_ina_day = 60*60*24;
>$current_time = time;
>$yesterday_time = $current_time - $seconds_ina_day;
>@yesterday = localtime($yesterday_time);
>$yesterday_date = "$yesterday[4]/$yesterday[3]/$yesterday[5]";
>print "$yesterday_date\n";
>And I'm sure it could be done in less.

Beware, the months ($yesterday[4]) range from 0 to 11 instead of your
assumption, 1 to 12. Therefore, you want this instead (and yes, it's
shorter too ;):
--
#!/usr/local/bin/perl5 -w
@y = localtime(time - 60*60*24);
print $y[4] + 1, "/$y[3]/$y[5]\n";
--

robert

Jeff Graham

unread,
Sep 10, 1997, 3:00:00 AM9/10/97
to

si...@msh.xs4all.nl wrote:

[massive snip]

> Most humans? Let's make that most americans (or somesuch), shall we?
> I never really understood why anyone in his right mind would use
> m/d/y instead of d/m/y. So to me, it looks like July 8...

isnt July 8 in m/d format? maybe thats why .. July 8, 1997 is in m/d/y
order... :)
maybe all americans arent insane.. oh wait yes they are... nevermind

dem

Geoffrey C Marshall

unread,
Sep 10, 1997, 3:00:00 AM9/10/97
to si...@msh.xs4all.nl

This is a multi-part message in MIME format.
--------------18B5978421FD3A7D4C105ED3
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

si...@msh.xs4all.nl wrote:

> [mostly deleted]


>
> Most humans? Let's make that most americans (or somesuch), shall we?
> I never really understood why anyone in his right mind would use
> m/d/y instead of d/m/y. So to me, it looks like July 8...
>

> CU, Sico.

While I should wholeheartedly agree with you, I can't.

If we had any brains we would *ALL* use y/m/d.....

Excusing any cultures that don't put the most significant digit first, of
course (I am unaware
that there are any).

--
Geoff...
_______________________________________________________________________
(a.k.a) ozemail.com.au
_______________________________________________________________________
SAGITTARIUS (Nov 22 - Dec 21)
You are optimistic and enthusiastic. You have a reckless
tendency to rely on luck since you lack talent. The majority
of Sagittarians are drunks or dope fiends or both. People
laugh at you a great deal.
_______________________________________________________________________
_


--------------18B5978421FD3A7D4C105ED3
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Geoffrey Marshall
Content-Disposition: attachment; filename="vcard.vcf"

begin: vcard
fn: Geoffrey Marshall
n: Marshall;Geoffrey
adr: 8, Fairy Dell Road;;;Tecoma;Victoria;3160;Australia
email;internet: co...@ozemail.com.au
tel;work: +613 9752 6503
tel;home: +613 9752 6503
x-mozilla-cpt: ;0
x-mozilla-html: FALSE
version: 2.1
end: vcard


--------------18B5978421FD3A7D4C105ED3--


si...@msh.xs4all.nl

unread,
Sep 12, 1997, 3:00:00 AM9/12/97
to

In article <5v6var$1nb$1...@nntp1.ba.best.com>,
Jeff Graham <de...@shell7.ba.best.com> wrote:

>si...@msh.xs4all.nl wrote:
>
>[massive snip]


>
>> Most humans? Let's make that most americans (or somesuch), shall we?
>> I never really understood why anyone in his right mind would use
>> m/d/y instead of d/m/y. So to me, it looks like July 8...
>

>isnt July 8 in m/d format? maybe thats why .. July 8, 1997 is in m/d/y
>order... :)
>maybe all americans arent insane.. oh wait yes they are... nevermind

8/7/97 is (to me) July 8, 1997, or 8 juli 1997 in dutch, or 8. Juli 1997
in german, or 8 juillet 1997 in french, or...

>dem

CU, Sico.

si...@msh.xs4all.nl

unread,
Sep 12, 1997, 3:00:00 AM9/12/97
to

In article <34167FF3...@ozemail.com.au>,
Geoffrey C Marshall <co...@ozemail.com.au> wrote:

>si...@msh.xs4all.nl wrote:
>
>> [mostly deleted]


>>
>> Most humans? Let's make that most americans (or somesuch), shall we?
>> I never really understood why anyone in his right mind would use
>> m/d/y instead of d/m/y. So to me, it looks like July 8...
>>

>> CU, Sico.
>
> While I should wholeheartedly agree with you, I can't.
>
>If we had any brains we would *ALL* use y/m/d.....

Don't the Japanese do that?

CU, Sico.

Jason D. Kelleher

unread,
Sep 12, 1997, 3:00:00 AM9/12/97
to
>Excusing any cultures that don't put the most significant digit first, of
>course (I am unaware
>that there are any).
>
>--
>Geoff...

It's even a standard (but I'm not sure who uses it besides me):

A Summary of the International Standard Date and Time Notation
http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html


--
Jason D. Kelleher Systems Administrator
kell...@susq.com Susquehanna Investment Group
kell...@eecis.udel.edu I work for 'em, don't speak for 'em.


Bill Vermillion

unread,
Sep 12, 1997, 3:00:00 AM9/12/97
to

In article <34167FF3...@ozemail.com.au>,
Geoffrey C Marshall <co...@ozemail.com.au> wrote:
>This is a multi-part message in MIME format.
>--------------18B5978421FD3A7D4C105ED3
>Content-Type: text/plain; charset=us-ascii
>Content-Transfer-Encoding: 7bit
>
>
>
>si...@msh.xs4all.nl wrote:
>
>> [mostly deleted]
>>
>> Most humans? Let's make that most americans (or somesuch), shall we?
>> I never really understood why anyone in his right mind would use
>> m/d/y instead of d/m/y. So to me, it looks like July 8...

> While I should wholeheartedly agree with you, I can't.

>If we had any brains we would *ALL* use y/m/d.....

>Excusing any cultures that don't put the most significant digit first, of
>course (I am unaware >that there are any).

Two of the most popular 'cultures' differ 100% in this
respect.

One is called Motorola, the other Intel (or iNTEL for those
who remember the old days)
--
Bill Vermillion - bill.ve...@oau.org | bi...@bilver.com

Bill Vermillion

unread,
Sep 12, 1997, 3:00:00 AM9/12/97
to

In article <5upcd3$16a$9...@peachy.apana.org.au>,
Graham Broadbridge <gra...@peachy.apana.org.au> wrote:

>In comp.unix.admin Matthew Tovey <mto...@mail.cern.ch> wrote:

>: How would you do this in a script (Bourne shell or similar)?

>: I need to get _yesterday's_ date (to analyse yesterday's logs). If today
>: is the 29th of August, then I need to get the string "28/08/97". If
>: today is the 1st of September I need to get the string "31/08/97".

>The easiest way is to set the TZ variable to your local timezone + or -

>whatever offset is needed to take you back a day.

>i.e. In Sydney Australia our offset is TZ=EST-10
>
>so I set TZ=EST-14 (10 + 14 == 24 hours)

>Then (in the same shell) execute the 'date' command. You'll end up with
>the same time yesterday.

If you need more flexibility you could call a program called
'ago' from the shell and use it's output.

It was on comp.sources.unix or comp.sources.misc along time
ago. The version on this system was compiled im May 1993.

This is what it looks like

-------------------
Script started on Fri Sep 12 10:41:51 1997
# ago -d567
Fri Feb 23 09:41:57 EST 1996
# ago -d1
Thu Sep 11 10:42:01 EDT 1997
# ago
Fri Sep 12 10:42:08 EDT 1997
# ago -
usage: ago [-s secs] [-m mins] [-h hrs] [-d days] [-w wks] [+fmt]
# ago -w3
Fri Aug 22 10:42:24 EDT 1997
# exit

script done on Fri Sep 12 10:42:28 1997
-------------------

Bill

John Sokol

unread,
Sep 16, 1997, 3:00:00 AM9/16/97
to

Why not just get a copy of the GNU date program then all that's required
is:-
date -d '1 day ago' +%d/%m/%y

This is very pretty and entailed somebody else doing all the work!
Regards
John

William R. Mattil <wrma...@ix.netcom.com> wrote in article
<3410C5EB...@ix.netcom.com>...


> Patrice Allais wrote:
> >
> > Matthew Tovey <mto...@mail.cern.ch> wrote in CyberSpace:
> >

0 new messages