Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
The date by example lets you format dates e.g. "January 02, 2006" using an example as a format string e.g "January 02, 2006" instead of the classic strftime format specifier e.g. "%B %d, %Y". The date by example adds:
String#to_strfime
Date#format
Time#format
DateTime#format
NilClass#format
to the built-in classes.
String#to_strftime
Methodclass String
def to_strftime() DateByExample.to_strftime( self ); end
end
The new String#to_strftime
method auto-builds the strftime
format string
from an example date:
require 'date/formatter'
p 'January 02, 2006'.to_strftime #=> "%B %d, %Y"
p 'Mon, Jan 02'.to_strftime #=> "%a, %b %d"
p '2 Jan 2006'.to_strftime #=> "%-d %b %Y"
p 'Monday, January 2, 2006'.to_strftime #=> "%A, %B %-d, %Y"
p 'Mon, Jan 02 3:00'.to_strftime #=> "%a, %b %d %-H:%M"
p '2 Mon 2006 03:00'.to_strftime #=> "%-d %b %Y %H:%M"
Date#format
Methodclass Date
def format( spec ) self.strftime( spec.to_strftime ); end
end
The new Date#format
method formats the date like the passed in example:
date = Date.today ## test run on 2020-02-09
p date.format( 'January 02, 2006' ) #=> "February 09, 2020"
p date.format( 'Mon, Jan 02' ) #=> "Sun, Feb 09"
p date.format( '2 Jan 2006' ) #=> "9 Feb 2020"
p date.format( 'Monday, January 2, 2006' ) #=> "Sunday, February 9, 2020"
Time#format
Methodclass Time
def format( spec ) self.strftime( spec.to_strftime ); end
end
The new Time#format
method formats the time like the passed in example:
time = Time.now ## test run on 2020-02-09 00:00
p time.format( 'January 02, 2006' ) #=> "February 09, 2020"
p time.format( 'Mon, Jan 02' ) #=> "Sun, Feb 09"
p time.format( '2 Jan 2006' ) #=> "9 Feb 2020"
p time.format( 'Monday, January 2, 2006' ) #=> "Sunday, February 9, 2020"
p time.format( 'Mon, Jan 02 3:00' ) #=> "Sun, Feb 09 0:00"
p time.format( '2 Mon 2006 03:00' ) #=> "9 Sun 2020 00:00"
NilClass#format
Methodclass NilClass
def format( spec ) ''; end
end
For convenience the new NilClass#format
will catch format calls on nil
and NOT crash but return an empty string
following the NilClass#to_s
example:
p nil.format( 'January 02, 2006' ) #=> ""
p nil.to_s #=> ""
The date-formatter
scripts are dedicated to the public domain.
Use it as you please with no restrictions whatsoever.
Send them along to the wwwmake Forum/Mailing List. Thanks!
FAQs
Unknown package
We found that date-formatter 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 malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.