44 | constructor | Initialiser Instructions | Overall constructor Creates a DAYo object with Intitaliser as the data and an optional Instructions to tweak or command In all cases the triksy grunt work is done by methods with the name convention ._Read...() Look at the documentation of those methods for details Initialiser is a string, number, Javascript Date, (see below) a DAYo to clone or an array [Signature,Sign,Y,M,D,Error code] Instructions depend on type of Initialiser number : DAYu.force32Bits ('32') default DAYu.forceJulian ('J') DAYu.forceTimestamp ('STAMP') string : An array ..................... _ReadUsingTemplate DAYu.forceYMD ('YMD') read just Y-M-D DAYu.forceYMDHMS ('YMDHMS') read extended using time bits DAYu.forceTilde ('~') read simple tilde format default is do the best we can looking for common patterns Date DAYu.forceYMDHMS ('YMDHMS') read extended using time bits default is only use Y M D to make a fully specified DAY |
1795 | AddDays | NoDays | add (-ve = subtract) a given number of days from a specific CAL date returns a new DAYo NK,EOT,BOT return themselves Anything else returns NV AR1 When adding days alone to a SPECIFIC date: Count according to the real calendar. AR2 Use method a. *** If AR2b is required use Tinterval method *** 'D' @@@ INT routine needs attention !@@@| Lots wrong with this routine |
1846 | AddMonths | NoMonths | add ( -ve = subtract ) specified number of months return new DAYo AR3: When adding months alone to a date: Convert the days part of the date into fractions of that month. Then add the months, carrying base 12 as required. Now convert the fraction back into days according to the actual length of the new month. May throw error if trying to add months to just a year but this will be ignored if NoMonths is a multiple of 12
|
1897 | AddYears | NoYears | add ( -ve = subtract ) specified number of years See .AddMonths() |
1668 | After | Aday | compares the logical values of the dates. Returns true if THIS is AFTER the ARGUMENT See Before() |
1405 | AsDays | Convert an interval into days Result may be fractional and negative | |
1633 | Before | Aday | Compares the logical values of the dates. Returns true if THIS is DEFINITELY before ARGUMENT Note there are many cases where this test doesn't make sense or where the data cannot possibly be interpreted. All of these will return false without any error being raised. Therefore it is up to the programmer to avoid propagating spurious FALSEs by suitably guarding before calling. |
1585 | CalendarType | if this is a CAL then tell what type 0 .. fully specified DAYu.CALTYPE_YMD 000 1 .. no day DAYu.CALTYPE_YMX 001 3 .. just year DAYu.CALTYPE_YXX 011 7 .. not calendar DAYu.CALTYPE_ERR 111 These funny values are because we use them in various representations to mask components we don't use. A 1 bit signifies unused | |
925 | ClearWWWS | Clear .whatWentWrongStr | |
1714 | Contains | Aday | Return true if this date is the same as or encompasses the argument. This must have the same or lower precision than the argument. Possible combinations for sensible testing ------------------------------------------ CAL y m d - y m d y m 0 - y m d y 0 0 - y m d, y m 0 FLO 0 m 0 - 0 m d Unsuitable values return false not an exception |
1939 | Copy | Aday | Copies all the argument's properties to this Not the same as .MakeClone() Always returns true
|
1988 | DateToString | Template | return a string representation of a CAL or FLO The format string is a sequence of two-character tokens that describe the elements to be included in the output These may be interleaved with literal characters. The Day(number) and Month elements will normally automatically be exchanged to match the DM_ORDER parameter in the appendix. (can be disabled with the -S flag) CALENDAR DATE FORMATTING CODES ------------------------------ y1 ... year without any leading zeroes y2 ... 2-digit year y4 ... 4-digit year m1 ... 1 or 2-digit month number m2 ... 2-digit month number M2 ... Month name tiny M3 ... Month name short M4 ... Month name long d1 ... 1 or 2-digit day number d2 ... 2-digit day number D2 ... Day name tiny D3 ... Day name short D4 ... Day name long BC ... BC indicator FLAGS ------------------------------ -T ... Don't use 'Today' -E ... Add extended NV and NVI reasons -S ... Disable effect of DM_ORDER |
1363 | Day | return day value. 0 implies not set | |
1446 | DayOfWeek | Day of week No date-day returns 0. Monday ... Sunday returns 1 ... 7 | |
1917 | DaysDifference | Aday | How many days difference |
1926 | DumpStr | Return string version of internal state for debugging | |
1229 | FirstDay | return first specific day | |
1605 | FloatType | if this is floating then tell what type 6 .. Floating day DAYu.FLOTYPE_XXD 110 5 .. Floating month DAYu.FLOTYPE_XMX 101 4 .. Floating month-day DAYu.FLOTYPE_XMD 100 0 .. not floating DAYu.FLOTYPE_ERR 000 These funny values are because we use them in various representations to mask components we don't use. A 1 bit signifies unused | |
1350 | FractionOfMonth | How far through month are we? Might throw error if year needed for February and not given Only applicable to CALs of form y+m+d and m+d | |
928 | GetErrorCode | what is the numerical value of the error | |
923 | GetWWWS | Get .whatWentWrongStr | |
1089 | HasDay | Return true if the day component is specified | |
1086 | HasMonth | Return true if the month component is specified | |
1092 | HasYear | Return true if the year component is specified | |
1095 | IsBC | Return true if the sign component is negative | |
1025 | IsBoT | Test for BoT signature | |
1062 | IsCalendar | Is this a calendar day of the form Y or YM or YMD | |
1028 | IsEoT | Test for EoT signature | |
1057 | IsErrorFree | True if there is no error reported | |
1048 | IsFloating | Test for a FLO signature | |
1035 | IsGiven | Test for a signature indicating a workable date ie. NK, BoT, Cal or EoT | |
1073 | IsGoodCalendar | MonthRequired DayRequired | Is it error-free and a calendar day with specified precision MonthRequired and DayRequired are boolean flags |
1031 | IsInterval | Test for INT or NVI | |
1039 | IsKnown | Test for signature indicating a 'known' date. ie. BoT, Cal or EoT | |
1022 | IsNotKnown | Test for NK signature | |
1052 | IsRealPeriod | Test for a real date which could be Y or YM ie. Day component is missing | |
832 | IsSameValue | DAYobj StrictFlag | See if two DAYs have the same value If StrictFlag is truthy then errorCodes must match as well. |
1043 | IsSpecific | Is this a Cal that referrs to a specified day. ie. Day, month and year components are all specified | |
1104 | IsToday | Return true if this is today | |
1014 | IsValid | Does DAYo have a valid signature This does not mean free from errors See IsErrorFree() and IsGoodCalendar() | |
1019 | IsValidDate | Test for a valid DAYo signature This does not mean free from errors See IsErrorFree() and IsGoodCalendar() | |
1432 | Julian | Julian() Return Julian day number * VERY IMPORTANT FUNCTION * Returns iNV if not a fully specified date | |
1232 | LastDay | return last specific day | |
1243 | Middle | Middle date of a range | |
1374 | Month | return month value 0 implies not set | |
1911 | MonthsDifference | Aday | How many months difference |
1238 | Next | return next Same sort of period | |
1235 | Previous | return previous Same sort of period | |
592 | SetNV | Code Where Desc | Set the signature of this object to NV with error codes and what went wrong string Always returns false Code is a DAYu error code Where is the routine that spotted the error Desc is an optional txt message to go into what went wrong (See ._WWWS) NOTE This operates on the object itself |
1397 | Signature | returns signature (integer) | |
1571 | SortsBefore | Aday | Does this DAYo sort before the DAYo in the argument |
1471 | To32Bits | To32Bits() Returns an unsigned number bits 31 - 29 Signature bits 28 Sign 0:-ve 1:+ve bits 27 - 16 Year 0 ... 4095 bits 15 - 12 Month 1:Jan ... 12:Dec 0 is legal bits 11 - 7 Day of month 1 ... 31 0 is legal bits 6 - 3 Day of week (Fully specified) 1:Mon ... 7:Sun 0:Undefined Not valid reason code (NV) See table 7 bit 3 Not used bit 2 Valid flag 1:Is validated bit 1 Fully specified 1:Is fully specified bit 0 Interval 1:Is interval | |
1559 | ToDate | return a fully encoded Javascript Date H, m and s are encoded | |
1278 | ToString | Arg1 Arg2 | ToString('Template','ExtendErrorCodeFlag') Default string representation. * Template (string) : See .DateToString() for template details and options * Also may be '~' to return a tilde separated easy string * ExtendErrorCodeFlag (boolean) : Missing/False->Number code True->String messages |
1326 | ToTilde | NumericFlag | Return easy to read string that is part of a standard The format is sig~sign~y~m~d~error Normally the output will be easy to read mnemonics and no padding but if NumericFlag is true then all values will be numeric and padded where appropriate. |
1502 | ToYmdhms | ResultType | ToYmdhms(ResultType) Depending on the ResultType argument this can return 'ARRAY' an array encoded the form 'y,m,d,h,m,s' 'DATE' a javascript Date object with h,m,s encoded 'YMDHMS' a string formatted as yyyy-mm-dd hh:mm:ss 'YMDTHMSZ' a string formatted as yyyy-mm-ddThh:mm:ss.000Z 'STAMP' Unixy timestamp version of DATE (milliseconds since January 1, 1970, 00:00:00 UTC -ve for prior)
|
1384 | Year | returns a signed year number or 0 if not set | |
1904 | YearsDifference | Aday | How many years difference |
1419 | _FloatingMetric | Internal function that returns a simple metric 'day count' 32 * days + months Only applicable to floats | |
147 | _FromDayi | Dayi | Given a DAYi object we convert into pure DAYo |
2447 | _FromInterval | Dayi | Read an interval into this DAYo
|
2141 | _LimitChars | Num Padding | Turn a string into a number with 0,2 or 4 zeros padding Padding should be 0, 2 or 4 |
815 | _Matches | ArrayOfInnerValues | _Matches Tests internal structure against supplied array 'Signature,Sign,y,m,d,errorCode' |
1117 | _RangeEnd | BegOrEnd | Return the earliest or latest possible date for this Date * BegOrEnd argument is one of DAYu.BoT or DAYu.EoT for beginning and end respectively * Throws error if Arg is bad or unsuitable signature
|
881 | _Read32Bits | UnsignedInt | Read native 32-bit format Sets DAY from number bits 31 - 29 Signature bits 28 Sign 0:-ve 1:+ve bits 27 - 16 Year 0 ... 4095 bits 15 - 12 Month 1:Jan ... 12:Dec 0 is legal bits 11 - 7 Day of month 1 ... 31 0 is legal bits 6 - 3 Day of week (Fully specified) 1:Mon ... 7:Sun 0:Undefined Not valid reason code (NV) See table 7 bit 3 Not used bit 2 Valid flag 1:Is validated bit 1 Fully specified 1:Is fully specified bit 0 Interval 1:Is interval Doesn't sanitize |
184 | _ReadArray | Ay | Ay is of the form [Signature,Sign,Y,M,D,Error code] |
230 | _ReadDate | JsDate UseTimeBits | Use a Javascript Date object to populate ourselves JsDate is a Javascript Date object UseTimeBits is a boolean flag to tell if the HMS part is to be used for rich dates. This would be false or missing for fully specified dates (ie. where Y,M and D are all valid). Note that if H,Mins,S are all 0 it is automatically treated as a simple YMD case.
|
199 | _ReadJulian | Julian | Set ourselves from a Julian day number Does not sanitize |
2198 | _ReadString | Str Patterns | Read a string according to one or more patterns Returns false if the input is weird Pattern tokens -------------------------------------- Y2 two digit year ) Typically appear Y4 Four digit year ) in combinations YY Y2 or Y4 ) yy YY but may be missing ) M1 One or two digit month ) M2 Two digit month ) MN Month name (incl partials) ) D1 One or two digit day ) D2 Two digit day ) aa Alpha to be ignored ) TY Today shortcut ) Always appear NV Not valid shortcut ) on their own NK Not known shortcut ) as they're nk Blank => Not known ) complete if ET End of time/Not yet ) found et Blank => End of time ) BT Beginning of time ) bt Blank => Beginning of time ) space optional space/punctuation ) All non alpha-numerics are treated as punctuation _ required space/punctuation ) Multiple punctuation characters are treated as one DEBUG Switches on diagnostics which will be returned in .whatWentWrongStr Combined pattern examples -------------------------------------- For example 'D2M2Y2' exactly six digits with no spaces 'DD MN yy' 1/2 day digits, month name, 2/4 digit year or year guessed 'mm YX' requires a month name but the year will be substituted if not present 'Y4 M2 D2' yyyy mm dd (Would match 2017::::05???+-=23) 'D1_M1_yy' would match '1 2' and 01,02,2017 but not 01022017 We automatically pick-up if the last token is the BC indicator string A special, complete on its own, pattern of DEBUG will switch-on pattern matching failures to .whatWentWrongStr
|
289 | _ReadText | Str | Read an ordinary human style text input We'd use this as a catch-all interpreter when ._ReadString() (which requires a sert of specified patterns) is not suitable. This has wonderful interpretive and guessing adaptability, but the trade-off for that is possible unintended results. Return false if an error |
166 | _ReadTilde | Str | String is in the form sig~sign~y~m~d~err
|
215 | _ReadTimestamp | UnixMilliseconds UseTimeBits | UnixMilliseconds is a standard UNIX timestamp Optional UseTimeBits is for when you can't use native 32-bit format Really a wrapper for .FromDate() |
610 | _ReadYMDHMS | Str UseTimeBits | The input is of the form YYYY-MM-DD with optional HH:MM:SS addition. Typically this will return a fully specified date, but the time elements may have been hacked to shoehorn a full DAYo object's data into an existing database field etc. Time elements are ignored unless optional UseTimeBits is true.
|
132 | _Reset | Reset all internal values .signature = NV .sign = pos .yr, .mo and .dy all set to 0 .errorCode = noError .whatWentWrongStr = '' This is not persistent or cloned. Read using GetWWWS() | |
711 | _Sanitize | WhereFrom | _Sanitize Private method to ensure internal values are safe If any errors then sanitize them and set signature to NV Return false if any errors found Tell error to .whatWentWrongStr WhereFrom is an optional string that tells the calling routine which can go into .whatWentWrongStr |
522 | _SetCalHelper | Y M D | We've got a d,m and y to process to finish |
494 | _SetFloatHelper | M D | We've got a float, so finish it off. The patterns are (0,day),(month,0),(month,day) |
974 | _SetFloats | PartialMask | Zero any of the Y M D values in a Flo according to The three-bit PartialMask If PartialMask is invalid or not a Flo then return false Typical use is when masking during an input conversion Return false if an issue |
938 | _SetPartials | PartialMask | Zero any of the Y M D values in a Cal according to The three-bit PartialMask If PartialMask is invalid or not a Cal then return false Typical use is when masking during an inout conversion Return false if an issue |
918 | _SetWWWS | NewErrorStr | Add error message to .whatWentWrongStr NewErrorStr should be of the form: [current routine] message Always returns false |
853 | _SetYear | Year | Set Year and deal with negative values |
1168 | _Step | BegOrEnd | Find the previous/next for dates eg 1957 ->1958, Aug 1957 -> Sep 1957, 13 Aug 1957 -> 14 Aug 1957 Returns a new DAYo Technically allow floats also eg 13 Aug -> 14 Aug but leap years will be a potential disaster so this IS NOT RECOMMENDED for use with floats. NB DO NOT try to add 3 days with three calls to this function etc. * BegOrEnd argument is one of DAYu.BoT or DAYu.EoT for beginning and end respectively * Throws error if Arg is bad or unsuitable signature
|
50 | BADFROMFORMAT | 1, | weird input to a .From...() method |
51 | BADFROMVALUE | 2, | some value to a .From...() method is unsuitable |
24 | BoT | 5, | beginning of time |
128 | CALTYPE_ERR | 7, | types of calendar dates |
129 | CALTYPE_YMD | 0, | fully specified ->>PRECISION_DAY->>3 |
130 | CALTYPE_YMX | 1, | no day (M+Y) ->>PRECISION_MONTH->>2 |
131 | CALTYPE_YXX | 3, | just year ->>PRECISION_YEAR-->1 |
102 | CONV_STATUS_INVALIDEXT | 1, | Invalid extension found in t/stamp or date |
103 | CONV_STATUS_NOT_FULL_DATE | 2, | Conversion failure of some sort |
25 | Cal | 6, | Calendar date |
814 | Convert2to4DigitYear | Year,BlockFlag | Given the supplied two digit year convert it into a 4 digit year using the rules given by the TWO_DIGIT_FIX setting. 0 = Disallow 20 = convert yy -> 20yy 50 = convert yy so that it lies between 50 years ago and 50 years ahead If the argument <0 or TWO_DIGIT_FIX = 0 then return 0 If the argument is already 4 digits then leave it alone Year can be a string (preferable) as this helps weed things like 0067 which is 0067 not 2067 etc Optional BlockFlag returns the number without any conversion To call from inside DAYo use (this.sign==DAYu.neg) returns 0 if fail/disallow |
153 | DAYSINMONTH | 30.4375, | 365.25 / 12 |
62 | DFS_STATUS_ALPHANOTUNDERSTOOD | 3, | alpha isn't shortcut or month name |
65 | DFS_STATUS_CANTDECODEDDMMYY | 5, | 2,4,6 or 8 digits only |
57 | DFS_STATUS_EMPTYSTRING | 1, | all whitespace |
61 | DFS_STATUS_MORETHANONEALPHA | 2, | only 1 alpha token allowed |
60 | DFS_STATUS_NOTOKENS | 2, | no alpha numerics in string |
56 | DFS_STATUS_OK | 0, | |
58 | DFS_STATUS_TOOLONG | 1, | sanity limit of 40 characters (far more than needed) |
59 | DFS_STATUS_TOOMANYTOKENS | 2, | max 6 tokens (far more than needed) |
67 | DFS_STATUS_UNKNOWNERROR | 7, | Sanitize failure |
66 | DFS_STATUS_UNSUITABLENUMBER | 6, | unsuitable numeric value somewhere |
63 | DFS_STATUS_YEARMISSINGORBAD | 4, | missing or bad year |
64 | DFS_STATUS_YEARNOT2OR4DIGITS | 4 , | year must be yy or yyyy |
486 | DayCountToYmdIntArray | DayCount | DayCount is a number of days (Not necessarily an integer) Return an array of 'Y,M,D' after applying the necessary conversions Uses the fractional conversion factor DAYu.DAYSINMONTH |
470 | DayOfMonthToFraction | Y,M,D | How far through the month is this d/m/y? Can throw error if year is missing |
554 | DaysDifference | Aday1,Aday2 | Number of days between date1 and Date2 Example : If D1 is '1 Jan 2001' and D2 is '2 Jan 2001' then result is +1 Uses Julian day subtraction |
445 | DaysInGivenMonth | M,Y | How many days in given month? If m is 2 then use (optional) y to tell us if it is a leap year If y is 0 then it is not a leap year Illegal m argument or m=2 and y=undefined throws an error |
711 | EarliestFinish | ArrayOfCals, IgnoreUnsuitable | What is the earliest finish of these dates? Only Cals are suitable values for the array. NVI,INT,NV,FLO will throw an exception NK,BoT,EoT will NORMALLY throw an excepton UNLESS the optional 2nd arg is set true when NK->NK,EoT->EoT and BoT ignored Zero-length array throws an exception |
675 | EarliestStart | ArrayOfCals, IgnoreUnsuitable | What is the earliest start date of these dates? Only Cals are suitable values for the array. NVI,INT,NV,FLO will throw an exception NK,BoT,EoT will NORMALLY throw an excepton UNLESS the optional 2nd arg is set true when NK->NK,BoT->BoT and EoT ignored Zero-length array throws an exception |
26 | EoT | 7, | End of time |
22 | FLO | 3, | floating date |
125 | FLOTYPE_ERR | 2, | error |
124 | FLOTYPE_XMD | 4, | month and day only |
123 | FLOTYPE_XMX | 5, | month only |
122 | FLOTYPE_XXD | 6, | types of floating date |
99 | FTS_STATUS_INVALIDSIG | 1, | Error codes for FromTimestamp & date |
477 | FractionToDayOfMonth | Y,M,Fraction | Inverse of DayOfMonthToFraction() |
375 | GetDefaultYear | return the default year Use IMPLIED_YEAR to tell us what to do return iNV if missing years are not allowed IMPLIED_YEAR ... Return 0 ........ iNV Do not allow inputs that miss out year part. Return iNV -1 ........ yyyy Use the current year -2 ........ 0 Allow floating date input nnnn ........ nnnn Use the specified year Possible returns are iNV,0,yyyy | |
403 | GuessCurrentYearForMonth | MonthNum | Suppose we want to let clerks type in "4 May" without having to type in 2017 every bloody time! A huge number of date inputs are 'around now' so this is a useful trick. This function looks at the month and guesses which year it applies to. For example if it's now January 2017 and the input is 12 (December) then that probably referrs to 2016 just past. 'WARNING' While this is a useful short-cut there are two issues that should be understood. 1: Obviously this is only applicable to certain fields. 2: Clerks won't care about the correctness of out of the ordinary inputs so system-level checks for data integrity will be required. |
74 | IFS_STATUS_BADLENGTH | 1, | too short or too long |
76 | IFS_STATUS_NOTOKENS | 2, | Must have at least one part |
73 | IFS_STATUS_OK | 0, | |
79 | IFS_STATUS_SIGNMISPLACED | 5, | + or - other than at start |
77 | IFS_STATUS_SIGNMISSING | 3, | must start with + or - |
75 | IFS_STATUS_TOOMANYTOKENS | 2, | Can only have three parts |
78 | IFS_STATUS_UNKNOWNUNIT | 4, | suffix not recognised |
80 | IFS_STATUS_UNSUITABLENUMBER | 6, | unsuitable numeric value somewhere |
20 | INT | 1, | Interval |
90 | INTERR_BADDATA | 1, | malformed string/ data/ constructor arg |
89 | INTERR_OK | 0, | No error |
95 | INTERR_READ_NV | 6, | Read from a string as NV |
96 | INTERR_TOBITS | 7, | Conversion to 32 bits failed |
93 | INTERR_USED_BT | 4, | ) a scalar value. |
94 | INTERR_USED_ET | 5, | ) |
92 | INTERR_USED_NK | 3, | ) DAYo methods means we can't arrive at |
91 | INTERR_USED_NV | 2, | ) One or more of the arguments used by |
87 | INTPRES_D | 3, | precise to day |
86 | INTPRES_M | 2, | precise to month |
84 | INTPRES_X | 0, | Constants for intervals |
85 | INTPRES_Y | 1, | precise to year |
138 | INTTYPE_D | 3, | precise to day (same as PRECISION_DAY) |
135 | INTTYPE_DDD | 0, | types of interval precision |
137 | INTTYPE_M | 2, | precise to month (same as PRECISION_MONTH) |
139 | INTTYPE_X | -1, | error |
136 | INTTYPE_Y | 1, | precise to year (same as PRECISION_YEAR) |
427 | IsLeapYear | Y | Is a given year a leap year? |
328 | JulianToYMD | Julian | Split Julian day number into array 'of Y,M,D' It may throw an exception through an unsuitable input (2436064 = 13/08/57) * SEE ALSO _JulianToCal() and DAYo constructor |
699 | LatestFinish | ArrayOfCals, IgnoreUnsuitable | What is the latest finish of these dates? Only Cals are suitable values for the array. NVI,INT,NV,FLO will throw an exception NK,BoT,EoT will NORMALLY throw an excepton UNLESS the optional 2nd arg is set true when NK->NK,EoT->EoT and BoT ignored Zero-length array throws an exception |
687 | LatestStart | ArrayOfCals, IgnoreUnsuitable | What is the latest start date of these dates? Only Cals are suitable values for the array. NVI,INT,NV,FLO will throw an exception NK,BoT,EoT will NORMALLY throw an excepton UNLESS the optional 2nd arg is set true when NK->NK,BoT->BoT and EoT ignored Zero-length array throws an exception |
912 | MakeBoT | Construct DAYo for Beginning of time | |
902 | MakeClone | DayObj | Clone a DAY object Copies .errorCode but not .whatWentWrongStr |
915 | MakeEoT | Construct DAYo for End of time | |
943 | MakeINT | Years,Months,Days | Construct a DAYi interval See DAYi.SetYMD() |
918 | MakeNK | Construct DAYo for Not known | |
927 | MakeNV | ErrorCode,Desc,MoreDayInfo | Construct DAYo for Not Valid ErrorCode is a number 0 - 7 Desc is an optional string description. To put the name of the routine into the description put it in square brackets at the front by convention in the manner of ._SetWWWS() MoreDayInfo is an option DAYo object we will use to copy the sign,y,m,d elements from Compare with .SetNV() which is an object method rather than a constructor |
950 | MakeNVI | ErrorCode | Construct a not valid interval with an optional error code |
909 | MakeToday | Construct DAYo for Today | |
784 | MonthOnly | Aday | Return a DAYo with just the month component |
587 | MonthsDifference | Aday1,Aday2 | calculate (or approximate if days are involved) the number of months difference. (Date2 - Date1) Arguments must have the same pattern of y/m/d components and be CAL or FLO. Cal y m d, y m 0 or y 0 0 FLO 0 0 d, 0 m 0 or 0 m d |
23 | NK | 4, | date not known |
21 | NV | 2, | Not a date value |
162 | NVD_INT_MULTINEGATIVE | 1, | Not valid details ---day--- ---date--- ---int--- |
19 | NVI | 0, | Invalid interval |
106 | NVR_FUNCTION_FAILURE | 7, | Not valid reasons |
107 | NVR_NOT_CONCURRENT | 8, | '@' change to 1..7 |
146 | PRECISION_DAY | 3, | fully specified |
143 | PRECISION_ERR | -1, | types of precision NB The greater the value the more precise |
145 | PRECISION_MONTH | 2, | only to months |
144 | PRECISION_YEAR | 1, | only to years |
156 | SECONDSPERDAY | 864000, | eg (J - UNIXDAYSTOJULIAN) * 86400 -> U |
29 | SIGNATURE_STRINGS | ['NVI', 'INT', 'NV', 'FLO', 'NK', 'BoT', 'Cal', 'EoT'], | |
35 | SIGN_STRINGS | ['-ve','+ve','-','+'], | |
211 | SigStrToConst | Str | Convert a three character string into a signature constant Case insensitive Special case where digits 0..7 are allowed 'as they are' Returns NV if unable to interpret Str 'T' |
194 | SigToStr | Sig, NumericFlag | Signature code to three character string Sig is number 0..7 Return appropriate string from DAYu.SIGNATURE_STRINGS If optional boolean NumericFlag is true then return a single digit string "0".."7" 'T' |
249 | SignStrToConst | Str | - or -ve return DAYu.neg anything else returns DAYu.pos 'T' |
235 | SignToStr | Sign, NumericFlag | Sign to three character string Sign is 0 or 1 returning "-" or "+" If optional boolean NumericFlag is true then return a single digit string "0" or "1" 'T' |
532 | SortsBefore | Day1,Day2 | Compare two DAYo objects If both are intervals then compare magnitude otherwise compare on 32 bit representation Return -1 d1 < d2 0 d1 == d2 +1 d1 > d2 (Note this is SIMILAR but not identical to DAYo.SortsBefore() which conflates == and > into false.) |
957 | SumIntervals | Intervals | Construct an interval by adding one or more intervals |
154 | UNIXDAYSTOJULIAN | 2440587, | Number to add to Unix day number to get Julian day number |
167 | UNIX_BOT | -2147540400, | 13 Dec 1901 05:00:00 |
168 | UNIX_EOT | 2147410800, | 18 Jan 2038 07:00:00 |
166 | UNIX_NK | -2147544000, | 13 Dec 1901 04:00:00 |
165 | UNIX_NV | -2147551200, | special values for unix timestamps |
69 | UNKNOWNERROR | 7, | Sanitize failure |
150 | YEAR_GUESS_DELAY | 4, | how many months might we go back to last year in GuessCurrentYearForMonth() |
266 | YMDToJulian | Yr, Mo, Dy | Create Julian day number from Year, month and day Year can be +ve or negative |
630 | YearsDifference | Aday1,Aday2 | Practically the same as MonthsDifference / 12 except - unsuitable args returns iNV - where CAL pattern is y 0 0 the calculation is simple subtraction. |
854 | _Div | a,b | Utility integer division function eg (7,2) -> 3 |
719 | _EarliestLatestAnyAll | Caller, ArrayOfCals, IgnoreUnsuitable | Internal servicing method for Earliest/Latest Any/All Caller is two character code eg EF for EarliestFinish |
883 | _IsAlpha | Str | returns true if Str is all alpha @@@ Do we ever use this now? |
890 | _IsNumeric | Str | returns true if Str is all numbers @@@ Do we ever use this now? |
351 | _JulianToCal | Julian | |
866 | _PadInt | LeftPadChr, Num, Width, Zero | Utility pad-right for integer LeftPadChr is typically 0 or space Num is numeric value Width is total width (Grows by 1 if Num is -ve) Zero is an optional substitute character for 0 |
513 | _StepYear | Year,Increment | Step year up or down but trap year 0 |
46 | badNumber | 6, | FromJulian() |
44 | badSetObject | 2, | DAYo.Set() given inappropriate object |
43 | badSetSignature | 1, | DAYo.Set() given inapropriate signature |
39 | canNeverHappen001 | -1, | Dayo.Set() |
173 | debuggingTrail | { | Debugging trail that can be used to log as required Call as DAYu.debuggingTrail.Add(someMessage) etc. |
115 | force32Bits | '32', | |
114 | forceJulian | 'J', | |
119 | forceTilde | '~', | |
118 | forceTimestamp | 'STAMP', | |
116 | forceYMD | 'YMD', | |
117 | forceYMDHMS | 'YMDHMS', | |
111 | iNV | -9999999, | integer not valid return value iNV |
32 | neg | 0, | sign negative |
40 | noError | 0, | |
33 | pos | 1, | sign positive |
45 | unsuitableRange | 3, | DAYo.Middle() on inapropriate object |
15 | version | "Built on {{BUILDDATE}}", | curly placeholder modified by build-tools |
147 | AllowDayOnlyIntervals | NewValBool | Do we allow INTs to be created with more than 31 days eg +0y 0m 66d |
132 | AllowExcessDaysInMonth | NewValBool | Get/Set true if we allow silent coercing of slightly too many days in month to end of month |
192 | BCIndicator | String used to indicate negative years @@@ needs to rewritten as get/set | |
263 | BuildCommonTerms | We need to look up shortcuts quite often for inputs so build A list of shortcuts (eg B for BoT) and other terms such as Beg-of-time | |
247 | BuildInputHacks | Create a lookup dictionary to allow some inputs to be converted to other (more acceptable ones) | |
282 | BuildMonthLookups | We're quite likely going to need to look-up month names As with Common Terms we need a shortest version and a full version for different ways of matching | |
443 | DumpCfg | Diagnostic for useful parameters usually pertaining to input strings | |
427 | ExtendedErrorStr | DayOrSig,ErrorNumber,ExtraInfo | Return error string (if applicable) If there's no error then return an empty string This can be called in two ways: Either Int(0-7) DayOrSig, Int(0-7) ErrorNumber , optional string ExtraInfo or Just a DAYo object where .whatWentWrongStr will be used as the extra info. eg if(var em = DAYc.ExtendedErrorStr(someDay)){ // single = is correct DoShoutAnError(em); . . . |
472 | INITIAL_DATA | [ | Default, built-in en-gb settings |
162 | ImpliedYear | NewValInt | Get/Set numeric value of IMPLIED_YEAR Allowable inputs are 0,-1,-2 or a year > 999 |
465 | InYearLimits | Year | Check to ensure the year given is within current limits. Only applies to INT and Cal |
62 | Initialise | OptionalAppendixData | Load the appendix file with the UI settings Must be done early on Returns false if there is an error OptionalAppendixData is either text in appendix format or an object in straightforward Key-Value form @@@ We need another method such as GetAppendix(appx-name) as a wrapper which will be file getting and asynch :( |
311 | InterpretString | InpStr | Interpret string Return '' or 0 for not understood Return 'BoT','EoT','NK','NV','TODAY','NVI' if found Return month number |
118 | IsDmyOrder | NewValBool | Get/Set true if we are working in a d-m-y environment Always returns boolean' Only changed if NewValBool is of type boolean |
7 | KV | new Dict(), | |
98 | Lookup | Str,Num | Lookup a key The args may be just a string or a string and number eg ('BoT',3) |
409 | MonthName | MonNum,Version | Convert month number into a name MonNum 1..12 Version 1..4 (2 is 3 characters length) |
364 | SearchMonths | InpStr | Search month names to return a numeric equivilent eg Fe -> 2 Return a numeric equivilent or 0 if not found |
329 | SearchShortcuts | PossibleShortcutStr | Search shortcuts to return a string code eg "BoT" Return null string for not found |
346 | SearchTerms | PossibleTerm | Look to see if PossibleTerm might be start of a standard term For example PT=Be ST=Beg-of-Time -> "BoT" returns key string or null string |
107 | SetKeyValue | Key,Value | Temporaraly (session) set a K-V pair in the configuration Preferably use one of the direct convenience methods |
177 | TwoDigitFix | NewValInt | Get/Set numeric value of TWO_DIGIT_FIX Allowable inputs are 0,20,50 |
203 | _ExtractAppxSettings | AppxFileData,FirstLoad | (private) Read appendix file data. Sets .error to null string if OK |
86 | _Rebuild | ||
9 | appendix | "en-gb.dax", | actual file name |
8 | error | '', | eg load issue such as badly formatted file |
11 | force2or4DigitYears | false, | if true then years input MUST be in the form yy or yyyy |
10 | i18n | "i18n", | path (no trailing slash) to appendix |
49 | inputHacks | new Dict(), | AltStr -> NormalStr (all u/case) |
48 | months1 | new Dict(), | July ->4 |
47 | months32 | new Dict(), | Jy ->4 Jul->4 |
46 | months4 | new Dict(), | These are the officialy approved strings that represent special terms allowed for input of BoT,EoT,NK,NV,NVI,TODAY. (Match if term starts with input.) |
12 | needsBuild | true, | flag if needs to be initialised |
39 | shortcuts | new Dict(), | B->BoT,E->EoT etc |
43 | specialTerms | new Dict(), | shortcuts are the shortest string that identifies a special term eg E for EoT These are generated from the .3 items in section 1 of the appendix for BoT,EoT,NK,NV,NVI,TODAY. (Match if input starts with shortcut) |
13 | yearLimit | 4095, | Maximum size of year |
36 | constructor | Initialiser | Standard constructor Initialiser can be undefined ... Not very useful string ...... see .FromString() number <4096... Number of days >4095... see .From32Bits() array ....... see .FromArray() DAYi object.. make a copy DAYo object.. see .ReadDAYo() |
515 | Add | DAYis UseDurations | Add one or an array of DAYis This is sign sensitive If optional UseDurations is true then convert everything to days NOTE If UseDurations is true then precision will be set to days otherwise the least precise of the operands. This can have unexpected consequences. For example if this is +1y to yearly precision and we 'add' -200d we don't get 156d but 0y Return false if we have a NVI result (In which case the error code is INTERR_USED_NV Note It's important to add a bunch of intervals as an array rather than a succession of individual .Add() operations. This is because .Add() rounds fractions at the end of the procedure. So if you have four intervals of 100 days to add to 1 year (with yearly precision) then doing it the right way will be roundToYears(365.25 + 100 + 100 + 100 + 100) => 2 years but doing it the wrong way will be a succession of roundToYears(365.25 + 100) => 1 year which repeated four times is still 1 year.
|
468 | AsDays | ||
463 | AsMonths | RespectPrecision | |
460 | AsYears | RespectPrecision | Return floating point value for the overall value of the interval in years. note NVIs return 0 If RespectPrecision is true then ignore elements beneath .Precision |
151 | Copy | Dayi | Copy argument values into this |
490 | DaysDifference | Dayi | Comparing the magnitudes of the intervals If this is larger than the argument then the result will be positive. |
417 | DumpStr | Debugging aid | |
451 | Duration | RespectPrecision | The size of the interval including the sign Calculations as for .Magnitude() Note that NVIs return iNV |
277 | ErrorOrPrecision | Depending on the signature (INT or NVI) return appropriate value | |
296 | FromString | IntStr | Read the standard string format for interval of required + or - optional integer then y optional integer then m optional integer then d
|
281 | GetErrorCode | What is the errorCode | |
283 | GetPrecision | What is the precision | |
140 | GetPrecisionOrError | For the purposes of dressing an interval as a DAYo we combine precision and error codes depending on if the error is set. Return whichever is appropriate | |
483 | IsLargerThan | Dayi | Does this have a larger magnitude (ignoring sign) than argument |
411 | IsPositive | ||
481 | IsSmallerThan | Dayi | Does this have a smaller magnitude (ignoring sign) than argument |
285 | IsValid | Is this a valid interval | |
436 | Magnitude | RespectPrecision | The absolute size of the interval ignoring the sign An approximation to number of days This is calculated in days assuming there are 365.25 days in a year and and 1/12th of that each month NVIs return iNV RespectPrecision is an optional boolean which if true will respect the .precision value. So for example +1y 2m with a precision of years will return 365.25 if this is true but 426.125 if missing or false |
413 | MakeNegative | ||
412 | MakePositive | ||
270 | Precision | NewValue | Get or set precision
|
624 | ReduceDays | Days Precision | We have a number of days which we want to set the interval to. A simple case is 300 days where the interval is precise to days in which case we end up with +0y 0m 300d. BUT REAL LIFE ISN'T ALWAYS SIMPLE :( If the precision is monthly then we'll have 200/30.4375 months (=6.57...) which is rounded to give +0y 7m 0d If the precision is yearly 200 days becomes 200/365.25 = 0.547 with the result of +1y 0m 0d. Yearly precision and 150 days gives the result +0y 0m 0d The moral of the story is: If you want to work in days as your unit of duration then stick to plain integers. Precision can be DAYu.INTPRES_Y ... year DAYu.INTPRES_M ... month DAYu.INTPRES_D ... day with Y and M allocated large amounts missing .......... day with all other values zero. Day precision |
196 | SetYMD | Y M D | Simple and mainstream way to set the key values This will automatically set the precision according to what arguments are given/omitted eg (1,2) is monthly but (1,2,0) is daily Values are always integers. The last non-zero value will set the overall sign @@@ allow args to be null also @@@ |
678 | To32Bits | To32Bits() Returns an unsigned number bits 31 - 29 .signature bits 28 .positive 0:-ve 1:+ve bits 27 - 13 .years and .days combined bits 12 - 11 split 0.3 See .FindYDSplit() bits 10 - 7 .months bits 6 - 4 .errorCode (if NVI) or .precision (if INT) bit 3 Not used bit 2 Valid flag 1:Is validated bit 1 bit 0 Interval 1:Is interval | |
377 | ToString | ForceFull DigitCount | Return a string representation. Optionally force all three parts if ForceFull is truthy Optionally pad the output of the digits to a given number using DigitCount so that columns will be aligned |
753 | _FindYDSplit | Y D | How to apportion 15 bits between years and days Possibilities are bits | Max values | result ------+---------------+-------- 12/3 | 4095 7 | 0 10/5 | 1023 31 | 1 5/10 | 31 1023 | 2 3/12 | 7 4095 | 3 ------+---------------+-------- If these combinations won't work straight-off, see ._PackYMD() then hack about:- a) convert everything into months... b) ... then into years and months with spare days If this doesn't work (because too many days) then fudge the months and years. The splitting arrangement is based on the assumption that if you've got a large number of days then you're hardly likely to be bothering with years. Similarly if there are lots of years then who cares about a few days being fudged |
697 | _From32Bits | UnsignedInt | |
234 | _FromArray | DayArray | The lowest level 'constructor', all the other From() methods feed into this. Initialiser is an array 'Signature,Sign,Years,Months,Days,Precision,ErrorString'; .Signature must be DAYu.INT or DAYu.NVI .Years , .Months and .Days may be 0,-1 or a sensible value null is used to indicate missing. For example a string of "+1y 2m" would have a null for .Days. This is important for precision For example "+1y 2m" is precice to month but "+1y 2m 0d" is precise to day .ErrorCode is ignored unless .Signature is NVI
|
122 | _Normalise | Normalising means making sure the M and Y components are within the expected range 0..12 and 0..29 respectively. Un-normalised may have out of range values. Values are always +ve integers regardless. The reason for normalising is to fit into DAYo constraints. Normalising is completely separate from sanitizing It is also INACCURATE. 30 days in every month. 360 days in every year! | |
766 | _PackYMD | Y M D | Pack Y,M,D into 21 bits Y and D have the top 15 bits split between them 2 bits used for where the split is Least significant 4 bits used for month |
164 | _ReadDayo | Dayo | We may have DAYo wrapping an interval. So let's extract it.
|
77 | _Reset | Reset the internal state | |
93 | _Sanitize | fundamental checking of internals Throw all sorts of should never happen errors
| |
810 | _UnpackYMD | I21 | Unpack 21 bits into array 'Y,M,D' |
21 | constructor | Exp Act | ~~~~~~~~~~~~~ Used by library methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Stack expected and actual results NB Don't forget to do Exp='' afterwards |
10 | constructor | Haystack Needle | ~~~~~~~~~~~~~ Used by library methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ case insensitive string comparison |
356 | AddBadTestResult | LineNum,Task,Expected,Actual,Comment | THESE ARE NOT YET OBSOLETE |
364 | AddCommentResult | Comment | |
360 | AddGoodTestResult | LineNum,Task,Expected,Actual,Comment | will be obs |
676 | AddLibraryTest | TestName,Desc,InpArg,OutArg,FunCode | Add a test function to the library TestName will be capitalised Desc is description/purpose (Any authoring/versioning stuff will be comments in the code calling this. InpArg and OutArg describe the sort of input, ie bit in the brackets of a test line, and nature of expected result. FunCode is the actual code NOTE We use the variable DAYx.__FILE__ to inject the source file name This is normally set/cleared by the methods loader. |
318 | AddResult | Ok,TestData,Result,Comment | Add an entry to the results file Ok is boolean or array of 'Ok,TestData,Result' |
811 | AjaxForFiles | Path,Ext,ThenDo | Look for a list of files using AJAX call Path is relative eg './tests/scripts' Extension is type of file incl dot eg .testScript ThenDo is a function taking an array of filenames which have had their extensions removed *NOTE* Browser only |
830 | AjaxLoadMethodFiles | look in the methods directory for js files each should have one or more methods implemented by AddLibraryTest(). All these are eval-ed so as to populate the method library | |
48 | DayDisplay | D | Return HTML for the inner state of the DAYo object |
655 | DescribeLibraryTests | InHtml | List the tests in the library If InHtml is truthy then return a string of TRs else an array of 'Name,Desc,Input,Output,Filename' |
684 | DoTestLine | TestData | Execute a line of a test script |
93 | ErrorCodeToText | ErrCode | Return the text representation of the ErrorCode(number) |
374 | GetNextTestLine | Looks for the next line in the tests that contains an actual test. Return null if 'EOF' or array 'TestName,Function arguments,Expected result string,Comment' | |
164 | InitAtSubstitutions | set @TODAY and @YEAR substitutions ---------------------------------- | |
308 | Output | Label,Values | Send debugging information to results listing Can be toggled by the .showOutput property Label is a string Values is an array of bits to show |
113 | RunTestsInBrowser | FileName | BROWSER MAIN CALL Load the file of tests into an array of lines tests'n' will be the nth line of the file Uses jQuery |
177 | RunTestsInNode | FileName,Fs,Path | NODE MAIN CALL FileName is relative to current dir Fs is fs (file system) variable Path is path utility |
72 | SigToText | Signature | Return the text representation of the signature(number) |
751 | TestDateBothWays | TestData | Implements the DATEBOTHWAYS test |
487 | TestResultsTable | ShowAll | Returns HTML for a table of results (BROWSER) |
777 | TestSetConfig | TestData | Implements the SETCONFIG command (Not actually a test) Normal use : SETCONFIG(KEY,VALUE) Can be used for functions eg SETCONFIG(SetLimitToUnixExtended) |
702 | TestTwoWays | Day | This combines to/from js Date, to/from 32bits, to/from extended unix the result is ok or D, 3, U! being the first failure in the both ways We have this as a general add-on to the other tests so we get lots of coverage We expect these to be pretty reliable... OK Hope... OK wish :) |
447 | Wrap | S,Width | Wrap long text to the specified width When calculating, ignore HTML tags |
625 | _Bar | Text,Width | pad/truncate cell value and add a leading bar |
583 | _DumpResultsToFile | ShowAll | Writes results to file. either <script>.fails or <script>.results depending on ShowAll Filename is in 1st line testResults Node only |
430 | _ErrorPlace | Ex | Return string giving line and file where exception happened *** (Probably FF only. Alternatives at http://eriwen.com/javascript/js-stack-trace/) |
644 | _UnZero | NumStr | Utility function to drop trailing decimal zeroes from a number-string. "123.000" --\> "123" "123.400" --\> "123.4" |
236 | _UpdateOverview | Update the collection of statistics This is an HTML file with links to results Node only | |
36 | __FILE__ | '', | Used when reading-in methods |
34 | atToday | '', | substitution for @TODAY |
35 | atYear | '', | substitution for @YEAR |
37 | firstLine | 1, | |
32 | glines | '', | temp |
38 | lastLine | 9999, | |
26 | libMethods | {}, | library of available tests |
43 | readStringTemplates | ["_D MN yy"], | templates for ._ReadString() |
33 | scriptName | '', | full name of file being used |
41 | showOutput | true, | show results of .Output() |
30 | testFailCount | 0, | |
31 | testPassCount | 0, | |
29 | testResults | [], | results of tests |
28 | tests | [], | definition of test |