Skip to content

Commit

Permalink
Corrigido o problema da data
Browse files Browse the repository at this point in the history
  • Loading branch information
bombassaro committed Aug 26, 2020
1 parent c4a622b commit 90d7a70
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 18 deletions.
2 changes: 1 addition & 1 deletion components/Teasers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Teaser = ({content, datePublished, domain, hasImageTop, hasSubjectFilled,
const propsDate = {custom: 'teaser-date',w: '100p'}
const propsSubject = {custom: 'teaser-subject',mb: '1'}
const propsTitle = {custom: 'teaser-title'}

let dateValue =
!datePublished && content['time-modifiedDate'] ?
utils.dateDistance(content['time-modifiedDate'], 2880) :
Expand Down
13 changes: 9 additions & 4 deletions components/Util/dateDistance.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ import datePtBrFull from './datePtBrFull'

const dateDistance = (date, limit) => {

const _now = new Date()
const _date = new Date(date)

const distanteInWords = formatDistance(_date, _now, {locale: pt})
if(!date) return false
let d = date.replace("T", " ")
let _y = d.split('-')
let _d = _y[2].split(' ')
let _t = _d.length > 1 ? _d[1].split(':') : [0, 0]
let _now = new Date().getTime()
let _date = new Date(_y[0], _y[1] - 1, _d[0], _t[0], _t[1]).getTime()

const distanteInWords = formatDistance(_now, _date, {locale: pt})
const diffHours = differenceInHours(_now, _date, {locale: pt})

if(diffHours > limit)
Expand Down
12 changes: 11 additions & 1 deletion components/Util/datePtBrFull.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import format from 'date-fns/format'

const datePtBrFull = (date) => {
const _date = new Date(date)

if(!date) return false
let d = date.replace("T", " ")
let _y = d.split('-')
let _d = _y[2].split(' ')
let _t = _d.length > 1 ? _d[1].split(':') : [0, 0]
let _date = new Date(_y[0], _y[1] - 1, _d[0], _t[0], _t[1])

if(!(_date instanceof Date))
return false

return `${format(_date, "dd/MM/yyyy")} às ${format(_date, "HH:mm")}`
}
export default datePtBrFull
27 changes: 23 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4606,17 +4606,36 @@ function cleanEscapedString(input) {
}

var datePtBrFull = function datePtBrFull(date) {
var _date = new Date(date);
if (!date) return false;
var d = date.replace("T", " ");

var _y = d.split('-');

var _d = _y[2].split(' ');

var _t = _d.length > 1 ? _d[1].split(':') : [0, 0];

var _date = new Date(_y[0], _y[1] - 1, _d[0], _t[0], _t[1]);

if (!(_date instanceof Date)) return false;
return "".concat(format(_date, "dd/MM/yyyy"), " \xE0s ").concat(format(_date, "HH:mm"));
};

var dateDistance = function dateDistance(date, limit) {
var _now = new Date();
if (!date) return false;
var d = date.replace("T", " ");

var _y = d.split('-');

var _d = _y[2].split(' ');

var _t = _d.length > 1 ? _d[1].split(':') : [0, 0];

var _now = new Date().getTime();

var _date = new Date(date);
var _date = new Date(_y[0], _y[1] - 1, _d[0], _t[0], _t[1]).getTime();

var distanteInWords = formatDistance$2(_date, _now, {
var distanteInWords = formatDistance$2(_now, _date, {
locale: locale$1
});
var diffHours = differenceInHours(_now, _date, {
Expand Down
27 changes: 23 additions & 4 deletions teasers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3443,17 +3443,36 @@ function cleanEscapedString(input) {
}

var datePtBrFull = function datePtBrFull(date) {
var _date = new Date(date);
if (!date) return false;
var d = date.replace("T", " ");

var _y = d.split('-');

var _d = _y[2].split(' ');

var _t = _d.length > 1 ? _d[1].split(':') : [0, 0];

var _date = new Date(_y[0], _y[1] - 1, _d[0], _t[0], _t[1]);

if (!(_date instanceof Date)) return false;
return "".concat(format(_date, "dd/MM/yyyy"), " \xE0s ").concat(format(_date, "HH:mm"));
};

var dateDistance = function dateDistance(date, limit) {
var _now = new Date();
if (!date) return false;
var d = date.replace("T", " ");

var _y = d.split('-');

var _d = _y[2].split(' ');

var _t = _d.length > 1 ? _d[1].split(':') : [0, 0];

var _now = new Date().getTime();

var _date = new Date(date);
var _date = new Date(_y[0], _y[1] - 1, _d[0], _t[0], _t[1]).getTime();

var distanteInWords = formatDistance$2(_date, _now, {
var distanteInWords = formatDistance$2(_now, _date, {
locale: locale$1
});
var diffHours = differenceInHours(_now, _date, {
Expand Down
27 changes: 23 additions & 4 deletions templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -3463,17 +3463,36 @@ function cleanEscapedString(input) {
}

var datePtBrFull = function datePtBrFull(date) {
var _date = new Date(date);
if (!date) return false;
var d = date.replace("T", " ");

var _y = d.split('-');

var _d = _y[2].split(' ');

var _t = _d.length > 1 ? _d[1].split(':') : [0, 0];

var _date = new Date(_y[0], _y[1] - 1, _d[0], _t[0], _t[1]);

if (!(_date instanceof Date)) return false;
return "".concat(format(_date, "dd/MM/yyyy"), " \xE0s ").concat(format(_date, "HH:mm"));
};

var dateDistance = function dateDistance(date, limit) {
var _now = new Date();
if (!date) return false;
var d = date.replace("T", " ");

var _y = d.split('-');

var _d = _y[2].split(' ');

var _t = _d.length > 1 ? _d[1].split(':') : [0, 0];

var _now = new Date().getTime();

var _date = new Date(date);
var _date = new Date(_y[0], _y[1] - 1, _d[0], _t[0], _t[1]).getTime();

var distanteInWords = formatDistance$2(_date, _now, {
var distanteInWords = formatDistance$2(_now, _date, {
locale: locale$1
});
var diffHours = differenceInHours(_now, _date, {
Expand Down

0 comments on commit 90d7a70

Please sign in to comment.