unocha / un_date
UN date and time twig filters for Drupal 8
Installs: 2 603
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 7
Forks: 0
Open Issues: 0
Type:drupal-module
Requires
- php: >=8.0
- composer/installers: ^1.2 || ^2
- dev-main
- 2.0.16
- 2.0.15
- 2.0.14
- 2.0.13
- 2.0.12
- 2.0.11
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.0.2
- 1.0.1
- 1.0.0
- dev-UNO-812-timezone-name
- dev-UNO-812
- dev-double-am
- dev-PHP81
- dev-alternative-parser
- dev-interpreter
- dev-abbrev-translate
- dev-support-noon-midnight
- dev-no-more-to-utc
- dev-test-run-1
- dev-IASC-701
This package is auto-updated.
Last update: 2024-11-15 20:53:27 UTC
README
See UN standard for details.
All dates will be outputted as entered, there's no automatic timezone conversion.
We support English, French, Spanish, Chinese and Arabic.
Warning: You need the patch to fix translation of abbreviated month names.
The Humand readable output of RRules is flaky.
Install
Run composer install unocha/un_date
Core date formatter service
This service is replaced by UnDateFormatter
and will enforce the proper format for short
, medium
and long
.
Formatters
There's support for the following
- Core datetime field
- Core datetime_range field
- Contrib daterange_timezone
- Contrib date_recur
Twig filters and functions
Input can be either a DateTime compatible object, a Drupal structured data item, a string or a timestamp.
Most filters have an option for month_format, either numeric
, full
or abbreviation
(default numeric)
Filters
- un_date: Formatted as date
j.m.Y
- un_time: Formatted as time
g.i a.m.|p.m.
- un_datetime: Formatted as date and time
d.m.Y g.i a.m.|p.m.
- un_html_datetime: Formatted as date and time
Y-m-dTH:i:s
- un_daterange: Formatted as date and time
j.m.Y g.i a.m.|p.m. — g.i a.m.|p.m.
orj.m.Y g.i a.m.|p.m. — j.m.Y g.i a.m.|p.m.
if dates are different - un_daterange_times: Formatted as date and time
g.i a.m.|p.m. — g.i a.m.|p.m.
orj.m.Y g.i a.m.|p.m. — j.m.Y g.i a.m.|p.m.
if dates are different - un_timerange: Formatted as time
g.i a.m.|p.m. — g.i a.m.|p.m.
- un_year: Formatted as
Y
- un_month: Formatted as
m
- un_month_full: Formatted as
F
- un_month_abbr: Formatted as
M
- un_day: Formatted as
j
- un_hour: Formatted as
G
,g
,noon
,midnight
- un_minute: Formatted as
m
or blank if zero - un_ampm: Formatted as
a.m.|p.m.
or blank
Functions
Most function accept a DateRange (compatible) object or 2 DateTime inputs.
- un_is_same_date: identical
- un_is_same_day: on the same day
- un_is_same_month: in the same month and year
- un_is_same_year: in the same year
- un_is_all_day: all day event
- un_is_utc: using UTC timezone
- un_is_rtl: RTL locale
- un_separator: the separator used
- un_duration: Return duration as human readable string
Human readable RRUle
Currently using https://github.com/rlanvin/php-rrule but https://github.com/simshaun/recurr looks nicer