[Issue 14792] New: Add function to convert from time_t to SysTime

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Jul 9 15:51:56 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14792

          Issue ID: 14792
           Summary: Add function to convert from time_t to SysTime
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: issues.dlang at jmdavisProg.com

SysTime currently has toUnixTime to convert to unix time (which is what time_t
usually is, though apparently, the C standard does not require it to be unix
time, and in the case of dmc, it isn't). However, SysTime does not provide a
way to convert from unix time to SysTime. We have stdTimeToUnixTime and
unixTimeToStdTime to do the conversions of the integral values, but while
toUnixTime wraps stdTimeToUnixTime for you, in the case of converting to from
unix time, you currently have to do something like

auto st = SysTime(unixTimeToStdTime(myTimeT));

It's been requested on multiple occasions that we have a function like
toUnixTime except that it does the conversion in the opposite direction, thus
allowing for code like

auto st = SysTime.fromUnixTime(myTimeT);

--


More information about the Digitalmars-d-bugs mailing list