Jump to content

Calculating date/time relative to UTC


4Eyes
 Share

Recommended Posts

Folks,

Looking at the helpfile in relation to _Date_Time_GetTimeZoneInformation() gives me a headache.

The first element of the returned array is specified as:

0 - Daylight savings time is not used in the current time zone

1 - Daylight savings time operating with standard time

2 - Daylight savings time operating with daylight savings time

I understand:

'0 - Daylight savings time is not used in the current time zone' and

'2 - Daylight savings time operating with daylight savings time'

but what is 'Daylight savings time operating with standard time'? How can you have daylight savings time with no change to the local time or am I misinterpreting the explanation? I'm really tired so I assume that is the actual answer.

Blah... meant to post this in the General help and support forum.

Edited by 4Eyes
Link to comment
Share on other sites

  • 1 year later...

Func _TimeConvert_GetDaylightSavingTime($__iShow)
    ;    Please don't remove this line - © Copyright 2013: J. Malmgren, wwww.tryware.dk
    ;    Get SystemTime, convert it with Daylight saving time (DST), and convert it according to $__iShow
    ;    Return result:        Syntax:
    ;    YYYYMMDD HH:MM:SS    $__iShow =1
    ;    YYYYMMDD            $__iShow =2
    ;    HH:MM:SS            $__iShow =3
    ;    HHMMSS                $__iShow =4
    ;
    ;    Examples:
    ;
    ;    MsgBox(0,"YYYYMMDD HH:MM:SS",_TimeConvert_GetDaylightSavingTime(1))
    ;    MsgBox(0,"YYYYMMDD",_TimeConvert_GetDaylightSavingTime(2))
    ;    MsgBox(0,"HH:MM:SS",_TimeConvert_GetDaylightSavingTime(3))
    ;    MsgBox(0,"HHMMSS",_TimeConvert_GetDaylightSavingTime(4))
    ;    MsgBox(0,"ERROR:",_TimeConvert_GetDaylightSavingTime(5))

    Local $__sGetSystemTime = _Date_Time_GetSystemTime()
    Local $__sGetDstTime  = _Date_Time_SystemTimeToTzSpecificLocalTime(DllStructGetPtr($__sGetSystemTime))
    Local $__iGetTime = _Date_Time_SystemTimeToDateTimeStr($__sGetDstTime)

    Local $__sTime                    ;    1234567890123456789
                                    ;    12/31/2013 23:23:22

    Switch $__iShow
        Case 1                        ;    YYYYMMDD HH:MM:SS
            $__sTime = StringMid($__iGetTime, 7, 4) & ":" & StringMid($__iGetTime, 1, 2) & ":" & StringMid($__iGetTime, 4, 2)
            $__sTime = $__sTime  & " " & StringMid($__iGetTime, 12, 3) & StringMid($__iGetTime, 15, 3) & StringMid($__iGetTime, 18, 2)

        Case 2                        ;    YYYYMMDD
            $__sTime = Int(StringMid($__iGetTime, 7, 4) & StringMid($__iGetTime, 1, 2) & StringMid($__iGetTime, 4, 2))

        Case 3                        ;    HH:MM:SS
            $__sTime = StringMid($__iGetTime, 12, 3) & StringMid($__iGetTime, 15, 3) & StringMid($__iGetTime, 18, 2)

        Case 4                        ;    HHMMSS
            $__sTime = Int(StringMid($__iGetTime, 12, 2) & StringMid($__iGetTime, 15, 2) & StringMid($__iGetTime, 18, 2))

        Case Else
            $__sTime = "SYNTAX ERROR: _TimeGetDaylightSavingTime = 1, 2, 3 or 4"
    EndSwitch

    Return $__sTime
EndFunc

Edited by Melba23
Added code tags

Sincerely

J. Malmgren

IT-Programmer

http://www.tryware.dk

 

Link to comment
Share on other sites

  • Moderators

nergmlam,

When you post code please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. ;)

M23

Edit: And I see you have posted this same function in several posts - I have deleted all the other instances. Next time just add it to the "Examples" section and please do not multi-post like that again! :naughty:

Edited by Melba23
Typo

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...