Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
bae5812
Replace Date and DateTime classes from C to Ruby.
jinroq Feb 11, 2026
0cdfd42
Put `# encoding: US-ASCII` at the beginning.
jinroq Feb 15, 2026
802e0c2
Optimized methods
jinroq Feb 15, 2026
d4aa1aa
Optimized some methods.
jinroq Feb 22, 2026
8909ef5
Rewrite Date and DateTime from C extension to pure Ruby
jinroq Feb 25, 2026
d276c80
Auto-generate lib/date/zonetab.rb from ext/date/zonetab.list
jinroq Mar 1, 2026
2b938aa
Remove redundant .encode(Encoding::US_ASCII).freeze from constants.rb
jinroq Mar 1, 2026
fb37439
Optimize Date.new by delegating to Date.civil directly
jinroq Mar 2, 2026
ea0355e
Merge branch 'master' into replace_c_to_ruby
jinroq Mar 2, 2026
a65aca6
Refactor getbyte to StringScanner, and optimize strptime
jinroq Mar 3, 2026
7e80db9
Remove inlined civil_to_jd and other duplicated method bodies
jinroq Mar 4, 2026
a9255c0
Replace Rational() method calls with rational literals for performance
jinroq Mar 7, 2026
aa536c6
Merge branch 'master' into replace_c_to_ruby
jinroq Jun 6, 2026
1b3b1ef
Address review feedback: stricter arg checks, drop debug-only methods…
jinroq Jun 6, 2026
fd03c6f
Inline idiv helper and remove unused Date#initialize
jinroq Jun 6, 2026
997de16
Delegate comparison to Comparable, simplify deconstruct_keys, drop yd…
jinroq Jun 6, 2026
e2698ea
Access day fraction via #day_fraction instead of @df in Date
jinroq Jun 6, 2026
a539110
Rename @sg/@df ivars to @start/@day_fraction
jinroq Jun 6, 2026
c211307
Fix Date#+/#- Integer path to preserve shape and day fraction
jinroq Jun 6, 2026
e67f196
Normalize Date::Infinity start to Float in marshal_load
jinroq Jun 6, 2026
5bcb504
Remove unnecessary `strip!` on offset expression in zonetab generator
jinroq Jun 16, 2026
d80a88b
Simplify zonetab sort to Hash#sort
jinroq Jun 16, 2026
382bb9a
Use printf with %p in zonetab generator key formatting
jinroq Jun 17, 2026
a6abfc1
Use File.foreach chomp option in zonetab generator
jinroq Jun 17, 2026
7c04350
Simplify section tracking in zonetab generator
jinroq Jun 17, 2026
9e9d45a
Accept input/output paths as arguments in zonetab generator
jinroq Jun 17, 2026
e880620
Build abbr 3-key tables with shared compute_3key helper
jinroq Jun 17, 2026
20198e3
Remove unused lib/date/patterns.rb
jinroq Jun 17, 2026
d0b25b2
Move file-local flag constants out of constants.rb
jinroq Jun 17, 2026
c9b2175
Drop the C extension; pure Ruby implementation only (Ruby >= 3.3)
jinroq Jun 17, 2026
f6a2947
Fix calendar-reform validation in civil/ordinal/commercial
jinroq Jun 20, 2026
3773d98
Return Float for Date#start to match the C extension
jinroq Jun 20, 2026
6786840
Remove unused require and dead constant
jinroq Jun 20, 2026
4e11ebb
Implement DateTime#inspect to match the C extension
jinroq Jun 20, 2026
4a2bf55
Fix DateTime month/year arithmetic, new_offset and negative-year %y
jinroq Jun 20, 2026
9131c63
Use String#getbyte in compute_3key to avoid array allocation
jinroq Jun 30, 2026
8795e36
Merge branch 'master' into replace_c_to_ruby
jinroq Jun 30, 2026
d12d8d1
Return US-ASCII from jisx0301 and DateTime#iso8601
jinroq Jul 20, 2026
f902a83
Consolidate duplicate constants and restore constant docs
jinroq Jul 22, 2026
e14ea30
Merge branch 'master' into replace_c_to_ruby
jinroq Aug 18, 2026
7844527
Apply behavior-preserving refactors from PR #155 review
jinroq Aug 26, 2026
1270d21
Fix strftime colon parsing for %z to match the C extension
jinroq Aug 26, 2026
025665c
Restore width and colons when a locale modifier is invalid in strftime
jinroq Aug 26, 2026
3e3572d
Remove hallucinated width.precision handling from strftime
jinroq Aug 26, 2026
24a670e
Zero-pad %C, %s, %Q, %u, %w in strftime to match the C extension
jinroq Aug 26, 2026
64154a1
Respect strftime flag order for space vs zero padding
jinroq Aug 26, 2026
7b9c9ad
Reject a strftime flag that appears after the width
jinroq Aug 26, 2026
c67d644
Fix %z flag handling in strftime to match the C extension
jinroq Aug 26, 2026
160735e
Pad the %% conversion in strftime like the C extension
jinroq Aug 26, 2026
2e0b1a2
Keep the sign with the digits when space-padding in strftime
jinroq Aug 26, 2026
1cea9fa
Raise TypeError for non-String strptime arguments, matching the C ext…
jinroq Aug 26, 2026
606cd82
Raise TypeError for non-String parse arguments, matching the C extension
jinroq Aug 26, 2026
040b948
Unify the strptime/parse limit-exceeded message via parse_check_limit
jinroq Aug 26, 2026
523e0d8
Validate DateTime.new argument types like the C extension
jinroq Aug 26, 2026
c7260fd
Reject a trailing fraction in DateTime.new like the C extension
jinroq Aug 26, 2026
6a9a4da
Ignore out-of-range numeric DateTime offsets like the C extension
jinroq Aug 26, 2026
3c98e05
Parse DateTime offset strings via the full zone_to_diff port
jinroq Aug 26, 2026
124117b
Consolidate DateTime offset handling into _parse_of
jinroq Aug 26, 2026
5d90a4f
Validate jd/ordinal/commercial time arguments like the C extension
jinroq Aug 26, 2026
e3189bc
Coerce iso8601/jisx0301 precision like NUM2INT
jinroq Aug 26, 2026
20af640
Make DateTime Marshal format byte-compatible with the C extension
jinroq Aug 26, 2026
dd7d755
Fix DateTime._strptime/strptime default arguments
jinroq Aug 28, 2026
a336aed
Return self from Date/DateTime#marshal_load
jinroq Aug 28, 2026
fa8af06
Remove dead _split_sec helper from DateTime
jinroq Aug 28, 2026
8ebc031
Drop fractional day support for Date
jinroq Aug 28, 2026
ffacbcd
Rename Date#init_from_jd to #initialize and cache known civil fields
jinroq Aug 29, 2026
b206d5e
Split Date/DateTime strftime time parts into overridable methods
jinroq Aug 29, 2026
d44f6c0
Rename DateTime second ivars and expose time fields with attr_reader
jinroq Aug 29, 2026
17db803
Fold strftime '+' specifier into the composite expansion table
jinroq Aug 29, 2026
c1078d6
Replace _parse character-class bitmask with boolean locals
jinroq Aug 29, 2026
12dd14b
Realign assignment block in DateTime#_init_datetime
jinroq Aug 29, 2026
49a1b07
Extract optional-sign scanning into sp_scan_sign
jinroq Aug 29, 2026
ec8ca0d
Deduplicate fmt_str and fmt_z in strftime
jinroq Aug 29, 2026
b43e3de
Deduplicate wday lookup tables in constants
jinroq Aug 29, 2026
4634633
Extract repeated strptime idioms into helper methods
jinroq Aug 29, 2026
f5dec00
Merge branch 'master' into replace_c_to_ruby, and range-check Rationa…
jinroq Sep 27, 2026
468e401
Deduplicate offset and year handling in parse.rb
jinroq Sep 27, 2026
aa2df6b
Inline single-use DateTime format constants
jinroq Sep 27, 2026
9e6e8da
Deduplicate DateTime#ajd and offset-string accessors
jinroq Sep 27, 2026
45d12ae
Deduplicate DateTime#+ and DateTime#- branches
jinroq Sep 27, 2026
82c1495
Extract repeated match-blanking into a helper (parse)
jinroq Sep 27, 2026
5ae91c8
Remove no-op zone reassignment in _rfc2822
jinroq Sep 27, 2026
fe084e5
Simplify fmt_year in strftime
jinroq Sep 27, 2026
de45312
Remove Date#initialize_copy
jeremyevans Oct 24, 2026
84b854a
Make Date.new_from_jd an alias of Class#new
jeremyevans Oct 24, 2026
a638c1b
Remove mention of DateTime in Date#sec_fraction documentation/comments
jeremyevans Oct 24, 2026
114e5ce
Remove unnecessary String#encode calls in DateTime
jeremyevans Oct 24, 2026
36d579d
Freeze DateTime::UNSET private constant
jeremyevans Oct 24, 2026
3cd2bfe
Make DateTime.new the same as Class.new
jeremyevans Oct 24, 2026
fc0f2f5
Rename DateTime#_parse_of to #_parse_offset
jeremyevans Oct 24, 2026
76d6576
Replace some DateTime private method definitions with equivalent aliases
jeremyevans Oct 24, 2026
6c8a844
Remove unnecessary comment line
jeremyevans Oct 24, 2026
0ff4b7f
Drop usage of DEFAULT_STRFTIME_FMT/YMD_FMT constants
jeremyevans Oct 24, 2026
be6ff07
Move Errno::ERANGE raising in strftime
jeremyevans Oct 24, 2026
6b33e92
Have Date#{year,month,day} check for necessary instance variable first
jeremyevans Oct 24, 2026
74a834c
Avoid internal_civil unless @year
jeremyevans Oct 24, 2026
78e2301
Inline strptime constants used in a single place
jeremyevans Oct 25, 2026
35b6d27
Combine fast/medium paths in internal_strptime_ymd
jeremyevans Oct 25, 2026
0753a97
Cache @day_fraction for DateTime
jeremyevans Oct 25, 2026
418de0b
Inline DateTime#_from_total_sec_r into only caller
jeremyevans Oct 25, 2026
9a88d8b
Fix call-seq formatting issues
jeremyevans Oct 25, 2026
f05d11c
Merge pull request #1 from jeremyevans/date-fixes
jinroq Nov 22, 2026
02c4905
Remove StringScanner fast paths from _rfc3339 and _httpdate
jinroq Nov 23, 2026
e16584a
Replace compute_3key integer keys with plain string keys
jinroq Nov 23, 2026
ca4778f
Use character-string case dispatch in strftime
jinroq Nov 23, 2026
8631a12
Use character-string case dispatch in strptime sp_run
jinroq Nov 23, 2026
3c85c59
Inline low-value packaging tables; keep MONTH_DAY_SUFFIX
jinroq Nov 23, 2026
6b96fa8
Add regression tests for two edge-case fixes toward the C extension
jinroq Nov 23, 2026
b012024
Clean up after the dispatch/key refactors
jinroq Nov 23, 2026
02ebff4
Derive ABBR_*_NUM from ABBR_*_INFO
jinroq Nov 23, 2026
891afac
Fix %v year formatting for negative years
jinroq Nov 23, 2026
09f5cbd
Emit the original text for invalid strftime conversions
jinroq Nov 23, 2026
ad85ee0
Ignore the '#' flag on composite strftime conversions
jinroq Nov 23, 2026
b33eeea
Emit invalid bytes in a strftime format verbatim
jinroq Nov 23, 2026
ea1cdd5
Validate the zone offset range in _rfc3339
jinroq Nov 23, 2026
4a3d8a1
Range-check colon-form zone offsets in fast_zone_offset
jinroq Nov 23, 2026
792acc0
Replace single-use StringScanner with Regexp#match in parse.rb
jinroq Nov 23, 2026
e934355
Add exhaustive strftime C-extension comparison tests
jinroq Nov 23, 2026
e1d4674
Add tests covering untested features and fast paths
jinroq Nov 23, 2026
b9c83a0
Cover more strftime/strptime edge paths
jinroq Nov 23, 2026
7ab5f07
Drop unreachable branches in strftime
jinroq Nov 23, 2026
4eca0d4
Remove dead jd/ordinal helpers; match C ext fractional-cutover inspect
jinroq Nov 23, 2026
5f84be7
Add coverage tests for calendar starts, ordinal, comparisons and errors
jinroq Nov 23, 2026
6d4df74
Add Marshal cross-version/cross-implementation test
jinroq Nov 23, 2026
45e8929
Honor the offset in DateTime#rfc2822 and #httpdate
jinroq Nov 23, 2026
c73d959
Use Regexp#match in sp_zone_to_diff and align its offset validation
jinroq Nov 23, 2026
8c7b6ab
Raise TypeError from Date#>> and Date#<< for a non-integer argument
jinroq Nov 23, 2026
5f31be6
Drop decimal-hour zone offsets
jinroq Nov 23, 2026
dad8d21
Precompute civil/day-fraction for clone(freeze: true)
jinroq Nov 23, 2026
2c933f9
Compare, eql? and hash by the absolute instant
jinroq Nov 23, 2026
75ff40f
Account for offsets in Date#- (and cover <=>/step NaN cases)
jinroq Nov 23, 2026
915c1bc
Validate the start argument and ignore invalid values
jinroq Nov 24, 2026
e0abdb3
Range-check the offset in the old DateTime marshal format
jinroq Nov 24, 2026
ca33626
Account for the nth field when loading marshal data
jinroq Nov 24, 2026
4f3d994
Handle the calendar-reform gap in month shift and negative mday
jinroq Nov 24, 2026
a921c7a
Normalize Date#<=> against a Numeric to its sign
jinroq Nov 24, 2026
d8c3240
Cover Date minus an offset DateTime
jinroq Nov 24, 2026
c243f46
Fix strptime fallback, weekday completion and week-number validity
jinroq Nov 24, 2026
980798e
Match the C extension for cross-class initialize_copy
jinroq Nov 24, 2026
0567ca3
Merge master into the pure Ruby rewrite
jinroq Nov 24, 2026
f5173e6
Find the month's last day by scanning for a negative mday
jinroq Nov 24, 2026
f6ff6e4
Reject a non-numeric start with a TypeError
jinroq Nov 24, 2026
66ac8b9
Floor a fractional month count in Date#>> and Date#<<
jinroq Nov 24, 2026
25578e0
Hash the instant as an integer triple, not via ajd
jinroq Nov 24, 2026
e2f98e6
Round a fractional start to even in Date#inspect
jinroq Nov 24, 2026
73d4915
Reject a cwday with no week number in strptime
jinroq Nov 24, 2026
0f1dd90
Match the C extension's initialize_copy type error message
jinroq Nov 24, 2026
3f52617
Match NUM2DBL exactly for a non-numeric start
jinroq Nov 24, 2026
506ada1
Raise "expected numeric" from Date#<< for a non-numeric count
jinroq Nov 24, 2026
4ccb5a7
Start the last-day scan at the month length
jinroq Nov 24, 2026
85e8612
Add a hash test for the UTC-instant rewrite
jinroq Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
with:
engine: cruby
min_version: 2.6
min_version: 3.3

