
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
A simple date class that can be used to store partial date values in a single column/attribute. An example use case would include an archive, or catalogue entry where the complete date is unknown. Year is optional and can be a negative value. Month and day are optional, but month must be set before day.
PartialDate::Date uses a 30 bit register as the backing store for date instances, and bit fiddling to get or set year, month and day values. As such it will perform well in a loop or collection of date objects.
Use date.value
to get or set an Integer value that can be used to rehydrate a date object, or save the date value to a persistence store in a readable Integer form e.g. 20121201 for 2012 December 01.
PartialDate::Date#to_s has the following built-in formats:
d.to_s :default => "%Y-%m-%d"
d.to_s :short :short => "%d %m %Y"
d.to_s :medium :medium => "%d %b %Y"
d.to_s :long :long => "%d %B %Y"
d_to_s :number :number => "%Y%m%d"
Custom formatters can be specified using the following:
%Y - Year with century (can be negative, 4 digits at least)
-0001, 0000, 1995, 2009, 14292, etc.
%m - Month of the year, zero-padded (01..12)
%B - The full month name ('January')
%b - The abbreviated month name ('Jan')
%d - Day of the month, zero-padded (01..31)
%e - Day of the month, blank-padded ( 1..31)
require 'partial-date'
# Default initializer
date = PartialDate::Date.new
# =>
date.value
# => 0
# Initialize from a block of integers
date = PartialDate::Date.new {|d| d.year = 2012; d.month = 01}
# => 2012-01
date.value
# => 20120100
# Initialize from a block of strings
date = PartialDate::Date.new {|d| d.year = "2012"; d.month = "01"}
# => 2012-01
date.value
# => 20120100
date.to_s :medium
# => Jan 2012
# Initialize from the class load method - for rehydrating a date instance from a stored integer date value.
date = PartialDate::Date.load 20121201
# => 2012-12-01
date.year
# => 2012
date.month
# => 12
date.day
# => 1
date.to_s :long
# => 01 December 2012
$ gem install partial-date
Copyright (c) 2012 Anthony Bouch
See {file:LICENSE.txt} for details.
FAQs
Unknown package
We found that partial-date 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.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.