J
jfry
Hey all,
I'm a relative ruby beginner, looking to create short-ish date/time
strings. I came up with:
Time.now.xmlschema.delete(':-').chop.chop.chop.chop #yields something
like 20071022T123910
Which works for me...but it seemed like I might be doing acrobatics to
solve a problem that ruby can solve more elegantly. I'm mostly just
looking for a unique alphanumeric string that's not too long. (I
chopped the timezone to make it a bit shorter.) The particular format
I ended up with works well for me, but is not a requirement - another
option I'd be happy with would be seconds (or smaller) since epoch,
for example.
I ask because I enjoy learning to make my ruby more elegant.
Thanks,
Jeff
I'm a relative ruby beginner, looking to create short-ish date/time
strings. I came up with:
Time.now.xmlschema.delete(':-').chop.chop.chop.chop #yields something
like 20071022T123910
Which works for me...but it seemed like I might be doing acrobatics to
solve a problem that ruby can solve more elegantly. I'm mostly just
looking for a unique alphanumeric string that's not too long. (I
chopped the timezone to make it a bit shorter.) The particular format
I ended up with works well for me, but is not a requirement - another
option I'd be happy with would be seconds (or smaller) since epoch,
for example.
I ask because I enjoy learning to make my ruby more elegant.
Thanks,
Jeff