Skip to content

Fix DateTime timezone support: namespace::autoclean stub + keyword autoquoting#343

Merged
fglock merged 8 commits into
masterfrom
fix/datetime-timezone-support
Mar 20, 2026
Merged

Fix DateTime timezone support: namespace::autoclean stub + keyword autoquoting#343
fglock merged 8 commits into
masterfrom
fix/datetime-timezone-support

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Mar 20, 2026

Summary

This PR completes Phase 11 of the CPAN client support, enabling full DateTime functionality including timezone support.

Changes

  1. namespace::autoclean stub (src/main/perl/lib/namespace/autoclean.pm)

    • Provides the interface but skips cleanup entirely
    • Allows imported functions (like Try::Tiny's try/catch) to remain available
    • Fixes the "Undefined subroutine &DateTime::TimeZone::catch" error
  2. Parser fix for keyword autoquoting (ListParser.java)

    • Extended AUTOQUOTABLE_KEYWORDS set to include: if, unless, while, until, for, foreach (in addition to existing and, or, xor, when)
    • Keywords followed by => are now correctly treated as bareword hash keys
    • Fixes parser errors like "Expected token } but got until"

DateTime Now Works with Timezones

./jperl -MDateTime -e '
  my $dt = DateTime->new(
      year => 2024,
      month => 3,
      day => 15,
      hour => 14,
      minute => 30,
      time_zone => "America/New_York"
  );
  print $dt->datetime, "\n";   # 2024-03-15T14:30:00
  $dt->add(days => 5, hours => 2);
  print $dt->datetime, "\n";   # 2024-03-20T16:30:00
'

Test Plan

  • Unit tests pass (make)
  • DateTime basic operations work
  • DateTime with timezone works
  • Keywords as hash keys work (e.g., { foo => 1, until => 2 })

Generated with Devin

fglock and others added 8 commits March 20, 2026 10:22
…toquoting

Phase 11 completion:

1. namespace::autoclean stub (src/main/perl/lib/namespace/autoclean.pm)
   - Provides interface but skips cleanup entirely
   - Allows imported functions (Try::Tiny try/catch) to remain available
   - Fixes Undefined subroutine DateTime::TimeZone::catch error

2. Parser fix for keyword autoquoting (ListParser.java)
   - Extended AUTOQUOTABLE_KEYWORDS set to include: if, unless, while,
     until, for, foreach (in addition to and, or, xor, when)
   - Keywords followed by => are now treated as bareword hash keys
   - Fixes Expected token } but got until parser error

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ete)

Added missing key-value slice delete operations:

1. RuntimeHash.java: Added deleteKeyValueSlice() method
   - Returns alternating keys and values of deleted elements
   - Fixes delete %hash{key1, key2} returning keys and values

2. RuntimeArray.java: Added getKeyValueSlice() and deleteKeyValueSlice()
   - getKeyValueSlice() returns alternating indices and values
   - deleteKeyValueSlice() deletes and returns index/value pairs
   - Fixes delete %array[idx1, idx2] returning indices and values

3. Dereference.java: Extended handleHashElementOperator and handleArrayElementOperator
   - Added handling for % sigil with delete operation
   - Properly routes to the new *KeyValueSlice methods

This improves op/delete.t from 13 to ~50 passing tests.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Implement three new opcodes for the bytecode interpreter:
- ARRAY_SLICE_DELETE (390): delete @array[indices]
- HASH_KV_SLICE_DELETE (391): delete %hash{keys} (returns key-value pairs)
- ARRAY_KV_SLICE_DELETE (392): delete %array[indices] (returns index-value pairs)

These operations were already supported in the JVM backend via
RuntimeArray.deleteSlice() and RuntimeHash/RuntimeArray.deleteKeyValueSlice(),
but the interpreter was failing with "Array exists/delete requires simple
array variable" errors.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Fix refaddr to return identity hash of underlying object, not wrapper
  This fixes Specio enum validation and DateTime truncate/today

- Add POSIX math functions: floor, ceil, fmod, fabs, pow, trig, etc.
  DateTime uses POSIX::floor and POSIX::fmod

- Update cpan_client.md with Phase 12 completion details

DateTime now uses Java XS implementation ($DateTime::IsPurePerl = 0)
with 98.5% of DateTime tests passing.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Added comprehensive list of remaining DateTime test failures (45/3292):
- Overload stringification StackOverflowError (HIGH PRIORITY)
- Leap second handling issues (19 failures)
- End-of-month arithmetic bugs (21 failures)
- Missing test dependencies
- DateTime::Locale data file installation
- IPC::Open3 read-only modification bug
- Dist::CheckConflicts method resolution
- Encode::PERLQQ undefined
- Number::Overloaded integration

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…erloaded objects

When a double-quoted string contains only a single interpolated variable
like "$obj", the parser was optimizing it to just return the variable
directly. This broke overloaded objects because:

1. The 'eq' overload handler does: return "$a" eq "$b"
2. PerlOnJava was treating "$a" as just $a (no stringification)
3. This caused the eq overload to call itself infinitely (StackOverflowError)

The fix ensures that single non-string segments in string interpolation
are wrapped in a join() operation, which forces proper stringification.

This does NOT apply in regex context (isRegex=true) because regex patterns
should use the 'qr' overload, not stringify.

Fixes DateTime test failures:
- t/20infinite.t: stringified infinity comparisons now work
- t/31formatter.t: formatter stringification now works

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- t/20infinite.t: All 104 tests now pass
- t/31formatter.t: All 11 tests now pass
- DateTime test results improved: 3260/3302 (98.7%), down from 45 to 42 failures

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Set $XSLoader::VERSION to 0.32 (compatible with CPAN version)
- Add bootstrap_inherit() stub that delegates to load()

This fixes 'XSLoader does not define $XSLoader::VERSION' errors when
CPAN runs XSLoader's own test suite during dependency resolution.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock merged commit cf17bfa into master Mar 20, 2026
2 checks passed
@fglock fglock deleted the fix/datetime-timezone-support branch March 20, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant