Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #6950 > unrolled thread
| Started by | "Jamal" <someone@example.com> |
|---|---|
| First post | 2014-06-12 18:39 -0400 |
| Last post | 2014-06-17 08:47 +0200 |
| Articles | 15 — 3 participants |
Back to article view | Back to comp.lang.clipper.visual-objects
GetTimeZoneDiff() documentation missing "Jamal" <someone@example.com> - 2014-06-12 18:39 -0400
Re: GetTimeZoneDiff() documentation missing Camille Kater <katercam@pt.lu> - 2014-06-13 13:49 +0200
Re: GetTimeZoneDiff() documentation missing "Jamal" <someone@example.com> - 2014-06-13 12:34 -0400
Re: GetTimeZoneDiff() documentation missing Camille Kater <katercam@pt.lu> - 2014-06-14 09:57 +0200
Re: GetTimeZoneDiff() documentation missing "Karl-Heinz" <invalid@invalid.invalid> - 2014-06-15 18:27 +0200
Re: GetTimeZoneDiff() documentation missing "Jamal" <someone@example.com> - 2014-06-15 21:31 -0400
Re: GetTimeZoneDiff() documentation missing "Karl-Heinz" <invalid@invalid.invalid> - 2014-06-16 14:45 +0200
Re: GetTimeZoneDiff() documentation missing "Jamal" <someone@example.com> - 2014-06-16 18:49 +0300
Re: GetTimeZoneDiff() documentation missing "Karl-Heinz" <invalid@invalid.invalid> - 2014-06-17 08:49 +0200
Re: GetTimeZoneDiff() documentation missing Camille Kater <katercam@pt.lu> - 2014-06-16 17:26 +0200
Re: GetTimeZoneDiff() documentation missing "Jamal" <someone@example.com> - 2014-06-16 14:08 -0400
Re: GetTimeZoneDiff() documentation missing Camille Kater <katercam@pt.lu> - 2014-06-17 09:30 +0200
Re: GetTimeZoneDiff() documentation missing "Jamal" <someone@example.com> - 2014-06-17 10:37 -0400
Re: GetTimeZoneDiff() documentation missing Camille Kater <katercam@pt.lu> - 2014-06-18 09:34 +0200
Re: GetTimeZoneDiff() documentation missing "Karl-Heinz" <invalid@invalid.invalid> - 2014-06-17 08:47 +0200
| From | "Jamal" <someone@example.com> |
|---|---|
| Date | 2014-06-12 18:39 -0400 |
| Subject | GetTimeZoneDiff() documentation missing |
| Message-ID | <lnda6q$fp4$1@speranza.aioe.org> |
The GetTimeZoneDiff() is not documented in the help file. Does anyone have the description of this function and what the return values mean? Thanks! Jamal
[toc] | [next] | [standalone]
| From | Camille Kater <katercam@pt.lu> |
|---|---|
| Date | 2014-06-13 13:49 +0200 |
| Message-ID | <1402661063_1@vo.lu> |
| In reply to | #6950 |
Hi Jamal On my PC I get as return -1 I found this function in the Internet SDK, while I was searching for a function to transform a Windows date to Unix Timestamp and vice-versa. But until now I had no success. Maybe there is somebody who can help with this Unix Timestamp ? Camille On 13/06/2014 00:39, Jamal wrote: > The GetTimeZoneDiff() is not documented in the help file. > > Does anyone have the description of this function and what the return > values mean? > > Thanks! > Jamal >
[toc] | [prev] | [next] | [standalone]
| From | "Jamal" <someone@example.com> |
|---|---|
| Date | 2014-06-13 12:34 -0400 |
| Message-ID | <lnf96h$6bi$1@speranza.aioe.org> |
| In reply to | #6955 |
Hi Camille,
The function found Internet SDK function and the function in VO28RUN.DLL are
not the same.
I wrote some VO function to do the Unix Epoch time conversion which I am
still testing for accuracy for different time zones and daylight savings. I
did not have to use the GetTimeZoneDiff().
In the mean time I found the following in VB.NET. I'll probably create a lib
and convert COM if the above does work out.
Create a winform app, then on the Form, create two lables, and a button.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Me.Label1.Text = UnixTime2DT(1318536660)
Me.Label2.Text = DT2UnixTime(Me.Label1.Text)
End Sub
Public Function UnixTime2DT(lUnixTimeStamp As Long) As Date
UnixTime2DT = DateAdd("s", lUnixTimeStamp, #1/1/1970#)
End Function
Public Function DT2UnixTime(ByVal dDate As Date) As Long
DT2UnixTime = DateDiff("s", #1/1/1970#, dDate)
End Function
Jamal
"Camille Kater" wrote in message news:1402661063_1@vo.lu...
Hi Jamal
On my PC I get as return -1
I found this function in the Internet SDK, while I was searching for a
function to transform a Windows date to Unix Timestamp and vice-versa.
But until now I had no success.
Maybe there is somebody who can help with this Unix Timestamp ?
Camille
On 13/06/2014 00:39, Jamal wrote:
> The GetTimeZoneDiff() is not documented in the help file.
>
> Does anyone have the description of this function and what the return
> values mean?
>
> Thanks!
> Jamal
>
[toc] | [prev] | [next] | [standalone]
| From | Camille Kater <katercam@pt.lu> |
|---|---|
| Date | 2014-06-14 09:57 +0200 |
| Message-ID | <1402733512_3@vo.lu> |
| In reply to | #6958 |
HI Jamal,
Thanks for your reply.
Please keep me informed about your Unix Epoch time conversion.
I need those functions urgently.
Camille
On 13/06/2014 18:34, Jamal wrote:
> Hi Camille,
>
> The function found Internet SDK function and the function in VO28RUN.DLL
> are not the same.
>
> I wrote some VO function to do the Unix Epoch time conversion which I am
> still testing for accuracy for different time zones and daylight
> savings. I did not have to use the GetTimeZoneDiff().
>
> In the mean time I found the following in VB.NET. I'll probably create a
> lib and convert COM if the above does work out.
>
> Create a winform app, then on the Form, create two lables, and a button.
>
> Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
> Button1.Click
> Me.Label1.Text = UnixTime2DT(1318536660)
> Me.Label2.Text = DT2UnixTime(Me.Label1.Text)
> End Sub
>
> Public Function UnixTime2DT(lUnixTimeStamp As Long) As Date
> UnixTime2DT = DateAdd("s", lUnixTimeStamp, #1/1/1970#)
> End Function
>
> Public Function DT2UnixTime(ByVal dDate As Date) As Long
> DT2UnixTime = DateDiff("s", #1/1/1970#, dDate)
> End Function
>
> Jamal
>
>
> "Camille Kater" wrote in message news:1402661063_1@vo.lu...
>
> Hi Jamal
>
> On my PC I get as return -1
>
> I found this function in the Internet SDK, while I was searching for a
> function to transform a Windows date to Unix Timestamp and vice-versa.
> But until now I had no success.
> Maybe there is somebody who can help with this Unix Timestamp ?
>
> Camille
>
> On 13/06/2014 00:39, Jamal wrote:
>> The GetTimeZoneDiff() is not documented in the help file.
>>
>> Does anyone have the description of this function and what the return
>> values mean?
>>
>> Thanks!
>> Jamal
>>
>
[toc] | [prev] | [next] | [standalone]
| From | "Karl-Heinz" <invalid@invalid.invalid> |
|---|---|
| Date | 2014-06-15 18:27 +0200 |
| Message-ID | <c05vreF9ba0U1@mid.individual.net> |
| In reply to | #6958 |
Hi Jamal, > I wrote some VO function to do the Unix Epoch time conversion which I am > still testing for accuracy for different time zones and daylight savings. > I did not have to use the GetTimeZoneDiff(). yes, i doubt that GetTimeZoneDiff() does anything useful. Assuming the func should return the bias in hours, it should return in a german environment -2, (UTC+01:00 + 1 hour daylight ). But if it would work as one might expect it would fail in timezones like "Adelaide UTC+09:30 ". In such cases the minutes are truncated because GetTimeZoneDiff() is declared as INT. Anyway, are you using in your VO code "SystemTimeToTzSpecificLocalTime" and "TzSpecificLocalTimeToSystemTime" to calc unix- <> windows-datetimestamps ? It seems that both funcs do not require any TimeZone calculations, and that they are smart enough to use automatically the correct bias on a given date. If you are interested i´ll put some VO snippets based on both funcs together. regards Karl-Heinz
[toc] | [prev] | [next] | [standalone]
| From | "Jamal" <someone@example.com> |
|---|---|
| Date | 2014-06-15 21:31 -0400 |
| Message-ID | <lnlhd9$p34$1@speranza.aioe.org> |
| In reply to | #6961 |
Hi Karl-Heinz,
I am not using those functions. Any samples on their use would be great.
I was able in getting the the UTC date and time of from the Epoch time.
The issue right now the local time based on different time zone.
Here is some code:
function ConvertEpochTime() as void pascal
local nDays, nEpochTime as int
local nTimeZone := -5 as int // EASTERN - 5 GMT
local nSecondsInDay := 86400 as int
local nLocal as int
local lDaylight as logic
local dUTCDate as date
local dLocalDate as date
nEpochTime := 1402680885 // 1318536660 // Unix EPOCH time in seconds
from 1970.1.1
// nEpochTime := 1402673020 // Unix EPOCH time in seconds from
1970.1.1
? "Epoch Time", nEpochTime
nDays := Days(nEpochTime) + iif(nTimeZone > 0, 1, 0) // From 1970
lDaylight := IsDayLight()
if nTimeZone > 0
nLocal := nTimeZone + 24
else
nLocal := nTimeZone
endif
nLocal += iif(lDaylight, 1,0) // adjust for DayLight
? nLocal
dUTCDate := ConDate(1970,1,1) + Days(nEpochTime) // get the UTC date
? "UTC Date: ", dUTCDate
dLocalDate := ConDate(1970,1,1) + nDays // get the date
? "LOCAL Date: ", dLocalDate
? "UTC Time: " , TString((nEpochTime - (Days(nEpochTime) *
nSecondsInDay)))
? "Local Time: ", TString((nEpochTime - (nDays * nSecondsInDay))+(nLocal
* 3600))
WAIT
return
FUNCTION IsDayLight() as logic PASCAL
LOCAL tzi is _WINTIME_ZONE_INFORMATION
LOCAL dwZone as DWORD
LOCAL lDayLight as logic
dwZone := GetTimeZoneInformation(@tzi)
// ? tzi.Bias
// ? tzi.DaylightName
// ? tzi.StandardName
do CASE
CASE dwZone == TIME_ZONE_ID_STANDARD
lDayLight := false
CASE dwZone == TIME_ZONE_ID_DAYLIGHT
lDayLight := true
ENDCASE
RETURN lDayLight
Jamal
"Karl-Heinz" wrote in message news:c05vreF9ba0U1@mid.individual.net...
Hi Jamal,
> I wrote some VO function to do the Unix Epoch time conversion which I am
> still testing for accuracy for different time zones and daylight savings.
> I did not have to use the GetTimeZoneDiff().
yes, i doubt that GetTimeZoneDiff() does anything useful. Assuming the func
should return the bias in hours, it should return in a german
environment -2, (UTC+01:00 + 1 hour daylight ). But if it would work as one
might expect it would fail in timezones like "Adelaide UTC+09:30 ". In such
cases the minutes are truncated because GetTimeZoneDiff() is declared as
INT. Anyway, are you using in your VO code
"SystemTimeToTzSpecificLocalTime" and "TzSpecificLocalTimeToSystemTime" to
calc unix- <> windows-datetimestamps ? It seems that both funcs do not
require any TimeZone calculations, and that they are smart enough to use
automatically the correct bias on a given date. If you are interested i´ll
put some VO snippets based on both funcs together.
regards
Karl-Heinz
[toc] | [prev] | [next] | [standalone]
| From | "Karl-Heinz" <invalid@invalid.invalid> |
|---|---|
| Date | 2014-06-16 14:45 +0200 |
| Message-ID | <c0878rFnl71U1@mid.individual.net> |
| In reply to | #6962 |
Hi Jamal,
> I am not using those functions. Any samples on their use would be great.
>
> I was able in getting the the UTC date and time of from the Epoch time.
> The issue right now the local time based on different time zone.
a few months ago we had an unix alert ;-), so i spent some hours in the
sources below. Because the alert went away almost as fast as it raised
further investigations were canceled. But i have the feeling that the
sources must be pretty close ...
There are two DLL imports and two self explaining main functions. Each func
has one optional Parameter "lUTCGMT". Here you can decide if the result will
be either localtime or UTC/GMT.
Let me know how it goes.
regards
Karl-Heinz
---- start ----
_DLL FUNCTION SystemTimeToTzSpecificLocalTime ( lpTimeZoneInformation AS
_WINTIME_ZONE_INFORMATION , lpUniversalTime AS _WINSYSTEMTIME , lpLocalTime
AS _WINSYSTEMTIME ) AS LOGIC PASCAL:Kernel32.SystemTimeToTzSpecificLocalTime
_DLL FUNCTION TzSpecificLocalTimeToSystemTime ( lpTimeZoneInformation AS
_WINTIME_ZONE_INFORMATION , lpLocalTime AS _WINSYSTEMTIME ,lpUniversalTime
AS _WINSYSTEMTIME ) AS LOGIC PASCAL:Kernel32.TzSpecificLocalTimeToSystemTime
FUNCTION WinDateTime2UnixDateTime ( d AS DATE , nHours AS INT , nMinutes AS
INT , nSeconds AS INT , lUTCGMT := FALSE AS LOGIC ) AS INT PASCAL
LOCAL nUnixDateTimestamp, nDays AS INT
LOCAL s1, s2 AS _WINSYSTEMTIME
nUnixDateTimestamp := -1
// -------------------------
nDays := INT ( _CAST , d ) - INT ( _CAST , ConDate ( 1970 , 1 , 1 ) )
IF lUTCGMT
nUnixDateTimestamp := ( nDays * 86400 ) + ( nHours * 3600 ) + (
nMinutes * 60 ) + nSeconds
ELSE
s1 := MemAlloc ( _SIZEOF ( _WINSYSTEMTIME ) )
s2 := MemAlloc ( _SIZEOF ( _WINSYSTEMTIME ) )
s1.wYear := Year ( d )
s1.wMonth := Month ( d )
s1.wDay := Day ( d )
s1.wHour := nHours
s1.wMinute := nMinutes
s1.wSecond := nSeconds
IF TzSpecificLocalTimeToSystemTime ( NULL , s1 , s2 )
nUnixDateTimestamp := ( nDays * 86400 ) + ( s2.wHour * 3600 ) + (
s2.wMinute * 60 ) + s2.wSecond
ENDIF
MemFree ( s1 )
MemFree ( s2 )
ENDIF
RETURN nUnixDateTimestamp
FUNCTION UnixDateTime2WinDateTime ( nUnixDateTimestamp AS INT , d REF DATE ,
nHours REF INT , nMinutes REF INT , nSeconds REF INT , lUTCGMT := FALSE AS
LOGIC ) AS LOGIC PASCAL
LOCAL nDays, nSecondsRest1, nSecondsRest2, nSecondsRest3 , nHoursTemp,
nMinutesTemp, nSecondsTemp AS INT
LOCAL dWinDate AS DATE
LOCAL s1, s2 AS _WINSYSTEMTIME
LOCAL lRet AS LOGIC
// ---------------
nDays := nUnixDateTimestamp / 86400
nSecondsRest1 := Mod ( nUnixDateTimestamp , 86400 )
// -----------------------
dWinDate := ConDate ( 1970 , 1 , 1 ) + nDays
// --------------------
nHoursTemp := nSecondsRest1 / 3600
nSecondsRest2 := Mod ( nSecondsRest1 , 3600 )
// -------------------
nMinutesTemp := nSecondsRest2 / 60
nSecondsRest3 := Mod ( nSecondsRest2 , 60 )
// -------------------
nSecondsTemp := nSecondsRest3
IF lUTCGMT
// ref vars
d := ConDate ( Year ( dWinDate ) , Month ( dWinDate ) , Day (
dWinDate ) )
nHours := nHoursTemp
nMinutes := nMinutesTemp
nSeconds := nSecondsTemp
lRet := TRUE
ELSE
s1 := MemAlloc ( _SIZEOF ( _WINSYSTEMTIME ) )
s2 := MemAlloc ( _SIZEOF ( _WINSYSTEMTIME ) )
s1.wYear := Year ( dWinDate )
s1.wMonth := Month ( dWinDate )
s1.wDay := Day (dWinDate )
s1.wHour := nHoursTemp
s1.wMinute := nMinutesTemp
s1.wSecond := nSecondsTemp
IF SystemTimeToTzSpecificLocalTime ( NULL , s1 , s2 )
// ref vars
d := ConDate ( s2.wYear , s2.wMonth , s2.wDay )
nHours := s2.wHour
nMinutes := s2.wMinute
nSeconds := s2.wSecond
lRet := TRUE
ENDIF
MemFree ( s1 )
MemFree ( s2 )
ENDIF
RETURN lRet
--- end -----
[toc] | [prev] | [next] | [standalone]
| From | "Jamal" <someone@example.com> |
|---|---|
| Date | 2014-06-16 18:49 +0300 |
| Message-ID | <lnn3lb$h9q$1@speranza.aioe.org> |
| In reply to | #6966 |
Hi Karl-Heinz,
Thanks! Your code works great with some changes since my interest is in
returning the Date and Time from the epoch time. I updated your function
UnixDateTime2WinDateTime to take an Epoch time and lUTCGMT flag, an retrun
an array of a human readable date and a time using TString:
FUNCTION Start()
local lUTCGMT := FALSE as LOGIC
local aDateTime as array
aDateTime := UnixDateTime2WinDateTime(1402932982, lUTCGMT)
? aDateTime[1], aDateTime[2]
WAIT
RETURN nil
FUNCTION UnixDateTime2WinDateTime ( nUnixDateTimestamp as int, lUTCGMT as
LOGIC ) as array PASCAL
LOCAL nDays, nSecondsRest1, nSecondsRest2, nSecondsRest3 , nHoursTemp,
nMinutesTemp, nSecondsTemp as int
LOCAL dWinDate as date
LOCAL s1, s2 as _WINSYSTEMTIME
LOCAL lRet as LOGIC
local d as date
local nHours as int
local nMinutes as int
local nSeconds as int
// ---------------
nDays := nUnixDateTimestamp / 86400
nSecondsRest1 := Mod ( nUnixDateTimestamp , 86400 )
// -----------------------
dWinDate := ConDate ( 1970 , 1 , 1 ) + nDays
// --------------------
nHoursTemp := nSecondsRest1 / 3600
nSecondsRest2 := Mod ( nSecondsRest1 , 3600 )
// -------------------
nMinutesTemp := nSecondsRest2 / 60
nSecondsRest3 := Mod ( nSecondsRest2 , 60 )
// -------------------
nSecondsTemp := nSecondsRest3
IF lUTCGMT
// ref vars
d := ConDate ( Year ( dWinDate ) , Month ( dWinDate ) , Day
(dWinDate ) )
nHours := nHoursTemp
nMinutes := nMinutesTemp
nSeconds := nSecondsTemp
lRet := true
ELSE
s1 := MemAlloc ( _sizeof ( _WINSYSTEMTIME ) )
s2 := MemAlloc ( _sizeof ( _WINSYSTEMTIME ) )
s1.wYear := Year ( dWinDate )
s1.wMonth := Month ( dWinDate )
s1.wDay := Day (dWinDate )
s1.wHour := nHoursTemp
s1.wMinute := nMinutesTemp
s1.wSecond := nSecondsTemp
IF SystemTimeToTzSpecificLocalTime ( null , s1 , s2 )
// ref vars
d := ConDate ( s2.wYear , s2.wMonth , s2.wDay )
nHours := s2.wHour
nMinutes := s2.wMinute
nSeconds := s2.wSecond
lRet := true
ENDIF
MemFree ( s1 )
MemFree ( s2 )
ENDIF
RETURN { dWinDate, TString(nHours*3600 + nMinutes*60 + nSeconds) }
"Karl-Heinz" wrote in message news:c0878rFnl71U1@mid.individual.net...
Hi Jamal,
> I am not using those functions. Any samples on their use would be great.
>
> I was able in getting the the UTC date and time of from the Epoch time.
> The issue right now the local time based on different time zone.
a few months ago we had an unix alert ;-), so i spent some hours in the
sources below. Because the alert went away almost as fast as it raised
further investigations were canceled. But i have the feeling that the
sources must be pretty close ...
There are two DLL imports and two self explaining main functions. Each func
has one optional Parameter "lUTCGMT". Here you can decide if the result will
be either localtime or UTC/GMT.
Let me know how it goes.
regards
Karl-Heinz
---- start ----
_DLL FUNCTION SystemTimeToTzSpecificLocalTime ( lpTimeZoneInformation AS
_WINTIME_ZONE_INFORMATION , lpUniversalTime AS _WINSYSTEMTIME , lpLocalTime
AS _WINSYSTEMTIME ) AS LOGIC PASCAL:Kernel32.SystemTimeToTzSpecificLocalTime
_DLL FUNCTION TzSpecificLocalTimeToSystemTime ( lpTimeZoneInformation AS
_WINTIME_ZONE_INFORMATION , lpLocalTime AS _WINSYSTEMTIME ,lpUniversalTime
AS _WINSYSTEMTIME ) AS LOGIC PASCAL:Kernel32.TzSpecificLocalTimeToSystemTime
FUNCTION WinDateTime2UnixDateTime ( d AS DATE , nHours AS INT , nMinutes AS
INT , nSeconds AS INT , lUTCGMT := FALSE AS LOGIC ) AS INT PASCAL
LOCAL nUnixDateTimestamp, nDays AS INT
LOCAL s1, s2 AS _WINSYSTEMTIME
nUnixDateTimestamp := -1
// -------------------------
nDays := INT ( _CAST , d ) - INT ( _CAST , ConDate ( 1970 , 1 , 1 ) )
IF lUTCGMT
nUnixDateTimestamp := ( nDays * 86400 ) + ( nHours * 3600 ) + (
nMinutes * 60 ) + nSeconds
ELSE
s1 := MemAlloc ( _SIZEOF ( _WINSYSTEMTIME ) )
s2 := MemAlloc ( _SIZEOF ( _WINSYSTEMTIME ) )
s1.wYear := Year ( d )
s1.wMonth := Month ( d )
s1.wDay := Day ( d )
s1.wHour := nHours
s1.wMinute := nMinutes
s1.wSecond := nSeconds
IF TzSpecificLocalTimeToSystemTime ( NULL , s1 , s2 )
nUnixDateTimestamp := ( nDays * 86400 ) + ( s2.wHour * 3600 ) + (
s2.wMinute * 60 ) + s2.wSecond
ENDIF
MemFree ( s1 )
MemFree ( s2 )
ENDIF
RETURN nUnixDateTimestamp
FUNCTION UnixDateTime2WinDateTime ( nUnixDateTimestamp AS INT , d REF DATE ,
nHours REF INT , nMinutes REF INT , nSeconds REF INT , lUTCGMT := FALSE AS
LOGIC ) AS LOGIC PASCAL
LOCAL nDays, nSecondsRest1, nSecondsRest2, nSecondsRest3 , nHoursTemp,
nMinutesTemp, nSecondsTemp AS INT
LOCAL dWinDate AS DATE
LOCAL s1, s2 AS _WINSYSTEMTIME
LOCAL lRet AS LOGIC
// ---------------
nDays := nUnixDateTimestamp / 86400
nSecondsRest1 := Mod ( nUnixDateTimestamp , 86400 )
// -----------------------
dWinDate := ConDate ( 1970 , 1 , 1 ) + nDays
// --------------------
nHoursTemp := nSecondsRest1 / 3600
nSecondsRest2 := Mod ( nSecondsRest1 , 3600 )
// -------------------
nMinutesTemp := nSecondsRest2 / 60
nSecondsRest3 := Mod ( nSecondsRest2 , 60 )
// -------------------
nSecondsTemp := nSecondsRest3
IF lUTCGMT
// ref vars
d := ConDate ( Year ( dWinDate ) , Month ( dWinDate ) , Day (
dWinDate ) )
nHours := nHoursTemp
nMinutes := nMinutesTemp
nSeconds := nSecondsTemp
lRet := TRUE
ELSE
s1 := MemAlloc ( _SIZEOF ( _WINSYSTEMTIME ) )
s2 := MemAlloc ( _SIZEOF ( _WINSYSTEMTIME ) )
s1.wYear := Year ( dWinDate )
s1.wMonth := Month ( dWinDate )
s1.wDay := Day (dWinDate )
s1.wHour := nHoursTemp
s1.wMinute := nMinutesTemp
s1.wSecond := nSecondsTemp
IF SystemTimeToTzSpecificLocalTime ( NULL , s1 , s2 )
// ref vars
d := ConDate ( s2.wYear , s2.wMonth , s2.wDay )
nHours := s2.wHour
nMinutes := s2.wMinute
nSeconds := s2.wSecond
lRet := TRUE
ENDIF
MemFree ( s1 )
MemFree ( s2 )
ENDIF
RETURN lRet
--- end -----
[toc] | [prev] | [next] | [standalone]
| From | "Karl-Heinz" <invalid@invalid.invalid> |
|---|---|
| Date | 2014-06-17 08:49 +0200 |
| Message-ID | <c0a6snF5vg6U2@mid.individual.net> |
| In reply to | #6968 |
Hi Jamal, > Thanks! Your code works great with some changes since my interest is in > returning the Date and Time from the epoch time. I updated your function > UnixDateTime2WinDateTime to take an Epoch time and lUTCGMT flag, an > retrun an array of a human readable date and a time using TString: Glad to know the code also works in other timezones without the need of additional api calls and/or timezone calculations. regards Karl-Heinz
[toc] | [prev] | [next] | [standalone]
| From | Camille Kater <katercam@pt.lu> |
|---|---|
| Date | 2014-06-16 17:26 +0200 |
| Message-ID | <1402933274_5@vo.lu> |
| In reply to | #6961 |
Hi Karl-Heinz, I would be very interested in those VO functions. Thanks Camille On 15/06/2014 18:27, Karl-Heinz wrote: > Hi Jamal, > >> I wrote some VO function to do the Unix Epoch time conversion which I >> am still testing for accuracy for different time zones and daylight >> savings. I did not have to use the GetTimeZoneDiff(). > > yes, i doubt that GetTimeZoneDiff() does anything useful. Assuming the > func should return the bias in hours, it should return in a german > environment -2, (UTC+01:00 + 1 hour daylight ). But if it would work as > one might expect it would fail in timezones like "Adelaide UTC+09:30 ". > In such cases the minutes are truncated because GetTimeZoneDiff() is > declared as INT. Anyway, are you using in your VO code > "SystemTimeToTzSpecificLocalTime" and "TzSpecificLocalTimeToSystemTime" > to calc unix- <> windows-datetimestamps ? It seems that both funcs do > not require any TimeZone calculations, and that they are smart enough to > use automatically the correct bias on a given date. If you are > interested i´ll put some VO snippets based on both funcs together. > > regards > Karl-Heinz >
[toc] | [prev] | [next] | [standalone]
| From | "Jamal" <someone@example.com> |
|---|---|
| Date | 2014-06-16 14:08 -0400 |
| Message-ID | <lnnbr0$9ku$1@speranza.aioe.org> |
| In reply to | #6967 |
Hi Camille,
Based on Karl-Heinz functions, here is some code that may help. See my other
post with the modifications.
The sample below returns both current Epoch Time and todays's date and
current time.
How does it work for you?
Jamal
FUNCTION Start()
TestEpoch()
WAIT
return nil
function TestEpoch() as void pascal
local nHours as int
local nMinutes as int
local nSeconds as int
local aDateTime as array
local iEpoch as int
local cTime24 as string
cTime24 := Time24()
nHours := Val(SubStr3(cTime24, 1,2))
nMinutes := Val(SubStr3(cTime24, 4,5))
nSeconds := Val(SubStr3(cTime24, 6,7))
iEpoch := WinDateTime2UnixDateTime(Today(), nHours, nMinutes,
nSeconds, false)
? "Epoch Time", iEpoch
aDateTime := UnixDateTime2WinDateTime(iEpoch, false)
? "UTC/GMT Time", aDateTime[1], aDateTime[2]
aDateTime := UnixDateTime2WinDateTime(iEpoch, true)
? "Local Time: ", aDateTime[1], aDateTime[2]
RETURN
"Camille Kater" wrote in message news:1402933274_5@vo.lu...
Hi Karl-Heinz,
I would be very interested in those VO functions.
Thanks
Camille
On 15/06/2014 18:27, Karl-Heinz wrote:
> Hi Jamal,
>
>> I wrote some VO function to do the Unix Epoch time conversion which I
>> am still testing for accuracy for different time zones and daylight
>> savings. I did not have to use the GetTimeZoneDiff().
>
> yes, i doubt that GetTimeZoneDiff() does anything useful. Assuming the
> func should return the bias in hours, it should return in a german
> environment -2, (UTC+01:00 + 1 hour daylight ). But if it would work as
> one might expect it would fail in timezones like "Adelaide UTC+09:30 ".
> In such cases the minutes are truncated because GetTimeZoneDiff() is
> declared as INT. Anyway, are you using in your VO code
> "SystemTimeToTzSpecificLocalTime" and "TzSpecificLocalTimeToSystemTime"
> to calc unix- <> windows-datetimestamps ? It seems that both funcs do
> not require any TimeZone calculations, and that they are smart enough to
> use automatically the correct bias on a given date. If you are
> interested i´ll put some VO snippets based on both funcs together.
>
> regards
> Karl-Heinz
>
[toc] | [prev] | [next] | [standalone]
| From | Camille Kater <katercam@pt.lu> |
|---|---|
| Date | 2014-06-17 09:30 +0200 |
| Message-ID | <1402991069_7@vo.lu> |
| In reply to | #6969 |
Hi Jamal, Many thanks. It works for me. I can extract the date/time from a Unix timestamp I got via mail. Now I must do the inverse: translate a date/time into a Unix timestamp in order to reply to the mail. How can I do that ? Again many thanks for your help. Camille On 16/06/2014 20:08, Jamal wrote: > Hi Camille, > > Based on Karl-Heinz functions, here is some code that may help. See my > other post with the modifications. > > The sample below returns both current Epoch Time and todays's date and > current time. > > How does it work for you? > > Jamal > > > FUNCTION Start() > TestEpoch() > WAIT > > return nil > > function TestEpoch() as void pascal > > local nHours as int > local nMinutes as int > local nSeconds as int > local aDateTime as array > local iEpoch as int > local cTime24 as string > > cTime24 := Time24() > nHours := Val(SubStr3(cTime24, 1,2)) > nMinutes := Val(SubStr3(cTime24, 4,5)) > nSeconds := Val(SubStr3(cTime24, 6,7)) > > iEpoch := WinDateTime2UnixDateTime(Today(), nHours, nMinutes, > nSeconds, false) > > ? "Epoch Time", iEpoch > > aDateTime := UnixDateTime2WinDateTime(iEpoch, false) > > ? "UTC/GMT Time", aDateTime[1], aDateTime[2] > > aDateTime := UnixDateTime2WinDateTime(iEpoch, true) > ? "Local Time: ", aDateTime[1], aDateTime[2] > > > RETURN > > "Camille Kater" wrote in message news:1402933274_5@vo.lu... > > Hi Karl-Heinz, > > I would be very interested in those VO functions. > Thanks > > Camille > > > On 15/06/2014 18:27, Karl-Heinz wrote: >> Hi Jamal, >> >>> I wrote some VO function to do the Unix Epoch time conversion which I >>> am still testing for accuracy for different time zones and daylight >>> savings. I did not have to use the GetTimeZoneDiff(). >> >> yes, i doubt that GetTimeZoneDiff() does anything useful. Assuming the >> func should return the bias in hours, it should return in a german >> environment -2, (UTC+01:00 + 1 hour daylight ). But if it would work as >> one might expect it would fail in timezones like "Adelaide UTC+09:30 ". >> In such cases the minutes are truncated because GetTimeZoneDiff() is >> declared as INT. Anyway, are you using in your VO code >> "SystemTimeToTzSpecificLocalTime" and "TzSpecificLocalTimeToSystemTime" >> to calc unix- <> windows-datetimestamps ? It seems that both funcs do >> not require any TimeZone calculations, and that they are smart enough to >> use automatically the correct bias on a given date. If you are >> interested i´ll put some VO snippets based on both funcs together. >> >> regards >> Karl-Heinz >> >
[toc] | [prev] | [next] | [standalone]
| From | "Jamal" <someone@example.com> |
|---|---|
| Date | 2014-06-17 10:37 -0400 |
| Message-ID | <lnpjs5$cg5$1@speranza.aioe.org> |
| In reply to | #6972 |
Hi Camille, >> Now I must do the inverse: translate a date/time into a Unix timestamp in order to reply to the mail. How can I do that ? >> It should be easy to handle. First, determine how your date/time is formatted, then parse it and pass the arguments to: iEpoch := WinDateTime2UnixDateTime(dDate, nHours, nMinutes, nSeconds, false) See the test from previous post for a sample where I passed today's date and current time. You can also [rewrite] the WinDateTime2UnixDateTime() to take a Date/Time as string and parse it (substr) within the function to make it more modular. iEpoch := WinDateTime2UnixDateTime(cDateTime, false) Jamal "Camille Kater" wrote in message news:1402991069_7@vo.lu... Hi Jamal, Many thanks. It works for me. I can extract the date/time from a Unix timestamp I got via mail. Now I must do the inverse: translate a date/time into a Unix timestamp in order to reply to the mail. How can I do that ? Again many thanks for your help. Camille On 16/06/2014 20:08, Jamal wrote: > Hi Camille, > > Based on Karl-Heinz functions, here is some code that may help. See my > other post with the modifications. > > The sample below returns both current Epoch Time and todays's date and > current time. > > How does it work for you? > > Jamal > > > FUNCTION Start() > TestEpoch() > WAIT > > return nil > > function TestEpoch() as void pascal > > local nHours as int > local nMinutes as int > local nSeconds as int > local aDateTime as array > local iEpoch as int > local cTime24 as string > > cTime24 := Time24() > nHours := Val(SubStr3(cTime24, 1,2)) > nMinutes := Val(SubStr3(cTime24, 4,5)) > nSeconds := Val(SubStr3(cTime24, 6,7)) > > iEpoch := WinDateTime2UnixDateTime(Today(), nHours, nMinutes, > nSeconds, false) > > ? "Epoch Time", iEpoch > > aDateTime := UnixDateTime2WinDateTime(iEpoch, false) > > ? "UTC/GMT Time", aDateTime[1], aDateTime[2] > > aDateTime := UnixDateTime2WinDateTime(iEpoch, true) > ? "Local Time: ", aDateTime[1], aDateTime[2] > > > RETURN > > "Camille Kater" wrote in message news:1402933274_5@vo.lu... > > Hi Karl-Heinz, > > I would be very interested in those VO functions. > Thanks > > Camille > > > On 15/06/2014 18:27, Karl-Heinz wrote: >> Hi Jamal, >> >>> I wrote some VO function to do the Unix Epoch time conversion which I >>> am still testing for accuracy for different time zones and daylight >>> savings. I did not have to use the GetTimeZoneDiff(). >> >> yes, i doubt that GetTimeZoneDiff() does anything useful. Assuming the >> func should return the bias in hours, it should return in a german >> environment -2, (UTC+01:00 + 1 hour daylight ). But if it would work as >> one might expect it would fail in timezones like "Adelaide UTC+09:30 ". >> In such cases the minutes are truncated because GetTimeZoneDiff() is >> declared as INT. Anyway, are you using in your VO code >> "SystemTimeToTzSpecificLocalTime" and "TzSpecificLocalTimeToSystemTime" >> to calc unix- <> windows-datetimestamps ? It seems that both funcs do >> not require any TimeZone calculations, and that they are smart enough to >> use automatically the correct bias on a given date. If you are >> interested i´ll put some VO snippets based on both funcs together. >> >> regards >> Karl-Heinz >> >
[toc] | [prev] | [next] | [standalone]
| From | Camille Kater <katercam@pt.lu> |
|---|---|
| Date | 2014-06-18 09:34 +0200 |
| Message-ID | <1403077709_9@vo.lu> |
| In reply to | #6975 |
Hi Jamal, Thanks, everything's working now. Thanks also to Karl-Heinz. Camille
[toc] | [prev] | [next] | [standalone]
| From | "Karl-Heinz" <invalid@invalid.invalid> |
|---|---|
| Date | 2014-06-17 08:47 +0200 |
| Message-ID | <c0a6smF5vg6U1@mid.individual.net> |
| In reply to | #6967 |
Hi Camille, > I would be very interested in those VO functions. a few messages above you´ll find my initial code snippets. regards Karl-Heinz
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.clipper.visual-objects
csiph-web