{
    "mode": "perldoc",
    "parameter": "Date::Calendar::Profiles",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Date%3A%3ACalendar%3A%3AProfiles/json",
    "generated": "2026-06-09T20:41:51Z",
    "synopsis": "use Date::Calendar::Profiles qw( $Profiles );\nuse Date::Calendar;\n$calUSAK = Date::Calendar->new( $Profiles->{'US-AK'} [,LANG[,WEEKEND]] );\n$calDEBY = Date::Calendar->new( $Profiles->{'DE-BY'} [,LANG[,WEEKEND]] );\nor\nuse Date::Calendar::Profiles qw( $Profiles );\nuse Date::Calendar::Year;\n$year2000USFL = Date::Calendar::Year->new( 2000, $Profiles->{'US-FL'} [,LANG[,WEEKEND]] );\n$year2001DENW = Date::Calendar::Year->new( 2001, $Profiles->{'DE-NW'} [,LANG[,WEEKEND]] );\nand also\nuse Date::Calendar::Profiles\nqw(\n&PreviousFriday\n&NextMonday\n&NextMondayorTuesday\n&NearestWorkday\n&SundaytoMonday\n&Advent1\n&Advent2\n&Advent3\n&Advent4\n&Advent\n);",
    "sections": {
        "NAME": {
            "content": "Date::Calendar::Profiles - Some sample profiles for Date::Calendar and Date::Calendar::Year\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Date::Calendar::Profiles qw( $Profiles );\nuse Date::Calendar;\n\n$calUSAK = Date::Calendar->new( $Profiles->{'US-AK'} [,LANG[,WEEKEND]] );\n$calDEBY = Date::Calendar->new( $Profiles->{'DE-BY'} [,LANG[,WEEKEND]] );\n\nor\n\nuse Date::Calendar::Profiles qw( $Profiles );\nuse Date::Calendar::Year;\n\n$year2000USFL = Date::Calendar::Year->new( 2000, $Profiles->{'US-FL'} [,LANG[,WEEKEND]] );\n$year2001DENW = Date::Calendar::Year->new( 2001, $Profiles->{'DE-NW'} [,LANG[,WEEKEND]] );\n\nand also\n\nuse Date::Calendar::Profiles\nqw(\n&PreviousFriday\n&NextMonday\n&NextMondayorTuesday\n&NearestWorkday\n&SundaytoMonday\n&Advent1\n&Advent2\n&Advent3\n&Advent4\n&Advent\n);\n",
            "subsections": []
        },
        "PREFACE": {
            "content": "This module provides some sample profiles (i.e., holiday schemes) for use with the\nDate::Calendar(3) and Date::Calendar::Year(3) module.\n\nYou are not required to use these, you can always roll your own (this is very easy). See the\nsection \"HOW TO ROLL YOUR OWN\" below for more instructions on how to do this, and take the\nprofiles from this module as examples.\n\nI intend not to make any fixes to any of the calendar profiles in this module anymore unless\nthere are VERY compelling reasons to do so. These profiles are merely meant as examples.\n\nThe suggested way of using these profiles is to copy them to your own code and then to modify\nthem as needed. Otherwise many people could be negatively affected if I made any changes to a\nprofile someone has been using for years.\n\nAny improvements are therefore left as an exercise to the inclined reader.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The method \"init()\" in module Date::Calendar::Year(3) is responsible for parsing the calendar\nschemes contained here in the Date::Calendar::Profiles module.\n\nThis method offers a \"mini-language\" which allows one to specify common date formulas, like for\ninstance a simple fixed date (in various different formats, e.g. american or european), or\nthings like \"the second Sunday of May\" (Mother's Day), or \"Easter Sunday minus 46 days\" (Ash\nWednesday), to cite just a few.\n\nSee the section \"DATE FORMULA SYNTAX\" below for more details.\n\nThere are some more complicated formulas, however, which cannot be expressed in such simple\nterms.\n\nThe rule that if a holiday falls on a weekend, it will be substituted by either the adjacent\nFriday or Monday (whichever lies closer), is an example of this.\n\nIn order to be able to deal with such formulas, and in order to be as flexible as possible, the\n\"init()\" method offers the possibility of using callback functions to deal with such dates and\nformulas.\n\nSee the section \"CALLBACK INTERFACE\" below for more details on this topic.\n\nIn order to assist you with more common cases of odd formulas, the module\nDate::Calendar::Profiles exports the following utility subroutines (which are meant to be used\nas \"filters\" in callback functions of your own):\n\n* \"($year,$month,$day[,ANYTHING]) = PreviousFriday($year,$month,$day[,ANYTHING]);\"\n\nIf the given date falls on a Saturday or Sunday, this function changes the date to the\nadjacent Friday before that, and returns this new date.\n\nOtherwise the given date is returned unchanged.\n\nThe rest of the input parameters, if any, are simply copied to the output.\n\n* \"($year,$month,$day[,ANYTHING]) = NextMonday($year,$month,$day[,ANYTHING]);\"\n\nIf the given date falls on a Saturday or Sunday, this function changes the date to the\nadjacent Monday after that, and returns this new date.\n\nOtherwise the given date is returned unchanged.\n\nThe rest of the input parameters, if any, are simply copied to the output.\n\n* \"($year,$month,$day[,ANYTHING]) = NextMondayorTuesday($year,$month,$day[,ANYTHING]);\"\n\nIf the given date falls on a Saturday, the date of the next Monday (after that weekend) is\nreturned.\n\nIf the given date falls on a Sunday, the date of the next Tuesday (after that weekend) is\nreturned.\n\nIf the given date falls on a Monday, the date of the next Tuesday (the day after the Monday)\nis returned.\n\nOtherwise the given date is returned unchanged.\n\nThe rest of the input parameters, if any, are simply copied to the output.\n\nThis function is used for the second of two adjacent holidays, where the first holiday obeys\nthe \"Next Monday\" rule (see the description of the function immediately above).\n\nExamples of this are Christmas and Boxing Day, among others.\n\nWhen the first holiday falls on Friday, the second one falls on Saturday and is substituted by\nMonday.\n\nWhen the first holiday falls on a Saturday, the second one falls on Sunday, so the first\nholiday is substituted by Monday and the second one by Tuesday.\n\nWhen the first holiday falls on a Sunday, the second one falls on a Monday. Therefore the\nfirst holiday is substituted by Monday, and consequently the second holiday must be\nsubstituted by Tuesday.\n\nOr, in other terms:\n\nFri Sat => Fri Mon\nSat Sun => Mon Tue\nSun Mon => Mon Tue\n\nNote that there is no filter subroutine yet for the second of two adjacent holidays when the\nfirst holiday obeys the \"Nearest Workday\" rule (see the function described immediately below),\ni.e.,\n\nFri Sat => Fri Mon\nSat Sun => Fri Mon\nSun Mon => Mon Tue\n\nThis is left as an excercise to the inclined reader. \":-)\"\n\n* \"($year,$month,$day[,ANYTHING]) = NearestWorkday($year,$month,$day[,ANYTHING]);\"\n\nIf the given date falls on a Saturday, this function returns the date of the Friday on the day\nbefore.\n\nIf the given date falls on a Sunday, this function returns the date of the Monday on the day\nafter.\n\nOtherwise the given date is returned unchanged.\n\nThe rest of the input parameters, if any, are simply copied to the output.\n\n* \"($year,$month,$day[,ANYTHING]) = SundaytoMonday($year,$month,$day[,ANYTHING]);\"\n\nIf the given date falls on a Sunday, this function returns the date of the Monday on the day\nafter.\n\nOtherwise the given date is returned unchanged.\n\nThe rest of the input parameters, if any, are simply copied to the output.\n\nThe typical use of these filter subroutines is in a \"return\" statement at the end of callback\nfunctions of your own, when you already have calculated the holiday in question and only need to\nadjust it according to the rule implemented by the filter subroutine in question.\n\nSee also the implementation of the Date::Calendar::Profiles module for examples of how to use\nthese functions.\n",
            "subsections": []
        },
        "DATE FORMULA SYNTAX": {
            "content": "-  Fixed dates:\n\n\"Christmas\"  =>  \"24.12\",   # European format (day, month)\n\"Christmas\"  =>  \"24.12.\",\n\n\"Christmas\"  =>  \"24Dec\",\n\"Christmas\"  =>  \"24.Dec\",\n\"Christmas\"  =>  \"24Dec.\",\n\"Christmas\"  =>  \"24.Dec.\",\n\n\"Christmas\"  =>  \"24-12\",\n\"Christmas\"  =>  \"24-12-\",\n\n\"Christmas\"  =>  \"24-Dec\",\n\"Christmas\"  =>  \"24-Dec-\",\n\n\"Christmas\"  =>  \"12/25\",   # American format (month, day)\n\"Christmas\"  =>  \"Dec25\",\n\"Christmas\"  =>  \"Dec/25\",\n\n-  Dates relative to Easter Sunday:\n\n\"Ladies' Carnival\"  =>  \"-52\",\n\"Carnival Monday\"   =>  \"-48\",\n\"Mardi Gras\"        =>  \"-47\",\n\"Ash Wednesday\"     =>  \"-46\",\n\"Palm Sunday\"       =>   \"-7\",\n\"Maundy Thursday\"   =>   \"-3\",\n\"Good Friday\"       =>   \"-2\",\n\"Easter Sunday\"     =>   \"+0\",\n\"Easter Monday\"     =>   \"+1\",\n\"Ascension\"         =>  \"+39\",\n\"Whitsunday\"        =>  \"+49\",\n\"Whitmonday\"        =>  \"+50\",\n\"Corpus Christi\"    =>  \"+60\",\n\n-  The 1st, 2nd, 3rd, 4th or last day of week:\n\n\"Thanksgiving\"      =>  \"4Thu11\",\n\"Thanksgiving\"      =>  \"4/Thu/Nov\",\n\"Columbus Day\"      =>  \"2/Mon/Oct\",\n\"Columbus Day\"      =>  \"2/Mon/10\",\n\"Columbus Day\"      =>  \"2/1/Oct\",\n\"Columbus Day\"      =>  \"2/1/10\",\n\"Memorial Day\"      =>  \"5/Mon/May\", # LAST Monday of May\n\n-  Half holidays, commemorative days:\n\n\"Christmas\"         =>  \":24.12.\", # only half a day off\n\"Valentine's Day\"   =>  \"#Feb/14\", # not an official holiday\n",
            "subsections": []
        },
        "CALLBACK INTERFACE": {
            "content": "The interface of the callback functions to use with the \"init()\" method of the\nDate::Calendar::Year(3) module is very simple:\n\nThe callback function receives two arguments when called, first the year number for which the\nholiday is to be calculated, and second the name (the \"label\") of the holiday in question (which\nserves as key in the hash of a holiday scheme).\n\nThis second parameter allows you to use the same callback function for different holidays, which\nmight be more practical (than separate callback functions) if for instance you have a set of\nsimilar holidays to calculate, like for instance the four Sundays before Christmas (\"Advent\").\n\nThe callback function \"Advent()\" (exported by the Date::Calendar::Profiles module) exemplifies\nthis technique.\n\nThe callback function is expected to return a list \"\"($year,$month,$day)\"\" with the exact date\nof the holiday (the year number in the output must of course match the year number passed as\nparameter).\n\nA fatal error occurs if the returned list does not constitute a valid date, in the requested\nyear.\n\nOptionally, the callback function may return a fourth value (after the date) containing a\nstring, which may be either \"#\" or \":\".\n\nThe string \"#\" signifies that the date in question is a purely commemorative date, i.e., that\nyou don't get a day off from work on that day.\n\nThe string \":\" means that the date in question is a \"half\" holiday, i.e., a day on which you get\nhalf a day off from work.\n\nIn case the holiday in question was not observed or did not exist in the requested year, the\ncallback function may also return an empty list. This will cause the \"init()\" method to simply\ndrop this holiday for that year.\n\nThe module Date::Calendar::Profiles exports the sample callback functions \"Advent1()\",\n\"Advent2()\", \"Advent3()\", \"Advent4()\" and \"Advent()\", which might assist you in rolling your own\nprofiles.\n",
            "subsections": []
        },
        "HOW TO ROLL YOUR OWN": {
            "content": "Every calendar profile (holiday scheme) is a hash.\n\nThe name of the holiday (like \"Christmas\", for instance) serves as the key in this hash and must\ntherefore be unique (unless you want to override a default which was set previously, but see\nbelow for more on this).\n\nThe value for each key is either a string, which specifies a simple date formula, or the\nreference of a callback function.\n\nSee the section \"CALLBACK INTERFACE\" above for a description of the interface (in and out) of\nthese callback functions.\n\nSee the section \"DATE FORMULA SYNTAX\" above and the description of the \"init()\" method in\nDate::Calendar::Year(3) for the exact syntax of date formula strings.\n\nBEWARE that if keys are not unique in the source code, later entries will overwrite previous\nones! I.e.,\n\n...\n\"My special holiday\" => \"01-11\",\n\"My special holiday\" => \"02-11\",\n...\n\nwill NOT set two holidays of the same name, one on November first, the other on November second,\nbut only one, on November second!\n\nTherefore, in order to use sets of defaults and to be able to override some of them, you must\nFIRST include any hash containing the default definitions, and THEN write down your own\ndefinitions (see also the Date::Calendar::Profiles module for examples of this!), like this:\n\n$defaults =\n{\n\"Holiday #1\" => \"01-01\",\n\"Holiday #2\" => \"02-02\",\n\"Holiday #3\" => \"03-03\"\n};\n\n$variant1 =\n{\n%$defaults,\n\"Holiday #2\" => \"09-02\",\n\"Holiday #4\" => \"04-04\"\n};\n\nThis is because of the way hashes work in Perl.\n\nNow let's suppose that you want to write a profile containing all your relatives' and friends'\nbirthdays or anniversaries.\n\nSimply go ahead and list them in your program, in any order you like, as follows (for example):\n\n$Birthdays =\n{\n\"Spouse 1971\"             =>  \"30.12.\",\n\"Wedding Day 1992\"        =>  \"01.09.\",\n\"Valentine's Day\"         =>  \"14.02.\",\n\"Son Richard 1996\"        =>  \"11.05.\",\n\"Daughter Irene 1994\"     =>  \"17.01.\",\n\"Mom 1939\"                =>  \"19.08.\",\n\"Dad 1937\"                =>  \"23.04.\",\n\"Brother Timothy 1969\"    =>  \"24.04.\",\n\"Sister Catherine 1973\"   =>  \"21.10.\",\n\"Cousin Paul 1970\"        =>  \"16.10.\",\n\"Aunt Marjorie 1944\"      =>  \"09.06.\",\n\"Uncle George 1941\"       =>  \"02.08.\",\n\"Friend Alexander 1968\"   =>  \"12.06.\",\n};\n\nThe year numbers after the names are not really necessary, but they allow us to display the\nperson's current age. If this year number is omitted, we simply don't display the age.\n\nNow in order to query this birthday database, we can use the following little program:\n\n#!perl -w\n\nuse strict;\nno strict \"vars\";\nuse Date::Calc qw(:all);\nuse Date::Calendar;\n\n$Birthdays =\n{\n... # (see above)\n};\n\n@today = Today();\n$calendar = Date::Calendar->new( $Birthdays );\n$calendar->year( $today[0] );\n\nforeach $key (@ARGV)\n{\nif (@list = $calendar->search( $key ))\n{\nforeach $date (@list)\n{\n@labels = $calendar->labels( $date );\n$dow = shift(@labels);\n# More than one person might have birthday on the same date:\n$name = $key;\nforeach $person (@labels)\n{\nif (index(lc($person),lc($key)) >= 0)\n{\n$name = $person;\nlast;\n}\n}\n$delta = DeltaDays(@today, $date->date());\n$age = '';\nif ($name =~ s!\\s*(\\d+)\\s*$!!)\n{\n$age = $today[0] - $1;\n$age-- if ($delta > 0);\n$age = sprintf(\" (%2d years old)\", $age);\n}\nprintf\n(\n\"%-20.20s: %+5d days => %3.3s %2d-%3.3s-%4d%s\\n\",\n$name,\n$delta,\n$dow,\n$date->day(),\nMonthtoText($date->month()),\n$date->year(),\n$age\n);\n}\n}\nelse { print \"No entry found in birthday list for '$key'!\\n\" }\n}\n\nEND\n\nLet us save this program as, say, \"birthday.pl\".\n\nThen we can query this birthday database by providing search strings on the command line, like\nthis (note that this is a (case-insensitive) substring search, NOT a regular expression match!):\n\n> date\nWed Oct  3 18:05:45 CEST 2001\n\n> perl birthday.pl wed spo\nWedding Day         :   -32 days => Sat  1-Sep-2001 ( 9 years old)\nSpouse              :   +88 days => Sun 30-Dec-2001 (29 years old)\n\n> perl birthday.pl son daug\nSon Richard         :  -145 days => Fri 11-May-2001 ( 5 years old)\nDaughter Irene      :  -259 days => Wed 17-Jan-2001 ( 7 years old)\n\n> perl birthday.pl broth sist\nBrother Timothy     :  -162 days => Tue 24-Apr-2001 (32 years old)\nSister Catherine    :   +18 days => Sun 21-Oct-2001 (27 years old)\n\n> perl birthday.pl mom dad\nMom                 :   -45 days => Sun 19-Aug-2001 (62 years old)\nDad                 :  -163 days => Mon 23-Apr-2001 (64 years old)\n\n> perl birthday.pl uncl aunt\nUncle George        :   -62 days => Thu  2-Aug-2001 (60 years old)\nAunt Marjorie       :  -116 days => Sat  9-Jun-2001 (57 years old)\n\n> perl birthday.pl alex\nFriend Alexander    :  -113 days => Tue 12-Jun-2001 (33 years old)\n\nIn order to get the whole list, we can supply a substring which is contained in every name,\nwhich happens to be a blank (\" \"):\n\n> perl birthday.pl ' '\nDaughter Irene      :  -259 days => Wed 17-Jan-2001 ( 7 years old)\nValentine's Day     :  -231 days => Wed 14-Feb-2001\nDad                 :  -163 days => Mon 23-Apr-2001 (64 years old)\nBrother Timothy     :  -162 days => Tue 24-Apr-2001 (32 years old)\nSon Richard         :  -145 days => Fri 11-May-2001 ( 5 years old)\nAunt Marjorie       :  -116 days => Sat  9-Jun-2001 (57 years old)\nFriend Alexander    :  -113 days => Tue 12-Jun-2001 (33 years old)\nUncle George        :   -62 days => Thu  2-Aug-2001 (60 years old)\nMom                 :   -45 days => Sun 19-Aug-2001 (62 years old)\nWedding Day         :   -32 days => Sat  1-Sep-2001 ( 9 years old)\nCousin Paul         :   +13 days => Tue 16-Oct-2001 (30 years old)\nSister Catherine    :   +18 days => Sun 21-Oct-2001 (27 years old)\nSpouse              :   +88 days => Sun 30-Dec-2001 (29 years old)\n\nBy the way, a similar program is included in the \"examples\" subdirectory of the Date::Calc\ndistribution, called \"anniversaries.pl\".\n\nSee also the file \"EXAMPLES.txt\" in the distribution's main directory for a short description of\nthat little script.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Date::Calendar(3), Date::Calendar::Year(3), Date::Calc::Object(3), Date::Calc(3),\nDate::Calc::Util(3).\n",
            "subsections": []
        },
        "LIMITATIONS": {
            "content": "The calendar profiles included in this module usually do not take historical irregularities into\naccount (even though some do in order to show how this can be done), they only provide means for\ncalculating regularly recurring events (the profiles should therefore not be relied upon for\nhistorical faithfulness).\n",
            "subsections": []
        },
        "KNOWN BUGS": {
            "content": "The australian calendar profiles are known to contain wrong dates. This is due to the fact that\nAustralia decrees its holidays individually for each year, difficulting the calculation of the\nholidays by way of a formula. An effort to compare (and to correct) the current implementation\nwith official documents (web pages) by the Australian authorities is under way. This hasn't been\nfinished yet because it is very time-consuming.\n",
            "subsections": []
        },
        "VERSION": {
            "content": "This man page documents \"Date::Calendar::Profiles\" version 6.4.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Steffen Beyer\nmailto:STBEY@cpan.org\nhttp://www.engelschall.com/u/sb/download/\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (c) 2000 - 2015 by Steffen Beyer. All rights reserved.\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "This package is free software; you can use, modify and redistribute it under the same terms as\nPerl itself, i.e., at your option, under the terms either of the \"Artistic License\" or the \"GNU\nGeneral Public License\".\n\nThe C library at the core of the module \"Date::Calc::XS\" can, at your discretion, also be used,\nmodified and redistributed under the terms of the \"GNU Library General Public License\".\n\nPlease refer to the files \"Artistic.txt\", \"GNUGPL.txt\" and \"GNULGPL.txt\" in the \"license\"\nsubdirectory of this distribution for any details!\n",
            "subsections": []
        },
        "DISCLAIMER": {
            "content": "This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\nwithout even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\nSee the \"GNU General Public License\" for more details.\n",
            "subsections": []
        }
    },
    "summary": "Date::Calendar::Profiles - Some sample profiles for Date::Calendar and Date::Calendar::Year",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "Calendar",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Calendar/3/json"
        },
        {
            "name": "Year",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Year/3/json"
        },
        {
            "name": "Object",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Object/3/json"
        },
        {
            "name": "Calc",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Calc/3/json"
        },
        {
            "name": "Util",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Util/3/json"
        }
    ]
}