replacement for dos_filedate

replacement for dos_filedate

HE-MJJ
Advocate Advocate
1,786 Views
25 Replies
Message 1 of 26

replacement for dos_filedate

HE-MJJ
Advocate
Advocate

I'm trying find a replacement for dos_filedate.

 

I thought by using vl-file-systime, but vl-file-systime apparently does not return a value of a file that is opened which dos_filedate does. As you can see in results below:

 

_$ (vl-file-systime "H:\\0000\\0000\\Tekeningen\\BT\\0000_BT-BB-022A.dwg")
nil
_$ (vl-file-systime "H:\\0000\\0000\\Tekeningen\\BT\\0000_BT-BB-022.dwg")
(2024 3 5 15 12 31 56 0)
_$ (dos_filedate "H:\\0000\\0000\\Tekeningen\\BT\\0000_BT-BB-022A.dwg")
(("0000_BT-BB-022A.dwg" . 2.02404e+07))
_$

 

Does anyone know a working alternative for dos_filedate to obtain the date of an opened drawing?

0 Likes
1,787 Views
25 Replies
Replies (25)
Message 2 of 26

paullimapa
Mentor
Mentor

Perhaps try code on this thread


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 26

EnM4st3r
Advocate
Advocate

try this:

  (if (not jtod) (load "Julian.lsp"))
  (jtod (getvar "tdupdate"))
0 Likes
Message 4 of 26

HE-MJJ
Advocate
Advocate

Thanks. Not sure if I already tried this. I need it to work under AutoCAD LT. I will try to figure it out...

0 Likes
Message 5 of 26

HE-MJJ
Advocate
Advocate

Thanks. Not sure if I already tried this. I need it to work under AutoCAD LT. I will try to figure it out...

0 Likes
Message 6 of 26

paullimapa
Mentor
Mentor

Then it won’t work since LT lisp doesn’t support this function  vlax-create-object which is required to run that code


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 7 of 26

EnM4st3r
Advocate
Advocate

julain.lsp is from express tools. it does not use vlax-create-object so it should work. Though idk if you have access to them

0 Likes
Message 8 of 26

HE-MJJ
Advocate
Advocate

That is too bad. I like to think in possibilities ; )

 

0 Likes
Message 9 of 26

paullimapa
Mentor
Mentor

Unfortunately no express tools for LT either 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 10 of 26

HE-MJJ
Advocate
Advocate

I have Julian.lsp but afaik it cannot be use to obtain the date of a file. Correct me if I'm wrong.

0 Likes
Message 11 of 26

EnM4st3r
Advocate
Advocate

you can use it to convert the time you get in Juilan format for example (getvar "TDUPDATE") wich gives you the last updated time.
Watch my first answer.

0 Likes
Message 12 of 26

EnM4st3r
Advocate
Advocate

i mean its just basic calculations. Though im not sure if we are allowed to just post that code.

0 Likes
Message 13 of 26

EnM4st3r
Advocate
Advocate

here try this. Since you said you have Julian.lsp it should work.

(defun c:timetest (/ date dateStr)
  (if (not jtod) (load "Julian.lsp"))
  (CurDate (jtod (getvar "TDUPDATE")) nil)
)

; Returns or outputs the current date and time
; time = coded decimal time format (like you get from CDATE)
; bOutput = T - Output the string to the Command prompt
; bOutput = nil - Return a string in the MM/DD/YYYY  HH:MM:SS format
; Usage: (CurDate T)
; Usage: (CurDate nil)

(defun CurDate (time bOuput / date_val YYYY M D HH MM SS)
  ; Get the current date/time
  (setq date_val (rtos time 2 6))

  ; Break up the string into its separate date and time parts
  (setq YYYY (substr date_val 1 4)
        M    (substr date_val 5 2)
        D    (substr date_val 7 2)
        HH   (substr date_val 10 2)
        MM   (substr date_val 12 2)
        SS   (substr date_val 14 2)
  )

  ; Output the current date and time to the Command
  ; prompt or return the formatted output as a string
  (if bOuput
    (progn
      (prompt (strcat "\nDate: " M "/" D "/" YYYY
                      "\nTime: " HH ":" MM ":" SS
              )
      )
      (princ)
    )
    (strcat M "/" D "/" YYYY "  " HH ":" MM ":" SS)
  )
)
0 Likes
Message 14 of 26

