I have a datetime value in a component's metadata that I need to access and write out in a component design using the Razor Mediator. Since this is a non-mandatory value I really need to check if it's populated, but as is mentioned in this blog post, datetime in Tridion is non-nullable meaning it simply defaults to the datetime.first value if not populated in a component.
I tried something similar to the suggestion made in the blog post, using the "HasField()" method from Razor documentation instead of "Contains()" as you would in TOM.Net. However, even though I've confirmed in Template Builder that the component object's metadata does not contain an entry for this datetime, it still evaluates as True in "HasField()".
I've got a solution that I'll post, but I'm thinking there's a better option and I'd be curious if someone has a more elegant way to do it, or perhaps could explain why "HasField()" behaves the way it does.