Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 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.

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.

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.

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 the timezone to use to calculate the time
return: array an array that represents the date in user 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.

param: int $year
param: int $month
param: int $day
param: int $hour
param: int $minute
return: array the converted day, month, year, hour and 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.

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

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

return: string locale