View source code Display the source code in std/datetime.d from which this page was generated on github. Improve this page Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone. Page wiki View or edit the community-maintained wiki page associated with this page.

std.datetime.sys_time.frac_secs - multiple declarations

Function SysTime.fracSecs

Fractional seconds past the second (i.e. the portion of a SysTime which is less than a second).

Prototype

void fracSecs(
  Duration fracSecs
) @property @safe;

Parameters

NameDescription
fracSecs The duration to set this SysTime's fractional seconds to.

Throws

DateTimeException if the given duration is negative or if it's greater than or equal to one second.

Example

auto st = SysTime(DateTime(1982, 4, 1, 20, 59, 22));
assert(st.fracSecs == Duration.zero);

st.fracSecs = msecs(213);
assert(st.fracSecs == msecs(213));

st.fracSecs = hnsecs(1234567);
assert(st.fracSecs == hnsecs(1234567));

// SysTime has a precision of hnsecs (100 ns), so nsecs are
// going to be truncated.
st.fracSecs = nsecs(123456789);
assert(st.fracSecs == hnsecs(1234567));


Function SysTime.fracSecs

Fractional seconds past the second (i.e. the portion of a SysTime which is less than a second).

Prototype

Duration fracSecs() nothrow @property @safe const;

Example

auto dt = DateTime(1982, 4, 1, 20, 59, 22);
assert(SysTime(dt, msecs(213)).fracSecs == msecs(213));
assert(SysTime(dt, usecs(5202)).fracSecs == usecs(5202));
assert(SysTime(dt, hnsecs(1234567)).fracSecs == hnsecs(1234567));

// SysTime and Duration both have a precision of hnsecs (100 ns),
// so nsecs are going to be truncated.
assert(SysTime(dt, nsecs(123456789)).fracSecs == nsecs(123456700));


Authors

Jonathan M Davis and Kato Shoichi

License

Boost License 1.0.

Comments