On a low level, we probably want to make use of ruby's "strftime", which offers a lot of flexibility, and can be done securely because it's just a string (not executable code). Below is an example of strftime in use for the *now card:
define_view :raw, :name=>'now' do |args|
Time.now.strftime('%A, %B %d, %Y %I:%M %p %Z')
end
The string in bold is what we want to allow wagneers to configure. We could eventually build clean interface for choosing / constructing such strings.
Much less clear is what's needed on a high level. One idea proposed has been that there be a setting like "*time format". There are several problems that would have to be worked out for that to fly:
- We generally want the format to be determined by the context, not the date. Consider the *now card; you might sometimes want to show it in words, other times in numbers. If our only tool is a rule on the *now card, then how does that work?
- Similarly, let's say there's a card "my schedule" with 20 dates on it. You often want them all formatted the same way. How's that work? One obvious proposal is that there is a format rule on "my schedule", but then we have an interesting question of where we find the rule. If "my plan" includes "my schedule" includes "my appointment" includes "my appointment+time", where do we go to find our rule? Remember, if there's a *all rule, they all have one, so you'd have to have some principle that would allow you NOT to use that rule on "my appointment+time" in order to know how to contextualize it.
- this gets even messier when you consider that you typically need separate handing for dates, times, and combinations thereof. Do we create settings for each?
My impulse is to say that this may make more sense to handle in inclusion syntax, but that idea will need baking, too.