I asked the same question on [stackOverflow]https://stackoverflow.com/questions/74185889/how-to-instantiate-a-datetime-object-at-compile-time):
I'm pretty sure at this point I'm just overlooking something obvious. Anyway, Nim 2 will have the ability to instantiate objects with default values for its fields. The feature is already available on nim's devel branch. Given that, I would like to be able to have this default instantiation for fields with DateTime types.
Something like this:
import std/times
type A = object
d: DateTime = times.now()
let x = default(d)
However, this can not work, as now() can not work at compiletime. Similarly, dateTime and initDateTime break at compiletime.
It is unlikely that the actual value will ever be used, I just need a way to instantiate objects so that other packages can replace the values later on (e.g. norm when parsing data from a database into that object). Given that, how can I instantiate a DateTime to make objects with such fields default initializable?