react-timestamp
Advanced tools
Comparing version
@@ -71,8 +71,10 @@ 'use strict'; | ||
if (seconds < 60) { | ||
// 1 minute | ||
if (is_comparing) { | ||
return is_ago ? 'Just then' : 'Soon'; | ||
} else { | ||
return 'A few seconds'; | ||
if (!this.props.actualSeconds) { | ||
if (seconds < 60) { | ||
// 1 minute | ||
if (is_comparing) { | ||
return is_ago ? 'Just then' : 'Soon'; | ||
} else { | ||
return 'A few seconds'; | ||
} | ||
} | ||
@@ -85,3 +87,6 @@ } | ||
if (this.props.precision == 1) { | ||
if (seconds < 60 * 60) { | ||
if (seconds < 60) { | ||
// 1 minute | ||
when = seconds + ' ' + plural('second', seconds); | ||
} else if (seconds < 60 * 60) { | ||
// 1 hour | ||
@@ -173,6 +178,17 @@ distance = Math.round(seconds / 60); | ||
// eg. 5 Nov 12, 1:37pm | ||
if (date.getHours() % 12 == 0) { | ||
hours = 12; | ||
if (this.props.twentyFourHour) { | ||
hours = date.getHours(); | ||
ampm = ''; | ||
} else { | ||
hours = date.getHours() % 12; | ||
if (date.getHours() % 12 == 0) { | ||
hours = 12; | ||
} else { | ||
hours = date.getHours() % 12; | ||
} | ||
if (date.getHours() > 11) { | ||
ampm = 'pm'; | ||
} else { | ||
ampm = 'am'; | ||
} | ||
} | ||
@@ -186,8 +202,2 @@ | ||
if (date.getHours() > 11) { | ||
ampm = 'pm'; | ||
} else { | ||
ampm = 'am'; | ||
} | ||
var day = this.props.includeDay ? DAYS[date.getDay()] + ', ' : ''; | ||
@@ -287,5 +297,7 @@ | ||
style: {}, | ||
autoUpdate: false | ||
autoUpdate: false, | ||
twentyFourHour: false, | ||
actualSeconds: false | ||
}; | ||
module.exports = Timestamp; |
{ | ||
"name": "react-timestamp", | ||
"version": "4.3.1", | ||
"version": "4.4.0", | ||
"description": "A React component for displaying a datetime in the local timezone", | ||
@@ -37,5 +37,5 @@ "main": "lib/timestamp.js", | ||
"mocha": "^2.3.4", | ||
"moment-timezone": "*", | ||
"moment-timezone": "^0.5.14", | ||
"should": "^8.0.1" | ||
} | ||
} |
@@ -22,2 +22,4 @@ # Timestamp | ||
<Timestamp time={thing.created_at} /> | ||
<Timestamp time={thing.created_at} twentyFourHour /> | ||
<Timestamp time={thing.created_at} actualSeconds /> <!-- Shows actual seconds instead of 'a few seconds ago' --> | ||
<Timestamp time={thing.created_at} precision={2} /> | ||
@@ -24,0 +26,0 @@ <Timestamp time="2015-10-10 10:30:00" format='full' /> |
12393
4.51%255
4.94%74
2.78%