ext/iodine/iodine_helpers.c
/**
Takes an optional Integer for Unix Time and returns a faster (though less
localized) HTTP Date formatted String.


        Iodine::Rack.time2str => "Sun, 11 Jun 2017 06:14:08 GMT"

        Iodine::Rack.time2str(Time.now.to_i) => "Wed, 15 Nov 1995 06:25:24 GMT"

Since Iodine uses time caching within it's reactor, using the default value
(now) will be faster than providing an explicit time using `Time.now.to_i`.

*/
Takes an optional Integer for Unix Time and returns a faster (though less
localized) HTTP Date formatted String.





Since Iodine uses time caching within it's reactor, using the default value
(now) will be faster than providing an explicit time using `Time.now.to_i`.
Takes an optional Integer for Unix Time and returns a faster ( though less localized ) HTTP Date formatted String . Since Iodine uses time caching within it ' s reactor using the default value ( now ) will be faster than providing an explicit time using ` Time . now . to_i ` .
static VALUE date_str(int argc, VALUE *argv, VALUE self) {
  if (argc > 1)
    rb_raise(rb_eArgError,
             "wrong number of arguments (given %d, expected 0..1).", argc);
  time_t last_tick;
  if (argc) {
    if (TYPE(argv[0]) != T_FIXNUM)
      argv[0] = rb_funcallv(argv[0], iodine_to_i_func_id, 0, NULL);
    Check_Type(argv[0], T_FIXNUM);
    last_tick =
        FIX2ULONG(argv[0]) ? FIX2ULONG(argv[0]) : fio_last_tick().tv_sec;
  } else
    last_tick = fio_last_tick().tv_sec;
  VALUE str = rb_str_buf_new(32);
  struct tm tm;
  http_gmtime(last_tick, &tm);
  size_t len = http_date2str(RSTRING_PTR(str), &tm);
  rb_str_set_len(str, len);
  return str;
  (void)self;
}
static VALUE date_str ( int argc , VALUE * argv , VALUE self ) { if ( argc > 1 ) rb_raise ( rb_eArgError , " " , argc ) ; time_t last_tick ; if ( argc ) { if ( TYPE ( argv [ 0 ] ) != T_FIXNUM ) argv [ 0 ] = rb_funcallv ( argv [ 0 ] , iodine_to_i_func_id , 0 , NULL ) ; Check_Type ( argv [ 0 ] , T_FIXNUM ) ; last_tick = FIX2ULONG ( argv [ 0 ] ) ? FIX2ULONG ( argv [ 0 ] ) : fio_last_tick ( ) . tv_sec ; } else last_tick = fio_last_tick ( ) . tv_sec ; VALUE str = rb_str_buf_new ( 32 ) ; struct tm tm ; http_gmtime ( last_tick , & tm ) ; size_t len = http_date2str ( RSTRING_PTR ( str ) , & tm ) ; rb_str_set_len ( str , len ) ; return str ; ( void ) self ; }
Takes an optional Integer for Unix Time and returns a faster (though less
localized) HTTP Date formatted String.
Takes an optional Integer for Unix Time and returns a faster ( though less localized ) HTTP Date formatted String .