pradosoft / prado

Prado - Component Framework for PHP
Other
186 stars 71 forks source link

TTimeDelta for showing how long ago something was posted (eg 10 seconds, 39 minutes, 6 hours, etc) #777

Open belisoful opened 3 years ago

belisoful commented 3 years ago

this is an interactive interface control for displaying how long ago something was done/posted/submitted/etc.

Many websites now have the "10 minutes ago" that updates in real time for how long ago something was posted.

PRADO needs a component for displaying how long ago something was done. I propose that clicking on the "xx minutes/hours ago" would change to the date and time of the event.

This is developed here: https://github.com/belisoful/prado/blob/master/framework/Web/UI/WebControls/TTimeAgo.php

There is a javascript aspect to this component so Prado JS map is updated.

The major challenge is I18N of this component as the interface is driven by javascript rather than server side.

belisoful commented 3 years ago

I'm thinking about how this should work. I have a prototype for comment here:

https://github.com/belisoful/prado/blob/master/framework/Web/UI/WebControls/TTimeAgo.php

I'm thinking of removing the "ago" part and just focus on the timing, both count down to a time, and how long ago a time was.

I'm also waiting on fixing my computer code so php ICU-units works. I'm just focusing on these other changes first.

belisoful commented 1 year ago

The environment I was in before didn't have the PHP resources built in for I18N. when I have a moment, I'll re-look at this again.

belisoful commented 1 year ago

Maybe php 8 (and the OS) has these I8N resources on my dev system now

ctrlaltca commented 1 year ago

You can use php's DateInterval to calculate the "time delta" and format it. Then you can get localized data from ICU (php's intl extension). A nice web interface to see what's available can be found here: https://intl.rmcreative.ru/unit-data/en Prado\I18N\core\CultureInfo is already able to fetch data from ICU, but maybe you'll need to add support for the ICUDATA-unit table

belisoful commented 1 year ago

I was trying to access the ICU Data but in the prior php system it was not found. It just wasn't there. So. It was delayed.

belisoful commented 1 year ago

imagining: `"2023-05-31 13:11:11+800" web component? and having the TTimeAgo for the template?

Prado doesn't have any architecture for WebComponents. #963