On Monday, June 9, 2025 at 2:59:44 PM UTC-4 David Karr wrote:

I've used "time.Parse()" several times in various small applications, and 
today I realized a curious inflexibility with it.  If I have to parse date 
values where the months or days could be either 1 or 2 digits, which is all 
cases if the code might be dealing with dates anywhere in the year, then I 
have no choice but to implement a "normalize" function that adds a "0" at 
the start if the value is not two digits. I got this to work, but anyone 
who uses this method would have to write the same code. It seems odd that 
this wouldn't be handled automatically.


David,

What does the documentation say?

https://pkg.go.dev/time@latest    

Within the format string, the underscores in "_2" and "__2" represent 
spaces that may be replaced by digits if the following number has multiple 
digits, for compatibility with fixed-width Unix time formats. A leading 
zero represents a zero-padded value.

Peter 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/d056071c-8f1c-4def-afcc-1671e13c7190n%40googlegroups.com.

Reply via email to