Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore timezone for fields of type date #276

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions force-app/main/default/classes/TimelineService.cls
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ public with sharing class TimelineService {
mapData.put('detailFieldLabel', detailValues.get('label'));
mapData.put('positionDateField', positionValues.get('label'));
mapData.put('positionDateValue', positionValues.get('value'));
mapData.put('positionDateType', positionValues.get('type'));
mapData.put('objectName', tr.objectName);
mapData.put('fallbackTooltipField', fallbackValues.get('label'));
mapData.put('fallbackTooltipValue', fallbackValues.get('value'));
Expand Down Expand Up @@ -421,6 +422,7 @@ public with sharing class TimelineService {

String fieldValue = '';
String fieldLabel = '';
String fieldType = '';
String objectCheck = '';
//String fieldCheck = '';
String fieldStripped = '';
Expand Down Expand Up @@ -512,6 +514,7 @@ public with sharing class TimelineService {

fieldLabel = fieldMetadata.getLabel();
fieldCanAccess = fieldMetadata.isAccessible();
fieldType = String.valueOf(fieldMetadata.getType());

if (fieldCanAccess == false) {
fieldValue = '![' + fieldLabel + ']!';
Expand All @@ -523,6 +526,7 @@ public with sharing class TimelineService {

fieldDetails.put('value', fieldValue);
fieldDetails.put('label', fieldLabel);
fieldDetails.put('type', fieldType);

return fieldDetails;
}
Expand Down Expand Up @@ -634,6 +638,7 @@ public with sharing class TimelineService {
private String iconBackgroundField;
private String positionDateField;
private String positionDateValue;
private String positionDateType;
private String objectName;
private String type;
private String tooltipIdField;
Expand Down
43 changes: 28 additions & 15 deletions force-app/main/default/lwc/timeline/timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,19 +440,9 @@ export default class timeline extends NavigationMixin(LightningElement) {
let timelineResult = [];
let timelineTimes = [];

const options = {
hour: 'numeric',
minute: 'numeric',
year: 'numeric',
month: 'numeric',
day: 'numeric',
timeZone: TIMEZONE
};

const dateFormatter = new Intl.DateTimeFormat(me.calculatedLOCALE(), options);

result.forEach(function (record, index) {
let recordCopy = {};
let options;

recordCopy.recordId = record.objectId;
recordCopy.id = index;
Expand All @@ -461,9 +451,34 @@ export default class timeline extends NavigationMixin(LightningElement) {
recordCopy.objectName = record.objectName;
recordCopy.positionDateField = record.positionDateField;

let convertDate = record.positionDateValue.replace(' ', 'T');
convertDate = convertDate + '.000Z';
if (record.positionDateType === 'DATE') {
options = {
year: 'numeric',
month: 'numeric',
day: 'numeric'
};
}
else {
options = {
hour: 'numeric',
minute: 'numeric',
year: 'numeric',
month: 'numeric',
day: 'numeric',
timeZone: TIMEZONE
};
}

let dateFormatter = new Intl.DateTimeFormat(me.calculatedLOCALE(), options);

let convertDate = record.positionDateValue;


if (record.positionDateType === 'DATETIME') {
convertDate = record.positionDateValue.replace(' ', 'T');
convertDate = convertDate + '.000Z';
}

let localDate = new Date(convertDate);
let localPositionDate = dateFormatter.format(localDate);

Expand All @@ -472,10 +487,8 @@ export default class timeline extends NavigationMixin(LightningElement) {

recordCopy.detailField = record.detailField;
recordCopy.detailFieldLabel = record.detailFieldLabel;

recordCopy.fallbackTooltipField = record.fallbackTooltipField;
recordCopy.fallbackTooltipValue = record.fallbackTooltipValue;

recordCopy.tooltipId = record.tooltipId;
recordCopy.tooltipObject = record.tooltipObject;
recordCopy.drilldownId = record.drilldownId;
Expand Down