Re: [go-nuts] time: error prone implementation of Time.Format

2017-03-30 Thread Manlio Perillo
Il giorno giovedì 30 marzo 2017 17:28:47 UTC+2, Ian Lance Taylor ha scritto:
>
> > [...]
> >> But it's not clearly incorrect to write 
> >> 
> >> "2006-01-02 or Jan 02, 2006" 
> >> 
> > 
> > I'm probably missing something, but "2006-01-02" is a valid time layout 
> > string. 
>
> I'm presenting that entire string as a valid time layout format.  It 
> is valid today, but would be invalid under your proposed change. 
>
> My point is to repeat what I said before: it is difficult to define 
> "clearly incorrect." 
>
>
Ok.
I missed the fact that "2006-01-02 or Jan 02, 2006"  was one layout string 
and not two different layout strings.


Thanks
Manlio

-- 
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.


Re: [go-nuts] time: error prone implementation of Time.Format

2017-03-30 Thread Ian Lance Taylor
On Thu, Mar 30, 2017 at 7:49 AM, Manlio Perillo
 wrote:
> Il giorno giovedì 30 marzo 2017 01:21:14 UTC+2, Ian Lance Taylor ha scritto:
>>
>> On Wed, Mar 29, 2017 at 2:29 PM, Manlio Perillo
>>  wrote:
>> > Il giorno mercoledì 29 marzo 2017 23:18:09 UTC+2, Ian Lance Taylor ha
>> > scritto:
>> >>
>> >> On Wed, Mar 29, 2017 at 2:03 PM, Manlio Perillo
>> >>  wrote:
>> >> > In a program I have a function that formats the time in Italian date
>> >> > format:
>> >> > dd/mm/, but, due to an oversight, I wrote the layout string as
>> >> > "02/02/2006", instead of "02/01/2006".
>> >> > This caused all the dates to be incorrectly formatted.
>> >> >
>> >> > IMHO, this is a nasty behavior.  The layout is clearly incorrect and
>> >> > the
>> >> > implementation should report an error, instead of returning an
>> >> > incorrectly
>> >> > formatted time.
>> >>
>> >> I think it would be difficult to define "clearly incorrect" in a way
>> >> that does not introduce any false negatives while remaining useful.
>> >
>> >
>> > In my case I specified stdZeroDay twice.
>> >
>> > The AppendFormat function can define some additional boolean variables:
>> > hasYear, hasMonth, hasDay, ...
>> > and return an error if a variable is set to true more than one time.
>>
>> But it's not clearly incorrect to write
>>
>> "2006-01-02 or Jan 02, 2006"
>>
>
> I'm probably missing something, but "2006-01-02" is a valid time layout
> string.

I'm presenting that entire string as a valid time layout format.  It
is valid today, but would be invalid under your proposed change.

My point is to repeat what I said before: it is difficult to define
"clearly incorrect."

Ian

-- 
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.


Re: [go-nuts] time: error prone implementation of Time.Format

2017-03-30 Thread David Collier-Brown
I think he said "02/02/2006", and got two day-numbers instead of a day and 
a month.

--dave

