Prima::Calendar(3)
π Prima::Calendar β the standard calendar widget, bestie π
So you want a calendar in your Prima app? Say less. This is Prima::Calendar, the built-in date-picking widget, and honestly? She's iconic. ποΈβ¨
πΈ SYNOPSIS πΈ
use Prima qw(Calendar Application);
my $cal = Prima::Calendar-> create(
useLocale => 1,
size => [ 150, 150 ],
onChange => sub {
print $_[0]-> date_as_string, "\n";
},
);
$cal-> date_from_time( localtime );
$cal-> month( 5);
run Prima;
Like, that's the whole vibe. You create her, you feed her a date, you set the month, you run Prima. Done. π
β¨ DESCRIPTION β¨
She gives you interactive selection for dates between the years 1900 and 2099. No cap.
Her main character property is date, and it's a three-integer array of day, month, and year, in the same format as perl localtime (see "localtime" in perlfunc) β so:
- day's range is between 1 and 31
- month's is 0 to 11
- year's is from 0 to 199
Yes the month is zero-indexed, yes it's a jumpscare, no you're not the only one who keeps forgetting. π
π¦ API π¦
π Events
Changeβ Called when thedateproperty is changed. That's it, that's the event. She noticed you changed the date and she's telling you about it. π«Ά
π Properties
date DAY, MONTH, YEARβ Accepts three integers in the format oflocaltime.DAYcan be from 1 to 31,MONTHfrom 0 to 11,YEARfrom 0 to 199.
Default value: today's date. (She ships knowing what day it is, queen behavior. π)
day INTEGERβ Selects the day in the month.firstDayOfWeek INTEGERβ Selects the first day of the week, an integer between 0 and 6, where0is Sunday as the first day,1is Monday, etc. So you can start your week on Monday like a civilized person.
Default value: 0
monthβ Selects the month.useLocale BOOLEANβ If1, the locale-specific names of months and days of week are used. These are read by callingPOSIX::strftime. If an invocation of the POSIX module fails, the property is automatically assigned to0. So like, she tries her best, and if POSIX ghosts her she just falls back. π
If 0, the English names of months and days of week are used.
Default value: 1
See also: date_as_string
yearβ Selects the year.
π Methods
can_use_localeβ Returns a boolean value, whether the locale information can be retrieved by callingstrftimeor not. A little vibe check on your locale, basically. β¨month2str MONTHβ Returns theMONTHname according to theuseLocalevalue.make_monthsβ Returns an array of the 12 month names according to theuseLocalevalue. All twelve. In order. Gorgeous. πday_of_week DAY, MONTH, YEAR, [ USE_FIRST_DAY_OF_WEEK = 1 ]β Returns an integer value between 0 and 6, the day of week onDAY,MONTH,YEARdate. If booleanUSE_FIRST_DAY_OF_WEEKis set, the value of thefirstDayOfWeekproperty is taken into account, so f ex the result of 0 means that this is a Sunday shifted forward byfirstDayOfWeekdays.
The switch from the Julian to the Gregorian calendar is ignored. She's not doing that math, bestie, and honestly? Fair. π
date_as_string [ DAY, MONTH, YEAR ]β Returns string representation of date onDAY,MONTH,YEARaccording to theuseLocaleproperty value.date_from_time SEC, MIN, HOUR, M_DAY, MONTH, YEAR, ...β Copies date fromlocaltimeorgmtimeresults. This helper method allows the following syntax:
$calendar-> date_from_time( localtime( time));
Literally just hand her your localtime and she eats it up. π₯
π§ AUTHOR π§
Dmitry Karasik, <dmitry@karasik.eu.org>. Shoutout to him fr fr. π«Ά
π SEE ALSO π
Prima, Prima::Widget, POSIX, "localtime" in perlfunc, "time" in perlfunc, examples/calendar.pl.
Like, go read those too, iykyk. π
Okay that's the whole page, and it slayed. This was Prima::Calendar(3) β perl v5.42.0, dated 2024-08-20. Now go build something adorable with a calendar in it. Periodt. πππ¦
π¦ where this page comes from
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms