Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Challenge: sort weekdays in week-order (Time::Piece)

by LanX (Saint)
on Jul 22, 2022 at 12:17 UTC ( [id://11145653]=note: print w/replies, xml ) Need Help??


in reply to Re: Challenge: sort weekdays in week-order (elegantly and efficiently)
in thread Challenge: sort weekdays in week-order (elegantly and efficiently)

FWIW
> perl -de0 DB<38> use Time::Piece DB<39> x Time::Piece::day_list 0 'Sun' 1 'Mon' 2 'Tue' 3 'Wed' 4 'Thu' 5 'Fri' 6 'Sat' DB<40> x @{Time::Piece::_get_localization->{weekday}} 0 'Sunday' 1 'Monday' 2 'Tuesday' 3 'Wednesday' 4 'Thursday' 5 'Friday' 6 'Saturday'

And if you don't like the traditional order

DB<41> @W = @{Time::Piece::_get_localization->{weekday}} DB<42> push @W, shift @W DB<43> x @W 0 'Monday' 1 'Tuesday' 2 'Wednesday' 3 'Thursday' 4 'Friday' 5 'Saturday' 6 'Sunday' DB<44>

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^3: Challenge: sort weekdays in week-order (Time::Piece)
by choroba (Cardinal) on Jul 22, 2022 at 12:48 UTC
    Hmm... Not present in 5.26.1, works but not documented in 5.37.1. I'm not sure I'd use it.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      oh I see _get_localization is new in Time::Piece

      I just needed it anyway only to access the private

      my @FULLDAY_LIST = qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday);

      There are some (ugly) hacks to get it directly tho ...

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11145653]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-04-23 10:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found