This will most likely depend on the twig code around it (eg: is it in a for loop, and what you are iterating in the loop), and which twig file you’re editing (as they all are influenced by where they’re called from).
eg: event-single.twig is a special case compared to the others, as it only displays one event at a time, whereas other views need to handle multiple events. This isn’t the only ones with differences however.
I can do them right next to each other, like so:
<div class="col-md-12">
{{ event.get('start') }}
{% if expired( event.get('start') ) %}
<span class="register-for-event expired">Registration Closed</span>
{% else %}
<a class="register-for-event replace-me" data-event-id="{{ event.get( 'post_id' ) }}" href="">Register</a>
{% endif %}
</div>
And I still get two different things. I’m calling the same function on the same object in the same context it seems.
I haven’t played with setting up functions (Time.ly are currently documenting the way to do this with within a calendar child theme, rather than by editing the core code), but I’ve played a lot with twig.
You might try:
{% if expired( event.get('start') | raw ) %}
Or:
{% set startevent = event.get('start') %}
{% if expired( startevent ) %}
Note: What is expired supposed to spit out? The if is expecting true/false only.
I haven’t edited any core code – I used their functions to grab the global Twig Environment from the site’s core plugin, then use new Twig_SimpleFunction() and so on. I hate to edit core files.
Neither of those solutions worked, unfortunately, but it did occur to me that echoing the object resulted in a string, so there must be a method doing it somewhere. That led me to the __toString() method in the Ai1EC_Date_Time class, which got me what I needed, so I ended up with
strtotime($date->__toString())
It did exactly what I wanted. Thanks for taking the time to address my question.