reverse asctime()? EEEK!

Marshall Cline cline at sun.soe.clarkson.edu
Thu Jun 8 04:35:18 AEST 1989


In article <5178 at b11.ingr.com> abashian at b11.ingr.com (Pete Abashian) writes:

>.......  I need to be able to take an ascii string and 
>convert it back to the internal storage - number of seconds since epoch.
>The task would normally entail some simple mathematics to incorporate leap
>[gag] years, etc...  But what about the sticky user(s) that want to be
>able to input virtually any valid combination of dates/times?  12MAY89,
>12-MAY-89, May 12, 1989....etc.  For the life of me I cannot remember EVER  
>seeing an include file or archive with a reference to such a routine.

Don't the "at" and "calendar" utilities do something like that?

The "at" syntax for a date/time isn't as general as you'd like.
Man page extract from at(1):
	|     Thus legitimate commands include:
	|          at 0815am Jan 24
	|          at 8:15am Jan 24
	|          at now + 1 day
	|          at 5 pm Friday

The dates syntax of "calendar" is more flexible.  From "calendar(1)" man page:
	|DESCRIPTION
	|     .....................  Most  reasonable  month-day  dates  -
	|     such as `Dec. 7,' `december 7,' and `12/7' - are recognized,
	|     but `7 December' or `7/12' are not..........................

"calendar" uses /usr/lib/calendar (an a.out) to figure out todays and
tomorrows date.  It's an egrep expression, which is (for June 7, 1989):
(^|[ 	(,;])((([Jj]un[^ 	]*|\*)[ 	]*|(06|6|\*)/)0*7)([^0123456789]|$)
(^|[ 	(,;])((([Jj]un[^ 	]*|\*)[ 	]*|(06|6|\*)/)0*8)([^0123456789]|$)
As EVERYBODY can PLAINLY see, this is a TRIVIAL representation for... well...
It's...  Ummm...  so obvious I don't need to say anything.  :-)

Anyway, the point is that "calendar" waits until the date shown matches
"today"'s date.  That's not really what you want.  But it may be a start.

Marshall

--
	________________________________________________________________
	Marshall P. Cline	ARPA:	cline at sun.soe.clarkson.edu
	ECE Department		UseNet:	uunet!sun.soe.clarkson.edu!cline
	Clarkson University	BitNet:	BH0W at CLUTX
	Potsdam, NY  13676	AT&T:	(315) 268-6591



More information about the Comp.lang.c mailing list