Skip to content

Instantly share code, notes, and snippets.

@raydiak
Created May 23, 2021 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raydiak/1268d5e52e730db0b7d3ca17d23d37ff to your computer and use it in GitHub Desktop.
Save raydiak/1268d5e52e730db0b7d3ca17d23d37ff to your computer and use it in GitHub Desktop.
#!/usr/bin/env raku
use NativeCall;
class TimeStruct is repr<CStruct> {
has int32 $.tm_sec;
has int32 $.tm_min;
has int32 $.tm_hour;
has int32 $.tm_mday;
has int32 $.tm_mon;
has int32 $.tm_year;
has int32 $.tm_wday;
has int32 $.tm_yday;
has int32 $.tm_isdst;
}
sub gmtime (int64 $timep is rw) returns TimeStruct is native {}
my int64 $t = now.to-posix[0].Int;
say gmtime($t);
say nativecast Pointer, gmtime($t);
# TimeStruct.new(tm_sec => 54, tm_min => 40, tm_hour => 2, tm_mday => 23, tm_mon => 4, tm_year => 121, tm_wday => 0, tm_yday => 142, tm_isdst => 0)
# NativeCall::Types::Pointer<0x7f73242b1ec0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment