Skip to content

Commit

Permalink
Document 'duration' tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
aufdemrand committed Jul 22, 2013
1 parent 5e8b524 commit c5d2093
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/java/net/aufdemrand/denizen/objects/Duration.java
Expand Up @@ -279,18 +279,34 @@ public String getAttribute(Attribute attribute) {

if (attribute == null) return null;

// <--
// <d@duration.in_seconds> -> Element(number)
// returns the number of seconds in the Duration.
// -->
if (attribute.startsWith("in_seconds"))
return new Element(String.valueOf(seconds))
.getAttribute(attribute.fulfill(1));

// <--
// <d@duration.in_seconds> -> Element(number)
// returns the number of hours in the Duration.
// -->
if (attribute.startsWith("in_hours"))
return new Element(String.valueOf(seconds / 1800))
.getAttribute(attribute.fulfill(1));

// <--
// <d@duration.in_minutes> -> Element(number)
// returns the number of minutes in the Duration.
// -->
if (attribute.startsWith("in_minutes"))
return new Element(String.valueOf(seconds / 60))
.getAttribute(attribute.fulfill(1));

// <--
// <d@duration.in_ticks> -> Element(number)
// returns the number of ticks in the Duration. (20t/second)
// -->
if (attribute.startsWith("in_ticks"))
return new Element(String.valueOf(getTicksAsInt()))
.getAttribute(attribute.fulfill(1));
Expand All @@ -315,6 +331,11 @@ public String getAttribute(Attribute attribute) {
.getAttribute(attribute.fulfill(1));
}

// <--
// <d@duration.value> -> Element
// returns the value of the duration, in the best format
// possible.
// -->
if (attribute.startsWith("value")) {
if (seconds % 43200 == 0)
return new Element(seconds / 86400 + "d")
Expand Down

0 comments on commit c5d2093

Please sign in to comment.