ceylon-sdk
ceylon-sdk copied to clipboard
datestamp() function
Currently ceylon.time can produce ISO timestamps. I would also like to have a convenience function for rendering "date stamps", of form 20161102.
@DiegoCoronel @luolong WDYT?
parseDate not good enough?
or do you mean the other way around — that would be Date.string, I guess...
Nope, it uses this format:
"Returns ISO-8601 formatted String representation of this date.\n
Reference: https://en.wikipedia.org/wiki/ISO_8601#Dates"
shared actual String string
=> "``year.string.padLeading(4, '0')``-``month.integer.string.padLeading(2, '0')``-``day.string.padLeading(2, '0')``";
I want, literally: 20161102.
Well, the trouble here is that all those *.string methods are currently returning similarly formatted output across the board.
Date.string returns yyyy-mm-dd, Time.string returns hh:mm:ss, DateTime.string returns Date.string + 'T' + Time.string and Instant (the timestamp) simply returns ZoneDateTime.string at UTC.
I suppose the correct way to approach this would be to put those specific formats into ceylon.formatter module.
On the other hand, the YYMMDD and HHmmss formats are also valid ISO representations. so it would be relatively easy to change default output to the shorter variant.
I personally dislike those though. They are useful at times, but I prefer to keep the variants with dashes and colons as default textual representation.
Well, the trouble here is that all those
*.stringmethods are currently returning similarly formatted output across the board.
And I think that's perfectly fine. I don't want to change that.
But the shorter YYMMDD and HHmmss formats are also sometimes useful, and I think we should have convenience functions (or attributes, perhaps) for generating them.