On Thursday, March 30, 2017 at 10:49:29 AM UTC-4, Manlio Perillo wrote:
>
> Il giorno giovedì 30 marzo 2017 01:21:14 UTC+2, Ian Lance Taylor ha 
> scritto:
>>
>> On Wed, Mar 29, 2017 at 2:29 PM, Manlio Perillo 
>>  wrote: 
>> > Il giorno mercoledì 29 marzo 2017 23:18:09 UTC+2, Ian Lance Taylor ha 
>> > scritto: 
>> >> 
>> >> On Wed, Mar 29, 2017 at 2:03 PM, Manlio Perillo 
>> >>  wrote: 
>> >> > In a program I have a function that formats the time in Italian date 
>> >> > format: 
>> >> > dd/mm/, but, due to an oversight, I wrote the layout string as 
>> >> > "02/02/2006", instead of "02/01/2006". 
>> >> > This caused all the dates to be incorrectly formatted. 
>> >> > 
>> >> > IMHO, this is a nasty behavior.  The layout is clearly incorrect and 
>> the 
>> >> > implementation should report an error, instead of returning an 
>> >> > incorrectly 
>> >> > formatted time. 
>> >> 
>> >> I think it would be difficult to define "clearly incorrect" in a way 
>> >> that does not introduce any false negatives while remaining useful. 
>> > 
>> > 
>> > In my case I specified stdZeroDay twice. 
>> > 
>> > The AppendFormat function can define some additional boolean variables: 
>> > hasYear, hasMonth, hasDay, ... 
>> > and return an error if a variable is set to true more than one time. 
>>
>> But it's not clearly incorrect to write 
>>
>> "2006-01-02 or Jan 02, 2006" 
>>
>>
> I'm probably missing something, but "2006-01-02" is a valid time layout 
> string.
>
> Manlio 
>

-- 
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.


Re: [go-nuts] time: error prone implementation of Time.Format

2017-03-30 Thread Manlio Perillo
Il giorno giovedì 30 marzo 2017 01:21:14 UTC+2, Ian Lance Taylor ha scritto:
>
> On Wed, Mar 29, 2017 at 2:29 PM, Manlio Perillo 
> > wrote: 
> > Il giorno mercoledì 29 marzo 2017 23:18:09 UTC+2, Ian Lance Taylor ha 
> > scritto: 
> >> 
> >> On Wed, Mar 29, 2017 at 2:03 PM, Manlio Perillo 
> >>  wrote: 
> >> > In a program I have a function that formats the time in Italian date 
> >> > format: 
> >> > dd/mm/, but, due to an oversight, I wrote the layout string as 
> >> > "02/02/2006", instead of "02/01/2006". 
> >> > This caused all the dates to be incorrectly formatted. 
> >> > 
> >> > IMHO, this is a nasty behavior.  The layout is clearly incorrect and 
> the 
> >> > implementation should report an error, instead of returning an 
> >> > incorrectly 
> >> > formatted time. 
> >> 
> >> I think it would be difficult to define "clearly incorrect" in a way 
> >> that does not introduce any false negatives while remaining useful. 
> > 
> > 
> > In my case I specified stdZeroDay twice. 
> > 
> > The AppendFormat function can define some additional boolean variables: 
> > hasYear, hasMonth, hasDay, ... 
> > and return an error if a variable is set to true more than one time. 
>
> But it's not clearly incorrect to write 
>
> "2006-01-02 or Jan 02, 2006" 
>
>
I'm probably missing something, but "2006-01-02" is a valid time layout 
string.

Manlio 

-- 
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.


Re: [go-nuts] time: error prone implementation of Time.Format

2017-03-30 Thread Manlio Perillo
Certainly this is a bug that can be found with unit test, however catching 
a bug early is always better, if this is possible.


Manlio



Il giorno giovedì 30 marzo 2017 13:18:35 UTC+2, rog ha scritto:
>
> Isn't this the kind of thing we write tests for?
>
> On 29 Mar 2017 22:03, "Manlio Perillo" > 
> wrote:
>
>> In a program I have a function that formats the time in Italian date 
>> format: dd/mm/, but, due to an oversight, I wrote the layout string as 
>> "02/02/2006", instead of "02/01/2006".
>> This caused all the dates to be incorrectly formatted.
>>
>> IMHO, this is a nasty behavior.  The layout is clearly incorrect and the 
>> implementation should report an error, instead of returning an incorrectly 
>> formatted time.
>>
>>
>> Thanks
>> Manlio
>>
>> -- 
>> 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 .
>> 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.


Re: [go-nuts] time: error prone implementation of Time.Format

2017-03-30 Thread David Collier-Brown
>From your described implementation, I assume you're asking for something 
like

