* Re: Weekday in DCL
1996-01-24 5:00 Weekday in DCL Marc Gobes
@ 1996-01-24 5:00 ` David M. Desroches
0 siblings, 0 replies; 2+ messages in thread
From: David M. Desroches @ 1996-01-24 5:00 UTC (permalink / raw)
Marc Gobes writes:
>Q: How can I calculate the weeknumber in DCL ?
>or, if it is not possible, in (dec) C ??
Here's how we do it.
----------------------- Start of included DCL ------------------------
$!
$ date = f$cvtime(p1,"absolute")
$!
$ year = f$integer(f$cvtime(date,,"year"))
$ month = f$integer(f$cvtime(date,,"month"))
$ day = f$integer(f$cvtime(date,,"day"))
$!
$ if month .eq. 1 then -
julian_day == day
$ if month .eq. 2 then -
julian_day == 31 + day
$ if month .eq. 3 then -
julian_day == 31 + 28 + day
$ if month .eq. 4 then -
julian_day == 31 + 28 + 31 + day
$ if month .eq. 5 then -
julian_day == 31 + 28 + 31 + 30 + day
$ if month .eq. 6 then -
julian_day == 31 + 28 + 31 + 30 + 31 + day
$ if month .eq. 7 then -
julian_day == 31 + 28 + 31 + 30 + 31 + 30 + day
$ if month .eq. 8 then -
julian_day == 31 + 28 + 31 + 30 + 31 + 30 + 31 + day
$ if month .eq. 9 then -
julian_day == 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + day
$ if month .eq. 10 then -
julian_day == 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day
$ if month .eq. 11 then -
julian_day == 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day
$ if month .eq. 12 then -
julian_day == 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day
$!
$ if (month .ge. 3) .and. (f$cvtime("28-feb-''year'+1-",,"day") .eqs. "29") then -
julian_day == julian_day + 1
$!
$ weekday = f$cvtime("1-jan-''year'",,"weekday")
$ if weekday .eqs. "Sunday" then -
julian_week == ((julian_day - 1) / 7) + 1
$ if weekday .eqs. "Monday" then -
julian_week == (julian_day / 7) + 1
$ if weekday .eqs. "Tuesday" then -
julian_week == ((julian_day + 1) / 7) + 1
$ if weekday .eqs. "Wednesday" then -
julian_week == ((julian_day + 2) / 7) + 1
$ if weekday .eqs. "Thursday" then -
julian_week == ((julian_day + 3) / 7) + 1
$ if weekday .eqs. "Friday" then -
julian_week == ((julian_day + 4) / 7) + 1
$ if weekday .eqs. "Saturday" then -
julian_week == ((julian_day + 5) / 7) + 1
$!
$ exit
------------------------ End of included DCL -------------------------
--
David M. Desroches | O my Jesus, forgive us our sins, save us from the
dmdesroches@jake.wpi.edu | fires of hell, and lead all souls into heaven,
Worcester Polytechnic Inst | especially those in most need of Thy mercy.
(508) 831-5487 | -- Our Lady of Fatima, 1917
^ permalink raw reply [flat|nested] 2+ messages in thread