Skip to content

Commit

Permalink
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/TimeNodes.java
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.source.SourceSection;

import org.joda.time.DateTimeZone;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyContext;
@@ -21,6 +22,23 @@
@CoreClass(name = "Time")
public abstract class TimeNodes {

// We need it to copy the internal data for a call to Kernel#clone.
@CoreMethod(names = "initialize_copy", required = 1)
public abstract static class InitializeCopyNode extends CoreMethodArrayArgumentsNode {

public InitializeCopyNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object initializeCopy(RubyTime self, RubyTime from) {
self.setDateTime(from.getDateTime());
self.setOffset(from.getOffset());
return self;
}

}

// Not a core method, used to simulate Rubinius @is_gmt.
@NodeChild(type = RubyNode.class, value = "self")
public abstract static class InternalGMTNode extends CoreMethodNode {

0 comments on commit e9a4c9c

Please sign in to comment.