Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Re: what would this look like in Perl6...

First of all you wouldn't do this in Perl6 if you could help it! You would just use the built in core DateTime object and then use the attributes on that object to get the bits of the date and time you want >;3 If you grab yourself a copy of Rakudo the following works from the command line REPL:

$ perl6 > my $time = DateTime.new(time) 2014-11-05T22:35:54Z > $time.^methods check-time now clone clone-without-validating Instant posix offset off +set-in-minutes offset-in-hours later earlier truncated-to whole-secon +d in-timezone utc local Date Str IO is-leap-year days-in-month daycou +nt-from-ymd ymd-from-daycount get-daycount day-of-month day-of-week w +eek week-year week-number weekday-of-month day-of-year check-value ch +eck-date truncate-parts new perl gist <anon> <anon> <anon> <anon> <an +on> <anon> <anon> <anon> > $time.^attributes Int $!year Int $!month Int $!day Int $!hour Int $!minute Mu $!second M +u $!timezone Callable &!formatter > say $time.month 11 >

DateTime.new(time) above is the current local time as an object. Just time on its own gives you an Int as the system epoch timestamp in seconds. Calling ^methods on anything gives you a list of the methods an object has which is useful for picking up Perl6, ^attributes is similarly useful and makes it fairly obvious what you can get at in DateTime.


In reply to Re: localtime parse within hash init by Ultimatt
in thread localtime parse within hash init by NetWallah

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2022-09-24 17:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (115 votes). Check out past polls.

    Notices?