As a programmer, if I ask for a date with month twice, I wish to 
revieve a warning"

If so, it would complain if I asked to print something like "01/01/2017 (1 
Jan 2017)"

--dave

-- 
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.


Re: [go-nuts] time: error prone implementation of Time.Format

2017-03-30 Thread David Collier-Brown
>From your described implementation, I assume youre asking for



On Wednesday, March 29, 2017 at 5:29:19 PM UTC-4, Manlio Perillo wrote:
>
> Il giorno mercoledì 29 marzo 2017 23:18:09 UTC+2, Ian Lance Taylor ha 
> scritto:
>>
>> On Wed, Mar 29, 2017 at 2:03 PM, Manlio Perillo 
>>  wrote: 
>> > In a program I have a function that formats the time in Italian date 
>> format: 
>> > dd/mm/, but, due to an oversight, I wrote the layout string as 
>> > "02/02/2006", instead of "02/01/2006". 
>> > This caused all the dates to be incorrectly formatted. 
>> > 
>> > IMHO, this is a nasty behavior.  The layout is clearly incorrect and 
>> the 
>> > implementation should report an error, instead of returning an 
>> incorrectly 
>> > formatted time. 
>>
>> I think it would be difficult to define "clearly incorrect" in a way 
>> that does not introduce any false negatives while remaining useful. 
>>
>
> In my case I specified stdZeroDay twice.
>
> The AppendFormat function can define some additional boolean variables:
> hasYear, hasMonth, hasDay, ...
> and return an error if a variable is set to true more than one time.
>
>
> Manlio 
>

-- 
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.


Re: [go-nuts] time: error prone implementation of Time.Format

2017-03-30 Thread roger peppe
Isn't this the kind of thing we write tests for?

On 29 Mar 2017 22:03, "Manlio Perillo"  wrote:

> In a program I have a function that formats the time in Italian date
> format: dd/mm/, but, due to an oversight, I wrote the layout string as
> "02/02/2006", instead of "02/01/2006".
> This caused all the dates to be incorrectly formatted.
>
> IMHO, this is a nasty behavior.  The layout is clearly incorrect and the
> implementation should report an error, instead of returning an incorrectly
> formatted time.
>
>
> Thanks
> Manlio
>
> --
> 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.
>

-- 
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.


RE: [go-nuts] time: error prone implementation of Time.Format

2017-03-29 Thread John Souvestre
Granted, but is this a common occurrence?  Also, the workaround is easy.

On the other hand, how common are the errors which would be caught by adding 
the test?

John

John Souvestre - New Orleans LA


-Original Message-
From: golang-nuts@googlegroups.com [mailto:golang-nuts@googlegroups.com] On 
Behalf Of Ian Lance Taylor
Sent: 2017 March 29, Wed 18:21
To: Manlio Perillo
Cc: golang-nuts
Subject: Re: [go-nuts] time: error prone implementation of Time.Format

On Wed, Mar 29, 2017 at 2:29 PM, Manlio Perillo
 wrote:
> Il giorno mercoled� 29 marzo 2017 23:18:09 UTC+2, Ian Lance Taylor ha
> scritto:
>>
>> On Wed, Mar 29, 2017 at 2:03 PM, Manlio Perillo
>>  wrote:
>> > In a program I have a function that formats the time in Italian date
>> > format:
>> > dd/mm/, but, due to an oversight, I wrote the layout string as
>> > "02/02/2006", instead of "02/01/2006".
>> > This caused all the dates to be incorrectly formatted.
>> >
>> > IMHO, this is a nasty behavior.  The layout is clearly incorrect and the
>> > implementation should report an error, instead of returning an
>> > incorrectly
>> > formatted time.
>>
>> I think it would be difficult to define "clearly incorrect" in a way
>> that does not introduce any false negatives while remaining useful.
>
>
> In my case I specified stdZeroDay twice.
>
> The AppendFormat function can define some additional boolean variables:
> hasYear, hasMonth, hasDay, ...
> and return an error if a variable is set to true more than one time.

