@@ -436,7 +436,7 @@ public void updateCal(DateTime dt) {
436
436
this .dt = dt ;
437
437
}
438
438
439
- protected long getTimeInMillis () {
439
+ public long getTimeInMillis () {
440
440
return dt .getMillis ();
441
441
}
442
442
@@ -565,9 +565,7 @@ public RubyTime getlocal19(ThreadContext context, IRubyObject[] args) {
565
565
throw new AssertionError (java .util .Arrays .toString (args ));
566
566
}
567
567
568
- /**
569
- * @see #strftime(ThreadContext, IRubyObject)
570
- */
568
+ @ Deprecated
571
569
public RubyString strftime (IRubyObject format ) {
572
570
return strftime (getRuntime ().getCurrentContext (), format );
573
571
}
@@ -581,12 +579,12 @@ public RubyString strftime(ThreadContext context, IRubyObject format) {
581
579
@ JRubyMethod (name = "==" , required = 1 )
582
580
@ Override
583
581
public IRubyObject op_equal (ThreadContext context , IRubyObject other ) {
584
- if (other .isNil ()) {
585
- return context .runtime .getFalse ();
586
- }
587
582
if (other instanceof RubyTime ) {
588
583
return context .runtime .newBoolean (cmp ((RubyTime ) other ) == 0 );
589
584
}
585
+ if (other == context .nil ) {
586
+ return context .runtime .getFalse ();
587
+ }
590
588
591
589
return RubyComparable .op_equal (context , this , other );
592
590
}
@@ -773,40 +771,44 @@ public RubyString asctime() {
773
771
@ Override
774
772
@ JRubyMethod (name = {"to_s" , "inspect" })
775
773
public IRubyObject to_s () {
776
- return inspectCommon (TO_S_FORMATTER , TO_S_UTC_FORMATTER );
774
+ final String str = inspectCommon (TO_S_FORMATTER , TO_S_UTC_FORMATTER );
775
+ return RubyString .newString (getRuntime (), str , USASCIIEncoding .INSTANCE );
777
776
}
778
777
779
778
public final IRubyObject to_s19 () {
780
779
return to_s ();
781
780
}
782
781
783
- private RubyString inspectCommon (DateTimeFormatter formatter , DateTimeFormatter utcFormatter ) {
782
+ private String inspectCommon (final DateTimeFormatter formatter , final DateTimeFormatter utcFormatter ) {
784
783
DateTimeFormatter simpleDateFormat ;
785
784
if (dt .getZone () == DateTimeZone .UTC ) {
786
785
simpleDateFormat = utcFormatter ;
787
786
} else {
788
787
simpleDateFormat = formatter ;
789
788
}
790
789
791
- String result = simpleDateFormat .print (dt );
792
-
793
790
if (isTzRelative ) {
794
791
// display format needs to invert the UTC offset if this object was
795
792
// created with a specific offset in the 7-arg form of #new
796
793
DateTimeZone dtz = dt .getZone ();
797
794
int offset = dtz .toTimeZone ().getOffset (dt .getMillis ());
798
795
DateTimeZone invertedDTZ = DateTimeZone .forOffsetMillis (offset );
799
796
DateTime invertedDT = dt .withZone (invertedDTZ );
800
- result = simpleDateFormat .print (invertedDT );
797
+ return simpleDateFormat .print (invertedDT );
801
798
}
802
799
803
- return RubyString .newString (getRuntime (), result , USASCIIEncoding .INSTANCE );
800
+ return simpleDateFormat .print (dt );
801
+ }
802
+
803
+ @ Override
804
+ public String toString () {
805
+ return inspectCommon (TO_S_FORMATTER , TO_S_UTC_FORMATTER );
804
806
}
805
807
806
808
@ JRubyMethod
807
809
@ Override
808
810
public RubyArray to_a () {
809
- return RubyArray .newArrayMayCopy (getRuntime (), sec (), min (), hour (), mday (), month (), year (), wday (), yday (), isdst (), zone ());
811
+ return RubyArray .newArrayNoCopy (getRuntime (), sec (), min (), hour (), mday (), month (), year (), wday (), yday (), isdst (), zone ());
810
812
}
811
813
812
814
@ JRubyMethod
0 commit comments