[Bug 224] [ICE] std/datetime.o: in reload_combine_note_use, at postreload.c:1535
via D.gnu
d.gnu at puremagic.com
Wed May 18 12:05:21 PDT 2016
http://bugzilla.gdcproject.org/show_bug.cgi?id=224
--- Comment #3 from Iain Buclaw <ibuclaw at gdcproject.org> ---
This is the "reduced" test.
---
import core.time;
import core.sys.posix.sys.time;
struct Clock
{
static currTime(immutable TimeZone = LocalTime())
{
return SysTime(currStdTime);
}
static currStdTime()
{
return convert!("seconds", "hnsecs")(0);
}
}
struct SysTime
{
import std.typecons;
this(TimeZone) { }
this(DateTime) { }
this(Date date, immutable TimeZone tz = null)
{
_timezone = tz is null ? LocalTime() : tz;
try
{
immutable adjustedTime = (date - Date()).total!"hnsecs";
immutable standardTime = _timezone.tzToUTC(adjustedTime);
this(standardTime);
}
catch
assert(0);
}
this(long stdTime, immutable TimeZone tz = null)
{
_stdTime = stdTime;
_timezone = tz is null ? LocalTime() : tz;
}
@property stdTime()
{
return _stdTime;
}
@property dayOfGregorianCal()
{
adjTime;
long hnsecs;
days = hnsecs;
return 0;
}
Date opCast()
{
return Date(dayOfGregorianCal);
}
DateTime opCast()() if(is(Unqual))
{
}
string toISOString()
{
import std.format;
try
{
auto dateTime = DateTime();
return format("%s",
dateTime.toISOString);
}
catch
assert(0);
}
@property adjTime()
{
_timezone.utcToTZ(_stdTime);
}
long _stdTime;
Rebindable!(immutable TimeZone) _timezone;
}
struct Date
{
short _year;
ubyte _day;
this(int, int) { }
this(int) { }
@property year() { }
@property month() { }
@property day() { }
@property day()
{
return _day;
}
Duration opBinary(string op)(Date)
{
return dur!"days"(dayOfGregorianCal);
}
@property dayOfGregorianCal()
{
return 0;
}
}
struct TimeOfDay
{
@property second() { }
}
struct DateTime
{
this(Date) { }
this(int) { }
@property date() { }
@property timeOfDay() { }
string toISOString() { return ""; }
}
class TimeZone
{
long utcToTZ(long) const;
long tzToUTC(long) const;
this() immutable { }
Duration utcOffsetAt(long stdTime)
{
return dur!"hnsecs"(stdTime);
}
}
class LocalTime : TimeZone
{
static immutable(LocalTime) opCall()
{
return (cast()&singleton)();
}
bool hasDST()
{
try
{
cast(Date)Clock.currTime;
auto janOffset = SysTime(Date()).stdTime - SysTime(Date()).stdTime;
auto julyOffset = SysTime(Date()).stdTime -
SysTime(Date()).stdTime;
return janOffset != julyOffset;
}
catch
assert(0);
}
this() immutable { }
static localTime = new immutable(LocalTime);
immutable(LocalTime) singleton()
{
synchronized
return localTime;
}
}
time_t stdTimeToUnixTime()
{
return cast(time_t)convert!("hnsecs", "seconds")(0);
}
SysTime DosFileTimeToSysTime()
{
try
return SysTime(DateTime());
catch
assert(0);
}
--
You are receiving this mail because:
You are watching all bug changes.
More information about the D.gnu
mailing list