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

toDate() and time in future - relative time is wrong #3605

Closed
Jimmi08 opened this issue Jan 7, 2019 · 9 comments
Closed

toDate() and time in future - relative time is wrong #3605

Jimmi08 opened this issue Jan 7, 2019 · 9 comments
Labels
type: bug A problem that should not be happening
Milestone

Comments

@Jimmi08
Copy link
Contributor

Jimmi08 commented Jan 7, 2019

I have those data:

    ".$row2['ecds_date']." <br>
    ".$tp->toDate($row2['ecds_date'], "relative")." <br>
    ".$tp->toDate($row2['ecds_date'], "long")."

Result:
image

Date is correctly saved in Unix forum. Manual checking:
image
image

What could be wrong?
Server time is correct (user timezone is not used)

image

Checked html code:
<span data-livestamp="1546988400">1 day ago</span>

@Moc Moc added the status: testing required Someone needs to confirm this issue's existence and write a test to prevent the fix from regressing. label Jan 8, 2019
@Moc
Copy link
Member

Moc commented Jan 10, 2019

Confirmed. Test code:

<?php
require_once("class2.php");
require_once(HEADERF);
 
$timestamp = "1577880000"; // January 1st, 2020. 12:00 (24h) 

$text = "Long: ".e107::getParser()->toDate($timestamp, "long")." <br >";
$text .= "Relative: ".e107::getParser()->toDate($timestamp, "relative")." <br >";

$ns->tablerender($caption, $text);
require_once(FOOTERF);

@Moc Moc added type: bug A problem that should not be happening and removed status: testing required Someone needs to confirm this issue's existence and write a test to prevent the fix from regressing. labels Jan 10, 2019
@Moc Moc modified the milestone: e107 2.2.0 Jan 10, 2019
@Moc
Copy link
Member

Moc commented Jan 10, 2019

So it works properly when I install the plugin "Livetime" by @arunshekher which includes the actual JS files required to make use of the 'livestamp' plugin (http://mattbradley.github.io/livestampjs/) referred to in the docs of the toDate() method

By default these files are not included. I'm just wondering why by default it does support "x time ago" but not future. Researching....

@Jimmi08
Copy link
Contributor Author

Jimmi08 commented Jan 10, 2019

And I think there is hardcoded Lang string as AGO. (translated but always ago)

@Moc
Copy link
Member

Moc commented Jan 10, 2019

When using 'relative', by default the toDate() method calls the computeLapse() method in date_handler.

This by default returns return ($mode ? $outputArray : implode(", ", $outputArray) . " " . LANDT_AGO);

LANDT_AGO which is defined as define("LANDT_AGO", "ago");

I think it should also consider datestamps in the future.
@CaMer0n thoughts?

@Moc Moc added this to the e107 2.2.0 milestone Jan 10, 2019
@CaMer0n
Copy link
Member

CaMer0n commented Jan 11, 2019

@Moc I agree. 👍

@Moc Moc closed this as completed in 01263ef Jan 11, 2019
@Moc
Copy link
Member

Moc commented Jan 11, 2019

@CaMer0n Can you check if my fix is OK please? I am pretty sure it could be done more efficiently but I didn't want to break anything as it such a core method.

Moc added a commit that referenced this issue Jan 11, 2019
@CaMer0n
Copy link
Member

CaMer0n commented Jan 11, 2019

@Moc I ran the test and it failed. It appears to be placing 'in ' in all cases for me. How about you?

@CaMer0n
Copy link
Member

CaMer0n commented Jan 16, 2019

@Moc I found some time to rewrite it. Please give it a try. Thanks.

@Moc
Copy link
Member

Moc commented Jan 16, 2019

@CaMer0n Thanks! Just tested and it seems to work fine 👍

@Moc Moc closed this as completed Jan 16, 2019
Moc added a commit that referenced this issue Feb 9, 2019
Used in relative datestamp. This makes sure "just now" is properly displayed".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A problem that should not be happening
Projects
None yet
Development

No branches or pull requests

3 participants