Time::M...djusters(3)

πŸ’– Time::Moment::Adjusters πŸ’–

okay bestie, sit down, hydrate, and let me tell you about Time::Moment::Adjusters β€” it's a little slice of the User Contributed Perl Documentation and honestly? iconic. it's the adjuster pack for Time::Moment, and it's about to make your date math so much cuter. πŸŽ€


✨ NAME ✨

Time::Moment::Adjusters β€” the adjusters for Time::Moment, no cap. πŸ’…


🌸 SYNOPSIS 🌸

like, here's the whole vibe in one code block:

$adjuster = NextDayOfWeek($day);
$adjuster = NextOrSameDayOfWeek($day);

$adjuster = PreviousDayOfWeek($day);
$adjuster = PreviousOrSameDayOfWeek($day);

$adjuster = NearestDayOfWeek($day);

$adjuster = FirstDayOfWeekInMonth($day);
$adjuster = LastDayOfWeekInMonth($day);

$adjuster = NthDayOfWeekInMonth($ordinal, $day);

$adjuster = WesternEasterSunday();
$adjuster = OrthodoxEasterSunday();

$adjuster = NearestMinuteInterval($interval);

πŸ¦‹ DESCRIPTION πŸ¦‹

so Time::Moment::Adjusters provides adjusters. and what's an adjuster, you ask? it's literally a CODE reference that you invoke with an instance of Time::Moment, and it's expected to hand you back an instance of Time::Moment. that's the whole deal. periodt. ✨


πŸ‘‘ FUNCTIONS πŸ‘‘

🌈 NextDayOfWeek

$adjuster = NextDayOfWeek($day);

the $adjuster adjusts the date to the next occurrence of the given day of the week [1=Monday, 7=Sunday] that is after the date. so it skips today if today is already that day, bestie. 🫢

🌈 NextOrSameDayOfWeek

$adjuster = NextOrSameDayOfWeek($day);

the $adjuster adjusts the date to the next occurrence of the given day of the week [1=Monday, 7=Sunday]. but β€” plot twist β€” if the date already falls on the given day of the week, it's unaltered. she stays exactly as she is. πŸ’…

🌈 PreviousDayOfWeek

$adjuster = PreviousDayOfWeek($day);

the $adjuster adjusts the date to the previous occurrence of the given day of the week [1=Monday, 7=Sunday] that is before the date. going back in time, main character energy. βͺ

🌈 PreviousOrSameDayOfWeek

$adjuster = PreviousOrSameDayOfWeek($day);

the $adjuster adjusts the date to the previous occurrence of the given day of the week [1=Monday, 7=Sunday]. and if the date already falls on the given day of the week, it's unaltered. same energy as her next-y sister, just backwards. πŸ™ˆ

🌈 NearestDayOfWeek

$adjuster = NearestDayOfWeek($day);

the $adjuster adjusts the date to the nearest occurrence of the given day of the week [1=Monday, 7=Sunday]. closest one wins. vibe check passed. ✨

🌈 FirstDayOfWeekInMonth

$adjuster = FirstDayOfWeekInMonth($day);

the $adjuster adjusts the date to the first occurrence of the given day of the week [1=Monday, 7=Sunday] within the month. firsties. πŸ₯‡

🌈 LastDayOfWeekInMonth

$adjuster = LastDayOfWeekInMonth($day);

the $adjuster adjusts the date to the last occurrence of the given day of the week [1=Monday, 7=Sunday] within the month. she's the finale, the closer, the last one out. πŸ’«

🌈 NthDayOfWeekInMonth

$adjuster = NthDayOfWeekInMonth($ordinal, $day);

the $adjuster adjusts the date to the given ordinal day of the week within the month.

Parameters:

  • ordinal β€” the ordinal of the week within the month, and the valid range is [-4, -1] βˆͺ [1, 4]. yes, negatives are allowed, she contains multitudes. 🌈
  • day β€” the day of the week, [1=Monday, 7=Sunday]. πŸ—“οΈ

🌈 WesternEasterSunday

$adjuster = WesternEasterSunday();

the $adjuster adjusts the date to the Western Easter Sunday. the Western computus is based on the Gregorian calendar. 🐣

🌈 OrthodoxEasterSunday

$adjuster = OrthodoxEasterSunday();

the $adjuster adjusts the date to the Orthodox Easter Sunday. the Orthodox computus is based on the Julian calendar, with the Julian date converted to the equivalent Gregorian date. two calendars, one slay. 🐣✨

🌈 NearestMinuteInterval

$adjuster = NearestMinuteInterval($interval);

the $adjuster adjusts the time of day to the nearest minute of the given minute interval [1, 1440]. ⏰

given an minute interval of 30:

T10:14:59 => T10:00:00
T10:15:00 => T10:30:00
T10:29:59 => T10:30:00
T23:55:00 => T00:00:00 (midnight of the following day)
note that last one, bestie β€” T23:55:00 => T00:00:00 (midnight of the following day). she crosses the midnight line and doesn't even apologize. πŸ˜­πŸ’€

πŸŽ€ EXPORTS πŸŽ€

  • None by default. like, she's lowkey shy at first.
  • all functions can be exported using the :all tag, or individually. so you can have all of her, or just the ones you want. obsessed. πŸ’–

πŸ’œ AUTHOR πŸ’œ

Christian Hansen chansen@cpan.org β€” the icon, the legend, the moment. πŸ‘‘


Copyright 2015-2017 by Christian Hansen.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. free as in freedom, bestie. πŸ•ŠοΈ


okay that's the whole page, i love her, i love you, go adjust some dates. mwah. πŸ’…πŸ’–

this was Time::M...djusters(3) from the User Contributed Perl Documentation, perl v5.42.0, dated 2026-01-21. bye bestie, drink water. 🫢

πŸ“¦ where this page comes from