build:
if: ${{ startsWith(github.repository, 'ruby/') || github.event_name != 'schedule' }}
Expand Down Expand Up @@ -40,7 +40,5 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true # 'bundle install' and cache
- run: choco install gperf
if: ${{ matrix.ruby == 'mswin' }}
- name: Run test
run: bundle exec rake compile test
run: bundle exec rake test
5 changes: 2 additions & 3 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ jobs:
steps:
- uses: actions/checkout@v7
- name: Set up Ruby
run: sudo apt-get --no-install-recommends -q -y install ruby-dev gperf
run: sudo apt-get --no-install-recommends -q -y install ruby-dev
- name: Install dependencies
run: sudo gem install --no-document nokogiri
- name: Update zonetab
working-directory: ext/date
run: |
make -f prereq.mk update-zonetab
make -f prereq.mk zonetab.h
env:
top_srcdir: ../..
srcdir: .
Expand All @@ -31,7 +30,7 @@ jobs:
echo "diff=true" >> $GITHUB_OUTPUT
- name: Commit
run: |
git commit --message="Update zonetab.h at $(date +%F)" ext/date
git commit --message="Update zonetab at $(date +%F)" ext/date lib/date/zonetab.rb
git pull --ff-only origin ${GITHUB_REF#refs/heads/}
git push origin ${GITHUB_REF#refs/heads/}
env:
Expand Down
22 changes: 3 additions & 19 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,14 @@
require "bundler/gem_tasks"
require "rake/testtask"
require "shellwords"
require "rake/extensiontask"

extask = Rake::ExtensionTask.new("date") do |ext|
ext.name = "date_core"
ext.lib_dir.sub!(%r[(?=/|\z)], "/#{RUBY_VERSION}/#{ext.platform}")
end

# Pure Ruby — no compilation needed
Rake::TestTask.new(:test) do |t|
t.libs << extask.lib_dir
t.libs << "lib"
t.libs << "test/lib"
t.ruby_opts << "-rhelper"
t.test_files = FileList['test/**/test_*.rb']
end

task compile: "ext/date/zonetab.h"
file "ext/date/zonetab.h" => "ext/date/zonetab.list" do |t|
dir, hdr = File.split(t.name)
make_program_name =
ENV['MAKE'] || ENV['make'] ||
RbConfig::CONFIG['configure_args'][/with-make-prog\=\K\w+/] ||
(/mswin/ =~ RUBY_PLATFORM ? 'nmake' : 'make')
make_program = Shellwords.split(make_program_name)
sh(*make_program, "-f", "prereq.mk", "top_srcdir=.."+"/.."*dir.count("/"),
hdr, chdir: dir)
end
task :compile # no-op, kept for compatibility

task :default => [:compile, :test]
24 changes: 6 additions & 18 deletions date.gemspec
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
# frozen_string_literal: true

version = File.foreach(File.expand_path("../lib/date.rb", __FILE__)).find do |line|
/^\s*VERSION\s*=\s*["'](.*)["']/ =~ line and break $1
end
require_relative "lib/date/version"

Gem::Specification.new do |s|
s.name = "date"
s.version = version
s.version = Date::VERSION
s.summary = "The official date library for Ruby."
s.description = "The official date library for Ruby."

if Gem::Platform === s.platform and s.platform =~ 'java' or RUBY_ENGINE == 'jruby'
s.platform = 'java'
# No files shipped, no require path, no-op for now on JRuby
else
s.require_path = %w{lib}
s.require_path = %w{lib}

s.files = [
"README.md", "COPYING", "BSDL",
"lib/date.rb", "ext/date/date_core.c", "ext/date/date_parse.c", "ext/date/date_strftime.c",
"ext/date/date_strptime.c", "ext/date/date_tmx.h", "ext/date/extconf.rb", "ext/date/prereq.mk",
"ext/date/zonetab.h", "ext/date/zonetab.list"
]
s.extensions = "ext/date/extconf.rb"
end
s.files = Dir["README.md", "COPYING", "BSDL", "lib/**/*.rb",
"ext/date/prereq.mk", "ext/date/zonetab.list"]

s.required_ruby_version = ">= 2.6.0"
s.required_ruby_version = ">= 3.3.0"

s.authors = ["Tadayoshi Funaba"]
s.email = [nil]
Expand Down
Loading