www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8411] New: core.time: No easy way to check if Duration is empty

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

           Summary: core.time: No easy way to check if Duration is empty
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: druntime
        AssignedTo: nobody puremagic.com
        ReportedBy: thecybershadow gmail.com



06:46:38 PDT ---
The simplest way to check for an empty Duration seems to be:

if (!duration.total!"hnsecs"()) { ... }

I suggest either implementing an isEmpty property (given that there already is
an isNegative property), or implement opCast!bool so that the following will
work:

if (!duration) { ... }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 22 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8411


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com



PST ---
We now have Duration.zero, so

if(duration != Duration.zero)

will work as will

if(duration != Duration.init)

But there's no such thing as an "empty" duration. All durations have a value,
and they aren't ranges or containers. It makes as much sense to have an isEmpty
property on a Duration as it does to have it on an int.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 24 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8411




09:13:59 EET ---
An interval has a .empty property, though.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 24 2013