-
-
Save raydiak/1268d5e52e730db0b7d3ca17d23d37ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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