Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

(no description)

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

Defines 1 class


Class: structure  - X-Ref

Handles calendar functions for the gregorian calendar.

get_name()   X-Ref
Returns the name of the calendar.

This is the non-translated name, usually just
the name of the folder.

return: string the calendar name

get_days()   X-Ref
Returns a list of all the possible days for all months.

This is used to generate the select box for the days
in the date selector elements. Some months contain more days
than others so this function should return all possible days as
we can not predict what month will be chosen (the user
may have JS turned off and we need to support this situation in
Moodle).

return: array the days

get_months()   X-Ref
Returns a list of all the names of the months.

return: array the month names

get_min_year()   X-Ref
Returns the minimum year for the calendar.

return: int The minimum year

get_max_year()   X-Ref
Returns the maximum year for the calendar

return: int The maximum year

get_years($minyear = null, $maxyear = null)   X-Ref
Returns an array of years.

param: int $minyear
param: int $maxyear
return: array the years

get_date_order($minyear = null, $maxyear = null)   X-Ref
Returns a multidimensional array with information for day, month, year
and the order they are displayed when selecting a date.
The order in the array will be the order displayed when selecting a date.
Override this function to change the date selector order.

param: int $minyear The year to start with
param: int $maxyear The year to finish with
return: array Full date information

get_num_weekdays()   X-Ref
Returns the number of days in a week.

return: int the number of days

get_weekdays()   X-Ref
Returns an indexed list of all the names of the weekdays.

The list starts with the index 0. Each index, representing a
day, must be an array that contains the indexes 'shortname'
and 'fullname'.

return: array array of days

get_starting_weekday()   X-Ref
Returns the index of the starting week day.

This may vary, for example some may consider Monday as the start of the week,
where as others may consider Sunday the start.

return: int

get_weekday($year, $month, $day)   X-Ref
Returns the index of the weekday for a specific calendar date.

param: int $year
param: int $month
param: int $day
return: int

get_num_days_in_month($year, $month)   X-Ref
Returns the number of days in a given month.

param: int $year
param: int $month
return: int the number of days

get_prev_month($year, $month)   X-Ref
Get the previous month.

If the current month is January, it will get the last month of the previous year.

param: int $year
param: int $month
return: array previous month and year

get_next_month($year, $month)   X-Ref
Get the next month.

If the current month is December, it will get the first month of the following year.

param: int $year
param: int $month
return: array the following month and year

timestamp_to_date_string($time, $format, $timezone, $fixday, $fixhour)   X-Ref
Returns a formatted string that represents a date in user time.

Returns a formatted string that represents a date in user time
<b>WARNING: note that the format is for strftime(), not date().</b>
Because of a bug in most Windows time libraries, we can't use
the nicer %e, so we have to use %d which has leading zeroes.
A lot of the fuss in the function is just getting rid of these leading
zeroes as efficiently as possible.

If parameter fixday = true (default), then take off leading
zero from %d, else maintain it.

param: int $time the timestamp in UTC, as obtained from the database
param: string $format strftime format
param: int|float|string $timezone the timezone to use
param: bool $fixday if true then the leading zero from %d is removed,
param: bool $fixhour if true then the leading zero from %I is removed,
return: string the formatted date/time

timestamp_to_date_array($time, $timezone = 99)   X-Ref
Given a $time timestamp in GMT (seconds since epoch), returns an array that
represents the date in user time.

param: int $time Timestamp in GMT
param: float|int|string $timezone offset's time with timezone, if float and not 99, then no
return: array an array that represents the date in user time

convert_from_gregorian($year, $month, $day, $hour = 0, $minute = 0)   X-Ref
Provided with a day, month, year, hour and minute in a specific
calendar type convert it into the equivalent Gregorian date.

In this function we don't need to do anything except pass the data
back as an array. This is because the date received is Gregorian.

param: int $year
param: int $month
param: int $day
param: int $hour
param: int $minute
return: array the converted date

convert_to_gregorian($year, $month, $day, $hour = 0, $minute = 0)   X-Ref
Provided with a day, month, year, hour and minute in a specific
calendar type convert it into the equivalent Gregorian date.

In this function we don't need to do anything except pass the data
back as an array. This is because the date received is Gregorian.

param: int $year
param: int $month
param: int $day
param: int $hour
param: int $minute
return: array the converted date

locale_win_charset()   X-Ref
This return locale for windows os.

return: string locale