Skip to content

Add support for 'in:' kwarg in Time.new and Time.now - #432

Open
mcfadden wants to merge 1 commit into
travisjeffery:masterfrom
mcfadden:bm/support-in-kwarg
Open

Add support for 'in:' kwarg in Time.new and Time.now#432
mcfadden wants to merge 1 commit into
travisjeffery:masterfrom
mcfadden:bm/support-in-kwarg

Conversation

@mcfadden

Copy link
Copy Markdown

This adds support for Ruby 3.1's in: keyword argument.

Example usage:

Timecop.freeze(Time.new(2024, 9, 20, 1, 2, 30)) do
  puts Time.new # 2024-09-20 01:02:30 -0400
  puts Time.new(in: "+04:00") # 2024-09-20 09:02:30 +0400
  puts Time.now(in: "+03:00") # 2024-09-20 08:02:30 +0300
  puts Time.new(in: "+02:00") # 2024-09-20 07:02:30 +0200
end

Fixes #431

@joshuacronemeyer

Copy link
Copy Markdown
Collaborator

@mcfadden thanks for this! Can you add some usages of this in the unit tests so we can make sure there are assertions that ensure this parameter is handled? Also I noticed the ruby docs use this for the Time.at method as well so can you throw that in as well? Thank you.

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.

Time.new with in: keyword argument does not return frozen time.

2 participants