Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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

(no description)

File Size: 317 lines (9 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 1 class


Class: structure  - X-Ref

Handles calendar functions for the test calendar.

The test calendar is going to be 2 years, 2 days, 2 hours and 2 minutes
in the future of the Gregorian calendar.

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

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.

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

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.

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

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.

return: int

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

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

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

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

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.

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

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.

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

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

return: string the formatted date/time
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,

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.

return: array an array that represents the date in user time
param: int $time timestamp in GMT
param: float|int|string $timezone the timezone to use to calculate the time

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

return: array the converted day, month, year, hour and minute.
param: int $year
param: int $month
param: int $day
param: int $hour
param: int $minute

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

return: array the converted day, month, year, hour and minute.
param: int $year
param: int $month
param: int $day
param: int $hour
param: int $minute

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

return: string locale