Dual-Life / Time-Piece

Object Oriented time objects
Other
15 stars 33 forks source link

Add a method to get a time string with a twelve hour and AM/PM #58

Closed scottchiefbaker closed 2 years ago

scottchiefbaker commented 2 years ago

Time::Piece lacks any way to get the hour in a twelve hour format (only 24 hour is supported). This would be a much welcome addition to my American brain. Something like $t->hour12. This would require an option for AM/PM to go with it $t->ampm.

Ideally a method like $t->hms with a twelve hour variant would be very helpful. Perhaps something like $t->hms12 which would return something like: 2:48:28 PM

smith153 commented 2 years ago

This: Time::Piece->new()->strftime('%a, %d %b %Y %I:%M:%S %p %Z'); right now returns: Mon, 18 Jul 2022 08:50:06 PM CDT

Does that work?

scottchiefbaker commented 2 years ago

Yes that does work. I don't know why I didn't even think about strftime() :)

Probably cuz the majority of the man page is dedicated to the built in format options.

smith153 commented 2 years ago

Yea, docs aren't the best, sorry.