|
static | create_from_datetime (DateTimeInterface $datetime, ?int $near=DAYSECS, bool $timeonly=false, ?url $link=null, ?string $langtimeformat=null, bool $userelatives=true,) |
| Creates a new humandate instance from a datetime.
|
|
static | create_from_timestamp (int $timestamp, ?int $near=DAYSECS, bool $timeonly=false, ?url $link=null, ?string $langtimeformat=null, bool $userelatives=true,) |
| Creates a new humandate instance from a timestamp.
|
|
|
| __construct (protected DateTimeImmutable DateTimeImmutable $datetime,) |
| Class constructor.
|
|
|
clock clock | $clock |
| The clock interface to handle time.
|
|
string null string | $langtimeformat = null |
| An optional date format to apply.
|
|
url null url | $link = null |
| Link for the date.
|
|
int null int | $near = DAYSECS |
| The number of seconds within which a date is considered near.
|
|
bool bool | $timeonly = false |
| Whether we should show time only or date and time.
|
|
bool bool | $userelatives = true |
| Whether to use human relative terminology.
|
|
◆ __construct()
core_calendar\output\humandate::__construct |
( |
protected DateTimeImmutable DateTimeImmutable | $datetime | ) |
|
|
protected |
Class constructor.
Use the factory methods, such as create_from_timestamp or create_from_datetime, instead.
- Parameters
-
DateTimeImmutable | $datetime | The datetime. |
- Parameters
-
$datetime | $datetime The datetime. * |
◆ create_from_datetime()
static core_calendar\output\humandate::create_from_datetime |
( |
DateTimeInterface | $datetime, |
|
|
?int | $near = DAYSECS, |
|
|
bool | $timeonly = false, |
|
|
?url | $link = null, |
|
|
?string | $langtimeformat = null, |
|
|
bool | $userelatives = true ) |
|
static |
Creates a new humandate instance from a datetime.
- Parameters
-
DateTimeInterface | $datetime | The datetime. |
int | null | $near | The number of seconds within which a date is considered near. 1 day by default. |
bool | $timeonly | Whether we should show time only or date and time. |
url | null | $link | Link for the date. |
string | null | $langtimeformat | An optional date format to apply. |
bool | $userelatives | Whether to use human relative terminology. |
- Return values
-
humandate | The new instance. |
◆ create_from_timestamp()
static core_calendar\output\humandate::create_from_timestamp |
( |
int | $timestamp, |
|
|
?int | $near = DAYSECS, |
|
|
bool | $timeonly = false, |
|
|
?url | $link = null, |
|
|
?string | $langtimeformat = null, |
|
|
bool | $userelatives = true ) |
|
static |
Creates a new humandate instance from a timestamp.
- Parameters
-
int | $timestamp | The timestamp. |
int | null | $near | The number of seconds within which a date is considered near. 1 day by default. |
bool | $timeonly | Whether we should show time only or date and time. |
url | null | $link | Link for the date. |
string | null | $langtimeformat | An optional date format to apply. |
bool | $userelatives | Whether to use human relative terminology. |
- Return values
-
humandate | The new instance. |
◆ export_for_template()
core_calendar\output\humandate::export_for_template |
( |
renderer_base | $output | ) |
|
Function to export the renderer data in a format that is suitable for a mustache template.
This means:
- No complex types - only stdClass, array, int, string, float, bool
- Any additional info that is required for the template is pre-calculated (e.g. capability checks).
- Parameters
-
renderer_base | $output | Used to do a final render of any components that need to be rendered for export. |
- Return values
-
Implements core\output\templatable.
◆ set_display_time_only()
core_calendar\output\humandate::set_display_time_only |
( |
bool | $timeonly | ) |
|
Sets whether we should show time only or date and time.
- Parameters
-
bool | $timeonly | Whether we should show time only or date and time. |
- Return values
-
◆ set_lang_time_format()
core_calendar\output\humandate::set_lang_time_format |
( |
?string | $langtimeformat | ) |
|
Sets an optional date format to apply.
- Parameters
-
string | null | $langtimeformat | Lang date and time format to use to format the date. |
- Return values
-
◆ set_link()
core_calendar\output\humandate::set_link |
( |
?url | $link | ) |
|
Sets the link for the date.
If null, no link will be added.
- Parameters
-
url | null | $link | The link for the date. |
- Return values
-
◆ set_near_limit()
core_calendar\output\humandate::set_near_limit |
( |
?int | $near | ) |
|
Sets the number of seconds within which a date is considered near.
- Parameters
-
int | null | $near | The number of seconds within which a date is considered near. |
- Return values
-
◆ set_use_relatives()
core_calendar\output\humandate::set_use_relatives |
( |
bool | $userelatives | ) |
|
Sets whether to use human relative terminology.
- Parameters
-
bool | $userelatives | Whether to use human relative terminology. |
- Return values
-
◆ $near
int null int core_calendar\output\humandate::$near = DAYSECS |
|
protected |
The number of seconds within which a date is considered near.
1 day by default.
The documentation for this class was generated from the following file:
- calendar/classes/output/humandate.php