Skip to content

Commit 85eca77

Browse files
committed
ext/intl: Implement IntlRelativeDateTimeFormatter
1 parent 4226d16 commit 85eca77

14 files changed

Lines changed: 995 additions & 1 deletion

ext/intl/CREDITS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Internationalization
2-
Ed Batutis, Vladimir Iordanov, Dmitry Lakhtyuk, Stanislav Malyshev, Vadim Savchuk, Kirti Velankar
2+
Ed Batutis, Vladimir Iordanov, Dmitry Lakhtyuk, Stanislav Malyshev, Vadim Savchuk, Kirti Velankar, Weilin Du

ext/intl/config.m4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ if test "$PHP_INTL" != "no"; then
7373
breakiterator/codepointiterator_internal.cpp \
7474
breakiterator/codepointiterator_methods.cpp \
7575
listformatter/listformatter_class.cpp \
76+
reldateformatter/reldateformatter_class.cpp \
7677
transliterator/transliterator_class.cpp \
7778
transliterator/transliterator_methods.cpp \
7879
idn/idn.cpp \
@@ -123,6 +124,7 @@ if test "$PHP_INTL" != "no"; then
123124
$ext_builddir/idn
124125
$ext_builddir/locale
125126
$ext_builddir/listformatter
127+
$ext_builddir/reldateformatter
126128
$ext_builddir/msgformat
127129
$ext_builddir/normalizer
128130
$ext_builddir/rangeformatter

ext/intl/config.w32

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ if (PHP_INTL != "no") {
4141
ADD_SOURCES(configure_module_dirname + "/listformatter", "\
4242
listformatter_class.cpp \
4343
", "intl");
44+
ADD_SOURCES(configure_module_dirname + "/reldateformatter", "\
45+
reldateformatter_class.cpp \
46+
", "intl");
4447
ADD_SOURCES(configure_module_dirname + "/locale", "\
4548
locale.cpp \
4649
locale_class.cpp \

ext/intl/php_intl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "locale/locale_class.h"
4343

4444
#include "listformatter/listformatter_class.h"
45+
#include "reldateformatter/reldateformatter_class.h"
4546
#include "rangeformatter/rangeformatter_class.h"
4647

4748
#include "dateformat/dateformat.h"
@@ -190,6 +191,9 @@ PHP_MINIT_FUNCTION( intl )
190191
/* Register 'ListFormatter' PHP class */
191192
listformatter_register_class( );
192193

194+
/* Register 'IntlRelativeDateTimeFormatter' PHP class */
195+
reldateformatter_register_class( );
196+
193197
#if U_ICU_VERSION_MAJOR_NUM >= 63
194198
/* Register 'NumberRangeFormatter' PHP class */
195199
rangeformatter_register_class( );
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
3+
/** @generate-class-entries */
4+
5+
/**
6+
* @not-serializable
7+
* @strict-properties
8+
*/
9+
final class IntlRelativeDateTimeFormatter
10+
{
11+
/** @cvalue UDAT_STYLE_LONG */
12+
public const int STYLE_LONG = UNKNOWN;
13+
14+
/** @cvalue UDAT_STYLE_SHORT */
15+
public const int STYLE_SHORT = UNKNOWN;
16+
17+
/** @cvalue UDAT_STYLE_NARROW */
18+
public const int STYLE_NARROW = UNKNOWN;
19+
20+
/** @cvalue UDISPCTX_CAPITALIZATION_NONE */
21+
public const int CAPITALIZATION_NONE = UNKNOWN;
22+
23+
/** @cvalue UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE */
24+
public const int CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE = UNKNOWN;
25+
26+
/** @cvalue UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE */
27+
public const int CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE = UNKNOWN;
28+
29+
/** @cvalue UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU */
30+
public const int CAPITALIZATION_FOR_UI_LIST_OR_MENU = UNKNOWN;
31+
32+
/** @cvalue UDISPCTX_CAPITALIZATION_FOR_STANDALONE */
33+
public const int CAPITALIZATION_FOR_STANDALONE = UNKNOWN;
34+
35+
/** @cvalue UDAT_REL_UNIT_YEAR */
36+
public const int UNIT_YEAR = UNKNOWN;
37+
38+
/** @cvalue UDAT_REL_UNIT_QUARTER */
39+
public const int UNIT_QUARTER = UNKNOWN;
40+
41+
/** @cvalue UDAT_REL_UNIT_MONTH */
42+
public const int UNIT_MONTH = UNKNOWN;
43+
44+
/** @cvalue UDAT_REL_UNIT_WEEK */
45+
public const int UNIT_WEEK = UNKNOWN;
46+
47+
/** @cvalue UDAT_REL_UNIT_DAY */
48+
public const int UNIT_DAY = UNKNOWN;
49+
50+
/** @cvalue UDAT_REL_UNIT_HOUR */
51+
public const int UNIT_HOUR = UNKNOWN;
52+
53+
/** @cvalue UDAT_REL_UNIT_MINUTE */
54+
public const int UNIT_MINUTE = UNKNOWN;
55+
56+
/** @cvalue UDAT_REL_UNIT_SECOND */
57+
public const int UNIT_SECOND = UNKNOWN;
58+
59+
/** @cvalue UDAT_REL_UNIT_SUNDAY */
60+
public const int UNIT_SUNDAY = UNKNOWN;
61+
62+
/** @cvalue UDAT_REL_UNIT_MONDAY */
63+
public const int UNIT_MONDAY = UNKNOWN;
64+
65+
/** @cvalue UDAT_REL_UNIT_TUESDAY */
66+
public const int UNIT_TUESDAY = UNKNOWN;
67+
68+
/** @cvalue UDAT_REL_UNIT_WEDNESDAY */
69+
public const int UNIT_WEDNESDAY = UNKNOWN;
70+
71+
/** @cvalue UDAT_REL_UNIT_THURSDAY */
72+
public const int UNIT_THURSDAY = UNKNOWN;
73+
74+
/** @cvalue UDAT_REL_UNIT_FRIDAY */
75+
public const int UNIT_FRIDAY = UNKNOWN;
76+
77+
/** @cvalue UDAT_REL_UNIT_SATURDAY */
78+
public const int UNIT_SATURDAY = UNKNOWN;
79+
80+
public function __construct(
81+
?string $locale = null,
82+
int $style = IntlRelativeDateTimeFormatter::STYLE_LONG,
83+
int $capitalizationContext = IntlRelativeDateTimeFormatter::CAPITALIZATION_NONE,
84+
?NumberFormatter $numberFormatter = null,
85+
) {}
86+
87+
public function format(int|float $offset, int $unit): string|false {}
88+
89+
public function formatNumeric(int|float $offset, int $unit): string|false {}
90+
91+
public function combineDateAndTime(string $relativeDate, string $time): string|false {}
92+
93+
public function getErrorCode(): int {}
94+
95+
public function getErrorMessage(): string {}
96+
}

ext/intl/reldateformatter/reldateformatter_arginfo.h

Lines changed: 192 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)