Extension, Fieldtype, Module

Developer
Supported

Event Helper

ExpressionEngine 3, ExpressionEngine 4

Back to this add-on's main page
View Other Add-ons From Derek Hogue

     

You must be logged in to post.

Events/dates before the Unix Epoch don’t display

General

Boiler Room Digital
Boiler Room Digital

Hello,

It took me a while to work this out, but I noticed that I’d used an EE Helper field to replace a DropDate field in EE3 (since EE Helper date fields were displaying nicely on the front end and in my Channel Forms). I noticed that the “Birthday” fields weren’t displaying a date, and I realised that this is because they’re before 1970 (so the Unix Timestamp is a negative number).

When it comes to editing, the number is still there (though I think partly because of a workaround I used in a previous post where I’m querying the database a second time with my own addon).

The key code (in ft.event_helper.php) is

function replace_tag($data$params = array(), $tagdata FALSE)
 
{
  
if($data 0)
  
{
   
return ee()->TMPL->process_date($data$params);  
  
}
 }
 
 
function replace_relative($data$params = array(), $tagdata FALSE)
 
{
  
if($data 0)
  
{
   
return ee()->TMPL->process_date($data$paramstrue); 
  
}
 } 

If I change this to

if($data != 0

instead, all the birthdays display. I guess the only risk is someone being born on 1st Jan 1970… How is this normally handled

I know that this isn’t the intended use case for Event Helper (I guess most often it’s used to add events in the future, rather than the distant past) but I wondered if you had any thoughts…

Derek Hogue
# 1
Developer
Derek Hogue

Good catch. Really that should just be a !empty($data) conditional, but there was an issue at some point in the add-on’s history where I had been returning FALSE rather than NULL for empty fields, which ended up saving 0 rather than NULL to the database, and thus creating false positives for empty fields.

But it’s likely time to ditch that for this exact reason. I’ll change it in the next update.