Skip to content

Instantly share code, notes, and snippets.

@lizmat
Created April 29, 2014 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lizmat/11404980 to your computer and use it in GitHub Desktop.
Save lizmat/11404980 to your computer and use it in GitHub Desktop.
Duration primitives
sub term:<1sec>() { Duration.new(1) }
sub term:<1second>() { Duration.new(1) }
sub term:<1min>() { Duration.new(60) }
sub term:<1minute>() { Duration.new(60) }
sub term:<1hour>() { Duration.new( 60 * 60 ) }
sub term:<1day>() { Duration.new( 24 * 60 * 60 ) }
sub term:<1week>() { Duration.new( 7 * 24 * 60 * 60 ) }
sub postfix:<secs>($secs) { Duration.new($secs) }
sub postfix:<seconds>($seconds) { Duration.new($seconds) }
sub postfix:<mins>($mins) { Duration.new( 60 * $mins ) }
sub postfix:<minutes>($minutes) { Duration.new( 60 * $minutes ) }
sub postfix:<hours>($hours) { Duration.new( 60 * 60 * $hours ) }
sub postfix:<days>($days) { Duration.new( 24 * 60 * 60 * $days ) }
sub postfix:<weeks>($weeks) { Duration.new( 7 * 24 * 60 * 60 * $weeks ) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment