www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Cannot understand deprecation message recently added to Phobos

reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
Can somebody explain the meaning of split in the error message

Deprecation: function core.time.Duration.weeks is deprecated - 
Please use split instead. weeks was too frequently confused for 
total!"weeks".

given by function

shortDurationString()

at

https://github.com/nordlow/justd/blob/master/pprint.d
Jun 11 2014
next sibling parent reply "Kapps" <opantm2+spam gmail.com> writes:
On Wednesday, 11 June 2014 at 20:59:25 UTC, Nordlöw wrote:
 Can somebody explain the meaning of split in the error message

 Deprecation: function core.time.Duration.weeks is deprecated - 
 Please use split instead. weeks was too frequently confused for 
 total!"weeks".

 given by function

 shortDurationString()

 at

 https://github.com/nordlow/justd/blob/master/pprint.d
https://github.com/D-Programming-Language/druntime/pull/825
Jun 11 2014
next sibling parent =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
On Wednesday, 11 June 2014 at 21:06:42 UTC, Kapps wrote:
 On Wednesday, 11 June 2014 at 20:59:25 UTC, Nordlöw wrote:
 Can somebody explain the meaning of split in the error message

 Deprecation: function core.time.Duration.weeks is deprecated - 
 Please use split instead. weeks was too frequently confused 
 for total!"weeks".

 given by function

 shortDurationString()

 at

 https://github.com/nordlow/justd/blob/master/pprint.d
https://github.com/D-Programming-Language/druntime/pull/825
Ok, I replaced immutable weeks = dur.weeks(); with immutable weeks = dur.split!"weeks"; but my code using it if (weeks) { if (weeks < 52) fails as pprint.d(39,9): Error: expression weeks of type immutable(SplitUnits) does not have a boolean value pprint.d(41,13): Error: incompatible types for ((weeks) < (52)): 'immutable(SplitUnits)' and 'int' Sorry but I don't understand what to do with the struct SplitUnits.
Jun 11 2014
prev sibling next sibling parent =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
 https://github.com/D-Programming-Language/druntime/pull/825
I updated https://github.com/nordlow/justd/blob/master/pprint.d with two versions of shortDurationString(). DMD picks the right one using static if (__VERSION__ >= 2066L) // new else // old I hope I it right this time.
Jun 11 2014
prev sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Wed, 11 Jun 2014 17:06:41 -0400, Kapps <opantm2+spam gmail.com> wrote=
:

 On Wednesday, 11 June 2014 at 20:59:25 UTC, Nordl=C3=B6w wrote:
 Can somebody explain the meaning of split in the error message

 Deprecation: function core.time.Duration.weeks is deprecated - Please=
=
 use split instead. weeks was too frequently confused for total!"weeks=
".
 given by function

 shortDurationString()

 at

 https://github.com/nordlow/justd/blob/master/pprint.d
https://github.com/D-Programming-Language/druntime/pull/825
Now fixed, is the message clearer for you? https://github.com/D-Programming-Language/druntime/pull/837 -Steve
Jun 12 2014
prev sibling parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Wed, 11 Jun 2014 16:59:24 -0400, Nordl=C3=B6w <per.nordlow gmail.com>=
 wrote:

 Can somebody explain the meaning of split in the error message

 Deprecation: function core.time.Duration.weeks is deprecated - Please =
=
 use split instead. weeks was too frequently confused for total!"weeks"=
.
 given by function

 shortDurationString()

 at

 https://github.com/nordlow/justd/blob/master/pprint.d
Actually, that may not be a valid deprecation message. All the other unit functions do not get the total number of units, but = there are not larger units supported by Duration. In fact, dur.weeks was= = the equivalent of dur.total!"weeks". You can safely change your code to use total!"weeks" instead. Jonathan, can we update this deprecation message? The function is going away because of the confusion with smaller units. = = For example, dur.seconds could be confused as "the number of seconds in = = this duration", but it's really "the number of seconds that do not make = up = a whole minute in this duration". Basically, it's the mod remainder for = = the seconds. -Steve
Jun 11 2014
parent =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
 You can safely change your code to use total!"weeks" instead.
Ok. Thx
Jun 11 2014