Fix intenaldate parser

This commit is contained in:
RainLoop Team 2014-07-31 00:57:41 +04:00
parent 1de1ecc9c4
commit 7dc9441852
12 changed files with 199 additions and 184 deletions

View file

@ -1138,7 +1138,8 @@ Utils.createMomentDate = function (oObject)
return ko.computed(function () { return ko.computed(function () {
Globals.momentTrigger(); Globals.momentTrigger();
return this.moment().fromNow(); var oMoment = this.moment();
return 1970 === oMoment.year() ? '' : oMoment.fromNow();
}, oObject); }, oObject);
}; };
@ -1156,7 +1157,11 @@ Utils.createMomentShortDate = function (oObject)
sMomentDate = this.momentDate() sMomentDate = this.momentDate()
; ;
if (4 >= oMomentNow.diff(oMoment, 'hours')) if (1970 === oMoment.year())
{
sResult = '';
}
else if (4 >= oMomentNow.diff(oMoment, 'hours'))
{ {
sResult = sMomentDate; sResult = sMomentDate;
} }

View file

@ -46,7 +46,7 @@ function MessageModel()
this.hasAttachments = ko.observable(false); this.hasAttachments = ko.observable(false);
this.attachmentsMainType = ko.observable(''); this.attachmentsMainType = ko.observable('');
this.moment = ko.observable(moment()); this.moment = ko.observable(moment(moment.unix(0)));
this.attachmentIconClass = ko.computed(function () { this.attachmentIconClass = ko.computed(function () {
var sClass = ''; var sClass = '';
@ -76,10 +76,6 @@ function MessageModel()
return MessageModel.calculateFullFromatDateValue(this.dateTimeStampInUTC()); return MessageModel.calculateFullFromatDateValue(this.dateTimeStampInUTC());
}, this); }, this);
this.fullFormatDateValue = ko.computed(function () {
return MessageModel.calculateFullFromatDateValue(this.dateTimeStampInUTC());
}, this);
this.momentDate = Utils.createMomentDate(this); this.momentDate = Utils.createMomentDate(this);
this.momentShortDate = Utils.createMomentShortDate(this); this.momentShortDate = Utils.createMomentShortDate(this);
@ -140,7 +136,7 @@ MessageModel.newInstanceFromJson = function (oJsonMessage)
*/ */
MessageModel.calculateFullFromatDateValue = function (iTimeStampInUTC) MessageModel.calculateFullFromatDateValue = function (iTimeStampInUTC)
{ {
return moment.unix(iTimeStampInUTC).format('LLL'); return 0 < iTimeStampInUTC ? moment.unix(iTimeStampInUTC).format('LLL') : '';
}; };
/** /**

View file

@ -2,7 +2,7 @@
"name": "RainLoop", "name": "RainLoop",
"title": "RainLoop Webmail", "title": "RainLoop Webmail",
"version": "1.6.8", "version": "1.6.8",
"release": "151", "release": "153",
"description": "Simple, modern & fast web-based email client", "description": "Simple, modern & fast web-based email client",
"homepage": "http://rainloop.net", "homepage": "http://rainloop.net",
"main": "gulpfile.js", "main": "gulpfile.js",

View file

@ -55,7 +55,13 @@ class DateTimeHelper
*/ */
public static function ParseInternalDateString($sDateTime) public static function ParseInternalDateString($sDateTime)
{ {
$oDateTime = \DateTime::createFromFormat('d-M-Y H:i:s O', \trim($sDateTime), \MailSo\Base\DateTimeHelper::GetUtcTimeZoneObject()); $sDateTime = \trim($sDateTime);
if (\preg_match('/^[a-z]{2,4}, /i', $sDateTime)) // RFC2822
{
return \MailSo\Base\DateTimeHelper::ParseRFC2822DateString($sDateTime);
}
$oDateTime = \DateTime::createFromFormat('d-M-Y H:i:s O', $sDateTime, \MailSo\Base\DateTimeHelper::GetUtcTimeZoneObject());
return $oDateTime ? $oDateTime->getTimestamp() : 0; return $oDateTime ? $oDateTime->getTimestamp() : 0;
} }

View file

