Fix scope usage of SysTime/TimeZone

This commit is contained in:
dkorpel 2021-11-16 20:12:17 +01:00 committed by The Dlang Bot
parent 62780daf85
commit 5d0cfcd13a
5 changed files with 59 additions and 58 deletions

View file

@ -8349,7 +8349,7 @@ private:
}
{
SysTime stFunc(scope const SysTime st) { return cast(SysTime) st; }
SysTime stFunc(scope const SysTime st) { return SysTime.init; }
auto interval = Interval!SysTime(SysTime(DateTime(2010, 7, 4, 12, 1, 7)),
SysTime(DateTime(2012, 1, 7, 14, 0, 0)));
auto ir = IntervalRange!(SysTime, Direction.fwd)(interval, &stFunc);
@ -8794,7 +8794,7 @@ private:
}
{
SysTime stFunc(scope const SysTime st) { return cast(SysTime) st; }
SysTime stFunc(scope const SysTime st) { return SysTime.init; }
auto posInfInterval = PosInfInterval!SysTime(SysTime(DateTime(2010, 7, 4, 12, 1, 7)));
auto ir = PosInfIntervalRange!SysTime(posInfInterval, &stFunc);
}
@ -9076,7 +9076,7 @@ private:
}
{
SysTime stFunc(scope const SysTime st) { return cast(SysTime)(st); }
SysTime stFunc(scope const SysTime st) { return SysTime.init; }
auto negInfInterval = NegInfInterval!SysTime(SysTime(DateTime(2012, 1, 7, 14, 0, 0)));
auto ir = NegInfIntervalRange!(SysTime)(negInfInterval, &stFunc);
}

View file

