As designed <xf:date>'s data-full-old-date doesn't work for future dates

DragonByte Tech

Well-known member
Affected version
2.0.1
Now you might be tempted to say that's not a bug since it specifically says old dates, but there's no "data-full-future-date" and it was touted as being the method with which to always display full dates, so I'm reporting it as a bug.

I have a date field for license expiry that may be a date in the future and may be a date in the past, and I don't think you should be forced to create an if check and manually define date formats if it's a future date vs if it's a past date :p


Fillip
 
@Kier this does not appear to work for dates in the past:

PHP:
            <xf:formrow label="{{ phrase('dbtech_ecommerce_purchase_date') }}">
                <xf:date time="{$license.purchase_date}" data-full-date="true" />
            </xf:formrow>

            <xf:formrow label="{{ phrase('dbtech_ecommerce_expiry_date') }}">
                <xf:if is="{{ $license.isLifetime() }}">
                    {{ phrase('never') }}
                <xf:else />
                    <xf:date time="{$license.expiry_date}" data-full-date="true" />
                </xf:if>
            </xf:formrow>

1517512044140.webp

Fillip
 
The date stamp is hitting this part of the JS:

JavaScript:
                else if (thisTime >= yesterdayStart)
                {
                    if (dynType !== 'yesterday')
                    {
                        $el.text(XF.phrase('yesterday_at_x', {
                            '{time}': $el.attr('data-time-string') // must use attr for string value
                        }));
                        el.xfDynType = 'yesterday';
                    }
                }

Which is wrong, when the data-full-date attribute is used it should always use the full date. It seems to me like the whole refresh function should have been rewritten but it wasn't.


Fillip
 
In case it helps with testing, here's the outputted HTML:

HTML:
            <dl class="formRow">
                <dt>
                    <div class="formRow-labelWrapper">
                    <label class="formRow-label">Purchase date</label></div>
                </dt>
                <dd>
                    
                <time  class="u-dt" dir="auto" datetime="2018-01-31T15:56:18+0000" data-time="1517414178" data-date-string="Jan 31, 2018" data-time-string="3:56 PM" title="Jan 31, 2018 at 3:56 PM" data-full-date="true">Yesterday at 3:56 PM</time>
            
                </dd>
            </dl>
        

            
            <dl class="formRow">
                <dt>
                    <div class="formRow-labelWrapper">
                    <label class="formRow-label">Expiry date</label></div>
                </dt>
                <dd>
                    
                
                    <time  class="u-dt" dir="auto" datetime="2018-05-01T16:56:18+0100" data-time="1525190178" data-date-string="May 1, 2018" data-time-string="4:56 PM" title="May 1, 2018 at 4:56 PM" data-full-date="true">May 1, 2018</time>
                
            
                </dd>
            </dl>


Fillip
 
I might be missing something here, but I actually only changed the behaviour for future dates.

The previous data-full-old-date attribute is actually just a switch for dates that fall outside of the 'relative' window (Monday, yesterday, tomorrow etc.) and it would only show the full date/time string in the event that the outputted string did not include the time - ie:, just 'January 24th' rather than 'January 24th 2018 16:45'.
 
I might be missing something here, but I actually only changed the behaviour for future dates.

The previous data-full-old-date attribute is actually just a switch for dates that fall outside of the 'relative' window (Monday, yesterday, tomorrow etc.) and it would only show the full date/time string in the event that the outputted string did not include the time - ie:, just 'January 24th' rather than 'January 24th 2018 16:45'.
I'm not sure I understand - the desired behaviour (and what the name implies) is that no matter what the time stamp is, the full date & time should be displayed. If that is not the intended behaviour, then the naming is very confusing.


Fillip
 
I'm not sure I understand - the desired behaviour (and what the name implies) is that no matter what the time stamp is, the full date & time should be displayed. If that is not the intended behaviour, then the naming is very confusing.


Fillip
I think what you're looking for is basic, non-dynamic absolute date/time output. <xf:date> is very much geared up to dynamic output, so don't use that if you don't need or want the dynamic aspect.

Instead, you should be using {{ date($unixtime) }} and {{ time($unixtime) }}, or {{ date($unixtime, $YOUR_FORMAT_HERE) }}

Examples:
HTML:
<time>{{ date($t) }} at {{ time($t) }}</time>
<time datetime="{{ date($t, 'H:i:s l jS F Y') }}">{{ time($t) }}</time>
 
I think what you're looking for is basic, non-dynamic absolute date/time output. <xf:date> is very much geared up to dynamic output, so don't use that if you don't need or want the dynamic aspect.

Instead, you should be using {{ date($unixtime) }} and {{ time($unixtime) }}, or {{ date($unixtime, $YOUR_FORMAT_HERE) }}

Examples:
HTML:
<time>{{ date($t) }} at {{ time($t) }}</time>
<time datetime="{{ date($t, 'H:i:s l jS F Y') }}">{{ time($t) }}</time>
Sorry for bumping it up. Is there a CSS-only or LESS-only approach to achieve this?
I want to hack node-extra-date to show exact {{ date($unixtime) }}, while its format syncs with the locale settings of the current language file.
 
Last edited:
Back
Top Bottom