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

time_only

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

time_only

  • 1.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

TimeOnly

A simple class for handling time and only time. No dates, no time zones, just good old time of day. At the moment, TimeOnly only supports resolution to 1 second.

Installation

Add this line to your application's Gemfile:

gem 'time_only'

And then execute:

$ bundle

Or install it yourself as:

$ gem install time_only

Usage

TimeOnly attempts to implement the same functionality as Time where it makes sense to do so.

require 'time_only'

time = TimeOnly.new(8, 0, 2)
# => '08:00:02'

time.hour
# => 8

time.min
# => 0

time.sec
# => 2

time.strftime('The time is %-l:%M:%S %P.')
# => 'The time is 1:03:56 pm.'

# adding times rolls the time forward and returns a new TimeOnly
TimeOnly.new(23, 59, 59) + 3
# => '00:00:02'
    
morning_flights, afternoon_flights = departure_times.partition(&:am?)

current_time = TimeOnly.now

# and many more...

Method documentation can be found in the source.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

FAQs

Package last updated on 04 Dec 2012

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