www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4944] New: Missing tzname even though we have tzset

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4944

           Summary: Missing tzname even though we have tzset
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: druntime
        AssignedTo: sean invisibleduck.org
        ReportedBy: jmdavisProg gmx.com



PDT ---
We have tzset in core.stdc.time. Missing from there are daylight and tzname
(which are what tzset sets). Personally, I don't think that daylight matters
much since you can get that easily enough from a tm. However, the lack of
tzname is a bit of a problem. Yes, tm has tm_zone which has the _current_ value
from tzname (be it tzname[0] or tzname[2]), but as far as I can tell, there is
no way at present to get both of the values of tzname without either directly
adding the appropriate C stuff yourself or by trying tms for multiple dates to
determine the second tzname value.

tzname in core.sys.posix.time but commented out - along with tzset and a
comment that they're in core.stdc.time, but only tzset is there, not tzname.

So, ideally, tzname would be added.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 26 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4944




PDT ---
Okay. daylight does matter. I misread the man page, thinking that it was
whether daylight savings time is in effect, but it's not - it's whether the
current timezone _has_ DST, which is definitely useful.

In any case, a declaration of

extern(C)
{
    extern __gshared char* tzname[2];
    extern __gshared int   daylight;
}


in my code seems to do the trick, but it really should be in core.stdc.time.
Also, the int on daylight makes me moderately nervous since int's size can vary
in C/C++, but there does not appear to be a c_int declared in druntime, only
c_long, otherwise I'd use that.

Looking further in core.sys.posix.time, I see a daylight (which may be the
daylight in question) and a timezone which is a c_long (whatever that's for),
but in spite of finding daylight, I still don't see tzname anywhere.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 26 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4944


Sohgo Takeuchi <sohgo sohgo.dyndns.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sohgo sohgo.dyndns.org



JST ---


Just for your information.

FreeBSD and OpenBSD do not have such a global variable of "daylight". (But
NetBSD has.)

On the other hand, {Free,Open,Net}BSD have the "char *tzname[2]".

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 18 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4944


Sean Kelly <sean invisibleduck.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED



---
tzset and tzname aren't standard C so they really shouldn't be in core.stdc. 
tzset was one of the few nonstandard routines added anyway because it's so
commonly used, even on Windows.  I'll see about defining tzname in
core.sys.posix though.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 18 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4944




PST ---
Well, looking at the man page for tzset... tzset, tzname, timezone, and
daylight are all standard posix. So, I don't know why daylight wouldn't be on
some of the BSDs. Of course, clock_gettime is also standard posix and Mac OS X
doesn't have it, so I don't know how much you can really rely on posix stuff
being on posix systems.

As for core.stdc.time, you're right. That's the wrong place to put it. It's
posix, not standard C. It should be in the appropriate posix module. But tzset,
tzname, timezone, and daylight should all be defined if they're on the OS. And
since they're all posix, you would _think_ that they'd be on all Posix systems,
but I guess that we can't declare daylight on FreeBSD. Bleh. What good is Posix
if it isn't followed?

In any case, once they're in druntime, I can remove them from std.datetime, and
I'm obviously going to have to see what I do with daylight in there to make
sure that it's not going to be broken on FreeBSD.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 18 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4944




PST ---
I see that core.sys.posix.time currently has daylight for just linux and
timezone for linux, OSX, FreeBSD, and Solaris (I didn't even know that there
_was_ a Solaris version of anything in druntime!). tzname isn't declared for
any of them. Personally, I'd argue for moving tzset to core.sys.posix.time and
the _* functions such as _tzset to the appropriate place in the Windows
hierarchy instead of having them in core.stdc.* simply because they _aren't_
standard C, but that's up to Sean I guess.

In any case, I notice that daylight is not declared in core.sys.posix.time for
OSX, and std.datetime _has_ been declaring it for all of Posix (hence bug

pretty sure that we can declare daylight for OSX in core.sys.posix.time (we
might want to verify that though). That would actually make that block of
declarations identical on linux and OSX.

But tzname needs to be set on all of them still regardless. Since, I'm having
to fix std.datetime to not require daylight on Posix, I'll remove the
declaration for it from std.datetime (though until OSX is fixed to have
daylight in core, OSX will unfortunately, use the less desirable workaround),
but until tzname is added to druntime, I'll have to leave it declared in
std.datetime.

Actually, I think that I'll create a pull request or two for the appropriate
changes (dividing them up as seems appropriate) and Sean can then pick which
ones he thinks are appropriate.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 19 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4944




PST ---
Ah, I see that Sean has added tzname to druntime now. I'd missed that check-in.
That still leaves the matter of daylight on Mac OS X and whether or not tzset
should be moved, but that fixes the main problem.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 19 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4944


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED



PST ---
Michel Fortin has confirmed that Mac OS X does indeed declare daylight. It
seemed rather silly to create a pull request for just one line of code, so I
just pushed it.

In any case, with Sean adding tzname to core.stdc.time, this bug appears to be
fixed. It would probably, technically be more appropriate to have put tzname in
core.sys.posix.time, but tzset is already in core.stdc.time anyway. The commit
for Seans fix is:

https://github.com/D-Programming-Language/druntime/commit/2860799026c9595785580b876173dc890d22451c

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 20 2011