mirror of
https://github.com/SuiteCRM/SuiteCRM.git
synced 2026-03-02 19:16:58 -05:00
DateTime fields inside templates rendered as Dates #3310
Labels
No labels
Area: API
Area: Campaigns
Area: Cases
Area: Clean Up
Area: Clean Up: Performance
Area: Dashlets
Area: Databases
Area: Developer Tools
Area: Elasticsearch
Area: Elasticsearch
Area: Emails
Area: Emails:Campaigns
Area: Emails:Cases
Area: Emails:Compose
Area: Emails:Config
Area: Emails:Templates
Area: Environment
Area: Installation
Area: Language
Area: Mobile
Area: Module
Area: PDFs
Area: PHP8
Area: Reports
Area: Studio
Area: Styling
Area: Upgrading
Area: Workflow
Area:Activity Stream
Area:Calls
Area:Import
Area:Projects
Area:Search
Area:Surveys
Area:Themes
Area:Users
Branch:Hotfix
Good First Issue
Hacktoberfest
Help Wanted
PR:Community Contribution
PR:Type:Enhancement
Priority:Critical
Priority:Important
Priority:Moderate
Severity: Major
Severity: Minor
Severity: Moderate
Status: Requires Code Review
Status: Requires Updates
Status: Stale
Status: Team Investigating
Status:Assessed
Status:Fix Proposed
Status:Needs Assessed
Status:Requires Automated Tests
Type: Bug
Type:Deprecated
Type:Discussion
Type:Duplicate
Type:Invalid
Type:Question
Type:Suggestion
Type:Suggestion
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/SuiteCRM-SuiteCRM#3310
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Jorilx on GitHub (Sep 20, 2018).
The class responsible for rendering datetimes inside templates,
include/SugarFields/Datetime/SugarFieldDatetime.php, looks for the format to use with$user_dateFormat = $timedate->get_date_format();instead of
$user_dateFormat = $timedate->get_date_time_format();so if you use a datetime inside a
*viewdefs.php, it gets rendered as a date instead of a datetime.Is this by design? Am I missing something?
I'm on SuiteCRM 7.10.8 but this call has been there from the "beginning" :)
@pgorod commented on GitHub (Oct 3, 2018):
I am not sure this is related, but does this fix help anything?
https://suitecrm.com/suitecrm/forum/suitecrm-7-0-discussion/3265-datetime-field-wouldn-t-show-the-time-in-pdf-email-how-to-show-datetime-correctly-instead-of-showing-only-date#72440
@Jorilx commented on GitHub (Oct 4, 2018):
Well the fix I mentioned in my post is enough for me, I was just wondering WHY SugarFieldDatetime looks for
get_date_formatinstead ofget_date_time_format:) Thanks for your help though!@pgorod commented on GitHub (Oct 4, 2018):
Do you want to make a PR to add your fix to the SuiteCRM code?
@Jorilx commented on GitHub (Oct 4, 2018):
I'll try, thanks! :D
@samus-aran commented on GitHub (Nov 30, 2018):
Hey @Jorilx
`$user_dateFormat = $timedate->get_date_format();
if (!empty($vardef['value']) && !$timedate->check_matching_format($vardef['value'], $user_dateFormat)) {
From looking at the code it appears that the get_date_format is only used to find out the user's preferences i.e. d/m/y or m/d/y which is needed to just 'confirm' that the value can be converted later
at this point $vardef['date_formatted_value'] = $timedate->asUserDate($sdt, $current_user);
So the point that you are really questioning is.... https://github.com/salesagility/SuiteCRM/blob/master/include/TimeDate.php#L674
@samus-aran commented on GitHub (Nov 30, 2018):
Perhaps looking at https://github.com/salesagility/SuiteCRM/blob/master/include/TimeDate.php#L613
AsUser returns datetime field types which uses the get_date_time_format()
@Jorilx commented on GitHub (Dec 6, 2018):
I'm not sure of what's going on, but my situation is the following:
using Studio I've added the "date_modified" field to the Accounts EditView, and if I leave SugarFieldDatetime.php as it is, the field gets rendered just as a date. If I apply my patch, it gets rendered correctly as datetime.
As a workaround I've found that I can leave SugarFieldDatetime.php alone if I specify
'customCode' => '{$fields.date_modified.value}'inside metadata/editviewdefs.php.I'll try and investigate the issue further, thanks for your time!
@Jorilx commented on GitHub (Dec 6, 2018):
I'm sorry, but isn't it odd that a function that's trying to render a datetime calls asUserDate? Moreover, the comment for asUserDate is
Format DateTime object as user dateso I'd be inclined to believe that the intention behind the code is really to render it as just a date... I'm quite confused 😄@samus-aran commented on GitHub (Dec 18, 2018):
Can we close this @Jorilx? This an issue or have we got a work around?
@Jorilx commented on GitHub (Dec 18, 2018):
Well I think that the original behaviour is "unexpected" and someone else could be bitten by this problem in the future, but the customCode workaround works so it's not an issue for me anymore.
@cameronblaikie commented on GitHub (Apr 5, 2019):
Hi @Jorilx ,
I'm unable to replicate this issue on hotfix or latest LTS. Please let me know if this is still an issue you can replicate and we will investigate further.
Thanks.