Author Topic: Time Zone ..  (Read 2399 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Time Zone ..
« on: September 03, 2007, 10:00:04 PM »

Has anyone come across a way, from V/Lisp to determine the time offset from GMT ?
If so, care to share ?

Code: [Select]
(SETQ d              (RTOS (GETVAR "cdate") 2 6)
      rev::datestamp (STRCAT (SUBSTR d 1 4)
                             "-"
                             (SUBSTR d 5 2)
                             "-"
                             (SUBSTR d 7 2)
                             "T"
                             (SUBSTR d 10 2)
                             ":"
                             (SUBSTR d 12 2)
                             ":"
                             (SUBSTR d 14 2)
                     )
)

Returns "2007-09-04T11:50:13"
I want to add the time offset
ie; "2007-09-04T11:50:13+10.00"

I'll hack one through a C# interface if really necessary, but in this case I'd prefer vlisp.

For the curious, I'm writing a timestamp to an XML file field that is required to be sortable when imported into SQL
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8785
  • AKA Daniel
Re: Time Zone ..
« Reply #1 on: September 03, 2007, 10:56:47 PM »
how about using WMI?

http://www.microsoft.com/technet/scriptcenter/guide/sas_wmi_fvwp.mspx?mfr=true

Code: [Select]
((defun GMT:OFFSET (/ item meth1 meth2 s serx wmi)
 (vl-load-com)
 (setq WMI (vlax-create-object "WbemScripting.SWbemLocator")
       meth1 (VLAX-INVOKE WMI 'ConnectServer nil nil nil nil nil nil nil nil)
       meth2 (vlax-invoke meth1 'ExecQuery "SELECT * FROM  Win32_OperatingSystem")
       s (vlax-for item meth2 (setq serx (list (vlax-get item 'CurrentTimeZone))))
 )
 (vlax-release-object meth1)
 (vlax-release-object meth2)
 (vlax-release-object wmi)
 (/ (car s) 60)
)


(defun WMI:TIME (/ item meth1 meth2 s serx wmi)
 (vl-load-com)
 (setq WMI (vlax-create-object "WbemScripting.SWbemLocator")
       meth1 (VLAX-INVOKE WMI 'ConnectServer nil nil nil nil nil nil nil nil)
       meth2 (vlax-invoke meth1 'ExecQuery "SELECT * FROM  Win32_OperatingSystem")
       s (vlax-for item meth2 (setq serx (list (vlax-get item 'LocalDateTime))))
 )
 (vlax-release-object meth1)
 (vlax-release-object meth2)
 (vlax-release-object wmi)
 (car s)
)

« Last Edit: September 03, 2007, 10:58:39 PM by Danielm103 »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Time Zone ..
« Reply #2 on: September 03, 2007, 11:27:36 PM »
Perfect Daniel ....

Your blood's worth bottling !!

I just started to look at WMI .. that saves me a heap of testing .. Thanks.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Time Zone ..
« Reply #3 on: September 14, 2007, 10:26:47 PM »
Thanks again Daniel.
I've needed to also extract and format the "TDCREATE" variable ( Time/Date created)
It's become a little heavy, getting the julian time, converting to calendar, getting the GMT Time offset, formatting it all together  ...

.. but it works well.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8785
  • AKA Daniel
Re: Time Zone ..
« Reply #4 on: September 18, 2007, 11:44:43 AM »
It’s my pleasure Kerry
I’m interested to see how your XML project progresses.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Time Zone ..
« Reply #5 on: September 24, 2007, 12:00:12 PM »
Daniel,
Pity it wasn't this simple ... I think it's time to pick up C# again.

Code: [Select]
            string dtz = DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz" ));
Quote
The time is 2007-09-25T01:58:38+10:00
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

ASMI

  • Guest
Re: Time Zone ..
« Reply #6 on: September 24, 2007, 03:52:26 PM »
One more brick in the wall  8-):

Code: [Select]
(defun Time_with_Offset(/ tOff)
 (vl-load-com)
   (vla-eval(vlax-get-acad-object)
     "ThisDrawing.SetVariable \"USERS1\", (Date$) & \"T\" & (Time$)")
  (setq tOff(-(/(vl-registry-read
       "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation\\"
       "ActiveTimeBias")60)))
    (strcat(getvar "USERS1")(if(minusp tOff) "-" "+")(itoa tOff)":00")
  ); end of Time_with_Offset

Code: [Select]
_$ (Time_with_Offset)
"09-26-2007T22:46:43+2:00"