Is there a better way to handle DateTime when I need to reset a field value? I have to use "make" and refill original values, and I have to check for overflow to next field. It would be nice if DateTime would have a set(FiedType, fieldValue) method.
~Zemian
brianSat 17 Dec 2011
For adding fields you typically use + some duration. It handles overflow, and can get be especially nice if you switch to Date for managing dates. I do an extreme amount of time manipulation, but never actually wanted to set a specific field. Seems useful, but at the same time I don't want to add a constant or method for every field - that would be a ton of clutter for marginal value.
So I think it is really just figuring out a nice API that is only one (or a couple) of methods. Maybe something like using a Locale pattern:
saltnlight5 Sat 17 Dec 2011
I wrote a little cron expression parser in Fantom. https://bitbucket.org/saltnlight5/fan-examples/src/c2baba25527d/scripts/cron.fan
Is there a better way to handle DateTime when I need to reset a field value? I have to use "make" and refill original values, and I have to check for overflow to next field. It would be nice if DateTime would have a set(FiedType, fieldValue) method.
~Zemian
brian Sat 17 Dec 2011
For adding fields you typically use + some duration. It handles overflow, and can get be especially nice if you switch to Date for managing dates. I do an extreme amount of time manipulation, but never actually wanted to set a specific field. Seems useful, but at the same time I don't want to add a constant or method for every field - that would be a ton of clutter for marginal value.
So I think it is really just figuring out a nice API that is only one (or a couple) of methods. Maybe something like using a Locale pattern:
msl Sun 18 Dec 2011
How about a minor change to that proposal:
So you could then do:
saltnlight5 Mon 19 Dec 2011
I tend to like enum more than free text for type. In any case, a method is better than no better though. :)