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