Mailspring/internal_packages/message-list/lib/message-timestamp.cjsx
Ben Gotow 503631e685 fix(*): Resolve a variety of small and simple bugs
Summary:
Fix T1822 - saving templates not working, not showing template

Fix T1800 - give composers a minimum size

Fix the bottom bar of the composer so the gray bar goes all the way across in popout mode.

Fix T1825 - switch to a more attractive "June 4, 2015 at 3:10 PM" styling for expanded dates

Remove, rather than hide, react components for text fields in composer. Fixes T1147

Fix specs

Switch to 999+ instead of infinity. Fixes T1768

Fix broken TemplateStore specs

Test Plan: Run tests

Reviewers: evan

Reviewed By: evan

Maniphest Tasks: T1147, T1768, T1822, T1800, T1825

Differential Revision: https://phab.nylas.com/D1601
2015-06-05 11:02:44 -07:00

49 lines
1.3 KiB
CoffeeScript

_ = require 'underscore'
moment = require 'moment-timezone'
React = require 'react'
{Utils} = require 'nylas-exports'
class MessageTimestamp extends React.Component
@displayName: 'MessageTimestamp'
@propTypes:
date: React.PropTypes.object.isRequired,
className: React.PropTypes.string,
isDetailed: React.PropTypes.bool
onClick: React.PropTypes.func
shouldComponentUpdate: (nextProps, nextState) =>
+nextProps.date isnt +@props.date or nextProps.isDetailed isnt @props.isDetailed
render: =>
<div className={@props.className}
onClick={@props.onClick}>{@_formattedDate()}</div>
_formattedDate: =>
moment.tz(@props.date, Utils.timeZone).format(@_timeFormat())
_timeFormat: =>
if @props.isDetailed
return "MMMM D, YYYY [at] h:mm A"
else
today = moment(@_today())
dayOfEra = today.dayOfYear() + today.year() * 365
msgDate = moment(@props.date)
msgDayOfEra = msgDate.dayOfYear() + msgDate.year() * 365
diff = dayOfEra - msgDayOfEra
if diff < 1
return "h:mm a"
if diff < 4
return "MMM D, h:mm a"
else if diff > 1 and diff <= 365
return "MMM D"
else
return "MMM D YYYY"
# Stubbable for testing. Returns a `moment`
_today: -> moment.tz(Utils.timeZone)
module.exports = MessageTimestamp