{
    "mode": "perldoc",
    "parameter": "Date::Manip::Base",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Date%3A%3AManip%3A%3ABase/json",
    "generated": "2026-06-12T05:36:21Z",
    "synopsis": "use Date::Manip::Base;\n$dmb = new Date::Manip::Base;",
    "sections": {
        "NAME": {
            "content": "Date::Manip::Base - Base methods for date manipulation\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Date::Manip::Base;\n$dmb = new Date::Manip::Base;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The Date::Manip package of modules consists of several modules for doing high level date\noperations with full error checking and a lot of flexibility.\n\nThe high level operations, though intended to be used in most situations, have a lot of overhead\nassociated with them. As such, a number of the most useful low level routines (which the high\nlevel routines use to do much of the real work) are included in this module and are available\ndirectly to users.\n\nThese low level routines are powerful enough that they can be used independent of the high level\nroutines and perform useful (though much simpler) operations. They are also significantly faster\nthan the high level routines.\n\nThese routines do little error checking on input. Invalid data will result in meaningless\nresults. If you need error checking, you must call the higher level Date::Manip routines instead\nof these.\n\nThese routines also ignore all effects of time zones and daylight saving time. One way to think\nof these routines is working with times and dates in the GMT time zone.\n",
            "subsections": []
        },
        "BASE METHODS": {
            "content": "This class inherits several base methods from the Date::Manip::Obj class. Please refer to the\ndocumentation for that class for a description of those methods.\n\nerr\nnew\nnewconfig\nPlease refer to the Date::Manip::Obj documentation for these methods.\n\nconfig\n$dmb->config($var1,$val1,$var2,$val2,...);\n\nThis will set the value of any configuration variable. Please refer to the\nDate::Manip::Config manual for a list of all configuration variables and their description.\n",
            "subsections": []
        },
        "DATE METHODS": {
            "content": "In all of the following method descriptions, the following variables are used:\n\n$date\nThis is a list reference containing a full date and time:\n\n[$y, $m, $d, $h, $mn, $s]\n\n$ymd\nA list reference containing only the date portion:\n\n[$y, $m, $d]\n\n$hms\nA list reference containing only the time portion:\n\n[$h, $mn, $s]\n\n$delta\nA list containing a full delta (an amount of time elapsed, or a duration):\n\n[$dy, $dm, $dw, $dd, $dh, $dmn, $ds]\n\n$time\nA list reference containing the hour/minute/second portion of a delta:\n\n[$dh, $dmn, $ds]\n\n$offset\nA list containing a time zone expressed as an offset:\n\n[ $offh, $offm, $offs ]\n\nAlthough this module does not make use of timezone information, a few of the functions\nperform operations on time zone offsets, primarily because these operations are needed in\nthe higher level modules.\n\nThe elements \"($y, $m, $d, $h, $mn, $s)\" are all numeric. In most of the routines described\nbelow, no error checking is done on the input. $y should be between 1 and 9999, $m between 1 and\n12, $d between 1 and 31, $h should be between 0 and 23, $mn and $s between 0 and 59.\n\n$hms can be between 00:00:00 and 24:00:00, but an $offset must be between -23:59:59 and\n+23:59:59.\n\nYears are not translated to 4 digit years, so passing in a year of \"04\" will be equivalent to\n\"0004\", NOT \"2004\".\n\nThe elements \"($dy, $dm, $dw, $dd, $dh, $dmn, $ds)\" are all numeric, but can be positive or\nnegative. They represent an elapsed amount of time measured in years, months, weeks, etc.\n\nSince no error checking is done, passing in \"($y,$m,$d) = (2004,2,31)\" will NOT trigger an\nerror, even though February does not have 31 days. Instead, some meaningless result will be\nreturned.\n\ncalcdatedate\ncalcdatedays\ncalcdatedelta\ncalcdatetime\ncalctimetime\nThese are all routines for doing simple date and time calculations. As mentioned above, they\nignore all affects of time zones and daylight saving time.\n\nThe following methods are available:\n\n$time = $dmb->calcdatedate($date1,$date2);\n\nThis take two dates and determine the amount of time between them.\n\n$date = $dmb->calcdatedays($date,$n [,$subtract]);\n$ymd  = $dmb->calcdatedays($ymd,$n [,$subtract]);\n\nThis returns a date $n days later (if \"$n>0\") or earlier (if \"$n<0\") than the date passed\nin. If $subtract is passed in, the sign of $n is reversed.\n\n$date = $dmb->calcdatedelta($date,$delta [,$subtract]);\n\nThis take a date and add the given delta to it (or subtract the delta if $subtract is\nnon-zero).\n\n$date = $dmb->calcdatetime($date,$time [,$subtract]);\n\nThis take a date and add the given time to it (or subtract the time if $subtract is\nnon-zero).\n\n$time = $dmb->calctimetime(@time1,@time2 [,$subtract]);\n\nThis take two times and add them together (or subtract the second from the first if\n$subtract is non-zero).\n\ncheck\nchecktime\n$valid = $dmb->check($date);\n$valid = $dmb->checktime($hms);\n\nThis tests a list of values to see if they form a valid date or time ignoring all time zone\naffects. The date/time would be valid in GMT, but perhaps not in all time zones.\n\n1 is returned if the the fields are valid, 0 otherwise.\n\n$hms is in the range 00:00:00 to 24:00:00.\n\ncmp\n$flag = $dmb->cmp($date1,$date2);\n\nReturns -1, 0, or 1 if date1 is before, the same as, or after date2.\n\ndayofweek\n$day = $dmb->dayofweek($date);\n$day = $dmb->dayofweek($ymd);\n\nReturns the day of the week (1 for Monday, 7 for Sunday).\n\ndayofyear\n$day = $dmb->dayofyear($ymd);\n$day = $dmb->dayofyear($date);\n\nIn the first case, returns the day of the year (1 to 366) for \"($y, $m, $d)\". In the second\ncase, it returns a fractional day (1.0 <= $day < 367.0). For example, day 1.5 falls on Jan\n1, at noon. The somewhat non-intuitive answer (1.5 instead of 0.5) is to make the two forms\nreturn numerically equivalent answers for times of 00:00:00 . You can look at the integer\npart of the number as being the day of the year, and the fractional part of the number as\nthe fraction of the day that has passed at the given time.\n\nThe inverse operations can also be done:\n\n$ymd   = $dmb->dayofyear($y,$day);\n$date  = $dmb->dayofyear($y,$day);\n\nIf $day is an integer, the year, month, and day is returned. If $day is a floating point\nnumber, it returns the year, month, day, hour, minutes, and decimal seconds.\n\n$day must be greater than or equal to 1 and less than 366 on non-leap years or 367 on leap\nyears.\n\ndaysinmonth\n$days = $dmb->daysinmonth($y,$m);\n\nReturns the number of days in the month.\n\n@days = $dmb->daysinmonth($y,0);\n\nReturns a list of 12 elements with the days in each month of the year.\n\ndaysinyear\n$days = $dmb->daysinyear($y);\n\nReturns the number of days in the year (365 or 366)\n\ndayssince1BC\n$days = $dmb->dayssince1BC($date);\n$days = $dmb->dayssince1BC($ymd);\n\nReturns the number of days since Dec 31, 1BC. Since the calendar has changed a number of\ntimes, the number returned is based on the current calendar projected backwards in time, and\nin no way reflects a true number of days since then. As such, the result is largely\nmeaningless, except when called twice as a means of determining the number of days\nseparating two dates.\n\nThe inverse operation is also available:\n\n$ymd = $dmb->dayssince1BC($days);\n\nReturns the date $days since Dec 31, 1BC. So day 1 is Jan 1, 0001.\n\nleapyear\n$flag = $dmb->leapyear($y);\n\nReturns 1 if the argument is a leap year.\n\nnthdayofweek\n$ymd = $dmb->nthdayofweek($y,$n,$dow);\n\nReturns the $nth occurrence of $dow (1 for Monday, 7 for Sunday) in the year. $n must be\nbetween 1 and 53 or -1 through -53.\n\n$ymd = $dmb->nthdayofweek($y,$n,$dow,$m);\n\nReturns the $nth occurrence of $dow in the given month. $n must be between 1 and 5 or it can\nbe -1 through -5.\n\nIn all cases, nothing is returned if $n is beyond the last actual result (i.e. the 5th\nSunday in a month with only four Sundays).\n\nsecssince1970\n$secs = $dmb->secssince1970($date);\n\nReturns the number of seconds since Jan 1, 1970 00:00:00 (negative if date is earlier).\n\n$date = $dmb->secssince1970($secs);\n\nTranslates number of seconds into a date.\n\nsplit\njoin\nThe split and join functions are used to take a string containing a common type of time data\nand split it into a list of fields. The join function takes the list and forms it into a\nstring.\n\nThe general format for these is:\n\n$obj    = $dmb->split($type,$string,\\%opts);\n$string = $dmb->join($type,$obj,\\%opts);\n\nAn older format is also supported:\n\n$obj    = $dmb->split($type,$string,[$nonormalize]);\n$string = $dmb->join($type,$obj,[$nonormalize]);\n\nbut this is deprecated and will be removed in Date::Manip 7.00. These are equivalent to:\n\n$obj    = $dmb->split($type,$string,{ 'nonorm' => $nonormalize });\n$string = $dmb->join($type,$obj,{ 'nonorm' => $nonormalize });\n\nThe value of $type determines what type of join/split operation occurs.\n\nRudimentary error checking is performed with both of these functions and undef is returned\nin the case of any error. No error checking is done on the specific values.\n\n$type = 'date'\n$date = $dmb->split(\"date\",$string);\n$string = $dmb->join(\"date\",$date);\n\nThis splits a string containing a date or creates one from a list reference. The\nstring split must be of one of the forms:\n\nYYYYMMDDHH:MN:SS\nYYYYMMDDHHMNSS\nYYYY-MM-DD-HH:MN:SS\n\nThe string formed by join is one of the above, depending on the value of the\nPrintable config variable. The default format is YYYYMMDDHH:MN:SS, but if Printable\nis set to 1, YYYYMMDDHHMNSS is produced, and if Printable is set to 2, the\nYYYY-MM-DD-HH:MN:SS form is produced.\n\n$type = 'hms'\n$hms = $dmb->split(\"hms\",$string);\n$string = $dmb->join(\"hms\",$hms);\n\nThis works with the hours, minutes, and seconds portion of a date.\n\nWhen splitting a string, the string can be of any of the forms:\n\nH\nH:MN\nH:MN:SS\nHH\nHHMN\nHHMNSS\n\nHere, H is a 1 or 2 digit representation of the hours but HH (and all other fields)\nare two digit representations.\n\nThe string formed by the join function will always be of the form HH:MN:SS.\n\nThe time must be between 00:00:00 and 24:00:00.\n\n$type = 'offset'\n$offset = $dmb->split(\"offset\",$string);\n$string = $dmb->join(\"offset\",$offset);\n\nAn offset string should have a sign (though it is optional if it is positive) and is\nany of the forms:\n\n+H\n+H:MN\n+H:MN:SS\n+HH\n+HHMN\n+HHMNSS\n\nHere, H is a 1 or 2 digit representation of the hours. All other fields are two\ndigit representations.\n\nThe string formed by the join function will always be of the form +HH:MN:SS.\n\nThe offset must be between -23:59:59 and +23:59:59 .\n\n$type = 'time'\n$time = $dmb->split(\"time\",$string,\\%opts]);\n$string = $dmb->join(\"time\",$time,\\%opts);\n\nThe only option supported is:\n\n'nonorm'   0/1\n\nThis works with an amount of time in hours, minutes, and seconds. The string is of\nthe format:\n\n+H:MN:S\n\nwhere all signs are optional. The returned value (whether a list reference from the\nsplit function, or a string from the join function) will have all fields normalized\nunless \"nonorm\" is true.\n\n$type = 'delta'\n$delta = $dmb->split(\"delta\",$string,\\%opts);\n$string = $dmb->join(\"delta\",$delta,\\%opts);\n\nOptions recognized are:\n\nmode     : standard/business\nnonorm   : 0/1\ntype     : exact/semi/approx/estimated\n\nA second format is also supported, but is deprecated and will be removed in\nDate::Manip 7.0.\n\n$delta = $dmb->split(\"business\",$string,\\%opts);\n$string = $dmb->join(\"business\",$delta,\\%opts);\n\nThese are equivalent to using 'delta' with an option of \"'mode' =\" 'business'>.\n\nThese split a string containing a delta, or create a string containing one using the\nrules described in the Date::Manip::Delta documentation.\n\nThe string that can be split is of the form:\n\nY:M:W:D:H:MN:S\n\nAny field may have a sign, but they are optional.\n\nFields may be omitted entirely. For example:\n\nD:H:MN:S\nD:::S\n\nare both valid.\n\nThe string or list output is normalized unless the nonorm option is passed in.\n\nThe type of the delta (which determines how it will be normalized) will be\nautomatically determined if not specified. The type will default to the value given\nin the table below based on the FIRST condition that is true.\n\ndefaulttype  condition\n\nestimated     any field is a non-integer\napprox        any of the approximate fields are non-zero\nsemi          any of the semi-exact fields are non-zero\nexact         only the exact fields are non-zero\n\nweek1day1\n$ymd = $dmb->week1day1($y);\n\nThis returns the date of the 1st day of the 1st week in the given year. Note that this uses\nthe ISO 8601 definition of week, so the year returned may be the year before the one passed\nin.\n\nThis uses the FirstDay and Jan1Week1 config variables to evaluate the results.\n\nweeksinyear\n$w = $dmb->weeksinyear($y);\n\nThis returns the number of ISO 8601 weeks in the year. It will always be 52 or 53.\n\nweekofyear\n($y,$w) = $dmb->weekofyear($date);\n($y,$w) = $dmb->weekofyear($ymd);\n\nThis returns the week number (1-53) of the given date and the year that it falls in. Since\nthe ISO 8601 definition of a week is used, the year returned is not necessarily the one\npassed in (it may differ for the first or last week of the year).\n\nThe inverse operation is also available:\n\n$ymd = $dmb->weekofyear($y,$w);\n\nwhich returns the first day of the given week.\n\nThis uses the FirstDay and Jan1Week1 config variables to evaluate the results.\n",
            "subsections": []
        },
        "KNOWN BUGS": {
            "content": "None known.\n",
            "subsections": []
        },
        "BUGS AND QUESTIONS": {
            "content": "Please refer to the Date::Manip::Problems documentation for information on submitting bug\nreports or questions to the author.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Date::Manip - main module documentation\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "This script is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Sullivan Beck (sbeck@cpan.org)\n",
            "subsections": []
        }
    },
    "summary": "Date::Manip::Base - Base methods for date manipulation",
    "flags": [],
    "examples": [],
    "see_also": []
}