Date off by a day

Date off by a day

john.uhden
Mentor Mentor
1,048 Views
5 Replies
Message 1 of 6

Date off by a day

john.uhden
Mentor
Mentor

I don't think there is anything wrong with this, but AutoCAD is telling me today is 12-28-2017.

 

(defun ACDate ()
  (eval
    (list 'menucmd
      (strcat "M=$(edtime," (rtos (getvar "date") 2 0) ",M/D/YYYY)")
    )
  )
)

Note that this was posted on 12-27-2017 (I think).

 

AHAH!!  I know why.  Do you?

John F. Uhden

0 Likes
Accepted solutions (1)
1,049 Views
5 Replies
Replies (5)
Message 2 of 6

cadffm
Consultant
Consultant
Accepted solution

Please do not use 'ACDate' as function name, it is a used system-symbolname

(defun ACDateX ()
  (eval
    (list 'menucmd
      (strcat "M=$(edtime," (rtos (getvar "date") 2 18) ",M/D/YYYY)")
    )
  )
)

Sebastian

0 Likes
Message 3 of 6

john.uhden
Mentor
Mentor

Thank you for that name advice.

 

Well, I don't think you had to go so far as 18, but you got the answer.  Nevertheless, if the whole units are days starting from 4000± BC, why would any decimal value affect the date to the nearest day?  And especially make it later?

John F. Uhden

0 Likes
Message 4 of 6

cadffm
Consultant
Consultant

Use this line for answer yourself: (alert (strcat (rtos (getvar "date") 2 18) " - " (rtos (getvar "date") 2 0)))

 

"rtos" round down OR UP

 

(rtos eighteen I use 18 because: Why not, why should i use less - like 9? Why you did that? 18 is clear if i read that in the future and show me "there is nothing edited except real-to-string))

Sebastian

0 Likes
Message 5 of 6

john.uhden
Mentor
Mentor

@cadffm wrote: " (alert (strcat (rtos (getvar "date") 2 18) " - " (rtos (getvar "date") 2 0)))"

 

Well look at that.

  I guess I had forgotten about how rtos works.  My original code is ages old, so I guess I had used it only in the morning. Smiley Surprised

But if I'm looking for only M-D-YYYY, then 1 place will work just fine.  Like why should I overstress my feeble laptop?

Actually, it's for my one (1) remaining client.  It would probably be embarrassing to show a date on the plan a day after the product was made and shipped.

John F. Uhden

Message 6 of 6

cadffm
Consultant
Consultant

 

OT - Note for Users with newer versions or programs for newer versions (2017+) : cdate and date value had changed,
they don't include millisecs, or better: The return of the Millisecs is available, but wrong!

(use variable MILLISECS for this if you need handle with that in your program)


not documented in Help2017

but documented in Help2018 as updated in 2017.. and also on helppage for date - and cdate

F1-MILLISECS


( I had no desire to look what is right, but the hint is certainly not wrong )

Sebastian

0 Likes