@ -503,7 +503,7 @@ public:
given $(REF DateTime,std,datetime,date) is assumed to
be in the given time zone.
+/
this(DateTime dateTime, immutable TimeZone tz = null) @safe nothrow
this(DateTime dateTime, return scope immutable TimeZone tz = null) return scope @safe nothrow
{
try
this(dateTime, Duration.zero, tz);
@ -554,7 +554,7 @@ public:
$(REF DateTimeException,std,datetime,date) if `fracSecs` is negative or if it's
greater than or equal to one second.
+/
this(DateTime dateTime, Duration fracSecs, immutable TimeZone tz = null) @safe
this(DateTime dateTime, Duration fracSecs, return scope immutable TimeZone tz = null) return scope @safe
{
enforce(fracSecs >= Duration.zero, new DateTimeException("A SysTime cannot have negative fractional seconds."));
enforce(fracSecs < seconds(1), new DateTimeException("Fractional seconds must be less than one second."));
@ -611,7 +611,7 @@ public:
given $(REF Date,std,datetime,date) is assumed to be in the
given time zone.
+/
this(Date date, immutable TimeZone tz = null) @safe nothrow
this(Date date, return scope immutable TimeZone tz = null) return scope @safe nothrow
{
_timezone = tz is null ? LocalTime() : tz;
@ -664,7 +664,7 @@ public:
$(LREF SysTime). If null,
$(REF LocalTime,std,datetime,timezone) will be used.
+/
this(long stdTime, immutable TimeZone tz = null) @safe pure nothrow
this(long stdTime, return scope immutable TimeZone tz = null) return scope @safe pure nothrow
{
_stdTime = stdTime;
_timezone = tz is null ? LocalTime() : tz;
@ -693,7 +693,7 @@ public:
Returns: The `this` of this `SysTime`.
+/
ref SysTime opAssign()(auto ref const(SysTime) rhs) return @safe pure nothrow scope
ref SysTime opAssign()(auto ref const(SysTime) rhs) return scope @safe pure nothrow
{
_stdTime = rhs._stdTime;
_timezone = rhs._timezone;
@ -710,6 +710,7 @@ public:
st = other;
assert(st == other);
version (none) // https://issues.dlang.org/show_bug.cgi?id=21175
static void testScope(scope ref SysTime left, const scope SysTime right) @safe
{
left = right;
@ -2184,7 +2185,7 @@ public:
hours - adjust the time to this $(LREF SysTime)'s time zone before
returning.
+/
@property immutable(TimeZone) timezone() @safe const pure nothrow scope
@property immutable(TimeZone) timezone() @safe const pure nothrow return scope
{
return _timezone;
}
@ -2238,7 +2239,7 @@ public:
/++
Returns whether DST is in effect for this $(LREF SysTime).
+/
@property bool dstInEffect() @safe const nothrow scope
@property bool dstInEffect() @safe const nothrow return scope
{
return _timezone.dstInEffect(_stdTime);
}
@ -2261,7 +2262,7 @@ public:
Returns what the offset from UTC is for this $(LREF SysTime).
It includes the DST offset in effect at that time (if any).
+/
@property Duration utcOffset() @safe const nothrow scope
@property Duration utcOffset() @safe const nothrow return scope
{
return _timezone.utcOffsetAt(_stdTime);
}
@ -9586,13 +9587,13 @@ private:
@property override bool hasDST() @safe const nothrow @nogc { return false; }
override bool dstInEffect(long stdTime) @safe const nothrow @nogc { return false; }
override bool dstInEffect(long stdTime) @safe const scope nothrow @nogc { return false; }
override long utcToTZ(long stdTime) @safe const nothrow @nogc { return 0; }
override long utcToTZ(long stdTime) @safe const scope nothrow @nogc { return 0; }
override long tzToUTC(long adjTime) @safe const nothrow @nogc { return 0; }
override long tzToUTC(long adjTime) @safe const scope nothrow @nogc { return 0; }
override Duration utcOffsetAt(long stdTime) @safe const nothrow @nogc { return Duration.zero; }
override Duration utcOffsetAt(long stdTime) @safe const scope nothrow @nogc { return Duration.zero; }
private:
@ -9628,7 +9629,7 @@ private:
return _timezoneStorage is null ? InitTimeZone() : _timezoneStorage;
}
pragma(inline, true) @property void _timezone(immutable TimeZone tz) @safe pure nothrow @nogc scope
pragma(inline, true) @property void _timezone(return scope immutable TimeZone tz) @safe pure nothrow @nogc scope
{
_timezoneStorage = tz;
}

View file

@ -100,7 +100,7 @@ public:
However, on Windows, it may be the unabbreviated name (e.g. Pacific
Standard Time). Regardless, it is not the same as name.
+/
@property string stdName() @safe const nothrow
@property string stdName() @safe const scope nothrow
{
return _stdName;
}
@ -113,7 +113,7 @@ public:
However, on Windows, it may be the unabbreviated name (e.g. Pacific
Daylight Time). Regardless, it is not the same as name.
+/
@property string dstName() @safe const nothrow
@property string dstName() @safe const scope nothrow
{
return _dstName;
}
@ -137,7 +137,7 @@ public:
stdTime = The UTC time that needs to be checked for DST in this time
zone.
+/
abstract bool dstInEffect(long stdTime) @safe const nothrow;
abstract bool dstInEffect(long stdTime) @safe const scope nothrow;
/++
@ -148,7 +148,7 @@ public:
stdTime = The UTC time that needs to be adjusted to this time zone's
time.
+/
abstract long utcToTZ(long stdTime) @safe const nothrow;
abstract long utcToTZ(long stdTime) @safe const scope nothrow;
/++
@ -159,7 +159,7 @@ public:
adjTime = The time in this time zone that needs to be adjusted to
UTC time.
+/
abstract long tzToUTC(long adjTime) @safe const nothrow;
abstract long tzToUTC(long adjTime) @safe const scope nothrow;
/++
@ -170,7 +170,7 @@ public:
stdTime = The UTC time for which to get the offset from UTC for this
time zone.
+/
Duration utcOffsetAt(long stdTime) @safe const nothrow
Duration utcOffsetAt(long stdTime) @safe const scope nothrow
{
return dur!"hnsecs"(utcToTZ(stdTime) - stdTime);
}
@ -580,7 +580,7 @@ public:
dynamically rather than it being fixed like it would be with most time
zones.
+/
@property override string stdName() @trusted const nothrow
@property override string stdName() @trusted const scope nothrow
{
version (Posix)
{
@ -665,7 +665,7 @@ public:
dynamically rather than it being fixed like it would be with most time
zones.
+/
@property override string dstName() @trusted const nothrow
@property override string dstName() @trusted const scope nothrow
{
version (Posix)
{
@ -809,7 +809,7 @@ public:
stdTime = The UTC time that needs to be checked for DST in this time
zone.
+/
override bool dstInEffect(long stdTime) @trusted const nothrow
override bool dstInEffect(long stdTime) @trusted const scope nothrow
{
import core.stdc.time : tm;
@ -863,7 +863,7 @@ public:
See_Also:
`TimeZone.utcToTZ`
+/
override long utcToTZ(long stdTime) @trusted const nothrow
override long utcToTZ(long stdTime) @trusted const scope nothrow
{
version (Solaris)
return stdTime + convert!("seconds", "hnsecs")(tm_gmtoff(stdTime));
@ -904,7 +904,7 @@ public:
adjTime = The time in this time zone that needs to be adjusted to
UTC time.
+/
override long tzToUTC(long adjTime) @trusted const nothrow
override long tzToUTC(long adjTime) @trusted const scope nothrow
{
version (Posix)
{
@ -1159,7 +1159,7 @@ public:
/++
Always returns false.
+/
override bool dstInEffect(long stdTime) @safe const nothrow
override bool dstInEffect(long stdTime) @safe const scope nothrow
{
return false;
}
@ -1175,7 +1175,7 @@ public:
See_Also:
`TimeZone.utcToTZ`
+/
override long utcToTZ(long stdTime) @safe const nothrow
override long utcToTZ(long stdTime) @safe const scope nothrow
{
return stdTime;
}
@ -1208,7 +1208,7 @@ public:
adjTime = The time in this time zone that needs to be adjusted to
UTC time.
+/
override long tzToUTC(long adjTime) @safe const nothrow
override long tzToUTC(long adjTime) @safe const scope nothrow
{
return adjTime;
}
@ -1238,7 +1238,7 @@ public:
stdTime = The UTC time for which to get the offset from UTC for this
time zone.
+/
override Duration utcOffsetAt(long stdTime) @safe const nothrow
override Duration utcOffsetAt(long stdTime) @safe const scope nothrow
{
return dur!"hnsecs"(0);
}
@ -1285,7 +1285,7 @@ public:
/++
Always returns false.
+/
override bool dstInEffect(long stdTime) @safe const nothrow
override bool dstInEffect(long stdTime) @safe const scope nothrow
{
return false;
}
@ -1299,7 +1299,7 @@ public:
stdTime = The UTC time that needs to be adjusted to this time zone's
time.
+/
override long utcToTZ(long stdTime) @safe const nothrow
override long utcToTZ(long stdTime) @safe const scope nothrow
{
return stdTime + _utcOffset.total!"hnsecs";
}
@ -1326,7 +1326,7 @@ public:
adjTime = The time in this time zone that needs to be adjusted to
UTC time.
+/
override long tzToUTC(long adjTime) @safe const nothrow
override long tzToUTC(long adjTime) @safe const scope nothrow
{
return adjTime - _utcOffset.total!"hnsecs";
}
@ -1352,7 +1352,7 @@ public:
stdTime = The UTC time for which to get the offset from UTC for this
time zone.
+/
override Duration utcOffsetAt(long stdTime) @safe const nothrow
override Duration utcOffsetAt(long stdTime) @safe const scope nothrow
{
return _utcOffset;
}
@ -1919,7 +1919,7 @@ public:
stdTime = The UTC time that needs to be checked for DST in this time
zone.
+/
override bool dstInEffect(long stdTime) @safe const nothrow
override bool dstInEffect(long stdTime) @safe const scope nothrow
{
assert(!_transitions.empty);
@ -1943,7 +1943,7 @@ public:
stdTime = The UTC time that needs to be adjusted to this time zone's
time.
+/
override long utcToTZ(long stdTime) @safe const nothrow
override long utcToTZ(long stdTime) @safe const scope nothrow
{
assert(!_transitions.empty);
@ -1968,7 +1968,7 @@ public:
adjTime = The time in this time zone that needs to be adjusted to
UTC time.
+/
override long tzToUTC(long adjTime) @safe const nothrow
override long tzToUTC(long adjTime) @safe const scope nothrow
{
assert(!_transitions.empty, "UTC offset's not available");
@ -2691,7 +2691,7 @@ private:
}
int calculateLeapSeconds(long stdTime) @safe const pure nothrow
int calculateLeapSeconds(long stdTime) @safe const scope pure nothrow
{
if (_leapSeconds.empty)
return 0;
@ -2864,7 +2864,7 @@ version (StdDdoc)
current dates but will still return true for `hasDST` because the
time zone did at some point have DST.
+/
@property override bool hasDST() @safe const nothrow;
@property override bool hasDST() @safe const scope nothrow;
/++
@ -2876,7 +2876,7 @@ version (StdDdoc)
stdTime = The UTC time that needs to be checked for DST in this
time zone.
+/
override bool dstInEffect(long stdTime) @safe const nothrow;
override bool dstInEffect(long stdTime) @safe const scope nothrow;
/++
@ -2888,7 +2888,7 @@ version (StdDdoc)
stdTime = The UTC time that needs to be adjusted to this time
zone's time.
+/
override long utcToTZ(long stdTime) @safe const nothrow;
override long utcToTZ(long stdTime) @safe const scope nothrow;
/++
@ -2900,7 +2900,7 @@ version (StdDdoc)
adjTime = The time in this time zone that needs to be adjusted
to UTC time.
+/
override long tzToUTC(long adjTime) @safe const nothrow;
override long tzToUTC(long adjTime) @safe const scope nothrow;
/++
@ -2945,9 +2945,9 @@ version (StdDdoc)
else
alias TIME_ZONE_INFORMATION = void*;
static bool _dstInEffect(const TIME_ZONE_INFORMATION* tzInfo, long stdTime) nothrow;
static long _utcToTZ(const TIME_ZONE_INFORMATION* tzInfo, long stdTime, bool hasDST) nothrow;
static long _tzToUTC(const TIME_ZONE_INFORMATION* tzInfo, long adjTime, bool hasDST) nothrow;
static bool _dstInEffect(const scope TIME_ZONE_INFORMATION* tzInfo, long stdTime) nothrow;
static long _utcToTZ(const scope TIME_ZONE_INFORMATION* tzInfo, long stdTime, bool hasDST) nothrow;
static long _tzToUTC(const scope TIME_ZONE_INFORMATION* tzInfo, long adjTime, bool hasDST) nothrow;
this() immutable pure
{
@ -2967,25 +2967,25 @@ else version (Windows)
public:
@property override bool hasDST() @safe const nothrow
@property override bool hasDST() @safe const scope nothrow
{
return _tzInfo.DaylightDate.wMonth != 0;
}
override bool dstInEffect(long stdTime) @safe const nothrow
override bool dstInEffect(long stdTime) @safe const scope nothrow
{
return _dstInEffect(&_tzInfo, stdTime);
}
override long utcToTZ(long stdTime) @safe const nothrow
override long utcToTZ(long stdTime) @safe const scope nothrow
{
return _utcToTZ(&_tzInfo, stdTime, hasDST);
}
override long tzToUTC(long adjTime) @safe const nothrow
override long tzToUTC(long adjTime) @safe const scope nothrow
{
return _tzToUTC(&_tzInfo, adjTime, hasDST);
}
@ -3071,7 +3071,7 @@ else version (Windows)
private:
static bool _dstInEffect(const TIME_ZONE_INFORMATION* tzInfo, long stdTime) @trusted nothrow
static bool _dstInEffect(const scope TIME_ZONE_INFORMATION* tzInfo, long stdTime) @trusted nothrow
{
try
{
@ -3155,7 +3155,7 @@ else version (Windows)
}
static long _utcToTZ(const TIME_ZONE_INFORMATION* tzInfo, long stdTime, bool hasDST) @safe nothrow
static long _utcToTZ(const scope TIME_ZONE_INFORMATION* tzInfo, long stdTime, bool hasDST) @safe nothrow
{
if (hasDST && WindowsTimeZone._dstInEffect(tzInfo, stdTime))
return stdTime - convert!("minutes", "hnsecs")(tzInfo.Bias + tzInfo.DaylightBias);
@ -3164,7 +3164,7 @@ else version (Windows)
}
static long _tzToUTC(const TIME_ZONE_INFORMATION* tzInfo, long adjTime, bool hasDST) @trusted nothrow
static long _tzToUTC(const scope TIME_ZONE_INFORMATION* tzInfo, long adjTime, bool hasDST) @trusted nothrow
{
if (hasDST)
{

View file

@ -3859,17 +3859,17 @@ else version (Windows)
return _size;
}
@property SysTime timeCreated() const pure nothrow scope
@property SysTime timeCreated() const pure nothrow return scope
{
return cast(SysTime)_timeCreated;
}
@property SysTime timeLastAccessed() const pure nothrow scope
@property SysTime timeLastAccessed() const pure nothrow return scope
{
return cast(SysTime)_timeLastAccessed;
}
@property SysTime timeLastModified() const pure nothrow scope
@property SysTime timeLastModified() const pure nothrow return scope
{
return cast(SysTime)_timeLastModified;
}

View file

@ -2239,7 +2239,7 @@ if (is(T == class) || is(T == interface) || isAssociativeArray!T)
U stripped;
}
void opAssign(T another) pure nothrow @nogc
void opAssign(return scope T another) pure nothrow @nogc
{
// If `T` defines `opCast` we must infer the safety
static if (hasMember!(T, "opCast"))
@ -2271,7 +2271,7 @@ if (is(T == class) || is(T == interface) || isAssociativeArray!T)
opAssign(initializer);
}
@property inout(T) get() @trusted pure nothrow @nogc inout
@property inout(T) get() @trusted pure nothrow @nogc return scope inout
{
return original;
}