Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 400 and 401]

(no description)

File Size: 133 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

YearFrac:: (3 methods):
  fraction()
  excelBug()
  method1()


Class: YearFrac  - X-Ref

fraction($startDate, $endDate, $method = 0)   X-Ref
YEARFRAC.

Calculates the fraction of the year represented by the number of whole days between two dates
(the start_date and the end_date).
Use the YEARFRAC worksheet function to identify the proportion of a whole year's benefits or
obligations to assign to a specific term.

Excel Function:
YEARFRAC(startDate,endDate[,method])
See https://lists.oasis-open.org/archives/office-formula/200806/msg00039.html
for description of algorithm used in Excel

param: mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
param: mixed $endDate Excel date serial value (float), PHP date timestamp (integer),
param: array|int $method Method used for the calculation
return: array|float|string fraction of the year, or a string containing an error

excelBug(float $sDate, $startDate, $endDate, int $method)   X-Ref
Excel 1900 calendar treats date argument of null as 1900-01-00. Really.

param: mixed $startDate
param: mixed $endDate

method1(float $startDate, float $endDate)   X-Ref
No description