But it's not clearly incorrect to write

"2006-01-02 or Jan 02, 2006"

Ian

-- 
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.

-- 
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.


Re: [go-nuts] time: error prone implementation of Time.Format

2017-03-29 Thread Ian Lance Taylor
On Wed, Mar 29, 2017 at 2:29 PM, Manlio Perillo
 wrote:
> Il giorno mercoledì 29 marzo 2017 23:18:09 UTC+2, Ian Lance Taylor ha
> scritto:
>>
>> On Wed, Mar 29, 2017 at 2:03 PM, Manlio Perillo
>>  wrote:
>> > In a program I have a function that formats the time in Italian date
>> > format:
>> > dd/mm/, but, due to an oversight, I wrote the layout string as
>> > "02/02/2006", instead of "02/01/2006".
>> > This caused all the dates to be incorrectly formatted.
>> >
>> > IMHO, this is a nasty behavior.  The layout is clearly incorrect and the
>> > implementation should report an error, instead of returning an
>> > incorrectly
>> > formatted time.
>>
>> I think it would be difficult to define "clearly incorrect" in a way
>> that does not introduce any false negatives while remaining useful.
>
>
> In my case I specified stdZeroDay twice.
>
> The AppendFormat function can define some additional boolean variables:
> hasYear, hasMonth, hasDay, ...
> and return an error if a variable is set to true more than one time.

But it's not clearly incorrect to write

"2006-01-02 or Jan 02, 2006"

Ian

-- 
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.


Re: [go-nuts] time: error prone implementation of Time.Format

2017-03-29 Thread Manlio Perillo
Il giorno mercoledì 29 marzo 2017 23:18:09 UTC+2, Ian Lance Taylor ha 
scritto:
>
> On Wed, Mar 29, 2017 at 2:03 PM, Manlio Perillo 
> > wrote: 
> > In a program I have a function that formats the time in Italian date 
> format: 
> > dd/mm/, but, due to an oversight, I wrote the layout string as 
> > "02/02/2006", instead of "02/01/2006". 
> > This caused all the dates to be incorrectly formatted. 
> > 
> > IMHO, this is a nasty behavior.  The layout is clearly incorrect and the 
> > implementation should report an error, instead of returning an 
> incorrectly 
> > formatted time. 
>
> I think it would be difficult to define "clearly incorrect" in a way 
> that does not introduce any false negatives while remaining useful. 
>

In my case I specified stdZeroDay twice.

The AppendFormat function can define some additional boolean variables:
hasYear, hasMonth, hasDay, ...
and return an error if a variable is set to true more than one time.


Manlio 

-- 
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.


Re: [go-nuts] time: error prone implementation of Time.Format

2017-03-29 Thread Ian Lance Taylor
On Wed, Mar 29, 2017 at 2:03 PM, Manlio Perillo
 wrote:
> In a program I have a function that formats the time in Italian date format:
> dd/mm/, but, due to an oversight, I wrote the layout string as
> "02/02/2006", instead of "02/01/2006".
> This caused all the dates to be incorrectly formatted.
>
> IMHO, this is a nasty behavior.  The layout is clearly incorrect and the
> implementation should report an error, instead of returning an incorrectly
> formatted time.

I think it would be difficult to define "clearly incorrect" in a way
that does not introduce any false negatives while remaining useful.

Ian

-- 
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.


[go-nuts] time: error prone implementation of Time.Format

2017-03-29 Thread Manlio Perillo
In a program I have a function that formats the time in Italian date 
format: dd/mm/, but, due to an oversight, I wrote the layout string as 
"02/02/2006", instead of "02/01/2006".
This caused all the dates to be incorrectly formatted.

IMHO, this is a nasty behavior.  The layout is clearly incorrect and the 
implementation should report an error, instead of returning an incorrectly 
formatted time.


Thanks
Manlio

-- 
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.