Julian Dates?

Michael Foy mike at essex-web.com
Wed Apr 10 10:58:01 EDT 2002


here's a bit of basic that could be converted.

first bit sets up the names of the days for the last function, so you know
the day of the week
the second function is for converting the julian back and the first one is
for converting to 'a julian date' don't worry about the zero position

miock

SUB FillEnglishArrays
  SevenDays(1) = "Monday"    : SevenDays(2) = "Tuesday"
  SevenDays(3) = "Wednesday" : SevenDays(4) = "Thursday"
  SevenDays(5) = "Friday"    : SevenDays(6) = "Saturday"
  SevenDays(7) = "Sunday"
END SUB

'--------------------- Functions ------------------------------

FUNCTION Julian(year, month, day) AS LONG
  temp& = (month - 14) \ 12
  JulPart& = day - 32075 + (1461 * (year + 4800 + temp&) \ 4)
  JulPart& = JulPart& + (367 * (month - 2 - temp& * 12) \ 12)
  FUNCTION = JulPart& - (3 * ((year + 4900 + temp&) \ 100) \ 4)
END FUNCTION

FUNCTION JulToDate (Jul&) AS STRING
  ' converts a Julian number into a computational date ("MM-DD-[-]YYYY")

  INCR Jul&, 68569
  help& = 4 * Jul& \ 146097
  DECR Jul&, (146097 * help& + 3) \ 4
  TempYear& = 4000 * (Jul& + 1) \ 1461001
  DECR Jul&, 1461 * TempYear& \ 4
  INCR Jul&, 31
  TempMonth& = 80 * Jul& \ 2447

  day& = Jul& - (2447 * TempMonth& \ 80)
  day$ = RIGHT$("00" + LTRIM$(RTRIM$(STR$(day&))), 2)

  month& = TempMonth& + 2 - (12 * (TempMonth& \ 11))
  month$ = RIGHT$("00" + LTRIM$(RTRIM$(STR$(month&))), 2)

  year& = 100 * (help& - 49) + TempYear& + (TempMonth& \ 11)
  year$ = RIGHT$("0000" + LTRIM$(RTRIM$(STR$(ABS(year&)))), 4)
  IF year& < 0 THEN year$ = "-" + year$
  FUNCTION = month$ + "-" + day$ + "-" + year$
END FUNCTION

FUNCTION DayOfTheWeek(BYVAL year, BYVAL month, BYVAL day) AS STRING
  ' returns the name for each day of the week

  DECR month, 2
  IF month < 1 OR month > 10 THEN
    INCR month, 12 : DECR year
  END IF
  century = year \ 100
  year = year MOD 100
  temp = INT(2.6 * month - .19) + day + year + (year \ 4)
  result = (temp + (century \ 4) - (century * 2)) MOD 7
  IF result < 1 THEN INCR result, 7
  FUNCTION = SevenDays(result)
END FUNCTION

----- Original Message -----
From: Richard Harrison <harrison at all-auctions.com>
To: <use-revolution at lists.runrev.com>
Sent: Wednesday, April 10, 2002 3:33 PM
Subject: Julian Dates?


> Hi there,
>
> Does anyone have a Julian Date conversion routine
> set up yet?  It is such a useful thing to have I'm
> surprised the Rev people haven't put it in yet!
>
> Thanks in advance,
>
> Rick Harrison
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>





More information about the use-livecode mailing list