TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: whdjr on May 24, 2005, 04:20:53 PM

Title: Date formats
Post 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,
Title: Date formats
Post by: daron on May 24, 2005, 04:35:36 PM
Autocad usually uses, Julian.
Title: Date formats
Post by: whdjr on May 24, 2005, 04:47:13 PM
These are actually properties of files.

Ok...so how do you convert Julian date to 'regular date' or tell which is more current?
Title: Date formats
Post by: Crank on May 24, 2005, 05:01:45 PM
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>

Code: [Select]
(setq s (getvar "DATE"))
(setq nth_second (* 3600.0 24.0 (- s (fix s))))
Title: Date formats
Post by: whdjr on May 24, 2005, 08:39:48 PM
Quote from: Crank
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?
Title: Date formats
Post by: Jürg Menzi on May 25, 2005, 02:17:11 AM
That's what I use:
Code: [Select]
;
; -- 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
Title: Date formats
Post by: whdjr on May 25, 2005, 02:56:17 PM
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?
Title: Date formats
Post by: Jürg Menzi on May 26, 2005, 06:59:18 AM
Hi Will

You're welcome :D
Quote from: whdjr
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:
Code: [Select]
(fix (* 24 (- FirstTime NextTime)))FirstTime and NextTime should be a Julian-type date...

Cheers
Title: Date formats
Post by: whdjr on May 26, 2005, 12:02:03 PM
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?
Title: Date formats
Post by: whdjr on May 26, 2005, 02:45:40 PM
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.
Code: [Select]
(cond
    ((< (- FirstTime NextTime) 0.5)(do this))
    ((this is True)(do this))
)

Thanks for the help Jürg
Title: Date formats
Post by: Jürg Menzi on May 26, 2005, 03:25:11 PM
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