Subject: | |
From: | |
Reply To: | Simonsen, Larry |
Date: | Wed, 30 Dec 1998 08:11:05 -0700 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Here are two scripts for handling dates.
The first, MPEJD, converts today's date to a dates offset.
The second, FMTJD, formats a jd to a mm/dd/yy.
They use the Julian script from the jazz site repeated at the end.
These are most useful for a format date which is an offset from today's
date of n days.
As in:
!mpejd todayjd
!fmtjd (todayjd-7) fjdcut
!showvar
!SPOOLF O@;SELEQ=[dev=dlp AND DATE < !fjdcut];SHOW;delete
Is there a way of making these functions rather than scripts?
MPEJD
PARM rtnvar=""
# Converts "today" to a ask Julian date. Handles leap years.
# If "rtnvar" is passed the Julian date is returned in this var, else it
# is written to $stdlist.
julian _yearjd
setvar _jd ( (hpyyyy-1973) * 1461) /4 + _yearjd + 428
if "!rtnvar" = "" then
echo Jd for !hpdatef is: !_jd
else
setvar !rtnvar _jd
endif
deletevar _jd
deletevar _yearjd
FMTJD
PARM jd, rtnvar=""
# Formats jd to mm/dd/yyyy.
# If "rtnvar" is passed the string is returned in this var, else it
# is written to $stdlist.
setvar _jdyt (!jd * 4 - 489) / 1461
setvar _jdmt !jd - !_jdyt *1461/4
setvar _jdm (10 * !_jdmt -1) / 306 -1
setvar _jdy !_jdyt + 1972
setvar _jdd !_jdmt - ( !_jdm + 1) * 153/5
if !_jdm > 12 then
setvar !_jdm !_jdm - 12
setvar !_jdy = !_jdy +1
endif
if "!rtnvar" = "" then
echo Jd for !jd is: !_jdm/!_jdd/!_jdy
else
setvar !rtnvar "!_jdm/!_jdd/!_jdy"
endif
deletevar _jdyt
deletevar _jdmt
deletevar _jdm
deletevar _jdy
deletevar _jdd
JULIAN
PARM rtnvar=""
# Converts "today" to a Julian date. Handles leap years.
# If "rtnvar" is passed the Julian date is returned in this var, else it
# is written to $stdlist.
setvar _julian hpdate + &
![WORD("0 31 59 90 120 151 181 212 243 273 304 334",,hpmonth)]
if hpyyyy mod 4 = 0 and (hpyyyy mod 100 <> 0 or hpyyyy mod 400 = 0) &
and hpmonth >= 3 then
setvar _julian _julian + 1
endif
if "!rtnvar" = "" then
echo Julian date for !hpdatef is: !_julian
else
setvar !rtnvar _julian
endif
deletevar _julian
------------------------------------------------------------------------
Larry Simonsen Phone: 801-489-2450
Flowserve Corporation Fax: 801-491-1750
PO Box 2200 http://www.flowserve.com
Springville, UT 84663 e-mail: [log in to unmask]
------------------------------------------------------------------------
|
|
|