Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 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
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