Skip to content

Commit

Permalink
add TimeTag.from_now convenience tag
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Dec 13, 2020
1 parent f52997e commit e245a65
Showing 1 changed file with 16 additions and 1 deletion.
Expand Up @@ -516,11 +516,26 @@ public static void registerTags() {
return new TimeTag(object.millis() - toSub.getMillis(), object.instant.getZone());
});

// <--[tag]
// @attribute <TimeTag.from_now>
// @returns DurationTag
// @description
// Returns the DurationTag between this time object and the real current system time.
// The value will always be positive.
// This is equivalent to the absolute value of ".duration_since[<util.time_now>]", and exists primarily as a convenience tag.
// For example, a TimeTag for Tuesday will return a DurationTag of '1d' when the tag is used on a Monday.
// A TimeTag for Sunday will also return a DurationTag of '1d' when used on a Monday.
// If positive/negative differences are required, consider instead using <@link tag TimeTag.duration_since>.
// -->
registerTag("from_now", (attribute, object) -> {
return new DurationTag(Math.abs(object.millis() - now().millis()) / 1000.0);
});

// <--[tag]
// @attribute <TimeTag.duration_since[<time>]>
// @returns DurationTag
// @description
// Returns the DurationTime that passed between the input time and this time.
// Returns the DurationTag that passed between the input time and this time.
// That is, a.duration_since[b] returns (a - b).
// For example, a time on Monday, .duration_since[a time on Sunday], will return '1d'.
// -->
Expand Down

0 comments on commit e245a65

Please sign in to comment.