HE-MJJ
Advocate
Advocate

Ah! I see what you mean. Maybe I can use this in a different approach. Thanks.

0 Likes
Message 15 of 26

HE-MJJ
Advocate
Advocate

Hi,

 

I'm picking up on this subject again and I'm running into some issues...

 

For example: I have this file:

HEMJJ_2-1717578258843.png

(setq fnm-d (vl-file-systime "H:\\0000\\0000\\Tekeningen\\BT\\0000_BT-BB-022.dwg"))

Results in: (2024 3 5 15 12 31 56 0)

Hours is 12 and according to above properties it is 11. So I guess daylight savings time is not taken into account.

But that's not so much the problem. The date is more important for me.

 

(dtoj 20240315) results in: 2.46038e+06 But reversed: (jtod 2.46038e+06) results in 2.02403e+07

Why is this? Do I use wrong input?

 

0 Likes
Message 16 of 26

HE-MJJ
Advocate
Advocate

CDATE = 20240605.11173200 (read only)


_$ (dtoj 20240605.11173200)
2.46047e+06
_$ (jtod 2.46047e+06)
2.02406e+07

Not? 20240605.11173200

 

 

0 Likes
Message 17 of 26

EnM4st3r
Advocate
Advocate

(dtoj 20240315) results in: 2.46038e+06 But reversed: (jtod 2.46038e+06) results in 2.02403e+07

Why is this? Do I use wrong input?

 


this is just the written output in the commandline, the value is actually the same.

you can try this for example and will see its equal:

(setq cdate 20240605.11173200)
(equal cdate (jtod (dtoj cdate)) 0.001)

 

0 Likes
Message 18 of 26

EnM4st3r
Advocate
Advocate

so if you print it to the commandline using for example rtos it will give out the actual result with your given precision

(rtos (jtod (dtoj 20240315)) 2 6)

 

0 Likes
Message 19 of 26

HE-MJJ
Advocate
Advocate

I seem to be almost there...

 

This is my replacement for dos_filedate so far:

 

(defun dos-filedate (fnm / fnm-d fnm-d-j )
(if (setq fnm-d (vl-file-systime fnm))
(progn
(setq fnm-d-j (dtoj (atoi (strcat (rtos (nth 0 fnm-d) 2 0) (strnr (rtos (nth 1 fnm-d) 2 0) 2) (strnr (rtos (nth 3 fnm-d) 2 0) 2))))) ; Check: (rtos (jtod fnm-d-j) 2 6)
(setq fnm (list (cons (strcat (nth 2 (dos-splitpath fnm)) (nth 3 (dos-splitpath fnm))) fnm-d-j)))
)
(if (= (strcase (strcat (getvar "dwgprefix") (getvar "dwgname"))) (strcase fnm)) ; Bij dit geopende bestand
(progn
(setq fnm-d-j (getvar "tdupdate")) ; Check: (rtos (jtod fnm-d-j) 2 6)
(setq fnm (list (cons (strcat (nth 2 (dos-splitpath fnm)) (nth 3 (dos-splitpath fnm))) fnm-d-j)))
)
)
)
fnm
)

 

If I check my code by replacing - for _ in dos_filedate

 

; form dos_filedate loaded * original doslib command *
_$
_1_$

(("0000_BT-BB-022.dwg" . 2.02403e+07))
_1_$

(("0000_BT-BB-022A.dwg" . 2.02404e+07))
_1_$
_$

; form dos-filedate loaded
_$
_1_$

(("0000_BT-BB-022.DWG" . 2.46038e+06))
_1_$

(("0000_BT-BB-022A.DWG" . 2.46041e+06))
_1_$
_$

 

This results in these different dates:

HEMJJ_0-1717664936729.png

Can you see where I'm ging wrong in the code?

 

(strnr is used to add 0 when strlen is 1)

 

 

0 Likes
Message 20 of 26

HE-MJJ
Advocate
Advocate

Almost got it:

Corrected the code and this is now correct:

 

HEMJJ_0-1717666713663.png

Exept no time. What is the cause of that?

 

0 Likes