Rose::...Parser(3pm)

πŸ“¦
version 0.540 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Rose::DateTime::Parser β€” the manual page, but make it cute πŸ’–

okay bestie, gather round, because today we're talking about Rose::DateTime::Parser (that's the Rose::...Parser(3pm) page, perl v5.34.0, dated 2022-06-17, in case you were wondering what you just opened) πŸŽ€

✨ NAME ✨

Rose::DateTime::Parser β€” it's a DateTime parser object. that's it. that's the whole vibe. πŸ¦‹


🌸 SYNOPSIS 🌸

here's the whole thing in action, no notes:

use Rose::DateTime::Parser;

$parser = Rose::DateTime::Parser->new(time_zone => 'UTC');

$dt = $parser->parse_date('4/30/2001 8am')
  or warn $parser->error;

look at her go. iconic behavior. πŸ‘‘


πŸ’œ DESCRIPTION πŸ’œ

so Rose::DateTime::Parser is basically a little glow-up wrapper around one specific kind of call to Rose::DateTime::Util's parse_date and parse_european_date functions. the object holds onto the time zone you want, and then passes that along to every single call. it's giving "personal assistant who remembers your coffee order." β˜•βœ¨

this class inherits from β€” and follows the conventions of β€” Rose::Object. if you want the full lore, go read the Rose::Object documentation. no cap, it's all there. πŸ“š


πŸŽ€ CONSTRUCTOR πŸŽ€

  • new PARAMS β€” builds you a brand new Rose::DateTime::Parser object based on PARAMS, where PARAMS are name/value pairs. and here's the cute part: any object method is a valid parameter name. so yes, you can pass whatever you want, she's flexible like that πŸ’…

🌈 OBJECT METHODS 🌈

  • error [ERROR] β€” get or set the error message string. that's the tea. when something goes wrong, this is where the drama lives 😭
  • european [BOOL] β€” get or set a boolean that controls how parse_date reads "xx/xx/xxxx" dates. two options, bestie: month/day/year or year/month/day. pick your fighter πŸ₯Š
    • if it's true, then parse_date hands its arguments to Rose::DateTime::Util's parse_european_date function, which reads those dates as "dd/mm/yyyy".
    • if it's false, then parse_date temporarily forces non-European date parsing and then calls Rose::DateTime::Util's parse_date function, which reads the date as "mm/dd/yyyy".
    • this attribute defaults to whatever the Rose::DateTime::Util->european_dates class method returned at the moment the Rose::DateTime::Parser object got constructed. ⏰
    • and here's the sneaky bit: if the BOOL argument is undefined (instead of "false, but defined") then the attribute snaps back to its default value by calling the Rose::DateTime::Util->european_dates class method all over again. so if you want to unambiguously set it true or false, pass a defined value like 1 or 0. don't be vague about it, she hates that πŸ™ˆ
  • parse_date STRING β€” tries to parse STRING by handing it to Rose::DateTime::Util's parse_date or parse_european_date function. which one? that's the european attribute's call, not yours. ✨
    • if parsing succeeds, you get the resulting DateTime object back. slay.
    • otherwise, error gets set and false is returned. πŸ’€
  • parse_datetime STRING β€” this method is literally just an alias for parse_date(). same energy, different name 🫢
  • parse_european_date STRING β€” tries to parse STRING by handing it to Rose::DateTime::Util's parse_european_date function β€” regardless of what the european attribute says. no negotiations, European all the way. if parsing succeeds, you get the resulting DateTime object. otherwise, error is set and false comes back. 🌸
  • time_zone [STRING] β€” get or set the time zone string that gets passed to Rose::DateTime::Util's parse_date function. it defaults to whatever the Rose::DateTime::Util->time_zone class method returns. 🌍

⭐ AUTHOR ⭐

John C. Siracusa (siracusa@gmail.com) β€” the main character who wrote all this πŸ‘‘


πŸ“œ LICENSE πŸ“œ

Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

okay so that's the legal bit, and it's important, so don't skip it just because it's not as fun as the parser methods πŸ’–

and that's the whole page bestie, no crumbs left πŸ“βœ¨

perl v5.34.0 β€” 2022-06-17 β€” that's the source, version and date, mwah, bye, go parse something gorgeous πŸ’…πŸŽ€πŸ’œ

πŸ“¦ where this page comes from