Excellent....got everything I need now! Interesting to note that the EVM
development group at Compaq have noted the issue, and it is resolved in
version 5.1 (see below).
I wonder when GNU Date will replace standard date......(as gzip has replaced
compress).
Thanks to:
Jem Treadwell
Robert Mulley
Bevan Broun
Mark Scarborogh
Steve VanDevender
Matt White
Alan Rollow
A. Saravanan
Here are all the postings (in no particular order!) - original posting at
end.....
============================================================================
=
Hi, I'm the tech lead for EVM development at Compaq - thanks for posting
the question! This is definitely a problem for EVM in 5.0 - the good
news is that it's much simpler at 5.1, which is coming soon. You'll be
able to say:
evmget -f '[age < 8d] & [age > 7d]'
where d means days. You can also specify hours, minutes, seconds and
weeks. 0d and 1d mean any time since the previous midnight (i.e.
today!), 2d = yesterday, etc.
We added this because the 5.0 facilities, while complete, clearly *are*
cumbersome, and there is no simple way to calculate a backward time
using the date command. The s_back_date function, which I'm assuming is
the one you're pointing at in your reference, has a comment that says
there's no attempt to deal with crossing year boundaries, so to do it
right it would get even more complex. It's a shame that the date
command isn't capable of doing arithmetic.
I suspect the simplest thing is to produce a simple C program to do it.
I'll take a look at this first thing in the morning. In the meantime,
if you get any ideas from anyone can you forward them to me - this is
obviously an area I'm interested in!
============================================================================
=
http://www.injunea.demon.co.uk/pages/page212.htm
============================================================================
=
I can't comment on how hard it is in the context of your
practice, but "one week ago" is also 608,800 seconds ago.
Get the current integer time, subtract 608,800 and format
that time into the format desired. Back in the ULTRIX
uerf(8) days, I had a program that did this for "yesterday"
and put the date into the time format that uerf(8) used.
/*
* Author: Alan Rollow, EIS/CXO, Digital Equipment Corp.
* File: yesterday.c
* Date: 1/1/98
* Version: 1.2
*
* yesterday.c - Print yesterday's date in uerf date format.
*/
#ifndef lint
static char SccsId[] = "_at_(#)yesterday.c 1.2 (yesterday) 1/1/98" ;
#endif
#include <sys/types.h>
#include <time.h>
#include <stdio.h>
#define DAY (24*60*60)
main(int argc, char *argv[])
{
time_t time(), clock ;
char *part ;
struct tm *localtime(), *p ;
clock = time((time_t *)0) - DAY ;
p = localtime(&clock) ;
if( argc == 1 )
part = "00:00:00" ;
else
part = argv[1] ;
printf("%d-%3.3s-%d,%s\n", p->tm_mday,
&"JanFebMarAprMayJunJulAugSepOctNovDec"[p->tm_mon*3],
p->tm_year + 1900, part) ;
return 0 ;
}
============================================================================
=
How about:
---snip---
#!/usr/bin/perl
$now = time();
$lastweek = $now - (7 * 24 * 60 * 60);
($d,$m,$y) = (localtime($now))[3,4,5];
$y+=1900;
$m+=1;
$today = sprintf("%d:%02d:%02d:00:00:00",$y,$m,$d);
($d,$m,$y) = (localtime($lastweek))[3,4,5];
$y+=1900;
$m+=1;
$since = sprintf("%d:%02d:%02d:00:00:00",$y,$m,$d);
print "[since $since] & [before $today]\n";
---snip---
============================================================================
=
GNU date (part of the sh-utils package, available from ftp.gnu.org) has
the ability to specify alternate dates in the form:
date -d yesterday
or
date -d '7 days ago'
It can also print dates in a format of your choice, i.e.
date -d '7 days ago' '+[since %Y:%m:%M:00:00:00]'
date '+[before %Y:%m:%M:00:00:00]'
============================================================================
=
search for a utility called mktime. It impleaments the C time
functions as shell commands. It will do what you need. For example,
with out getting the formatting as you want the date 7 years ago:
bevanb_at_groucho>mktime -F '%B %d, %Y' -d -7
August 11, 2000
============================================================================
=
#!/usr/bin/perl
_at_dt = localtime( time - ( 86400 * $ARGV[0] ) );
printf( "%04d:%02d:%02d:%02d:%02d:%02d\n", ( $dt[5] + 1900 ), ( $dt[4] +
1 ), ( $dt[3] + 1 ), $dt[2], $dt[1], $dt[0] );
If you give this an argument like ./scriptname 7 it should give you what
you are after. Of course I just made this script up so it is likely not
to work, but you should be able to get it working.
============================================================================
=
Here's a quick question
I would like a report of 1 weeks emvget data [Tru64 v5.0]. For this, I need
to know the date 7 days ago, in the format
year:month-of-year:day-of-month:hours:minutes:seconds
[man EvmFilter]
While this is very easy for the date today - I cannot see an elegant
solution for 7 days ago......
The eventual command would be something like
evmget -f '[since 2000:07:30:00:00:00] & [before 2000:08:06:00:00:00]'
There is one solution at this web site
http://www.injunea.demon.co.uk/pages/page212.htm
but there's got to be a better, more simple way!
============================================================================
=
Received on Fri Aug 18 2000 - 13:25:29 NZST