TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: whdjr on May 24, 2005, 04:20:53 PM
-
Can someone enlighten me as to what type of date system this is and how to calculate which is older?
(http://www.theswamp.org/screens/whdjr/ScreenShot028.jpg)
Thanks,
-
Autocad usually uses, Julian.
-
These are actually properties of files.
Ok...so how do you convert Julian date to 'regular date' or tell which is more current?
-
The right is older, because <DateCreated> is lower (you can also use the variable TDCREATE).
This value is represented as a Modified Julian Date (MJD), which is the Julian day number and decimal fraction of a day in the format : <Julian day number>.<Decimal fraction of a day>
(setq s (getvar "DATE"))
(setq nth_second (* 3600.0 24.0 (- s (fix s))))
-
The right is older, because <DateCreated> is lower (you can also use the variable TDCREATE)...
Is this always true? Can I bank on this being a fact all the time?
-
That's what I use:
;
; -- Function ConvJulianDate
; Convert julian date/time (also serial) to standard format.
; Arguments [Typ]:
; Val = Julian date/time [REAL]
; Mde = Conversion mode, eg. "MO/DD/YYYY H:MMam/pm" [STR] *)
; Return [Typ]:
; > Formatted date/time [STR]
; Notes:
; *) Details for mode see Diesel, edtime
;
(defun ConvJulianDate (Val Mde / TmpVal)
(setq TmpVal (if (minusp (- Val 2415019.0)) (+ Val 2415019.0) Val))
(menucmd (strcat "M=$(edtime," (rtos TmpVal) "," Mde ")"))
)
Cheers
-
Thanks for all your help Jürg.
One more question though,
If I retrieve a date from a file that is '36460.6', using your code i know the date to be '10/27/1999 2:24pm'.
What would I need to do if I wanted to know if another date was within 12 hours of this time?
-
Hi Will
You're welcome :D
If I retrieve a date from a file that is '36460.6', using your code i know the date to be '10/27/1999 2:24pm'.
What would I need to do if I wanted to know if another date was within 12 hours of this time?
That's an easy one:(fix (* 24 (- FirstTime NextTime)))
FirstTime and NextTime should be a Julian-type date...
Cheers
-
Well Jürg, I'mm sorry to say that the results I get mean absolutely nothing. They don't equal the time difference. Can you explain any of it for me?
-
I have Googled this to death and this is what I came up with. '.5' represents 12 hours therefore this will tell me if my file is with a 12 hour window.
(cond
((< (- FirstTime NextTime) 0.5)(do this))
((this is True)(do this))
)
Thanks for the help Jürg
-
Hi Will
Glad to help... :D
May I've misunderstand your question, I was thinking you need the difference (in hours) between two julian dates...
Cheers