realbasic-nug
[Top] [All Lists]

Another OS X libc Declare Questions

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Another OS X libc Declare Questions
From: Tim Jones <tjmac at tolisgroup dot com>
Date: Tue, 31 Aug 2004 14:03:25 -0700
Delivered-to: realbasic-nug at lists dot realsoftware dot com
Hi Folks,

I've started expanding my UnixTime module to include all of the various time functions and I've run into one that I can't get to work - mktime. According to the manpage (and it works in C), the mktime function takes a tm_struct pointer and returns a long (time_t).

To experiment, I call time() and place the result in a tm MemoryBlock (which works). I then pass the resulting tm.long(0) to localtime and I get back a valid tm_struct in the 44 byte tmStruct memoryblock. I can parse the 11 members of the tmStruct and all of the values are valid. If I then pass that tmStruct back to mktime, I always get a 0 returned.

Here's my MakeTime function:

Protected Function MakeTime(ts As MemoryBlock) As Integer
  Dim s As Integer

Declare Function mktime Lib "/usr/local/libc.dylib" (t As Ptr) As Integer

Debug.Print "mktime is passed: " + Str(ts.Long(16)) + " " + Str(ts.Long(12)) + " " + _ Str(ts.Long(8)) + ":" + Str(ts.Long(4)) + ", " + Str(ts.Long(20) + 1900)

  s = mktime(ts)
  Debug.Print "mktime result = " + Format(s, "##")
  Return s

End Function

Of course, normally, I'd just return mktime(ts) rather than go through the assignment, but I'm trying to determine where this is failing. Also, it's not really failing as a failure on the part of mktime is supposed to return -1.

Any thoughts?

Tim
--
Tim Jones                                       tjmac at tolisgroup dot com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>