Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Ever tried to convert your distant friend's or colleague's phrase "OK, let's connect tomorrow at 6 pm my time (GMT+8)" into easily calculatable Ruby code? E.g. what time it would be in your timezone at 18:00 GMT+8? What is your favorite solution? Now it should be that:
TZOffset.parse('GMT+8').local(2016, 10, 20, 18).localtime
# => 2016-10-20 13:00:00 +0300
# or just
TZOffset.parse('+8').local(2016, 10, 20, 18).localtime
# => 2016-10-20 13:00:00 +0300
# Also works with most common timezone abbreviations
TZOffset.parse('CEST').local(2016, 10, 20, 18).localtime
# => 2016-10-20 19:00:00 +0300
In other words, TZOffset
is simple, no-magic, incapsulated abstraction of "time offset".
TZOffset.parse('EET')
# => #<TZOffset +02:00 (EET)>
TZOffset.parse('CDT')
# => [#<TZOffset -05:00 (CDT)>, #<TZOffset -04:00 (CDT)>]
TZOffset.parse('CDT').map(&:description)
# => ["Central Daylight Time (North America)", "Cuba Daylight Time"]
TZOffset.parse('CDT').map(&:region)
# => ["Central", "Cuba"]
# NB: Just "Central", "Eastern" and so on is related to North America in timezones nomenclature
eet = TZOffset.parse('EET')
# => #<TZOffset +02:00 (EET)>
eet.dst?
# => false
eet.opposite
# => #<TZOffset +03:00 (EEST)>
[eet.description, eet.opposite.description]
# => ["Eastern European Time", "Eastern European Summer Time"]
Do your usual routine with gem named tz_offset
(e.g. gem install tz_offset
or add
gem "tz_offset
to your Gemfile
).
Most of it is already shown above!
require 'tz_offset'
off = TZOffset.parse('-02:30')
# => #<TZOffset -02:30>
off.now
# => 2016-10-25 16:07:55 -0230
off.local(2016, 10, 1)
# => 2016-10-01 00:00:00 -0230
eet = TZOffset.parse('EET')
# => #<TZOffset +02:00 (EET)>
eet.now
# => 2016-10-25 20:29:03 +0200
eet.description
# => "Eastern European Time"
eet.region
# => "Eastern European"
eet.opposite
# => #<TZOffset +03:00 (EEST)>
eet.opposite.now
# => 2016-10-25 21:39:26 +0300
# Parsing time string into desired timezone
off = TZOffset.parse('-02:30')
off.parse('2014-10-01 12:30')
# => 2014-10-01 12:30:00 -0230
off.parse('12:30')
# => 2016-10-26 12:30:00 -0230
Victor Shepelev -- extracted from reality project.
MIT.
FAQs
Unknown package
We found that tz_offset 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.