HP3000-L Archives

March 1998, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Glenn Cole <[log in to unmask]>
Reply To:
Date:
Fri, 20 Mar 1998 12:28:27 -0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (64 lines)
Bob McGregor asks:

> I'd like to create a command file where I supply a date in the format of
> mm/dd/yy and get returned the corresponding day of the week.  Is there a
> function available at the CI level I can use to do this?

Not too concerned about y2k, eh? ;)

If you have MPEX, this is trivial.

        anyparm mydate
        mpex.pub.vesoft "setvar dow DateDayOfWeek(!mydate)"
        setvar days "SunMonTueWedThuFriSat"
        echo !mydate falls on a ![str(days,(dow-1)*3+1,3)]

Call this "GetDOW" and invoke it with, say, :GetDOW 7/4/1998 .

DateDayOfWeek returns an integer in the range [1,7], where 1=Sun, 7=Sat.

Whenever you do the y2k migration for this command file, you won't
have to worry about DateDayOfWeek:  by default, it accepts dates
in both mm/dd/yy and mm/dd/yyyy formats.

Also note that the "implied run" format used above for MPEX
does not print "END OF PROGRAM" at the end.  If you want to
use the explicit RUN, then send the output to $NULL.


If you don't have MPEX, well... it's doable, but not easy.

Since the CI doesn't have any real date manipulation (that I can find,
anyway), you can build a file with the target date, then use FINFO to
format it for you (it names the dow in the first 3 chars).  The question
is, how do you build a file with a specific date?

POSIX.

The 'touch' command allows you to specify a date AND TIME (both are
required).  Use either YYMMDDhhmm or YYYYMMDDhhmm formats.  Also,
since it's a POSIX command, the 'case' of the filename matters.

Here's how to get the dow for the same "7/4/1998" above:

        touch.hpbin.sys "199807041200 DOWFILE"
        setvar dowString lft( finfo("DOWFILE","fmtaccessed"), 3 )
        purge DOWFILE

(This example used the time 12:00 noon.)

'touch' (by default) builds the file if it doesn't exist.
Its reason for being is to update the access and mod date and time.


Personally, I prefer the MPEX approach, though I never remember
whether Sunday is 1 (as in MPE) or 0 (as in cron on Unix).

--Glenn Cole
  Software al dente, Inc.
  [log in to unmask]

.......................................................................

Item Subject: cc:Mail Text

ATOM RSS1 RSS2