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

enterprise_time_extensions

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enterprise_time_extensions

  • 1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

h1. Enterprise Time Extensions

Enterprisey extensions to Ruby's Time class. How else will you know when it's OK to stop avoiding work, and you can actually leave work?

Example:

h2. Un-Fun, All-Business Instance Method Examples

  
    t = Time.now #=> Fri Jan 09 22:12:31 0100 2009
    # Enterprisey methods in action!:
    t.after_hours? #=> false
    t.holiday? #=> false

    t = Time.local(2009, 12, 25) #=>  Fri Dec 25 00:00:00 0100 2009
    t.after_hours? #=> true -- because it's a holiday
    t.holiday? #=> true -- I told you!

    t = Time.local(2009, 1, 9, 18, 30) #=> Fri Jan 09 18:30:00 0100 2009
    t.after_hours? #=> true -- Business hours are 8AM to 6PM ... SHARP!
    t.holiday? #=> false
  

There are question mark methods for the holidays that are paid-time-off for slaves of The Enterprise.

  • new_years_day?
  • mlk_jr_day?
  • memorial_day?
  • independence_day?
  • labor_day?
  • thanksgiving?
  • christmas_day?

If you need/want more, let me know! You're welcome to do it yourself, if you wish.

h2. Frank, Straight-Shooting Class Methods

  
  # Countdown to the next football game?
  Time.next_sunday #=> Sun Jan 11 00:00:00 0100 2009
  # The big one:
  Time.nth_wday(3, 6, 7, 2009) #=> Sat Jul 18 00:00:00 0200 2009
  

Time::nth_wday could probably use some explanation. Time::nth_wday will find the 'nth' week day of a month. Above, we found the 3th (hehe) Saturday of July 2009. This is actually used often in the various holiday methods from above. For instance, Thanksgiving is on the 4th Thursday of November. The method looks like this:

  
  def self.nth_wday(n, wday, month, year)
  # ...
  end
  

Enjoy!

(I feel obligated to tell you, honestly, that the environment at nFrame is far removed from the usual negative implications of the word 'Enterprise'. It's quite nice, actually. Oh, and we only have like 40 total employees.)

FAQs

Package last updated on 25 Jul 2009

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