-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathintl.inc
More file actions
89 lines (72 loc) · 2.25 KB
/
intl.inc
File metadata and controls
89 lines (72 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* php safe options - only tests for module intl
* Php 5.3+
*/
/** ---------------------------------- Tests functions -------------------------------------------- */
// ------------------------- INTL tests -----------------------
/**
* @since 5.3.0
*/
function test_30_Intl_Number_Format()
{
global $testsLoopLimits, $totalOps, $emptyResult;
if (!class_exists('NumberFormatter', false)) {
return $emptyResult;
}
if (!function_exists('numfmt_create')) {
return $emptyResult;
}
$count = $testsLoopLimits['30_intl_number_format'];
$time_start = get_microtime();
$fmt = new NumberFormatter( 'ru_RU', NumberFormatter::DECIMAL );
$fmtD = new NumberFormatter( 'ru_RU', NumberFormatter::DURATION );
$fmtC = new NumberFormatter( 'ru_RU', NumberFormatter::CURRENCY );
$fmtS = new NumberFormatter( 'en', NumberFormatter::SPELLOUT );
for ($i = 0; $i < $count; $i++) {
$num = $i / 100.;
$fmt->format($num);
$fmtC->formatCurrency($num, 'EUR');
$fmtC->formatCurrency($num, 'RUR');
$fmtD->format($num);
$fmtD->setTextAttribute(NumberFormatter::DEFAULT_RULESET, "%in-numerals");
$fmtD->format($num);
$fmtD->setTextAttribute(NumberFormatter::DEFAULT_RULESET, "%with-words");
$fmtD->format($num);
$fmtS->format($num);
}
$totalOps += $count;
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
}
/**
* @since: 5.5.0
*/
function test_32_Intl_Calendar()
{
global $testsLoopLimits, $totalOps, $emptyResult;
if (!class_exists('IntlCalendar', false)) {
return $emptyResult;
}
if (!class_exists('IntlTimeZone', false)) {
return $emptyResult;
}
$count = $testsLoopLimits['32_intl_calendar'];
$time_start = get_microtime();
$cal = IntlCalendar::createInstance(IntlTimeZone::getGMT());
$a = 0;
for ($i = 0; $i < $count; $i++) {
$num = $i / 100.;
$cal->clear();
$cal->setTime($num);
if ($cal->inDaylightTime()) $a++;
if ($cal->isWeekend()) $a--;
if ($cal->getMinimalDaysInFirstWeek()) $a++;
$cal->add(IntlCalendar::FIELD_MONTH, 1);
$cal->add(IntlCalendar::FIELD_DAY_OF_MONTH, 1);
if ($cal->inDaylightTime()) $a--;
if ($cal->isWeekend()) $a++;
if ($cal->getMinimalDaysInFirstWeek()) $a--;
}
$totalOps += $count;
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
}