@ -179,7 +179,9 @@
<span class="i18n uiLabel labelTo" data-i18n-text="MESSAGE/LABEL_TO"></span>: <span class="i18n uiLabel labelTo" data-i18n-text="MESSAGE/LABEL_TO"></span>:
<span class="to" data-bind="html: viewToShort, title: viewTo"></span> <span class="to" data-bind="html: viewToShort, title: viewTo"></span>
</span> </span>
<span data-bind="visible: '' !== viewDate()">
(<span class="date" data-bind="text: viewDate"></span>) (<span class="date" data-bind="text: viewDate"></span>)
</span>
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
@ -205,7 +207,7 @@
&nbsp; &nbsp;
<span class="bcc" data-bind="text: viewBcc, title: viewBcc"></span> <span class="bcc" data-bind="text: viewBcc, title: viewBcc"></span>
</div> </div>
<div> <div data-bind="visible: '' !== viewDate()">
<span class="i18n uiLabel labelBcc" data-i18n-text="MESSAGE/LABEL_DATE"></span>: <span class="i18n uiLabel labelBcc" data-i18n-text="MESSAGE/LABEL_DATE"></span>:
&nbsp; &nbsp;
<span class="date" data-bind="text: viewDate"></span> <span class="date" data-bind="text: viewDate"></span>

View file

@ -1940,7 +1940,8 @@ Utils.createMomentDate = function (oObject)
return ko.computed(function () { return ko.computed(function () {
Globals.momentTrigger(); Globals.momentTrigger();
return this.moment().fromNow(); var oMoment = this.moment();
return 1970 === oMoment.year() ? '' : oMoment.fromNow();
}, oObject); }, oObject);
}; };
@ -1958,7 +1959,11 @@ Utils.createMomentShortDate = function (oObject)
sMomentDate = this.momentDate() sMomentDate = this.momentDate()
; ;
if (4 >= oMomentNow.diff(oMoment, 'hours')) if (1970 === oMoment.year())
{
sResult = '';
}
else if (4 >= oMomentNow.diff(oMoment, 'hours'))
{ {
sResult = sMomentDate; sResult = sMomentDate;
} }

File diff suppressed because one or more lines are too long

View file

@ -1943,7 +1943,8 @@ Utils.createMomentDate = function (oObject)
return ko.computed(function () { return ko.computed(function () {
Globals.momentTrigger(); Globals.momentTrigger();
return this.moment().fromNow(); var oMoment = this.moment();
return 1970 === oMoment.year() ? '' : oMoment.fromNow();
}, oObject); }, oObject);
}; };
@ -1961,7 +1962,11 @@ Utils.createMomentShortDate = function (oObject)
sMomentDate = this.momentDate() sMomentDate = this.momentDate()
; ;
if (4 >= oMomentNow.diff(oMoment, 'hours')) if (1970 === oMoment.year())
{
sResult = '';
}
else if (4 >= oMomentNow.diff(oMoment, 'hours'))
{ {
sResult = sMomentDate; sResult = sMomentDate;
} }
@ -6917,7 +6922,7 @@ function MessageModel()
this.hasAttachments = ko.observable(false); this.hasAttachments = ko.observable(false);
this.attachmentsMainType = ko.observable(''); this.attachmentsMainType = ko.observable('');
this.moment = ko.observable(moment()); this.moment = ko.observable(moment(moment.unix(0)));
this.attachmentIconClass = ko.computed(function () { this.attachmentIconClass = ko.computed(function () {
var sClass = ''; var sClass = '';
@ -6947,10 +6952,6 @@ function MessageModel()
return MessageModel.calculateFullFromatDateValue(this.dateTimeStampInUTC()); return MessageModel.calculateFullFromatDateValue(this.dateTimeStampInUTC());
}, this); }, this);
this.fullFormatDateValue = ko.computed(function () {
return MessageModel.calculateFullFromatDateValue(this.dateTimeStampInUTC());
}, this);
this.momentDate = Utils.createMomentDate(this); this.momentDate = Utils.createMomentDate(this);
this.momentShortDate = Utils.createMomentShortDate(this); this.momentShortDate = Utils.createMomentShortDate(this);
@ -7011,7 +7012,7 @@ MessageModel.newInstanceFromJson = function (oJsonMessage)
*/ */
MessageModel.calculateFullFromatDateValue = function (iTimeStampInUTC) MessageModel.calculateFullFromatDateValue = function (iTimeStampInUTC)
{ {
return moment.unix(iTimeStampInUTC).format('LLL'); return 0 < iTimeStampInUTC ? moment.unix(iTimeStampInUTC).format('LLL') : '';
}; };
/** /**

File diff suppressed because one or more lines are too long