Rose::...Parser(3pm)
π 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 newRose::DateTime::Parserobject based onPARAMS, wherePARAMSare 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 howparse_datereads"xx/xx/xxxx"dates. two options, bestie: month/day/year or year/month/day. pick your fighter π₯- if it's true, then
parse_datehands its arguments toRose::DateTime::Util'sparse_european_datefunction, which reads those dates as"dd/mm/yyyy". - if it's false, then
parse_datetemporarily forces non-European date parsing and then callsRose::DateTime::Util'sparse_datefunction, which reads the date as"mm/dd/yyyy". - this attribute defaults to whatever the
Rose::DateTime::Util->european_datesclass method returned at the moment theRose::DateTime::Parserobject got constructed. β° - and here's the sneaky bit: if the
BOOLargument is undefined (instead of "false, but defined") then the attribute snaps back to its default value by calling theRose::DateTime::Util->european_datesclass method all over again. so if you want to unambiguously set it true or false, pass a defined value like1or0. don't be vague about it, she hates that π
- if it's true, then
parse_date STRINGβ tries to parseSTRINGby handing it toRose::DateTime::Util'sparse_dateorparse_european_datefunction. which one? that's theeuropeanattribute's call, not yours. β¨- if parsing succeeds, you get the resulting DateTime object back. slay.
- otherwise,
errorgets set and false is returned. π
parse_datetime STRINGβ this method is literally just an alias forparse_date(). same energy, different name π«Άparse_european_date STRINGβ tries to parseSTRINGby handing it toRose::DateTime::Util'sparse_european_datefunction β regardless of what theeuropeanattribute says. no negotiations, European all the way. if parsing succeeds, you get the resulting DateTime object. otherwise,erroris set and false comes back. πΈtime_zone [STRING]β get or set the time zone string that gets passed toRose::DateTime::Util'sparse_datefunction. it defaults to whatever theRose::DateTime::Util->time_zoneclass 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
- debian bookworm: librose-datetime-perl 0.540-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: librose-datetime-perl 0.540-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: librose-datetime-perl 0.540-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: librose-datetime-perl 0.540-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: librose-datetime-perl 0.540-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms