Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

meskyanichi-timer

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

meskyanichi-timer

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Timer

Timer, a simple plugin that calculates the time between a "start time" and a "end time". Currently Timer has the ability to take a Time object or a timestamp for the start and end times and will calculate the time between these values in days, hours (and days in hours), minutes and seconds! There is also the option to force it to display 2 digits at all times when you are creating a 'non-words' timer, though would display for example "09:34:02" instead of "9:34:2". However, when you aren't forcing the two digits to be displayed you could create a string such as: "7 days, 5 hours, 11 minutes and 56 seconds remaining..".

The output it quite limited, but it also enables you to either extend the class to create your own custom outputs. You can of course choose not to create a whole new class to do this and just generate the strings inside of a specific helper/module, whatever you think is best!

Example #1

New Instance of Timer

t = Timer.new

Set the start time to the current time

t.start_time = Time.now

Set the end time to begin 2010

t.end_time = Time.parse('2010-01-01 00:00:00')

Output Timer

<%= "#{t.days} days, #{t.hours} hours, #{t.minutes} minutes, #{t.seconds} seconds" %>

Outputs

313 days, 0 hours, 12 minutes, 29 seconds

Example #2

New Instance of Timer

t = Timer.new

Set the start time to the current time

t.start_time = Time.now

Set the end time to begin 2010

t.end_time = Time.parse('2010-01-01 00:00:00')

Force Timer to atleast output two digits (the zero's)

t.force_two_digits = true

Output Timer

<%= "#{t.days_in_hours}:#{t.minutes}:#{t.seconds}" %>

#Outputs (Hours:Minutes:Seconds) 7512:09:43

OR

Output Timer

<%= "#{t.hours}:#{t.minutes}:#{t.seconds} in #{t.days} days" %>

#Outputs (Hours:Minutes:Seconds) 00:06:51 in 313 days

Copyright (c) 2009 [Michael van Rooijen], released under the MIT license

FAQs

Package last updated on 11 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc