www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14792] New: Add function to convert from time_t to SysTime


          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 puremagic.com
          Reporter: issues.dlang 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);

Jul 09 2015