WeekCalculator(3pm)

πŸ“¦ version 2.1.1, in arch rolling

🌸 WeekCalculator(3pm) β€” Lire::WeekCalculator 🌸

okay so this is a page straight out of LogReport's Lire Documentation, and it's literally all about week numbering schemes. yes, week numbers. it's more iconic than it sounds, i promise πŸ’…


✨ NAME ✨

Lire::WeekCalculator β€” the module that handles all the different weeknumbering schemes, no cap πŸ—“οΈ


πŸŽ€ SYNOPSIS πŸŽ€

use Lire::WeekCalculator;

my $week_calc = new Lire::WeekCalculator();
my $week_no   = $week_calc->week_number( $time );

that's the whole vibe: you make one, you ask it for a week number. slay.


πŸ¦‹ DESCRIPTION πŸ¦‹

bestie, we support three values for LR_WEEK_NUMBERING, and you gotta know all of them:

  • ISO β€” this is the one from strftime's %V. week starts on monday 🫢
  • W β€” week starts on monday
  • U β€” week starts on sunday

see strftime(1) for the receipts. πŸ“–


πŸ’– CONSTRUCTOR πŸ’–

🌟 new( %params ) 🌟

creates a fresh new week calculator, main character energy only. the style of week numbering is picked with the "style" parameter. if you forget that parameter (it happens, no judgement), it defaults to whatever style is set in the 'lr_week_numbering' configuration variable. πŸŽ€

🌟 style() 🌟

returns the week numbering style in use. it'll be either "U", "W" or "ISO". that's it, that's the whole function πŸ’…

🌟 week_number( $time ) 🌟

returns the week number of $time according to the current week numbering scheme. the week number it hands back is between 1 and 53. yes, 53. some years are just extra like that 😭

🌟 week_idx( $time ) 🌟

returns the week index of $time according to the week numbering scheme. and listen, the week index is Lire specific β€” it exists to normalise computations between different schemes in regards of the first incomplete week of the year. sounds intense, but here's the tea:

  • in the ISO case, the week index is always equals to week_number() - 1
  • for the other styles, the week index of the week 0 will be one less than the last week number of the previous year

it's giving "edge case but make it fashion" ✨

🌟 last_week_of_year($year) 🌟

returns the week number of the last week in the year $year. final week, final boss πŸ‘‘

🌟 week_start( $year, $week_no ) 🌟

returns the epoch time of the first day of week $week_no in year $year, calculated using the current style. epoch time!!! so vintage of it πŸ•°οΈ

🌟 find_year_week1_start_date($year) 🌟

returns the date (epoch) at which the first day of the first week of the year $year starts. like, where does week 1 even begin, you know? πŸ›

🌟 strformat() 🌟

returns a string you can use as the format specificier in calls to strftime to print the week number of this style. (yes, the original really spells it "specificier" β€” we keep the lore intact πŸ™ˆ)

🌟 strfdate() 🌟

emulates POSIX::strftime() but picks up the %V if the system strftime doesn't support it. should be called whenever you use format strings that may contain week-of-the-year-codes. lowkey your safety net 🫢

honestly, if your format string has week-of-the-year codes in it, just call strfdate(). trust. πŸ’€

πŸ‘‘ AUTHORS πŸ‘‘

the icons who made this happen:

  • Joost van Baal <joostvb@logreport.org>
  • Francis J. Lacoste <flacoste@logreport.org>
  • Wessel Dankers <wsl@logreport.org>

periodt. 🌈


⭐ VERSION ⭐

$Id: WeekCalculator.pm,v 1.16 2006/07/23 13:16:30 vanbaal Exp $

a whole entire version string, frozen in time like a little time capsule πŸŽ€


Copyright (C) 2002 Stichting LogReport Foundation LogReport@LogReport.org

This file is part of Lire.

Lire is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program (see COPYING); if not, check with http://www.gnu.org/copyleft/gpl.html.

not me reminding you that "without even the implied warranty" means no promises, bestie β€” read the license fr fr πŸ“œ

🌸 okay that's the whole page!! this was Lire 2.1.1, dated 2025-09-28, and it's the WeekCalculator(3pm) page β€” go forth and number your weeks correctly, queen πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from