Thread overview
[Issue 8411] New: core.time: No easy way to check if Duration is empty
Jul 22, 2012
Vladimir Panteleev
Jan 24, 2013
Jonathan M Davis
Jan 25, 2013
Vladimir Panteleev
July 22, 2012
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


--- Comment #0 from Vladimir Panteleev <thecybershadow@gmail.com> 2012-07-22 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: -------
January 24, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8411


Jonathan M Davis <jmdavisProg@gmx.com> changed:

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


--- Comment #1 from Jonathan M Davis <jmdavisProg@gmx.com> 2013-01-24 12:36:20 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: -------
January 25, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8411



--- Comment #2 from Vladimir Panteleev <thecybershadow@gmail.com> 2013-01-25 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: -------