Results 1 to 3 of 3

Thread: OS Configuration and DST

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    2

    OS Configuration and DST

    Hello,

    i'm working with the C++ RogueWave-Libary in a project relevant to security. For that reason i need to know the operating system's influence on the RWZone::local() under Linux and Windows.

    When using RWZone::local( &RWZone:: os () ); the Daylight saving time rule should be set according to the underlying operating system, the documentation says. But i realized that, under Linux, a slight change of the TZ-variable from "MET-1METDST,M3.5.0,M10.5.0" to "MET-1METDST" leads to a change of the DST (North American rules) which is not wished.

    What part of Windows and Linux configuration (only TZ-variable?) has influence on the DST-rules used with the "RWZone::local( &RWZone:: os () );" call?

  2. #2
    Junior Member
    Join Date
    Apr 2011
    Posts
    1

    Re: OS Configuration and DST

    The RWZone::os() call defers to the C library to determine the time zone and daylight saving time rules in use by your operating system. More specifically, it uses one or more of the following functions-- localtime(), localtime_r(), mktime(), gettimeofday() and tzset(). Any changes in your environment that affect the behavior of these functions will affect the behavior of RWZone::os().

    From the man pages for localtime() on a Linux system...

    The localtime() function converts the calendar time timep to broken-time representation, expressed relative to the user's specified timezone. The function acts as if it called tzset(3) and sets the external variables tzname with information about the current timezone, timezone with the difference between Coordinated Universal Time (UTC) and local standard time in seconds, and daylight to a non-zero value if daylight savings rules apply during some part of the year.
    And the documentation for tzset()...

    The tzset() function initializes the tzname variable from the TZ environment variable. This function is automatically called by the other time conversion functions that depend on the timezone. In a System-V-like environment it will also set the variables timezone (seconds West of GMT) and daylight (0 if this timezone does not have any daylight saving time rules, non-zero if there is a time during the year when daylight saving time applies).

    If the TZ variable does not appear in the environment, the tzname variable is initialized with the best approximation of local wall clock time, as specified by the tzfile(5)-format file localtime found in the system timezone directory (see below). (One also often sees /etc/localtime used here, a symlink to the right file in the system timezone directory.)

    If the TZ variable does appear in the environment but its value is empty or its value cannot be interpreted using any of the formats specified below, Coordinated Universal Time (UTC) is used.
    It should be noted that RWZone::os() only reads the system timezone once, the first time it is called. All subsequent calls use the cached results.

    If you are concerned with the security of using time zone information derived from the operating system, you should consider using RWZone::utc() or RWZoneSimple to get a zone that doesn't depend on the environment or operating system configuration.

    Travis

  3. #3
    Junior Member
    Join Date
    Apr 2011
    Posts
    2

    Re: OS Configuration and DST

    Thanks! That explains it very well for me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •