From ef6f6dc04e35ab006747083bab50ead0353b0746 Mon Sep 17 00:00:00 2001 From: zverok Date: Mon, 12 Dec 2022 22:48:54 +0200 Subject: [PATCH] fixup! Implement Date#deconstruct_keys and DateTime#deconstruct_keys --- ext/date/date_core.c | 6 +----- test/date/test_date.rb | 12 +++++++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ext/date/date_core.c b/ext/date/date_core.c index dd06774..d1f2963 100644 --- a/ext/date/date_core.c +++ b/ext/date/date_core.c @@ -7438,14 +7438,12 @@ d_lite_jisx0301(VALUE self) static VALUE deconstruct_keys(VALUE self, VALUE keys, int is_datetime) { - VALUE h; + VALUE h = rb_hash_new(); long i; get_d1(self); if (NIL_P(keys)) { - h = rb_hash_new(); - rb_hash_aset(h, sym_year, m_real_year(dat)); rb_hash_aset(h, sym_month, INT2FIX(m_mon(dat))); rb_hash_aset(h, sym_day, INT2FIX(m_mday(dat))); @@ -7468,8 +7466,6 @@ deconstruct_keys(VALUE self, VALUE keys, int is_datetime) { } - h = rb_hash_new(); - for (i=0; i