Author Topic: Time difference..  (Read 4630 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Time difference..
« Reply #15 on: November 06, 2006, 06:25:42 PM »
I Know i have AutoCAD log report on server...FlexLM...and also I can use SAMreport..

But I think SAM is not perfect.....
that why i've made this little RPT file to test SAM.

Also, I had a big headhake by trying to found a way to take the date and hour when AutoCAD close....and not the drawing....but if you see the code....I've found a trick..!

;-)
Keep smile...

Derwin

  • Guest
Re: Time difference..
« Reply #16 on: November 06, 2006, 11:07:10 PM »
k, heres the YEAR.MONTH.DAY part. same as before, but now we convert to DAYS, and no need to convert back. (representing a DIFFERENCE as a DATE would be misleading..)

maybe tommorow ill make the whole day+seconds thing work..

not sure anymore if its what you were asking for, but its something i put off for a while, and needed, a logging of drawings opened/closed by the various drafters here. a pleasant hour of afternoon coding before an earlymark, before the great ozzie horse race==melbourne cup, around the same time that the yanks have their great race..  (both can be interpreted as to be dealing with issues of cruelty to animals.. :|)

Code: [Select]
; ----------------------------------------------------------------------------
; memeeng 071106
;
(defun C:testdatediff ()
  (datediff "20061101.000000" "20061102.111111" )
  (datediff "20061001.000000" "20061101.111111" )
  (datediff "20051001.000000" "20061001.111111" )
  (datediff "20000101.000000" "20010101.111111" )
  (datediff "20010101.000000" "20020101.111111" )
  (princ)
)

; ----------------------------------------------------------------------------
; memeeng 071106
;
(defun datediff ( DATEA DATEB / DAYEA DAYEB DAYEC)
  (setq DAYEA (CountDaysUntil DATEA)
DAYEB (CountDaysUntil DATEB)
  DAYEC (if (< DAYEA DAYEB) (- DAYEB DAYEA) (- DAYEA DAYEB) )
  )
  (princ "\nDAY Difference between " )(princ DATEA)(princ " and ")(princ DATEB)(princ " is ")
  (princ DAYEC)(princ " days.")
)

; ----------------------------------------------------------------------------
; memeeng 071106 RETURNS total days up till YEAR
;
(defun CountYearDaysUntil ( YEAR / YEARC DAYEC )
  (setq YEARC 0
DAYEC 0)
  (while (< YEARC YEAR)
(setq DAYEC (+ DAYEC (if(or(= 0 (rem YEARC 4))(= 0 (rem YEARC 400))) 366 365) ))
(setq YEARC (1+ YEARC))
  )
  DAYEC
)

; ----------------------------------------------------------------------------
; memeeng 071106 RETURNS total days up to MONTH
;
(defun  CountMonthDaysUntil( YEAR MUNF / MUNFC DAYEC )
  (setq DAYEC 0 MUNFC 1)
  (while (< MUNFC MUNF)
    (setq DAYEC (+ DAYEC (nth (1- MUNFC) (list 31 28 31 30 31 30 31 31 30 31 30 31)) )
  MUNFC (1+ MUNFC))
  );endWHILE
  (if (and(> MUNF 2)(or(= 0 (rem YEAR 4))(= 0 (rem YEAR 400))) )
    (1+ DAYEC)
    DAYEC
  );FeburayFIX
)

; ----------------------------------------------------------------------------
; memeeng 071106 RETURNS date as TOTAL DAYS since YEAR 0.1.1
;
(defun CountDaysUntil ( DATE )
  (+ (CountYearDaysUntil  (read(substr DATE 1 4)) )
     (CountMonthDaysUntil (read(substr DATE 1 4)) (read(substr DATE 5 2)) )
     (read(substr DATE 7 2)) )
)