summaryrefslogtreecommitdiff
path: root/swig/Date.i
blob: 0b4538eeabf85304fa90d9a04b3d7beb0870651b (plain)
1
2
3
4
5
6
7
8
9
10
11
12

%typemap(rubyin) Date {
  Date::ValueType seconds = (Date::ValueType) NUM2INT( rb_funcall( $input, rb_intern("to_i"), 0, 0) );
  $1 = Date(seconds);
}

%typemap(rubyout) Date {
  // Time works without require
  VALUE klass = rb_const_get( rb_cObject, rb_intern("Time"));
  VALUE rbtimenum = INT2NUM( (Date::ValueType) $1 );
  $result = rb_funcall( klass, rb_intern("at"), 1, rbtimenum);
}