Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
Timeline
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
WP Plugins
Timeline
Commits
c413942e
Commit
c413942e
authored
11 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Update date handling to deal with empty end dates and events that don't span more than a day.
Fixes #8. Closes #8.
parent
6da79570
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
eth-timeline.php
+23
-3
23 additions, 3 deletions
eth-timeline.php
with
23 additions
and
3 deletions
eth-timeline.php
+
23
−
3
View file @
c413942e
...
...
@@ -300,6 +300,7 @@ class ETH_Timeline {
* @uses this::get_times
* @uses the_ID
* @uses this::format_date
* @uses get_the_ID
* @uses the_title
* @uses get_the_content
* @uses remove_filter
...
...
@@ -386,7 +387,7 @@ class ETH_Timeline {
// Info about the item
?>
<li
class=
"eth-timeline-item"
id=
"eth-timeline-
<?php
the_ID
();
?>
"
>
<span
class=
"eth-timeline-date"
>
<?php
echo
$this
->
format_date
(
$times
[
'start'
],
$year
,
$month
);
?>
–
<?php
echo
$this
->
format_date
(
$times
[
'end'
]
,
$year
,
$month
,
false
);
?>
:
</span>
<span
class=
"eth-timeline-date"
>
<?php
echo
$this
->
format_date
(
get_the_ID
()
,
$year
,
$month
);
?>
:
</span>
<span
class=
"eth-timeline-location"
>
<?php
the_title
();
?>
</span>
<?php
...
...
@@ -441,9 +442,28 @@ class ETH_Timeline {
return
compact
(
'start'
,
'end'
);
}
/**
* Format entry dates for display
*
* @param int $post_id
* @param int $loop_year
* @param int $loop_month
* @uses this::get_times
* @uses this::format_single_date
* @return string
*/
private
function
format_date
(
$post_id
,
$loop_year
,
$loop_month
)
{
$times
=
$this
->
get_times
(
$post_id
);
if
(
empty
(
$times
[
'end'
]
)
||
$times
[
'end'
]
<=
$times
[
'start'
]
)
{
return
$this
->
format_single_date
(
$times
[
'start'
],
$loop_year
,
$loop_month
);
}
else
{
return
$this
->
format_single_date
(
$times
[
'start'
],
$loop_year
,
$loop_month
)
.
'–'
.
$this
->
format_single_date
(
$times
[
'end'
],
$loop_year
,
$loop_month
,
false
);
}
}
/**
* Determine appropriate date format for display start and end dates together.
* Prevents duplication of month or year.
*
* @param int $timestamp
* @param int $loop_year
...
...
@@ -451,7 +471,7 @@ class ETH_Timeline {
* @param bool $start
* @return string
*/
private
function
format_date
(
$timestamp
,
$loop_year
,
$loop_month
,
$start
=
true
)
{
private
function
format_
single_
date
(
$timestamp
,
$loop_year
,
$loop_month
,
$start
=
true
)
{
$ts_year
=
date
(
'Y'
,
$timestamp
);
$ts_month
=
date
(
'n'
,
$timestamp
);
...
...
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