DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Include time zone information in report

Hi,

 

I am using DIAdem template and script to update a report. At footer, I am printing date and time information but would like to include time zone information after time. Because, the script will be used and report will be generated by analyst from different part of the world.

 

Suggest me to include time zone information in report.

 

Footer:

       Report Generated: @@CurrDate@@ @@CurrTime@@ <Time_Zone>

 

      Expected: 01/09/2023 12:15:20 IST

 

 

0 Kudos
Message 1 of 2
(924 Views)

Hi Durai26,

 

With VBScript it is not so easy to determine the name or even the abbreviation of the local time zone. It is possible to determine the offset to UTC using CreateObject("WbemScripting.SWbemDateTime"). But then the assignment to the names of the time zones is still missing.

dim dateTime
set dateTime = CreateObject("WbemScripting.SWbemDateTime")
call dateTime.SetVarDate(now())
print("Minutes after UTC: " & str(dateTime.UTC))

 

If you have Python installed, you can use Python for this task. However, determining the abbreviation for the time zones name is not so easy either, since it depends on the language of the operating system. With the following function you can determine the current time with indication of the time zone, which however is not abbreviated by Python:

def GET_LOCAL_DATE():
    from datetime import datetime as dt
    from dateutil.tz import tzlocal    
    custom = dt.now(tzlocal())
    return custom.strftime("%d/%m/%Y %H:%M:%S %Z")
    #return custom.strftime("%d/%m/%Y %H:%M:%S %z")

If you save this function in a Python file and execute it once in DIAdem or register it as a user command, then you can use the function in the REPORT layout as an expression: @@GET_LOCAL_DATE()@@. It is important to know here that Python user commands must always be capitalized in DIAdem so that they can be used in an expression using @@...@@.

 

The result in REPORT then looks as follows:

local_time.png

0 Kudos
Message 2 of 2
(896 Views)