> I don’t see an obvious way of expressing the example hour (15) in a way 
that would imply “24 hour format, but no zero padding”.

I agree with that.
It's difficult to decide an example format for 24-hour without zero padding 
as a part of the standard feature.

And that makes me believe the customizing feature is useful.
Developers can decide the example expression for their custom formats as it 
works fine with their usecases.
They may want to use 8 (unused in the existing example formats) for that, 
or may want to use f (hexiadecimal of 15) for that.


2017年7月2日日曜日 3時22分27秒 UTC+9 Jakob Borg:
>
> I think this would be difficult to do correctly, given the (very unusual) 
> choice of using an example time as the format string. I don’t see an 
> obvious way of expressing the example hour (15) in a way that would imply 
> “24 hour format, but no zero padding”.
>
> //jb
>
> On 1 Jul 2017, at 19:01, "iked...@gmail.com <javascript:>" <
> iked...@gmail.com <javascript:>> wrote:
>
> Thanks for the answer.
>
> I believe it would be nice if custom formats can be added by developers.
> Does it make sense to create a pull request for time/format to allow 
> developers add custom formats?
>
> Custom formats can be defined if I could extend `nextStdChunk` (extracting 
> `std` from layouts) and a part of `AppendFormat` (converting `std` to 
> outputs).
> So I plan to extract and export those two functions, and provide alternate 
> `Format` (e.g. `FormatWithCustomStd) that receives customized version of 
> them.
>
> Or should it be provided as some third-party library?
>
> Regards,
> Ikedam
>
> 2017年7月2日日曜日 1時18分14秒 UTC+9 Sam Whited: 
>>
>> On Sat, Jul 1, 2017 at 11:01 AM, Sam Whited <s...@samwhited.com> wrote: 
>> > Check out the documentation for the "Format" function: 
>>
>> Follow up because I only answered part of the question (my apologies): 
>> unfortunately, while Format does allow you to add custom formats, it 
>> won't let you change the padding for 24-hour formats. You could always 
>> format a simple timestamp like this using the generic string 
>> formatting methods: 
>>
>>     fmt.Println(fmt.Sprintf("%d:%02d", t.Hour(), t.Minute())) 
>>
>> —Sam 
>>
> -- 
> 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...@googlegroups.com <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to