Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
14820553
Commit
14820553
authored
9 years ago
by
Andreas Gohr
Browse files
Options
Downloads
Plain Diff
Merge pull request #1216 from splitbrain/IXR-date
IXR_Date
parents
67b479b2
ec3b241d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
_test/tests/inc/ixr_library_date.test.php
+11
-2
11 additions, 2 deletions
_test/tests/inc/ixr_library_date.test.php
inc/IXR_Library.php
+27
-30
27 additions, 30 deletions
inc/IXR_Library.php
with
38 additions
and
32 deletions
_test/tests/inc/ixr_library_date.test.php
+
11
−
2
View file @
14820553
...
@@ -2,6 +2,9 @@
...
@@ -2,6 +2,9 @@
require_once
DOKU_INC
.
'inc/IXR_Library.php'
;
require_once
DOKU_INC
.
'inc/IXR_Library.php'
;
/**
* Class ixr_library_date_test
*/
class
ixr_library_date_test
extends
DokuWikiTest
{
class
ixr_library_date_test
extends
DokuWikiTest
{
...
@@ -16,18 +19,24 @@ class ixr_library_date_test extends DokuWikiTest {
...
@@ -16,18 +19,24 @@ class ixr_library_date_test extends DokuWikiTest {
array
(
'2010-08-17T09:23:14Z'
,
1282036994
),
array
(
'2010-08-17T09:23:14Z'
,
1282036994
),
array
(
'20100817T09:23:14Z'
,
1282036994
),
array
(
'20100817T09:23:14Z'
,
1282036994
),
// with timezone
array
(
'2010-08-17 09:23:14+0000'
,
1282036994
),
array
(
'2010-08-17 09:23:14+00:00'
,
1282036994
),
array
(
'2010-08-17 12:23:14+03:00'
,
1282036994
),
// no seconds
// no seconds
array
(
'2010-08-17T09:23'
,
1282036980
),
array
(
'2010-08-17T09:23'
,
1282036980
),
array
(
'20100817T09:23'
,
1282036980
),
array
(
'20100817T09:23'
,
1282036980
),
// no time
// no time
array
(
'2010-08-17'
,
1282003200
),
array
(
'2010-08-17'
,
1282003200
),
//array('20100817', 1282003200), #this will NOT be parsed, but is assumed to be timestamp
array
(
1282036980
,
1282036980
),
// array('20100817', 1282003200), #this will NOT be parsed, but is assumed to be timestamp
);
);
foreach
(
$tests
as
$test
){
foreach
(
$tests
as
$test
){
$dt
=
new
IXR_Date
(
$test
[
0
]);
$dt
=
new
IXR_Date
(
$test
[
0
]);
$this
->
assertEquals
(
$dt
->
getTimeStamp
()
,
$test
[
1
]
);
$this
->
assertEquals
(
$test
[
1
],
$dt
->
getTimeStamp
());
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
inc/IXR_Library.php
+
27
−
30
View file @
14820553
...
@@ -297,6 +297,7 @@ class IXR_Message {
...
@@ -297,6 +297,7 @@ class IXR_Message {
* @param $tag
* @param $tag
*/
*/
function
tag_close
(
$parser
,
$tag
)
{
function
tag_close
(
$parser
,
$tag
)
{
$value
=
null
;
$valueFlag
=
false
;
$valueFlag
=
false
;
switch
(
$tag
)
{
switch
(
$tag
)
{
case
'int'
:
case
'int'
:
...
@@ -818,18 +819,14 @@ EOD;
...
@@ -818,18 +819,14 @@ EOD;
* @since 1.5
* @since 1.5
*/
*/
class
IXR_Date
{
class
IXR_Date
{
var
$year
;
var
$month
;
/** @var DateTime */
var
$day
;
protected
$date
;
var
$hour
;
var
$minute
;
var
$second
;
var
$timezone
;
/**
/**
* @param int|string $time
* @param int|string $time
*/
*/
function
__construct
(
$time
)
{
public
function
__construct
(
$time
)
{
// $time can be a PHP timestamp or an ISO one
// $time can be a PHP timestamp or an ISO one
if
(
is_numeric
(
$time
))
{
if
(
is_numeric
(
$time
))
{
$this
->
parseTimestamp
(
$time
);
$this
->
parseTimestamp
(
$time
);
...
@@ -839,51 +836,48 @@ class IXR_Date {
...
@@ -839,51 +836,48 @@ class IXR_Date {
}
}
/**
/**
* Parse unix timestamp
*
* @param int $timestamp
* @param int $timestamp
*/
*/
function
parseTimestamp
(
$timestamp
)
{
protected
function
parseTimestamp
(
$timestamp
)
{
$this
->
year
=
gmdate
(
'Y'
,
$timestamp
);
$this
->
date
=
new
DateTime
(
'@'
.
$timestamp
);
$this
->
month
=
gmdate
(
'm'
,
$timestamp
);
$this
->
day
=
gmdate
(
'd'
,
$timestamp
);
$this
->
hour
=
gmdate
(
'H'
,
$timestamp
);
$this
->
minute
=
gmdate
(
'i'
,
$timestamp
);
$this
->
second
=
gmdate
(
's'
,
$timestamp
);
$this
->
timezone
=
''
;
}
}
/**
/**
* Parses less or more complete iso dates and much more, if no timezone given assumes UTC
*
* @param string $iso
* @param string $iso
*/
*/
function
parseIso
(
$iso
)
{
protected
function
parseIso
(
$iso
)
{
if
(
preg_match
(
'/^(\d\d\d\d)-?(\d\d)-?(\d\d)([T ](\d\d):(\d\d)(:(\d\d))?)?/'
,
$iso
,
$match
))
{
$this
->
date
=
new
DateTime
(
$iso
,
new
DateTimeZone
(
"UTC"
));
$this
->
year
=
(
int
)
$match
[
1
];
$this
->
month
=
(
int
)
$match
[
2
];
$this
->
day
=
(
int
)
$match
[
3
];
$this
->
hour
=
(
int
)
$match
[
5
];
$this
->
minute
=
(
int
)
$match
[
6
];
$this
->
second
=
(
int
)
$match
[
8
];
}
}
}
/**
/**
* Returns date in ISO 8601 format
*
* @return string
* @return string
*/
*/
function
getIso
()
{
public
function
getIso
()
{
return
$this
->
year
.
$this
->
month
.
$this
->
day
.
'T'
.
$this
->
hour
.
':'
.
$this
->
minute
.
':'
.
$this
->
second
.
$this
->
timezone
;
return
$this
->
date
->
format
(
DateTime
::
ISO8601
)
;
}
}
/**
/**
* Returns date in valid xml
*
* @return string
* @return string
*/
*/
function
getXml
()
{
public
function
getXml
()
{
return
'<dateTime.iso8601>'
.
$this
->
getIso
()
.
'</dateTime.iso8601>'
;
return
'<dateTime.iso8601>'
.
$this
->
getIso
()
.
'</dateTime.iso8601>'
;
}
}
/**
/**
* Returns Unix timestamp
*
* @return int
* @return int
*/
*/
function
getTimestamp
()
{
function
getTimestamp
()
{
return
gmmktime
(
$this
->
hour
,
$this
->
minute
,
$this
->
second
,
$this
->
month
,
$this
->
day
,
$this
->
year
);
return
$this
->
date
->
getTimestamp
(
);
}
}
}
}
...
@@ -923,6 +917,9 @@ class IXR_IntrospectionServer extends IXR_Server {
...
@@ -923,6 +917,9 @@ class IXR_IntrospectionServer extends IXR_Server {
/** @var string[] */
/** @var string[] */
var
$help
;
var
$help
;
/**
* Constructor
*/
function
__construct
()
{
function
__construct
()
{
$this
->
setCallbacks
();
$this
->
setCallbacks
();
$this
->
setCapabilities
();
$this
->
setCapabilities
();
...
@@ -1107,7 +1104,7 @@ class IXR_ClientMulticall extends IXR_Client {
...
@@ -1107,7 +1104,7 @@ class IXR_ClientMulticall extends IXR_Client {
* @param int $port
* @param int $port
*/
*/
function
__construct
(
$server
,
$path
=
false
,
$port
=
80
)
{
function
__construct
(
$server
,
$path
=
false
,
$port
=
80
)
{
parent
::
IXR_Clien
t
(
$server
,
$path
,
$port
);
parent
::
__construc
t
(
$server
,
$path
,
$port
);
//$this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
//$this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment