
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Calculate the amount of business time between two times based on any arbitrary work calendar.
gem 'time_clock'
Once you've set a default calendar, any Time
instance will have a few helpful methods.
Time.now.business_seconds_until(Time.now + 1.day)
=> 43200
Time.now.business_minutes_until(Time.now + 1.day)
=> 720
Time.now.business_hours_until(Time.now + 1.day)
=> 12
Also, Date
and Time
instances will have a method that calculates how many work dates there are between two times or dates.
Date.today.business_days_until(Date.today)
=> 1
You can also make custom calendars for each calculation (see Calendars section for details).
Things you may like about this library:
Time
, including mixed types.Set a default_calendar
for all comparisons to use for their calculation.
For example, in a Rails initializer:
# Time zones aren't required. Used here to make it easier to read.
time_zone = ActiveSupport::TimeZone.new("America/Chicago")
# The TimeClock::Calendar object stores the shifts for the business calendar.
calendar = TimeClock::Calendar.new
# Add all the work days (or individual shifts) to the calendar
# This example adds non week days between 6am and 6pm.
(Date.new(2011,1,1)..Date.new(2015,1,1)).each do |date|
next unless (1..5).cover?(date.wday)
calendar.add_shift(
TimeClock::Shift.new(
time_zone.local(date.year,date.month,date.day,6),
time_zone.local(date.year,date.month,date.day,18),
)
)
end
# Set the default calendar
TimeClock.default_calendar = calendar
If you want to use a separate calendar for an individual calculation, use a TimeClock::Comparison
instance. Refer back to the configuration example to understand how to build a calendar.
TimeClock::Comparison.new(Time.now, Time.now + 1.day, custom_calendar).seconds
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that time_clock demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.