Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
Dwoo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Common
Dwoo
Commits
cfb65a97
Commit
cfb65a97
authored
May 16, 2008
by
Seldaek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* Fixed a bug in {date_format} that prevented anything but unix timestamps to work
git-svn-id:
svn://dwoo.org/dwoo/trunk@62
0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent
187a71c6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
5 deletions
+7
-5
Compiler.php
lib/Dwoo/Compiler.php
+1
-1
date_format.php
lib/plugins/builtin/functions/date_format.php
+5
-3
FuncTests.php
tests/FuncTests.php
+1
-1
No files found.
lib/Dwoo/Compiler.php
View file @
cfb65a97
...
...
@@ -493,7 +493,7 @@ class Dwoo_Compiler implements Dwoo_ICompiler
// strips comments
if
(
strstr
(
$tpl
,
$this
->
ld
.
'*'
)
!==
false
)
$tpl
=
preg_replace
(
'
{'
.
$this
->
ldr
.
'\*.*?\*'
.
$this
->
rdr
.
'}
s'
,
''
,
$tpl
);
$tpl
=
preg_replace
(
'
/'
.
$this
->
ldr
.
'\*.*?\*'
.
$this
->
rdr
.
'/
s'
,
''
,
$tpl
);
// strips php tags if required by the security policy
if
(
$this
->
securityPolicy
!==
null
)
...
...
lib/plugins/builtin/functions/date_format.php
View file @
cfb65a97
...
...
@@ -24,14 +24,16 @@ function Dwoo_Plugin_date_format(Dwoo $dwoo, $value, $format='%b %e, %Y', $defau
if
(
!
empty
(
$value
))
{
// don't convert if it's a valid unix timestamp
if
(
preg_match
(
'#^\d{10}$#'
,
$value
)
===
false
)
if
(
preg_match
(
'#^\d{10}$#'
,
$value
)
===
0
)
$value
=
strtotime
(
$value
);
}
elseif
(
!
empty
(
$default
))
{
// don't convert if it's a valid unix timestamp
if
(
preg_match
(
'#^\d{10}$#'
,
$default
)
===
false
)
if
(
preg_match
(
'#^\d{10}$#'
,
$default
)
===
0
)
$value
=
strtotime
(
$default
);
else
$value
=
$default
;
}
else
return
''
;
...
...
@@ -39,7 +41,7 @@ function Dwoo_Plugin_date_format(Dwoo $dwoo, $value, $format='%b %e, %Y', $defau
// Credits for that windows compat block to Monte Ohrt who made smarty's date_format plugin
if
(
DIRECTORY_SEPARATOR
==
'\\'
)
{
$_win_from
=
array
(
'%D'
,
'%h'
,
'%n'
,
'%r'
,
'%R'
,
'%t'
,
'%T'
);
$_win_from
=
array
(
'%D'
,
'%h'
,
'%n'
,
'%r'
,
'%R'
,
'%t'
,
'%T'
);
$_win_to
=
array
(
'%m/%d/%y'
,
'%b'
,
"
\n
"
,
'%I:%M:%S %p'
,
'%H:%M'
,
"
\t
"
,
'%H:%M:%S'
);
if
(
strpos
(
$format
,
'%e'
)
!==
false
)
{
...
...
tests/FuncTests.php
View file @
cfb65a97
...
...
@@ -116,7 +116,7 @@ class FuncTests extends PHPUnit_Framework_TestCase
$tpl
=
new
Dwoo_Template_String
(
'{date_format $dwoo.now "%Y%H:%M:%S"}{date_format $foo "%Y%H:%M:%S" "one hour ago"}{date_format ""}'
);
$tpl
->
forceCompilation
();
$this
->
assertEquals
(
strftime
(
"%Y%H:%M:%S"
,
$_SERVER
[
'REQUEST_TIME'
])
.
strftime
(
'%Y%H:%M:%S'
,
strtotime
(
"one hour ago"
)),
$this
->
dwoo
->
get
(
$tpl
,
array
(),
$this
->
compiler
));
$this
->
assertEquals
(
strftime
(
"%Y%H:%M:%S"
,
$_SERVER
[
'REQUEST_TIME'
])
.
strftime
(
'%Y%H:%M:%S'
,
strtotime
(
"one hour ago"
)),
$this
->
dwoo
->
get
(
$tpl
,
array
(
'foo'
=>
''
),
$this
->
compiler
));
}
public
function
testDefault
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment