code
stringlengths 3
10M
| language
stringclasses 31
values |
|---|---|
void main() {
problem();
}
void problem() {
auto N = scan!long;
auto P = scan!long(N);
void solve() {
auto ng = new bool[200_001];
long cur;
foreach(p; P) {
ng[p] = true;
while(ng[cur]) cur++;
writeln(cur);
}
}
solve();
}
// ----------------------------------------------
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) { if (!m) return [[]]; if (s.empty) return []; return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(long n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");
// -----------------------------------------------
|
D
|
const int SPL_Cost_Zap = 15;
const int SPL_Damage_Zap = 30;
instance Spell_Zap(C_Spell_Proto)
{
time_per_mana = 0;
damage_per_level = SPL_Damage_Zap;
damagetype = DAM_MAGIC;
};
func int Spell_Logic_Zap(var int manaInvested)
{
return Spell_Logic_Proto(SPL_Cost_Zap);
};
func void Spell_Cast_Zap(var int spellLevel)
{
Spell_Cast_Proto(SPL_Cost_Zap);
self.aivar[AIV_SelectSpell] += 1;
};
|
D
|
import pgship.model;
import std.stdio;
import std.string;
public const string appver = "0.1.0";
int main(string[] args)
{
writeln("PGship Database Migration Tool");
writeln("Version: ", appver);
writeln();
if (args.length < 4) {
displayUsage();
return 0;
}
auto deploymentFile = args[1];
auto serverUrl = args[2];
auto database = args[3];
bool requireSsl = false;
string user = null;
string password = null;
if (args.length > 4) {
for(int i = 4; i < args.length; i++) {
if (args[i].toLower() == "-requireSSL".toLower()) requireSsl = true;
if (args[i].toLower() == "-user".toLower()) {
user = args[i+1];
i++;
}
if (args[i].toLower() == "-password".toLower()) {
password = args[i+1];
i++;
}
}
}
return 0;
}
public void displayUsage()
{
writeln("Usage: pgship <path to deployment file> <server url> <database> [options]");
writeln();
writeln("Options:");
writeln(" -requireSSL Require SSL to connect to the server.");
writeln(" -user Username to use for the connection.");
writeln(" -password Password for the supplied username.");
}
|
D
|
module kgl3n.linearcomponent;
import kgl3n.vector;
struct Line
{
vec3 p, d;
}
struct Ray
{
vec3 p, d;
}
struct LineSegment
{
vec3 p, d;
float t;
}
|
D
|
/**
* Windows is a registered trademark of Microsoft Corporation in the United
* States and other countries.
*
* Copyright: Copyright Digital Mars 2000 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
* Authors: Walter Bright, Sean Kelly
*/
/* Copyright Digital Mars 2000 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.windows.windows;
extern (Windows) nothrow:
alias uint ULONG;
alias ULONG *PULONG;
alias ushort USHORT;
alias USHORT *PUSHORT;
alias ubyte UCHAR;
alias UCHAR *PUCHAR;
alias char *PSZ;
alias void VOID;
alias char CHAR;
alias short SHORT;
alias int LONG;
alias CHAR* LPCH, LPSTR, PCH, PSTR;
alias const(CHAR)* LPCCH, LPCSTR, PCCH, PCSTR;
alias wchar WCHAR;
alias WCHAR* LPWCH, LPWSTR, PWCH, PWSTR;
alias const(WCHAR)* LPCWCH, LPCWSTR, PCWCH, PCWSTR;
alias CHAR* LPTCH, LPTSTR, PTCH, PTSTR;
alias const(CHAR)* LPCTCH, LPCTSTR, PCTCH, PCTSTR;
alias uint DWORD;
alias ulong DWORD64;
alias int BOOL;
alias ubyte BYTE;
alias ushort WORD;
alias float FLOAT;
alias FLOAT* PFLOAT;
alias BOOL* LPBOOL, PBOOL;
alias BYTE* LPBYTE, PBYTE;
alias int* LPINT, PINT;
alias WORD* LPWORD, PWORD;
alias int* LPLONG;
alias DWORD* LPDWORD, PDWORD;
alias void* LPVOID;
alias const(void)* LPCVOID;
alias int INT;
alias uint UINT;
alias uint* PUINT;
alias size_t SIZE_T;
// ULONG_PTR must be able to store a pointer as an integral type
version (Win64)
{
alias long INT_PTR;
alias ulong UINT_PTR;
alias long LONG_PTR;
alias ulong ULONG_PTR;
alias long * PINT_PTR;
alias ulong * PUINT_PTR;
alias long * PLONG_PTR;
alias ulong * PULONG_PTR;
}
else // Win32
{
alias int INT_PTR;
alias uint UINT_PTR;
alias int LONG_PTR;
alias uint ULONG_PTR;
alias int * PINT_PTR;
alias uint * PUINT_PTR;
alias int * PLONG_PTR;
alias uint * PULONG_PTR;
}
alias ULONG_PTR DWORD_PTR;
alias void *HANDLE;
alias void *PVOID;
alias HANDLE HGLOBAL;
alias HANDLE HLOCAL;
alias LONG HRESULT;
alias LONG SCODE;
alias HANDLE HINSTANCE;
alias HINSTANCE HMODULE;
alias HANDLE HWND;
alias HANDLE HGDIOBJ;
alias HANDLE HACCEL;
alias HANDLE HBITMAP;
alias HANDLE HBRUSH;
alias HANDLE HCOLORSPACE;
alias HANDLE HDC;
alias HANDLE HGLRC;
alias HANDLE HDESK;
alias HANDLE HENHMETAFILE;
alias HANDLE HFONT;
alias HANDLE HICON;
alias HANDLE HMENU;
alias HANDLE HMETAFILE;
alias HANDLE HPALETTE;
alias HANDLE HPEN;
alias HANDLE HRGN;
alias HANDLE HRSRC;
alias HANDLE HSTR;
alias HANDLE HTASK;
alias HANDLE HWINSTA;
alias HANDLE HKL;
alias HICON HCURSOR;
alias HANDLE HKEY;
alias HKEY *PHKEY;
alias DWORD ACCESS_MASK;
alias ACCESS_MASK *PACCESS_MASK;
alias ACCESS_MASK REGSAM;
alias int function() FARPROC;
alias UINT WPARAM;
alias LONG LPARAM;
alias LONG LRESULT;
alias DWORD COLORREF;
alias DWORD *LPCOLORREF;
alias WORD ATOM;
version (0)
{ // Properly prototyped versions
alias BOOL function(HWND, UINT, WPARAM, LPARAM) DLGPROC;
alias VOID function(HWND, UINT, UINT_PTR, DWORD) TIMERPROC;
alias BOOL function(HDC, LPARAM, int) GRAYSTRINGPROC;
alias BOOL function(HWND, LPARAM) WNDENUMPROC;
alias LRESULT function(int code, WPARAM wParam, LPARAM lParam) HOOKPROC;
alias VOID function(HWND, UINT, DWORD, LRESULT) SENDASYNCPROC;
alias BOOL function(HWND, LPCSTR, HANDLE) PROPENUMPROCA;
alias BOOL function(HWND, LPCWSTR, HANDLE) PROPENUMPROCW;
alias BOOL function(HWND, LPSTR, HANDLE, DWORD) PROPENUMPROCEXA;
alias BOOL function(HWND, LPWSTR, HANDLE, DWORD) PROPENUMPROCEXW;
alias int function(LPSTR lpch, int ichCurrent, int cch, int code)
EDITWORDBREAKPROCA;
alias int function(LPWSTR lpch, int ichCurrent, int cch, int code)
EDITWORDBREAKPROCW;
alias BOOL function(HDC hdc, LPARAM lData, WPARAM wData, int cx, int cy)
DRAWSTATEPROC;
}
else
{
alias FARPROC DLGPROC;
alias FARPROC TIMERPROC;
alias FARPROC GRAYSTRINGPROC;
alias FARPROC WNDENUMPROC;
alias FARPROC HOOKPROC;
alias FARPROC SENDASYNCPROC;
alias FARPROC EDITWORDBREAKPROCA;
alias FARPROC EDITWORDBREAKPROCW;
alias FARPROC PROPENUMPROCA;
alias FARPROC PROPENUMPROCW;
alias FARPROC PROPENUMPROCEXA;
alias FARPROC PROPENUMPROCEXW;
alias FARPROC DRAWSTATEPROC;
}
extern (D) pure
{
WORD HIWORD(int l) { return cast(WORD)((l >> 16) & 0xFFFF); }
WORD LOWORD(int l) { return cast(WORD)l; }
bool FAILED(int status) { return status < 0; }
bool SUCCEEDED(int Status) { return Status >= 0; }
}
enum : int
{
FALSE = 0,
TRUE = 1,
}
enum : uint
{
MAX_PATH = 260,
HINSTANCE_ERROR = 32,
}
enum
{
ERROR_SUCCESS = 0,
ERROR_INVALID_FUNCTION = 1,
ERROR_FILE_NOT_FOUND = 2,
ERROR_PATH_NOT_FOUND = 3,
ERROR_TOO_MANY_OPEN_FILES = 4,
ERROR_ACCESS_DENIED = 5,
ERROR_INVALID_HANDLE = 6,
ERROR_NO_MORE_FILES = 18,
ERROR_MORE_DATA = 234,
ERROR_NO_MORE_ITEMS = 259,
}
enum
{
DLL_PROCESS_ATTACH = 1,
DLL_THREAD_ATTACH = 2,
DLL_THREAD_DETACH = 3,
DLL_PROCESS_DETACH = 0,
}
enum
{
FILE_BEGIN = 0,
FILE_CURRENT = 1,
FILE_END = 2,
}
enum : uint
{
DELETE = 0x00010000,
READ_CONTROL = 0x00020000,
WRITE_DAC = 0x00040000,
WRITE_OWNER = 0x00080000,
SYNCHRONIZE = 0x00100000,
STANDARD_RIGHTS_REQUIRED = 0x000F0000,
STANDARD_RIGHTS_READ = READ_CONTROL,
STANDARD_RIGHTS_WRITE = READ_CONTROL,
STANDARD_RIGHTS_EXECUTE = READ_CONTROL,
STANDARD_RIGHTS_ALL = 0x001F0000,
SPECIFIC_RIGHTS_ALL = 0x0000FFFF,
ACCESS_SYSTEM_SECURITY = 0x01000000,
MAXIMUM_ALLOWED = 0x02000000,
GENERIC_READ = 0x80000000,
GENERIC_WRITE = 0x40000000,
GENERIC_EXECUTE = 0x20000000,
GENERIC_ALL = 0x10000000,
}
enum
{
FILE_SHARE_READ = 0x00000001,
FILE_SHARE_WRITE = 0x00000002,
FILE_SHARE_DELETE = 0x00000004,
FILE_ATTRIBUTE_READONLY = 0x00000001,
FILE_ATTRIBUTE_HIDDEN = 0x00000002,
FILE_ATTRIBUTE_SYSTEM = 0x00000004,
FILE_ATTRIBUTE_DIRECTORY = 0x00000010,
FILE_ATTRIBUTE_ARCHIVE = 0x00000020,
FILE_ATTRIBUTE_NORMAL = 0x00000080,
FILE_ATTRIBUTE_TEMPORARY = 0x00000100,
FILE_ATTRIBUTE_COMPRESSED = 0x00000800,
FILE_ATTRIBUTE_OFFLINE = 0x00001000,
FILE_NOTIFY_CHANGE_FILE_NAME = 0x00000001,
FILE_NOTIFY_CHANGE_DIR_NAME = 0x00000002,
FILE_NOTIFY_CHANGE_ATTRIBUTES = 0x00000004,
FILE_NOTIFY_CHANGE_SIZE = 0x00000008,
FILE_NOTIFY_CHANGE_LAST_WRITE = 0x00000010,
FILE_NOTIFY_CHANGE_LAST_ACCESS = 0x00000020,
FILE_NOTIFY_CHANGE_CREATION = 0x00000040,
FILE_NOTIFY_CHANGE_SECURITY = 0x00000100,
FILE_ACTION_ADDED = 0x00000001,
FILE_ACTION_REMOVED = 0x00000002,
FILE_ACTION_MODIFIED = 0x00000003,
FILE_ACTION_RENAMED_OLD_NAME = 0x00000004,
FILE_ACTION_RENAMED_NEW_NAME = 0x00000005,
FILE_CASE_SENSITIVE_SEARCH = 0x00000001,
FILE_CASE_PRESERVED_NAMES = 0x00000002,
FILE_UNICODE_ON_DISK = 0x00000004,
FILE_PERSISTENT_ACLS = 0x00000008,
FILE_FILE_COMPRESSION = 0x00000010,
FILE_VOLUME_IS_COMPRESSED = 0x00008000,
}
enum : DWORD
{
MAILSLOT_NO_MESSAGE = cast(DWORD)-1,
MAILSLOT_WAIT_FOREVER = cast(DWORD)-1,
}
enum : uint
{
FILE_FLAG_WRITE_THROUGH = 0x80000000,
FILE_FLAG_OVERLAPPED = 0x40000000,
FILE_FLAG_NO_BUFFERING = 0x20000000,
FILE_FLAG_RANDOM_ACCESS = 0x10000000,
FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000,
FILE_FLAG_DELETE_ON_CLOSE = 0x04000000,
FILE_FLAG_BACKUP_SEMANTICS = 0x02000000,
FILE_FLAG_POSIX_SEMANTICS = 0x01000000,
}
enum
{
CREATE_NEW = 1,
CREATE_ALWAYS = 2,
OPEN_EXISTING = 3,
OPEN_ALWAYS = 4,
TRUNCATE_EXISTING = 5,
}
enum
{
HANDLE INVALID_HANDLE_VALUE = cast(HANDLE)-1,
DWORD INVALID_SET_FILE_POINTER = cast(DWORD)-1,
DWORD INVALID_FILE_SIZE = cast(DWORD)0xFFFFFFFF,
}
union LARGE_INTEGER
{
struct
{
uint LowPart;
int HighPart;
}
long QuadPart;
}
alias LARGE_INTEGER* PLARGE_INTEGER;
union ULARGE_INTEGER
{
struct
{
uint LowPart;
uint HighPart;
}
ulong QuadPart;
}
alias ULARGE_INTEGER* PULARGE_INTEGER;
struct OVERLAPPED {
ULONG_PTR Internal;
ULONG_PTR InternalHigh;
union {
struct {
DWORD Offset;
DWORD OffsetHigh;
}
void* Pointer;
}
HANDLE hEvent;
}
struct SECURITY_ATTRIBUTES {
DWORD nLength;
void *lpSecurityDescriptor;
BOOL bInheritHandle;
}
alias SECURITY_ATTRIBUTES* PSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES;
struct FILETIME {
DWORD dwLowDateTime;
DWORD dwHighDateTime;
}
alias FILETIME* PFILETIME, LPFILETIME;
struct WIN32_FIND_DATA {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD dwReserved0;
DWORD dwReserved1;
char cFileName[MAX_PATH];
char cAlternateFileName[ 14 ];
}
struct WIN32_FIND_DATAW {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD dwReserved0;
DWORD dwReserved1;
wchar cFileName[ 260 ];
wchar cAlternateFileName[ 14 ];
}
// Critical Section
struct _LIST_ENTRY
{
_LIST_ENTRY *Flink;
_LIST_ENTRY *Blink;
}
alias _LIST_ENTRY LIST_ENTRY;
struct _RTL_CRITICAL_SECTION_DEBUG
{
WORD Type;
WORD CreatorBackTraceIndex;
_RTL_CRITICAL_SECTION *CriticalSection;
LIST_ENTRY ProcessLocksList;
DWORD EntryCount;
DWORD ContentionCount;
DWORD Spare[ 2 ];
}
alias _RTL_CRITICAL_SECTION_DEBUG RTL_CRITICAL_SECTION_DEBUG;
struct _RTL_CRITICAL_SECTION
{
RTL_CRITICAL_SECTION_DEBUG * DebugInfo;
//
// The following three fields control entering and exiting the critical
// section for the resource
//
LONG LockCount;
LONG RecursionCount;
HANDLE OwningThread; // from the thread's ClientId->UniqueThread
HANDLE LockSemaphore;
ULONG_PTR SpinCount; // force size on 64-bit systems when packed
}
alias _RTL_CRITICAL_SECTION CRITICAL_SECTION;
enum
{
STD_INPUT_HANDLE = cast(DWORD)-10,
STD_OUTPUT_HANDLE = cast(DWORD)-11,
STD_ERROR_HANDLE = cast(DWORD)-12,
}
enum GET_FILEEX_INFO_LEVELS
{
GetFileExInfoStandard,
GetFileExMaxInfoLevel
}
struct WIN32_FILE_ATTRIBUTE_DATA
{
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
}
alias WIN32_FILE_ATTRIBUTE_DATA* LPWIN32_FILE_ATTRIBUTE_DATA;
export
{
BOOL SetCurrentDirectoryA(LPCSTR lpPathName);
BOOL SetCurrentDirectoryW(LPCWSTR lpPathName);
UINT GetSystemDirectoryA(LPSTR lpBuffer, UINT uSize);
UINT GetSystemDirectoryW(LPWSTR lpBuffer, UINT uSize);
DWORD GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer);
DWORD GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer);
BOOL CreateDirectoryA(LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
BOOL CreateDirectoryW(LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
BOOL CreateDirectoryExA(LPCSTR lpTemplateDirectory, LPCSTR lpNewDirectory, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
BOOL CreateDirectoryExW(LPCWSTR lpTemplateDirectory, LPCWSTR lpNewDirectory, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
BOOL RemoveDirectoryA(LPCSTR lpPathName);
BOOL RemoveDirectoryW(LPCWSTR lpPathName);
BOOL CloseHandle(HANDLE hObject);
HANDLE CreateFileA(in char* lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
SECURITY_ATTRIBUTES *lpSecurityAttributes, DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
SECURITY_ATTRIBUTES *lpSecurityAttributes, DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
BOOL DeleteFileA(in char *lpFileName);
BOOL DeleteFileW(LPCWSTR lpFileName);
BOOL FindClose(HANDLE hFindFile);
HANDLE FindFirstFileA(in char *lpFileName, WIN32_FIND_DATA* lpFindFileData);
HANDLE FindFirstFileW(in LPCWSTR lpFileName, WIN32_FIND_DATAW* lpFindFileData);
BOOL FindNextFileA(HANDLE hFindFile, WIN32_FIND_DATA* lpFindFileData);
BOOL FindNextFileW(HANDLE hFindFile, WIN32_FIND_DATAW* lpFindFileData);
BOOL GetExitCodeThread(HANDLE hThread, DWORD *lpExitCode);
DWORD GetLastError();
DWORD GetFileAttributesA(in char *lpFileName);
DWORD GetFileAttributesW(in wchar *lpFileName);
BOOL GetFileAttributesExA(LPCSTR, GET_FILEEX_INFO_LEVELS, PVOID);
BOOL GetFileAttributesExW(LPCWSTR, GET_FILEEX_INFO_LEVELS, PVOID);
DWORD GetFileSize(HANDLE hFile, DWORD *lpFileSizeHigh);
BOOL CopyFileA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName, BOOL bFailIfExists);
BOOL CopyFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, BOOL bFailIfExists);
BOOL MoveFileA(in char *from, in char *to);
BOOL MoveFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName);
BOOL ReadFile(HANDLE hFile, void *lpBuffer, DWORD nNumberOfBytesToRead,
DWORD *lpNumberOfBytesRead, OVERLAPPED *lpOverlapped);
DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove,
LONG *lpDistanceToMoveHigh, DWORD dwMoveMethod);
BOOL WriteFile(HANDLE hFile, in void *lpBuffer, DWORD nNumberOfBytesToWrite,
DWORD *lpNumberOfBytesWritten, OVERLAPPED *lpOverlapped);
DWORD GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize);
DWORD GetModuleFileNameW(HMODULE hModule, LPWSTR lpFilename, DWORD nSize);
HANDLE GetStdHandle(DWORD nStdHandle);
BOOL SetStdHandle(DWORD nStdHandle, HANDLE hHandle);
}
struct MEMORYSTATUS {
DWORD dwLength;
DWORD dwMemoryLoad;
DWORD dwTotalPhys;
DWORD dwAvailPhys;
DWORD dwTotalPageFile;
DWORD dwAvailPageFile;
DWORD dwTotalVirtual;
DWORD dwAvailVirtual;
};
alias MEMORYSTATUS *LPMEMORYSTATUS;
HMODULE LoadLibraryA(LPCSTR lpLibFileName);
HMODULE LoadLibraryW(LPCWSTR lpLibFileName);
FARPROC GetProcAddress(HMODULE hModule, LPCSTR lpProcName);
DWORD GetVersion();
BOOL FreeLibrary(HMODULE hLibModule);
void FreeLibraryAndExitThread(HMODULE hLibModule, DWORD dwExitCode);
BOOL DisableThreadLibraryCalls(HMODULE hLibModule);
//
// Registry Specific Access Rights.
//
enum
{
KEY_QUERY_VALUE = 0x0001,
KEY_SET_VALUE = 0x0002,
KEY_CREATE_SUB_KEY = 0x0004,
KEY_ENUMERATE_SUB_KEYS = 0x0008,
KEY_NOTIFY = 0x0010,
KEY_CREATE_LINK = 0x0020,
KEY_READ = cast(int)((STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & ~SYNCHRONIZE),
KEY_WRITE = cast(int)((STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & ~SYNCHRONIZE),
KEY_EXECUTE = cast(int)(KEY_READ & ~SYNCHRONIZE),
KEY_ALL_ACCESS = cast(int)((STANDARD_RIGHTS_ALL | KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_CREATE_LINK) & ~SYNCHRONIZE),
}
//
// Key creation/open disposition
//
enum : int
{
REG_CREATED_NEW_KEY = 0x00000001, // New Registry Key created
REG_OPENED_EXISTING_KEY = 0x00000002, // Existing Key opened
}
//
//
// Predefined Value Types.
//
enum
{
REG_NONE = 0, // No value type
REG_SZ = 1, // Unicode nul terminated string
REG_EXPAND_SZ = 2, // Unicode nul terminated string
// (with environment variable references)
REG_BINARY = 3, // Free form binary
REG_DWORD = 4, // 32-bit number
REG_DWORD_LITTLE_ENDIAN = 4, // 32-bit number (same as REG_DWORD)
REG_DWORD_BIG_ENDIAN = 5, // 32-bit number
REG_LINK = 6, // Symbolic Link (unicode)
REG_MULTI_SZ = 7, // Multiple Unicode strings
REG_RESOURCE_LIST = 8, // Resource list in the resource map
REG_FULL_RESOURCE_DESCRIPTOR = 9, // Resource list in the hardware description
REG_RESOURCE_REQUIREMENTS_LIST = 10,
REG_QWORD = 11,
REG_QWORD_LITTLE_ENDIAN = 11,
}
/*
* MessageBox() Flags
*/
enum
{
MB_OK = 0x00000000,
MB_OKCANCEL = 0x00000001,
MB_ABORTRETRYIGNORE = 0x00000002,
MB_YESNOCANCEL = 0x00000003,
MB_YESNO = 0x00000004,
MB_RETRYCANCEL = 0x00000005,
MB_ICONHAND = 0x00000010,
MB_ICONQUESTION = 0x00000020,
MB_ICONEXCLAMATION = 0x00000030,
MB_ICONASTERISK = 0x00000040,
MB_USERICON = 0x00000080,
MB_ICONWARNING = MB_ICONEXCLAMATION,
MB_ICONERROR = MB_ICONHAND,
MB_ICONINFORMATION = MB_ICONASTERISK,
MB_ICONSTOP = MB_ICONHAND,
MB_DEFBUTTON1 = 0x00000000,
MB_DEFBUTTON2 = 0x00000100,
MB_DEFBUTTON3 = 0x00000200,
MB_DEFBUTTON4 = 0x00000300,
MB_APPLMODAL = 0x00000000,
MB_SYSTEMMODAL = 0x00001000,
MB_TASKMODAL = 0x00002000,
MB_HELP = 0x00004000, // Help Button
MB_NOFOCUS = 0x00008000,
MB_SETFOREGROUND = 0x00010000,
MB_DEFAULT_DESKTOP_ONLY = 0x00020000,
MB_TOPMOST = 0x00040000,
MB_RIGHT = 0x00080000,
MB_RTLREADING = 0x00100000,
MB_TYPEMASK = 0x0000000F,
MB_ICONMASK = 0x000000F0,
MB_DEFMASK = 0x00000F00,
MB_MODEMASK = 0x00003000,
MB_MISCMASK = 0x0000C000,
}
int MessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);
int MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType);
int MessageBoxExA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType, WORD wLanguageId);
int MessageBoxExW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType, WORD wLanguageId);
enum : HKEY
{
HKEY_CLASSES_ROOT = cast(HKEY)(0x80000000),
HKEY_CURRENT_USER = cast(HKEY)(0x80000001),
HKEY_LOCAL_MACHINE = cast(HKEY)(0x80000002),
HKEY_USERS = cast(HKEY)(0x80000003),
HKEY_PERFORMANCE_DATA = cast(HKEY)(0x80000004),
HKEY_PERFORMANCE_TEXT = cast(HKEY)(0x80000050),
HKEY_PERFORMANCE_NLSTEXT = cast(HKEY)(0x80000060),
HKEY_CURRENT_CONFIG = cast(HKEY)(0x80000005),
HKEY_DYN_DATA = cast(HKEY)(0x80000006),
}
enum
{
REG_OPTION_RESERVED = (0x00000000), // Parameter is reserved
REG_OPTION_NON_VOLATILE = (0x00000000), // Key is preserved
// when system is rebooted
REG_OPTION_VOLATILE = (0x00000001), // Key is not preserved
// when system is rebooted
REG_OPTION_CREATE_LINK = (0x00000002), // Created key is a
// symbolic link
REG_OPTION_BACKUP_RESTORE = (0x00000004), // open for backup or restore
// special access rules
// privilege required
REG_OPTION_OPEN_LINK = (0x00000008), // Open symbolic link
REG_LEGAL_OPTION = (REG_OPTION_RESERVED | REG_OPTION_NON_VOLATILE | REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK | REG_OPTION_BACKUP_RESTORE | REG_OPTION_OPEN_LINK),
}
export LONG RegDeleteKeyA(in HKEY hKey, LPCSTR lpSubKey);
export LONG RegDeleteKeyW(in HKEY hKey, LPCWSTR lpSubKey);
export LONG RegDeleteValueA(in HKEY hKey, LPCSTR lpValueName);
export LONG RegDeleteValueW(in HKEY hKey, LPCWSTR lpValueName);
export LONG RegEnumKeyExA(in HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcbName, LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcbClass, FILETIME* lpftLastWriteTime);
export LONG RegEnumKeyExW(in HKEY hKey, DWORD dwIndex, LPWSTR lpName, LPDWORD lpcbName, LPDWORD lpReserved, LPWSTR lpClass, LPDWORD lpcbClass, FILETIME* lpftLastWriteTime);
export LONG RegEnumValueA(in HKEY hKey, DWORD dwIndex, LPSTR lpValueName, LPDWORD lpcbValueName, LPDWORD lpReserved,
LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData);
export LONG RegEnumValueW(in HKEY hKey, DWORD dwIndex, LPWSTR lpValueName, LPDWORD lpcbValueName, LPDWORD lpReserved,
LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData);
export LONG RegCloseKey(in HKEY hKey);
export LONG RegFlushKey(in HKEY hKey);
export LONG RegOpenKeyA(in HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult);
export LONG RegOpenKeyW(in HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult);
export LONG RegOpenKeyExA(in HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
export LONG RegOpenKeyExW(in HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
export LONG RegQueryInfoKeyA(in HKEY hKey, LPSTR lpClass, LPDWORD lpcbClass,
LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcbMaxSubKeyLen, LPDWORD lpcbMaxClassLen,
LPDWORD lpcValues, LPDWORD lpcbMaxValueNameLen, LPDWORD lpcbMaxValueLen, LPDWORD lpcbSecurityDescriptor,
PFILETIME lpftLastWriteTime);
export LONG RegQueryInfoKeyW(in HKEY hKey, LPWSTR lpClass, LPDWORD lpcbClass,
LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcbMaxSubKeyLen, LPDWORD lpcbMaxClassLen,
LPDWORD lpcValues, LPDWORD lpcbMaxValueNameLen, LPDWORD lpcbMaxValueLen, LPDWORD lpcbSecurityDescriptor,
PFILETIME lpftLastWriteTime);
export LONG RegQueryValueA(in HKEY hKey, LPCSTR lpSubKey, LPSTR lpValue, LPLONG lpcbValue);
export LONG RegQueryValueW(in HKEY hKey, LPCWSTR lpSubKey, LPWSTR lpValue, LPLONG lpcbValue);
export LONG RegQueryValueExA(in HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPVOID lpData, LPDWORD lpcbData);
export LONG RegQueryValueExW(in HKEY hKey, LPCWSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPVOID lpData, LPDWORD lpcbData);
export LONG RegCreateKeyExA(in HKEY hKey, LPCSTR lpSubKey, DWORD Reserved, LPSTR lpClass,
DWORD dwOptions, REGSAM samDesired, SECURITY_ATTRIBUTES* lpSecurityAttributes,
PHKEY phkResult, LPDWORD lpdwDisposition);
export LONG RegCreateKeyExW(in HKEY hKey, LPCWSTR lpSubKey, DWORD Reserved, LPWSTR lpClass,
DWORD dwOptions, REGSAM samDesired, SECURITY_ATTRIBUTES* lpSecurityAttributes,
PHKEY phkResult, LPDWORD lpdwDisposition);
export LONG RegSetValueExA(in HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, BYTE* lpData, DWORD cbData);
export LONG RegSetValueExW(in HKEY hKey, LPCWSTR lpValueName, DWORD Reserved, DWORD dwType, BYTE* lpData, DWORD cbData);
export LONG RegOpenCurrentUser(REGSAM samDesired, PHKEY phkResult);
export LONG RegConnectRegistryA(LPCSTR lpMachineName, HKEY hKey, PHKEY phkResult);
export LONG RegConnectRegistryW(LPCWSTR lpMachineName, HKEY hKey, PHKEY phkResult);
struct MEMORY_BASIC_INFORMATION {
PVOID BaseAddress;
PVOID AllocationBase;
DWORD AllocationProtect;
DWORD RegionSize;
DWORD State;
DWORD Protect;
DWORD Type;
}
alias MEMORY_BASIC_INFORMATION* PMEMORY_BASIC_INFORMATION;
enum
{
SECTION_QUERY = 0x0001,
SECTION_MAP_WRITE = 0x0002,
SECTION_MAP_READ = 0x0004,
SECTION_MAP_EXECUTE = 0x0008,
SECTION_EXTEND_SIZE = 0x0010,
SECTION_ALL_ACCESS = cast(int)(STANDARD_RIGHTS_REQUIRED|SECTION_QUERY| SECTION_MAP_WRITE | SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_EXTEND_SIZE),
PAGE_NOACCESS = 0x01,
PAGE_READONLY = 0x02,
PAGE_READWRITE = 0x04,
PAGE_WRITECOPY = 0x08,
PAGE_EXECUTE = 0x10,
PAGE_EXECUTE_READ = 0x20,
PAGE_EXECUTE_READWRITE = 0x40,
PAGE_EXECUTE_WRITECOPY = 0x80,
PAGE_GUARD = 0x100,
PAGE_NOCACHE = 0x200,
MEM_COMMIT = 0x1000,
MEM_RESERVE = 0x2000,
MEM_DECOMMIT = 0x4000,
MEM_RELEASE = 0x8000,
MEM_FREE = 0x10000,
MEM_PRIVATE = 0x20000,
MEM_MAPPED = 0x40000,
MEM_RESET = 0x80000,
MEM_TOP_DOWN = 0x100000,
SEC_FILE = 0x800000,
SEC_IMAGE = 0x1000000,
SEC_RESERVE = 0x4000000,
SEC_COMMIT = 0x8000000,
SEC_NOCACHE = 0x10000000,
MEM_IMAGE = SEC_IMAGE,
}
enum
{
FILE_MAP_COPY = SECTION_QUERY,
FILE_MAP_WRITE = SECTION_MAP_WRITE,
FILE_MAP_READ = SECTION_MAP_READ,
FILE_MAP_ALL_ACCESS = SECTION_ALL_ACCESS,
}
//
// Define access rights to files and directories
//
//
// The FILE_READ_DATA and FILE_WRITE_DATA constants are also defined in
// devioctl.h as FILE_READ_ACCESS and FILE_WRITE_ACCESS. The values for these
// constants *MUST* always be in sync.
// The values are redefined in devioctl.h because they must be available to
// both DOS and NT.
//
enum
{
FILE_READ_DATA = ( 0x0001 ), // file & pipe
FILE_LIST_DIRECTORY = ( 0x0001 ), // directory
FILE_WRITE_DATA = ( 0x0002 ), // file & pipe
FILE_ADD_FILE = ( 0x0002 ), // directory
FILE_APPEND_DATA = ( 0x0004 ), // file
FILE_ADD_SUBDIRECTORY = ( 0x0004 ), // directory
FILE_CREATE_PIPE_INSTANCE = ( 0x0004 ), // named pipe
FILE_READ_EA = ( 0x0008 ), // file & directory
FILE_WRITE_EA = ( 0x0010 ), // file & directory
FILE_EXECUTE = ( 0x0020 ), // file
FILE_TRAVERSE = ( 0x0020 ), // directory
FILE_DELETE_CHILD = ( 0x0040 ), // directory
FILE_READ_ATTRIBUTES = ( 0x0080 ), // all
FILE_WRITE_ATTRIBUTES = ( 0x0100 ), // all
FILE_ALL_ACCESS = cast(int)(STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF),
FILE_GENERIC_READ = cast(int)(STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE),
FILE_GENERIC_WRITE = cast(int)(STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE),
FILE_GENERIC_EXECUTE = cast(int)(STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE),
}
export
{
BOOL FreeResource(HGLOBAL hResData);
LPVOID LockResource(HGLOBAL hResData);
BOOL GlobalUnlock(HGLOBAL hMem);
HGLOBAL GlobalFree(HGLOBAL hMem);
UINT GlobalCompact(DWORD dwMinFree);
void GlobalFix(HGLOBAL hMem);
void GlobalUnfix(HGLOBAL hMem);
LPVOID GlobalWire(HGLOBAL hMem);
BOOL GlobalUnWire(HGLOBAL hMem);
void GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer);
HLOCAL LocalAlloc(UINT uFlags, UINT uBytes);
HLOCAL LocalReAlloc(HLOCAL hMem, UINT uBytes, UINT uFlags);
LPVOID LocalLock(HLOCAL hMem);
HLOCAL LocalHandle(LPCVOID pMem);
BOOL LocalUnlock(HLOCAL hMem);
UINT LocalSize(HLOCAL hMem);
UINT LocalFlags(HLOCAL hMem);
HLOCAL LocalFree(HLOCAL hMem);
UINT LocalShrink(HLOCAL hMem, UINT cbNewSize);
UINT LocalCompact(UINT uMinFree);
BOOL FlushInstructionCache(HANDLE hProcess, LPCVOID lpBaseAddress, DWORD dwSize);
LPVOID VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect);
BOOL VirtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType);
BOOL VirtualProtect(LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
SIZE_T VirtualQuery(LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength);
LPVOID VirtualAllocEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect);
BOOL VirtualFreeEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType);
BOOL VirtualProtectEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
SIZE_T VirtualQueryEx(HANDLE hProcess, LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength);
}
struct SYSTEMTIME
{
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
}
struct TIME_ZONE_INFORMATION {
LONG Bias;
WCHAR StandardName[ 32 ];
SYSTEMTIME StandardDate;
LONG StandardBias;
WCHAR DaylightName[ 32 ];
SYSTEMTIME DaylightDate;
LONG DaylightBias;
}
struct REG_TZI_FORMAT
{
LONG Bias;
LONG StandardBias;
LONG DaylightBias;
SYSTEMTIME StandardDate;
SYSTEMTIME DaylightDate;
}
enum
{
TIME_ZONE_ID_UNKNOWN = 0,
TIME_ZONE_ID_STANDARD = 1,
TIME_ZONE_ID_DAYLIGHT = 2,
}
export void GetSystemTime(SYSTEMTIME* lpSystemTime);
export BOOL GetFileTime(HANDLE hFile, FILETIME *lpCreationTime, FILETIME *lpLastAccessTime, FILETIME *lpLastWriteTime);
export void GetSystemTimeAsFileTime(FILETIME* lpSystemTimeAsFileTime);
export BOOL SetSystemTime(SYSTEMTIME* lpSystemTime);
export BOOL SetFileTime(HANDLE hFile, in FILETIME *lpCreationTime, in FILETIME *lpLastAccessTime, in FILETIME *lpLastWriteTime);
export void GetLocalTime(SYSTEMTIME* lpSystemTime);
export BOOL SetLocalTime(SYSTEMTIME* lpSystemTime);
export BOOL SystemTimeToTzSpecificLocalTime(TIME_ZONE_INFORMATION* lpTimeZoneInformation, SYSTEMTIME* lpUniversalTime, SYSTEMTIME* lpLocalTime);
export BOOL TzSpecificLocalTimeToSystemTime(TIME_ZONE_INFORMATION* lpTimeZoneInformation, SYSTEMTIME* lpLocalTime, SYSTEMTIME* lpUniversalTime);
export DWORD GetTimeZoneInformation(TIME_ZONE_INFORMATION* lpTimeZoneInformation);
export BOOL SetTimeZoneInformation(TIME_ZONE_INFORMATION* lpTimeZoneInformation);
export BOOL SystemTimeToFileTime(in SYSTEMTIME *lpSystemTime, FILETIME* lpFileTime);
export BOOL FileTimeToLocalFileTime(in FILETIME *lpFileTime, FILETIME* lpLocalFileTime);
export BOOL LocalFileTimeToFileTime(in FILETIME *lpLocalFileTime, FILETIME* lpFileTime);
export BOOL FileTimeToSystemTime(in FILETIME *lpFileTime, SYSTEMTIME* lpSystemTime);
export LONG CompareFileTime(in FILETIME *lpFileTime1, in FILETIME *lpFileTime2);
export BOOL FileTimeToDosDateTime(in FILETIME *lpFileTime, WORD* lpFatDate, WORD* lpFatTime);
export BOOL DosDateTimeToFileTime(WORD wFatDate, WORD wFatTime, FILETIME* lpFileTime);
export DWORD GetTickCount();
export BOOL SetSystemTimeAdjustment(DWORD dwTimeAdjustment, BOOL bTimeAdjustmentDisabled);
export BOOL GetSystemTimeAdjustment(DWORD* lpTimeAdjustment, DWORD* lpTimeIncrement, BOOL* lpTimeAdjustmentDisabled);
export DWORD FormatMessageA(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPSTR lpBuffer, DWORD nSize, void* *Arguments);
export DWORD FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, void* *Arguments);
enum
{
FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100,
FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200,
FORMAT_MESSAGE_FROM_STRING = 0x00000400,
FORMAT_MESSAGE_FROM_HMODULE = 0x00000800,
FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000,
FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000,
FORMAT_MESSAGE_MAX_WIDTH_MASK = 0x000000FF,
};
//
// Language IDs.
//
// The following two combinations of primary language ID and
// sublanguage ID have special semantics:
//
// Primary Language ID Sublanguage ID Result
// ------------------- --------------- ------------------------
// LANG_NEUTRAL SUBLANG_NEUTRAL Language neutral
// LANG_NEUTRAL SUBLANG_DEFAULT User default language
// LANG_NEUTRAL SUBLANG_SYS_DEFAULT System default language
//
//
// Primary language IDs.
//
enum
{
LANG_NEUTRAL = 0x00,
LANG_AFRIKAANS = 0x36,
LANG_ALBANIAN = 0x1c,
LANG_ARABIC = 0x01,
LANG_BASQUE = 0x2d,
LANG_BELARUSIAN = 0x23,
LANG_BULGARIAN = 0x02,
LANG_CATALAN = 0x03,
LANG_CHINESE = 0x04,
LANG_CROATIAN = 0x1a,
LANG_CZECH = 0x05,
LANG_DANISH = 0x06,
LANG_DUTCH = 0x13,
LANG_ENGLISH = 0x09,
LANG_ESTONIAN = 0x25,
LANG_FAEROESE = 0x38,
LANG_FARSI = 0x29,
LANG_FINNISH = 0x0b,
LANG_FRENCH = 0x0c,
LANG_GERMAN = 0x07,
LANG_GREEK = 0x08,
LANG_HEBREW = 0x0d,
LANG_HUNGARIAN = 0x0e,
LANG_ICELANDIC = 0x0f,
LANG_INDONESIAN = 0x21,
LANG_ITALIAN = 0x10,
LANG_JAPANESE = 0x11,
LANG_KOREAN = 0x12,
LANG_LATVIAN = 0x26,
LANG_LITHUANIAN = 0x27,
LANG_NORWEGIAN = 0x14,
LANG_POLISH = 0x15,
LANG_PORTUGUESE = 0x16,
LANG_ROMANIAN = 0x18,
LANG_RUSSIAN = 0x19,
LANG_SERBIAN = 0x1a,
LANG_SLOVAK = 0x1b,
LANG_SLOVENIAN = 0x24,
LANG_SPANISH = 0x0a,
LANG_SWEDISH = 0x1d,
LANG_THAI = 0x1e,
LANG_TURKISH = 0x1f,
LANG_UKRAINIAN = 0x22,
LANG_VIETNAMESE = 0x2a,
}
//
// Sublanguage IDs.
//
// The name immediately following SUBLANG_ dictates which primary
// language ID that sublanguage ID can be combined with to form a
// valid language ID.
//
enum
{
SUBLANG_NEUTRAL = 0x00, // language neutral
SUBLANG_DEFAULT = 0x01, // user default
SUBLANG_SYS_DEFAULT = 0x02, // system default
SUBLANG_ARABIC_SAUDI_ARABIA = 0x01, // Arabic (Saudi Arabia)
SUBLANG_ARABIC_IRAQ = 0x02, // Arabic (Iraq)
SUBLANG_ARABIC_EGYPT = 0x03, // Arabic (Egypt)
SUBLANG_ARABIC_LIBYA = 0x04, // Arabic (Libya)
SUBLANG_ARABIC_ALGERIA = 0x05, // Arabic (Algeria)
SUBLANG_ARABIC_MOROCCO = 0x06, // Arabic (Morocco)
SUBLANG_ARABIC_TUNISIA = 0x07, // Arabic (Tunisia)
SUBLANG_ARABIC_OMAN = 0x08, // Arabic (Oman)
SUBLANG_ARABIC_YEMEN = 0x09, // Arabic (Yemen)
SUBLANG_ARABIC_SYRIA = 0x0a, // Arabic (Syria)
SUBLANG_ARABIC_JORDAN = 0x0b, // Arabic (Jordan)
SUBLANG_ARABIC_LEBANON = 0x0c, // Arabic (Lebanon)
SUBLANG_ARABIC_KUWAIT = 0x0d, // Arabic (Kuwait)
SUBLANG_ARABIC_UAE = 0x0e, // Arabic (U.A.E)
SUBLANG_ARABIC_BAHRAIN = 0x0f, // Arabic (Bahrain)
SUBLANG_ARABIC_QATAR = 0x10, // Arabic (Qatar)
SUBLANG_CHINESE_TRADITIONAL = 0x01, // Chinese (Taiwan)
SUBLANG_CHINESE_SIMPLIFIED = 0x02, // Chinese (PR China)
SUBLANG_CHINESE_HONGKONG = 0x03, // Chinese (Hong Kong)
SUBLANG_CHINESE_SINGAPORE = 0x04, // Chinese (Singapore)
SUBLANG_DUTCH = 0x01, // Dutch
SUBLANG_DUTCH_BELGIAN = 0x02, // Dutch (Belgian)
SUBLANG_ENGLISH_US = 0x01, // English (USA)
SUBLANG_ENGLISH_UK = 0x02, // English (UK)
SUBLANG_ENGLISH_AUS = 0x03, // English (Australian)
SUBLANG_ENGLISH_CAN = 0x04, // English (Canadian)
SUBLANG_ENGLISH_NZ = 0x05, // English (New Zealand)
SUBLANG_ENGLISH_EIRE = 0x06, // English (Irish)
SUBLANG_ENGLISH_SOUTH_AFRICA = 0x07, // English (South Africa)
SUBLANG_ENGLISH_JAMAICA = 0x08, // English (Jamaica)
SUBLANG_ENGLISH_CARIBBEAN = 0x09, // English (Caribbean)
SUBLANG_ENGLISH_BELIZE = 0x0a, // English (Belize)
SUBLANG_ENGLISH_TRINIDAD = 0x0b, // English (Trinidad)
SUBLANG_FRENCH = 0x01, // French
SUBLANG_FRENCH_BELGIAN = 0x02, // French (Belgian)
SUBLANG_FRENCH_CANADIAN = 0x03, // French (Canadian)
SUBLANG_FRENCH_SWISS = 0x04, // French (Swiss)
SUBLANG_FRENCH_LUXEMBOURG = 0x05, // French (Luxembourg)
SUBLANG_GERMAN = 0x01, // German
SUBLANG_GERMAN_SWISS = 0x02, // German (Swiss)
SUBLANG_GERMAN_AUSTRIAN = 0x03, // German (Austrian)
SUBLANG_GERMAN_LUXEMBOURG = 0x04, // German (Luxembourg)
SUBLANG_GERMAN_LIECHTENSTEIN = 0x05, // German (Liechtenstein)
SUBLANG_ITALIAN = 0x01, // Italian
SUBLANG_ITALIAN_SWISS = 0x02, // Italian (Swiss)
SUBLANG_KOREAN = 0x01, // Korean (Extended Wansung)
SUBLANG_KOREAN_JOHAB = 0x02, // Korean (Johab)
SUBLANG_NORWEGIAN_BOKMAL = 0x01, // Norwegian (Bokmal)
SUBLANG_NORWEGIAN_NYNORSK = 0x02, // Norwegian (Nynorsk)
SUBLANG_PORTUGUESE = 0x02, // Portuguese
SUBLANG_PORTUGUESE_BRAZILIAN = 0x01, // Portuguese (Brazilian)
SUBLANG_SERBIAN_LATIN = 0x02, // Serbian (Latin)
SUBLANG_SERBIAN_CYRILLIC = 0x03, // Serbian (Cyrillic)
SUBLANG_SPANISH = 0x01, // Spanish (Castilian)
SUBLANG_SPANISH_MEXICAN = 0x02, // Spanish (Mexican)
SUBLANG_SPANISH_MODERN = 0x03, // Spanish (Modern)
SUBLANG_SPANISH_GUATEMALA = 0x04, // Spanish (Guatemala)
SUBLANG_SPANISH_COSTA_RICA = 0x05, // Spanish (Costa Rica)
SUBLANG_SPANISH_PANAMA = 0x06, // Spanish (Panama)
SUBLANG_SPANISH_DOMINICAN_REPUBLIC = 0x07, // Spanish (Dominican Republic)
SUBLANG_SPANISH_VENEZUELA = 0x08, // Spanish (Venezuela)
SUBLANG_SPANISH_COLOMBIA = 0x09, // Spanish (Colombia)
SUBLANG_SPANISH_PERU = 0x0a, // Spanish (Peru)
SUBLANG_SPANISH_ARGENTINA = 0x0b, // Spanish (Argentina)
SUBLANG_SPANISH_ECUADOR = 0x0c, // Spanish (Ecuador)
SUBLANG_SPANISH_CHILE = 0x0d, // Spanish (Chile)
SUBLANG_SPANISH_URUGUAY = 0x0e, // Spanish (Uruguay)
SUBLANG_SPANISH_PARAGUAY = 0x0f, // Spanish (Paraguay)
SUBLANG_SPANISH_BOLIVIA = 0x10, // Spanish (Bolivia)
SUBLANG_SPANISH_EL_SALVADOR = 0x11, // Spanish (El Salvador)
SUBLANG_SPANISH_HONDURAS = 0x12, // Spanish (Honduras)
SUBLANG_SPANISH_NICARAGUA = 0x13, // Spanish (Nicaragua)
SUBLANG_SPANISH_PUERTO_RICO = 0x14, // Spanish (Puerto Rico)
SUBLANG_SWEDISH = 0x01, // Swedish
SUBLANG_SWEDISH_FINLAND = 0x02, // Swedish (Finland)
}
//
// Sorting IDs.
//
enum
{
SORT_DEFAULT = 0x0, // sorting default
SORT_JAPANESE_XJIS = 0x0, // Japanese XJIS order
SORT_JAPANESE_UNICODE = 0x1, // Japanese Unicode order
SORT_CHINESE_BIG5 = 0x0, // Chinese BIG5 order
SORT_CHINESE_PRCP = 0x0, // PRC Chinese Phonetic order
SORT_CHINESE_UNICODE = 0x1, // Chinese Unicode order
SORT_CHINESE_PRC = 0x2, // PRC Chinese Stroke Count order
SORT_KOREAN_KSC = 0x0, // Korean KSC order
SORT_KOREAN_UNICODE = 0x1, // Korean Unicode order
SORT_GERMAN_PHONE_BOOK = 0x1, // German Phone Book order
}
// end_r_winnt
//
// A language ID is a 16 bit value which is the combination of a
// primary language ID and a secondary language ID. The bits are
// allocated as follows:
//
// +-----------------------+-------------------------+
// | Sublanguage ID | Primary Language ID |
// +-----------------------+-------------------------+
// 15 10 9 0 bit
//
//
// Language ID creation/extraction macros:
//
// MAKELANGID - construct language id from a primary language id and
// a sublanguage id.
// PRIMARYLANGID - extract primary language id from a language id.
// SUBLANGID - extract sublanguage id from a language id.
//
int MAKELANGID(int p, int s) { return ((cast(WORD)s) << 10) | cast(WORD)p; }
WORD PRIMARYLANGID(int lgid) { return cast(WORD)(lgid & 0x3ff); }
WORD SUBLANGID(int lgid) { return cast(WORD)(lgid >> 10); }
struct FLOATING_SAVE_AREA {
DWORD ControlWord;
DWORD StatusWord;
DWORD TagWord;
DWORD ErrorOffset;
DWORD ErrorSelector;
DWORD DataOffset;
DWORD DataSelector;
BYTE RegisterArea[80 ];
DWORD Cr0NpxState;
}
enum
{
SIZE_OF_80387_REGISTERS = 80,
//
// The following flags control the contents of the CONTEXT structure.
//
CONTEXT_i386 = 0x00010000, // this assumes that i386 and
CONTEXT_i486 = 0x00010000, // i486 have identical context records
CONTEXT_CONTROL = (CONTEXT_i386 | 0x00000001), // SS:SP, CS:IP, FLAGS, BP
CONTEXT_INTEGER = (CONTEXT_i386 | 0x00000002), // AX, BX, CX, DX, SI, DI
CONTEXT_SEGMENTS = (CONTEXT_i386 | 0x00000004), // DS, ES, FS, GS
CONTEXT_FLOATING_POINT = (CONTEXT_i386 | 0x00000008), // 387 state
CONTEXT_DEBUG_REGISTERS = (CONTEXT_i386 | 0x00000010), // DB 0-3,6,7
CONTEXT_FULL = (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS),
}
struct CONTEXT
{
//
// The flags values within this flag control the contents of
// a CONTEXT record.
//
// If the context record is used as an input parameter, then
// for each portion of the context record controlled by a flag
// whose value is set, it is assumed that that portion of the
// context record contains valid context. If the context record
// is being used to modify a threads context, then only that
// portion of the threads context will be modified.
//
// If the context record is used as an IN OUT parameter to capture
// the context of a thread, then only those portions of the thread's
// context corresponding to set flags will be returned.
//
// The context record is never used as an OUT only parameter.
//
DWORD ContextFlags;
//
// This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
// set in ContextFlags. Note that CONTEXT_DEBUG_REGISTERS is NOT
// included in CONTEXT_FULL.
//
DWORD Dr0;
DWORD Dr1;
DWORD Dr2;
DWORD Dr3;
DWORD Dr6;
DWORD Dr7;
//
// This section is specified/returned if the
// ContextFlags word contians the flag CONTEXT_FLOATING_POINT.
//
FLOATING_SAVE_AREA FloatSave;
//
// This section is specified/returned if the
// ContextFlags word contians the flag CONTEXT_SEGMENTS.
//
DWORD SegGs;
DWORD SegFs;
DWORD SegEs;
DWORD SegDs;
//
// This section is specified/returned if the
// ContextFlags word contians the flag CONTEXT_INTEGER.
//
DWORD Edi;
DWORD Esi;
DWORD Ebx;
DWORD Edx;
DWORD Ecx;
DWORD Eax;
//
// This section is specified/returned if the
// ContextFlags word contians the flag CONTEXT_CONTROL.
//
DWORD Ebp;
DWORD Eip;
DWORD SegCs; // MUST BE SANITIZED
DWORD EFlags; // MUST BE SANITIZED
DWORD Esp;
DWORD SegSs;
}
enum ADDRESS_MODE
{
AddrMode1616,
AddrMode1632,
AddrModeReal,
AddrModeFlat
}
struct ADDRESS
{
DWORD Offset;
WORD Segment;
ADDRESS_MODE Mode;
}
struct ADDRESS64
{
DWORD64 Offset;
WORD Segment;
ADDRESS_MODE Mode;
}
struct KDHELP
{
DWORD Thread;
DWORD ThCallbackStack;
DWORD NextCallback;
DWORD FramePointer;
DWORD KiCallUserMode;
DWORD KeUserCallbackDispatcher;
DWORD SystemRangeStart;
DWORD ThCallbackBStore;
DWORD KiUserExceptionDispatcher;
DWORD StackBase;
DWORD StackLimit;
DWORD[5] Reserved;
}
struct KDHELP64
{
DWORD64 Thread;
DWORD ThCallbackStack;
DWORD ThCallbackBStore;
DWORD NextCallback;
DWORD FramePointer;
DWORD64 KiCallUserMode;
DWORD64 KeUserCallbackDispatcher;
DWORD64 SystemRangeStart;
DWORD64 KiUserExceptionDispatcher;
DWORD64 StackBase;
DWORD64 StackLimit;
DWORD64[5] Reserved;
}
struct STACKFRAME
{
ADDRESS AddrPC;
ADDRESS AddrReturn;
ADDRESS AddrFrame;
ADDRESS AddrStack;
PVOID FuncTableEntry;
DWORD[4] Params;
BOOL Far;
BOOL Virtual;
DWORD[3] Reserved;
KDHELP KdHelp;
ADDRESS AddrBStore;
}
struct STACKFRAME64
{
ADDRESS64 AddrPC;
ADDRESS64 AddrReturn;
ADDRESS64 AddrFrame;
ADDRESS64 AddrStack;
ADDRESS64 AddrBStore;
PVOID FuncTableEntry;
DWORD64[4] Params;
BOOL Far;
BOOL Virtual;
DWORD64[3] Reserved;
KDHELP64 KdHelp;
}
enum
{
THREAD_BASE_PRIORITY_LOWRT = 15, // value that gets a thread to LowRealtime-1
THREAD_BASE_PRIORITY_MAX = 2, // maximum thread base priority boost
THREAD_BASE_PRIORITY_MIN = -2, // minimum thread base priority boost
THREAD_BASE_PRIORITY_IDLE = -15, // value that gets a thread to idle
THREAD_PRIORITY_LOWEST = THREAD_BASE_PRIORITY_MIN,
THREAD_PRIORITY_BELOW_NORMAL = (THREAD_PRIORITY_LOWEST+1),
THREAD_PRIORITY_NORMAL = 0,
THREAD_PRIORITY_HIGHEST = THREAD_BASE_PRIORITY_MAX,
THREAD_PRIORITY_ABOVE_NORMAL = (THREAD_PRIORITY_HIGHEST-1),
THREAD_PRIORITY_ERROR_RETURN = int.max,
THREAD_PRIORITY_TIME_CRITICAL = THREAD_BASE_PRIORITY_LOWRT,
THREAD_PRIORITY_IDLE = THREAD_BASE_PRIORITY_IDLE,
}
struct SYSTEM_INFO
{
union
{
DWORD dwOemId;
struct
{
WORD wProcessorArchitecture;
WORD wReserved;
}
}
DWORD dwPageSize;
LPVOID lpMinimumApplicationAddress;
LPVOID lpMaximumApplicationAddress;
DWORD_PTR dwActiveProcessorMask;
DWORD dwNumberOfProcessors;
DWORD dwProcessorType;
DWORD dwAllocationGranularity;
WORD wProcessorLevel;
WORD wProcessorRevision;
}
alias SYSTEM_INFO* LPSYSTEM_INFO;
export void GetSystemInfo(LPSYSTEM_INFO lpSystemInfo);
export void GetNativeSystemInfo(LPSYSTEM_INFO lpSystemInfo);
enum : DWORD
{
MAX_COMPUTERNAME_LENGTH = 15,
}
export BOOL GetComputerNameA(LPSTR lpBuffer, LPDWORD nSize);
export BOOL GetComputerNameW(LPWSTR lpBuffer, LPDWORD nSize);
export BOOL SetComputerNameA(LPCSTR lpComputerName);
export BOOL SetComputerNameW(LPCWSTR lpComputerName);
export BOOL GetUserNameA(LPSTR lpBuffer, LPDWORD lpnSize);
export BOOL GetUserNameW(LPWSTR lpBuffer, LPDWORD lpnSize);
export HANDLE GetCurrentThread();
export BOOL GetProcessTimes(HANDLE hProcess, LPFILETIME lpCreationTime, LPFILETIME lpExitTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime);
export HANDLE GetCurrentProcess();
export DWORD GetCurrentProcessId();
export BOOL DuplicateHandle (HANDLE sourceProcess, HANDLE sourceThread,
HANDLE targetProcessHandle, HANDLE *targetHandle, DWORD access,
BOOL inheritHandle, DWORD options);
export DWORD GetCurrentThreadId();
export BOOL SetThreadPriority(HANDLE hThread, int nPriority);
export BOOL SetThreadPriorityBoost(HANDLE hThread, BOOL bDisablePriorityBoost);
export BOOL GetThreadPriorityBoost(HANDLE hThread, PBOOL pDisablePriorityBoost);
export BOOL GetThreadTimes(HANDLE hThread, LPFILETIME lpCreationTime, LPFILETIME lpExitTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime);
export int GetThreadPriority(HANDLE hThread);
export BOOL GetThreadContext(HANDLE hThread, CONTEXT* lpContext);
export BOOL SetThreadContext(HANDLE hThread, CONTEXT* lpContext);
export DWORD SuspendThread(HANDLE hThread);
export DWORD ResumeThread(HANDLE hThread);
export DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds);
export DWORD WaitForMultipleObjects(DWORD nCount, HANDLE *lpHandles, BOOL bWaitAll, DWORD dwMilliseconds);
export void Sleep(DWORD dwMilliseconds);
export BOOL SwitchToThread();
// Synchronization
export
{
LONG InterlockedIncrement(LPLONG lpAddend);
LONG InterlockedDecrement(LPLONG lpAddend);
LONG InterlockedExchange(LPLONG Target, LONG Value);
LONG InterlockedExchangeAdd(LPLONG Addend, LONG Value);
PVOID InterlockedCompareExchange(PVOID *Destination, PVOID Exchange, PVOID Comperand);
void InitializeCriticalSection(CRITICAL_SECTION * lpCriticalSection);
void EnterCriticalSection(CRITICAL_SECTION * lpCriticalSection);
BOOL TryEnterCriticalSection(CRITICAL_SECTION * lpCriticalSection);
void LeaveCriticalSection(CRITICAL_SECTION * lpCriticalSection);
void DeleteCriticalSection(CRITICAL_SECTION * lpCriticalSection);
}
export BOOL QueryPerformanceCounter(long* lpPerformanceCount);
export BOOL QueryPerformanceFrequency(long* lpFrequency);
enum
{
WM_NOTIFY = 0x004E,
WM_INPUTLANGCHANGEREQUEST = 0x0050,
WM_INPUTLANGCHANGE = 0x0051,
WM_TCARD = 0x0052,
WM_HELP = 0x0053,
WM_USERCHANGED = 0x0054,
WM_NOTIFYFORMAT = 0x0055,
NFR_ANSI = 1,
NFR_UNICODE = 2,
NF_QUERY = 3,
NF_REQUERY = 4,
WM_CONTEXTMENU = 0x007B,
WM_STYLECHANGING = 0x007C,
WM_STYLECHANGED = 0x007D,
WM_DISPLAYCHANGE = 0x007E,
WM_GETICON = 0x007F,
WM_SETICON = 0x0080,
WM_NCCREATE = 0x0081,
WM_NCDESTROY = 0x0082,
WM_NCCALCSIZE = 0x0083,
WM_NCHITTEST = 0x0084,
WM_NCPAINT = 0x0085,
WM_NCACTIVATE = 0x0086,
WM_GETDLGCODE = 0x0087,
WM_NCMOUSEMOVE = 0x00A0,
WM_NCLBUTTONDOWN = 0x00A1,
WM_NCLBUTTONUP = 0x00A2,
WM_NCLBUTTONDBLCLK = 0x00A3,
WM_NCRBUTTONDOWN = 0x00A4,
WM_NCRBUTTONUP = 0x00A5,
WM_NCRBUTTONDBLCLK = 0x00A6,
WM_NCMBUTTONDOWN = 0x00A7,
WM_NCMBUTTONUP = 0x00A8,
WM_NCMBUTTONDBLCLK = 0x00A9,
WM_KEYFIRST = 0x0100,
WM_KEYDOWN = 0x0100,
WM_KEYUP = 0x0101,
WM_CHAR = 0x0102,
WM_DEADCHAR = 0x0103,
WM_SYSKEYDOWN = 0x0104,
WM_SYSKEYUP = 0x0105,
WM_SYSCHAR = 0x0106,
WM_SYSDEADCHAR = 0x0107,
WM_KEYLAST = 0x0108,
WM_IME_STARTCOMPOSITION = 0x010D,
WM_IME_ENDCOMPOSITION = 0x010E,
WM_IME_COMPOSITION = 0x010F,
WM_IME_KEYLAST = 0x010F,
WM_INITDIALOG = 0x0110,
WM_COMMAND = 0x0111,
WM_SYSCOMMAND = 0x0112,
WM_TIMER = 0x0113,
WM_HSCROLL = 0x0114,
WM_VSCROLL = 0x0115,
WM_INITMENU = 0x0116,
WM_INITMENUPOPUP = 0x0117,
WM_MENUSELECT = 0x011F,
WM_MENUCHAR = 0x0120,
WM_ENTERIDLE = 0x0121,
WM_CTLCOLORMSGBOX = 0x0132,
WM_CTLCOLOREDIT = 0x0133,
WM_CTLCOLORLISTBOX = 0x0134,
WM_CTLCOLORBTN = 0x0135,
WM_CTLCOLORDLG = 0x0136,
WM_CTLCOLORSCROLLBAR = 0x0137,
WM_CTLCOLORSTATIC = 0x0138,
WM_MOUSEFIRST = 0x0200,
WM_MOUSEMOVE = 0x0200,
WM_LBUTTONDOWN = 0x0201,
WM_LBUTTONUP = 0x0202,
WM_LBUTTONDBLCLK = 0x0203,
WM_RBUTTONDOWN = 0x0204,
WM_RBUTTONUP = 0x0205,
WM_RBUTTONDBLCLK = 0x0206,
WM_MBUTTONDOWN = 0x0207,
WM_MBUTTONUP = 0x0208,
WM_MBUTTONDBLCLK = 0x0209,
WM_MOUSELAST = 0x0209,
WM_PARENTNOTIFY = 0x0210,
MENULOOP_WINDOW = 0,
MENULOOP_POPUP = 1,
WM_ENTERMENULOOP = 0x0211,
WM_EXITMENULOOP = 0x0212,
WM_NEXTMENU = 0x0213,
}
enum
{
/*
* Dialog Box Command IDs
*/
IDOK = 1,
IDCANCEL = 2,
IDABORT = 3,
IDRETRY = 4,
IDIGNORE = 5,
IDYES = 6,
IDNO = 7,
IDCLOSE = 8,
IDHELP = 9,
// end_r_winuser
/*
* Control Manager Structures and Definitions
*/
// begin_r_winuser
/*
* Edit Control Styles
*/
ES_LEFT = 0x0000,
ES_CENTER = 0x0001,
ES_RIGHT = 0x0002,
ES_MULTILINE = 0x0004,
ES_UPPERCASE = 0x0008,
ES_LOWERCASE = 0x0010,
ES_PASSWORD = 0x0020,
ES_AUTOVSCROLL = 0x0040,
ES_AUTOHSCROLL = 0x0080,
ES_NOHIDESEL = 0x0100,
ES_OEMCONVERT = 0x0400,
ES_READONLY = 0x0800,
ES_WANTRETURN = 0x1000,
ES_NUMBER = 0x2000,
// end_r_winuser
/*
* Edit Control Notification Codes
*/
EN_SETFOCUS = 0x0100,
EN_KILLFOCUS = 0x0200,
EN_CHANGE = 0x0300,
EN_UPDATE = 0x0400,
EN_ERRSPACE = 0x0500,
EN_MAXTEXT = 0x0501,
EN_HSCROLL = 0x0601,
EN_VSCROLL = 0x0602,
/* Edit control EM_SETMARGIN parameters */
EC_LEFTMARGIN = 0x0001,
EC_RIGHTMARGIN = 0x0002,
EC_USEFONTINFO = 0xffff,
// begin_r_winuser
/*
* Edit Control Messages
*/
EM_GETSEL = 0x00B0,
EM_SETSEL = 0x00B1,
EM_GETRECT = 0x00B2,
EM_SETRECT = 0x00B3,
EM_SETRECTNP = 0x00B4,
EM_SCROLL = 0x00B5,
EM_LINESCROLL = 0x00B6,
EM_SCROLLCARET = 0x00B7,
EM_GETMODIFY = 0x00B8,
EM_SETMODIFY = 0x00B9,
EM_GETLINECOUNT = 0x00BA,
EM_LINEINDEX = 0x00BB,
EM_SETHANDLE = 0x00BC,
EM_GETHANDLE = 0x00BD,
EM_GETTHUMB = 0x00BE,
EM_LINELENGTH = 0x00C1,
EM_REPLACESEL = 0x00C2,
EM_GETLINE = 0x00C4,
EM_LIMITTEXT = 0x00C5,
EM_CANUNDO = 0x00C6,
EM_UNDO = 0x00C7,
EM_FMTLINES = 0x00C8,
EM_LINEFROMCHAR = 0x00C9,
EM_SETTABSTOPS = 0x00CB,
EM_SETPASSWORDCHAR = 0x00CC,
EM_EMPTYUNDOBUFFER = 0x00CD,
EM_GETFIRSTVISIBLELINE = 0x00CE,
EM_SETREADONLY = 0x00CF,
EM_SETWORDBREAKPROC = 0x00D0,
EM_GETWORDBREAKPROC = 0x00D1,
EM_GETPASSWORDCHAR = 0x00D2,
EM_SETMARGINS = 0x00D3,
EM_GETMARGINS = 0x00D4,
EM_SETLIMITTEXT = EM_LIMITTEXT, /* ;win40 Name change */
EM_GETLIMITTEXT = 0x00D5,
EM_POSFROMCHAR = 0x00D6,
EM_CHARFROMPOS = 0x00D7,
// end_r_winuser
/*
* EDITWORDBREAKPROC code values
*/
WB_LEFT = 0,
WB_RIGHT = 1,
WB_ISDELIMITER = 2,
// begin_r_winuser
/*
* Button Control Styles
*/
BS_PUSHBUTTON = 0x00000000,
BS_DEFPUSHBUTTON = 0x00000001,
BS_CHECKBOX = 0x00000002,
BS_AUTOCHECKBOX = 0x00000003,
BS_RADIOBUTTON = 0x00000004,
BS_3STATE = 0x00000005,
BS_AUTO3STATE = 0x00000006,
BS_GROUPBOX = 0x00000007,
BS_USERBUTTON = 0x00000008,
BS_AUTORADIOBUTTON = 0x00000009,
BS_OWNERDRAW = 0x0000000B,
BS_LEFTTEXT = 0x00000020,
BS_TEXT = 0x00000000,
BS_ICON = 0x00000040,
BS_BITMAP = 0x00000080,
BS_LEFT = 0x00000100,
BS_RIGHT = 0x00000200,
BS_CENTER = 0x00000300,
BS_TOP = 0x00000400,
BS_BOTTOM = 0x00000800,
BS_VCENTER = 0x00000C00,
BS_PUSHLIKE = 0x00001000,
BS_MULTILINE = 0x00002000,
BS_NOTIFY = 0x00004000,
BS_FLAT = 0x00008000,
BS_RIGHTBUTTON = BS_LEFTTEXT,
/*
* User Button Notification Codes
*/
BN_CLICKED = 0,
BN_PAINT = 1,
BN_HILITE = 2,
BN_UNHILITE = 3,
BN_DISABLE = 4,
BN_DOUBLECLICKED = 5,
BN_PUSHED = BN_HILITE,
BN_UNPUSHED = BN_UNHILITE,
BN_DBLCLK = BN_DOUBLECLICKED,
BN_SETFOCUS = 6,
BN_KILLFOCUS = 7,
/*
* Button Control Messages
*/
BM_GETCHECK = 0x00F0,
BM_SETCHECK = 0x00F1,
BM_GETSTATE = 0x00F2,
BM_SETSTATE = 0x00F3,
BM_SETSTYLE = 0x00F4,
BM_CLICK = 0x00F5,
BM_GETIMAGE = 0x00F6,
BM_SETIMAGE = 0x00F7,
BST_UNCHECKED = 0x0000,
BST_CHECKED = 0x0001,
BST_INDETERMINATE = 0x0002,
BST_PUSHED = 0x0004,
BST_FOCUS = 0x0008,
/*
* Static Control Constants
*/
SS_LEFT = 0x00000000,
SS_CENTER = 0x00000001,
SS_RIGHT = 0x00000002,
SS_ICON = 0x00000003,
SS_BLACKRECT = 0x00000004,
SS_GRAYRECT = 0x00000005,
SS_WHITERECT = 0x00000006,
SS_BLACKFRAME = 0x00000007,
SS_GRAYFRAME = 0x00000008,
SS_WHITEFRAME = 0x00000009,
SS_USERITEM = 0x0000000A,
SS_SIMPLE = 0x0000000B,
SS_LEFTNOWORDWRAP = 0x0000000C,
SS_OWNERDRAW = 0x0000000D,
SS_BITMAP = 0x0000000E,
SS_ENHMETAFILE = 0x0000000F,
SS_ETCHEDHORZ = 0x00000010,
SS_ETCHEDVERT = 0x00000011,
SS_ETCHEDFRAME = 0x00000012,
SS_TYPEMASK = 0x0000001F,
SS_NOPREFIX = 0x00000080, /* Don't do "&" character translation */
SS_NOTIFY = 0x00000100,
SS_CENTERIMAGE = 0x00000200,
SS_RIGHTJUST = 0x00000400,
SS_REALSIZEIMAGE = 0x00000800,
SS_SUNKEN = 0x00001000,
SS_ENDELLIPSIS = 0x00004000,
SS_PATHELLIPSIS = 0x00008000,
SS_WORDELLIPSIS = 0x0000C000,
SS_ELLIPSISMASK = 0x0000C000,
// end_r_winuser
/*
* Static Control Mesages
*/
STM_SETICON = 0x0170,
STM_GETICON = 0x0171,
STM_SETIMAGE = 0x0172,
STM_GETIMAGE = 0x0173,
STN_CLICKED = 0,
STN_DBLCLK = 1,
STN_ENABLE = 2,
STN_DISABLE = 3,
STM_MSGMAX = 0x0174,
}
enum
{
/*
* Window Messages
*/
WM_NULL = 0x0000,
WM_CREATE = 0x0001,
WM_DESTROY = 0x0002,
WM_MOVE = 0x0003,
WM_SIZE = 0x0005,
WM_ACTIVATE = 0x0006,
/*
* WM_ACTIVATE state values
*/
WA_INACTIVE = 0,
WA_ACTIVE = 1,
WA_CLICKACTIVE = 2,
WM_SETFOCUS = 0x0007,
WM_KILLFOCUS = 0x0008,
WM_ENABLE = 0x000A,
WM_SETREDRAW = 0x000B,
WM_SETTEXT = 0x000C,
WM_GETTEXT = 0x000D,
WM_GETTEXTLENGTH = 0x000E,
WM_PAINT = 0x000F,
WM_CLOSE = 0x0010,
WM_QUERYENDSESSION = 0x0011,
WM_QUIT = 0x0012,
WM_QUERYOPEN = 0x0013,
WM_ERASEBKGND = 0x0014,
WM_SYSCOLORCHANGE = 0x0015,
WM_ENDSESSION = 0x0016,
WM_SHOWWINDOW = 0x0018,
WM_WININICHANGE = 0x001A,
WM_SETTINGCHANGE = WM_WININICHANGE,
WM_DEVMODECHANGE = 0x001B,
WM_ACTIVATEAPP = 0x001C,
WM_FONTCHANGE = 0x001D,
WM_TIMECHANGE = 0x001E,
WM_CANCELMODE = 0x001F,
WM_SETCURSOR = 0x0020,
WM_MOUSEACTIVATE = 0x0021,
WM_CHILDACTIVATE = 0x0022,
WM_QUEUESYNC = 0x0023,
WM_GETMINMAXINFO = 0x0024,
}
struct RECT
{
LONG left;
LONG top;
LONG right;
LONG bottom;
}
alias RECT* PRECT, NPRECT, LPRECT;
struct PAINTSTRUCT {
HDC hdc;
BOOL fErase;
RECT rcPaint;
BOOL fRestore;
BOOL fIncUpdate;
BYTE rgbReserved[32];
}
alias PAINTSTRUCT* PPAINTSTRUCT, NPPAINTSTRUCT, LPPAINTSTRUCT;
// flags for GetDCEx()
enum
{
DCX_WINDOW = 0x00000001,
DCX_CACHE = 0x00000002,
DCX_NORESETATTRS = 0x00000004,
DCX_CLIPCHILDREN = 0x00000008,
DCX_CLIPSIBLINGS = 0x00000010,
DCX_PARENTCLIP = 0x00000020,
DCX_EXCLUDERGN = 0x00000040,
DCX_INTERSECTRGN = 0x00000080,
DCX_EXCLUDEUPDATE = 0x00000100,
DCX_INTERSECTUPDATE = 0x00000200,
DCX_LOCKWINDOWUPDATE = 0x00000400,
DCX_VALIDATE = 0x00200000,
}
export
{
BOOL UpdateWindow(HWND hWnd);
HWND SetActiveWindow(HWND hWnd);
HWND GetForegroundWindow();
BOOL PaintDesktop(HDC hdc);
BOOL SetForegroundWindow(HWND hWnd);
HWND WindowFromDC(HDC hDC);
HDC GetDC(HWND hWnd);
HDC GetDCEx(HWND hWnd, HRGN hrgnClip, DWORD flags);
HDC GetWindowDC(HWND hWnd);
int ReleaseDC(HWND hWnd, HDC hDC);
HDC BeginPaint(HWND hWnd, LPPAINTSTRUCT lpPaint);
BOOL EndPaint(HWND hWnd, PAINTSTRUCT *lpPaint);
BOOL GetUpdateRect(HWND hWnd, LPRECT lpRect, BOOL bErase);
int GetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase);
int SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw);
int GetWindowRgn(HWND hWnd, HRGN hRgn);
int ExcludeUpdateRgn(HDC hDC, HWND hWnd);
BOOL InvalidateRect(HWND hWnd, RECT *lpRect, BOOL bErase);
BOOL ValidateRect(HWND hWnd, RECT *lpRect);
BOOL InvalidateRgn(HWND hWnd, HRGN hRgn, BOOL bErase);
BOOL ValidateRgn(HWND hWnd, HRGN hRgn);
BOOL RedrawWindow(HWND hWnd, RECT *lprcUpdate, HRGN hrgnUpdate, UINT flags);
}
// flags for RedrawWindow()
enum
{
RDW_INVALIDATE = 0x0001,
RDW_INTERNALPAINT = 0x0002,
RDW_ERASE = 0x0004,
RDW_VALIDATE = 0x0008,
RDW_NOINTERNALPAINT = 0x0010,
RDW_NOERASE = 0x0020,
RDW_NOCHILDREN = 0x0040,
RDW_ALLCHILDREN = 0x0080,
RDW_UPDATENOW = 0x0100,
RDW_ERASENOW = 0x0200,
RDW_FRAME = 0x0400,
RDW_NOFRAME = 0x0800,
}
export
{
BOOL GetClientRect(HWND hWnd, LPRECT lpRect);
BOOL GetWindowRect(HWND hWnd, LPRECT lpRect);
BOOL AdjustWindowRect(LPRECT lpRect, DWORD dwStyle, BOOL bMenu);
BOOL AdjustWindowRectEx(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle);
HFONT CreateFontA(int, int, int, int, int, DWORD,
DWORD, DWORD, DWORD, DWORD, DWORD,
DWORD, DWORD, LPCSTR);
HFONT CreateFontW(int, int, int, int, int, DWORD,
DWORD, DWORD, DWORD, DWORD, DWORD,
DWORD, DWORD, LPCWSTR);
}
enum
{
OUT_DEFAULT_PRECIS = 0,
OUT_STRING_PRECIS = 1,
OUT_CHARACTER_PRECIS = 2,
OUT_STROKE_PRECIS = 3,
OUT_TT_PRECIS = 4,
OUT_DEVICE_PRECIS = 5,
OUT_RASTER_PRECIS = 6,
OUT_TT_ONLY_PRECIS = 7,
OUT_OUTLINE_PRECIS = 8,
OUT_SCREEN_OUTLINE_PRECIS = 9,
CLIP_DEFAULT_PRECIS = 0,
CLIP_CHARACTER_PRECIS = 1,
CLIP_STROKE_PRECIS = 2,
CLIP_MASK = 0xf,
CLIP_LH_ANGLES = (1<<4),
CLIP_TT_ALWAYS = (2<<4),
CLIP_EMBEDDED = (8<<4),
DEFAULT_QUALITY = 0,
DRAFT_QUALITY = 1,
PROOF_QUALITY = 2,
NONANTIALIASED_QUALITY = 3,
ANTIALIASED_QUALITY = 4,
DEFAULT_PITCH = 0,
FIXED_PITCH = 1,
VARIABLE_PITCH = 2,
MONO_FONT = 8,
ANSI_CHARSET = 0,
DEFAULT_CHARSET = 1,
SYMBOL_CHARSET = 2,
SHIFTJIS_CHARSET = 128,
HANGEUL_CHARSET = 129,
GB2312_CHARSET = 134,
CHINESEBIG5_CHARSET = 136,
OEM_CHARSET = 255,
JOHAB_CHARSET = 130,
HEBREW_CHARSET = 177,
ARABIC_CHARSET = 178,
GREEK_CHARSET = 161,
TURKISH_CHARSET = 162,
VIETNAMESE_CHARSET = 163,
THAI_CHARSET = 222,
EASTEUROPE_CHARSET = 238,
RUSSIAN_CHARSET = 204,
MAC_CHARSET = 77,
BALTIC_CHARSET = 186,
FS_LATIN1 = 0x00000001L,
FS_LATIN2 = 0x00000002L,
FS_CYRILLIC = 0x00000004L,
FS_GREEK = 0x00000008L,
FS_TURKISH = 0x00000010L,
FS_HEBREW = 0x00000020L,
FS_ARABIC = 0x00000040L,
FS_BALTIC = 0x00000080L,
FS_VIETNAMESE = 0x00000100L,
FS_THAI = 0x00010000L,
FS_JISJAPAN = 0x00020000L,
FS_CHINESESIMP = 0x00040000L,
FS_WANSUNG = 0x00080000L,
FS_CHINESETRAD = 0x00100000L,
FS_JOHAB = 0x00200000L,
FS_SYMBOL = cast(int)0x80000000L,
/* Font Families */
FF_DONTCARE = (0<<4), /* Don't care or don't know. */
FF_ROMAN = (1<<4), /* Variable stroke width, serifed. */
/* Times Roman, Century Schoolbook, etc. */
FF_SWISS = (2<<4), /* Variable stroke width, sans-serifed. */
/* Helvetica, Swiss, etc. */
FF_MODERN = (3<<4), /* Constant stroke width, serifed or sans-serifed. */
/* Pica, Elite, Courier, etc. */
FF_SCRIPT = (4<<4), /* Cursive, etc. */
FF_DECORATIVE = (5<<4), /* Old English, etc. */
/* Font Weights */
FW_DONTCARE = 0,
FW_THIN = 100,
FW_EXTRALIGHT = 200,
FW_LIGHT = 300,
FW_NORMAL = 400,
FW_MEDIUM = 500,
FW_SEMIBOLD = 600,
FW_BOLD = 700,
FW_EXTRABOLD = 800,
FW_HEAVY = 900,
FW_ULTRALIGHT = FW_EXTRALIGHT,
FW_REGULAR = FW_NORMAL,
FW_DEMIBOLD = FW_SEMIBOLD,
FW_ULTRABOLD = FW_EXTRABOLD,
FW_BLACK = FW_HEAVY,
PANOSE_COUNT = 10,
PAN_FAMILYTYPE_INDEX = 0,
PAN_SERIFSTYLE_INDEX = 1,
PAN_WEIGHT_INDEX = 2,
PAN_PROPORTION_INDEX = 3,
PAN_CONTRAST_INDEX = 4,
PAN_STROKEVARIATION_INDEX = 5,
PAN_ARMSTYLE_INDEX = 6,
PAN_LETTERFORM_INDEX = 7,
PAN_MIDLINE_INDEX = 8,
PAN_XHEIGHT_INDEX = 9,
PAN_CULTURE_LATIN = 0,
}
struct RGBQUAD {
BYTE rgbBlue;
BYTE rgbGreen;
BYTE rgbRed;
BYTE rgbReserved;
}
alias RGBQUAD* LPRGBQUAD;
struct BITMAPINFOHEADER
{
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
}
alias BITMAPINFOHEADER* LPBITMAPINFOHEADER, PBITMAPINFOHEADER;
struct BITMAPINFO {
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
}
alias BITMAPINFO* LPBITMAPINFO, PBITMAPINFO;
struct PALETTEENTRY {
BYTE peRed;
BYTE peGreen;
BYTE peBlue;
BYTE peFlags;
}
alias PALETTEENTRY* PPALETTEENTRY, LPPALETTEENTRY;
struct LOGPALETTE {
WORD palVersion;
WORD palNumEntries;
PALETTEENTRY palPalEntry[1];
}
alias LOGPALETTE* PLOGPALETTE, NPLOGPALETTE, LPLOGPALETTE;
/* Pixel format descriptor */
struct PIXELFORMATDESCRIPTOR
{
WORD nSize;
WORD nVersion;
DWORD dwFlags;
BYTE iPixelType;
BYTE cColorBits;
BYTE cRedBits;
BYTE cRedShift;
BYTE cGreenBits;
BYTE cGreenShift;
BYTE cBlueBits;
BYTE cBlueShift;
BYTE cAlphaBits;
BYTE cAlphaShift;
BYTE cAccumBits;
BYTE cAccumRedBits;
BYTE cAccumGreenBits;
BYTE cAccumBlueBits;
BYTE cAccumAlphaBits;
BYTE cDepthBits;
BYTE cStencilBits;
BYTE cAuxBuffers;
BYTE iLayerType;
BYTE bReserved;
DWORD dwLayerMask;
DWORD dwVisibleMask;
DWORD dwDamageMask;
}
alias PIXELFORMATDESCRIPTOR* PPIXELFORMATDESCRIPTOR, LPPIXELFORMATDESCRIPTOR;
export
{
BOOL RoundRect(HDC, int, int, int, int, int, int);
BOOL ResizePalette(HPALETTE, UINT);
int SaveDC(HDC);
int SelectClipRgn(HDC, HRGN);
int ExtSelectClipRgn(HDC, HRGN, int);
int SetMetaRgn(HDC);
HGDIOBJ SelectObject(HDC, HGDIOBJ);
HPALETTE SelectPalette(HDC, HPALETTE, BOOL);
COLORREF SetBkColor(HDC, COLORREF);
int SetBkMode(HDC, int);
LONG SetBitmapBits(HBITMAP, DWORD, void *);
UINT SetBoundsRect(HDC, RECT *, UINT);
int SetDIBits(HDC, HBITMAP, UINT, UINT, void *, BITMAPINFO *, UINT);
int SetDIBitsToDevice(HDC, int, int, DWORD, DWORD, int,
int, UINT, UINT, void *, BITMAPINFO *, UINT);
DWORD SetMapperFlags(HDC, DWORD);
int SetGraphicsMode(HDC hdc, int iMode);
int SetMapMode(HDC, int);
HMETAFILE SetMetaFileBitsEx(UINT, BYTE *);
UINT SetPaletteEntries(HPALETTE, UINT, UINT, PALETTEENTRY *);
COLORREF SetPixel(HDC, int, int, COLORREF);
BOOL SetPixelV(HDC, int, int, COLORREF);
BOOL SetPixelFormat(HDC, int, PIXELFORMATDESCRIPTOR *);
int SetPolyFillMode(HDC, int);
BOOL StretchBlt(HDC, int, int, int, int, HDC, int, int, int, int, DWORD);
BOOL SetRectRgn(HRGN, int, int, int, int);
int StretchDIBits(HDC, int, int, int, int, int, int, int, int,
void *, BITMAPINFO *, UINT, DWORD);
int SetROP2(HDC, int);
int SetStretchBltMode(HDC, int);
UINT SetSystemPaletteUse(HDC, UINT);
int SetTextCharacterExtra(HDC, int);
COLORREF SetTextColor(HDC, COLORREF);
UINT SetTextAlign(HDC, UINT);
BOOL SetTextJustification(HDC, int, int);
BOOL UpdateColors(HDC);
}
/* Text Alignment Options */
enum
{
TA_NOUPDATECP = 0,
TA_UPDATECP = 1,
TA_LEFT = 0,
TA_RIGHT = 2,
TA_CENTER = 6,
TA_TOP = 0,
TA_BOTTOM = 8,
TA_BASELINE = 24,
TA_RTLREADING = 256,
TA_MASK = (TA_BASELINE+TA_CENTER+TA_UPDATECP+TA_RTLREADING),
}
struct POINT
{
LONG x;
LONG y;
}
alias POINT* PPOINT, NPPOINT, LPPOINT;
export
{
BOOL MoveToEx(HDC, int, int, LPPOINT);
BOOL TextOutA(HDC, int, int, LPCSTR, int);
BOOL TextOutW(HDC, int, int, LPCWSTR, int);
}
export void PostQuitMessage(int nExitCode);
export LRESULT DefWindowProcA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
export LRESULT DefWindowProcW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
export HMODULE GetModuleHandleA(LPCSTR lpModuleName);
export HMODULE GetModuleHandleW(LPCWSTR lpModuleName);
alias LRESULT function (HWND, UINT, WPARAM, LPARAM) WNDPROC;
struct WNDCLASSEXA {
UINT cbSize;
/* Win 3.x */
UINT style;
WNDPROC lpfnWndProc;
int cbClsExtra;
int cbWndExtra;
HINSTANCE hInstance;
HICON hIcon;
HCURSOR hCursor;
HBRUSH hbrBackground;
LPCSTR lpszMenuName;
LPCSTR lpszClassName;
/* Win 4.0 */
HICON hIconSm;
}
alias WNDCLASSEXA* PWNDCLASSEXA, NPWNDCLASSEXA, LPWNDCLASSEXA;
struct WNDCLASSA {
UINT style;
WNDPROC lpfnWndProc;
int cbClsExtra;
int cbWndExtra;
HINSTANCE hInstance;
HICON hIcon;
HCURSOR hCursor;
HBRUSH hbrBackground;
LPCSTR lpszMenuName;
LPCSTR lpszClassName;
}
alias WNDCLASSA* PWNDCLASSA, NPWNDCLASSA, LPWNDCLASSA;
alias WNDCLASSA WNDCLASS;
/*
* Window Styles
*/
enum : uint
{
WS_OVERLAPPED = 0x00000000,
WS_POPUP = 0x80000000,
WS_CHILD = 0x40000000,
WS_MINIMIZE = 0x20000000,
WS_VISIBLE = 0x10000000,
WS_DISABLED = 0x08000000,
WS_CLIPSIBLINGS = 0x04000000,
WS_CLIPCHILDREN = 0x02000000,
WS_MAXIMIZE = 0x01000000,
WS_CAPTION = 0x00C00000, /* WS_BORDER | WS_DLGFRAME */
WS_BORDER = 0x00800000,
WS_DLGFRAME = 0x00400000,
WS_VSCROLL = 0x00200000,
WS_HSCROLL = 0x00100000,
WS_SYSMENU = 0x00080000,
WS_THICKFRAME = 0x00040000,
WS_GROUP = 0x00020000,
WS_TABSTOP = 0x00010000,
WS_MINIMIZEBOX = 0x00020000,
WS_MAXIMIZEBOX = 0x00010000,
WS_TILED = WS_OVERLAPPED,
WS_ICONIC = WS_MINIMIZE,
WS_SIZEBOX = WS_THICKFRAME,
/*
* Common Window Styles
*/
WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX),
WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW,
WS_POPUPWINDOW = (WS_POPUP | WS_BORDER | WS_SYSMENU),
WS_CHILDWINDOW = (WS_CHILD),
}
/*
* Class styles
*/
enum
{
CS_VREDRAW = 0x0001,
CS_HREDRAW = 0x0002,
CS_KEYCVTWINDOW = 0x0004,
CS_DBLCLKS = 0x0008,
CS_OWNDC = 0x0020,
CS_CLASSDC = 0x0040,
CS_PARENTDC = 0x0080,
CS_NOKEYCVT = 0x0100,
CS_NOCLOSE = 0x0200,
CS_SAVEBITS = 0x0800,
CS_BYTEALIGNCLIENT = 0x1000,
CS_BYTEALIGNWINDOW = 0x2000,
CS_GLOBALCLASS = 0x4000,
CS_IME = 0x00010000,
}
export
{
HICON LoadIconA(HINSTANCE hInstance, LPCSTR lpIconName);
HICON LoadIconW(HINSTANCE hInstance, LPCWSTR lpIconName);
HCURSOR LoadCursorA(HINSTANCE hInstance, LPCSTR lpCursorName);
HCURSOR LoadCursorW(HINSTANCE hInstance, LPCWSTR lpCursorName);
}
enum : LPSTR
{
IDI_APPLICATION = cast(LPSTR)(32512),
IDC_ARROW = cast(LPSTR)(32512),
IDC_CROSS = cast(LPSTR)(32515),
}
/*
* Color Types
*/
enum
{
CTLCOLOR_MSGBOX = 0,
CTLCOLOR_EDIT = 1,
CTLCOLOR_LISTBOX = 2,
CTLCOLOR_BTN = 3,
CTLCOLOR_DLG = 4,
CTLCOLOR_SCROLLBAR = 5,
CTLCOLOR_STATIC = 6,
CTLCOLOR_MAX = 7,
COLOR_SCROLLBAR = 0,
COLOR_BACKGROUND = 1,
COLOR_ACTIVECAPTION = 2,
COLOR_INACTIVECAPTION = 3,
COLOR_MENU = 4,
COLOR_WINDOW = 5,
COLOR_WINDOWFRAME = 6,
COLOR_MENUTEXT = 7,
COLOR_WINDOWTEXT = 8,
COLOR_CAPTIONTEXT = 9,
COLOR_ACTIVEBORDER = 10,
COLOR_INACTIVEBORDER = 11,
COLOR_APPWORKSPACE = 12,
COLOR_HIGHLIGHT = 13,
COLOR_HIGHLIGHTTEXT = 14,
COLOR_BTNFACE = 15,
COLOR_BTNSHADOW = 16,
COLOR_GRAYTEXT = 17,
COLOR_BTNTEXT = 18,
COLOR_INACTIVECAPTIONTEXT = 19,
COLOR_BTNHIGHLIGHT = 20,
COLOR_3DDKSHADOW = 21,
COLOR_3DLIGHT = 22,
COLOR_INFOTEXT = 23,
COLOR_INFOBK = 24,
COLOR_DESKTOP = COLOR_BACKGROUND,
COLOR_3DFACE = COLOR_BTNFACE,
COLOR_3DSHADOW = COLOR_BTNSHADOW,
COLOR_3DHIGHLIGHT = COLOR_BTNHIGHLIGHT,
COLOR_3DHILIGHT = COLOR_BTNHIGHLIGHT,
COLOR_BTNHILIGHT = COLOR_BTNHIGHLIGHT,
}
enum : int
{
CW_USEDEFAULT = cast(int)0x80000000
}
/*
* Special value for CreateWindow, et al.
*/
enum : HWND
{
HWND_DESKTOP = cast(HWND)0,
}
export ATOM RegisterClassA(WNDCLASSA *lpWndClass);
export HWND CreateWindowExA(
DWORD dwExStyle,
LPCSTR lpClassName,
LPCSTR lpWindowName,
DWORD dwStyle,
int X,
int Y,
int nWidth,
int nHeight,
HWND hWndParent ,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam);
HWND CreateWindowA(
LPCSTR lpClassName,
LPCSTR lpWindowName,
DWORD dwStyle,
int X,
int Y,
int nWidth,
int nHeight,
HWND hWndParent ,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam)
{
return CreateWindowExA(0, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
}
/*
* Message structure
*/
struct MSG {
HWND hwnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
DWORD time;
POINT pt;
}
alias MSG* PMSG, NPMSG, LPMSG;
export
{
BOOL GetMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax);
BOOL TranslateMessage(MSG *lpMsg);
LONG DispatchMessageA(MSG *lpMsg);
BOOL PeekMessageA(MSG *lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg);
HWND GetFocus();
}
/* http://msdn.microsoft.com/en-us/library/windows/desktop/ms683187(v=vs.85).aspx
According to MSDN about a value returned by GetEnvironmentString:
"Treat this memory as read-only; do not modify it directly.".
So return type of GetEnvironmentStrings is changed from LPWCH (as in *.h file)
to LPCWCH. FreeEnvironmentStrings's argument type is changed correspondingly.
*/
export LPCWCH GetEnvironmentStringsW();
export BOOL FreeEnvironmentStringsW(LPCWCH lpszEnvironmentBlock);
export DWORD GetEnvironmentVariableW(LPCWSTR lpName, LPWSTR lpBuffer, DWORD nSize);
export BOOL SetEnvironmentVariableW(LPCWSTR lpName, LPCWSTR lpValue);
export DWORD ExpandEnvironmentStringsA(LPCSTR lpSrc, LPSTR lpDst, DWORD nSize);
export DWORD ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize);
export
{
BOOL IsValidCodePage(UINT CodePage);
UINT GetACP();
UINT GetOEMCP();
//BOOL GetCPInfo(UINT CodePage, LPCPINFO lpCPInfo);
BOOL IsDBCSLeadByte(BYTE TestChar);
BOOL IsDBCSLeadByteEx(UINT CodePage, BYTE TestChar);
int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cchMultiByte, LPWSTR lpWideCharStr, int cchWideChar);
int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, LPSTR lpMultiByteStr, int cchMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar);
}
export HANDLE CreateFileMappingA(HANDLE hFile, LPSECURITY_ATTRIBUTES lpFileMappingAttributes, DWORD flProtect, DWORD dwMaximumSizeHigh, DWORD dwMaximumSizeLow, LPCSTR lpName);
export HANDLE CreateFileMappingW(HANDLE hFile, LPSECURITY_ATTRIBUTES lpFileMappingAttributes, DWORD flProtect, DWORD dwMaximumSizeHigh, DWORD dwMaximumSizeLow, LPCWSTR lpName);
export BOOL GetMailslotInfo(HANDLE hMailslot, LPDWORD lpMaxMessageSize, LPDWORD lpNextSize, LPDWORD lpMessageCount, LPDWORD lpReadTimeout);
export BOOL SetMailslotInfo(HANDLE hMailslot, DWORD lReadTimeout);
export LPVOID MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap);
export LPVOID MapViewOfFileEx(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap, LPVOID lpBaseAddress);
export BOOL FlushViewOfFile(LPCVOID lpBaseAddress, SIZE_T dwNumberOfBytesToFlush);
export BOOL UnmapViewOfFile(LPCVOID lpBaseAddress);
export HGDIOBJ GetStockObject(int);
export BOOL ShowWindow(HWND hWnd, int nCmdShow);
/* Stock Logical Objects */
enum
{ WHITE_BRUSH = 0,
LTGRAY_BRUSH = 1,
GRAY_BRUSH = 2,
DKGRAY_BRUSH = 3,
BLACK_BRUSH = 4,
NULL_BRUSH = 5,
HOLLOW_BRUSH = NULL_BRUSH,
WHITE_PEN = 6,
BLACK_PEN = 7,
NULL_PEN = 8,
OEM_FIXED_FONT = 10,
ANSI_FIXED_FONT = 11,
ANSI_VAR_FONT = 12,
SYSTEM_FONT = 13,
DEVICE_DEFAULT_FONT = 14,
DEFAULT_PALETTE = 15,
SYSTEM_FIXED_FONT = 16,
DEFAULT_GUI_FONT = 17,
STOCK_LAST = 17,
}
/*
* ShowWindow() Commands
*/
enum
{ SW_HIDE = 0,
SW_SHOWNORMAL = 1,
SW_NORMAL = 1,
SW_SHOWMINIMIZED = 2,
SW_SHOWMAXIMIZED = 3,
SW_MAXIMIZE = 3,
SW_SHOWNOACTIVATE = 4,
SW_SHOW = 5,
SW_MINIMIZE = 6,
SW_SHOWMINNOACTIVE = 7,
SW_SHOWNA = 8,
SW_RESTORE = 9,
SW_SHOWDEFAULT = 10,
SW_MAX = 10,
}
struct TEXTMETRICA
{
LONG tmHeight;
LONG tmAscent;
LONG tmDescent;
LONG tmInternalLeading;
LONG tmExternalLeading;
LONG tmAveCharWidth;
LONG tmMaxCharWidth;
LONG tmWeight;
LONG tmOverhang;
LONG tmDigitizedAspectX;
LONG tmDigitizedAspectY;
BYTE tmFirstChar;
BYTE tmLastChar;
BYTE tmDefaultChar;
BYTE tmBreakChar;
BYTE tmItalic;
BYTE tmUnderlined;
BYTE tmStruckOut;
BYTE tmPitchAndFamily;
BYTE tmCharSet;
}
export BOOL GetTextMetricsA(HDC, TEXTMETRICA*);
/*
* Scroll Bar Constants
*/
enum
{ SB_HORZ = 0,
SB_VERT = 1,
SB_CTL = 2,
SB_BOTH = 3,
}
/*
* Scroll Bar Commands
*/
enum
{ SB_LINEUP = 0,
SB_LINELEFT = 0,
SB_LINEDOWN = 1,
SB_LINERIGHT = 1,
SB_PAGEUP = 2,
SB_PAGELEFT = 2,
SB_PAGEDOWN = 3,
SB_PAGERIGHT = 3,
SB_THUMBPOSITION = 4,
SB_THUMBTRACK = 5,
SB_TOP = 6,
SB_LEFT = 6,
SB_BOTTOM = 7,
SB_RIGHT = 7,
SB_ENDSCROLL = 8,
}
export int SetScrollPos(HWND hWnd, int nBar, int nPos, BOOL bRedraw);
export int GetScrollPos(HWND hWnd, int nBar);
export BOOL SetScrollRange(HWND hWnd, int nBar, int nMinPos, int nMaxPos, BOOL bRedraw);
export BOOL GetScrollRange(HWND hWnd, int nBar, LPINT lpMinPos, LPINT lpMaxPos);
export BOOL ShowScrollBar(HWND hWnd, int wBar, BOOL bShow);
export BOOL EnableScrollBar(HWND hWnd, UINT wSBflags, UINT wArrows);
/*
* LockWindowUpdate API
*/
export BOOL LockWindowUpdate(HWND hWndLock);
export BOOL ScrollWindow(HWND hWnd, int XAmount, int YAmount, RECT* lpRect, RECT* lpClipRect);
export BOOL ScrollDC(HDC hDC, int dx, int dy, RECT* lprcScroll, RECT* lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate);
export int ScrollWindowEx(HWND hWnd, int dx, int dy, RECT* prcScroll, RECT* prcClip, HRGN hrgnUpdate, LPRECT prcUpdate, UINT flags);
/*
* Virtual Keys, Standard Set
*/
enum
{ VK_LBUTTON = 0x01,
VK_RBUTTON = 0x02,
VK_CANCEL = 0x03,
VK_MBUTTON = 0x04, /* NOT contiguous with L & RBUTTON */
VK_BACK = 0x08,
VK_TAB = 0x09,
VK_CLEAR = 0x0C,
VK_RETURN = 0x0D,
VK_SHIFT = 0x10,
VK_CONTROL = 0x11,
VK_MENU = 0x12,
VK_PAUSE = 0x13,
VK_CAPITAL = 0x14,
VK_ESCAPE = 0x1B,
VK_SPACE = 0x20,
VK_PRIOR = 0x21,
VK_NEXT = 0x22,
VK_END = 0x23,
VK_HOME = 0x24,
VK_LEFT = 0x25,
VK_UP = 0x26,
VK_RIGHT = 0x27,
VK_DOWN = 0x28,
VK_SELECT = 0x29,
VK_PRINT = 0x2A,
VK_EXECUTE = 0x2B,
VK_SNAPSHOT = 0x2C,
VK_INSERT = 0x2D,
VK_DELETE = 0x2E,
VK_HELP = 0x2F,
/* VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
/* VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
VK_LWIN = 0x5B,
VK_RWIN = 0x5C,
VK_APPS = 0x5D,
VK_NUMPAD0 = 0x60,
VK_NUMPAD1 = 0x61,
VK_NUMPAD2 = 0x62,
VK_NUMPAD3 = 0x63,
VK_NUMPAD4 = 0x64,
VK_NUMPAD5 = 0x65,
VK_NUMPAD6 = 0x66,
VK_NUMPAD7 = 0x67,
VK_NUMPAD8 = 0x68,
VK_NUMPAD9 = 0x69,
VK_MULTIPLY = 0x6A,
VK_ADD = 0x6B,
VK_SEPARATOR = 0x6C,
VK_SUBTRACT = 0x6D,
VK_DECIMAL = 0x6E,
VK_DIVIDE = 0x6F,
VK_F1 = 0x70,
VK_F2 = 0x71,
VK_F3 = 0x72,
VK_F4 = 0x73,
VK_F5 = 0x74,
VK_F6 = 0x75,
VK_F7 = 0x76,
VK_F8 = 0x77,
VK_F9 = 0x78,
VK_F10 = 0x79,
VK_F11 = 0x7A,
VK_F12 = 0x7B,
VK_F13 = 0x7C,
VK_F14 = 0x7D,
VK_F15 = 0x7E,
VK_F16 = 0x7F,
VK_F17 = 0x80,
VK_F18 = 0x81,
VK_F19 = 0x82,
VK_F20 = 0x83,
VK_F21 = 0x84,
VK_F22 = 0x85,
VK_F23 = 0x86,
VK_F24 = 0x87,
VK_NUMLOCK = 0x90,
VK_SCROLL = 0x91,
/*
* VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys.
* Used only as parameters to GetAsyncKeyState() and GetKeyState().
* No other API or message will distinguish left and right keys in this way.
*/
VK_LSHIFT = 0xA0,
VK_RSHIFT = 0xA1,
VK_LCONTROL = 0xA2,
VK_RCONTROL = 0xA3,
VK_LMENU = 0xA4,
VK_RMENU = 0xA5,
VK_PROCESSKEY = 0xE5,
VK_ATTN = 0xF6,
VK_CRSEL = 0xF7,
VK_EXSEL = 0xF8,
VK_EREOF = 0xF9,
VK_PLAY = 0xFA,
VK_ZOOM = 0xFB,
VK_NONAME = 0xFC,
VK_PA1 = 0xFD,
VK_OEM_CLEAR = 0xFE,
}
export LRESULT SendMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
alias UINT function (HWND, UINT, WPARAM, LPARAM) LPOFNHOOKPROC;
struct OPENFILENAMEA {
DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
LPCSTR lpstrFilter;
LPSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPSTR lpstrFile;
DWORD nMaxFile;
LPSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPCSTR lpstrInitialDir;
LPCSTR lpstrTitle;
DWORD Flags;
WORD nFileOffset;
WORD nFileExtension;
LPCSTR lpstrDefExt;
LPARAM lCustData;
LPOFNHOOKPROC lpfnHook;
LPCSTR lpTemplateName;
}
alias OPENFILENAMEA *LPOPENFILENAMEA;
struct OPENFILENAMEW {
DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
LPCWSTR lpstrFilter;
LPWSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPWSTR lpstrFile;
DWORD nMaxFile;
LPWSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPCWSTR lpstrInitialDir;
LPCWSTR lpstrTitle;
DWORD Flags;
WORD nFileOffset;
WORD nFileExtension;
LPCWSTR lpstrDefExt;
LPARAM lCustData;
LPOFNHOOKPROC lpfnHook;
LPCWSTR lpTemplateName;
}
alias OPENFILENAMEW *LPOPENFILENAMEW;
BOOL GetOpenFileNameA(LPOPENFILENAMEA);
BOOL GetOpenFileNameW(LPOPENFILENAMEW);
BOOL GetSaveFileNameA(LPOPENFILENAMEA);
BOOL GetSaveFileNameW(LPOPENFILENAMEW);
short GetFileTitleA(LPCSTR, LPSTR, WORD);
short GetFileTitleW(LPCWSTR, LPWSTR, WORD);
enum
{
PM_NOREMOVE = 0x0000,
PM_REMOVE = 0x0001,
PM_NOYIELD = 0x0002,
}
/* Bitmap Header Definition */
struct BITMAP
{
LONG bmType;
LONG bmWidth;
LONG bmHeight;
LONG bmWidthBytes;
WORD bmPlanes;
WORD bmBitsPixel;
LPVOID bmBits;
}
alias BITMAP* PBITMAP, NPBITMAP, LPBITMAP;
export HDC CreateCompatibleDC(HDC);
export int GetObjectA(HGDIOBJ, int, LPVOID);
export int GetObjectW(HGDIOBJ, int, LPVOID);
export BOOL DeleteDC(HDC);
struct LOGFONTA
{
LONG lfHeight;
LONG lfWidth;
LONG lfEscapement;
LONG lfOrientation;
LONG lfWeight;
BYTE lfItalic;
BYTE lfUnderline;
BYTE lfStrikeOut;
BYTE lfCharSet;
BYTE lfOutPrecision;
BYTE lfClipPrecision;
BYTE lfQuality;
BYTE lfPitchAndFamily;
CHAR lfFaceName[32 ];
}
alias LOGFONTA* PLOGFONTA, NPLOGFONTA, LPLOGFONTA;
export HMENU LoadMenuA(HINSTANCE hInstance, LPCSTR lpMenuName);
export HMENU LoadMenuW(HINSTANCE hInstance, LPCWSTR lpMenuName);
export HMENU GetSubMenu(HMENU hMenu, int nPos);
export HBITMAP LoadBitmapA(HINSTANCE hInstance, LPCSTR lpBitmapName);
export HBITMAP LoadBitmapW(HINSTANCE hInstance, LPCWSTR lpBitmapName);
LPSTR MAKEINTRESOURCEA(int i) { return cast(LPSTR)(cast(DWORD)(cast(WORD)(i))); }
export HFONT CreateFontIndirectA(LOGFONTA *);
export BOOL MessageBeep(UINT uType);
export int ShowCursor(BOOL bShow);
export BOOL SetCursorPos(int X, int Y);
export HCURSOR SetCursor(HCURSOR hCursor);
export BOOL GetCursorPos(LPPOINT lpPoint);
export BOOL ClipCursor( RECT *lpRect);
export BOOL GetClipCursor(LPRECT lpRect);
export HCURSOR GetCursor();
export BOOL CreateCaret(HWND hWnd, HBITMAP hBitmap , int nWidth, int nHeight);
export UINT GetCaretBlinkTime();
export BOOL SetCaretBlinkTime(UINT uMSeconds);
export BOOL DestroyCaret();
export BOOL HideCaret(HWND hWnd);
export BOOL ShowCaret(HWND hWnd);
export BOOL SetCaretPos(int X, int Y);
export BOOL GetCaretPos(LPPOINT lpPoint);
export BOOL ClientToScreen(HWND hWnd, LPPOINT lpPoint);
export BOOL ScreenToClient(HWND hWnd, LPPOINT lpPoint);
export int MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints);
export HWND WindowFromPoint(POINT Point);
export HWND ChildWindowFromPoint(HWND hWndParent, POINT Point);
export BOOL TrackPopupMenu(HMENU hMenu, UINT uFlags, int x, int y,
int nReserved, HWND hWnd, RECT *prcRect);
align (2) struct DLGTEMPLATE {
DWORD style;
DWORD dwExtendedStyle;
WORD cdit;
short x;
short y;
short cx;
short cy;
}
alias DLGTEMPLATE *LPDLGTEMPLATEA;
alias DLGTEMPLATE *LPDLGTEMPLATEW;
alias LPDLGTEMPLATEA LPDLGTEMPLATE;
alias DLGTEMPLATE *LPCDLGTEMPLATEA;
alias DLGTEMPLATE *LPCDLGTEMPLATEW;
alias LPCDLGTEMPLATEA LPCDLGTEMPLATE;
export int DialogBoxParamA(HINSTANCE hInstance, LPCSTR lpTemplateName,
HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam);
export int DialogBoxIndirectParamA(HINSTANCE hInstance,
LPCDLGTEMPLATEA hDialogTemplate, HWND hWndParent, DLGPROC lpDialogFunc,
LPARAM dwInitParam);
enum : DWORD
{
SRCCOPY = cast(DWORD)0x00CC0020, /* dest = source */
SRCPAINT = cast(DWORD)0x00EE0086, /* dest = source OR dest */
SRCAND = cast(DWORD)0x008800C6, /* dest = source AND dest */
SRCINVERT = cast(DWORD)0x00660046, /* dest = source XOR dest */
SRCERASE = cast(DWORD)0x00440328, /* dest = source AND (NOT dest) */
NOTSRCCOPY = cast(DWORD)0x00330008, /* dest = (NOT source) */
NOTSRCERASE = cast(DWORD)0x001100A6, /* dest = (NOT src) AND (NOT dest) */
MERGECOPY = cast(DWORD)0x00C000CA, /* dest = (source AND pattern) */
MERGEPAINT = cast(DWORD)0x00BB0226, /* dest = (NOT source) OR dest */
PATCOPY = cast(DWORD)0x00F00021, /* dest = pattern */
PATPAINT = cast(DWORD)0x00FB0A09, /* dest = DPSnoo */
PATINVERT = cast(DWORD)0x005A0049, /* dest = pattern XOR dest */
DSTINVERT = cast(DWORD)0x00550009, /* dest = (NOT dest) */
BLACKNESS = cast(DWORD)0x00000042, /* dest = BLACK */
WHITENESS = cast(DWORD)0x00FF0062, /* dest = WHITE */
}
enum
{
SND_SYNC = 0x0000, /* play synchronously (default) */
SND_ASYNC = 0x0001, /* play asynchronously */
SND_NODEFAULT = 0x0002, /* silence (!default) if sound not found */
SND_MEMORY = 0x0004, /* pszSound points to a memory file */
SND_LOOP = 0x0008, /* loop the sound until next sndPlaySound */
SND_NOSTOP = 0x0010, /* don't stop any currently playing sound */
SND_NOWAIT = 0x00002000, /* don't wait if the driver is busy */
SND_ALIAS = 0x00010000, /* name is a registry alias */
SND_ALIAS_ID = 0x00110000, /* alias is a predefined ID */
SND_FILENAME = 0x00020000, /* name is file name */
SND_RESOURCE = 0x00040004, /* name is resource name or atom */
SND_PURGE = 0x0040, /* purge non-static events for task */
SND_APPLICATION = 0x0080, /* look for application specific association */
SND_ALIAS_START = 0, /* alias base */
}
export BOOL PlaySoundA(LPCSTR pszSound, HMODULE hmod, DWORD fdwSound);
export BOOL PlaySoundW(LPCWSTR pszSound, HMODULE hmod, DWORD fdwSound);
export int GetClipBox(HDC, LPRECT);
export int GetClipRgn(HDC, HRGN);
export int GetMetaRgn(HDC, HRGN);
export HGDIOBJ GetCurrentObject(HDC, UINT);
export BOOL GetCurrentPositionEx(HDC, LPPOINT);
export int GetDeviceCaps(HDC, int);
struct LOGPEN
{
UINT lopnStyle;
POINT lopnWidth;
COLORREF lopnColor;
}
alias LOGPEN* PLOGPEN, NPLOGPEN, LPLOGPEN;
enum
{
PS_SOLID = 0,
PS_DASH = 1, /* ------- */
PS_DOT = 2, /* ....... */
PS_DASHDOT = 3, /* _._._._ */
PS_DASHDOTDOT = 4, /* _.._.._ */
PS_NULL = 5,
PS_INSIDEFRAME = 6,
PS_USERSTYLE = 7,
PS_ALTERNATE = 8,
PS_STYLE_MASK = 0x0000000F,
PS_ENDCAP_ROUND = 0x00000000,
PS_ENDCAP_SQUARE = 0x00000100,
PS_ENDCAP_FLAT = 0x00000200,
PS_ENDCAP_MASK = 0x00000F00,
PS_JOIN_ROUND = 0x00000000,
PS_JOIN_BEVEL = 0x00001000,
PS_JOIN_MITER = 0x00002000,
PS_JOIN_MASK = 0x0000F000,
PS_COSMETIC = 0x00000000,
PS_GEOMETRIC = 0x00010000,
PS_TYPE_MASK = 0x000F0000,
}
export HPALETTE CreatePalette(LOGPALETTE *);
export HPEN CreatePen(int, int, COLORREF);
export HPEN CreatePenIndirect(LOGPEN *);
export HRGN CreatePolyPolygonRgn(POINT *, INT *, int, int);
export HBRUSH CreatePatternBrush(HBITMAP);
export HRGN CreateRectRgn(int, int, int, int);
export HRGN CreateRectRgnIndirect(RECT *);
export HRGN CreateRoundRectRgn(int, int, int, int, int, int);
export BOOL CreateScalableFontResourceA(DWORD, LPCSTR, LPCSTR, LPCSTR);
export BOOL CreateScalableFontResourceW(DWORD, LPCWSTR, LPCWSTR, LPCWSTR);
COLORREF RGB(int r, int g, int b)
{
return cast(COLORREF)
((cast(BYTE)r|(cast(WORD)(cast(BYTE)g)<<8))|((cast(DWORD)cast(BYTE)b)<<16));
}
export BOOL LineTo(HDC, int, int);
export BOOL DeleteObject(HGDIOBJ);
export int FillRect(HDC hDC, RECT *lprc, HBRUSH hbr);
export BOOL EndDialog(HWND hDlg, int nResult);
export HWND GetDlgItem(HWND hDlg, int nIDDlgItem);
export BOOL SetDlgItemInt(HWND hDlg, int nIDDlgItem, UINT uValue, BOOL bSigned);
export UINT GetDlgItemInt(HWND hDlg, int nIDDlgItem, BOOL *lpTranslated,
BOOL bSigned);
export BOOL SetDlgItemTextA(HWND hDlg, int nIDDlgItem, LPCSTR lpString);
export BOOL SetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPCWSTR lpString);
export UINT GetDlgItemTextA(HWND hDlg, int nIDDlgItem, LPSTR lpString, int nMaxCount);
export UINT GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount);
export BOOL CheckDlgButton(HWND hDlg, int nIDButton, UINT uCheck);
export BOOL CheckRadioButton(HWND hDlg, int nIDFirstButton, int nIDLastButton,
int nIDCheckButton);
export UINT IsDlgButtonChecked(HWND hDlg, int nIDButton);
export HWND SetFocus(HWND hWnd);
extern (C)
{
export int wsprintfA(LPSTR, LPCSTR, ...);
export int wsprintfW(LPWSTR, LPCWSTR, ...);
}
enum : uint
{
INFINITE = uint.max,
WAIT_OBJECT_0 = 0,
WAIT_ABANDONED_0 = 0x80,
WAIT_TIMEOUT = 0x102,
WAIT_IO_COMPLETION = 0xc0,
WAIT_ABANDONED = 0x80,
WAIT_FAILED = uint.max,
}
export HANDLE CreateSemaphoreA(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lInitialCount, LONG lMaximumCount, LPCTSTR lpName);
export HANDLE OpenSemaphoreA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCTSTR lpName);
export BOOL ReleaseSemaphore(HANDLE hSemaphore, LONG lReleaseCount, LPLONG lpPreviousCount);
struct COORD {
SHORT X;
SHORT Y;
}
alias COORD *PCOORD;
struct SMALL_RECT {
SHORT Left;
SHORT Top;
SHORT Right;
SHORT Bottom;
}
alias SMALL_RECT *PSMALL_RECT;
struct KEY_EVENT_RECORD {
BOOL bKeyDown;
WORD wRepeatCount;
WORD wVirtualKeyCode;
WORD wVirtualScanCode;
union {
WCHAR UnicodeChar;
CHAR AsciiChar;
}
DWORD dwControlKeyState;
}
alias KEY_EVENT_RECORD *PKEY_EVENT_RECORD;
//
// ControlKeyState flags
//
enum
{
RIGHT_ALT_PRESSED = 0x0001, // the right alt key is pressed.
LEFT_ALT_PRESSED = 0x0002, // the left alt key is pressed.
RIGHT_CTRL_PRESSED = 0x0004, // the right ctrl key is pressed.
LEFT_CTRL_PRESSED = 0x0008, // the left ctrl key is pressed.
SHIFT_PRESSED = 0x0010, // the shift key is pressed.
NUMLOCK_ON = 0x0020, // the numlock light is on.
SCROLLLOCK_ON = 0x0040, // the scrolllock light is on.
CAPSLOCK_ON = 0x0080, // the capslock light is on.
ENHANCED_KEY = 0x0100, // the key is enhanced.
}
struct MOUSE_EVENT_RECORD {
COORD dwMousePosition;
DWORD dwButtonState;
DWORD dwControlKeyState;
DWORD dwEventFlags;
}
alias MOUSE_EVENT_RECORD *PMOUSE_EVENT_RECORD;
//
// ButtonState flags
//
enum
{
FROM_LEFT_1ST_BUTTON_PRESSED = 0x0001,
RIGHTMOST_BUTTON_PRESSED = 0x0002,
FROM_LEFT_2ND_BUTTON_PRESSED = 0x0004,
FROM_LEFT_3RD_BUTTON_PRESSED = 0x0008,
FROM_LEFT_4TH_BUTTON_PRESSED = 0x0010,
}
//
// EventFlags
//
enum
{
MOUSE_MOVED = 0x0001,
DOUBLE_CLICK = 0x0002,
}
struct WINDOW_BUFFER_SIZE_RECORD {
COORD dwSize;
}
alias WINDOW_BUFFER_SIZE_RECORD *PWINDOW_BUFFER_SIZE_RECORD;
struct MENU_EVENT_RECORD {
UINT dwCommandId;
}
alias MENU_EVENT_RECORD *PMENU_EVENT_RECORD;
struct FOCUS_EVENT_RECORD {
BOOL bSetFocus;
}
alias FOCUS_EVENT_RECORD *PFOCUS_EVENT_RECORD;
struct INPUT_RECORD {
WORD EventType;
union {
KEY_EVENT_RECORD KeyEvent;
MOUSE_EVENT_RECORD MouseEvent;
WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
MENU_EVENT_RECORD MenuEvent;
FOCUS_EVENT_RECORD FocusEvent;
}
}
alias INPUT_RECORD *PINPUT_RECORD;
//
// EventType flags:
//
enum
{
KEY_EVENT = 0x0001, // Event contains key event record
MOUSE_EVENT = 0x0002, // Event contains mouse event record
WINDOW_BUFFER_SIZE_EVENT = 0x0004, // Event contains window change event record
MENU_EVENT = 0x0008, // Event contains menu event record
FOCUS_EVENT = 0x0010, // event contains focus change
}
struct CHAR_INFO {
union {
WCHAR UnicodeChar;
CHAR AsciiChar;
}
WORD Attributes;
}
alias CHAR_INFO *PCHAR_INFO;
//
// Attributes flags:
//
enum
{
FOREGROUND_BLUE = 0x0001, // text color contains blue.
FOREGROUND_GREEN = 0x0002, // text color contains green.
FOREGROUND_RED = 0x0004, // text color contains red.
FOREGROUND_INTENSITY = 0x0008, // text color is intensified.
BACKGROUND_BLUE = 0x0010, // background color contains blue.
BACKGROUND_GREEN = 0x0020, // background color contains green.
BACKGROUND_RED = 0x0040, // background color contains red.
BACKGROUND_INTENSITY = 0x0080, // background color is intensified.
}
struct CONSOLE_SCREEN_BUFFER_INFO {
COORD dwSize;
COORD dwCursorPosition;
WORD wAttributes;
SMALL_RECT srWindow;
COORD dwMaximumWindowSize;
}
alias CONSOLE_SCREEN_BUFFER_INFO *PCONSOLE_SCREEN_BUFFER_INFO;
struct CONSOLE_CURSOR_INFO {
DWORD dwSize;
BOOL bVisible;
}
alias CONSOLE_CURSOR_INFO *PCONSOLE_CURSOR_INFO;
enum
{
ENABLE_PROCESSED_INPUT = 0x0001,
ENABLE_LINE_INPUT = 0x0002,
ENABLE_ECHO_INPUT = 0x0004,
ENABLE_WINDOW_INPUT = 0x0008,
ENABLE_MOUSE_INPUT = 0x0010,
}
enum
{
ENABLE_PROCESSED_OUTPUT = 0x0001,
ENABLE_WRAP_AT_EOL_OUTPUT = 0x0002,
}
BOOL PeekConsoleInputA(HANDLE hConsoleInput, PINPUT_RECORD lpBuffer, DWORD nLength, LPDWORD lpNumberOfEventsRead);
BOOL PeekConsoleInputW(HANDLE hConsoleInput, PINPUT_RECORD lpBuffer, DWORD nLength, LPDWORD lpNumberOfEventsRead);
BOOL ReadConsoleInputA(HANDLE hConsoleInput, PINPUT_RECORD lpBuffer, DWORD nLength, LPDWORD lpNumberOfEventsRead);
BOOL ReadConsoleInputW(HANDLE hConsoleInput, PINPUT_RECORD lpBuffer, DWORD nLength, LPDWORD lpNumberOfEventsRead);
BOOL WriteConsoleInputA(HANDLE hConsoleInput, in INPUT_RECORD *lpBuffer, DWORD nLength, LPDWORD lpNumberOfEventsWritten);
BOOL WriteConsoleInputW(HANDLE hConsoleInput, in INPUT_RECORD *lpBuffer, DWORD nLength, LPDWORD lpNumberOfEventsWritten);
BOOL ReadConsoleOutputA(HANDLE hConsoleOutput, PCHAR_INFO lpBuffer, COORD dwBufferSize, COORD dwBufferCoord, PSMALL_RECT lpReadRegion);
BOOL ReadConsoleOutputW(HANDLE hConsoleOutput, PCHAR_INFO lpBuffer, COORD dwBufferSize, COORD dwBufferCoord, PSMALL_RECT lpReadRegion);
BOOL WriteConsoleOutputA(HANDLE hConsoleOutput, in CHAR_INFO *lpBuffer, COORD dwBufferSize, COORD dwBufferCoord, PSMALL_RECT lpWriteRegion);
BOOL WriteConsoleOutputW(HANDLE hConsoleOutput, in CHAR_INFO *lpBuffer, COORD dwBufferSize, COORD dwBufferCoord, PSMALL_RECT lpWriteRegion);
BOOL ReadConsoleOutputCharacterA(HANDLE hConsoleOutput, LPSTR lpCharacter, DWORD nLength, COORD dwReadCoord, LPDWORD lpNumberOfCharsRead);
BOOL ReadConsoleOutputCharacterW(HANDLE hConsoleOutput, LPWSTR lpCharacter, DWORD nLength, COORD dwReadCoord, LPDWORD lpNumberOfCharsRead);
BOOL ReadConsoleOutputAttribute(HANDLE hConsoleOutput, LPWORD lpAttribute, DWORD nLength, COORD dwReadCoord, LPDWORD lpNumberOfAttrsRead);
BOOL WriteConsoleOutputCharacterA(HANDLE hConsoleOutput, LPCSTR lpCharacter, DWORD nLength, COORD dwWriteCoord, LPDWORD lpNumberOfCharsWritten);
BOOL WriteConsoleOutputCharacterW(HANDLE hConsoleOutput, LPCWSTR lpCharacter, DWORD nLength, COORD dwWriteCoord, LPDWORD lpNumberOfCharsWritten);
BOOL WriteConsoleOutputAttribute(HANDLE hConsoleOutput, in WORD *lpAttribute, DWORD nLength, COORD dwWriteCoord, LPDWORD lpNumberOfAttrsWritten);
BOOL FillConsoleOutputCharacterA(HANDLE hConsoleOutput, CHAR cCharacter, DWORD nLength, COORD dwWriteCoord, LPDWORD lpNumberOfCharsWritten);
BOOL FillConsoleOutputCharacterW(HANDLE hConsoleOutput, WCHAR cCharacter, DWORD nLength, COORD dwWriteCoord, LPDWORD lpNumberOfCharsWritten);
BOOL FillConsoleOutputAttribute(HANDLE hConsoleOutput, WORD wAttribute, DWORD nLength, COORD dwWriteCoord, LPDWORD lpNumberOfAttrsWritten);
BOOL GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode);
BOOL GetNumberOfConsoleInputEvents(HANDLE hConsoleInput, LPDWORD lpNumberOfEvents);
BOOL GetConsoleScreenBufferInfo(HANDLE hConsoleOutput, PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo);
COORD GetLargestConsoleWindowSize( HANDLE hConsoleOutput);
BOOL GetConsoleCursorInfo(HANDLE hConsoleOutput, PCONSOLE_CURSOR_INFO lpConsoleCursorInfo);
BOOL GetNumberOfConsoleMouseButtons( LPDWORD lpNumberOfMouseButtons);
BOOL SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode);
BOOL SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput);
BOOL FlushConsoleInputBuffer(HANDLE hConsoleInput);
BOOL SetConsoleScreenBufferSize(HANDLE hConsoleOutput, COORD dwSize);
BOOL SetConsoleCursorPosition(HANDLE hConsoleOutput, COORD dwCursorPosition);
BOOL SetConsoleCursorInfo(HANDLE hConsoleOutput, in CONSOLE_CURSOR_INFO *lpConsoleCursorInfo);
BOOL ScrollConsoleScreenBufferA(HANDLE hConsoleOutput, in SMALL_RECT *lpScrollRectangle, in SMALL_RECT *lpClipRectangle, COORD dwDestinationOrigin, in CHAR_INFO *lpFill);
BOOL ScrollConsoleScreenBufferW(HANDLE hConsoleOutput, in SMALL_RECT *lpScrollRectangle, in SMALL_RECT *lpClipRectangle, COORD dwDestinationOrigin, in CHAR_INFO *lpFill);
BOOL SetConsoleWindowInfo(HANDLE hConsoleOutput, BOOL bAbsolute, in SMALL_RECT *lpConsoleWindow);
BOOL SetConsoleTextAttribute(HANDLE hConsoleOutput, WORD wAttributes);
alias BOOL function(DWORD CtrlType) PHANDLER_ROUTINE;
BOOL SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine, BOOL Add);
BOOL GenerateConsoleCtrlEvent( DWORD dwCtrlEvent, DWORD dwProcessGroupId);
BOOL AllocConsole();
BOOL FreeConsole();
DWORD GetConsoleTitleA(LPSTR lpConsoleTitle, DWORD nSize);
DWORD GetConsoleTitleW(LPWSTR lpConsoleTitle, DWORD nSize);
BOOL SetConsoleTitleA(LPCSTR lpConsoleTitle);
BOOL SetConsoleTitleW(LPCWSTR lpConsoleTitle);
BOOL ReadConsoleA(HANDLE hConsoleInput, LPVOID lpBuffer, DWORD nNumberOfCharsToRead, LPDWORD lpNumberOfCharsRead, LPVOID lpReserved);
BOOL ReadConsoleW(HANDLE hConsoleInput, LPVOID lpBuffer, DWORD nNumberOfCharsToRead, LPDWORD lpNumberOfCharsRead, LPVOID lpReserved);
BOOL WriteConsoleA(HANDLE hConsoleOutput, in void *lpBuffer, DWORD nNumberOfCharsToWrite, LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved);
BOOL WriteConsoleW(HANDLE hConsoleOutput, in void *lpBuffer, DWORD nNumberOfCharsToWrite, LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved);
HANDLE CreateConsoleScreenBuffer(DWORD dwDesiredAccess, DWORD dwShareMode, in SECURITY_ATTRIBUTES *lpSecurityAttributes, DWORD dwFlags, LPVOID lpScreenBufferData);
UINT GetConsoleCP();
BOOL SetConsoleCP( UINT wCodePageID);
UINT GetConsoleOutputCP();
BOOL SetConsoleOutputCP(UINT wCodePageID);
enum
{
CONSOLE_TEXTMODE_BUFFER = 1,
}
enum
{
SM_CXSCREEN = 0,
SM_CYSCREEN = 1,
SM_CXVSCROLL = 2,
SM_CYHSCROLL = 3,
SM_CYCAPTION = 4,
SM_CXBORDER = 5,
SM_CYBORDER = 6,
SM_CXDLGFRAME = 7,
SM_CYDLGFRAME = 8,
SM_CYVTHUMB = 9,
SM_CXHTHUMB = 10,
SM_CXICON = 11,
SM_CYICON = 12,
SM_CXCURSOR = 13,
SM_CYCURSOR = 14,
SM_CYMENU = 15,
SM_CXFULLSCREEN = 16,
SM_CYFULLSCREEN = 17,
SM_CYKANJIWINDOW = 18,
SM_MOUSEPRESENT = 19,
SM_CYVSCROLL = 20,
SM_CXHSCROLL = 21,
SM_DEBUG = 22,
SM_SWAPBUTTON = 23,
SM_RESERVED1 = 24,
SM_RESERVED2 = 25,
SM_RESERVED3 = 26,
SM_RESERVED4 = 27,
SM_CXMIN = 28,
SM_CYMIN = 29,
SM_CXSIZE = 30,
SM_CYSIZE = 31,
SM_CXFRAME = 32,
SM_CYFRAME = 33,
SM_CXMINTRACK = 34,
SM_CYMINTRACK = 35,
SM_CXDOUBLECLK = 36,
SM_CYDOUBLECLK = 37,
SM_CXICONSPACING = 38,
SM_CYICONSPACING = 39,
SM_MENUDROPALIGNMENT = 40,
SM_PENWINDOWS = 41,
SM_DBCSENABLED = 42,
SM_CMOUSEBUTTONS = 43,
SM_CXFIXEDFRAME = SM_CXDLGFRAME,
SM_CYFIXEDFRAME = SM_CYDLGFRAME,
SM_CXSIZEFRAME = SM_CXFRAME,
SM_CYSIZEFRAME = SM_CYFRAME,
SM_SECURE = 44,
SM_CXEDGE = 45,
SM_CYEDGE = 46,
SM_CXMINSPACING = 47,
SM_CYMINSPACING = 48,
SM_CXSMICON = 49,
SM_CYSMICON = 50,
SM_CYSMCAPTION = 51,
SM_CXSMSIZE = 52,
SM_CYSMSIZE = 53,
SM_CXMENUSIZE = 54,
SM_CYMENUSIZE = 55,
SM_ARRANGE = 56,
SM_CXMINIMIZED = 57,
SM_CYMINIMIZED = 58,
SM_CXMAXTRACK = 59,
SM_CYMAXTRACK = 60,
SM_CXMAXIMIZED = 61,
SM_CYMAXIMIZED = 62,
SM_NETWORK = 63,
SM_CLEANBOOT = 67,
SM_CXDRAG = 68,
SM_CYDRAG = 69,
SM_SHOWSOUNDS = 70,
SM_CXMENUCHECK = 71,
SM_CYMENUCHECK = 72,
SM_SLOWMACHINE = 73,
SM_MIDEASTENABLED = 74,
SM_CMETRICS = 75,
}
int GetSystemMetrics(int nIndex);
enum : DWORD
{
STILL_ACTIVE = (0x103),
}
DWORD TlsAlloc();
LPVOID TlsGetValue(DWORD);
BOOL TlsSetValue(DWORD, LPVOID);
BOOL TlsFree(DWORD);
// shellapi.h
HINSTANCE ShellExecuteA(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, INT nShowCmd);
HINSTANCE ShellExecuteW(HWND hwnd, LPCWSTR lpOperation, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
UINT_PTR SetTimer(HWND hwnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc);
BOOL KillTimer(HWND hwnd, UINT_PTR nIDEvent);
|
D
|
--- ltsmaster/runtime/druntime/src/core/sys/posix/setjmp.d.orig 2020-11-14 19:34:19 UTC
+++ ltsmaster/runtime/druntime/src/core/sys/posix/setjmp.d
@@ -163,6 +163,12 @@ else version( FreeBSD )
enum _JBLEN = 5;
struct _jmp_buf { c_long[_JBLEN + 1] _jb; }
}
+ else version( AArch64 )
+ {
+ enum _JBLEN = 31;
+ // __int128_t
+ struct _jmp_buf { long[2][_JBLEN + 1] _jb; };
+ }
else
static assert(0);
alias _jmp_buf[1] jmp_buf;
@@ -250,6 +256,11 @@ else version( FreeBSD )
enum _JB_SIGFLAG = 5;
struct _sigjmp_buf { c_long[_JBLEN + 1] _sjb; }
}
+ else version( AArch64 )
+ {
+ // __int128_t
+ struct _sigjmp_buf { long[2][_JBLEN + 1] _jb; };
+ }
else
static assert(0);
alias _sigjmp_buf[1] sigjmp_buf;
|
D
|
module vulkan.image.Fonts;
import vulkan.all;
final class Fonts {
private:
VulkanContext context;
VkDevice device;
string fontDirectory;
Font[string] fonts;
ulong allocationUsed;
public:
this(VulkanContext context, string fontDirectory) {
this.context = context;
this.device = context.device;
this.fontDirectory = fontDirectory;
}
void destroy() {
foreach(f; fonts.values) {
f.image.free();
}
this.log("Freed %s font image%s", fonts.length, fonts.length==1 ? "" : "s");
fonts = null;
}
Font get(string name) {
auto p = name in fonts;
if(p) return *p;
Font f = new Font;
f.name = name;
f.sdf = new SDFFont(fontDirectory, name);
f.image = createDeviceImage(f);
upload(f);
fonts[name] = f;
return f;
}
private:
DeviceImage createDeviceImage(Font f) {
if(f.sdf.getData().length > context.buffer(BufID.STAGING).size) {
throw new Error("Font '%s' (size %.2f) is larger than allocated staging size of %s MBs"
.format(f.name, f.sdf.getData().length.as!double/1.MB, context.buffer(BufID.STAGING).size / 1.MB));
}
VkFormat format = VK_FORMAT_R8_UNORM;
auto deviceImg = context.memory(MemID.LOCAL).allocImage(f.name, [f.sdf.width, f.sdf.height], VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, format);
deviceImg.createView(format, VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_COLOR_BIT);
allocationUsed += deviceImg.size;
this.log("Used %.2f MBs", allocationUsed.to!double / 1.MB);
return deviceImg;
}
void upload(Font f) {
auto data = f.sdf.getData();
auto staging = context.buffer(BufID.STAGING).alloc(data.length);
void* ptr = staging.map();
memcpy(ptr, data.ptr, data.length);
staging.flush();
f.image.write(staging);
staging.free();
}
}
|
D
|
module demu.emulator.parts.io.i8255;
import demu.emulator.machine;
import demu.emulator.parts.part;
/*** TODO: missing modes ***/
class I8255 : Part
{
alias void delegate(Port port, ubyte data, ubyte mask) WriteDelegate;
enum Port
{
A,
B,
C
}
enum Register
{
PortA,
PortB,
PortC,
Control
}
this(Machine machine, string name)
{
super(machine, name, Part.Feature.Registers);
regInfo = sRegInfo;
Reset();
}
void Reset()
{
portA = 0xff;
portB = 0xff;
portC = 0xff;
cntrl = 0x9B;
}
@property void OnWrite(WriteDelegate callback) { writeCallback = callback; }
@property WriteDelegate OnWrite() { return writeCallback; }
void SetPortBits(Port port, ubyte bits)
{
if(port == Port.A)
portA |= bits;
else if(port == Port.B)
portB |= bits;
else if(port == Port.C)
portC |= bits;
}
void ClearPortBits(Port port, ubyte bits)
{
if(port == Port.A)
portA &= ~bits;
else if(port == Port.B)
portB &= ~bits;
else if(port == Port.C)
portC &= ~bits;
}
void SetPortState(Port port, ubyte state)
{
if(port == Port.A)
portA = state;
else if(port == Port.B)
portB = state;
else if(port == Port.C)
portC = state;
}
ubyte Read(uint address)
{
ubyte state = 0xFF;
final switch(address & 0x3)
{
case 0:
// is Port A an input?
if((cntrl & 0x10) != 0)
state = portA;
break;
case 1:
// is Port B an input?
if((cntrl & 0x02) != 0)
state = portB;
break;
case 2:
// port C Lower DDR (0 = output)
if((cntrl & 0x1) != 0)
{
state &= 0xF0;
state |= portC&0x0F;
}
// port C Upper DDR (0 = output)
if((cntrl & 0x8) != 0)
{
state &= 0x0F;
state |= portC&0xF0;
}
break;
case 3:
state = cntrl | 0x80; // Bit 7 always 1
break;
}
return state;
}
void Write(uint address, ubyte value)
{
final switch(address & 0x3)
{
case 0:
// is Port A an output?
if((cntrl & 0x10) == 0)
{
portA = value;
if(writeCallback)
writeCallback(Port.A, portA, 0xFF);
}
break;
case 1:
// is Port B an output?
if((cntrl & 0x02) == 0)
{
portB = value;
if(writeCallback)
writeCallback(Port.B, portB, 0xFF);
}
break;
case 2:
// port C Lower DDR (0 = output)
if((cntrl & 0x01) == 0)
{
portC &= 0xF0;
portC |= value & 0x0F;
}
// port C Upper DDR (0 = output)
if((cntrl & 0x08) == 0)
{
portC &= 0x0F;
portC |= value & 0xF0;
}
if(writeCallback && (cntrl & 0x9) != 0x9)
writeCallback(Port.C, portC, ((cntrl & 0x1) == 0 ? 0x0F : 0) | ((cntrl & 0x8) == 0 ? 0xF0 : 0));
break;
case 3:
if((value & 0x80) != 0) // ordinary control word write
{
cntrl = value;
// when the control word is written, any port programmed as an output is initialised to 0x00
// port A DDR (0 = output)
if((cntrl & 0x10) == 0)
{
portA = 0;
if(writeCallback)
writeCallback(Port.A, portA, 0xFF);
}
// port B DDR (0 = output)
if((cntrl & 0x02) == 0)
{
portB = 0;
if(writeCallback)
writeCallback(Port.B, portB, 0xFF);
}
// port C Lower DDR (0 = output)
if((cntrl & 0x01) == 0)
portC &= 0xF0;
// port C Upper DDR (0 = output)
if((cntrl & 0x08) == 0)
portC &= 0x0F;
if(writeCallback && (cntrl & 0x9) != 0x9)
writeCallback(Port.C, portC, ((cntrl & 0x1) == 0 ? 0x0F : 0) | ((cntrl & 0x8) == 0 ? 0xF0 : 0));
// see if anything other than Mode 0
if((cntrl & 0x64) != 0)
assert(false, "Only Mode 0 for I8255 is currently supported.");
}
else
{
// Port C bit Set / Reset function
ubyte shift = (value >> 1) & 0x7; // shift amount (the bit to change is determined by the cntrl word bits 1..4)
ubyte bit = cast(ubyte)(1 << shift);
ubyte oldC = portC;
if((value & 0x1) != 0)
portC |= bit; // set the appropriate bit
else
portC &= ~bit; // clear the appropriate bit
if(portC != oldC && writeCallback && (cntrl & 0x9) != 0x9)
writeCallback(Port.C, portC, ((cntrl & 0x1) == 0 ? 0x0F : 0) | ((cntrl & 0x8) == 0 ? 0xF0 : 0));
}
break;
}
}
override uint GetRegisterValue(int reg)
{
switch(reg)
{
case Register.PortA:
return portA;
case Register.PortB:
return portB;
case Register.PortC:
return portC;
case Register.Control:
return cntrl;
default:
return 0xFF;
}
}
override void SetRegisterValue(int reg, uint value)
{
switch(reg)
{
case Register.PortA:
portA = cast(ubyte)value;
break;
case Register.PortB:
portB = cast(ubyte)value;
break;
case Register.PortC:
portC = cast(ubyte)value;
break;
case Register.Control:
cntrl = cast(ubyte)value;
break;
default:
break;
}
}
private:
ubyte portA;
ubyte portB;
ubyte portC;
ubyte cntrl;
WriteDelegate writeCallback;
}
private:
static immutable RegisterInfo[] sRegInfo =
[
RegisterInfo( "portA", 8, RegisterInfo.Flags.ReadOnly, null ),
RegisterInfo( "portB", 8, RegisterInfo.Flags.ReadOnly, null ),
RegisterInfo( "portC", 8, RegisterInfo.Flags.ReadOnly, null ),
RegisterInfo( "cntrl", 8, RegisterInfo.Flags.ReadOnly, null ),
];
|
D
|
module tango.net.device.Berkeley;
private import tango.sys.Common;
private import tango.core.Exception;
import consts=tango.sys.consts.socket;
private import rt.core.stdc.string : strlen;
private import rt.core.stdc.stringz;
/*******************************************************************************
*******************************************************************************/
enum {SOCKET_ERROR = consts.SOCKET_ERROR}
/*******************************************************************************
*******************************************************************************/
enum SocketOption
{
DEBUG = consts.SO_DEBUG , /* turn on debugging info recording */
BROADCAST = consts.SO_BROADCAST , /* permit sending of broadcast msgs */
REUSEADDR = consts.SO_REUSEADDR , /* allow local address reuse */
LINGER = consts.SO_LINGER , /* linger on close if data present */
DONTLINGER = ~(consts.SO_LINGER),
OOBINLINE = consts.SO_OOBINLINE , /* leave received OOB data in line */
ACCEPTCONN = consts.SO_ACCEPTCONN, /* socket has had listen() */
KEEPALIVE = consts.SO_KEEPALIVE , /* keep connections alive */
DONTROUTE = consts.SO_DONTROUTE , /* just use interface addresses */
TYPE = consts.SO_TYPE , /* get socket type */
/*
* Additional options, not kept in so_options.
*/
SNDBUF = consts.SO_SNDBUF, /* send buffer size */
RCVBUF = consts.SO_RCVBUF, /* receive buffer size */
ERROR = consts.SO_ERROR , /* get error status and clear */
// OptionLevel.IP settings
MULTICAST_TTL = consts.IP_MULTICAST_TTL ,
MULTICAST_LOOP = consts.IP_MULTICAST_LOOP ,
ADD_MEMBERSHIP = consts.IP_ADD_MEMBERSHIP ,
DROP_MEMBERSHIP = consts.IP_DROP_MEMBERSHIP,
// OptionLevel.TCP settings
TCP_NODELAY = consts.TCP_NODELAY ,
// Windows specifics
WIN_UPDATE_ACCEPT_CONTEXT = 0x700B,
WIN_CONNECT_TIME = 0x700C,
WIN_UPDATE_CONNECT_CONTEXT = 0x7010,
}
/*******************************************************************************
*******************************************************************************/
enum SocketOptionLevel
{
SOCKET = consts.SOL_SOCKET ,
IP = consts.IPPROTO_IP ,
TCP = consts.IPPROTO_TCP ,
UDP = consts.IPPROTO_UDP ,
}
/*******************************************************************************
*******************************************************************************/
enum SocketType
{
STREAM = consts.SOCK_STREAM , /++ sequential, reliable +/
DGRAM = consts.SOCK_DGRAM , /++ connectionless unreliable, max length +/
SEQPACKET = consts.SOCK_SEQPACKET, /++ sequential, reliable, max length +/
}
/*******************************************************************************
*******************************************************************************/
enum ProtocolType
{
IP = consts.IPPROTO_IP , /// default internet protocol (probably 4 for compatibility)
IPV4 = consts.IPPROTO_IP , /// internet protocol version 4
IPV6 = consts.IPPROTO_IPV6 , /// internet protocol version 6
ICMP = consts.IPPROTO_ICMP , /// internet control message protocol
IGMP = consts.IPPROTO_IGMP , /// internet group management protocol
TCP = consts.IPPROTO_TCP , /// transmission control protocol
PUP = consts.IPPROTO_PUP , /// PARC universal packet protocol
UDP = consts.IPPROTO_UDP , /// user datagram protocol
IDP = consts.IPPROTO_IDP , /// Xerox NS protocol
}
/*******************************************************************************
*******************************************************************************/
enum AddressFamily
{
UNSPEC = consts.AF_UNSPEC ,
UNIX = consts.AF_UNIX ,
INET = consts.AF_INET ,
IPX = consts.AF_IPX ,
APPLETALK = consts.AF_APPLETALK,
INET6 = consts.AF_INET6 ,
}
/*******************************************************************************
*******************************************************************************/
enum SocketShutdown
{
RECEIVE = consts.SHUT_RD,
SEND = consts.SHUT_WR,
BOTH = consts.SHUT_RDWR,
}
/*******************************************************************************
*******************************************************************************/
enum SocketFlags
{
NONE = 0,
OOB = consts.MSG_OOB, /// out of band
PEEK = consts.MSG_PEEK, /// only for receiving
DONTROUTE = consts.MSG_DONTROUTE, /// only for sending
NOSIGNAL = 0x4000, /// inhibit signals
}
enum AIFlags: int
{
PASSIVE = consts.AI_PASSIVE, /// get address to use bind()
CANONNAME = consts.AI_CANONNAME, /// fill ai_canonname
NUMERICHOST = consts.AI_NUMERICHOST, /// prevent host name resolution
NUMERICSERV = consts.AI_NUMERICSERV, /// prevent service name resolution valid
/// flags for addrinfo (not a standard def,
/// apps should not use it)
ALL = consts.AI_ALL, /// IPv6 and IPv4-mapped (with AI_V4MAPPED)
ADDRCONFIG = consts.AI_ADDRCONFIG, /// only if any address is assigned
V4MAPPED = consts.AI_V4MAPPED, /// accept IPv4-mapped IPv6 address special
/// recommended flags for getipnodebyname
MASK = consts.AI_MASK,
DEFAULT = consts.AI_DEFAULT,
}
enum AIError
{
BADFLAGS = consts.EAI_BADFLAGS, /// Invalid value for `ai_flags' field.
NONAME = consts.EAI_NONAME, /// NAME or SERVICE is unknown.
AGAIN = consts.EAI_AGAIN, /// Temporary failure in name resolution.
FAIL = consts.EAI_FAIL, /// Non-recoverable failure in name res.
NODATA = consts.EAI_NODATA, /// No address associated with NAME.
FAMILY = consts.EAI_FAMILY, /// `ai_family' not supported.
SOCKTYPE = consts.EAI_SOCKTYPE, /// `ai_socktype' not supported.
SERVICE = consts.EAI_SERVICE, /// SERVICE not supported for `ai_socktype'.
MEMORY = consts.EAI_MEMORY, /// Memory allocation failure.
}
enum NIFlags: int
{
MAXHOST = consts.NI_MAXHOST,
MAXSERV = consts.NI_MAXSERV,
NUMERICHOST = consts.NI_NUMERICHOST, /// Don't try to look up hostname.
NUMERICSERV = consts.NI_NUMERICSERV, /// Don't convert port number to name.
NOFQDN = consts.NI_NOFQDN, /// Only return nodename portion.
NAMEREQD = consts.NI_NAMEREQD, /// Don't return numeric addresses.
DGRAM = consts.NI_DGRAM, /// Look up UDP service rather than TCP.
}
/*******************************************************************************
conversions for network byte-order
*******************************************************************************/
version(BigEndian)
{
private ushort htons (ushort x)
{
return x;
}
private uint htonl (uint x)
{
return x;
}
}
else
{
private import tango.core.BitManip;
private ushort htons (ushort x)
{
return cast(ushort) ((x >> 8) | (x << 8));
}
private uint htonl (uint x)
{
return bswap(x);
}
}
/*******************************************************************************
*******************************************************************************/
version (Win32)
{
pragma (lib, "ws2_32.lib");
private import tango.sys.win32.WsaSock;
private typedef int socket_t = ~0;
package extern (Windows)
{
alias closesocket close;
socket_t socket(int af, int type, int protocol);
int ioctlsocket(socket_t s, int cmd, uint* argp);
uint inet_addr(char* cp);
int bind(socket_t s, Address.sockaddr* name, int namelen);
int connect(socket_t s, Address.sockaddr* name, int namelen);
int listen(socket_t s, int backlog);
socket_t accept(socket_t s, Address.sockaddr* addr, int* addrlen);
int closesocket(socket_t s);
int shutdown(socket_t s, int how);
int getpeername(socket_t s, Address.sockaddr* name, int* namelen);
int getsockname(socket_t s, Address.sockaddr* name, int* namelen);
int send(socket_t s, void* buf, int len, int flags);
int sendto(socket_t s, void* buf, int len, int flags, Address.sockaddr* to, int tolen);
int recv(socket_t s, void* buf, int len, int flags);
int recvfrom(socket_t s, void* buf, int len, int flags, Address.sockaddr* from, int* fromlen);
int select(int nfds, SocketSet.fd* readfds, SocketSet.fd* writefds, SocketSet.fd* errorfds, SocketSet.timeval* timeout);
int getsockopt(socket_t s, int level, int optname, void* optval, int* optlen);
int setsockopt(socket_t s, int level, int optname, void* optval, int optlen);
int gethostname(void* namebuffer, int buflen);
char* inet_ntoa(uint ina);
NetHost.hostent* gethostbyname(char* name);
NetHost.hostent* gethostbyaddr(void* addr, int len, int type);
/**
The gai_strerror function translates error codes of getaddrinfo,
freeaddrinfo and getnameinfo to a human readable string, suitable
for error reporting. (C) MAN
*/
//char* gai_strerror(int errcode);
/**
Given node and service, which identify an Internet host and a service,
getaddrinfo() returns one or more addrinfo structures, each of which
contains an Internet address that can be specified in a call to bind
or connect. The getaddrinfo() function combines the functionality
provided by the getservbyname and getservbyport functions into a single
interface, but unlike the latter functions, getaddrinfo() is reentrant
and allows programs to eliminate IPv4-versus-IPv6 dependencies.(C) MAN
*/
int function(char* node, char* service, Address.addrinfo* hints, Address.addrinfo** res) getaddrinfo;
/**
The freeaddrinfo() function frees the memory that was allocated for the
dynamically allocated linked list res. (C) MAN
*/
void function(Address.addrinfo *res) freeaddrinfo;
/**
The getnameinfo() function is the inverse of getaddrinfo: it converts
a socket address to a corresponding host and service, in a protocol-
independent manner. It combines the functionality of gethostbyaddr and
getservbyport, but unlike those functions, getaddrinfo is reentrant and
allows programs to eliminate IPv4-versus-IPv6 dependencies. (C) MAN
*/
int function(Address.sockaddr* sa, int salen, char* host, int hostlen, char* serv, int servlen, int flags) getnameinfo;
bool function (socket_t, uint, void*, DWORD, DWORD, DWORD, DWORD*, OVERLAPPED*) AcceptEx;
bool function (socket_t, HANDLE, DWORD, DWORD, OVERLAPPED*, void*, DWORD) TransmitFile;
bool function (socket_t, void*, int, void*, DWORD, DWORD*, OVERLAPPED*) ConnectEx;
//char* inet_ntop(int af, void *src, char *dst, int len);
}
private HMODULE lib;
static this()
{
lib = LoadLibraryA ("Ws2_32.dll");
getnameinfo = cast(typeof(getnameinfo)) GetProcAddress(lib, "getnameinfo");
if (!getnameinfo)
{
FreeLibrary (lib);
lib = LoadLibraryA ("Wship6.dll");
}
getnameinfo = cast(typeof(getnameinfo)) GetProcAddress(lib, "getnameinfo");
getaddrinfo = cast(typeof(getaddrinfo)) GetProcAddress(lib, "getaddrinfo");
freeaddrinfo = cast(typeof(freeaddrinfo)) GetProcAddress(lib, "freeaddrinfo");
if (!getnameinfo)
{
FreeLibrary (lib);
lib = null;
}
WSADATA wd = void;
if (WSAStartup (0x0202, &wd))
throw new SocketException("version of socket library is too old");
DWORD result;
Guid acceptG = {0xb5367df1, 0xcbac, 0x11cf, [0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92]};
Guid connectG = {0x25a207b9, 0xddf3, 0x4660, [0x8e,0xe9,0x76,0xe5,0x8c,0x74,0x06,0x3e]};
Guid transmitG = {0xb5367df0, 0xcbac, 0x11cf, [0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92]};
auto s = cast(HANDLE) socket (AddressFamily.INET, SocketType.STREAM, ProtocolType.TCP);
assert (s != cast(HANDLE) -1);
WSAIoctl (s, SIO_GET_EXTENSION_FUNCTION_POINTER,
&connectG, connectG.sizeof, &ConnectEx,
ConnectEx.sizeof, &result, null, null);
WSAIoctl (s, SIO_GET_EXTENSION_FUNCTION_POINTER,
&acceptG, acceptG.sizeof, &AcceptEx,
AcceptEx.sizeof, &result, null, null);
WSAIoctl (s, SIO_GET_EXTENSION_FUNCTION_POINTER,
&transmitG, transmitG.sizeof, &TransmitFile,
TransmitFile.sizeof, &result, null, null);
closesocket (cast(socket_t) s);
}
static ~this()
{
if (lib)
FreeLibrary (lib);
WSACleanup();
}
}
else
{
private import rt.core.stdc.errno_;
private typedef int socket_t = -1;
package extern (C)
{
socket_t socket(int af, int type, int protocol);
int fcntl(socket_t s, int f, ...);
uint inet_addr(char* cp);
int bind(socket_t s, Address.sockaddr* name, int namelen);
int connect(socket_t s, Address.sockaddr* name, int namelen);
int listen(socket_t s, int backlog);
socket_t accept(socket_t s, Address.sockaddr* addr, int* addrlen);
int close(socket_t s);
int shutdown(socket_t s, int how);
int getpeername(socket_t s, Address.sockaddr* name, int* namelen);
int getsockname(socket_t s, Address.sockaddr* name, int* namelen);
int send(socket_t s, void* buf, size_t len, int flags);
int sendto(socket_t s, void* buf, size_t len, int flags, Address.sockaddr* to, int tolen);
int recv(socket_t s, void* buf, size_t len, int flags);
int recvfrom(socket_t s, void* buf, size_t len, int flags, Address.sockaddr* from, int* fromlen);
int select(int nfds, SocketSet.fd* readfds, SocketSet.fd* writefds, SocketSet.fd* errorfds, SocketSet.timeval* timeout);
int getsockopt(socket_t s, int level, int optname, void* optval, int* optlen);
int setsockopt(socket_t s, int level, int optname, void* optval, int optlen);
int gethostname(void* namebuffer, int buflen);
char* inet_ntoa(uint ina);
NetHost.hostent* gethostbyname(char* name);
NetHost.hostent* gethostbyaddr(void* addr, int len, int type);
/**
Given node and service, which identify an Internet host and a service,
getaddrinfo() returns one or more addrinfo structures, each of which
contains an Internet address that can be specified in a call to bind or
connect. The getaddrinfo() function combines the functionality provided
by the getservbyname and getservbyport functions into a single interface,
but unlike the latter functions, getaddrinfo() is reentrant and allows
programs to eliminate IPv4-versus-IPv6 dependencies. (C) MAN
*/
int getaddrinfo(char* node, char* service, Address.addrinfo* hints, Address.addrinfo** res);
/**
The freeaddrinfo() function frees the memory that was allocated for the
dynamically allocated linked list res. (C) MAN
*/
void freeaddrinfo(Address.addrinfo *res);
/**
The getnameinfo() function is the inverse of getaddrinfo: it converts a socket
address to a corresponding host and service, in a protocol-independent manner.
It combines the functionality of gethostbyaddr and getservbyport, but unlike
those functions, getaddrinfo is reentrant and allows programs to eliminate
IPv4-versus-IPv6 dependencies. (C) MAN
*/
int getnameinfo(Address.sockaddr* sa, int salen, char* host, int hostlen, char* serv, int servlen, int flags);
/**
The gai_strerror function translates error codes of getaddrinfo, freeaddrinfo
and getnameinfo to a human readable string, suitable for error reporting. (C) MAN
*/
char* gai_strerror(int errcode);
char* inet_ntop(int af, void *src, char *dst, int len);
}
}
/*******************************************************************************
*******************************************************************************/
public struct Berkeley
{
socket_t sock;
SocketType type;
AddressFamily family;
ProtocolType protocol;
version (Windows)
bool synchronous;
enum : socket_t
{
INVALID_SOCKET = socket_t.init
}
enum
{
Error = -1
}
alias Error ERROR; // backward compatibility
alias noDelay setNoDelay; // backward compatibility
alias addressReuse setAddressReuse; // backward compatibility
/***********************************************************************
Configure this instance
***********************************************************************/
void open (AddressFamily family, SocketType type, ProtocolType protocol, bool create=true)
{
this.type = type;
this.family = family;
this.protocol = protocol;
if (create)
reopen;
}
/***********************************************************************
Open/reopen a native socket for this instance
***********************************************************************/
void reopen (socket_t sock = sock.init)
{
if (this.sock != sock.init)
this.detach;
if (sock is sock.init)
{
sock = cast(socket_t) socket (family, type, protocol);
if (sock is sock.init)
exception ("Unable to create socket: ");
}
this.sock = sock;
}
/***********************************************************************
calling shutdown() before this is recommended for connection-
oriented sockets
***********************************************************************/
void detach ()
{
if (sock != sock.init)
.close (sock);
sock = sock.init;
}
/***********************************************************************
Return the underlying OS handle of this Conduit
***********************************************************************/
socket_t handle ()
{
return sock;
}
/***********************************************************************
Return socket error status
***********************************************************************/
int error ()
{
int errcode;
getOption (SocketOptionLevel.SOCKET, SocketOption.ERROR, (&errcode)[0..1]);
return errcode;
}
/***********************************************************************
Return the last error
***********************************************************************/
static int lastError ()
{
version (Win32)
return WSAGetLastError();
else
return errno;
}
/***********************************************************************
Is this socket still alive? A closed socket is considered to
be dead, but a shutdown socket is still alive.
***********************************************************************/
bool isAlive ()
{
int type, typesize = type.sizeof;
return getsockopt (sock, SocketOptionLevel.SOCKET,
SocketOption.TYPE, cast(char*) &type,
&typesize) != Error;
}
/***********************************************************************
***********************************************************************/
AddressFamily addressFamily ()
{
return family;
}
/***********************************************************************
***********************************************************************/
Berkeley* bind (Address addr)
{
if(Error == .bind (sock, addr.name, addr.nameLen))
exception ("Unable to bind socket: ");
return this;
}
/***********************************************************************
***********************************************************************/
Berkeley* connect (Address to)
{
if (Error == .connect (sock, to.name, to.nameLen))
{
if (! blocking)
{
auto err = lastError;
version (Windows)
{
if (err is WSAEWOULDBLOCK)
return this;
}
else
{
if (err is EINPROGRESS)
return this;
}
}
exception ("Unable to connect socket: ");
}
return this;
}
/***********************************************************************
need to bind() first
***********************************************************************/
Berkeley* listen (int backlog)
{
if (Error == .listen (sock, backlog))
exception ("Unable to listen on socket: ");
return this;
}
/***********************************************************************
need to bind() first
***********************************************************************/
void accept (ref Berkeley target)
{
auto newsock = .accept (sock, null, null);
if (socket_t.init is newsock)
exception ("Unable to accept socket connection: ");
target.reopen (newsock);
target.protocol = protocol; //same protocol
target.family = family; //same family
target.type = type; //same type
}
/***********************************************************************
The shutdown function shuts down the connection of the socket.
Depending on the argument value, it will:
- stop receiving data for this socket. If further data
arrives, it is rejected.
- stop trying to transmit data from this socket. Also
discards any data waiting to be sent. Stop looking for
acknowledgement of data already sent; don't retransmit
if any data is lost.
***********************************************************************/
Berkeley* shutdown (SocketShutdown how)
{
.shutdown (sock, how);
return this;
}
/***********************************************************************
set linger timeout
***********************************************************************/
Berkeley* linger (int period)
{
version (Win32)
alias ushort attr;
else
alias uint attr;
union linger
{
struct {
attr l_onoff; // option on/off
attr l_linger; // linger time
};
attr[2] array; // combined
}
linger l;
l.l_onoff = 1; // option on/off
l.l_linger = cast(ushort) period; // linger time
return setOption (SocketOptionLevel.SOCKET, SocketOption.LINGER, l.array);
}
/***********************************************************************
enable/disable address reuse
***********************************************************************/
Berkeley* addressReuse (bool enabled)
{
int[1] x = enabled;
return setOption (SocketOptionLevel.SOCKET, SocketOption.REUSEADDR, x);
}
/***********************************************************************
enable/disable noDelay option (nagle)
***********************************************************************/
Berkeley* noDelay (bool enabled)
{
int[1] x = enabled;
return setOption (SocketOptionLevel.TCP, SocketOption.TCP_NODELAY, x);
}
/***********************************************************************
Helper function to handle the adding and dropping of group
membership.
***********************************************************************/
void joinGroup (IPv4Address address, bool onOff)
{
assert (address, "Socket.joinGroup :: invalid null address");
struct ip_mreq
{
uint imr_multiaddr; /* IP multicast address of group */
uint imr_interface; /* local IP address of interface */
};
ip_mreq mrq;
auto option = (onOff) ? SocketOption.ADD_MEMBERSHIP : SocketOption.DROP_MEMBERSHIP;
mrq.imr_interface = 0;
mrq.imr_multiaddr = address.sin.sin_addr;
if (.setsockopt(sock, SocketOptionLevel.IP, option, &mrq, mrq.sizeof) == Error)
exception ("Unable to perform multicast join: ");
}
/***********************************************************************
***********************************************************************/
Address newFamilyObject ()
{
if (family is AddressFamily.INET)
return new IPv4Address;
if (family is AddressFamily.INET6)
return new IPv6Address;
return new UnknownAddress;
}
/***********************************************************************
return the hostname
***********************************************************************/
static char[] hostName ()
{
char[64] name;
if(Error == .gethostname (name.ptr, name.length))
exception ("Unable to obtain host name: ");
return name [0 .. strlen(name.ptr)].dup;
}
/***********************************************************************
return the default host address (IPv4)
***********************************************************************/
static uint hostAddress ()
{
auto ih = new NetHost;
ih.getHostByName (hostName);
assert (ih.addrList.length);
return ih.addrList[0];
}
/***********************************************************************
return the remote address of the current connection (IPv4)
***********************************************************************/
Address remoteAddress ()
{
auto addr = newFamilyObject;
auto nameLen = addr.nameLen;
if(Error == .getpeername (sock, addr.name, &nameLen))
exception ("Unable to obtain remote socket address: ");
assert (addr.addressFamily is family);
return addr;
}
/***********************************************************************
return the local address of the current connection (IPv4)
***********************************************************************/
Address localAddress ()
{
auto addr = newFamilyObject;
auto nameLen = addr.nameLen;
if(Error == .getsockname (sock, addr.name, &nameLen))
exception ("Unable to obtain local socket address: ");
assert (addr.addressFamily is family);
return addr;
}
/***********************************************************************
Send data on the connection. Returns the number of bytes
actually sent, or ERROR on failure. If the socket is blocking
and there is no buffer space left, send waits.
Returns number of bytes actually sent, or -1 on error
***********************************************************************/
int send (void[] buf, SocketFlags flags=SocketFlags.NONE)
{
if (buf.length is 0)
return 0;
version (Posix)
{
auto ret = .send (sock, buf.ptr, buf.length,
SocketFlags.NOSIGNAL + cast(int) flags);
if (errno is EPIPE)
ret = -1;
return ret;
}
else
return .send (sock, buf.ptr, buf.length, cast(int) flags);
}
/***********************************************************************
Send data to a specific destination Address. If the
destination address is not specified, a connection
must have been made and that address is used. If the
socket is blocking and there is no buffer space left,
sendTo waits.
***********************************************************************/
int sendTo (void[] buf, SocketFlags flags, Address to)
{
return sendTo (buf, cast(int) flags, to.name, to.nameLen);
}
/***********************************************************************
ditto
***********************************************************************/
int sendTo (void[] buf, Address to)
{
return sendTo (buf, SocketFlags.NONE, to);
}
/***********************************************************************
ditto - assumes you connect()ed
***********************************************************************/
int sendTo (void[] buf, SocketFlags flags=SocketFlags.NONE)
{
return sendTo (buf, cast(int) flags, null, 0);
}
/***********************************************************************
Send data to a specific destination Address. If the
destination address is not specified, a connection
must have been made and that address is used. If the
socket is blocking and there is no buffer space left,
sendTo waits.
***********************************************************************/
private int sendTo (void[] buf, int flags, Address.sockaddr* to, int len)
{
if (buf.length is 0)
return 0;
version (Posix)
{
auto ret = .sendto (sock, buf.ptr, buf.length,
flags | SocketFlags.NOSIGNAL, to, len);
if (errno is EPIPE)
ret = -1;
return ret;
}
else
return .sendto (sock, buf.ptr, buf.length, flags, to, len);
}
/***********************************************************************
Receive data on the connection. Returns the number of
bytes actually received, 0 if the remote side has closed
the connection, or ERROR on failure. If the socket is blocking,
receive waits until there is data to be received.
Returns number of bytes actually received, 0 on connection
closure, or -1 on error
***********************************************************************/
int receive (void[] buf, SocketFlags flags=SocketFlags.NONE)
{
if (!buf.length)
badArg ("Socket.receive :: target buffer has 0 length");
return .recv(sock, buf.ptr, buf.length, cast(int)flags);
}
/***********************************************************************
Receive data and get the remote endpoint Address. Returns
the number of bytes actually received, 0 if the remote side
has closed the connection, or ERROR on failure. If the socket
is blocking, receiveFrom waits until there is data to be
received.
***********************************************************************/
int receiveFrom (void[] buf, SocketFlags flags, Address from)
{
if (!buf.length)
badArg ("Socket.receiveFrom :: target buffer has 0 length");
assert(from.addressFamily() == family);
int nameLen = from.nameLen();
return .recvfrom(sock, buf.ptr, buf.length, cast(int)flags, from.name(), &nameLen);
}
/***********************************************************************
ditto
***********************************************************************/
int receiveFrom (void[] buf, Address from)
{
return receiveFrom(buf, SocketFlags.NONE, from);
}
/***********************************************************************
ditto - assumes you connect()ed
***********************************************************************/
int receiveFrom (void[] buf, SocketFlags flags = SocketFlags.NONE)
{
if (!buf.length)
badArg ("Socket.receiveFrom :: target buffer has 0 length");
return .recvfrom(sock, buf.ptr, buf.length, cast(int)flags, null, null);
}
/***********************************************************************
returns the length, in bytes, of the actual result - very
different from getsockopt()
***********************************************************************/
int getOption (SocketOptionLevel level, SocketOption option, void[] result)
{
int len = cast(int) result.length;
if(Error == .getsockopt (sock, cast(int)level, cast(int)option, result.ptr, &len))
exception ("Unable to get socket option: ");
return len;
}
/***********************************************************************
***********************************************************************/
Berkeley* setOption (SocketOptionLevel level, SocketOption option, void[] value)
{
if(Error == .setsockopt (sock, cast(int)level, cast(int)option, value.ptr, cast(int) value.length))
exception ("Unable to set socket option: ");
return this;
}
/***********************************************************************
getter
***********************************************************************/
bool blocking()
{
version (Windows)
return synchronous;
else
return !(fcntl(sock, F_GETFL, 0) & O_NONBLOCK);
}
/***********************************************************************
setter
***********************************************************************/
void blocking(bool yes)
{
version (Windows)
{
uint num = !yes;
if(ioctlsocket(sock, consts.FIONBIO, &num) is ERROR)
exception("Unable to set socket blocking: ");
synchronous = yes;
}
else
{
int x = fcntl(sock, F_GETFL, 0);
if(yes)
x &= ~O_NONBLOCK;
else
x |= O_NONBLOCK;
if(fcntl(sock, F_SETFL, x) is ERROR)
exception("Unable to set socket blocking: ");
}
return;
}
/***********************************************************************
***********************************************************************/
static void exception (char[] msg)
{
throw new SocketException (msg ~ SysError.lookup(lastError));
}
/***********************************************************************
***********************************************************************/
protected static void badArg (char[] msg)
{
throw new IllegalArgumentException (msg);
}
}
/*******************************************************************************
*******************************************************************************/
public abstract class Address
{
public struct sockaddr
{
ushort sa_family;
char[14] sa_data = 0;
}
struct addrinfo
{
int ai_flags;
int ai_family;
int ai_socktype;
int ai_protocol;
uint ai_addrlen;
version (freebsd)
{
char* ai_canonname;
sockaddr* ai_addr;
}
else
{
sockaddr* ai_addr;
char* ai_canonname;
}
addrinfo* ai_next;
}
abstract sockaddr* name();
abstract int nameLen();
/***********************************************************************
Internal usage
***********************************************************************/
private static ushort ntohs (ushort x)
{
return htons(x);
}
/***********************************************************************
Internal usage
***********************************************************************/
private static uint ntohl (uint x)
{
return htonl(x);
}
/***********************************************************************
Internal usage
***********************************************************************/
private static char[] fromInt (char[] tmp, int i)
{
size_t j = tmp.length;
do {
tmp[--j] = cast(char)(i % 10 + '0');
} while (i /= 10);
return tmp [j .. $];
}
/***********************************************************************
Internal usage
***********************************************************************/
private static int toInt (char[] s)
{
uint value;
foreach (c; s)
if (c >= '0' && c <= '9')
value = value * 10 + (c - '0');
else
break;
return value;
}
/***********************************************************************
Tango: added this common function
***********************************************************************/
static void exception (char[] msg)
{
throw new SocketException (msg);
}
/***********************************************************************
Address factory
***********************************************************************/
static Address create (sockaddr* sa)
{
switch (sa.sa_family)
{
case AddressFamily.INET:
return new IPv4Address(sa);
case AddressFamily.INET6:
return new IPv6Address(sa);
default:
return null;
}
}
/***********************************************************************
***********************************************************************/
static Address resolve (char[] host, char[] service = null,
AddressFamily af = AddressFamily.UNSPEC,
AIFlags flags = cast(AIFlags)0)
{
return resolveAll (host, service, af, flags)[0];
}
/***********************************************************************
***********************************************************************/
static Address resolve (char[] host, ushort port,
AddressFamily af = AddressFamily.UNSPEC,
AIFlags flags = cast(AIFlags)0)
{
return resolveAll (host, port, af, flags)[0];
}
/***********************************************************************
***********************************************************************/
static Address[] resolveAll (char[] host, char[] service = null,
AddressFamily af = AddressFamily.UNSPEC,
AIFlags flags = cast(AIFlags)0)
{
Address[] retVal;
version (Win32)
{
if (!getaddrinfo)
{ // *old* windows, let's fall back to NetHost
uint port = toInt(service);
if (flags & AIFlags.PASSIVE && host is null)
return [new IPv4Address(0, port)];
auto nh = new NetHost;
if (!nh.getHostByName(host))
throw new AddressException("couldn't resolve " ~ host);
retVal.length = nh.addrList.length;
foreach (i, addr; nh.addrList)
retVal[i] = new IPv4Address(addr, port);
return retVal;
}
}
addrinfo* info;
addrinfo hints;
hints.ai_flags = flags;
hints.ai_family = (flags & AIFlags.PASSIVE && af == AddressFamily.UNSPEC) ? AddressFamily.INET6 : af;
hints.ai_socktype = SocketType.STREAM;
int error = getaddrinfo(toStringz(host), service.length == 0 ? null : toStringz(service), &hints, &info);
if (error != 0)
throw new AddressException("couldn't resolve " ~ host);
retVal.length = 16;
retVal.length = 0;
while (info)
{
if (auto addr = create(info.ai_addr))
retVal ~= addr;
info = info.ai_next;
}
freeaddrinfo (info);
return retVal;
}
/***********************************************************************
***********************************************************************/
static Address[] resolveAll (char host[], ushort port,
AddressFamily af = AddressFamily.UNSPEC,
AIFlags flags = cast(AIFlags)0)
{
char[16] buf;
return resolveAll (host, fromInt(buf, port), af, flags);
}
/***********************************************************************
***********************************************************************/
static Address passive (char[] service,
AddressFamily af = AddressFamily.UNSPEC,
AIFlags flags = cast(AIFlags)0)
{
return resolve (null, service, af, flags | AIFlags.PASSIVE);
}
/***********************************************************************
***********************************************************************/
static Address passive (ushort port, AddressFamily af = AddressFamily.UNSPEC,
AIFlags flags = cast(AIFlags)0)
{
return resolve (null, port, af, flags | AIFlags.PASSIVE);
}
/***********************************************************************
***********************************************************************/
char[] toAddrString()
{
char[1025] host = void;
// Getting name info. Don't look up hostname, returns
// numeric name. (NIFlags.NUMERICHOST)
getnameinfo (name, nameLen, host.ptr, host.length, null, 0, NIFlags.NUMERICHOST);
return fromStringz (host.ptr);
}
/***********************************************************************
***********************************************************************/
char[] toPortString()
{
char[32] service = void;
// Getting name info. Returns port number, not
// service name. (NIFlags.NUMERICSERV)
getnameinfo (name, nameLen, null, 0, service.ptr, service.length, NIFlags.NUMERICSERV);
foreach (i, c; service)
if (c == '\0')
return service[0..i].dup;
return null;
}
/***********************************************************************
***********************************************************************/
char[] toString()
{
return toAddrString ~ ":" ~ toPortString;
}
/***********************************************************************
***********************************************************************/
AddressFamily addressFamily()
{
return cast(AddressFamily)name.sa_family;
}
}
/*******************************************************************************
*******************************************************************************/
public class UnknownAddress : Address
{
sockaddr sa;
/***********************************************************************
***********************************************************************/
sockaddr* name()
{
return &sa;
}
/***********************************************************************
***********************************************************************/
int nameLen()
{
return sa.sizeof;
}
/***********************************************************************
***********************************************************************/
AddressFamily addressFamily()
{
return cast(AddressFamily) sa.sa_family;
}
/***********************************************************************
***********************************************************************/
char[] toString()
{
return "Unknown";
}
}
/*******************************************************************************
*******************************************************************************/
public class IPv4Address : Address
{
/***********************************************************************
***********************************************************************/
enum
{
ADDR_ANY = 0,
ADDR_NONE = cast(uint)-1,
PORT_ANY = 0
}
/***********************************************************************
***********************************************************************/
struct sockaddr_in
{
version (freebsd)
{
ubyte sin_len;
ubyte sinfamily = AddressFamily.INET;
}
else
{
ushort sinfamily = AddressFamily.INET;
}
ushort sin_port;
uint sin_addr; //in_addr
char[8] sin_zero = 0;
}
static assert(sockaddr_in.sizeof is 16);
private sockaddr_in sin;
/***********************************************************************
***********************************************************************/
package this ()
{
}
/***********************************************************************
***********************************************************************/
this (ushort port)
{
sin.sin_addr = 0; //any, "0.0.0.0"
sin.sin_port = htons(port);
}
/***********************************************************************
***********************************************************************/
this (uint addr, ushort port)
{
sin.sin_addr = htonl(addr);
sin.sin_port = htons(port);
}
/***********************************************************************
-port- can be PORT_ANY
-addr- is an IP address or host name
***********************************************************************/
this (char[] addr, ushort port = PORT_ANY)
{
uint uiaddr = parse(addr);
if (ADDR_NONE == uiaddr)
{
auto ih = new NetHost;
if (!ih.getHostByName(addr))
{
char[16] tmp = void;
exception ("Unable to resolve "~addr~":"~fromInt(tmp, port));
}
uiaddr = ih.addrList[0];
}
sin.sin_addr = htonl(uiaddr);
sin.sin_port = htons(port);
}
/***********************************************************************
***********************************************************************/
this (sockaddr* addr)
{
sin = *(cast(sockaddr_in*)addr);
}
/***********************************************************************
***********************************************************************/
sockaddr* name()
{
return cast(sockaddr*)&sin;
}
/***********************************************************************
***********************************************************************/
int nameLen()
{
return sin.sizeof;
}
/***********************************************************************
***********************************************************************/
AddressFamily addressFamily()
{
return AddressFamily.INET;
}
/***********************************************************************
***********************************************************************/
ushort port()
{
return ntohs(sin.sin_port);
}
/***********************************************************************
***********************************************************************/
uint addr()
{
return ntohl(sin.sin_addr);
}
/***********************************************************************
***********************************************************************/
char[] toAddrString()
{
char[16] buff = 0;
version (Windows)
return fromStringz(inet_ntoa(sin.sin_addr)).dup;
else
return fromStringz(inet_ntop(AddressFamily.INET, &sin.sin_addr, buff.ptr, 16)).dup;
}
/***********************************************************************
***********************************************************************/
char[] toPortString()
{
char[8] _port;
return fromInt (_port, port()).dup;
}
/***********************************************************************
***********************************************************************/
char[] toString()
{
return toAddrString() ~ ":" ~ toPortString();
}
/***********************************************************************
-addr- is an IP address in the format "a.b.c.d"
returns ADDR_NONE on failure
***********************************************************************/
static uint parse(char[] addr)
{
char[64] tmp;
synchronized (IPv4Address.classinfo)
return ntohl(inet_addr(toStringz(addr, tmp)));
}
}
/*******************************************************************************
*******************************************************************************/
debug(UnitTest)
{
unittest
{
IPv4Address ia = new IPv4Address("63.105.9.61", 80);
assert(ia.toString() == "63.105.9.61:80");
}
}
/*******************************************************************************
IPv6 is the next-generation Internet Protocol version
designated as the successor to IPv4, the first
implementation used in the Internet that is still in
dominant use currently.
More information: http://ipv6.com/
IPv6 supports 128-bit address space as opposed to 32-bit
address space of IPv4.
IPv6 is written as 8 blocks of 4 octal digits (16 bit)
separated by a colon (":"). Zero block can be replaced by "::".
For example:
---
0000:0000:0000:0000:0000:0000:0000:0001
is equal
::0001
is equal
::1
is analogue IPv4 127.0.0.1
0000:0000:0000:0000:0000:0000:0000:0000
is equal
::
is analogue IPv4 0.0.0.0
2001:cdba:0000:0000:0000:0000:3257:9652
is equal
2001:cdba::3257:9652
IPv4 address can be submitted through IPv6 as ::ffff:xx.xx.xx.xx,
where xx.xx.xx.xx 32-bit IPv4 addresses.
::ffff:51b0:ec6d
is equal
::ffff:81.176.236.109
is analogue IPv4 81.176.236.109
The URL for the IPv6 address will be of the form:
http://[2001:cdba:0000:0000:0000:0000:3257:9652]/
If needed to specify a port, it will be listed after the
closing square bracket followed by a colon.
http://[2001:cdba:0000:0000:0000:0000:3257:9652]:8080/
address: "2001:cdba:0000:0000:0000:0000:3257:9652"
port: 8080
IPv6Address can be used as well as IPv4Address.
scope addr = new IPv6Address(8080);
address: "::"
port: 8080
scope addr_2 = new IPv6Address("::1", 8081);
address: "::1"
port: 8081
scope addr_3 = new IPv6Address("::1");
address: "::1"
port: PORT_ANY
Also in the IPv6Address constructor can specify the service name
or port as string
scope addr_3 = new IPv6Address("::", "ssh");
address: "::"
port: 22 (ssh service port)
scope addr_4 = new IPv6Address("::", "8080");
address: "::"
port: 8080
*******************************************************************************/
class IPv6Address : Address
{
protected:
/***********************************************************************
***********************************************************************/
struct sockaddr_in6
{
ushort sin_family;
ushort sin_port;
uint sin6_flowinfo;
ubyte[16] sin6_addr;
uint sin6_scope_id;
}
sockaddr_in6 sin;
/***********************************************************************
***********************************************************************/
this ()
{
}
/***********************************************************************
***********************************************************************/
this (sockaddr* sa)
{
sin = *cast(sockaddr_in6*)sa;
}
/***********************************************************************
***********************************************************************/
sockaddr* name()
{
return cast(sockaddr*)&sin;
}
/***********************************************************************
***********************************************************************/
int nameLen()
{
return sin.sizeof;
}
public:
/***********************************************************************
***********************************************************************/
AddressFamily addressFamily()
{
return AddressFamily.INET6;
}
const ushort PORT_ANY = 0;
/***********************************************************************
***********************************************************************/
ushort port()
{
return ntohs(sin.sin_port);
}
/***********************************************************************
Create IPv6Address with zero address
***********************************************************************/
this (int port)
{
this ("::", port);
}
/***********************************************************************
-port- can be PORT_ANY
-addr- is an IP address or host name
***********************************************************************/
this (char[] addr, int port = PORT_ANY)
{
version (Win32)
{
if (!getaddrinfo)
exception ("This platform does not support IPv6.");
}
addrinfo* info;
addrinfo hints;
hints.ai_family = AddressFamily.INET6;
int error = getaddrinfo((addr ~ '\0').ptr, null, &hints, &info);
if (error != 0)
exception("failed to create IPv6Address: ");
sin = *cast(sockaddr_in6*)(info.ai_addr);
sin.sin_port = htons(cast(ushort) port);
}
/***********************************************************************
-service- can be a port number or service name
-addr- is an IP address or host name
***********************************************************************/
this (char[] addr, char[] service)
{
version (Win32)
{
if(! getaddrinfo)
exception ("This platform does not support IPv6.");
}
addrinfo* info;
addrinfo hints;
hints.ai_family = AddressFamily.INET6;
int error = getaddrinfo((addr ~ '\0').ptr, (service ~ '\0').ptr, &hints, &info);
if (error != 0)
exception ("failed to create IPv6Address: ");
sin = *cast(sockaddr_in6*)(info.ai_addr);
}
/***********************************************************************
***********************************************************************/
ubyte[] addr()
{
return sin.sin6_addr;
}
/***********************************************************************
***********************************************************************/
version (Posix)
char[] toAddrString()
{
char[100] buff = 0;
return fromStringz(inet_ntop(AddressFamily.INET6, &sin.sin6_addr, buff.ptr, 100)).dup;
}
/***********************************************************************
***********************************************************************/
char[] toPortString()
{
char[8] _port;
return fromInt (_port, port()).dup;
}
/***********************************************************************
***********************************************************************/
char[] toString()
{
return "[" ~ toAddrString ~ "]:" ~ toPortString;
}
}
/*******************************************************************************
*******************************************************************************/
debug(UnitTest)
{
unittest
{
IPv6Address ia = new IPv6Address("7628:0d18:11a3:09d7:1f34:8a2e:07a0:765d", 8080);
assert(ia.toString() == "[7628:d18:11a3:9d7:1f34:8a2e:7a0:765d]:8080");
//assert(ia.toString() == "[7628:0d18:11a3:09d7:1f34:8a2e:07a0:765d]:8080");
}
}
/*******************************************************************************
*******************************************************************************/
public class NetHost
{
char[] name;
char[][] aliases;
uint[] addrList;
/***********************************************************************
***********************************************************************/
struct hostent
{
char* h_name;
char** h_aliases;
version (Win32)
{
short h_addrtype;
short h_length;
}
else
{
int h_addrtype;
int h_length;
}
char** h_addr_list;
char* h_addr()
{
return h_addr_list[0];
}
}
/***********************************************************************
***********************************************************************/
protected void validHostent(hostent* he)
{
if (he.h_addrtype != AddressFamily.INET || he.h_length != 4)
throw new SocketException("Address family mismatch.");
}
/***********************************************************************
***********************************************************************/
void populate (hostent* he)
{
int i;
char* p;
name = fromStringz(he.h_name);
for (i = 0;; i++)
{
p = he.h_aliases[i];
if(!p)
break;
}
if (i)
{
aliases = new char[][i];
for (i = 0; i != aliases.length; i++)
aliases[i] = fromStringz(he.h_aliases[i]);
}
else
aliases = null;
for (i = 0;; i++)
{
p = he.h_addr_list[i];
if(!p)
break;
}
if (i)
{
addrList = new uint[i];
for (i = 0; i != addrList.length; i++)
addrList[i] = Address.ntohl(*(cast(uint*)he.h_addr_list[i]));
}
else
addrList = null;
}
/***********************************************************************
***********************************************************************/
bool getHostByName(char[] name)
{
char[1024] tmp;
synchronized (NetHost.classinfo)
{
auto he = gethostbyname(toStringz(name, tmp));
if(!he)
return false;
validHostent(he);
populate(he);
}
return true;
}
/***********************************************************************
***********************************************************************/
bool getHostByAddr(uint addr)
{
uint x = htonl(addr);
synchronized (NetHost.classinfo)
{
auto he = gethostbyaddr(&x, 4, cast(int)AddressFamily.INET);
if(!he)
return false;
validHostent(he);
populate(he);
}
return true;
}
/***********************************************************************
***********************************************************************/
//shortcut
bool getHostByAddr(char[] addr)
{
char[64] tmp;
synchronized (NetHost.classinfo)
{
uint x = inet_addr(toStringz(addr, tmp));
auto he = gethostbyaddr(&x, 4, cast(int)AddressFamily.INET);
if(!he)
return false;
validHostent(he);
populate(he);
}
return true;
}
}
/*******************************************************************************
*******************************************************************************/
debug (UnitTest)
{
extern (C) int printf(char*, ...);
unittest
{
NetHost ih = new NetHost;
ih.getHostByName(Berkeley.hostName());
assert(ih.addrList.length > 0);
IPv4Address ia = new IPv4Address(ih.addrList[0], IPv4Address.PORT_ANY);
printf("addrses: %x %x\n", ia.toAddrString.ptr, ih.name.ptr);
printf("IP address = %.*s\nname = %.*s\n", ia.toAddrString(), ih.name);
foreach(int i, char[] s; ih.aliases)
{
printf("aliases[%d] = %.*s\n", i, s);
}
printf("---\n");
assert(ih.getHostByAddr(ih.addrList[0]));
printf("name = %.*s\n", ih.name);
foreach(int i, char[] s; ih.aliases)
{
printf("aliases[%d] = %.*s\n", i, s);
}
}
}
/*******************************************************************************
a set of sockets for Berkeley.select()
*******************************************************************************/
public class SocketSet
{
import rt.core.stdc.config;
struct timeval
{
c_long seconds, microseconds;
}
private uint nbytes; //Win32: excludes uint.size "count"
private byte* buf;
struct fd {}
version(Windows)
{
uint count()
{
return *(cast(uint*)buf);
}
void count(int setter)
{
*(cast(uint*)buf) = setter;
}
socket_t* first()
{
return cast(socket_t*)(buf + uint.sizeof);
}
}
else version (Posix)
{
import tango.core.BitManip;
uint nfdbits;
socket_t _maxfd = 0;
uint fdelt(socket_t s)
{
return cast(uint)s / nfdbits;
}
uint fdmask(socket_t s)
{
return 1 << cast(uint)s % nfdbits;
}
uint* first()
{
return cast(uint*)buf;
}
public socket_t maxfd()
{
return _maxfd;
}
}
public:
this (uint max)
{
version(Win32)
{
nbytes = max * socket_t.sizeof;
buf = (new byte[nbytes + uint.sizeof]).ptr;
count = 0;
}
else version (Posix)
{
if (max <= 32)
nbytes = 32 * uint.sizeof;
else
nbytes = max * uint.sizeof;
buf = (new byte[nbytes]).ptr;
nfdbits = nbytes * 8;
//clear(); //new initializes to 0
}
else
{
static assert(0);
}
}
this (SocketSet o)
{
nbytes = o.nbytes;
auto size = nbytes;
version (Win32)
size += uint.sizeof;
version (Posix)
{
nfdbits = o.nfdbits;
_maxfd = o._maxfd;
}
auto b = new byte[size];
b[] = o.buf[0..size];
buf = b.ptr;
}
this()
{
version(Win32)
{
this(64);
}
else version (Posix)
{
this(32);
}
else
{
static assert(0);
}
}
SocketSet dup()
{
return new SocketSet (this);
}
SocketSet reset()
{
version(Win32)
{
count = 0;
}
else version (Posix)
{
buf[0 .. nbytes] = 0;
_maxfd = 0;
}
else
{
static assert(0);
}
return this;
}
void add(socket_t s)
in
{
version(Win32)
{
assert(count < max); //added too many sockets; specify a higher max in the constructor
}
}
body
{
version(Win32)
{
uint c = count;
first[c] = s;
count = c + 1;
}
else version (Posix)
{
if (s > _maxfd)
_maxfd = s;
bts(cast(size_t*)&first[fdelt(s)], cast(size_t)s % nfdbits);
}
else
{
static assert(0);
}
}
void add(Berkeley* s)
{
add(s.handle);
}
void remove(socket_t s)
{
version(Win32)
{
uint c = count;
socket_t* start = first;
socket_t* stop = start + c;
for(; start != stop; start++)
{
if(*start == s)
goto found;
}
return; //not found
found:
for(++start; start != stop; start++)
{
*(start - 1) = *start;
}
count = c - 1;
}
else version (Posix)
{
btr(cast(size_t*)&first[fdelt(s)], cast(size_t)s % nfdbits);
// If we're removing the biggest file descriptor we've
// entered so far we need to recalculate this value
// for the socket set.
if (s == _maxfd)
{
while (--_maxfd >= 0)
{
if (isSet(_maxfd))
{
break;
}
}
}
}
else
{
static assert(0);
}
}
void remove(Berkeley* s)
{
remove(s.handle);
}
int isSet(socket_t s)
{
version(Win32)
{
socket_t* start = first;
socket_t* stop = start + count;
for(; start != stop; start++)
{
if(*start == s)
return true;
}
return false;
}
else version (Posix)
{
//return bt(cast(uint*)&first[fdelt(s)], cast(uint)s % nfdbits);
int index = cast(uint)s % nfdbits;
return (cast(uint*)&first[fdelt(s)])[index / (uint.sizeof*8)] & (1 << (index & ((uint.sizeof*8) - 1)));
}
else
{
static assert(0);
}
}
int isSet(Berkeley* s)
{
return isSet(s.handle);
}
uint max()
{
return nbytes / socket_t.sizeof;
}
fd* toFd_set()
{
return cast(fd*)buf;
}
/***********************************************************************
SocketSet's are updated to include only those sockets which an
event occured.
Returns the number of events, 0 on timeout, or -1 on error
for a connect()ing socket, writeability means connected
for a listen()ing socket, readability means listening
Winsock: possibly internally limited to 64 sockets per set
***********************************************************************/
static int select (SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, timeval* tv)
{
fd* fr, fw, fe;
//make sure none of the SocketSet's are the same object
if (checkRead)
{
assert(checkRead !is checkWrite);
assert(checkRead !is checkError);
}
if (checkWrite)
assert(checkWrite !is checkError);
version(Win32)
{
//Windows has a problem with empty fd_set's that aren't null
fr = (checkRead && checkRead.count()) ? checkRead.toFd_set() : null;
fw = (checkWrite && checkWrite.count()) ? checkWrite.toFd_set() : null;
fe = (checkError && checkError.count()) ? checkError.toFd_set() : null;
}
else
{
fr = checkRead ? checkRead.toFd_set() : null;
fw = checkWrite ? checkWrite.toFd_set() : null;
fe = checkError ? checkError.toFd_set() : null;
}
int result;
version(Win32)
{
while ((result = .select (socket_t.max - 1, fr, fw, fe, tv)) == -1)
{
if(WSAGetLastError() != WSAEINTR)
break;
}
}
else version (Posix)
{
socket_t maxfd = 0;
if (checkRead)
maxfd = checkRead.maxfd;
if (checkWrite && checkWrite.maxfd > maxfd)
maxfd = checkWrite.maxfd;
if (checkError && checkError.maxfd > maxfd)
maxfd = checkError.maxfd;
while ((result = .select (maxfd + 1, fr, fw, fe, tv)) == -1)
{
if(errno() != EINTR)
break;
}
}
else
{
static assert(0);
}
return result;
}
/***********************************************************************
select with specified timeout
***********************************************************************/
static int select (SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, long microseconds)
{
timeval tv = {
cast(typeof(timeval.seconds)) (microseconds / 1000000),
cast(typeof(timeval.microseconds)) (microseconds % 1000000)
};
return select (checkRead, checkWrite, checkError, &tv);
}
/***********************************************************************
select with maximum timeout
***********************************************************************/
static int select (SocketSet checkRead, SocketSet checkWrite, SocketSet checkError)
{
return select (checkRead, checkWrite, checkError, null);
}
}
|
D
|
/// Generate by tools
module net.sbbi.upnp.devices.UPNPRootDevice;
import java.lang.exceptions;
public class UPNPRootDevice
{
public this()
{
implMissing();
}
}
|
D
|
INSTANCE Mod_7163_ASS_Kamal_NW (Npc_Default)
{
// ------ NSC ------
name = "Kamal";
guild = GIL_OUT;
id = 7163;
voice = 11;
flags = 2;
npctype = NPCTYPE_MAIN;
// ------ Attribute ------
B_SetAttributesToChapter (self, 4);
// ------ Kampf-Taktik ------
fight_tactic = FAI_HUMAN_NORMAL;
// ------ Equippte Waffen ------
// ------ Inventory ------
B_CreateAmbientInv (self);
// ------ visuals ------
B_SetNpcVisual (self, MALE, "Hum_Head_Bald", Face_B_Normal_Sharky, BodyTex_B,ITAR_Assassine_02);
Mdl_SetModelFatness (self,0);
//Mdl_ApplyOverlayMds (self, "Humans_Relaxed.mds");
// ------ NSC-relevante Talente vergeben ------
B_GiveNpcTalents (self);
// ------ Kampf-Talente ------
B_SetFightSkills (self, 50);
// ------ TA anmelden ------
daily_routine = Rtn_Start_7163;
};
FUNC VOID Rtn_Start_7163()
{
TA_Potion_Alchemy (07,20,01,20,"WP_ASSASSINE_53");
TA_Potion_Alchemy (01,20,07,20,"WP_ASSASSINE_53");
};
FUNC VOID Rtn_Plaudern_7163()
{
TA_Smalltalk (07,20,01,20,"WP_ASSASSINE_67");
TA_Smalltalk (01,20,07,20,"WP_ASSASSINE_67");
};
FUNC VOID Rtn_Schlacht_7163()
{
TA_Stand_Guarding (07,20,01,20,"WP_ASSASSINE_51");
TA_Stand_Guarding (01,20,07,20,"WP_ASSASSINE_51");
};
FUNC VOID Rtn_Tot_7163()
{
TA_Stand_Guarding (07,20,01,20,"TOT");
TA_Stand_Guarding (01,20,07,20,"TOT");
};
|
D
|
// Runen
// Paladin Runen
//********************************************************************************************
//Joly: Macht die Runen nicht zu teuer, es sind Produktionsitems -> EXPLOID!!!!!!!!!!!
//********************************************************************************************
const string Name_PaladinSpell = "Czar Paladyna";
const int Value_Ru_PalLight = 500;
const int Value_Ru_PalLightHeal = 500;
const int Value_Ru_PalHolyBolt = 500;
const int Value_Ru_PalMediumHeal = 500;
const int Value_Ru_PalRepelEvil = 500;
const int Value_Ru_PalFullHeal = 500;
const int Value_Ru_PalDestroyEvil = 500;
//********************************************************************************************
//Joly: Macht die Runen nicht zu teuer, es sind Produktionsitems -> EXPLOID!!!!!!!!!!!
//********************************************************************************************
// Kreis 1
const int Value_Ru_Light = 300;// Lehrer Parlan
const int Value_Ru_Firebolt = 300;// Lehrer Hyglas
const int Value_Ru_Zap = 300;// Lehrer Marduk
const int Value_Ru_LightHeal = 300;// Lehrer Parlan
const int Value_Ru_SumGobSkel = 300;// Lehrer Karras
// Kreis 2
const int Value_Ru_InstantFireball = 600;// Lehrer Hyglas
const int Value_Ru_Icebolt = 600;// Lehrer Marduk
const int Value_Ru_SumWolf = 600;// Lehrer Karras
const int Value_Ru_Windfist = 600;
const int Value_Ru_Sleep = 600;
// Kreis 3
const int Value_Ru_MediumHeal = 900;// Lehrer Parlan
const int Value_Ru_SumSkel = 900;// Lehrer Karras
const int Value_Ru_Fear = 900;
const int Value_Ru_IceCube = 900;// Lehrer Marduk
const int Value_Ru_ThunderBall = 900;// Lehrer Marduk
const int Value_Ru_Firestorm = 900;// Lehrer Hyglas
// Kreis 4
const int Value_Ru_SumGol = 900;// Lehrer Karras
const int Value_Ru_HarmUndead = 900;
const int Value_Ru_LightningFlash = 900;// Lehrer Marduk
const int Value_Ru_ChargeFireball = 900;// Lehrer Hyglas
// Kreis 5
const int Value_Ru_IceWave = 1200;// Lehrer Marduk
const int Value_Ru_SumDemon = 1200;// Lehrer Karras
const int Value_Ru_FullHeal = 1200;// Lehrer Parlan
const int Value_Ru_Pyrokinesis = 1200;// Lehrer Hyglas
// Kreis 6
const int Value_Ru_Firerain = 1500;// Lehrer Hyglas
const int Value_Ru_BreathOfDeath = 1500;
const int Value_Ru_MassDeath = 1500;
const int Value_Ru_MasterOfDisaster = 1500;
const int Value_Ru_ArmyOfDarkness = 1500;// Lehrer Karras
const int Value_Ru_Shrink = 1500;
//TeleportRunen
const int Value_Ru_PalTeleportSecret = 500;
const int Value_Ru_TeleportSeaport = 500;
const int Value_Ru_TeleportMonastery = 500;
const int Value_Ru_TeleportFarm = 500;
const int Value_Ru_TeleportXardas = 500;
const int Value_Ru_TeleportPassNW = 500;
const int Value_Ru_TeleportPassOW = 500;
const int Value_Ru_TeleportOC = 500;
const int Value_Ru_TeleportOWDemonTower = 500;
const int Value_Ru_TeleportTaverne = 500;
const int Value_Ru_Teleport_3 = 500;
/*******************************************************************************************/
INSTANCE ItRu_PalLight (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_PalLight;
visual = "ItRu_PalLight.3ds";
material = MAT_STONE;
spell = SPL_PalLight;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_PalLight;
TEXT [0] = Name_PaladinSpell ;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_Cost_PalLight;
TEXT [2] = NAME_Duration;
COUNT [2] = SPL_Duration_PalLIGHT;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_PalLightHeal (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_PalLightHeal;
visual = "ItRu_PalLightHeal.3ds";
material = MAT_STONE;
spell = SPL_PalLightHeal;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_PalLightHeal;
TEXT [0] = Name_PaladinSpell ;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_Cost_PalLightHeal;
TEXT [2] = NAME_HealingPerCast;
COUNT [2] = SPL_Heal_PalLightHeal;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_PalMediumHeal (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_PalMediumHeal;
visual = "ItRu_PalMediumHeal.3ds";
material = MAT_STONE;
spell = SPL_PalMediumHeal;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_PalMediumHeal;
TEXT [0] = Name_PaladinSpell ;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_Cost_PalMediumHeal;
TEXT [2] = NAME_HealingPerCast;
COUNT [2] = SPL_Heal_PalMediumHeal;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_PalFullHeal (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_PalFullHeal;
visual = "ItRu_PalFullHeal.3ds";
material = MAT_STONE;
spell = SPL_PalFullHeal;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_PalFullHeal;
TEXT [0] = Name_PaladinSpell ;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_Cost_PalFullHeal;
TEXT [2] = NAME_HealingPerCast;
COUNT [2] = SPL_Heal_PalFullHeal;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_PalHolyBolt (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_PalHolyBolt;
visual = "ItRu_PalHolyBolt.3DS";
material = MAT_STONE;
spell = SPL_PalHolyBolt;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_PalHolyBolt;
TEXT [0] = Name_PaladinSpell ;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_Cost_PalHolyBolt;
TEXT [2] = NAME_Dam_Magic;
COUNT [2] = SPL_Damage_PalHolyBolt;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_PalRepelEvil (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_PalRepelEvil;
visual = "ItRu_PalRepelEvil.3DS";
material = MAT_STONE;
spell = SPL_PalRepelEvil;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_PalRepelEvil;
TEXT [0] = Name_PaladinSpell ;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_Cost_PalRepelEvil;
TEXT [2] = NAME_Dam_Magic;
COUNT [2] = SPL_Damage_PalRepelEvil;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_PalDestroyEvil (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_PalDestroyEvil;
visual = "ItRu_PalDestroyEvil.3DS";
material = MAT_STONE;
spell = SPL_PalDestroyEvil;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_PalDestroyEvil;
TEXT [0] = Name_PaladinSpell ;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_Cost_PalDestroyEvil;
TEXT [2] = NAME_Dam_Magic;
COUNT [2] = SPL_Damage_PalDestroyEvil;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_PalTeleportSecret (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_PalTeleportSecret;
visual = "ItRu_PalTeleportSecret.3DS";
material = MAT_STONE;
spell = SPL_PalTeleportSecret;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_PalTeleportSecret;
TEXT [0] = Name_PaladinSpell ;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_TELEPORT;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_TeleportSeaport (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_TeleportSeaport;
visual = "ItRu_TeleportSeaport.3ds";
material = MAT_STONE;
spell = SPL_TeleportSeaport;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_TeleportSeaport;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_TELEPORT;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_TeleportMonastery (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_TeleportMonastery;
visual = "ItRu_TeleportMonastery.3ds";
material = MAT_STONE;
spell = SPL_TeleportMonastery;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_TeleportMonastery;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_TELEPORT;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_TeleportFarm (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_TeleportFarm;
visual = "ItRu_TeleportFarm.3ds";
material = MAT_STONE;
spell = SPL_TeleportFarm;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_TeleportFarm;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_TELEPORT;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_TeleportXardas (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_TeleportXardas;
visual = "ItRu_TeleportXardas.3ds";
material = MAT_STONE;
spell = SPL_TeleportXardas;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_TeleportXardas;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_TELEPORT;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_TeleportPassNW (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_TeleportPassNW;
visual = "ItRu_TeleportPassNW.3ds";
material = MAT_STONE;
spell = SPL_TeleportPassNW;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_TeleportPassNW;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_TELEPORT;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_TeleportPassOW (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_TeleportPassOW;
visual = "ItRu_TeleportPassOW.3ds";
material = MAT_STONE;
spell = SPL_TeleportPassOW;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_TeleportPassOW;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_TELEPORT;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_TeleportOC (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_TeleportOC;
visual = "ItRu_TeleportOC.3ds";
material = MAT_STONE;
spell = SPL_TeleportOC;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_TeleportOC;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_TELEPORT;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*
instance ItRu_TeleportOC (C_Item)
{
name = "Teleportacja Do Zamku";
mainflag = ITEM_KAT_DOCS;
flags = ITEM_MISSION|ITEM_MULTI;
value = 50;
visual = "ItRu_TeleportOC.3ds";
material = MAT_LEATHER;
scemeName = "MAP";
on_state[0] = Use_ItRu_TeleportOC;
description = name;
TEXT[5] = NAME_Value;
COUNT[5] = value;
};
func void Use_ItRu_TeleportOC ()
{
AI_Teleport (self, "OC_MAGE_CENTER");
AI_PlayAni (self, "T_HEASHOOT_2_STAND" );
};
*/
/*******************************************************************************************/
INSTANCE ItRu_TeleportOWDemonTower (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_TeleportOWDemonTower;
visual = "ItRu_Teleport_2.3ds";
material = MAT_STONE;
spell = SPL_TeleportOWDemonTower;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_TeleportOWDemonTower;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_TELEPORT;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
INSTANCE ItRu_TeleportTaverne (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_TeleportTaverne;
visual = "ItRu_Teleport_2.3ds";
material = MAT_STONE;
spell = SPL_TeleportTaverne;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_TeleportTaverne;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_TELEPORT;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_Teleport_3 (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_Teleport_3;
visual = "ItRu_Teleport_3.3ds";
material = MAT_STONE;
spell = SPL_Teleport_3;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_Teleport_3;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_TELEPORT;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
// Kreis 1
INSTANCE ItRu_Light (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_Light;
visual = "ItRu_Light.3ds";
material = MAT_STONE;
spell = SPL_LIGHT;
mag_circle = 1;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_LIGHT;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_LIGHT;
TEXT [2] = NAME_Duration;
COUNT [2] = SPL_Duration_LIGHT;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_FireBolt (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_Firebolt;
visual = "ItRu_FireBolt.3DS";
material = MAT_STONE;
spell = SPL_FIREBOLT;
mag_circle = 1;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER_YELLOW";
description = NAME_SPL_Firebolt;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_FIREBOLT;
TEXT [2] = NAME_Dam_Magic;
COUNT [2] = SPL_DAMAGE_FIREBOLT;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_Zap (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_Zap;
visual = "ItRu_Zap.3DS";
material = MAT_STONE;
mag_circle = 1;
spell = SPL_Zap;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_Zap;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_Cost_Zap;
TEXT [2] = NAME_Dam_Magic;
COUNT [2] = SPL_DAMAGE_ZAP;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_LightHeal (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_LightHeal;
visual = "ItRu_LightHeal.3ds";
material = MAT_STONE;
spell = SPL_LightHeal;
mag_circle = 1;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_LightHeal;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_Cost_LightHeal;
TEXT [2] = NAME_HealingPerCast;
COUNT [2] = SPL_Heal_LightHeal;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_SumGobSkel (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_SumGobSkel;
visual = "ItRu_SumGobSkel.3DS";
material = MAT_STONE;
spell = SPL_SummonGoblinSkeleton;
mag_circle = 1;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_SummonGoblinSkeleton;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_Cost_SummonGoblinSkeleton;
TEXT [2] = "Niespokojne kości";
TEXT [3] = "martwych goblinów.";
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
// Kreis 2
INSTANCE ItRu_InstantFireball (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_InstantFireball;
visual = "ItRu_InstantFireball.3DS";
material = MAT_STONE;
mag_circle = 2;
spell = SPL_InstantFireball;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER_YELLOW";
description = NAME_SPL_InstantFireball;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_InstantFireball;
TEXT [2] = NAME_Dam_Magic;
COUNT [2] = SPL_DAMAGE_InstantFireball;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_Icebolt (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_Icebolt;
visual = "ItRu_Icebolt.3ds";
material = MAT_STONE;
spell = SPL_Icebolt;
mag_circle = 2;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER_BLUE";
description = NAME_SPL_Icebolt;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_Icebolt;
TEXT [2] = NAME_Dam_Magic;
COUNT [2] = SPL_DAMAGE_Icebolt;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_SumWolf (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_SumWolf;
visual = "ItRu_SumWolf.3DS";
material = MAT_STONE;
spell = SPL_SummonWolf;
mag_circle = 2;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_SummonWolf;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_Cost_SummonWolf;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_Windfist (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_Windfist;
visual = "ItRu_Windfist.3ds";
material = MAT_STONE;
spell = SPL_WINDFIST;
mag_circle = 2;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_WINDFIST;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_MinManakosten;
COUNT [1] = STEP_WindFist;
TEXT [2] = NAME_ManakostenMax;
COUNT [2] = SPL_COST_WINDFIST;
TEXT [3] = NAME_Addon_Damage_Min;
count [3] = SPL_Damage_Windfist;
TEXT [4] = NAME_Damage_Max;
COUNT [4] = (SPL_Damage_Windfist*4);
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_Sleep (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_Sleep;
visual = "ItRu_Sleep.3ds";
material = MAT_STONE;
spell = SPL_SLEEP;
mag_circle = 2;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_Sleep;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_SLEEP;
TEXT [2] = NAME_SEC_Duration;
COUNT [2] = SPL_TIME_Sleep;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
// Kreis 3
INSTANCE ItRu_MediumHeal (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_MediumHeal;
visual = "ItRu_MediumHeal.3ds";
material = MAT_STONE;
spell = SPL_MediumHeal;
mag_circle = 3;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_MediumHeal;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_Cost_MediumHeal;
TEXT [2] = NAME_HealingPerCast;
COUNT [2] = SPL_Heal_MediumHeal;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_LightningFlash (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_LightningFlash;
visual = "ItRu_LightningFlash.3DS";
material = MAT_STONE;
mag_circle = 4;
spell = SPL_LightningFlash;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_LightningFlash;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_Cost_LightningFlash;
TEXT [2] = NAME_Dam_Magic;
COUNT [2] = SPL_Damage_LightningFlash;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_ChargeFireball (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_ChargeFireball;
visual = "ItRu_ChargeFireball.3DS";
material = MAT_STONE;
mag_circle = 4;
spell = SPL_ChargeFireball;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER_YELLOW";
description = NAME_SPL_ChargeFireball;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_MinManakosten;
COUNT [1] = STEP_ChargeFireball;
TEXT [2] = NAME_ManakostenMax;
COUNT [2] = SPL_COST_ChargeFireball;
TEXT [3] = NAME_Addon_Damage_Min;
count [3] = SPL_Damage_ChargeFireball;
TEXT [4] = NAME_Damage_Max;
COUNT [4] = (SPL_Damage_ChargeFireball*4);
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_SumSkel (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_SumSkel;
visual = "ItRu_SumSkel.3DS";
material = MAT_STONE;
spell = SPL_SUMMONSKELETON;
mag_circle = 3;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_SummonSkeleton;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_SUMMONSKELETON;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_Fear (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_Fear;
visual = "ItRu_Fear.3DS";
material = MAT_STONE;
mag_circle = 3;
spell = SPL_FEAR;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_Fear;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_FEAR;
TEXT [2] = NAME_Sec_Duration;
COUNT [2] = SPL_TIME_Fear;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_IceCube (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_IceCube;
visual = "ItRu_IceCube.3ds";
material = MAT_STONE;
spell = SPL_ICECUBE;
mag_circle = 3;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER_BLUE";
description = NAME_SPL_IceCube;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_ICECUBE;
TEXT [2] = NAME_Damage;
COUNT [2] = 60;
TEXT [3] = NAME_Sec_Duration;
COUNT [3] = SPL_TIME_FREEZE;
TEXT [4] = NAME_DamagePerSec;
COUNT [4] = SPL_FREEZE_DAMAGE;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
// Kreis 4
INSTANCE ItRu_ThunderBall (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_ThunderBall;
visual = "ItRu_ThunderBall.3ds";
material = MAT_STONE;
spell = SPL_ChargeZap;
mag_circle = 3;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_ChargeZap;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_MinManakosten;
COUNT [1] = STEP_ChargeZap;
TEXT [2] = NAME_ManakostenMax;
COUNT [2] = SPL_COST_ChargeZap;
TEXT [3] = NAME_Addon_Damage_Min;
count [3] = SPL_Damage_ChargeZap;
TEXT [4] = NAME_Damage_Max;
COUNT [4] = (SPL_Damage_ChargeZap*4);
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_SumGol (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_SumGol;
visual = "ItRu_SumGol.3DS";
material = MAT_STONE;
spell = SPL_SummonGolem;
mag_circle = 4;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_SummonGolem;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_Cost_SummonGolem;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_HarmUndead (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_HarmUndead;
visual = "ItRu_HarmUndead.3DS";
material = MAT_STONE;
spell = SPL_DESTROYUNDEAD;
mag_circle = 4;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_DestroyUndead;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_DESTROYUNDEAD;
TEXT [2] = NAME_Dam_Magic;
COUNT [2] = SPL_DAMAGE_DESTROYUNDEAD;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_Pyrokinesis (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_Pyrokinesis;
visual = "ItRu_Pyrokinesis.3ds";
material = MAT_STONE;
spell = SPL_PYROKINESIS;
mag_circle = 5;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER_YELLOW";
description = NAME_SPL_Pyrokinesis;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_MinManakosten;
COUNT [1] = STEP_Firestorm;
TEXT [2] = NAME_ManakostenMax;
COUNT [2] = SPL_COST_Firestorm;
TEXT [3] = NAME_Addon_Damage_Min;
count [3] = SPL_Damage_Firestorm;
TEXT [4] = NAME_Damage_Max;
COUNT [4] = (SPL_Damage_Firestorm*4);
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
// Kreis 5
INSTANCE ItRu_Firestorm (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_Firestorm;
visual = "ItRu_Firestorm.3ds";
material = MAT_STONE;
spell = SPL_FIRESTORM;
mag_circle = 3;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER_YELLOW";
description = NAME_SPL_Firestorm;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_INSTANTFIRESTORM;
TEXT [2] = NAME_Dam_Magic;
COUNT [2] = SPL_DAMAGE_INSTANTFIRESTORM;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_IceWave (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_IceWave;
visual = "ItRu_IceWave.3ds";
material = MAT_STONE;
spell = SPL_ICEWAVE;
mag_circle = 5;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER_BLUE";
description = NAME_SPL_IceWave;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_Cost_IceWave;
TEXT [2] = NAME_Damage;
COUNT [2] = 60;
TEXT [3] = NAME_Sec_Duration;
COUNT [3] = SPL_TIME_FREEZE;
TEXT [4] = NAME_DamagePerSec;
COUNT [4] = SPL_FREEZE_DAMAGE;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_SumDemon (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_SumDemon;
visual = "ItRu_SumDemon.3DS";
material = MAT_STONE;
spell = SPL_SUMMONDEMON;
mag_circle = 5;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_SummonDemon;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_SUMMONDEMON;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_FullHeal (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_FullHeal;
visual = "ItRu_FullHeal.3ds";
material = MAT_STONE;
spell = SPL_FullHeal;
mag_circle = 5;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_FullHeal;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_Cost_FullHeal;
TEXT [2] = NAME_HealingPerCast;
COUNT [2] = SPL_Heal_FullHeal;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
// Kreis 6
INSTANCE ItRu_Firerain (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_Firerain;
visual = "ItRu_Firerain.3ds";
material = MAT_STONE;
spell = SPL_FIRERAIN;
mag_circle = 6;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER_YELLOW";
description = NAME_SPL_Firerain;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_FIRERAIN;
TEXT [2] = NAME_Dam_Magic;
COUNT [2] = SPL_DAMAGE_FIRERAIN;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_BreathOfDeath (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_BreathOfDeath;
visual = "ItRu_BreathOfDeath.3ds";
material = MAT_STONE;
spell = SPL_BREATHOFDEATH;
mag_circle = 6;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER_RED";
description = NAME_SPL_BreathOfDeath;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_BREATHOFDEATH;
TEXT [2] = NAME_Dam_Magic;
COUNT [2] = SPL_DAMAGE_BREATHOFDEATH;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_MassDeath (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = ITEM_MISSION;
value = Value_Ru_MassDeath;
visual = "ItRu_MassDeath.3ds";
material = MAT_STONE;
spell = SPL_MASSDEATH;
mag_circle = 6;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER_RED";
description = NAME_SPL_MassDeath;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_MASSDEATH;
TEXT [2] = NAME_Dam_Magic;
COUNT [2] = SPL_DAMAGE_MASSDEATH;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_MasterOfDisaster (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_MasterOfDisaster;
visual = "ItRu_MasterOfDesaster.3DS";
material = MAT_STONE;
spell = SPL_MasterOfDisaster;
mag_circle = 6;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER_RED";
description = NAME_SPL_MasterOfDisaster;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_MasterOfDisaster;
TEXT [2] = NAME_Dam_Magic;
COUNT [2] = SPL_DAMAGE_MasterOfDisaster;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_ArmyOfDarkness (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_ArmyofDarkness;
visual = "ItRu_ArmyOfDarkness.3DS";
material = MAT_STONE;
spell = SPL_ARMYOFDARKNESS;
mag_circle = 6;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER_RED";
description = NAME_SPL_ArmyOfDarkness;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_ARMYOFDARKNESS;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
INSTANCE ItRu_Shrink (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = Value_Ru_Shrink;
visual = "ItRu_Shrink.3DS";
material = MAT_STONE;
spell = SPL_SHRINK;
mag_circle = 6;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = NAME_SPL_Shrink;
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_SHRINK;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
/*******************************************************************************************/
//#########################
//NPC Spell
//#########################
INSTANCE ItRu_Deathbolt (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = 0;
visual = "ItRu_PalRepelEvil.3DS";
material = MAT_STONE;
spell = SPL_Deathbolt;
mag_circle = 6;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = "Pocisk śmierci";
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_Deathbolt;
TEXT [2] = NAME_Dam_Magic;
COUNT [2] = SPL_DAMAGE_Deathbolt;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
INSTANCE ItRu_Deathball (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = 0;
visual = "ItRu_PalRepelEvil.3DS";
material = MAT_STONE;
spell = SPL_Deathball;
mag_circle = 6;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = "Śmiertelna kula";
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_Deathball;
TEXT [2] = NAME_Dam_Magic;
COUNT [2] = SPL_DAMAGE_Deathball;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
INSTANCE ItRu_Concussionbolt (C_Item)
{
name = NAME_Rune;
mainflag = ITEM_KAT_RUNE;
flags = 0;
value = 0;
visual = "ItRu_PalRepelEvil.3DS";
material = MAT_STONE;
spell = SPL_Concussionbolt;
mag_circle = 6;
wear = WEAR_EFFECT;
effect = "SPELLFX_WEAKGLIMMER";
description = "Pocisk nieprzytomności";
TEXT [0] = NAME_Mag_Circle;
COUNT [0] = mag_circle;
TEXT [1] = NAME_Manakosten;
COUNT [1] = SPL_COST_Concussionbolt;
TEXT [2] = NAME_Dam_Magic;
COUNT [2] = SPL_DAMAGE_Concussionbolt;
TEXT [5] = NAME_Value;
COUNT [5] = value;
};
|
D
|
/**
Json
Copyright: (c) Enalye 2017
License: Zlib
Authors: Enalye
*/
module magia.core.json;
public import std.json;
import std.conv;
import std.regex, std.path;
import std.stdio;
/// Transform your path in a system agnostic path.
string convertPathToExport(string path) {
return replaceAll(path, regex(r"\\/|/|\\"), "/");
}
/// Transform the path in your path system.
string convertPathToImport(string path) {
return replaceAll(path, regex(r"\\/|/|\\"), dirSeparator);
}
/// Does the node exist ?
bool hasJson(JSONValue json, string tag) {
return ((tag in json.object) !is null);
}
/// Get the node
JSONValue getJson(JSONValue json, string tag) {
if ((tag in json.object) is null)
throw new Exception("JSON: \'" ~ tag ~ "\'' does not exist in JSON.");
return json.object[tag];
}
JSONValue[] getJsonArray(JSONValue json, string tag) {
if ((tag in json.object) is null)
throw new Exception("JSON: \'" ~ tag ~ "\'' does not exist in JSON.");
return json.object[tag].array;
}
string[] getJsonArrayStr(JSONValue json, string tag) {
if ((tag in json.object) is null)
throw new Exception("JSON: \'" ~ tag ~ "\'' does not exist in JSON.");
string[] array;
foreach (JSONValue value; json.object[tag].array)
array ~= value.str;
return array;
}
string[] getJsonArrayStr(JSONValue json, string tag, string[] defValue) {
if ((tag in json.object) is null)
return defValue;
string[] array;
foreach (JSONValue value; json.object[tag].array)
array ~= value.str;
return array;
}
int[] getJsonArrayInt(JSONValue json, string tag) {
if ((tag in json.object) is null)
throw new Exception("JSON: \'" ~ tag ~ "\'' does not exist in JSON.");
int[] array;
foreach (JSONValue value; json.object[tag].array) {
if (value.type() == JSONType.integer)
array ~= cast(int) value.integer;
else
array ~= to!int(value.str);
}
return array;
}
int[] getJsonArrayInt(JSONValue json, string tag, int[] defValue) {
if ((tag in json.object) is null)
return defValue;
int[] array;
foreach (JSONValue value; json.object[tag].array) {
if (value.type() == JSONType.integer)
array ~= cast(int) value.integer;
else
array ~= to!int(value.str);
}
return array;
}
float[] getJsonArrayFloat(JSONValue json, string tag) {
if ((tag in json.object) is null)
throw new Exception("JSON: \'" ~ tag ~ "\'' does not exist in JSON.");
float[] array;
foreach (JSONValue value; json.object[tag].array) {
if (value.type() == JSONType.integer)
array ~= value.floating;
else
array ~= to!float(value.str);
}
return array;
}
float[] getJsonArrayFloat(JSONValue json, string tag, float[] defValue) {
if ((tag in json.object) is null)
return defValue;
float[] array;
foreach (JSONValue value; json.object[tag].array) {
if (value.type() == JSONType.integer)
array ~= value.floating;
else
array ~= to!float(value.str);
}
return array;
}
string getJsonStr(JSONValue json, string tag) {
if ((tag in json.object) is null)
throw new Exception("JSON: \'" ~ tag ~ "\'' does not exist in JSON.");
return json.object[tag].str;
}
string getJsonStr(JSONValue json, string tag, string defValue) {
if ((tag in json.object) is null)
return defValue;
return json.object[tag].str;
}
int getJsonInt(JSONValue json, string tag) {
if ((tag in json.object) is null)
throw new Exception("JSON: \'" ~ tag ~ "\'' does not exist in JSON.");
JSONValue value = json.object[tag];
switch (value.type()) with (JSONType) {
case integer:
return cast(int) value.integer;
case uinteger:
return cast(int) value.uinteger;
case float_:
return cast(int) value.floating;
case string:
return to!int(value.str);
default:
throw new Exception("JSON: No integer value in \'" ~ tag ~ "\'.");
}
}
int getJsonInt(JSONValue json, string tag, int defValue) {
if ((tag in json.object) is null)
return defValue;
JSONValue value = json.object[tag];
switch (value.type()) with (JSONType) {
case integer:
return cast(int) value.integer;
case uinteger:
return cast(int) value.uinteger;
case float_:
return cast(int) value.floating;
case string:
return to!int(value.str);
default:
throw new Exception("JSON: No integer value in \'" ~ tag ~ "\'.");
}
}
float getJsonFloat(JSONValue json, string tag) {
if ((tag in json.object) is null)
throw new Exception("JSON: \'" ~ tag ~ "\'' does not exist in JSON.");
JSONValue value = json.object[tag];
switch (value.type()) with (JSONType) {
case integer:
return cast(float) value.integer;
case uinteger:
return cast(float) value.uinteger;
case float_:
return value.floating;
case string:
return to!float(value.str);
default:
throw new Exception("JSON: No floating value in \'" ~ tag ~ "\'.");
}
}
float getJsonFloat(JSONValue json, string tag, float defValue) {
if ((tag in json.object) is null)
return defValue;
JSONValue value = json.object[tag];
switch (value.type()) with (JSONType) {
case integer:
return cast(float) value.integer;
case uinteger:
return cast(float) value.uinteger;
case float_:
return value.floating;
case string:
return to!float(value.str);
default:
throw new Exception("JSON: No floating value in \'" ~ tag ~ "\'.");
}
}
bool getJsonBool(JSONValue json, string tag) {
if ((tag in json.object) is null)
throw new Exception("JSON: \'" ~ tag ~ "\'' does not exist in JSON.");
JSONValue value = json.object[tag];
if (value.type() == JSONType.true_)
return true;
else if (value.type() == JSONType.false_)
return false;
else
throw new Exception("JSON: \'" ~ tag ~ "\' is not a boolean value.");
}
bool getJsonBool(JSONValue json, string tag, bool defValue) {
if ((tag in json.object) is null)
return defValue;
JSONValue value = json.object[tag];
if (value.type() == JSONType.true_)
return true;
else if (value.type() == JSONType.false_)
return false;
else
throw new Exception("JSON: \'" ~ tag ~ "\' is not a boolean value.");
}
|
D
|
func void B_DIA_Addon_Myxir_TeachRequest()
{
AI_Output(other,self,"DIA_Addon_Myxir_TeachRequest_15_00"); //Teach me that language.
};
func void b_dia_addon_myxir_teach_fl()
{
AI_Output(self,other,"DIA_Addon_Myxir_TeachL1_12_00"); //We'll start with something easy. To begin with, I can teach you the language of the peasants.
AI_Output(self,other,"DIA_Addon_Myxir_TeachL1_12_01"); //As a rule, texts written in the language of the peasants deal with worldly matters such as work, love or obtaining food.
AI_Output(self,other,"DIA_Addon_Myxir_TeachL1_12_02"); //It was the common language of the city. You will be able to understand most of the texts found here if you know it.
AI_Output(self,other,"DIA_Addon_Myxir_TeachL2_12_00"); //You already know the language of the peasants. The language of the warriors is somewhat harder.
AI_Output(self,other,"DIA_Addon_Myxir_TeachL2_12_01"); //Texts written in the language of the warriors mostly deal with weapons and war. You will learn some useful things there.
AI_Output(self,other,"DIA_Addon_Myxir_TeachL3_12_01"); //Above all else, the holy scriptures, which explain the history and magic of the creators, are written in the language of the priests.
AI_Output(self,other,"DIA_Addon_Myxir_TeachL3_12_02"); //Each of these texts is a real treasure, if one understands their meaning.
};
func void B_DIA_Addon_Myxir_TeachNoMore()
{
AI_Output(self,other,"DIA_Addon_Myxir_TeachNoMore_12_00"); //There is nothing more that I can show you. You have now mastered the language of the builders.
};
func void B_DIA_Addon_Myxir_Teach_LANGUAGE_X()
{
AI_Output(self,other,"DIA_Addon_Myxir_Teach_LANGUAGE_X_12_00"); //Go and test your new knowledge. You will see that the scriptures of the builders are no longer an unsolvable mystery for you.
};
|
D
|
/*
* Hunt - A redis client library for D programming language.
*
* Copyright (C) 2018-2019 HuntLabs
*
* Website: https://www.huntlabs.net/
*
* Licensed under the Apache-2.0 License.
*
*/
module hunt.redis.BuilderFactory;
import hunt.redis.Builder;
import hunt.redis.GeoCoordinate;
import hunt.redis.GeoRadiusResponse;
import hunt.redis.Module;
import hunt.redis.StreamEntry;
import hunt.redis.StreamEntryID;
import hunt.redis.StreamPendingEntry;
import hunt.redis.Tuple;
import hunt.collection;
import hunt.Boolean;
import hunt.Byte;
import hunt.Double;
import hunt.Exceptions;
import hunt.Integer;
import hunt.logging.ConsoleLogger;
import hunt.Long;
import hunt.String;
import hunt.redis.util.SafeEncoder;
import std.conv;
import std.concurrency : initOnce;
import std.range;
/**
* TODO:
*/
class BuilderFactory {
static Builder!(Double) DOUBLE() {
__gshared Builder!(Double) inst;
return initOnce!inst(new class Builder!(Double) {
override
Double build(Object data) {
string str = STRING.build(data);
if (str is null) return null;
try {
return Double.valueOf(str.to!double);
} catch (NumberFormatException e) {
if (str == "inf" || str == "+inf") return new Double(Double.POSITIVE_INFINITY);
if (str == "-inf") return new Double(Double.NEGATIVE_INFINITY);
throw e;
}
}
override
string toString() {
return "double";
}
});
}
static Builder!(Boolean) BOOLEAN() {
__gshared Builder!(Boolean) inst;
return initOnce!inst(new class Builder!(Boolean) {
override
Boolean build(Object data) {
return Boolean.valueOf((cast(Long) data) == 1);
}
override
string toString() {
return "bool";
}
});
}
static Builder!(const(ubyte)[]) BYTE_ARRAY() {
__gshared Builder!(const(ubyte)[]) inst;
return initOnce!inst(new class Builder!(const(ubyte)[]) {
override
const(ubyte)[] build(Object data) {
if(data is null)
return null;
warning(typeid(data));
Bytes bytesObj = cast(Bytes)data;
return cast(const(ubyte)[]) bytesObj.value(); // deleted == 1
}
override string toString() {
return "const(ubyte)[]";
}
});
}
static Builder!(Long) LONG() {
__gshared Builder!(Long) inst;
return initOnce!inst(new class Builder!(Long) {
override
Long build(Object data) {
return cast(Long) data;
}
override
string toString() {
return "long";
}
});
}
static Builder!(string) STRING() {
__gshared Builder!(string) inst;
return initOnce!inst(new class Builder!(string) {
override
string build(Object data) {
if(data is null) {
version(HUNT_DEBUG) warning("data is null");
return null;
}
Bytes bytesObject = cast(Bytes)data;
if(bytesObject !is null) {
byte[] bytes = bytesObject.value();
version(HUNT_REDIS_DEBUG) tracef("value: %s, %(0x%02X, %)", cast(string)bytes, bytes);
return cast(string)bytes;
} else {
version(HUNT_DEBUG) warningf("value: %s, type: %s", data.toString(), typeid(data));
return data.toString();
}
}
override
string toString() {
return "string";
}
});
}
static Builder!(List!(string)) STRING_LIST() {
__gshared Builder!(List!(string)) inst;
return initOnce!inst(new class Builder!(List!(string)) {
override List!(string) build(Object data) {
if (data is null) {
return null;
}
version(HUNT_REDIS_DEBUG) warning(typeid(data));
List!(Object) l = cast(List!(Object)) data;
ArrayList!(string) result = new ArrayList!(string)(l.size());
foreach(Object barray ; l) {
Bytes bytes = cast(Bytes)barray;
if (bytes is null) {
result.add(cast(string)null);
} else {
result.add(SafeEncoder.encode(cast(ubyte[])bytes.value()));
}
}
return result;
}
override string toString() {
return "List!(string)";
}
});
}
static Builder!(Map!(string, string)) STRING_MAP() {
__gshared Builder!(Map!(string, string)) inst;
return initOnce!inst(new class Builder!(Map!(string, string)) {
override
Map!(string, string) build(Object data) {
// warning(typeid(data));
List!(const(ubyte)[]) flatHash = cast(List!(const(ubyte)[])) data;
Map!(string, string) hash = new HashMap!(string, string)(flatHash.size()/2, 1);
InputRange!(const(ubyte)[]) iterator = flatHash.iterator();
while (!iterator.empty()) {
const(ubyte)[] first = iterator.front(); iterator.popFront();
const(ubyte)[] second = iterator.front(); iterator.popFront();
hash.put(SafeEncoder.encode(first), SafeEncoder.encode(second));
}
return hash;
}
override
string toString() {
return "Map!(string, string)";
}
});
}
static Builder!(Map!(string, string)) PUBSUB_NUMSUB_MAP() {
__gshared Builder!(Map!(string, string)) inst;
return initOnce!inst(new class Builder!(Map!(string, string)) {
override
Map!(string, string) build(Object data) {
// warning(typeid(data));
List!(Object) flatHash = cast(List!(Object)) data;
Map!(string, string) hash = new HashMap!(string, string)(flatHash.size()/2, 1);
InputRange!(Object) iterator = flatHash.iterator();
while (!iterator.empty()) {
Object firstObj = iterator.front;
iterator.popFront();
Object secondObj = iterator.front;
iterator.popFront();
String stringObj = cast(String)firstObj;
Long longObj = cast(Long)secondObj;
hash.put(cast(string)SafeEncoder.encode(stringObj.value),
to!string(longObj.value));
}
return hash;
}
override
string toString() {
return "PUBSUB_NUMSUB_MAP!(string, string)";
}
});
}
static Builder!(Set!(string)) STRING_SET() {
__gshared Builder!(Set!(string)) inst;
return initOnce!inst(new class Builder!(Set!(string)) {
override
Set!(string) build(Object data) {
if (data is null) {
return null;
}
warning(typeid(data));
implementationMissing();
// List!(const(ubyte)[]) l = cast(List!(const(ubyte)[])) data;
// Set!(string) result = new HashSet!(string)(l.size(), 1);
// foreach(const(ubyte)[] barray ; l) {
// if (barray is null) {
// result.add(null);
// } else {
// result.add(SafeEncoder.encode(barray));
// }
// }
// return result;
return null;
}
override
string toString() {
return "Set!(string)";
}
});
}
static Builder!(List!(const(ubyte)[])) BYTE_ARRAY_LIST() {
__gshared Builder!(List!(const(ubyte)[])) inst;
return initOnce!inst(new class Builder!(List!(const(ubyte)[])) {
override
List!(const(ubyte)[]) build(Object data) {
if (data is null) {
return null;
}
List!Object lst = cast(List!Object)data;
if(lst is null) {
version(HUNT_DEBUG) warning("lst is null");
return null;
} else {
ArrayList!(const(ubyte)[]) result = new ArrayList!(const(ubyte)[])(lst.size());
foreach(Object obj; lst) {
Bytes bytes = cast(Bytes)obj;
if(bytes is null) {
result.add(null);
} else {
result.add(cast(ubyte[])bytes.value);
}
}
return result;
}
}
override
string toString() {
return "List!(const(ubyte)[])";
}
});
}
static Builder!(Set!(const(ubyte)[])) BYTE_ARRAY_ZSET() {
__gshared Builder!(Set!(const(ubyte)[])) inst;
return initOnce!inst(new class Builder!(Set!(const(ubyte)[])) {
override
Set!(const(ubyte)[]) build(Object data) {
if (data is null) {
return null;
}
warning(typeid(data));
implementationMissing();
return null;
// List!(const(ubyte)[]) l = cast(List!(const(ubyte)[])) data;
// Set!(const(ubyte)[]) result = new LinkedHashSet!(const(ubyte)[])(l);
// foreach(const(ubyte)[] barray ; l) {
// if (barray is null) {
// result.add(null);
// } else {
// result.add(barray);
// }
// }
// return result;
}
override
string toString() {
return "ZSet!(const(ubyte)[])";
}
});
}
static Builder!(Map!(const(ubyte)[], const(ubyte)[])) BYTE_ARRAY_MAP() {
__gshared Builder!(Map!(const(ubyte)[], const(ubyte)[])) inst;
return initOnce!inst(new class Builder!(Map!(const(ubyte)[], const(ubyte)[])) {
override
Map!(const(ubyte)[], const(ubyte)[]) build(Object data) {
if (data is null) {
return null;
}
warning(typeid(data));
implementationMissing();
return null;
// Map!(const(ubyte)[], const(ubyte)[]) build(Object data) {
// List!(const(ubyte)[]) flatHash = (List!(const(ubyte)[])) data;
// Map!(const(ubyte)[], const(ubyte)[]) hash = new RedisByteHashMap();
// Iterator!(const(ubyte)[]) iterator = flatHash.iterator();
// while (iterator.hasNext()) {
// hash.put(iterator.next(), iterator.next());
// }
// return hash;
}
override
string toString() {
return "Map!(const(ubyte)[], const(ubyte)[])";
}
});
}
static Builder!(Set!(string)) STRING_ZSET() {
__gshared Builder!(Set!(string)) inst;
return initOnce!inst(new class Builder!(Set!(string)) {
override
Set!(string) build(Object data) {
if (data is null) {
return null;
}
warning(typeid(data));
implementationMissing();
return null;
// List!(const(ubyte)[]) l = (List!(const(ubyte)[])) data;
// Set!(string) result = new LinkedHashSet!(string)(l.size(), 1);
// foreach(const(ubyte)[] barray ; l) {
// if (barray is null) {
// result.add(null);
// } else {
// result.add(SafeEncoder.encode(barray));
// }
// }
// return result;
}
override
string toString() {
return "ZSet!(string)";
}
});
}
static Builder!(Set!(Tuple)) TUPLE_ZSET() {
__gshared Builder!(Set!(Tuple)) inst;
return initOnce!inst(new class Builder!(Set!(Tuple)) {
override
Set!(Tuple) build(Object data) {
if (data is null) {
return null;
}
warning(typeid(data));
implementationMissing();
return null;
// List!(const(ubyte)[]) l = (List!(const(ubyte)[])) data;
// Set!(Tuple) result = new LinkedHashSet!(Tuple)(l.size()/2, 1);
// Iterator!(const(ubyte)[]) iterator = l.iterator();
// while (iterator.hasNext()) {
// result.add(new Tuple(iterator.next(), DOUBLE.build(iterator.next())));
// }
// return result;
}
override
string toString() {
return "ZSet!(Tuple)";
}
});
}
static Builder!(Object) EVAL_RESULT() {
__gshared Builder!(Object) inst;
return initOnce!inst(new class Builder!(Object) {
override
Object build(Object data) {
if (data is null) {
return null;
}
warning(typeid(data));
implementationMissing();
return null;
// if (result instanceof const(ubyte)[]) return SafeEncoder.encode((const(ubyte)[]) result);
// if (result instanceof List<?>) {
// List<?> list = (List<?>) result;
// List!(Object) listResult = new ArrayList!(Object)(list.size());
// foreach(Object bin ; list) {
// listResult.add(evalResult(bin));
// }
// return listResult;
// }
// return result;
}
override
string toString() {
return "Eval!(Object)";
}
});
}
static Builder!(Object) EVAL_BINARY_RESULT() {
__gshared Builder!(Object) inst;
return initOnce!inst(new class Builder!(Object) {
override
Object build(Object data) {
if (data is null) {
return null;
}
warning(typeid(data));
implementationMissing();
return null;
// if (result instanceof List<?>) {
// List<?> list = (List<?>) result;
// List!(Object) listResult = new ArrayList!(Object)(list.size());
// foreach(Object bin ; list) {
// listResult.add(evalResult(bin));
// }
// return listResult;
// }
// return result;
}
override
string toString() {
return "Eval!(Object)";
}
});
}
static Builder!(List!(GeoCoordinate)) GEO_COORDINATE_LIST() {
__gshared Builder!(List!(GeoCoordinate)) inst;
return initOnce!inst(new class Builder!(List!(GeoCoordinate)) {
override List!(GeoCoordinate) build(Object data) {
if (data is null) {
return null;
}
return interpretGeoposResult(cast(List!(Object)) data);
}
override string toString() {
return "List!(GeoCoordinate)";
}
});
}
private static List!(GeoCoordinate) interpretGeoposResult(List!(Object) responses) {
List!(GeoCoordinate) responseCoordinate = new ArrayList!(GeoCoordinate)(responses.size());
foreach(Object response ; responses) {
if (response is null) {
responseCoordinate.add(null);
} else {
List!(Object) respList = cast(List!(Object)) response;
Double first = DOUBLE.build(respList.get(0));
Double second = DOUBLE.build(respList.get(1));
assert(first !is null && second !is null);
GeoCoordinate coord = new GeoCoordinate(first.value(), second.value());
responseCoordinate.add(coord);
}
}
return responseCoordinate;
}
static Builder!(List!(GeoRadiusResponse)) GEORADIUS_WITH_PARAMS_RESULT() {
__gshared Builder!(List!(GeoRadiusResponse)) inst;
return initOnce!inst(new class Builder!(List!(GeoRadiusResponse)) {
override List!(GeoRadiusResponse) build(Object data) {
if (data is null) {
return null;
}
List!(Object) objectList = cast(List!(Object)) data;
List!(GeoRadiusResponse) responses = new ArrayList!(GeoRadiusResponse)(objectList.size());
if (objectList.isEmpty()) {
return responses;
}
List!Object tmp = cast(List!(Object)) objectList.get(0);
if (tmp !is null) {
// list of members with additional informations
GeoRadiusResponse resp;
foreach(Object obj ; objectList) {
List!(Object) informations = cast(List!(Object)) obj;
Object tempObj = informations.get(0);
Bytes tempData = cast(Bytes)tempObj;
if(tempData is null) {
warning(typeid(tempObj));
}
resp = new GeoRadiusResponse(cast(string)tempData.value());
int size = informations.size();
for (int idx = 1; idx < size; idx++) {
Object infoObj = informations.get(idx);
List!(Object) coord = cast(List!(Object))infoObj;
if (coord !is null) {
// coordinate
resp.setCoordinate(new GeoCoordinate(DOUBLE.build(coord.get(0)).value(),
DOUBLE.build(coord.get(1)).value()));
} else {
// distance
resp.setDistance(DOUBLE.build(infoObj).value());
}
}
responses.add(resp);
}
} else {
// list of members
foreach(Object obj ; objectList) {
Bytes tempObj = cast(Bytes)obj;
if(tempObj is null) {
warning(typeid(obj));
}
responses.add(new GeoRadiusResponse(cast(string)tempObj.value()));
}
}
return responses;
}
override string toString() {
return "GeoRadiusWithParamsResult";
}
});
}
static Builder!(List!(Module)) MODULE_LIST() {
__gshared Builder!(List!(Module)) inst;
return initOnce!inst(new class Builder!(List!(Module)) {
override
List!(Module) build(Object data) {
if (data is null) {
return null;
}
List!(List!(Object)) objectList = cast(List!(List!(Object))) data;
List!(Module) responses = new ArrayList!(Module)(objectList.size());
if (objectList.isEmpty()) {
return responses;
}
foreach(List!(Object) moduleResp; objectList) {
Object tempObj1 = moduleResp.get(1);
Object tempObj3 = moduleResp.get(3);
String strObj = cast(String)tempObj1;
if(strObj is null) {
warning(typeid(tempObj1));
implementationMissing();
}
Long longObj = cast(Long)tempObj3;
if(longObj is null) {
warning(typeid(tempObj3));
implementationMissing();
}
Module m = new Module(cast(string)SafeEncoder.encode(strObj.value),
longObj.intValue());
responses.add(m);
}
return responses;
}
override string toString() {
return "List!(Module)";
}
});
}
static Builder!(List!(Long)) LONG_LIST() {
__gshared Builder!(List!(Long)) inst;
return initOnce!inst(new class Builder!(List!(Long)) {
override List!(Long) build(Object data) {
if (data is null) {
return null;
}
version(HUNT_REDIS_DEBUG) warning(typeid(data));
return cast(List!(Long)) data;
}
override string toString() {
return "List!(Long)";
}
});
}
static Builder!(StreamEntryID) STREAM_ENTRY_ID() {
__gshared Builder!(StreamEntryID) inst;
return initOnce!inst(new class Builder!(StreamEntryID) {
override StreamEntryID build(Object data) {
if (data is null) {
return null;
}
String strObj = cast(String)data;
if(strObj is null) {
warning(typeid(data));
implementationMissing();
}
string id = cast(string)SafeEncoder.encode(strObj.value);
return new StreamEntryID(id);
}
override string toString() {
return "StreamEntryID";
}
});
}
static Builder!(List!(StreamEntry)) STREAM_ENTRY_LIST() {
__gshared Builder!(List!(StreamEntry)) inst;
return initOnce!inst(new class Builder!(List!(StreamEntry)) {
override List!(StreamEntry) build(Object data) {
List!(Object) objectList = cast(ArrayList!(Object)) data;
if(objectList is null) {
warningf("mismatched type: %s", typeid(data));
return new ArrayList!(StreamEntry)();
}
List!(StreamEntry) responses = new ArrayList!(StreamEntry)(objectList.size()/2);
if (objectList.isEmpty()) {
return responses;
}
foreach(Object obj0; objectList) {
ArrayList!(Object) res = cast(ArrayList!(Object))obj0;
assert(res !is null);
version(HUNT_REDIS_DEBUG_MORE) {
warning(typeid(res.get(0)));
}
Object obj = res.get(0);
Bytes bytes = cast(Bytes)obj;
if(bytes is null) {
warningf("wrong type: %s", typeid(obj));
continue;
}
string entryIdString = SafeEncoder.encode(cast(ubyte[])bytes.value());
StreamEntryID entryID = new StreamEntryID(entryIdString);
obj = res.get(1);
version(HUNT_REDIS_DEBUG_MORE) {
warningf("%s", typeid(obj));
}
List!(Object) hash = cast(List!(Object))obj;
if(hash is null) {
warningf("wrong type: %s", typeid(obj));
continue;
}
Map!(string, string) map = new HashMap!(string, string)(hash.size()/2);
for(int i=0; i<hash.size(); i=i+2) {
bytes = cast(Bytes)hash[i];
string first = SafeEncoder.encode(cast(ubyte[])bytes.value());
bytes = cast(Bytes)hash[i+1];
string second = SafeEncoder.encode(cast(ubyte[])bytes.value());
version(HUNT_REDIS_DEBUG_MORE) {
warningf("first: %s, second: %s", first, second);
}
map.put(first, second);
}
responses.add(new StreamEntry(entryID, map));
}
return responses;
}
override string toString() {
return "List!(StreamEntry)";
}
});
}
static Builder!(List!(StreamPendingEntry)) STREAM_PENDING_ENTRY_LIST() {
__gshared Builder!(List!(StreamPendingEntry)) inst;
return initOnce!inst(new class Builder!(List!(StreamPendingEntry)) {
override List!(StreamPendingEntry) build(Object data) {
List!(Object) streamsEntries = cast(List!(Object))data;
if(streamsEntries is null) {
warningf("mismatched type: %s", typeid(data));
return new ArrayList!(StreamPendingEntry)();
}
List!(StreamPendingEntry) result = new ArrayList!(StreamPendingEntry)(streamsEntries.size());
foreach(Object streamObj ; streamsEntries) {
List!(Object) stream = cast(List!(Object))streamObj;
//
Object obj = stream.get(0);
Bytes bytes = cast(Bytes)obj;
if(bytes is null) {
warningf("wrong type: %s", typeid(obj));
continue;
}
string id = SafeEncoder.encode(cast(ubyte[])bytes.value());
//
obj = stream.get(1);
bytes = cast(Bytes)obj;
if(bytes is null) {
warningf("wrong type: %s", typeid(obj));
continue;
}
string consumerName = SafeEncoder.encode(cast(ubyte[])bytes.value());
long idleTime = BuilderFactory.LONG.build(stream.get(2)).value();
long deliveredTimes = BuilderFactory.LONG.build(stream.get(3)).value();
result.add(new StreamPendingEntry(new StreamEntryID(id), consumerName, idleTime, deliveredTimes));
}
return result;
}
override string toString() {
return "List!(StreamPendingEntry)";
}
});
}
static Builder!(Object) OBJECT() {
__gshared Builder!(Object) inst;
return initOnce!inst(new class Builder!(Object) {
override Object build(Object data) {
return data;
}
override string toString() {
return "Object";
}
});
}
private this() {
throw new InstantiationError( "Must not instantiate this class" );
}
}
|
D
|
void stuff() {
asm {
int 80;
int 0b10;
int 0x80;
}
}
|
D
|
/Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/Routing.build/RouteGroup.swift.o : /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/Branch.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/ParametersContainer.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/RouteBuilder+RouteCollection.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/RouteBuilder+RouteGroup.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/RouteBuilder.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/RouteCollection.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/RouteGroup+RouteBuilder.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/RouteGroup.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/Router+Routes.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/Router.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/Core.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/libc.swiftmodule /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/Node.swiftmodule /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/PathIndexable.swiftmodule /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/Polymorphic.swiftmodule
/Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/Routing.build/RouteGroup~partial.swiftmodule : /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/Branch.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/ParametersContainer.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/RouteBuilder+RouteCollection.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/RouteBuilder+RouteGroup.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/RouteBuilder.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/RouteCollection.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/RouteGroup+RouteBuilder.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/RouteGroup.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/Router+Routes.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/Router.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/Core.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/libc.swiftmodule /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/Node.swiftmodule /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/PathIndexable.swiftmodule /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/Polymorphic.swiftmodule
/Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/Routing.build/RouteGroup~partial.swiftdoc : /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/Branch.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/ParametersContainer.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/RouteBuilder+RouteCollection.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/RouteBuilder+RouteGroup.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/RouteBuilder.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/RouteCollection.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/RouteGroup+RouteBuilder.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/RouteGroup.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/Router+Routes.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Routing-1.0.2/Sources/Routing/Router.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/Core.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/libc.swiftmodule /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/Node.swiftmodule /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/PathIndexable.swiftmodule /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/Polymorphic.swiftmodule
|
D
|
import app;
import std.math;
int mapSize = 1025;
immutable int mapCenterCord = 1025/2;
Point mapCenter = Point(mapCenterCord, mapCenterCord);
float mapBaseHeight = 15;
double[] spokeRotations = [
(PI*2)*(1f/16f),
(PI*2)*(2f/16f),
(PI*2)*(3f/16f),
(PI*2)*(4f/16f),
(PI*2)*(5f/16f),
(PI*2)*(6f/16f),
(PI*2)*(7f/16f),
(PI*2)*(8f/16f),
(PI*2)*(9f/16f),
(PI*2)*(10f/16f),
(PI*2)*(11f/16f),
(PI*2)*(12f/16f),
(PI*2)*(13f/16f),
(PI*2)*(14f/16f),
(PI*2)*(15f/16f),
];
//spokeInfo
int spokeDistanceFromCenter = 256+128, spokeDistanceFromEdge = 64;
int spokeWidth = 32;
int spokeSlopeWidth = 32;
float spokeBaseHieght = 30;
//CenterAreaInfo
int centerAreaSize = 128+64;
float lowerCenterAreaHeight = 20;
//Base Info
int baseAreaDistanceFromCenter = 256;
int distanceFromSpokeCenter = 128;
int baseAreaSize = 32;
float baseAreaHeight = 30.5f;
public void createAnyTeamComp(){
map = makeHieghtMap(mapSize, mapSize, cleanHeightToRawShortValue(mapBaseHeight));
createSpokes();
//createCenter();
//createBaseAreas();
saveHeightMap("AnyTeamComp.raw", map);
}
private void createSpokes(){
Point topEdgeSidePoint = Point(spokeDistanceFromEdge, mapCenterCord-(spokeWidth/2));
Point bottomEdgeSidePoint = Point(spokeDistanceFromEdge, mapCenterCord+(spokeWidth/2));
Point topCenterSidePoint = Point(mapCenterCord-spokeDistanceFromCenter, mapCenterCord-(spokeWidth/2));
Point bottomCenterSidePoint = Point(mapCenterCord-spokeDistanceFromCenter, mapCenterCord+(spokeWidth/2));
//bottom/edge
putTriangleOnMapRotated(topEdgeSidePoint, spokeBaseHieght, bottomCenterSidePoint, spokeBaseHieght, bottomEdgeSidePoint, spokeBaseHieght, mapCenter, spokeRotations);
//top/center
putTriangleOnMapRotated(topEdgeSidePoint, spokeBaseHieght, bottomCenterSidePoint, spokeBaseHieght, topCenterSidePoint, spokeBaseHieght, mapCenter, spokeRotations);
Point slopeTopEdgeSidePoint = Point(topEdgeSidePoint.x-spokeSlopeWidth, topEdgeSidePoint.y-spokeSlopeWidth);
Point slopeBottomEdgeSidePoint = Point(bottomEdgeSidePoint.x-spokeSlopeWidth, bottomEdgeSidePoint.y+spokeSlopeWidth);
Point slopeTopCenterSidePoint = Point(topCenterSidePoint.x+spokeSlopeWidth, topCenterSidePoint.y-spokeSlopeWidth);
Point slopeBottomCenterSidePoint = Point(bottomCenterSidePoint.x+spokeSlopeWidth, bottomCenterSidePoint.y+spokeSlopeWidth);
//slopes/edge
putTriangleOnMapRotated(topEdgeSidePoint, spokeBaseHieght, slopeTopEdgeSidePoint, mapBaseHeight, bottomEdgeSidePoint, spokeBaseHieght, mapCenter, spokeRotations);
putTriangleOnMapRotated(slopeTopEdgeSidePoint, mapBaseHeight, slopeBottomEdgeSidePoint, mapBaseHeight, bottomEdgeSidePoint, spokeBaseHieght, mapCenter, spokeRotations);
putTriangleOnMapRotated(slopeTopEdgeSidePoint, mapBaseHeight, topEdgeSidePoint, spokeBaseHieght, topCenterSidePoint, spokeBaseHieght, mapCenter, spokeRotations);
putTriangleOnMapRotated(slopeBottomEdgeSidePoint, mapBaseHeight, bottomEdgeSidePoint, spokeBaseHieght, bottomCenterSidePoint, spokeBaseHieght, mapCenter, spokeRotations);
putTriangleOnMapRotated(slopeTopEdgeSidePoint, mapBaseHeight, topCenterSidePoint, spokeBaseHieght, slopeTopCenterSidePoint, mapBaseHeight, mapCenter, spokeRotations);
putTriangleOnMapRotated(slopeBottomEdgeSidePoint, mapBaseHeight, bottomCenterSidePoint, spokeBaseHieght, slopeBottomCenterSidePoint, mapBaseHeight, mapCenter, spokeRotations);
}
private void createCenter(){
Point centerTriangleEdge = Point(mapCenterCord-centerAreaSize, mapCenterCord);
Point centerTriangleEdgeRotated = rotateCord(centerTriangleEdge, mapCenter, (PI*2)*(1f/8f));
putTriangleOnMapRotated(mapCenter, spokeBaseHieght, centerTriangleEdge, spokeBaseHieght, centerTriangleEdgeRotated, spokeBaseHieght, mapCenter, spokeRotations);
}
private void createBaseAreas(){
Point topLeft = Point(mapCenterCord-baseAreaDistanceFromCenter-(baseAreaSize/2), mapCenterCord-(spokeWidth/2)-(baseAreaSize/2));
Point topRight = Point(mapCenterCord-baseAreaDistanceFromCenter+(baseAreaSize/2), mapCenterCord-(spokeWidth/2)-(baseAreaSize/2));
Point bottomLeft = Point(mapCenterCord-baseAreaDistanceFromCenter-(baseAreaSize/2), mapCenterCord-(spokeWidth/2)+(baseAreaSize/2));
Point bottomRight = Point(mapCenterCord-baseAreaDistanceFromCenter+(baseAreaSize/2), mapCenterCord-(spokeWidth/2)+(baseAreaSize/2));
putTriangleOnMapRotated(topLeft, baseAreaHeight, topRight, baseAreaHeight, bottomLeft, baseAreaHeight, mapCenter, spokeRotations);
putTriangleOnMapRotated(bottomLeft, baseAreaHeight, bottomRight, baseAreaHeight, topRight, baseAreaHeight, mapCenter, spokeRotations);
topLeft.y += spokeWidth;
topRight.y += spokeWidth;
bottomLeft.y += spokeWidth;
bottomRight.y += spokeWidth;
putTriangleOnMapRotated(topLeft, baseAreaHeight, topRight, baseAreaHeight, bottomLeft, baseAreaHeight, mapCenter, spokeRotations);
putTriangleOnMapRotated(bottomLeft, baseAreaHeight, bottomRight, baseAreaHeight, topRight, baseAreaHeight, mapCenter, spokeRotations);
}
|
D
|
module app;
import meu2d;
class DMan : GameObject {
Texture texture;
int angle = 0;
double x = 0.0, y = 0.0, vx = 0.0, vy = 0.0;
this() {
texture = Texture("res/image.png");
}
override void update() {
const distx = Mouse.x - x;
const disty = Mouse.y - y;
const pow = (distx^^2 + disty^^2) / 1000000;
vx += distx * pow / 100;
vy += disty * pow / 100;
vx *= 0.98; x += vx;
vy *= 0.98; y += vy;
angle += 1;
if (angle % 10 == 0) meuLogger.log("Hi, I am D言語くん. ", x, " ", y);
}
override void draw() {
import std.conv : to;
texture.draw(x.to!int - 64, y.to!int - 64, 128, 128, Flip.none, angle);
}
}
MeuLogger meuLogger;
mixin gameMain!(() {
init(640, 480, "example", WindowStatus.resizable);
meuLogger = new MeuLogger(30, "res/mplus-1p-regular.ttf");
global.add(meuLogger.getGameObject, int.max);
global.add(new DMan());
start();
});
|
D
|
/home/hustccc/OS_Tutorial_Summer_of_Code/rCore_Labs/Lab3/os/target/debug/deps/lazy_static-cd1c195c29004fe1.rmeta: /home/hustccc/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/lazy_static-1.4.0/src/lib.rs /home/hustccc/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/lazy_static-1.4.0/src/core_lazy.rs
/home/hustccc/OS_Tutorial_Summer_of_Code/rCore_Labs/Lab3/os/target/debug/deps/liblazy_static-cd1c195c29004fe1.rlib: /home/hustccc/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/lazy_static-1.4.0/src/lib.rs /home/hustccc/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/lazy_static-1.4.0/src/core_lazy.rs
/home/hustccc/OS_Tutorial_Summer_of_Code/rCore_Labs/Lab3/os/target/debug/deps/lazy_static-cd1c195c29004fe1.d: /home/hustccc/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/lazy_static-1.4.0/src/lib.rs /home/hustccc/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/lazy_static-1.4.0/src/core_lazy.rs
/home/hustccc/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/lazy_static-1.4.0/src/lib.rs:
/home/hustccc/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/lazy_static-1.4.0/src/core_lazy.rs:
|
D
|
int i;
void main()
{
assert("keepthis");
// ...
assert(i , "bugbug");
}
|
D
|
/Users/waqar/Exercism/rust/snake_game/target/rls/debug/build/serde-0bdd8b5f3c2c8acd/build_script_build-0bdd8b5f3c2c8acd: /Users/waqar/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.117/build.rs
/Users/waqar/Exercism/rust/snake_game/target/rls/debug/build/serde-0bdd8b5f3c2c8acd/build_script_build-0bdd8b5f3c2c8acd.d: /Users/waqar/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.117/build.rs
/Users/waqar/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.117/build.rs:
|
D
|
/home/shaqb4/dev/rust/projects/oop/target/debug/deps/blog-b177a297a1332dec.rmeta: src/lib.rs
/home/shaqb4/dev/rust/projects/oop/target/debug/deps/blog-b177a297a1332dec.d: src/lib.rs
src/lib.rs:
|
D
|
func void trshacken_s1()
{
var C_Npc her;
her = Hlp_GetNpc(PC_Hero);
if(Hlp_GetInstanceID(self) == Hlp_GetInstanceID(her))
{
//print_percent_bar_none(ATR_STAMINA[0],ATR_STAMINA_MAX[0] * 10,"Vynoslivost'",42,97);
if(CinemaMod == TRUE)
{
Wld_PlayEffect("DIALOGSCOPE_FX",hero,hero,0,0,0,FALSE);
};
self.aivar[AIV_INVINCIBLE] = TRUE;
PLAYER_MOBSI_PRODUCTION = MOBSI_TRSHACKEN;
AI_ProcessInfos(her);
};
};
instance PC_TRSHACKEN_END(C_Info)
{
npc = PC_Hero;
nr = 999;
condition = pc_trshacken_end_condition;
information = pc_trshacken_end_info;
permanent = TRUE;
description = DIALOG_ENDE_WORK;
};
func int pc_trshacken_end_condition()
{
if((PLAYER_MOBSI_PRODUCTION == MOBSI_TRSHACKEN) && (OptionCheck == FALSE) && (TeleportCheck == FALSE))
{
return TRUE;
};
};
func void pc_trshacken_end_info()
{
b_endproductiondialog();
};
instance PC_TRSHACKEN_ADDON_HOUR(C_Info)
{
npc = PC_Hero;
nr = 1;
condition = pc_trshacken_addon_hour_condition;
information = pc_trshacken_addon_hour_info;
permanent = TRUE;
description = "Kopat";
};
func int pc_trshacken_addon_hour_condition()
{
if((PLAYER_MOBSI_PRODUCTION == MOBSI_TRSHACKEN) && (TREASURETAKE == FALSE) && (OptionCheck == FALSE) && (TeleportCheck == FALSE))
{
return TRUE;
};
};
func void pc_trshacken_addon_hour_info()
{
if(TREASURETAKE == FALSE)
{
RankPoints = RankPoints + 1;
TREASURETAKE = TRUE;
B_LogEntry(TOPIC_VIPERNUGGETS,"Našel jsem balík rudy!");
Wld_InsertItem(itmi_alefnuggetsbag,"OW_ALEF_TRS");
Wld_PlayEffect("spellFX_ItemAusbuddeln",itmi_alefnuggetsbag,itmi_alefnuggetsbag,0,0,0,FALSE);
B_Say_Overlay(hero,hero,"$FOUNDTREASURE");
Snd_Play("ORE_HACK");
B_GivePlayerXP(100);
b_endproductiondialog();
Wld_SendTrigger("EVT_ALEFTREASUREAPPERS");
Wld_InsertNpc(Skeleton_Shield,"OW_ALEF_TRS_GUARD");
};
};
|
D
|
module hunt.database.driver.postgresql.data.Line;
import hunt.Double;
/**
* Line data type in Postgres represented by the linear equation Ax + By + C = 0, where A and B are not both zero.
*/
class Line {
private double a;
private double b;
private double c;
this() {
this(0.0, 0.0, 0.0);
}
this(double a, double b, double c) {
this.a = a;
this.b = b;
this.c = c;
}
// this(JsonObject json) {
// LineConverter.fromJson(json, this);
// }
double getA() {
return a;
}
void setA(double a) {
this.a = a;
}
double getB() {
return b;
}
void setB(double b) {
this.b = b;
}
double getC() {
return c;
}
void setC(double c) {
this.c = c;
}
override
bool opEquals(Object o) {
if (this is o) return true;
Line that = cast(Line) o;
if(that is null) return false;
if (a != that.a) return false;
if (b != that.b) return false;
if (c != that.c) return false;
return true;
}
override
size_t toHash() @trusted nothrow {
import hunt.Double;
ulong result;
ulong temp;
temp = Double.doubleToLongBits(a);
result = (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(b);
result = 31 * result + (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(c);
result = 31 * result + (temp ^ (temp >>> 32));
return cast(size_t)result;
}
override
string toString() {
import std.conv;
return "Line{" ~ a.to!string() ~ "," ~ b.to!string() ~ "," ~ c.to!string() ~ "}";
}
// JsonObject toJson() {
// JsonObject json = new JsonObject();
// LineConverter.toJson(this, json);
// return json;
// }
}
|
D
|
module Syntax;
public import SyntaxProc;
public import Define;
public import Lambda;
public import Quote;
public import Cond;
|
D
|
/Users/Leex/TableView_Test/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RxSwift.build/Objects-normal/x86_64/Create.o : /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Amb.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/SingleAsync.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/DistinctUntilChanged.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Deferred.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Deprecated.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Enumerated.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/Maybe.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/AsMaybe.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Sequence.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/DataStructures/InfiniteSequence.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/ObservableType+PrimitiveSequence.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/PrimitiveSequence.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Debounce.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Reduce.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Range.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Merge.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Take.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Cancelable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/Completable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/GroupedObservable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/Single.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/AsSingle.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/TakeWhile.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/SkipWhile.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Sample.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Throttle.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/ShareReplayScope.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/ObservableType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/ConnectableObservableType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/SchedulerType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/ObserverType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Subjects/SubjectType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Create.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Generate.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/DataStructures/Queue.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/DataStructures/PriorityQueue.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Reactive.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Materialize.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Dematerialize.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/AddRef.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/DataStructures/Bag.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Using.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Debug.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Catch.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Date+Dispatch.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Switch.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/StartWith.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Concurrency/Lock.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/RecursiveLock.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Sink.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Optional.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/TakeUntil.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/SkipUntil.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/WithLatestFrom.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/SubscribeOn.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/ObserveOn.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Scan.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/Completable+AndThen.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/RetryWhen.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/Platform.Darwin.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/Internal/DispatchQueueConfiguration.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Zip+Collection.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/CombineLatest+Collection.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/DelaySubscription.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Do.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Map.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/CompactMap.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Zip.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Skip.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Producer.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Buffer.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Timer.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Filter.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Never.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/AnyObserver.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Error.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/Disposables.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/ObservableType+Extensions.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/DispatchQueue+Extensions.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Errors.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/ElementAt.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Concat.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Repeat.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Subjects/AsyncSubject.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Subjects/PublishSubject.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Subjects/BehaviorSubject.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Subjects/ReplaySubject.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/AtomicInt.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Event.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/SwiftSupport/SwiftSupport.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/TakeLast.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Multicast.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/CombineLatest.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/First.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Just.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Timeout.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Window.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Extensions/Bag+Rx.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Rx.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/RxMutableBox.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/Platform.Linux.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/GroupBy.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Delay.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/ToArray.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/PrimitiveSequence+Zip+arity.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Zip+arity.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/CombineLatest+arity.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Empty.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/SwitchIfEmpty.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/DefaultIfEmpty.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/Leex/TableView_Test/Pods/Target\ Support\ Files/RxSwift/RxSwift-umbrella.h /Users/Leex/TableView_Test/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RxSwift.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/Leex/TableView_Test/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RxSwift.build/Objects-normal/x86_64/Create~partial.swiftmodule : /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Amb.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/SingleAsync.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/DistinctUntilChanged.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Deferred.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Deprecated.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Enumerated.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/Maybe.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/AsMaybe.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Sequence.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/DataStructures/InfiniteSequence.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/ObservableType+PrimitiveSequence.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/PrimitiveSequence.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Debounce.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Reduce.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Range.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Merge.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Take.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Cancelable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/Completable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/GroupedObservable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/Single.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/AsSingle.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/TakeWhile.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/SkipWhile.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Sample.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Throttle.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/ShareReplayScope.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/ObservableType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/ConnectableObservableType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/SchedulerType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/ObserverType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Subjects/SubjectType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Create.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Generate.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/DataStructures/Queue.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/DataStructures/PriorityQueue.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Reactive.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Materialize.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Dematerialize.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/AddRef.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/DataStructures/Bag.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Using.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Debug.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Catch.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Date+Dispatch.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Switch.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/StartWith.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Concurrency/Lock.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/RecursiveLock.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Sink.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Optional.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/TakeUntil.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/SkipUntil.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/WithLatestFrom.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/SubscribeOn.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/ObserveOn.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Scan.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/Completable+AndThen.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/RetryWhen.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/Platform.Darwin.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/Internal/DispatchQueueConfiguration.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Zip+Collection.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/CombineLatest+Collection.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/DelaySubscription.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Do.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Map.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/CompactMap.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Zip.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Skip.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Producer.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Buffer.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Timer.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Filter.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Never.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/AnyObserver.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Error.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/Disposables.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/ObservableType+Extensions.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/DispatchQueue+Extensions.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Errors.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/ElementAt.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Concat.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Repeat.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Subjects/AsyncSubject.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Subjects/PublishSubject.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Subjects/BehaviorSubject.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Subjects/ReplaySubject.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/AtomicInt.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Event.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/SwiftSupport/SwiftSupport.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/TakeLast.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Multicast.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/CombineLatest.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/First.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Just.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Timeout.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Window.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Extensions/Bag+Rx.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Rx.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/RxMutableBox.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/Platform.Linux.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/GroupBy.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Delay.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/ToArray.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/PrimitiveSequence+Zip+arity.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Zip+arity.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/CombineLatest+arity.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Empty.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/SwitchIfEmpty.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/DefaultIfEmpty.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/Leex/TableView_Test/Pods/Target\ Support\ Files/RxSwift/RxSwift-umbrella.h /Users/Leex/TableView_Test/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RxSwift.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/Leex/TableView_Test/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RxSwift.build/Objects-normal/x86_64/Create~partial.swiftdoc : /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Amb.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/SingleAsync.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/DistinctUntilChanged.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Deferred.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Deprecated.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Enumerated.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/Maybe.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/AsMaybe.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Sequence.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/DataStructures/InfiniteSequence.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/ObservableType+PrimitiveSequence.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/PrimitiveSequence.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Debounce.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Reduce.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Range.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Merge.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Take.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Cancelable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/Completable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/GroupedObservable.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/Single.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/AsSingle.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/TakeWhile.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/SkipWhile.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Sample.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Throttle.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/ShareReplayScope.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/ObservableType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/ConnectableObservableType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/SchedulerType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/ObserverType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Subjects/SubjectType.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Create.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Generate.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/DataStructures/Queue.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/DataStructures/PriorityQueue.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Reactive.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Materialize.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Dematerialize.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/AddRef.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/DataStructures/Bag.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Using.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Debug.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Catch.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Date+Dispatch.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Switch.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/StartWith.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Concurrency/Lock.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/RecursiveLock.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Sink.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Optional.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/TakeUntil.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/SkipUntil.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/WithLatestFrom.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/SubscribeOn.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/ObserveOn.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Scan.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/Completable+AndThen.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/RetryWhen.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/Platform.Darwin.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/Internal/DispatchQueueConfiguration.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Zip+Collection.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/CombineLatest+Collection.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/DelaySubscription.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Do.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Map.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/CompactMap.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Zip.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Skip.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Producer.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Buffer.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Timer.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Filter.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Never.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/AnyObserver.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Error.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Disposables/Disposables.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/ObservableType+Extensions.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/DispatchQueue+Extensions.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Errors.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/ElementAt.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Concat.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Repeat.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Subjects/AsyncSubject.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Subjects/PublishSubject.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Subjects/BehaviorSubject.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Subjects/ReplaySubject.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/AtomicInt.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Event.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/SwiftSupport/SwiftSupport.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/TakeLast.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Multicast.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/CombineLatest.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/First.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Just.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Timeout.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Window.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Extensions/Bag+Rx.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Rx.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/RxMutableBox.swift /Users/Leex/TableView_Test/Pods/RxSwift/Platform/Platform.Linux.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/GroupBy.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Delay.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/ToArray.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Traits/PrimitiveSequence+Zip+arity.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Zip+arity.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/CombineLatest+arity.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/Empty.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/SwitchIfEmpty.swift /Users/Leex/TableView_Test/Pods/RxSwift/RxSwift/Observables/DefaultIfEmpty.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/Leex/TableView_Test/Pods/Target\ Support\ Files/RxSwift/RxSwift-umbrella.h /Users/Leex/TableView_Test/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RxSwift.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
|
D
|
/Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Fluent.build/Relations/Children.swift.o : /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Database/Database.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Database/Driver.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Entity/Entity.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Memory/Memory+Filters.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Memory/Memory+Group.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Memory/Memory+Sort.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Memory/MemoryDriver.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Preparation/Database+Preparation.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Preparation/Migration.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Preparation/Preparation.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Preparation/PreparationError.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Action.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Comparison.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Filter.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Group.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Join.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Limit.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Query.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Scope.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Sort.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Relations/Children.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Relations/Parent.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Relations/RelationError.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Relations/Siblings.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Schema/Database+Schema.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Schema/Schema+Creator.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Schema/Schema+Field.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Schema/Schema+Modifier.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Schema/Schema.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/SQL/GeneralSQLSerializer.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/SQL/SQL+Query.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/SQL/SQL+Schema.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/SQL/SQL.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/SQL/SQLSerializer.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Utilities/Fluent+Node.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Node.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/PathIndexable.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Polymorphic.swiftmodule
/Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Fluent.build/Children~partial.swiftmodule : /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Database/Database.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Database/Driver.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Entity/Entity.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Memory/Memory+Filters.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Memory/Memory+Group.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Memory/Memory+Sort.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Memory/MemoryDriver.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Preparation/Database+Preparation.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Preparation/Migration.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Preparation/Preparation.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Preparation/PreparationError.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Action.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Comparison.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Filter.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Group.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Join.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Limit.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Query.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Scope.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Sort.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Relations/Children.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Relations/Parent.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Relations/RelationError.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Relations/Siblings.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Schema/Database+Schema.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Schema/Schema+Creator.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Schema/Schema+Field.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Schema/Schema+Modifier.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Schema/Schema.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/SQL/GeneralSQLSerializer.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/SQL/SQL+Query.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/SQL/SQL+Schema.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/SQL/SQL.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/SQL/SQLSerializer.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Utilities/Fluent+Node.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Node.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/PathIndexable.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Polymorphic.swiftmodule
/Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Fluent.build/Children~partial.swiftdoc : /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Database/Database.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Database/Driver.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Entity/Entity.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Memory/Memory+Filters.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Memory/Memory+Group.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Memory/Memory+Sort.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Memory/MemoryDriver.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Preparation/Database+Preparation.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Preparation/Migration.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Preparation/Preparation.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Preparation/PreparationError.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Action.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Comparison.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Filter.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Group.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Join.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Limit.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Query.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Scope.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Query/Sort.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Relations/Children.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Relations/Parent.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Relations/RelationError.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Relations/Siblings.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Schema/Database+Schema.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Schema/Schema+Creator.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Schema/Schema+Field.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Schema/Schema+Modifier.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Schema/Schema.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/SQL/GeneralSQLSerializer.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/SQL/SQL+Query.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/SQL/SQL+Schema.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/SQL/SQL.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/SQL/SQLSerializer.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Fluent-1.0.7/Sources/Fluent/Utilities/Fluent+Node.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Node.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/PathIndexable.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Polymorphic.swiftmodule
|
D
|
import iopipe.textpipe;
import iopipe.bufpipe;
import iopipe.valve;
import std.format;
import std.io;
import std.typecons : refCounted;
auto stdout()
{
return File(1).refCounted;
}
// returns number of matches found
size_t performSearch(UTFType utfType, Dev)(Dev dev, size_t contextLines, string[] terms)
{
// repeat the input to the output. Don't transcode
alias Char = CodeUnit!utfType;
auto output = bufd!Char.push!(a => a
.encodeText!(utfType)
.outputPipe(stdout));
// output range that doesn't auto-decode
void writeOutput(const(Char)[] data)
{
if(data.length) // yes, put sometimes sends in 0 elements.
{
output.ensureElems(data.length);
output.window[0 .. data.length] = data;
output.release(data.length);
}
}
// keep N lines in context before the current line. Add one element for a
// sentinel (will always be 0)
size_t[] lineEnds = new size_t[contextLines + 1];
//size_t lineNum = 0;
size_t toPrint = 0;
size_t matches = 0;
bool printElipses = false;
auto linepipe = dev.assumeText!utfType.byLine;
while(true)
{
import std.algorithm.searching : canFind, any;
// every time we hit a match, we are going to print all the lines of
// context before, and then print all the lines of context after.
auto lstart = linepipe.window.length;
if(linepipe.extend() == 0)
break; // we are done
//++lineNum;
auto lineNum = linepipe.segments;
// check to see if we found any search terms in here
auto curLine = linepipe.window[lstart .. $];
if(terms.any!(a => curLine.canFind(a)))
{
++matches;
if(printElipses)
{
writeOutput("...\n");
printElipses = false;
}
foreach_reverse(i; 1 .. lineEnds.length)
{
if(lineEnds[i] != lineEnds[i-1])
{
formattedWrite(&writeOutput, cast(immutable(Char)[])"%s : %s", lineNum - i, linepipe.window[lineEnds[i] .. lineEnds[i - 1]]);
}
}
// print the matched line
formattedWrite(&writeOutput,cast(immutable(Char)[])"%s*: %s", lineNum, curLine);
toPrint = contextLines;
// release all data that we printed
lineEnds[] = 0;
linepipe.release(linepipe.window.length);
}
else if(toPrint > 0)
{
// keep printing lines
formattedWrite(&writeOutput, cast(immutable(Char)[])"%s : %s", lineNum, linepipe.window);
--toPrint;
// this line has been printed, so don't save it in the buffer.
linepipe.release(linepipe.window.length);
}
else if(contextLines == 0)
{
// we don't ever print context lines.
linepipe.release(linepipe.window.length);
printElipses = true;
}
else
{
// store the line ending information, but don't print anything
auto toRelease = lineEnds[$-2];
if(toRelease > 0)
{
linepipe.release(toRelease);
printElipses = true;
}
foreach_reverse(i; 1 .. lineEnds.length-1)
lineEnds[i] = lineEnds[i-1] - toRelease;
lineEnds[0] = linepipe.window.length;
}
}
return matches;
}
int main(string[] args)
{
import std.getopt;
import std.stdio : writefln, writeln, stderr;
size_t contextLines = 2;
bool useRing;
auto helpInfo = args.getopt("context", &contextLines, "ring", &useRing);
if(helpInfo.helpWanted)
{
defaultGetoptPrinter("usage", helpInfo.options);
return 1;
}
args = args[1 .. $];
if(args.length == 0)
{
stderr.writeln("Need search parameters");
return 1;
}
size_t result;
auto stdin = File(0).refCounted;
if(useRing)
result = stdin.rbufd.runWithEncoding!performSearch(contextLines, args);
else
result = stdin.bufd.runWithEncoding!performSearch(contextLines, args);
writefln("matched %s lines", result);
return 0;
}
|
D
|
/Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/JSON.build/JSON+Equatable.swift.o : /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Equatable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSONRepresentable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/Sequence+Convertible.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Parse.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Serialize.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Bytes.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSONContext.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Fuzzy.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/libc.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Node.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/PathIndexable.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/CHTTP.build/module.modulemap /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/CSQLite.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
/Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/JSON.build/JSON+Equatable~partial.swiftmodule : /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Equatable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSONRepresentable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/Sequence+Convertible.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Parse.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Serialize.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Bytes.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSONContext.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Fuzzy.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/libc.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Node.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/PathIndexable.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/CHTTP.build/module.modulemap /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/CSQLite.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
/Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/JSON.build/JSON+Equatable~partial.swiftdoc : /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Equatable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSONRepresentable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/Sequence+Convertible.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Parse.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Serialize.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Bytes.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSONContext.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Fuzzy.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/libc.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Node.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/PathIndexable.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/CHTTP.build/module.modulemap /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/CSQLite.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
|
D
|
/Users/macosx/Desktop/IOS-OBJ/ViberDemo/build/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Notifications.o : /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/MultipartFormData.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Timeline.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Alamofire.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Response.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/TaskDelegate.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/SessionDelegate.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/ParameterEncoding.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Validation.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/ResponseSerialization.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/SessionManager.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/NetworkReachabilityManager.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/AFError.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Notifications.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Result.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Request.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/ServerTrustPolicy.swift /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/ObjectiveC.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/CoreImage.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/QuartzCore.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Dispatch.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Metal.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Darwin.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Foundation.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/CoreFoundation.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/CoreGraphics.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Swift.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/UIKit.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/SwiftOnoneSupport.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Combine.framework/Modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftinterface /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/ObjectiveC.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreImage.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/QuartzCore.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Dispatch.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Metal.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Darwin.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Foundation.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreFoundation.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreGraphics.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Swift.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/UIKit.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Target\ Support\ Files/Alamofire/Alamofire-umbrella.h /Users/macosx/Desktop/IOS-OBJ/ViberDemo/build/Pods.build/Debug-iphonesimulator/Alamofire.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/UserNotifications.framework/Headers/UserNotifications.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/macosx/Desktop/IOS-OBJ/ViberDemo/build/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Notifications~partial.swiftmodule : /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/MultipartFormData.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Timeline.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Alamofire.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Response.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/TaskDelegate.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/SessionDelegate.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/ParameterEncoding.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Validation.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/ResponseSerialization.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/SessionManager.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/NetworkReachabilityManager.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/AFError.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Notifications.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Result.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Request.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/ServerTrustPolicy.swift /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/ObjectiveC.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/CoreImage.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/QuartzCore.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Dispatch.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Metal.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Darwin.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Foundation.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/CoreFoundation.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/CoreGraphics.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Swift.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/UIKit.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/SwiftOnoneSupport.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Combine.framework/Modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftinterface /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/ObjectiveC.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreImage.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/QuartzCore.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Dispatch.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Metal.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Darwin.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Foundation.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreFoundation.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreGraphics.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Swift.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/UIKit.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Target\ Support\ Files/Alamofire/Alamofire-umbrella.h /Users/macosx/Desktop/IOS-OBJ/ViberDemo/build/Pods.build/Debug-iphonesimulator/Alamofire.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/UserNotifications.framework/Headers/UserNotifications.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/macosx/Desktop/IOS-OBJ/ViberDemo/build/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Notifications~partial.swiftdoc : /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/MultipartFormData.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Timeline.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Alamofire.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Response.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/TaskDelegate.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/SessionDelegate.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/ParameterEncoding.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Validation.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/ResponseSerialization.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/SessionManager.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/NetworkReachabilityManager.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/AFError.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Notifications.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Result.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/Request.swift /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Alamofire/Source/ServerTrustPolicy.swift /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/ObjectiveC.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/CoreImage.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/QuartzCore.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Dispatch.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Metal.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Darwin.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Foundation.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/CoreFoundation.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/CoreGraphics.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Swift.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/UIKit.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/SwiftOnoneSupport.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Combine.framework/Modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftinterface /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/ObjectiveC.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreImage.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/QuartzCore.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Dispatch.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Metal.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Darwin.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Foundation.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreFoundation.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreGraphics.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Swift.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/UIKit.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Users/macosx/Desktop/IOS-OBJ/ViberDemo/Pods/Target\ Support\ Files/Alamofire/Alamofire-umbrella.h /Users/macosx/Desktop/IOS-OBJ/ViberDemo/build/Pods.build/Debug-iphonesimulator/Alamofire.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/UserNotifications.framework/Headers/UserNotifications.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
|
D
|
module line;
static assert(__LINE__ == 3);
int #line 10
x;
static assert(__LINE__ == 12);
version(Windows) {
static assert(__FILE__ == "compilable\\line.d");
static assert(__FILE_FULL_PATH__[1..3] == ":\\");
} else {
static assert(__FILE__ == "compilable/line.d");
static assert(__FILE_FULL_PATH__[0] == '/');
}
static assert(__FILE_FULL_PATH__[$-__FILE__.length..$] == __FILE__);
#line 100 "newfile.d"
static assert(__LINE__ == 101);
static assert(__FILE__ == "newfile.d");
static assert(__FILE_FULL_PATH__[$ - 9 .. $] == "newfile.d");
# line 200
static assert(__LINE__ == 201);
static assert(__FILE__ == "newfile.d");
static assert(__FILE_FULL_PATH__[$ - 9 .. $] == "newfile.d");
|
D
|
module deimos.hyperdex.hyperspace_builder;
/* Copyright (c) 2013, Cornell University
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of HyperDex nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
import deimos.hyperdex.core;
extern(C):
public:
nothrow:
struct hyperspace;
/* hyperspace_returncode occupies [8576, 8704) */
enum hyperspace_returncode
{
HYPERSPACE_SUCCESS = 8576,
HYPERSPACE_INVALID_NAME = 8577,
HYPERSPACE_INVALID_TYPE = 8578,
HYPERSPACE_DUPLICATE = 8579,
HYPERSPACE_IS_KEY = 8580,
HYPERSPACE_UNKNOWN_ATTR = 8581,
HYPERSPACE_NO_SUBSPACE = 8582,
HYPERSPACE_OUT_OF_BOUNDS = 8583,
HYPERSPACE_UNINDEXABLE = 8584,
HYPERSPACE_GARBAGE = 8703
};
hyperspace* hyperspace_create();
hyperspace* hyperspace_parse(const char* desc);
void hyperspace_destroy(hyperspace* space);
const (char*) hyperspace_error(hyperspace* space);
hyperspace_returncode hyperspace_set_name(hyperspace* space, const char* name);
hyperspace_returncode hyperspace_set_key(hyperspace* space, const char* attr, hyperdatatype datatype);
hyperspace_returncode hyperspace_add_attribute(hyperspace* space, const char* attr, hyperdatatype datatype);
hyperspace_returncode hyperspace_add_subspace(hyperspace* space);
hyperspace_returncode hyperspace_add_subspace_attribute(hyperspace* space, const char* attr);
hyperspace_returncode hyperspace_add_index(hyperspace* space, const char* attr);
hyperspace_returncode hyperspace_set_fault_tolerance(hyperspace* space, ulong num);
hyperspace_returncode hyperspace_set_number_of_partitions(hyperspace* space, ulong num);
hyperspace_returncode hyperspace_use_authorization(hyperspace* space);
|
D
|
module android.java.android.net.UrlQuerySanitizer_IllegalCharacterValueSanitizer_d_interface;
import arsd.jni : IJavaObjectImplementation, JavaPackageId, JavaName, IJavaObject, ImportExportImpl, JavaInterfaceMembers;
static import arsd.jni;
import import0 = android.java.java.lang.Class_d_interface;
@JavaName("UrlQuerySanitizer$IllegalCharacterValueSanitizer")
final class UrlQuerySanitizer_IllegalCharacterValueSanitizer : IJavaObject {
static immutable string[] _d_canCastTo = [
"android/net/UrlQuerySanitizer$ValueSanitizer",
];
@Import this(int);
@Import string sanitize(string);
@Import import0.Class getClass();
@Import int hashCode();
@Import bool equals(IJavaObject);
@Import @JavaName("toString") string toString_();
override string toString() { return arsd.jni.javaObjectToString(this); }
@Import void notify();
@Import void notifyAll();
@Import void wait(long);
@Import void wait(long, int);
@Import void wait();
mixin IJavaObjectImplementation!(false);
public static immutable string _javaParameterString = "Landroid/net/UrlQuerySanitizer$IllegalCharacterValueSanitizer;";
}
|
D
|
instance NOV_1340_Novize(Npc_Default)
{
name[0] = NAME_Novize;
npcType = npctype_ambient;
guild = GIL_NOV;
level = 9;
flags = 0;
voice = 3;
id = 1340;
attribute[ATR_STRENGTH] = 15;
attribute[ATR_DEXTERITY] = 15;
attribute[ATR_MANA_MAX] = 0;
attribute[ATR_MANA] = 0;
attribute[ATR_HITPOINTS_MAX] = 148;
attribute[ATR_HITPOINTS] = 148;
Mdl_SetVisual(self,"HUMANS.MDS");
Mdl_ApplyOverlayMds(self,"Humans_Mage.mds");
Mdl_SetVisualBody(self,"hum_body_Naked0",1,1,"Hum_Head_Psionic",75,1,nov_armor_m);
B_Scale(self);
Mdl_SetModelFatness(self,-1);
fight_tactic = FAI_HUMAN_COWARD;
Npc_SetTalentSkill(self,NPC_TALENT_1H,1);
EquipItem(self,ItMw_1H_Axe_Old_01);
daily_routine = Rtn_start_1340;
};
func void Rtn_start_1340()
{
TA_Sleep(2,0,8,5,"PSI_24_HUT_IN");
TA_Listen(8,5,2,0,"PSI_TEACH_CADAR");
};
|
D
|
//Written in the D programming language
/++
Module containing Date/Time functionality.
This module provides:
$(UL
$(LI Types to represent points in time: $(D SysTime), $(D Date),
$(D TimeOfDay), and $(D DateTime).)
$(LI Types to represent intervals of time.)
$(LI Types to represent ranges over intervals of time.)
$(LI Types to represent time zones (used by $(D SysTime)).)
$(LI A platform-independent, high precision stopwatch type:
$(D StopWatch))
$(LI Benchmarking functions.)
$(LI Various helper functions.)
)
Closely related to std.datetime is <a href="core_time.html">$(D core.time)</a>,
and some of the time types used in std.datetime come from there - such as
$(CXREF time, Duration), $(CXREF time, TickDuration), and
$(CXREF time, FracSec). So, you may want to look at its documentation as
well. However, core.time is publically imported into std.datetime, so you
don't have to import it separately.
Three of the main concepts used in this module are time points, time
durations, and time intervals.
A time point is a specific point in time. e.g. January 5th, 2010
or 5:00.
A time duration is a length of time with units. e.g. 5 days or 231 seconds.
A time interval indicates a period of time associated with a fixed point in
time. So, it is either two time points associated with each other,
indicating the time starting at the first point up to, but not including,
the second point - e.g. [January 5th, 2010 - March 10th, 2010$(RPAREN) - or
it is a time point and a time duration associated with one another. e.g.
January 5th, 2010 and 5 days, indicating [January 5th, 2010 -
January 10th, 2010$(RPAREN).
Various arithmetic operations are supported between time points and
durations (e.g. the difference between two time points is a time duration),
and ranges can be gotten from time intervals, so range-based operations may
be done on a series of time points.
The types that the typical user is most likely to be interested in are
$(D Date) (if they want dates but don't care about time), $(D DateTime)
(if they want dates and times but don't care about time zones), $(D SysTime)
(if they want the date and time from the OS and/or do care about time
zones), and StopWatch (a platform-independent, high precision stop watch).
$(D Date) and $(D DateTime) are optimized for calendar-based operations,
while $(D SysTime) is designed for dealing with time from the OS. Check out
their specific documentation for more details.
To get the current time, use $(D Clock.currTime). It will return the current
time as a $(D SysTime). If you want to print it, $(D toString) is
sufficient, but if you use $(D toISOString), $(D toISOExtString), or
$(D toSimpleString), you can use the corresponding $(D fromISOString),
$(D fromISOExtString), or $(D fromISOExtString) to create a
$(D SysTime) from the string.
--------------------
auto currentTime = Clock.currTime();
auto timeString = currentTime.toISOExtString();
auto restoredTime = SysTime.fromISOExtString(timeString);
--------------------
Various functions take a string (or strings) to represent a unit of time
(e.g. $(D convert!("days", "hours")(numDays))). The valid strings to use
with such functions are $(D "years"), $(D "months"), $(D "weeks"),
$(D "days"), $(D "hours"), $(D "minutes"), $(D "seconds"),
$(D "msecs") (milliseconds), $(D "usecs") (microseconds),
$(D "hnsecs") (hecto-nanoseconds - i.e. 100 ns), or some subset thereof.
There are a few functions in core.time which take $(D "nsecs"), but because
nothing in std.datetime has precision greater than hnsecs, and very little
in core.time does, no functions in std.datetime accept $(D "nsecs"). If
you need help remembering which units are abbreviated and which aren't,
notice that all units seconds and greater use their full names, and all
sub-second units are abbreviated (since they'd be rather long if they
weren't).
If you're looking for the definitions of $(D Duration), $(D TickDuration),
or $(D FracSec), they're in core.time.
Note:
$(D DateTimeException) is an alias for core.time's $(D TimeException),
so you don't need to worry about core.time functions and std.datetime
functions throwing different exception types (except in the rare case
that they throw something other than $(D TimeException) or
$(D DateTimeException)).
See_Also:
$(WEB en.wikipedia.org/wiki/ISO_8601, ISO 8601)
$(WEB en.wikipedia.org/wiki/Tz_database, Wikipedia entry on TZ Database)
$(WEB en.wikipedia.org/wiki/List_of_tz_database_time_zones,
List of Time Zones)
Copyright: Copyright 2010 - 2011
License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: Jonathan M Davis and Kato Shoichi
Source: $(PHOBOSSRC std/_datetime.d)
+/
module std.datetime;
public import core.time;
import core.exception;
import core.stdc.time;
import std.array;
import std.algorithm;
import std.ascii;
import std.conv;
import std.exception;
import std.file;
import std.functional;
import std.math;
import std.metastrings;
import std.path;
import std.range;
import std.stdio;
import std.string;
import std.system;
import std.traits;
import std.typecons;
version(Windows)
{
import core.sys.windows.windows;
import std.c.windows.winsock;
//For system call to access the registry.
pragma(lib, "advapi32.lib");
}
else version(Posix)
{
import core.sys.posix.arpa.inet;
import core.sys.posix.stdlib;
import core.sys.posix.time;
import core.sys.posix.sys.time;
//We need to disable many tests because building all of Phobos
//with all of std.datetime's unit tests enables currently causes
//dmd to run out of memory.
//Regardless of that, however, it's also useful to be able to
//easily turn the tests on and off.
version = testStdDateTime;
}
version(unittest)
{
import std.c.string;
import std.stdio;
}
//I'd just alias it to indexOf, but
//http://d.puremagic.com/issues/show_bug.cgi?id=6013 would mean that that would
//pollute the global namespace. So, for now, I've created an alias which is
//highly unlikely to conflict with anything that anyone else is doing.
private alias std.string.indexOf stds_indexOf;
//Verify module example.
version(testStdDateTime) unittest
{
auto currentTime = Clock.currTime();
auto timeString = currentTime.toISOExtString();
auto restoredTime = SysTime.fromISOExtString(timeString);
}
//Verify Examples for core.time.Duration which couldn't be in core.time.
unittest
{
assert(std.datetime.Date(2010, 9, 7) + dur!"days"(5) ==
std.datetime.Date(2010, 9, 12));
assert(std.datetime.Date(2010, 9, 7) - std.datetime.Date(2010, 10, 3) ==
dur!"days"(-26));
}
//Note: There various functions which void as their return type and ref of the
// struct type which they're in as a commented out return type. Ideally,
// they would return the ref, but there are several dmd bugs which prevent
// that, relating to both ref and invariants. So, I've left the ref return
// types commented out with the idea that those functions can be made to
// return a ref to this once those bugs have been fixed.
//==============================================================================
// Section with public enums and constants.
//==============================================================================
/++
Represents the 12 months of the Gregorian year (January is 1).
+/
enum Month : ubyte { jan = 1, ///
feb, ///
mar, ///
apr, ///
may, ///
jun, ///
jul, ///
aug, ///
sep, ///
oct, ///
nov, ///
dec ///
}
/++
Represents the 7 days of the Gregorian week (Sunday is 0).
+/
enum DayOfWeek : ubyte { sun = 0, ///
mon, ///
tue, ///
wed, ///
thu, ///
fri, ///
sat ///
}
/++
In some date calculations, adding months or years can cause the date to fall
on a day of the month which is not valid (e.g. February 29th 2001 or
June 31st 2000). If overflow is allowed (as is the default), then the month
will be incremented accordingly (so, February 29th 2001 would become
March 1st 2001, and June 31st 2000 would become July 1st 2000). If overflow
is not allowed, then the day will be adjusted to the last valid day in that
month (so, February 29th 2001 would become February 28th 2001 and
June 31st 2000 would become June 30th 2000).
AllowDayOverflow only applies to calculations involving months or years.
+/
enum AllowDayOverflow
{
/// No, don't allow day overflow.
no,
/// Yes, allow day overflow.
yes
}
/++
Indicates a direction in time. One example of its use is $(D Interval)'s
$(D expand) function which uses it to indicate whether the interval should
be expanded backwards (into the past), forwards (into the future), or both.
+/
enum Direction
{
/// Backward.
bwd,
/// Forward.
fwd,
/// Both backward and forward.
both
}
/++
Used to indicate whether $(D popFront) should be called immediately upon
creating a range. The idea is that for some functions used to generate a
range for an interval, $(D front) is not necessarily a time point which
would ever be generated by the range, and if you want the first time point
in the range to match what the function generates, then you use
$(D PopFirst.yes) to indicate that the range should have $(D popFront)
called on it before the range is returned so that $(D front) is a time point
which the function would generate.
For instance, if the function used to generate a range of time points
generated successive Easters (i.e. you're iterating over all of the Easters
within the interval), the initial date probably isn't an Easter. By using
$(D PopFirst.yes), you would be telling the function which returned the
range that you wanted $(D popFront) to be called so that front would then be
an Easter - the next one generated by the function (which if you were
iterating forward, would be the Easter following the original $(D front),
while if you were iterating backward, it would be the Easter prior to the
original $(D front)). If $(D PopFirst.no) were used, then $(D front) would
remain the original time point and it would not necessarily be a time point
which would be generated by the range-generating function (which in many
cases is exactly what you
want - e.g. if you were iterating over every day starting at the beginning
of the interval).
+/
enum PopFirst
{
/// No, don't call popFront() before returning the range.
no,
/// Yes, call popFront() before returning the range.
yes
}
/++
Used by StopWatch to indicate whether it should start immediately upon
construction.
+/
enum AutoStart
{
/// No, don't start the StopWatch when it is constructed.
no,
/// Yes, do start the StopWatch when it is constructed.
yes
}
/++
Array of the strings representing time units, starting with the smallest
unit and going to the largest. It does not include $(D "nsecs").
Includes $(D "hnsecs") (hecto-nanoseconds (100 ns)),
$(D "usecs") (microseconds), $(D "msecs") (milliseconds), $(D "seconds"),
$(D "minutes"), $(D "hours"), $(D "days"), $(D "weeks"), $(D "months"), and
$(D "years")
+/
immutable string[] timeStrings = ["hnsecs", "usecs", "msecs", "seconds", "minutes",
"hours", "days", "weeks", "months", "years"];
//==============================================================================
// Section with other types.
//==============================================================================
/++
Exception type used by std.datetime. It's an alias to TimeException, which
is what core.time uses. So, you can catch either and not worry about which
module it came from.
+/
alias TimeException DateTimeException;
/++
Effectively a namespace to make it clear that the methods it contains are
getting the time from the system clock. It cannot be instantiated.
+/
final class Clock
{
public:
/++
Returns the current time in the given time zone.
Throws:
$(D ErrnoException) (on Posix) or $(D Exception) (on Windows)
if it fails to get the time of day.
+/
static SysTime currTime(immutable TimeZone tz = LocalTime())
{
return SysTime(currStdTime, tz);
}
version(testStdDateTime) unittest
{
assert(currTime(UTC()).timezone is UTC());
//I have no idea why, but for some reason, Windows/Wine likes to get
//time_t wrong when getting it with core.stdc.time.time. On one box
//I have (which has its local time set to UTC), it always gives time_t
//in the real local time (America/Los_Angeles), and after the most recent
//DST switch, every Windows box that I've tried it in is reporting
//time_t as being 1 hour off of where it's supposed to be. So, I really
//don't know what the deal is, but given what I'm seeing, I don't trust
//core.stdc.time.time on Windows, so I'm just going to disable this test
//on Windows.
version(Posix)
{
immutable unixTimeD = currTime().toUnixTime();
immutable unixTimeC = core.stdc.time.time(null);
immutable diff = unixTimeC - unixTimeD;
_assertPred!">="(diff, -2);
_assertPred!"<="(diff, 2);
}
}
/++
Returns the number of hnsecs since midnight, January 1st, 1 A.D. for the
current time.
Throws:
$(D DateTimeException) if it fails to get the time.
+/
@trusted
static @property long currStdTime()
{
version(Windows)
{
//FILETIME represents hnsecs from midnight, January 1st, 1601.
enum hnsecsFrom1601 = 504_911_232_000_000_000L;
FILETIME fileTime;
GetSystemTimeAsFileTime(&fileTime);
ulong tempHNSecs = fileTime.dwHighDateTime;
tempHNSecs <<= 32;
tempHNSecs |= fileTime.dwLowDateTime;
return cast(long)tempHNSecs + hnsecsFrom1601;
}
else version(Posix)
{
enum hnsecsToUnixEpoch = 621_355_968_000_000_000L;
static if(is(typeof(clock_gettime)))
{
timespec ts;
if(clock_gettime(CLOCK_REALTIME, &ts) != 0)
throw new TimeException("Failed in clock_gettime().");
return convert!("seconds", "hnsecs")(ts.tv_sec) +
ts.tv_nsec / 100 +
hnsecsToUnixEpoch;
}
else
{
timeval tv;
if(gettimeofday(&tv, null) != 0)
throw new TimeException("Failed in gettimeofday().");
return convert!("seconds", "hnsecs")(tv.tv_sec) +
convert!("usecs", "hnsecs")(tv.tv_usec) +
hnsecsToUnixEpoch;
}
}
}
/++
The current system tick. The number of ticks per second varies from
system to system. currSystemTick uses a monotonic clock, so it's
intended for precision timing by comparing relative time values, not
for getting the current system time.
Warning:
On some systems, the monotonic clock may stop counting when
the computer goes to sleep or hibernates. So, the monotonic
clock could be off if that occurs. This is known to happen
on Mac OS X. It has not been tested whether it occurs on
either Windows or Linux.
Throws:
$(D DateTimeException) if it fails to get the time.
+/
@safe
static @property TickDuration currSystemTick()
{
return TickDuration.currSystemTick();
}
version(testStdDateTime) unittest
{
assert(Clock.currSystemTick.length > 0);
}
/++
The current number of system ticks since the application started.
The number of ticks per second varies from system to system.
This uses a monotonic clock.
Warning:
On some systems, the monotonic clock may stop counting when
the computer goes to sleep or hibernates. So, the monotonic
clock could be off if that occurs. This is known to happen
on Mac OS X. It has not been tested whether it occurs on
either Windows or on Linux.
Throws:
$(D DateTimeException) if it fails to get the time.
+/
@safe
static @property TickDuration currAppTick()
{
return currSystemTick - TickDuration.appOrigin;
}
version(testStdDateTime) unittest
{
auto a = Clock.currSystemTick;
auto b = Clock.currAppTick;
assert(a.length);
assert(b.length);
assert(a > b);
}
private:
@disable this() {}
}
//==============================================================================
// Section with time points.
//==============================================================================
/++
$(D SysTime) is the type used when you want to get the current time from the
system or if you're doing anything that involves time zones. Unlike
$(D DateTime), the time zone is an integral part of $(D SysTime) (though if
all you care about is local time, you can pretty much ignore time zones, and
it will work, since it defaults to using the local time zone). It holds its
internal time in std time (hnsecs since midnight, January 1st, 1 A.D. UTC),
so it interfaces well with the system time. However, that means that, unlike
$(D DateTime), it is not optimized for calendar-based operations, and
getting individual units from it such as years or days is going to involve
conversions and be less efficient.
Basically, if you care about calendar-based operations and don't
necessarily care about time zones, then $(D DateTime) would be the type to
use. However, if what you care about is the system time, then $(D SysTime)
would be the type to use.
$(D Clock.currTime) will return the current time as a $(D SysTime). If you
want to convert a $(D SysTime) to a $(D Date) or $(D DateTime), simply cast
it. And if you ever want to convert a $(D Date) or $(D DateTime) to a
$(D SysTime), use $(D SysTime)'s constructor, and you can pass in the
intended time zone with it (or don't pass in a $(D TimeZone), and the local
time zone will be used). Be aware, however, that converting from a
$(D DateTime) to a $(D SysTime) will not necessarily be 100% accurate due to
DST (one hour of the year doesn't exist and another occurs twice). So, if
you don't want to risk any conversion errors, keep your times as
$(D SysTime)s. Aside from DST though, there shouldn't be any conversion
problems.
If you care about using time zones other than local time or UTC, you can use
$(D PosixTimeZone) on Posix systems (or on Windows, if you provide the TZ
Database files), and you can use $(D WindowsTimeZone) on Windows systems.
The time in $(D SysTime) is kept internally in hnsecs from midnight,
January 1st, 1 A.D. UTC. So, you never get conversion errors when changing
the time zone of a $(D SysTime). $(D LocalTime) is the $(D TimeZone) class
which represents the local time, and $(D UTC) is the $(D TimeZone) class
which represents UTC. $(D SysTime) uses $(D LocalTime) if no $(D TimeZone)
is provided. For more details on time zones, look at the documentation for
$(D TimeZone), $(D PosixTimeZone), and $(D WindowsTimeZone).
$(D SysTime)'s range is from approximately 29,000 B.C. to approximately
29,000 A.D.
+/
struct SysTime
{
public:
/++
Params:
dateTime = The $(D DateTime) to use to set this $(D SysTime)'s
internal std time. As $(D DateTime) has no concept of
time zone, tz is used as its time zone.
tz = The $(D TimeZone) to use for this $(D SysTime). If null,
$(D LocalTime) will be used. The given $(D DateTime) is
assumed to be in the given time zone.
+/
this(in DateTime dateTime, immutable TimeZone tz = null) nothrow
{
try
this(dateTime, FracSec.from!"hnsecs"(0), tz);
catch(Exception e)
assert(0, "FracSec's constructor threw when it shouldn't have.");
}
version(testStdDateTime) unittest
{
static void test(DateTime dt, immutable TimeZone tz, long expected)
{
auto sysTime = SysTime(dt, tz);
_assertPred!"=="(sysTime._stdTime, expected);
assert(sysTime._timezone is (tz is null ? LocalTime() : tz),
format("Given DateTime: %s", dt));
}
test(DateTime.init, UTC(), 0);
test(DateTime(1, 1, 1, 12, 30, 33), UTC(), 450_330_000_000L);
test(DateTime(0, 12, 31, 12, 30, 33), UTC(), -413_670_000_000L);
test(DateTime(1, 1, 1, 0, 0, 0), UTC(), 0);
test(DateTime(1, 1, 1, 0, 0, 1), UTC(), 10_000_000L);
test(DateTime(0, 12, 31, 23, 59, 59), UTC(), -10_000_000L);
test(DateTime(1, 1, 1, 0, 0, 0), new SimpleTimeZone(-60),
36_000_000_000L);
test(DateTime(1, 1, 1, 0, 0, 0), new SimpleTimeZone(0), 0);
test(DateTime(1, 1, 1, 0, 0, 0), new SimpleTimeZone(60),
-36_000_000_000L);
}
/++
Params:
dateTime = The $(D DateTime) to use to set this $(D SysTime)'s
internal std time. As $(D DateTime) has no concept of
time zone, tz is used as its time zone.
fracSec = The fractional seconds portion of the time.
tz = The $(D TimeZone) to use for this $(D SysTime). If null,
$(D LocalTime) will be used. The given $(D DateTime) is
assumed to be in the given time zone.
Throws:
$(D DateTimeException) if $(D fracSec) is negative.
+/
this(in DateTime dateTime, in FracSec fracSec, immutable TimeZone tz = null)
{
immutable fracHNSecs = fracSec.hnsecs;
enforce(fracHNSecs >= 0, new DateTimeException("A SysTime cannot have negative fractional seconds."));
_timezone = tz is null ? LocalTime() : tz;
try
{
immutable dateDiff = (dateTime.date - Date(1, 1, 1)).total!"hnsecs";
immutable todDiff = (dateTime.timeOfDay - TimeOfDay(0, 0, 0)).total!"hnsecs";
immutable adjustedTime = dateDiff + todDiff + fracHNSecs;
immutable standardTime = _timezone.tzToUTC(adjustedTime);
this(standardTime, _timezone);
}
catch(Exception e)
{
assert(0, "Date, TimeOfDay, or DateTime's constructor threw when " ~
"it shouldn't have.");
}
}
version(testStdDateTime) unittest
{
static void test(DateTime dt,
FracSec fracSec,
immutable TimeZone tz,
long expected)
{
auto sysTime = SysTime(dt, fracSec, tz);
_assertPred!"=="(sysTime._stdTime, expected);
assert(sysTime._timezone is (tz is null ? LocalTime() : tz),
format("Given DateTime: %s, Given FracSec: %s", dt, fracSec));
}
test(DateTime.init, FracSec.init, UTC(), 0);
test(DateTime(1, 1, 1, 12, 30, 33), FracSec.init, UTC(), 450_330_000_000L);
test(DateTime(0, 12, 31, 12, 30, 33), FracSec.init, UTC(), -413_670_000_000L);
test(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"msecs"(1), UTC(), 10_000L);
test(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"msecs"(999), UTC(), -10_000L);
test(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999), UTC(), -1);
test(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(1), UTC(), -9_999_999);
test(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(0), UTC(), -10_000_000);
assertThrown!DateTimeException(SysTime(DateTime.init, FracSec.from!"hnsecs"(-1), UTC()));
}
/++
Params:
date = The $(D Date) to use to set this $(D SysTime)'s internal std
time. As $(D Date) has no concept of time zone, tz is used as
its time zone.
tz = The $(D TimeZone) to use for this $(D SysTime). If null,
$(D LocalTime) will be used. The given $(D Date) is assumed
to be in the given time zone.
+/
this(in Date date, immutable TimeZone tz = null) nothrow
{
_timezone = tz is null ? LocalTime() : tz;
try
{
immutable adjustedTime = (date - Date(1, 1, 1)).total!"hnsecs";
immutable standardTime = _timezone.tzToUTC(adjustedTime);
this(standardTime, _timezone);
}
catch(Exception e)
assert(0, "Date's constructor through when it shouldn't have.");
}
version(testStdDateTime) unittest
{
static void test(Date d, immutable TimeZone tz, long expected)
{
auto sysTime = SysTime(d, tz);
_assertPred!"=="(sysTime._stdTime, expected);
assert(sysTime._timezone is (tz is null ? LocalTime() : tz),
format("Given Date: %s", d));
}
test(Date.init, UTC(), 0);
test(Date(1, 1, 1), UTC(), 0);
test(Date(1, 1, 2), UTC(), 864000000000);
test(Date(0, 12, 31), UTC(), -864000000000);
}
/++
Note:
Whereas the other constructors take in the given date/time, assume
that it's in the given time zone, and convert it to hnsecs in UTC
since midnight, January 1st, 1 A.D. UTC - i.e. std time - this
constructor takes a std time, which is specifically already in UTC,
so no conversion takes place. Of course, the various getter
properties and functions will use the given time zone's conversion
function to convert the results to that time zone, but no conversion
of the arguments to this constructor takes place.
Params:
stdTime = The number of hnsecs since midnight, January 1st, 1 A.D. UTC.
tz = The $(D TimeZone) to use for this $(D SysTime). If null,
$(D LocalTime) will be used.
+/
this(long stdTime, immutable TimeZone tz = null) pure nothrow
{
_stdTime = stdTime;
_timezone = tz is null ? LocalTime() : tz;
}
version(testStdDateTime) unittest
{
static void test(long stdTime, immutable TimeZone tz)
{
auto sysTime = SysTime(stdTime, tz);
_assertPred!"=="(sysTime._stdTime, stdTime);
assert(sysTime._timezone is (tz is null ? LocalTime() : tz),
format("Given stdTime: %s", stdTime));
}
foreach(stdTime; [-1234567890L, -250, 0, 250, 1235657390L])
{
foreach(tz; testTZs)
test(stdTime, tz);
}
}
/++
Params:
rhs = The $(D SysTime) to assign to this one.
+/
ref SysTime opAssign(const ref SysTime rhs) pure nothrow
{
_stdTime = rhs._stdTime;
_timezone = rhs._timezone;
return this;
}
/++
Params:
rhs = The $(D SysTime) to assign to this one.
+/
ref SysTime opAssign(SysTime rhs) pure nothrow
{
_stdTime = rhs._stdTime;
_timezone = rhs._timezone;
return this;
}
/++
Checks for equality between this $(D SysTime) and the given
$(D SysTime).
Note that the time zone is ignored. Only the internal
std times (which are in UTC) are compared.
+/
bool opEquals(const ref SysTime rhs) const pure nothrow
{
return _stdTime == rhs._stdTime;
}
version(testStdDateTime) unittest
{
_assertPred!"=="(SysTime(DateTime.init, UTC()), SysTime(0, UTC()));
_assertPred!"=="(SysTime(DateTime.init, UTC()), SysTime(0));
_assertPred!"=="(SysTime(Date.init, UTC()), SysTime(0));
_assertPred!"=="(SysTime(0), SysTime(0));
static void test(DateTime dt,
immutable TimeZone tz1,
immutable TimeZone tz2)
{
auto st1 = SysTime(dt);
st1.timezone = tz1;
auto st2 = SysTime(dt);
st2.timezone = tz2;
_assertPred!"=="(st1, st2);
}
foreach(tz1; testTZs)
{
foreach(tz2; testTZs)
{
foreach(dt; chain(testDateTimesBC, testDateTimesAD))
test(dt, tz1, tz2);
}
}
auto st = SysTime(DateTime(1999, 7, 6, 12, 33, 30));
const cst = SysTime(DateTime(1999, 7, 6, 12, 33, 30));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 33, 30));
static assert(__traits(compiles, st == st));
static assert(__traits(compiles, st == cst));
//static assert(__traits(compiles, st == ist));
static assert(__traits(compiles, cst == st));
static assert(__traits(compiles, cst == cst));
//static assert(__traits(compiles, cst == ist));
//static assert(__traits(compiles, ist == st));
//static assert(__traits(compiles, ist == cst));
//static assert(__traits(compiles, ist == ist));
}
/++
Compares this $(D SysTime) with the given $(D SysTime).
Time zone is irrelevant when comparing $(D SysTime)s.
Returns:
$(BOOKTABLE,
$(TR $(TD this < rhs) $(TD < 0))
$(TR $(TD this == rhs) $(TD 0))
$(TR $(TD this > rhs) $(TD > 0))
)
+/
int opCmp(in SysTime rhs) const pure nothrow
{
if(_stdTime < rhs._stdTime)
return -1;
if(_stdTime > rhs._stdTime)
return 1;
return 0;
}
version(testStdDateTime) unittest
{
_assertPred!("opCmp", "==")(SysTime(DateTime.init, UTC()),
SysTime(0, UTC()));
_assertPred!("opCmp", "==")(SysTime(DateTime.init, UTC()), SysTime(0));
_assertPred!("opCmp", "==")(SysTime(Date.init, UTC()), SysTime(0));
_assertPred!("opCmp", "==")(SysTime(0), SysTime(0));
static void testEqual(DateTime dt,
immutable TimeZone tz1,
immutable TimeZone tz2)
{
auto st1 = SysTime(dt);
st1.timezone = tz1;
auto st2 = SysTime(dt);
st2.timezone = tz2;
_assertPred!("opCmp", "==")(st1, st2);
}
foreach(dt; chain(testDateTimesBC, testDateTimesAD))
{
foreach(tz1; testTZs)
{
foreach(tz2; testTZs)
testEqual(dt, tz1, tz2);
}
}
static void testCmp(DateTime dt1,
immutable TimeZone tz1,
DateTime dt2,
immutable TimeZone tz2)
{
auto st1 = SysTime(dt1);
st1.timezone = tz1;
auto st2 = SysTime(dt2);
st2.timezone = tz2;
_assertPred!("opCmp", "<")(st1, st2);
_assertPred!("opCmp", ">")(st2, st1);
}
auto dts = testDateTimesBC ~ testDateTimesAD;
foreach(tz1; testTZs)
{
foreach(tz2; testTZs)
{
for(size_t i = 0; i < dts.length; ++i)
{
for(size_t j = i + 1; j < dts.length; ++j)
testCmp(dts[i], tz1, dts[j], tz2);
}
}
}
auto st = SysTime(DateTime(1999, 7, 6, 12, 33, 30));
const cst = SysTime(DateTime(1999, 7, 6, 12, 33, 30));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 33, 30));
static assert(__traits(compiles, st.opCmp(st)));
static assert(__traits(compiles, st.opCmp(cst)));
//static assert(__traits(compiles, st.opCmp(ist)));
static assert(__traits(compiles, cst.opCmp(st)));
static assert(__traits(compiles, cst.opCmp(cst)));
//static assert(__traits(compiles, cst.opCmp(ist)));
//static assert(__traits(compiles, ist.opCmp(st)));
//static assert(__traits(compiles, ist.opCmp(cst)));
//static assert(__traits(compiles, ist.opCmp(ist)));
}
/++
Year of the Gregorian Calendar. Positive numbers are A.D. Non-positive
are B.C.
+/
@property short year() const nothrow
{
return (cast(Date)this).year;
}
version(testStdDateTime) unittest
{
static void test(SysTime sysTime, long expected, size_t line = __LINE__)
{
_assertPred!"=="(sysTime.year, expected,
format("Value given: %s", sysTime), __FILE__, line);
}
test(SysTime(0, UTC()), 1);
test(SysTime(1, UTC()), 1);
test(SysTime(-1, UTC()), 0);
foreach(year; chain(testYearsBC, testYearsAD))
{
foreach(md; testMonthDays)
{
foreach(tod; testTODs)
{
auto dt = DateTime(Date(year, md.month, md.day), tod);
foreach(tz; testTZs)
{
foreach(fs; testFracSecs)
test(SysTime(dt, fs, tz), year);
}
}
}
}
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cst.year));
//static assert(__traits(compiles, ist.year));
}
/++
Year of the Gregorian Calendar. Positive numbers are A.D. Non-positive
are B.C.
Params:
year = The year to set this $(D SysTime)'s year to.
Throws:
$(D DateTimeException) if the new year is not a leap year and the
resulting date would be on February 29th.
Examples:
--------------------
assert(SysTime(DateTime(1999, 7, 6, 9, 7, 5)).year == 1999);
assert(SysTime(DateTime(2010, 10, 4, 0, 0, 30)).year == 2010);
assert(SysTime(DateTime(-7, 4, 5, 7, 45, 2)).year == -7);
--------------------
+/
@property void year(int year)
{
auto hnsecs = adjTime;
auto days = splitUnitsFromHNSecs!"days"(hnsecs) + 1;
if(hnsecs < 0)
{
hnsecs += convert!("hours", "hnsecs")(24);
--days;
}
auto date = Date(cast(int)days);
date.year = year;
immutable newDaysHNSecs = convert!("days", "hnsecs")(date.dayOfGregorianCal - 1);
adjTime = newDaysHNSecs + hnsecs;
}
//Verify Examples.
version(testStdDateTime) unittest
{
assert(SysTime(DateTime(1999, 7, 6, 9, 7, 5)).year == 1999);
assert(SysTime(DateTime(2010, 10, 4, 0, 0, 30)).year == 2010);
assert(SysTime(DateTime(-7, 4, 5, 7, 45, 2)).year == -7);
}
version(testStdDateTime) unittest
{
static void test(SysTime st, int year, in SysTime expected, size_t line = __LINE__)
{
st.year = year;
_assertPred!"=="(st, expected, "", __FILE__, line);
}
foreach(st; chain(testSysTimesBC, testSysTimesAD))
{
auto dt = cast(DateTime)st;
foreach(year; chain(testYearsBC, testYearsAD))
{
auto e = SysTime(DateTime(year, dt.month, dt.day, dt.hour, dt.minute, dt.second),
st.fracSec,
st.timezone);
test(st, year, e);
}
}
foreach(fs; testFracSecs)
{
foreach(tz; testTZs)
{
foreach(tod; testTODs)
{
test(SysTime(DateTime(Date(1999, 2, 28), tod), fs, tz), 2000,
SysTime(DateTime(Date(2000, 2, 28), tod), fs, tz));
test(SysTime(DateTime(Date(2000, 2, 28), tod), fs, tz), 1999,
SysTime(DateTime(Date(1999, 2, 28), tod), fs, tz));
}
foreach(tod; testTODsThrown)
{
auto st = SysTime(DateTime(Date(2000, 2, 29), tod), fs, tz);
assertThrown!DateTimeException(st.year = 1999);
}
}
}
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.year = 7));
//static assert(!__traits(compiles, ist.year = 7));
}
/++
Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.
Throws:
$(D DateTimeException) if $(D isAD) is true.
Examples:
--------------------
assert(SysTime(DateTime(0, 1, 1, 12, 30, 33)).yearBC == 1);
assert(SysTime(DateTime(-1, 1, 1, 10, 7, 2)).yearBC == 2);
assert(SysTime(DateTime(-100, 1, 1, 4, 59, 0)).yearBC == 101);
--------------------
+/
@property ushort yearBC() const
{
return (cast(Date)this).yearBC;
}
//Verify Examples.
version(testStdDateTime) unittest
{
assert(SysTime(DateTime(0, 1, 1, 12, 30, 33)).yearBC == 1);
assert(SysTime(DateTime(-1, 1, 1, 10, 7, 2)).yearBC == 2);
assert(SysTime(DateTime(-100, 1, 1, 4, 59, 0)).yearBC == 101);
}
version(testStdDateTime) unittest
{
foreach(st; testSysTimesBC)
{
auto msg = format("SysTime: %s", st);
assertNotThrown!DateTimeException(st.yearBC, msg);
_assertPred!"=="(st.yearBC, (st.year * -1) + 1, msg);
}
foreach(st; [testSysTimesAD[0], testSysTimesAD[$/2], testSysTimesAD[$-1]])
assertThrown!DateTimeException(st.yearBC, format("SysTime: %s", st));
auto st = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, st.year = 12));
static assert(!__traits(compiles, cst.year = 12));
//static assert(!__traits(compiles, ist.year = 12));
}
/++
Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.
Params:
year = The year B.C. to set this $(D SysTime)'s year to.
Throws:
$(D DateTimeException) if a non-positive value is given.
Examples:
--------------------
auto st = SysTime(DateTime(2010, 1, 1, 7, 30, 0));
st.yearBC = 1;
assert(st == SysTime(DateTime(0, 1, 1, 7, 30, 0)));
st.yearBC = 10;
assert(st == SysTime(DateTime(-9, 1, 1, 7, 30, 0)));
--------------------
+/
@property void yearBC(int year)
{
auto hnsecs = adjTime;
auto days = splitUnitsFromHNSecs!"days"(hnsecs) + 1;
if(hnsecs < 0)
{
hnsecs += convert!("hours", "hnsecs")(24);
--days;
}
auto date = Date(cast(int)days);
date.yearBC = year;
immutable newDaysHNSecs = convert!("days", "hnsecs")(date.dayOfGregorianCal - 1);
adjTime = newDaysHNSecs + hnsecs;
}
//Verify Examples
version(testStdDateTime) unittest
{
auto st = SysTime(DateTime(2010, 1, 1, 7, 30, 0));
st.yearBC = 1;
assert(st == SysTime(DateTime(0, 1, 1, 7, 30, 0)));
st.yearBC = 10;
assert(st == SysTime(DateTime(-9, 1, 1, 7, 30, 0)));
}
version(testStdDateTime) unittest
{
static void test(SysTime st, int year, in SysTime expected, size_t line = __LINE__)
{
st.yearBC = year;
_assertPred!"=="(st, expected, format("SysTime: %s", st), __FILE__, line);
}
foreach(st; chain(testSysTimesBC, testSysTimesAD))
{
auto dt = cast(DateTime)st;
foreach(year; testYearsBC)
{
auto e = SysTime(DateTime(year, dt.month, dt.day, dt.hour, dt.minute, dt.second),
st.fracSec,
st.timezone);
test(st, (year * -1) + 1, e);
}
}
foreach(st; [testSysTimesBC[0], testSysTimesBC[$ - 1],
testSysTimesAD[0], testSysTimesAD[$ - 1]])
{
foreach(year; testYearsBC)
assertThrown!DateTimeException(st.yearBC = year);
}
foreach(fs; testFracSecs)
{
foreach(tz; testTZs)
{
foreach(tod; testTODs)
{
test(SysTime(DateTime(Date(-1999, 2, 28), tod), fs, tz), 2001,
SysTime(DateTime(Date(-2000, 2, 28), tod), fs, tz));
test(SysTime(DateTime(Date(-2000, 2, 28), tod), fs, tz), 2000,
SysTime(DateTime(Date(-1999, 2, 28), tod), fs, tz));
}
foreach(tod; testTODsThrown)
{
auto st = SysTime(DateTime(Date(-2000, 2, 29), tod), fs, tz);
assertThrown!DateTimeException(st.year = -1999);
}
}
}
auto st = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, st.yearBC = 12));
static assert(!__traits(compiles, cst.yearBC = 12));
//static assert(!__traits(compiles, ist.yearBC = 12));
}
/++
Month of a Gregorian Year.
Examples:
--------------------
assert(SysTime(DateTime(1999, 7, 6, 9, 7, 5)).month == 7);
assert(SysTime(DateTime(2010, 10, 4, 0, 0, 30)).month == 10);
assert(SysTime(DateTime(-7, 4, 5, 7, 45, 2)).month == 4);
--------------------
+/
@property Month month() const nothrow
{
return (cast(Date)this).month;
}
//Verify Examples.
version(testStdDateTime) unittest
{
assert(SysTime(DateTime(1999, 7, 6, 9, 7, 5)).month == 7);
assert(SysTime(DateTime(2010, 10, 4, 0, 0, 30)).month == 10);
assert(SysTime(DateTime(-7, 4, 5, 7, 45, 2)).month == 4);
}
version(testStdDateTime) unittest
{
static void test(SysTime sysTime, Month expected, size_t line = __LINE__)
{
_assertPred!"=="(sysTime.month, expected,
format("Value given: %s", sysTime), __FILE__, line);
}
test(SysTime(0, UTC()), Month.jan);
test(SysTime(1, UTC()), Month.jan);
test(SysTime(-1, UTC()), Month.dec);
foreach(year; chain(testYearsBC, testYearsAD))
{
foreach(md; testMonthDays)
{
foreach(tod; testTODs)
{
auto dt = DateTime(Date(year, md.month, md.day), tod);
foreach(fs; testFracSecs)
{
foreach(tz; testTZs)
test(SysTime(dt, fs, tz), md.month);
}
}
}
}
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cst.month));
//static assert(__traits(compiles, ist.month));
}
/++
Month of a Gregorian Year.
Params:
month = The month to set this $(D SysTime)'s month to.
Throws:
$(D DateTimeException) if the given month is not a valid month.
+/
@property void month(Month month)
{
auto hnsecs = adjTime;
auto days = splitUnitsFromHNSecs!"days"(hnsecs) + 1;
if(hnsecs < 0)
{
hnsecs += convert!("hours", "hnsecs")(24);
--days;
}
auto date = Date(cast(int)days);
date.month = month;
immutable newDaysHNSecs = convert!("days", "hnsecs")(date.dayOfGregorianCal - 1);
adjTime = newDaysHNSecs + hnsecs;
}
version(testStdDateTime) unittest
{
static void test(SysTime st, Month month, in SysTime expected, size_t line = __LINE__)
{
st.month = cast(Month)month;
_assertPred!"=="(st, expected, "", __FILE__, line);
}
foreach(st; chain(testSysTimesBC, testSysTimesAD))
{
auto dt = cast(DateTime)st;
foreach(md; testMonthDays)
{
if(st.day > maxDay(dt.year, md.month))
continue;
auto e = SysTime(DateTime(dt.year, md.month, dt.day, dt.hour, dt.minute, dt.second),
st.fracSec,
st.timezone);
test(st, md.month, e);
}
}
foreach(fs; testFracSecs)
{
foreach(tz; testTZs)
{
foreach(tod; testTODs)
{
foreach(year; filter!((a){return yearIsLeapYear(a);})
(chain(testYearsBC, testYearsAD)))
{
test(SysTime(DateTime(Date(year, 1, 29), tod), fs, tz),
Month.feb,
SysTime(DateTime(Date(year, 2, 29), tod), fs, tz));
}
foreach(year; chain(testYearsBC, testYearsAD))
{
test(SysTime(DateTime(Date(year, 1, 28), tod), fs, tz),
Month.feb,
SysTime(DateTime(Date(year, 2, 28), tod), fs, tz));
test(SysTime(DateTime(Date(year, 7, 30), tod), fs, tz),
Month.jun,
SysTime(DateTime(Date(year, 6, 30), tod), fs, tz));
}
}
}
}
foreach(fs; [testFracSecs[0], testFracSecs[$-1]])
{
foreach(tz; testTZs)
{
foreach(tod; testTODsThrown)
{
foreach(year; [testYearsBC[$-3], testYearsBC[$-2],
testYearsBC[$-2], testYearsAD[0],
testYearsAD[$-2], testYearsAD[$-1]])
{
auto day = yearIsLeapYear(year) ? 30 : 29;
auto st1 = SysTime(DateTime(Date(year, 1, day), tod), fs, tz);
assertThrown!DateTimeException(st1.month = Month.feb);
auto st2 = SysTime(DateTime(Date(year, 7, 31), tod), fs, tz);
assertThrown!DateTimeException(st2.month = Month.jun);
}
}
}
}
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.month = 12));
//static assert(!__traits(compiles, ist.month = 12));
}
/++
Day of a Gregorian Month.
Examples:
--------------------
assert(SysTime(DateTime(1999, 7, 6, 9, 7, 5)).day == 6);
assert(SysTime(DateTime(2010, 10, 4, 0, 0, 30)).day == 4);
assert(SysTime(DateTime(-7, 4, 5, 7, 45, 2)).day == 5);
--------------------
+/
@property ubyte day() const nothrow
{
return (cast(Date)this).day;
}
//Verify Examples.
version(testStdDateTime) unittest
{
assert(SysTime(DateTime(1999, 7, 6, 9, 7, 5)).day == 6);
assert(SysTime(DateTime(2010, 10, 4, 0, 0, 30)).day == 4);
assert(SysTime(DateTime(-7, 4, 5, 7, 45, 2)).day == 5);
}
version(testStdDateTime) unittest
{
static void test(SysTime sysTime, int expected, size_t line = __LINE__)
{
_assertPred!"=="(sysTime.day, expected,
format("Value given: %s", sysTime), __FILE__, line);
}
test(SysTime(0, UTC()), 1);
test(SysTime(1, UTC()), 1);
test(SysTime(-1, UTC()), 31);
foreach(year; chain(testYearsBC, testYearsAD))
{
foreach(md; testMonthDays)
{
foreach(tod; testTODs)
{
auto dt = DateTime(Date(year, md.month, md.day), tod);
foreach(tz; testTZs)
{
foreach(fs; testFracSecs)
test(SysTime(dt, fs, tz), md.day);
}
}
}
}
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cst.day));
//static assert(__traits(compiles, ist.day));
}
/++
Day of a Gregorian Month.
Params:
day = The day of the month to set this $(D SysTime)'s day to.
Throws:
$(D DateTimeException) if the given day is not a valid day of the
current month.
+/
@property void day(int day)
{
auto hnsecs = adjTime;
auto days = splitUnitsFromHNSecs!"days"(hnsecs) + 1;
if(hnsecs < 0)
{
hnsecs += convert!("hours", "hnsecs")(24);
--days;
}
auto date = Date(cast(int)days);
date.day = day;
immutable newDaysHNSecs = convert!("days", "hnsecs")(date.dayOfGregorianCal - 1);
adjTime = newDaysHNSecs + hnsecs;
}
version(testStdDateTime) unittest
{
static void test(SysTime st, int day, in SysTime expected, size_t line = __LINE__)
{
st.day = day;
_assertPred!"=="(st, expected, "", __FILE__, line);
}
foreach(day; chain(testDays))
{
foreach(st; chain(testSysTimesBC, testSysTimesAD))
{
auto dt = cast(DateTime)st;
if(day > maxDay(dt.year, dt.month))
continue;
auto e = SysTime(DateTime(dt.year, dt.month, day, dt.hour, dt.minute, dt.second),
st.fracSec,
st.timezone);
test(st, day, e);
}
}
foreach(tz; testTZs)
{
foreach(tod; testTODs)
{
foreach(fs; testFracSecs)
{
foreach(year; chain(testYearsBC, testYearsAD))
{
foreach(month; EnumMembers!Month)
{
auto st = SysTime(DateTime(Date(year, month, 1), tod), fs, tz);
immutable max = maxDay(year, month);
test(st, max, SysTime(DateTime(Date(year, month, max), tod), fs, tz));
}
}
}
}
}
foreach(tz; testTZs)
{
foreach(tod; testTODsThrown)
{
foreach(fs; [testFracSecs[0], testFracSecs[$-1]])
{
foreach(year; [testYearsBC[$-3], testYearsBC[$-2],
testYearsBC[$-2], testYearsAD[0],
testYearsAD[$-2], testYearsAD[$-1]])
{
foreach(month; EnumMembers!Month)
{
auto st = SysTime(DateTime(Date(year, month, 1), tod), fs, tz);
immutable max = maxDay(year, month);
assertThrown!DateTimeException(st.day = max + 1);
}
}
}
}
}
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.day = 27));
//static assert(!__traits(compiles, ist.day = 27));
}
/++
Hours past midnight.
+/
@property ubyte hour() const nothrow
{
auto hnsecs = adjTime;
auto days = splitUnitsFromHNSecs!"days"(hnsecs) + 1;
if(hnsecs < 0)
{
hnsecs += convert!("hours", "hnsecs")(24);
--days;
}
return cast(ubyte)getUnitsFromHNSecs!"hours"(hnsecs);
}
version(testStdDateTime) unittest
{
static void test(SysTime sysTime, int expected, size_t line = __LINE__)
{
_assertPred!"=="(sysTime.hour, expected,
format("Value given: %s", sysTime), __FILE__, line);
}
test(SysTime(0, UTC()), 0);
test(SysTime(1, UTC()), 0);
test(SysTime(-1, UTC()), 23);
foreach(tz; testTZs)
{
foreach(year; chain(testYearsBC, testYearsAD))
{
foreach(md; testMonthDays)
{
foreach(hour; testHours)
{
foreach(minute; testMinSecs)
{
foreach(second; testMinSecs)
{
auto dt = DateTime(Date(year, md.month, md.day),
TimeOfDay(hour, minute, second));
foreach(fs; testFracSecs)
test(SysTime(dt, fs, tz), hour);
}
}
}
}
}
}
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cst.hour));
//static assert(__traits(compiles, ist.hour));
}
/++
Hours past midnight.
Params:
hour = The hours to set this $(D SysTime)'s hour to.
Throws:
$(D DateTimeException) if the given hour are not a valid hour of
the day.
+/
@property void hour(int hour)
{
enforceValid!"hours"(hour);
auto hnsecs = adjTime;
auto days = splitUnitsFromHNSecs!"days"(hnsecs);
immutable daysHNSecs = convert!("days", "hnsecs")(days);
immutable negative = hnsecs < 0;
if(negative)
hnsecs += convert!("hours", "hnsecs")(24);
hnsecs = removeUnitsFromHNSecs!"hours"(hnsecs);
hnsecs += convert!("hours", "hnsecs")(hour);
if(negative)
hnsecs -= convert!("hours", "hnsecs")(24);
adjTime = daysHNSecs + hnsecs;
}
version(testStdDateTime) unittest
{
static void test(SysTime st, int hour, in SysTime expected,
size_t line = __LINE__)
{
st.hour = hour;
_assertPred!"=="(st, expected, "", __FILE__, line);
}
foreach(hour; chain(testHours))
{
foreach(st; chain(testSysTimesBC, testSysTimesAD))
{
auto dt = cast(DateTime)st;
auto e = SysTime(DateTime(dt.year, dt.month, dt.day, hour, dt.minute, dt.second),
st.fracSec,
st.timezone);
test(st, hour, e);
}
}
auto st = testSysTimesAD[0];
assertThrown!DateTimeException(st.hour = -1);
assertThrown!DateTimeException(st.hour = 60);
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.hour = 27));
//static assert(!__traits(compiles, ist.hour = 27));
}
/++
Minutes past the current hour.
+/
@property ubyte minute() const nothrow
{
auto hnsecs = adjTime;
auto days = splitUnitsFromHNSecs!"days"(hnsecs) + 1;
if(hnsecs < 0)
{
hnsecs += convert!("hours", "hnsecs")(24);
--days;
}
hnsecs = removeUnitsFromHNSecs!"hours"(hnsecs);
return cast(ubyte)getUnitsFromHNSecs!"minutes"(hnsecs);
}
version(testStdDateTime) unittest
{
static void test(SysTime sysTime, int expected, size_t line = __LINE__)
{
_assertPred!"=="(sysTime.minute, expected,
format("Value given: %s", sysTime), __FILE__, line);
}
test(SysTime(0, UTC()), 0);
test(SysTime(1, UTC()), 0);
test(SysTime(-1, UTC()), 59);
foreach(tz; testTZs)
{
foreach(year; chain(testYearsBC, testYearsAD))
{
foreach(md; testMonthDays)
{
foreach(hour; testHours)
{
foreach(minute; testMinSecs)
{
foreach(second; testMinSecs)
{
auto dt = DateTime(Date(year, md.month, md.day),
TimeOfDay(hour, minute, second));
foreach(fs; testFracSecs)
test(SysTime(dt, fs, tz), minute);
}
}
}
}
}
}
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cst.minute));
//static assert(__traits(compiles, ist.minute));
}
/++
Minutes past the current hour.
Params:
minutes = The minute to set this $(D SysTime)'s minute to.
Throws:
$(D DateTimeException) if the given minute are not a valid minute
of an hour.
+/
@property void minute(int minute)
{
enforceValid!"minutes"(minute);
auto hnsecs = adjTime;
auto days = splitUnitsFromHNSecs!"days"(hnsecs);
immutable daysHNSecs = convert!("days", "hnsecs")(days);
immutable negative = hnsecs < 0;
if(negative)
hnsecs += convert!("hours", "hnsecs")(24);
immutable hour = splitUnitsFromHNSecs!"hours"(hnsecs);
hnsecs = removeUnitsFromHNSecs!"minutes"(hnsecs);
hnsecs += convert!("hours", "hnsecs")(hour);
hnsecs += convert!("minutes", "hnsecs")(minute);
if(negative)
hnsecs -= convert!("hours", "hnsecs")(24);
adjTime = daysHNSecs + hnsecs;
}
version(testStdDateTime) unittest
{
static void test(SysTime st, int minute, in SysTime expected, size_t line = __LINE__)
{
st.minute = minute;
_assertPred!"=="(st, expected, "", __FILE__, line);
}
foreach(minute; testMinSecs)
{
foreach(st; chain(testSysTimesBC, testSysTimesAD))
{
auto dt = cast(DateTime)st;
auto e = SysTime(DateTime(dt.year, dt.month, dt.day, dt.hour, minute, dt.second),
st.fracSec,
st.timezone);
test(st, minute, e);
}
}
auto st = testSysTimesAD[0];
assertThrown!DateTimeException(st.minute = -1);
assertThrown!DateTimeException(st.minute = 60);
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.minute = 27));
//static assert(!__traits(compiles, ist.minute = 27));
}
/++
Seconds past the current minute.
+/
@property ubyte second() const nothrow
{
auto hnsecs = adjTime;
auto days = splitUnitsFromHNSecs!"days"(hnsecs) + 1;
if(hnsecs < 0)
{
hnsecs += convert!("hours", "hnsecs")(24);
--days;
}
hnsecs = removeUnitsFromHNSecs!"hours"(hnsecs);
hnsecs = removeUnitsFromHNSecs!"minutes"(hnsecs);
return cast(ubyte)getUnitsFromHNSecs!"seconds"(hnsecs);
}
version(testStdDateTime) unittest
{
static void test(SysTime sysTime, int expected, size_t line = __LINE__)
{
_assertPred!"=="(sysTime.second, expected,
format("Value given: %s", sysTime), __FILE__, line);
}
test(SysTime(0, UTC()), 0);
test(SysTime(1, UTC()), 0);
test(SysTime(-1, UTC()), 59);
foreach(tz; testTZs)
{
foreach(year; chain(testYearsBC, testYearsAD))
{
foreach(md; testMonthDays)
{
foreach(hour; testHours)
{
foreach(minute; testMinSecs)
{
foreach(second; testMinSecs)
{
auto dt = DateTime(Date(year, md.month, md.day),
TimeOfDay(hour, minute, second));
foreach(fs; testFracSecs)
test(SysTime(dt, fs, tz), second);
}
}
}
}
}
}
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cst.second));
//static assert(__traits(compiles, ist.second));
}
/++
Seconds past the current minute.
Params:
second = The second to set this $(D SysTime)'s second to.
Throws:
$(D DateTimeException) if the given second are not a valid second
of a minute.
+/
@property void second(int second)
{
enforceValid!"seconds"(second);
auto hnsecs = adjTime;
auto days = splitUnitsFromHNSecs!"days"(hnsecs);
immutable daysHNSecs = convert!("days", "hnsecs")(days);
immutable negative = hnsecs < 0;
if(negative)
hnsecs += convert!("hours", "hnsecs")(24);
immutable hour = splitUnitsFromHNSecs!"hours"(hnsecs);
immutable minute = splitUnitsFromHNSecs!"minutes"(hnsecs);
hnsecs = removeUnitsFromHNSecs!"seconds"(hnsecs);
hnsecs += convert!("hours", "hnsecs")(hour);
hnsecs += convert!("minutes", "hnsecs")(minute);
hnsecs += convert!("seconds", "hnsecs")(second);
if(negative)
hnsecs -= convert!("hours", "hnsecs")(24);
adjTime = daysHNSecs + hnsecs;
}
version(testStdDateTime) unittest
{
static void test(SysTime st, int second, in SysTime expected,
size_t line = __LINE__)
{
st.second = second;
_assertPred!"=="(st, expected, "", __FILE__, line);
}
foreach(second; testMinSecs)
{
foreach(st; chain(testSysTimesBC, testSysTimesAD))
{
auto dt = cast(DateTime)st;
auto e = SysTime(DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, second),
st.fracSec,
st.timezone);
test(st, second, e);
}
}
auto st = testSysTimesAD[0];
assertThrown!DateTimeException(st.second = -1);
assertThrown!DateTimeException(st.second = 60);
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.seconds = 27));
//static assert(!__traits(compiles, ist.seconds = 27));
}
/++
Fractional seconds passed the second.
+/
@property FracSec fracSec() const nothrow
{
try
{
auto hnsecs = removeUnitsFromHNSecs!"days"(adjTime);
if(hnsecs < 0)
hnsecs += convert!("hours", "hnsecs")(24);
hnsecs = removeUnitsFromHNSecs!"seconds"(hnsecs);
return FracSec.from!"hnsecs"(cast(int)hnsecs);
}
catch(Exception e)
assert(0, "FracSec.from!\"hnsecs\"() threw.");
}
version(testStdDateTime) unittest
{
static void test(SysTime sysTime, FracSec expected, size_t line = __LINE__)
{
_assertPred!"=="(sysTime.fracSec, expected,
format("Value given: %s", sysTime), __FILE__, line);
}
test(SysTime(0, UTC()), FracSec.from!"hnsecs"(0));
test(SysTime(1, UTC()), FracSec.from!"hnsecs"(1));
test(SysTime(-1, UTC()), FracSec.from!"hnsecs"(9_999_999));
foreach(tz; testTZs)
{
foreach(year; chain(testYearsBC, testYearsAD))
{
foreach(md; testMonthDays)
{
foreach(hour; testHours)
{
foreach(minute; testMinSecs)
{
foreach(second; testMinSecs)
{
auto dt = DateTime(Date(year, md.month, md.day),
TimeOfDay(hour, minute, second));
foreach(fs; testFracSecs)
test(SysTime(dt, fs, tz), fs);
}
}
}
}
}
}
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cst.fracSec));
//static assert(__traits(compiles, ist.fracSec));
}
/++
Fractional seconds passed the second.
Params:
fracSec = The fractional seconds to set this $(D SysTimes)'s
fractional seconds to.
Throws:
$(D DateTimeException) if $(D fracSec) is negative.
+/
@property void fracSec(FracSec fracSec)
{
immutable fracHNSecs = fracSec.hnsecs;
enforce(fracHNSecs >= 0, new DateTimeException("A SysTime cannot have negative fractional seconds."));
auto hnsecs = adjTime;
auto days = splitUnitsFromHNSecs!"days"(hnsecs);
immutable daysHNSecs = convert!("days", "hnsecs")(days);
immutable negative = hnsecs < 0;
if(negative)
hnsecs += convert!("hours", "hnsecs")(24);
immutable hour = splitUnitsFromHNSecs!"hours"(hnsecs);
immutable minute = splitUnitsFromHNSecs!"minutes"(hnsecs);
immutable second = getUnitsFromHNSecs!"seconds"(hnsecs);
hnsecs = fracHNSecs;
hnsecs += convert!("hours", "hnsecs")(hour);
hnsecs += convert!("minutes", "hnsecs")(minute);
hnsecs += convert!("seconds", "hnsecs")(second);
if(negative)
hnsecs -= convert!("hours", "hnsecs")(24);
adjTime = daysHNSecs + hnsecs;
}
version(testStdDateTime) unittest
{
static void test(SysTime st, FracSec fracSec, in SysTime expected, size_t line = __LINE__)
{
st.fracSec = fracSec;
_assertPred!"=="(st, expected, "", __FILE__, line);
}
foreach(fracSec; testFracSecs)
{
foreach(st; chain(testSysTimesBC, testSysTimesAD))
{
auto dt = cast(DateTime)st;
auto e = SysTime(DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second),
fracSec,
st.timezone);
test(st, fracSec, e);
}
}
SysTime st = SysTime(DateTime(2011, 7, 11, 2, 51, 27));
assertThrown!DateTimeException(st.fracSec = FracSec.from!"hnsecs"(-1));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.fracSec = FracSec.from!"msecs"(7)));
//static assert(!__traits(compiles, ist.fracSec = FracSec.from!"msecs"(7)));
}
/++
The total hnsecs from midnight, January 1st, 1 A.D. UTC. This is the
internal representation of $(D SysTime).
+/
@property long stdTime() const pure nothrow
{
return _stdTime;
}
version(testStdDateTime) unittest
{
_assertPred!"=="(SysTime(0).stdTime, 0);
_assertPred!"=="(SysTime(1).stdTime, 1);
_assertPred!"=="(SysTime(-1).stdTime, -1);
_assertPred!"=="(SysTime(DateTime(1, 1, 1, 0, 0, 33), FracSec.from!"hnsecs"(502), UTC()).stdTime,
330000502L);
_assertPred!"=="(SysTime(DateTime(1970, 1, 1, 0, 0, 0), UTC()).stdTime,
621355968000000000L);
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cst.stdTime));
//static assert(__traits(compiles, ist.stdTime));
}
/++
The total hnsecs from midnight, January 1st, 1 A.D. UTC. This is the
internal representation of $(D SysTime).
Params:
stdTime = The number of hnsecs since January 1st, 1 A.D. UTC.
+/
@property void stdTime(long stdTime) pure nothrow
{
_stdTime = stdTime;
}
version(testStdDateTime) unittest
{
static void test(long stdTime, in SysTime expected, size_t line = __LINE__)
{
auto st = SysTime(0, UTC());
st.stdTime = stdTime;
_assertPred!"=="(st, expected);
}
test(0, SysTime(Date(1, 1, 1), UTC()));
test(1, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1), UTC()));
test(-1, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999), UTC()));
test(330_000_502L, SysTime(DateTime(1, 1, 1, 0, 0, 33), FracSec.from!"hnsecs"(502), UTC()));
test(621_355_968_000_000_000L, SysTime(DateTime(1970, 1, 1, 0, 0, 0), UTC()));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.stdTime = 27));
//static assert(!__traits(compiles, ist.stdTime = 27));
}
/++
The current time zone of this $(D SysTime). Its internal time is always
kept in UTC, so there are no conversion issues between time zones due to
DST. Functions which return all or part of the time - such as hours -
adjust the time to this $(D SysTime)'s time zone before returning.
+/
@property immutable(TimeZone) timezone() const pure nothrow
{
return _timezone;
}
/++
The current time zone of this $(D SysTime). It's internal time is always
kept in UTC, so there are no conversion issues between time zones due to
DST. Functions which return all or part of the time - such as hours -
adjust the time to this $(D SysTime)'s time zone before returning.
Params:
tz = The $(D TimeZone) to set this $(D SysTime)'s time zone to.
+/
@property void timezone(immutable TimeZone timezone) pure nothrow
{
if(timezone is null)
_timezone = LocalTime();
else
_timezone = timezone;
}
/++
Returns whether DST is in effect for this $(D SysTime).
+/
@property bool dstInEffect() const nothrow
{
return _timezone.dstInEffect(_stdTime);
//This function's unit testing is done in the time zone classes.
}
/++
Returns a $(D SysTime) with the same std time as this one, but with
$(D LocalTime) as its time zone.
+/
SysTime toLocalTime() const nothrow
{
return SysTime(_stdTime, LocalTime());
}
unittest
{
version(testStdDateTime)
{
{
auto sysTime = SysTime(DateTime(1982, 1, 4, 8, 59, 7), FracSec.from!"hnsecs"(27));
_assertPred!"=="(sysTime, sysTime.toLocalTime());
_assertPred!"=="(sysTime._stdTime, sysTime.toLocalTime()._stdTime);
assert(sysTime.toLocalTime().timezone is LocalTime());
assert(sysTime.toLocalTime().timezone is sysTime.timezone);
assert(sysTime.toLocalTime().timezone !is UTC());
}
{
immutable stz = new SimpleTimeZone(-3 * 60);
auto sysTime = SysTime(DateTime(1982, 1, 4, 8, 59, 7), FracSec.from!"hnsecs"(27), stz);
_assertPred!"=="(sysTime, sysTime.toLocalTime());
_assertPred!"=="(sysTime._stdTime, sysTime.toLocalTime()._stdTime);
assert(sysTime.toLocalTime().timezone is LocalTime());
assert(sysTime.toLocalTime().timezone !is UTC());
assert(sysTime.toLocalTime().timezone !is stz);
}
}
}
/++
Returns a $(D SysTime) with the same std time as this one, but with
$(D UTC) as its time zone.
+/
SysTime toUTC() const pure nothrow
{
return SysTime(_stdTime, UTC());
}
unittest
{
version(testStdDateTime)
{
auto sysTime = SysTime(DateTime(1982, 1, 4, 8, 59, 7), FracSec.from!"hnsecs"(27));
_assertPred!"=="(sysTime, sysTime.toUTC());
_assertPred!"=="(sysTime._stdTime, sysTime.toUTC()._stdTime);
assert(sysTime.toUTC().timezone is UTC());
assert(sysTime.toUTC().timezone !is LocalTime());
assert(sysTime.toUTC().timezone !is sysTime.timezone);
}
}
/++
Returns a $(D SysTime) with the same std time as this one, but with
given time zone as its time zone.
+/
SysTime toOtherTZ(immutable TimeZone tz) const pure nothrow
{
if(tz is null)
return SysTime(_stdTime, LocalTime());
else
return SysTime(_stdTime, tz);
}
unittest
{
version(testStdDateTime)
{
immutable stz = new SimpleTimeZone(11 * 60);
auto sysTime = SysTime(DateTime(1982, 1, 4, 8, 59, 7), FracSec.from!"hnsecs"(27));
_assertPred!"=="(sysTime, sysTime.toOtherTZ(stz));
_assertPred!"=="(sysTime._stdTime, sysTime.toOtherTZ(stz)._stdTime);
assert(sysTime.toOtherTZ(stz).timezone is stz);
assert(sysTime.toOtherTZ(stz).timezone !is LocalTime());
assert(sysTime.toOtherTZ(stz).timezone !is UTC());
}
}
/++
Returns a $(D time_t) which represents the same time as this
$(D SysTime).
Note that like all conversions in std.datetime, this is a truncating
conversion.
If $(D time_t) is 32 bits, rather than 64, and the result can't fit in a
32-bit value, then the closest value that can be held in 32 bits will be
used (so $(D time_t.max) if it goes over and $(D time_t.min) if it goes
under).
+/
time_t toUnixTime() const pure nothrow
{
return stdTimeToUnixTime(_stdTime);
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(SysTime(DateTime(1970, 1, 1), UTC()).toUnixTime, 0);
_assertPred!"=="(SysTime(DateTime(1970, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1), UTC()).toUnixTime, 0);
_assertPred!"=="(SysTime(DateTime(1970, 1, 1, 0, 0, 0), FracSec.from!"usecs"(1), UTC()).toUnixTime, 0);
_assertPred!"=="(SysTime(DateTime(1970, 1, 1, 0, 0, 0), FracSec.from!"msecs"(1), UTC()).toUnixTime, 0);
_assertPred!"=="(SysTime(DateTime(1970, 1, 1, 0, 0, 1), UTC()).toUnixTime, 1);
_assertPred!"=="(SysTime(DateTime(1969, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999), UTC()).toUnixTime, 0);
_assertPred!"=="(SysTime(DateTime(1969, 12, 31, 23, 59, 59), FracSec.from!"usecs"(999_999), UTC()).toUnixTime, 0);
_assertPred!"=="(SysTime(DateTime(1969, 12, 31, 23, 59, 59), FracSec.from!"msecs"(999), UTC()).toUnixTime, 0);
_assertPred!"=="(SysTime(DateTime(1969, 12, 31, 23, 59, 59), UTC()).toUnixTime, -1);
}
}
/++
Returns a $(D timeval) which represents this $(D SysTime).
Note that like all conversions in std.datetime, this is a truncating
conversion.
If $(D time_t) is 32 bits, rather than 64, and the result can't fit in a
32-bit value, then the closest value that can be held in 32 bits will be
used for $(D tv_sec). (so $(D time_t.max) if it goes over and
$(D time_t.min) if it goes under).
+/
timeval toTimeVal() const pure nothrow
{
immutable tv_sec = toUnixTime();
immutable fracHNSecs = removeUnitsFromHNSecs!"seconds"(_stdTime - 621355968000000000L);
immutable tv_usec = cast(int)convert!("hnsecs", "usecs")(fracHNSecs);
return timeval(tv_sec, tv_usec);
}
unittest
{
version(testStdDateTime)
{
assert(SysTime(DateTime(1970, 1, 1), UTC()).toTimeVal() == timeval(0, 0));
assert(SysTime(DateTime(1970, 1, 1), FracSec.from!"hnsecs"(9), UTC()).toTimeVal() == timeval(0, 0));
assert(SysTime(DateTime(1970, 1, 1), FracSec.from!"hnsecs"(10), UTC()).toTimeVal() == timeval(0, 1));
assert(SysTime(DateTime(1970, 1, 1), FracSec.from!"usecs"(7), UTC()).toTimeVal() == timeval(0, 7));
assert(SysTime(DateTime(1970, 1, 1, 0, 0, 1), UTC()).toTimeVal() == timeval(1, 0));
assert(SysTime(DateTime(1970, 1, 1, 0, 0, 1), FracSec.from!"hnsecs"(9), UTC()).toTimeVal() == timeval(1, 0));
assert(SysTime(DateTime(1970, 1, 1, 0, 0, 1), FracSec.from!"hnsecs"(10), UTC()).toTimeVal() == timeval(1, 1));
assert(SysTime(DateTime(1970, 1, 1, 0, 0, 1), FracSec.from!"usecs"(7), UTC()).toTimeVal() == timeval(1, 7));
assert(SysTime(DateTime(1969, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999), UTC()).toTimeVal() ==
timeval(0, 0));
assert(SysTime(DateTime(1969, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_990), UTC()).toTimeVal() ==
timeval(0, -1));
assert(SysTime(DateTime(1969, 12, 31, 23, 59, 59), FracSec.from!"usecs"(999_999), UTC()).toTimeVal() ==
timeval(0, -1));
assert(SysTime(DateTime(1969, 12, 31, 23, 59, 59), FracSec.from!"usecs"(999), UTC()).toTimeVal() ==
timeval(0, -999_001));
assert(SysTime(DateTime(1969, 12, 31, 23, 59, 59), FracSec.from!"msecs"(999), UTC()).toTimeVal() ==
timeval(0, -1000));
assert(SysTime(DateTime(1969, 12, 31, 23, 59, 59), UTC()).toTimeVal() == timeval(-1, 0));
assert(SysTime(DateTime(1969, 12, 31, 23, 59, 58), FracSec.from!"usecs"(17), UTC()).toTimeVal() ==
timeval(-1, -999_983));
}
}
/++
Returns a $(D tm) which represents this $(D SysTime).
+/
tm toTM() const nothrow
{
try
{
auto dateTime = cast(DateTime)this;
tm timeInfo;
timeInfo.tm_sec = dateTime.second;
timeInfo.tm_min = dateTime.minute;
timeInfo.tm_hour = dateTime.hour;
timeInfo.tm_mday = dateTime.day;
timeInfo.tm_mon = dateTime.month - 1;
timeInfo.tm_year = dateTime.year - 1900;
timeInfo.tm_wday = dateTime.dayOfWeek;
timeInfo.tm_yday = dateTime.dayOfYear - 1;
timeInfo.tm_isdst = _timezone.dstInEffect(_stdTime);
version(Posix)
{
char[] zone = (timeInfo.tm_isdst ? _timezone.dstName : _timezone.stdName).dup;
zone ~= "\0";
timeInfo.tm_gmtoff = cast(int)convert!("hnsecs", "seconds")(adjTime - _stdTime);
timeInfo.tm_zone = zone.ptr;
}
return timeInfo;
}
catch(Exception e)
assert(0, "Either DateTime's constructor threw.");
}
unittest
{
version(testStdDateTime)
{
version(Posix)
{
scope(exit) clearTZEnvVar();
setTZEnvVar("America/Los_Angeles");
}
{
auto timeInfo = SysTime(DateTime(1970, 1, 1)).toTM();
_assertPred!"=="(timeInfo.tm_sec, 0);
_assertPred!"=="(timeInfo.tm_min, 0);
_assertPred!"=="(timeInfo.tm_hour, 0);
_assertPred!"=="(timeInfo.tm_mday, 1);
_assertPred!"=="(timeInfo.tm_mon, 0);
_assertPred!"=="(timeInfo.tm_year, 70);
_assertPred!"=="(timeInfo.tm_wday, 4);
_assertPred!"=="(timeInfo.tm_yday, 0);
version(Posix)
_assertPred!"=="(timeInfo.tm_isdst, 0);
else version(Windows)
assert(timeInfo.tm_isdst == 0 || timeInfo.tm_isdst == 1);
version(Posix)
{
_assertPred!"=="(timeInfo.tm_gmtoff, -8 * 60 * 60);
_assertPred!"=="(to!string(timeInfo.tm_zone), "PST");
}
}
{
auto timeInfo = SysTime(DateTime(2010, 7, 4, 12, 15, 7), FracSec.from!"hnsecs"(15)).toTM();
_assertPred!"=="(timeInfo.tm_sec, 7);
_assertPred!"=="(timeInfo.tm_min, 15);
_assertPred!"=="(timeInfo.tm_hour, 12);
_assertPred!"=="(timeInfo.tm_mday, 4);
_assertPred!"=="(timeInfo.tm_mon, 6);
_assertPred!"=="(timeInfo.tm_year, 110);
_assertPred!"=="(timeInfo.tm_wday, 0);
_assertPred!"=="(timeInfo.tm_yday, 184);
version(Posix)
_assertPred!"=="(timeInfo.tm_isdst, 1);
else version(Windows)
assert(timeInfo.tm_isdst == 0 || timeInfo.tm_isdst == 1);
version(Posix)
{
_assertPred!"=="(timeInfo.tm_gmtoff, -7 * 60 * 60);
_assertPred!"=="(to!string(timeInfo.tm_zone), "PDT");
}
}
}
}
/++
Adds the given number of years or months to this $(D SysTime). A
negative number will subtract.
Note that if day overflow is allowed, and the date with the adjusted
year/month overflows the number of days in the new month, then the month
will be incremented by one, and the day set to the number of days
overflowed. (e.g. if the day were 31 and the new month were June, then
the month would be incremented to July, and the new day would be 1). If
day overflow is not allowed, then the day will be set to the last valid
day in the month (e.g. June 31st would become June 30th).
Params:
units = The type of units to add ("years" or "months").
value = The number of months or years to add to this
$(D SysTime).
allowOverflow = Whether the days should be allowed to overflow,
causing the month to increment.
Examples:
--------------------
auto st1 = SysTime(DateTime(2010, 1, 1, 12, 30, 33));
st1.add!"months"(11);
assert(st1 == SysTime(DateTime(2010, 12, 1, 12, 30, 33)));
auto st2 = SysTime(DateTime(2010, 1, 1, 12, 30, 33));
st2.add!"months"(-11);
assert(st2 == SysTime(DateTime(2009, 2, 1, 12, 30, 33)));
auto st3 = SysTime(DateTime(2000, 2, 29, 12, 30, 33));
st3.add!"years"(1);
assert(st3 == SysTime(DateTime(2001, 3, 1, 12, 30, 33)));
auto st4 = SysTime(DateTime(2000, 2, 29, 12, 30, 33));
st4.add!"years"(1, AllowDayOverflow.no);
assert(st4 == SysTime(DateTime(2001, 2, 28, 12, 30, 33)));
--------------------
+/
ref SysTime add(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) nothrow
if(units == "years" ||
units == "months")
{
auto hnsecs = adjTime;
auto days = splitUnitsFromHNSecs!"days"(hnsecs) + 1;
if(hnsecs < 0)
{
hnsecs += convert!("hours", "hnsecs")(24);
--days;
}
auto date = Date(cast(int)days);
date.add!units(value, allowOverflow);
days = date.dayOfGregorianCal - 1;
if(days < 0)
{
hnsecs -= convert!("hours", "hnsecs")(24);
++days;
}
immutable newDaysHNSecs = convert!("days", "hnsecs")(days);
adjTime = newDaysHNSecs + hnsecs;
return this;
}
//Verify Examples.
unittest
{
version (testStdDateTime)
{
auto st1 = SysTime(DateTime(2010, 1, 1, 12, 30, 33));
st1.add!"months"(11);
assert(st1 == SysTime(DateTime(2010, 12, 1, 12, 30, 33)));
auto st2 = SysTime(DateTime(2010, 1, 1, 12, 30, 33));
st2.add!"months"(-11);
assert(st2 == SysTime(DateTime(2009, 2, 1, 12, 30, 33)));
auto st3 = SysTime(DateTime(2000, 2, 29, 12, 30, 33));
st3.add!"years"(1);
assert(st3 == SysTime(DateTime(2001, 3, 1, 12, 30, 33)));
auto st4 = SysTime(DateTime(2000, 2, 29, 12, 30, 33));
st4.add!"years"(1, AllowDayOverflow.no);
assert(st4 == SysTime(DateTime(2001, 2, 28, 12, 30, 33)));
}
}
//Test add!"years"() with AllowDayOverlow.yes
unittest
{
version(testStdDateTime)
{
//Test A.D.
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.add!"years"(7);
_assertPred!"=="(sysTime, SysTime(Date(2006, 7, 6)));
sysTime.add!"years"(-9);
_assertPred!"=="(sysTime, SysTime(Date(1997, 7, 6)));
}
{
auto sysTime = SysTime(Date(1999, 2, 28));
sysTime.add!"years"(1);
_assertPred!"=="(sysTime, SysTime(Date(2000, 2, 28)));
}
{
auto sysTime = SysTime(Date(2000, 2, 29));
sysTime.add!"years"(-1);
_assertPred!"=="(sysTime, SysTime(Date(1999, 3, 1)));
}
{
auto sysTime = SysTime(DateTime(1999, 7, 6, 12, 7, 3), FracSec.from!"msecs"(234));
sysTime.add!"years"(7);
_assertPred!"=="(sysTime, SysTime(DateTime(2006, 7, 6, 12, 7, 3), FracSec.from!"msecs"(234)));
sysTime.add!"years"(-9);
_assertPred!"=="(sysTime, SysTime(DateTime(1997, 7, 6, 12, 7, 3), FracSec.from!"msecs"(234)));
}
{
auto sysTime = SysTime(DateTime(1999, 2, 28, 0, 7, 2), FracSec.from!"usecs"(1207));
sysTime.add!"years"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(2000, 2, 28, 0, 7, 2), FracSec.from!"usecs"(1207)));
}
{
auto sysTime = SysTime(DateTime(2000, 2, 29, 0, 7, 2), FracSec.from!"usecs"(1207));
sysTime.add!"years"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 3, 1, 0, 7, 2), FracSec.from!"usecs"(1207)));
}
//Test B.C.
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.add!"years"(-7);
_assertPred!"=="(sysTime, SysTime(Date(-2006, 7, 6)));
sysTime.add!"years"(9);
_assertPred!"=="(sysTime, SysTime(Date(-1997, 7, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 2, 28));
sysTime.add!"years"(-1);
_assertPred!"=="(sysTime, SysTime(Date(-2000, 2, 28)));
}
{
auto sysTime = SysTime(Date(-2000, 2, 29));
sysTime.add!"years"(1);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 3, 1)));
}
{
auto sysTime = SysTime(DateTime(-1999, 7, 6, 12, 7, 3), FracSec.from!"msecs"(234));
sysTime.add!"years"(-7);
_assertPred!"=="(sysTime, SysTime(DateTime(-2006, 7, 6, 12, 7, 3), FracSec.from!"msecs"(234)));
sysTime.add!"years"(9);
_assertPred!"=="(sysTime, SysTime(DateTime(-1997, 7, 6, 12, 7, 3), FracSec.from!"msecs"(234)));
}
{
auto sysTime = SysTime(DateTime(-1999, 2, 28, 3, 3, 3), FracSec.from!"hnsecs"(3));
sysTime.add!"years"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(-2000, 2, 28, 3, 3, 3), FracSec.from!"hnsecs"(3)));
}
{
auto sysTime = SysTime(DateTime(-2000, 2, 29, 3, 3, 3), FracSec.from!"hnsecs"(3));
sysTime.add!"years"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(-1999, 3, 1, 3, 3, 3), FracSec.from!"hnsecs"(3)));
}
//Test Both
{
auto sysTime = SysTime(Date(4, 7, 6));
sysTime.add!"years"(-5);
_assertPred!"=="(sysTime, SysTime(Date(-1, 7, 6)));
sysTime.add!"years"(5);
_assertPred!"=="(sysTime, SysTime(Date(4, 7, 6)));
}
{
auto sysTime = SysTime(Date(-4, 7, 6));
sysTime.add!"years"(5);
_assertPred!"=="(sysTime, SysTime(Date(1, 7, 6)));
sysTime.add!"years"(-5);
_assertPred!"=="(sysTime, SysTime(Date(-4, 7, 6)));
}
{
auto sysTime = SysTime(Date(4, 7, 6));
sysTime.add!"years"(-8);
_assertPred!"=="(sysTime, SysTime(Date(-4, 7, 6)));
sysTime.add!"years"(8);
_assertPred!"=="(sysTime, SysTime(Date(4, 7, 6)));
}
{
auto sysTime = SysTime(Date(-4, 7, 6));
sysTime.add!"years"(8);
_assertPred!"=="(sysTime, SysTime(Date(4, 7, 6)));
sysTime.add!"years"(-8);
_assertPred!"=="(sysTime, SysTime(Date(-4, 7, 6)));
}
{
auto sysTime = SysTime(Date(-4, 2, 29));
sysTime.add!"years"(5);
_assertPred!"=="(sysTime, SysTime(Date(1, 3, 1)));
}
{
auto sysTime = SysTime(Date(4, 2, 29));
sysTime.add!"years"(-5);
_assertPred!"=="(sysTime, SysTime(Date(-1, 3, 1)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0));
sysTime.add!"years"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
sysTime.add!"years"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.add!"years"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.add!"years"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0));
sysTime.add!"years"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
sysTime.add!"years"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(0, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.add!"years"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.add!"years"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(4, 7, 6, 14, 7, 1), FracSec.from!"usecs"(54329));
sysTime.add!"years"(-5);
_assertPred!"=="(sysTime, SysTime(DateTime(-1, 7, 6, 14, 7, 1), FracSec.from!"usecs"(54329)));
sysTime.add!"years"(5);
_assertPred!"=="(sysTime, SysTime(DateTime(4, 7, 6, 14, 7, 1), FracSec.from!"usecs"(54329)));
}
{
auto sysTime = SysTime(DateTime(-4, 7, 6, 14, 7, 1), FracSec.from!"usecs"(54329));
sysTime.add!"years"(5);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 7, 6, 14, 7, 1), FracSec.from!"usecs"(54329)));
sysTime.add!"years"(-5);
_assertPred!"=="(sysTime, SysTime(DateTime(-4, 7, 6, 14, 7, 1), FracSec.from!"usecs"(54329)));
}
{
auto sysTime = SysTime(DateTime(-4, 2, 29, 5, 5, 5), FracSec.from!"msecs"(555));
sysTime.add!"years"(5);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 3, 1, 5, 5, 5), FracSec.from!"msecs"(555)));
}
{
auto sysTime = SysTime(DateTime(4, 2, 29, 5, 5, 5), FracSec.from!"msecs"(555));
sysTime.add!"years"(-5);
_assertPred!"=="(sysTime, SysTime(DateTime(-1, 3, 1, 5, 5, 5), FracSec.from!"msecs"(555)));
}
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.add!"years"(4)));
//static assert(!__traits(compiles, ist.add!"years"(4)));
}
}
//Test add!"years"() with AllowDayOverlow.no
unittest
{
version(testStdDateTime)
{
//Test A.D.
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.add!"years"(7, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(2006, 7, 6)));
sysTime.add!"years"(-9, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1997, 7, 6)));
}
{
auto sysTime = SysTime(Date(1999, 2, 28));
sysTime.add!"years"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(2000, 2, 28)));
}
{
auto sysTime = SysTime(Date(2000, 2, 29));
sysTime.add!"years"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 2, 28)));
}
{
auto sysTime = SysTime(DateTime(1999, 7, 6, 12, 7, 3), FracSec.from!"msecs"(234));
sysTime.add!"years"(7, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(2006, 7, 6, 12, 7, 3), FracSec.from!"msecs"(234)));
sysTime.add!"years"(-9, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1997, 7, 6, 12, 7, 3), FracSec.from!"msecs"(234)));
}
{
auto sysTime = SysTime(DateTime(1999, 2, 28, 0, 7, 2), FracSec.from!"usecs"(1207));
sysTime.add!"years"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(2000, 2, 28, 0, 7, 2), FracSec.from!"usecs"(1207)));
}
{
auto sysTime = SysTime(DateTime(2000, 2, 29, 0, 7, 2), FracSec.from!"usecs"(1207));
sysTime.add!"years"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 2, 28, 0, 7, 2), FracSec.from!"usecs"(1207)));
}
//Test B.C.
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.add!"years"(-7, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-2006, 7, 6)));
sysTime.add!"years"(9, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1997, 7, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 2, 28));
sysTime.add!"years"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-2000, 2, 28)));
}
{
auto sysTime = SysTime(Date(-2000, 2, 29));
sysTime.add!"years"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 2, 28)));
}
{
auto sysTime = SysTime(DateTime(-1999, 7, 6, 12, 7, 3), FracSec.from!"msecs"(234));
sysTime.add!"years"(-7, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-2006, 7, 6, 12, 7, 3), FracSec.from!"msecs"(234)));
sysTime.add!"years"(9, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-1997, 7, 6, 12, 7, 3), FracSec.from!"msecs"(234)));
}
{
auto sysTime = SysTime(DateTime(-1999, 2, 28, 3, 3, 3), FracSec.from!"hnsecs"(3));
sysTime.add!"years"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-2000, 2, 28, 3, 3, 3), FracSec.from!"hnsecs"(3)));
}
{
auto sysTime = SysTime(DateTime(-2000, 2, 29, 3, 3, 3), FracSec.from!"hnsecs"(3));
sysTime.add!"years"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-1999, 2, 28, 3, 3, 3), FracSec.from!"hnsecs"(3)));
}
//Test Both
{
auto sysTime = SysTime(Date(4, 7, 6));
sysTime.add!"years"(-5, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1, 7, 6)));
sysTime.add!"years"(5, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(4, 7, 6)));
}
{
auto sysTime = SysTime(Date(-4, 7, 6));
sysTime.add!"years"(5, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1, 7, 6)));
sysTime.add!"years"(-5, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-4, 7, 6)));
}
{
auto sysTime = SysTime(Date(4, 7, 6));
sysTime.add!"years"(-8, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-4, 7, 6)));
sysTime.add!"years"(8, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(4, 7, 6)));
}
{
auto sysTime = SysTime(Date(-4, 7, 6));
sysTime.add!"years"(8, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(4, 7, 6)));
sysTime.add!"years"(-8, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-4, 7, 6)));
}
{
auto sysTime = SysTime(Date(-4, 2, 29));
sysTime.add!"years"(5, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1, 2, 28)));
}
{
auto sysTime = SysTime(Date(4, 2, 29));
sysTime.add!"years"(-5, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1, 2, 28)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0));
sysTime.add!"years"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
sysTime.add!"years"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.add!"years"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.add!"years"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0));
sysTime.add!"years"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
sysTime.add!"years"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(0, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.add!"years"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.add!"years"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(4, 7, 6, 14, 7, 1), FracSec.from!"usecs"(54329));
sysTime.add!"years"(-5);
_assertPred!"=="(sysTime, SysTime(DateTime(-1, 7, 6, 14, 7, 1), FracSec.from!"usecs"(54329)));
sysTime.add!"years"(5);
_assertPred!"=="(sysTime, SysTime(DateTime(4, 7, 6, 14, 7, 1), FracSec.from!"usecs"(54329)));
}
{
auto sysTime = SysTime(DateTime(4, 7, 6, 14, 7, 1), FracSec.from!"usecs"(54329));
sysTime.add!"years"(-5, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-1, 7, 6, 14, 7, 1), FracSec.from!"usecs"(54329)));
sysTime.add!"years"(5, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(4, 7, 6, 14, 7, 1), FracSec.from!"usecs"(54329)));
}
{
auto sysTime = SysTime(DateTime(-4, 7, 6, 14, 7, 1), FracSec.from!"usecs"(54329));
sysTime.add!"years"(5, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 7, 6, 14, 7, 1), FracSec.from!"usecs"(54329)));
sysTime.add!"years"(-5, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-4, 7, 6, 14, 7, 1), FracSec.from!"usecs"(54329)));
}
{
auto sysTime = SysTime(DateTime(-4, 2, 29, 5, 5, 5), FracSec.from!"msecs"(555));
sysTime.add!"years"(5, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 2, 28, 5, 5, 5), FracSec.from!"msecs"(555)));
}
{
auto sysTime = SysTime(DateTime(4, 2, 29, 5, 5, 5), FracSec.from!"msecs"(555));
sysTime.add!"years"(-5, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-1, 2, 28, 5, 5, 5), FracSec.from!"msecs"(555)));
}
}
}
//Test add!"months"() with AllowDayOverlow.yes
unittest
{
version(testStdDateTime)
{
//Test A.D.
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.add!"months"(3);
_assertPred!"=="(sysTime, SysTime(Date(1999, 10, 6)));
sysTime.add!"months"(-4);
_assertPred!"=="(sysTime, SysTime(Date(1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.add!"months"(6);
_assertPred!"=="(sysTime, SysTime(Date(2000, 1, 6)));
sysTime.add!"months"(-6);
_assertPred!"=="(sysTime, SysTime(Date(1999, 7, 6)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.add!"months"(27);
_assertPred!"=="(sysTime, SysTime(Date(2001, 10, 6)));
sysTime.add!"months"(-28);
_assertPred!"=="(sysTime, SysTime(Date(1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(1999, 5, 31));
sysTime.add!"months"(1);
_assertPred!"=="(sysTime, SysTime(Date(1999, 7, 1)));
}
{
auto sysTime = SysTime(Date(1999, 5, 31));
sysTime.add!"months"(-1);
_assertPred!"=="(sysTime, SysTime(Date(1999, 5, 1)));
}
{
auto sysTime = SysTime(Date(1999, 2, 28));
sysTime.add!"months"(12);
_assertPred!"=="(sysTime, SysTime(Date(2000, 2, 28)));
}
{
auto sysTime = SysTime(Date(2000, 2, 29));
sysTime.add!"months"(12);
_assertPred!"=="(sysTime, SysTime(Date(2001, 3, 1)));
}
{
auto sysTime = SysTime(Date(1999, 7, 31));
sysTime.add!"months"(1);
_assertPred!"=="(sysTime, SysTime(Date(1999, 8, 31)));
sysTime.add!"months"(1);
_assertPred!"=="(sysTime, SysTime(Date(1999, 10, 1)));
}
{
auto sysTime = SysTime(Date(1998, 8, 31));
sysTime.add!"months"(13);
_assertPred!"=="(sysTime, SysTime(Date(1999, 10, 1)));
sysTime.add!"months"(-13);
_assertPred!"=="(sysTime, SysTime(Date(1998, 9, 1)));
}
{
auto sysTime = SysTime(Date(1997, 12, 31));
sysTime.add!"months"(13);
_assertPred!"=="(sysTime, SysTime(Date(1999, 1, 31)));
sysTime.add!"months"(-13);
_assertPred!"=="(sysTime, SysTime(Date(1997, 12, 31)));
}
{
auto sysTime = SysTime(Date(1997, 12, 31));
sysTime.add!"months"(14);
_assertPred!"=="(sysTime, SysTime(Date(1999, 3, 3)));
sysTime.add!"months"(-14);
_assertPred!"=="(sysTime, SysTime(Date(1998, 1, 3)));
}
{
auto sysTime = SysTime(Date(1998, 12, 31));
sysTime.add!"months"(14);
_assertPred!"=="(sysTime, SysTime(Date(2000, 3, 2)));
sysTime.add!"months"(-14);
_assertPred!"=="(sysTime, SysTime(Date(1999, 1, 2)));
}
{
auto sysTime = SysTime(Date(1999, 12, 31));
sysTime.add!"months"(14);
_assertPred!"=="(sysTime, SysTime(Date(2001, 3, 3)));
sysTime.add!"months"(-14);
_assertPred!"=="(sysTime, SysTime(Date(2000, 1, 3)));
}
{
auto sysTime = SysTime(DateTime(1999, 7, 6, 12, 2, 7), FracSec.from!"usecs"(5007));
sysTime.add!"months"(3);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 10, 6, 12, 2, 7), FracSec.from!"usecs"(5007)));
sysTime.add!"months"(-4);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 6, 6, 12, 2, 7), FracSec.from!"usecs"(5007)));
}
{
auto sysTime = SysTime(DateTime(1998, 12, 31, 7, 7, 7), FracSec.from!"hnsecs"(422202));
sysTime.add!"months"(14);
_assertPred!"=="(sysTime, SysTime(DateTime(2000, 3, 2, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
sysTime.add!"months"(-14);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 1, 2, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
}
{
auto sysTime = SysTime(DateTime(1999, 12, 31, 7, 7, 7), FracSec.from!"hnsecs"(422202));
sysTime.add!"months"(14);
_assertPred!"=="(sysTime, SysTime(DateTime(2001, 3, 3, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
sysTime.add!"months"(-14);
_assertPred!"=="(sysTime, SysTime(DateTime(2000, 1, 3, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
}
//Test B.C.
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.add!"months"(3);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 10, 6)));
sysTime.add!"months"(-4);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.add!"months"(6);
_assertPred!"=="(sysTime, SysTime(Date(-1998, 1, 6)));
sysTime.add!"months"(-6);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 7, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.add!"months"(-27);
_assertPred!"=="(sysTime, SysTime(Date(-2001, 4, 6)));
sysTime.add!"months"(28);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 8, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 5, 31));
sysTime.add!"months"(1);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 7, 1)));
}
{
auto sysTime = SysTime(Date(-1999, 5, 31));
sysTime.add!"months"(-1);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 5, 1)));
}
{
auto sysTime = SysTime(Date(-1999, 2, 28));
sysTime.add!"months"(-12);
_assertPred!"=="(sysTime, SysTime(Date(-2000, 2, 28)));
}
{
auto sysTime = SysTime(Date(-2000, 2, 29));
sysTime.add!"months"(-12);
_assertPred!"=="(sysTime, SysTime(Date(-2001, 3, 1)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 31));
sysTime.add!"months"(1);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 8, 31)));
sysTime.add!"months"(1);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 10, 1)));
}
{
auto sysTime = SysTime(Date(-1998, 8, 31));
sysTime.add!"months"(13);
_assertPred!"=="(sysTime, SysTime(Date(-1997, 10, 1)));
sysTime.add!"months"(-13);
_assertPred!"=="(sysTime, SysTime(Date(-1998, 9, 1)));
}
{
auto sysTime = SysTime(Date(-1997, 12, 31));
sysTime.add!"months"(13);
_assertPred!"=="(sysTime, SysTime(Date(-1995, 1, 31)));
sysTime.add!"months"(-13);
_assertPred!"=="(sysTime, SysTime(Date(-1997, 12, 31)));
}
{
auto sysTime = SysTime(Date(-1997, 12, 31));
sysTime.add!"months"(14);
_assertPred!"=="(sysTime, SysTime(Date(-1995, 3, 3)));
sysTime.add!"months"(-14);
_assertPred!"=="(sysTime, SysTime(Date(-1996, 1, 3)));
}
{
auto sysTime = SysTime(Date(-2002, 12, 31));
sysTime.add!"months"(14);
_assertPred!"=="(sysTime, SysTime(Date(-2000, 3, 2)));
sysTime.add!"months"(-14);
_assertPred!"=="(sysTime, SysTime(Date(-2001, 1, 2)));
}
{
auto sysTime = SysTime(Date(-2001, 12, 31));
sysTime.add!"months"(14);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 3, 3)));
sysTime.add!"months"(-14);
_assertPred!"=="(sysTime, SysTime(Date(-2000, 1, 3)));
}
{
auto sysTime = SysTime(DateTime(-1999, 7, 6, 12, 2, 7), FracSec.from!"usecs"(5007));
sysTime.add!"months"(3);
_assertPred!"=="(sysTime, SysTime(DateTime(-1999, 10, 6, 12, 2, 7), FracSec.from!"usecs"(5007)));
sysTime.add!"months"(-4);
_assertPred!"=="(sysTime, SysTime(DateTime(-1999, 6, 6, 12, 2, 7), FracSec.from!"usecs"(5007)));
}
{
auto sysTime = SysTime(DateTime(-2002, 12, 31, 7, 7, 7), FracSec.from!"hnsecs"(422202));
sysTime.add!"months"(14);
_assertPred!"=="(sysTime, SysTime(DateTime(-2000, 3, 2, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
sysTime.add!"months"(-14);
_assertPred!"=="(sysTime, SysTime(DateTime(-2001, 1, 2, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
}
{
auto sysTime = SysTime(DateTime(-2001, 12, 31, 7, 7, 7), FracSec.from!"hnsecs"(422202));
sysTime.add!"months"(14);
_assertPred!"=="(sysTime, SysTime(DateTime(-1999, 3, 3, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
sysTime.add!"months"(-14);
_assertPred!"=="(sysTime, SysTime(DateTime(-2000, 1, 3, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
}
//Test Both
{
auto sysTime = SysTime(Date(1, 1, 1));
sysTime.add!"months"(-1);
_assertPred!"=="(sysTime, SysTime(Date(0, 12, 1)));
sysTime.add!"months"(1);
_assertPred!"=="(sysTime, SysTime(Date(1, 1, 1)));
}
{
auto sysTime = SysTime(Date(4, 1, 1));
sysTime.add!"months"(-48);
_assertPred!"=="(sysTime, SysTime(Date(0, 1, 1)));
sysTime.add!"months"(48);
_assertPred!"=="(sysTime, SysTime(Date(4, 1, 1)));
}
{
auto sysTime = SysTime(Date(4, 3, 31));
sysTime.add!"months"(-49);
_assertPred!"=="(sysTime, SysTime(Date(0, 3, 2)));
sysTime.add!"months"(49);
_assertPred!"=="(sysTime, SysTime(Date(4, 4, 2)));
}
{
auto sysTime = SysTime(Date(4, 3, 31));
sysTime.add!"months"(-85);
_assertPred!"=="(sysTime, SysTime(Date(-3, 3, 3)));
sysTime.add!"months"(85);
_assertPred!"=="(sysTime, SysTime(Date(4, 4, 3)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0));
sysTime.add!"months"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
sysTime.add!"months"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.add!"months"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.add!"months"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 1, 0, 0, 0), FracSec.from!"hnsecs"(0));
sysTime.add!"months"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
sysTime.add!"months"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.add!"months"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.add!"months"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 7, 9), FracSec.from!"hnsecs"(17));
sysTime.add!"months"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 1, 0, 7, 9), FracSec.from!"hnsecs"(17)));
sysTime.add!"months"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 7, 9), FracSec.from!"hnsecs"(17)));
}
{
auto sysTime = SysTime(DateTime(4, 3, 31, 12, 11, 10), FracSec.from!"msecs"(9));
sysTime.add!"months"(-85);
_assertPred!"=="(sysTime, SysTime(DateTime(-3, 3, 3, 12, 11, 10), FracSec.from!"msecs"(9)));
sysTime.add!"months"(85);
_assertPred!"=="(sysTime, SysTime(DateTime(4, 4, 3, 12, 11, 10), FracSec.from!"msecs"(9)));
}
{
auto sysTime = SysTime(DateTime(-3, 3, 31, 12, 11, 10), FracSec.from!"msecs"(9));
sysTime.add!"months"(85);
_assertPred!"=="(sysTime, SysTime(DateTime(4, 5, 1, 12, 11, 10), FracSec.from!"msecs"(9)));
sysTime.add!"months"(-85);
_assertPred!"=="(sysTime, SysTime(DateTime(-3, 4, 1, 12, 11, 10), FracSec.from!"msecs"(9)));
}
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.add!"months"(4)));
//static assert(!__traits(compiles, ist.add!"months"(4)));
}
}
//Test add!"months"() with AllowDayOverlow.no
unittest
{
version(testStdDateTime)
{
//Test A.D.
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.add!"months"(3, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 10, 6)));
sysTime.add!"months"(-4, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.add!"months"(6, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(2000, 1, 6)));
sysTime.add!"months"(-6, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 7, 6)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.add!"months"(27, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(2001, 10, 6)));
sysTime.add!"months"(-28, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(1999, 5, 31));
sysTime.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 6, 30)));
}
{
auto sysTime = SysTime(Date(1999, 5, 31));
sysTime.add!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 4, 30)));
}
{
auto sysTime = SysTime(Date(1999, 2, 28));
sysTime.add!"months"(12, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(2000, 2, 28)));
}
{
auto sysTime = SysTime(Date(2000, 2, 29));
sysTime.add!"months"(12, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(2001, 2, 28)));
}
{
auto sysTime = SysTime(Date(1999, 7, 31));
sysTime.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 8, 31)));
sysTime.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 9, 30)));
}
{
auto sysTime = SysTime(Date(1998, 8, 31));
sysTime.add!"months"(13, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 9, 30)));
sysTime.add!"months"(-13, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1998, 8, 30)));
}
{
auto sysTime = SysTime(Date(1997, 12, 31));
sysTime.add!"months"(13, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 1, 31)));
sysTime.add!"months"(-13, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1997, 12, 31)));
}
{
auto sysTime = SysTime(Date(1997, 12, 31));
sysTime.add!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 2, 28)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1997, 12, 28)));
}
{
auto sysTime = SysTime(Date(1998, 12, 31));
sysTime.add!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(2000, 2, 29)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1998, 12, 29)));
}
{
auto sysTime = SysTime(Date(1999, 12, 31));
sysTime.add!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(2001, 2, 28)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 12, 28)));
}
{
auto sysTime = SysTime(DateTime(1999, 7, 6, 12, 2, 7), FracSec.from!"usecs"(5007));
sysTime.add!"months"(3, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 10, 6, 12, 2, 7), FracSec.from!"usecs"(5007)));
sysTime.add!"months"(-4, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 6, 6, 12, 2, 7), FracSec.from!"usecs"(5007)));
}
{
auto sysTime = SysTime(DateTime(1998, 12, 31, 7, 7, 7), FracSec.from!"hnsecs"(422202));
sysTime.add!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(2000, 2, 29, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1998, 12, 29, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
}
{
auto sysTime = SysTime(DateTime(1999, 12, 31, 7, 7, 7), FracSec.from!"hnsecs"(422202));
sysTime.add!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(2001, 2, 28, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 12, 28, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
}
//Test B.C.
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.add!"months"(3, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 10, 6)));
sysTime.add!"months"(-4, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.add!"months"(6, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1998, 1, 6)));
sysTime.add!"months"(-6, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 7, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.add!"months"(-27, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-2001, 4, 6)));
sysTime.add!"months"(28, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 8, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 5, 31));
sysTime.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 6, 30)));
}
{
auto sysTime = SysTime(Date(-1999, 5, 31));
sysTime.add!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 4, 30)));
}
{
auto sysTime = SysTime(Date(-1999, 2, 28));
sysTime.add!"months"(-12, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-2000, 2, 28)));
}
{
auto sysTime = SysTime(Date(-2000, 2, 29));
sysTime.add!"months"(-12, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-2001, 2, 28)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 31));
sysTime.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 8, 31)));
sysTime.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 9, 30)));
}
{
auto sysTime = SysTime(Date(-1998, 8, 31));
sysTime.add!"months"(13, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1997, 9, 30)));
sysTime.add!"months"(-13, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1998, 8, 30)));
}
{
auto sysTime = SysTime(Date(-1997, 12, 31));
sysTime.add!"months"(13, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1995, 1, 31)));
sysTime.add!"months"(-13, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1997, 12, 31)));
}
{
auto sysTime = SysTime(Date(-1997, 12, 31));
sysTime.add!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1995, 2, 28)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1997, 12, 28)));
}
{
auto sysTime = SysTime(Date(-2002, 12, 31));
sysTime.add!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-2000, 2, 29)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-2002, 12, 29)));
}
{
auto sysTime = SysTime(Date(-2001, 12, 31));
sysTime.add!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 2, 28)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-2001, 12, 28)));
}
{
auto sysTime = SysTime(DateTime(-1999, 7, 6, 12, 2, 7), FracSec.from!"usecs"(5007));
sysTime.add!"months"(3, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-1999, 10, 6, 12, 2, 7), FracSec.from!"usecs"(5007)));
sysTime.add!"months"(-4, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-1999, 6, 6, 12, 2, 7), FracSec.from!"usecs"(5007)));
}
{
auto sysTime = SysTime(DateTime(-2002, 12, 31, 7, 7, 7), FracSec.from!"hnsecs"(422202));
sysTime.add!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-2000, 2, 29, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-2002, 12, 29, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
}
{
auto sysTime = SysTime(DateTime(-2001, 12, 31, 7, 7, 7), FracSec.from!"hnsecs"(422202));
sysTime.add!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-1999, 2, 28, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-2001, 12, 28, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
}
//Test Both
{
auto sysTime = SysTime(Date(1, 1, 1));
sysTime.add!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(0, 12, 1)));
sysTime.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1, 1, 1)));
}
{
auto sysTime = SysTime(Date(4, 1, 1));
sysTime.add!"months"(-48, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(0, 1, 1)));
sysTime.add!"months"(48, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(4, 1, 1)));
}
{
auto sysTime = SysTime(Date(4, 3, 31));
sysTime.add!"months"(-49, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(0, 2, 29)));
sysTime.add!"months"(49, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(4, 3, 29)));
}
{
auto sysTime = SysTime(Date(4, 3, 31));
sysTime.add!"months"(-85, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-3, 2, 28)));
sysTime.add!"months"(85, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(4, 3, 28)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0));
sysTime.add!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
sysTime.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.add!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 1, 0, 0, 0), FracSec.from!"hnsecs"(0));
sysTime.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
sysTime.add!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.add!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 7, 9), FracSec.from!"hnsecs"(17));
sysTime.add!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 1, 0, 7, 9), FracSec.from!"hnsecs"(17)));
sysTime.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 7, 9), FracSec.from!"hnsecs"(17)));
}
{
auto sysTime = SysTime(DateTime(4, 3, 31, 12, 11, 10), FracSec.from!"msecs"(9));
sysTime.add!"months"(-85, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-3, 2, 28, 12, 11, 10), FracSec.from!"msecs"(9)));
sysTime.add!"months"(85, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(4, 3, 28, 12, 11, 10), FracSec.from!"msecs"(9)));
}
{
auto sysTime = SysTime(DateTime(-3, 3, 31, 12, 11, 10), FracSec.from!"msecs"(9));
sysTime.add!"months"(85, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(4, 4, 30, 12, 11, 10), FracSec.from!"msecs"(9)));
sysTime.add!"months"(-85, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-3, 3, 30, 12, 11, 10), FracSec.from!"msecs"(9)));
}
}
}
/++
Adds the given number of years or months to this $(D SysTime). A
negative number will subtract.
The difference between rolling and adding is that rolling does not
affect larger units. So, if you roll a $(D SysTime) 12 months, you
get the exact same $(D SysTime). However, the days can still be affected
due to the differing number of days in each month.
Because there are no units larger than years, there is no difference
between adding and rolling years.
Params:
units = The type of units to add ("years" or "months").
value = The number of months or years to add to this
$(D SysTime).
allowOverflow = Whether the days should be allowed to overflow,
causing the month to increment.
Examples:
--------------------
auto st1 = SysTime(DateTime(2010, 1, 1, 12, 33, 33));
st1.roll!"months"(1);
assert(st1 == SysTime(DateTime(2010, 2, 1, 12, 33, 33)));
auto st2 = SysTime(DateTime(2010, 1, 1, 12, 33, 33));
st2.roll!"months"(-1);
assert(st2 == SysTime(DateTime(2010, 12, 1, 12, 33, 33)));
auto st3 = SysTime(DateTime(1999, 1, 29, 12, 33, 33));
st3.roll!"months"(1);
assert(st3 == SysTime(DateTime(1999, 3, 1, 12, 33, 33)));
auto st4 = SysTime(DateTime(1999, 1, 29, 12, 33, 33));
st4.roll!"months"(1, AllowDayOverflow.no);
assert(st4 == SysTime(DateTime(1999, 2, 28, 12, 33, 33)));
auto st5 = SysTime(DateTime(2000, 2, 29, 12, 30, 33));
st5.roll!"years"(1);
assert(st5 == SysTime(DateTime(2001, 3, 1, 12, 30, 33)));
auto st6 = SysTime(DateTime(2000, 2, 29, 12, 30, 33));
st6.roll!"years"(1, AllowDayOverflow.no);
assert(st6 == SysTime(DateTime(2001, 2, 28, 12, 30, 33)));
--------------------
+/
/+ref SysTime+/ void roll(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) nothrow
if(units == "years")
{
add!"years"(value, allowOverflow);
}
unittest
{
version(testStdDateTime)
{
//Verify Examples.
auto st1 = SysTime(DateTime(2010, 1, 1, 12, 33, 33));
st1.roll!"months"(1);
assert(st1 == SysTime(DateTime(2010, 2, 1, 12, 33, 33)));
auto st2 = SysTime(DateTime(2010, 1, 1, 12, 33, 33));
st2.roll!"months"(-1);
assert(st2 == SysTime(DateTime(2010, 12, 1, 12, 33, 33)));
auto st3 = SysTime(DateTime(1999, 1, 29, 12, 33, 33));
st3.roll!"months"(1);
assert(st3 == SysTime(DateTime(1999, 3, 1, 12, 33, 33)));
auto st4 = SysTime(DateTime(1999, 1, 29, 12, 33, 33));
st4.roll!"months"(1, AllowDayOverflow.no);
assert(st4 == SysTime(DateTime(1999, 2, 28, 12, 33, 33)));
auto st5 = SysTime(DateTime(2000, 2, 29, 12, 30, 33));
st5.roll!"years"(1);
assert(st5 == SysTime(DateTime(2001, 3, 1, 12, 30, 33)));
auto st6 = SysTime(DateTime(2000, 2, 29, 12, 30, 33));
st6.roll!"years"(1, AllowDayOverflow.no);
assert(st6 == SysTime(DateTime(2001, 2, 28, 12, 30, 33)));
}
}
unittest
{
version(testStdDateTime)
{
auto st = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, st.roll!"years"(4)));
static assert(!__traits(compiles, cst.roll!"years"(4)));
//static assert(!__traits(compiles, ist.roll!"years"(4)));
}
}
//Shares documentation with "years" version.
/+ref SysTime+/ void roll(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) nothrow
if(units == "months")
{
auto hnsecs = adjTime;
auto days = splitUnitsFromHNSecs!"days"(hnsecs) + 1;
if(hnsecs < 0)
{
hnsecs += convert!("hours", "hnsecs")(24);
--days;
}
auto date = Date(cast(int)days);
date.roll!"months"(value, allowOverflow);
days = date.dayOfGregorianCal - 1;
if(days < 0)
{
hnsecs -= convert!("hours", "hnsecs")(24);
++days;
}
immutable newDaysHNSecs = convert!("days", "hnsecs")(days);
adjTime = newDaysHNSecs + hnsecs;
}
//Test roll!"months"() with AllowDayOverlow.yes
unittest
{
version(testStdDateTime)
{
//Test A.D.
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.roll!"months"(3);
_assertPred!"=="(sysTime, SysTime(Date(1999, 10, 6)));
sysTime.roll!"months"(-4);
_assertPred!"=="(sysTime, SysTime(Date(1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.roll!"months"(6);
_assertPred!"=="(sysTime, SysTime(Date(1999, 1, 6)));
sysTime.roll!"months"(-6);
_assertPred!"=="(sysTime, SysTime(Date(1999, 7, 6)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.roll!"months"(27);
_assertPred!"=="(sysTime, SysTime(Date(1999, 10, 6)));
sysTime.roll!"months"(-28);
_assertPred!"=="(sysTime, SysTime(Date(1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(1999, 5, 31));
sysTime.roll!"months"(1);
_assertPred!"=="(sysTime, SysTime(Date(1999, 7, 1)));
}
{
auto sysTime = SysTime(Date(1999, 5, 31));
sysTime.roll!"months"(-1);
_assertPred!"=="(sysTime, SysTime(Date(1999, 5, 1)));
}
{
auto sysTime = SysTime(Date(1999, 2, 28));
sysTime.roll!"months"(12);
_assertPred!"=="(sysTime, SysTime(Date(1999, 2, 28)));
}
{
auto sysTime = SysTime(Date(2000, 2, 29));
sysTime.roll!"months"(12);
_assertPred!"=="(sysTime, SysTime(Date(2000, 2, 29)));
}
{
auto sysTime = SysTime(Date(1999, 7, 31));
sysTime.roll!"months"(1);
_assertPred!"=="(sysTime, SysTime(Date(1999, 8, 31)));
sysTime.roll!"months"(1);
_assertPred!"=="(sysTime, SysTime(Date(1999, 10, 1)));
}
{
auto sysTime = SysTime(Date(1998, 8, 31));
sysTime.roll!"months"(13);
_assertPred!"=="(sysTime, SysTime(Date(1998, 10, 1)));
sysTime.roll!"months"(-13);
_assertPred!"=="(sysTime, SysTime(Date(1998, 9, 1)));
}
{
auto sysTime = SysTime(Date(1997, 12, 31));
sysTime.roll!"months"(13);
_assertPred!"=="(sysTime, SysTime(Date(1997, 1, 31)));
sysTime.roll!"months"(-13);
_assertPred!"=="(sysTime, SysTime(Date(1997, 12, 31)));
}
{
auto sysTime = SysTime(Date(1997, 12, 31));
sysTime.roll!"months"(14);
_assertPred!"=="(sysTime, SysTime(Date(1997, 3, 3)));
sysTime.roll!"months"(-14);
_assertPred!"=="(sysTime, SysTime(Date(1997, 1, 3)));
}
{
auto sysTime = SysTime(Date(1998, 12, 31));
sysTime.roll!"months"(14);
_assertPred!"=="(sysTime, SysTime(Date(1998, 3, 3)));
sysTime.roll!"months"(-14);
_assertPred!"=="(sysTime, SysTime(Date(1998, 1, 3)));
}
{
auto sysTime = SysTime(Date(1999, 12, 31));
sysTime.roll!"months"(14);
_assertPred!"=="(sysTime, SysTime(Date(1999, 3, 3)));
sysTime.roll!"months"(-14);
_assertPred!"=="(sysTime, SysTime(Date(1999, 1, 3)));
}
{
auto sysTime = SysTime(DateTime(1999, 7, 6, 12, 2, 7), FracSec.from!"usecs"(5007));
sysTime.roll!"months"(3);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 10, 6, 12, 2, 7), FracSec.from!"usecs"(5007)));
sysTime.roll!"months"(-4);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 6, 6, 12, 2, 7), FracSec.from!"usecs"(5007)));
}
{
auto sysTime = SysTime(DateTime(1998, 12, 31, 7, 7, 7), FracSec.from!"hnsecs"(422202));
sysTime.roll!"months"(14);
_assertPred!"=="(sysTime, SysTime(DateTime(1998, 3, 3, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
sysTime.roll!"months"(-14);
_assertPred!"=="(sysTime, SysTime(DateTime(1998, 1, 3, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
}
{
auto sysTime = SysTime(DateTime(1999, 12, 31, 7, 7, 7), FracSec.from!"hnsecs"(422202));
sysTime.roll!"months"(14);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 3, 3, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
sysTime.roll!"months"(-14);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 1, 3, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
}
//Test B.C.
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.roll!"months"(3);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 10, 6)));
sysTime.roll!"months"(-4);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.roll!"months"(6);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 1, 6)));
sysTime.roll!"months"(-6);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 7, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.roll!"months"(-27);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 4, 6)));
sysTime.roll!"months"(28);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 8, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 5, 31));
sysTime.roll!"months"(1);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 7, 1)));
}
{
auto sysTime = SysTime(Date(-1999, 5, 31));
sysTime.roll!"months"(-1);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 5, 1)));
}
{
auto sysTime = SysTime(Date(-1999, 2, 28));
sysTime.roll!"months"(-12);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 2, 28)));
}
{
auto sysTime = SysTime(Date(-2000, 2, 29));
sysTime.roll!"months"(-12);
_assertPred!"=="(sysTime, SysTime(Date(-2000, 2, 29)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 31));
sysTime.roll!"months"(1);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 8, 31)));
sysTime.roll!"months"(1);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 10, 1)));
}
{
auto sysTime = SysTime(Date(-1998, 8, 31));
sysTime.roll!"months"(13);
_assertPred!"=="(sysTime, SysTime(Date(-1998, 10, 1)));
sysTime.roll!"months"(-13);
_assertPred!"=="(sysTime, SysTime(Date(-1998, 9, 1)));
}
{
auto sysTime = SysTime(Date(-1997, 12, 31));
sysTime.roll!"months"(13);
_assertPred!"=="(sysTime, SysTime(Date(-1997, 1, 31)));
sysTime.roll!"months"(-13);
_assertPred!"=="(sysTime, SysTime(Date(-1997, 12, 31)));
}
{
auto sysTime = SysTime(Date(-1997, 12, 31));
sysTime.roll!"months"(14);
_assertPred!"=="(sysTime, SysTime(Date(-1997, 3, 3)));
sysTime.roll!"months"(-14);
_assertPred!"=="(sysTime, SysTime(Date(-1997, 1, 3)));
}
{
auto sysTime = SysTime(Date(-2002, 12, 31));
sysTime.roll!"months"(14);
_assertPred!"=="(sysTime, SysTime(Date(-2002, 3, 3)));
sysTime.roll!"months"(-14);
_assertPred!"=="(sysTime, SysTime(Date(-2002, 1, 3)));
}
{
auto sysTime = SysTime(Date(-2001, 12, 31));
sysTime.roll!"months"(14);
_assertPred!"=="(sysTime, SysTime(Date(-2001, 3, 3)));
sysTime.roll!"months"(-14);
_assertPred!"=="(sysTime, SysTime(Date(-2001, 1, 3)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0));
sysTime.roll!"months"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 12, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
sysTime.roll!"months"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.roll!"months"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 12, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.roll!"months"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 1, 0, 0, 0), FracSec.from!"hnsecs"(0));
sysTime.roll!"months"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
sysTime.roll!"months"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.roll!"months"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.roll!"months"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(-1999, 7, 6, 12, 2, 7), FracSec.from!"hnsecs"(5007));
sysTime.roll!"months"(3);
_assertPred!"=="(sysTime, SysTime(DateTime(-1999, 10, 6, 12, 2, 7), FracSec.from!"hnsecs"(5007)));
sysTime.roll!"months"(-4);
_assertPred!"=="(sysTime, SysTime(DateTime(-1999, 6, 6, 12, 2, 7), FracSec.from!"hnsecs"(5007)));
}
{
auto sysTime = SysTime(DateTime(-2002, 12, 31, 7, 7, 7), FracSec.from!"hnsecs"(422202));
sysTime.roll!"months"(14);
_assertPred!"=="(sysTime, SysTime(DateTime(-2002, 3, 3, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
sysTime.roll!"months"(-14);
_assertPred!"=="(sysTime, SysTime(DateTime(-2002, 1, 3, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
}
{
auto sysTime = SysTime(DateTime(-2001, 12, 31, 7, 7, 7), FracSec.from!"hnsecs"(422202));
sysTime.roll!"months"(14);
_assertPred!"=="(sysTime, SysTime(DateTime(-2001, 3, 3, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
sysTime.roll!"months"(-14);
_assertPred!"=="(sysTime, SysTime(DateTime(-2001, 1, 3, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
}
//Test Both
{
auto sysTime = SysTime(Date(1, 1, 1));
sysTime.roll!"months"(-1);
_assertPred!"=="(sysTime, SysTime(Date(1, 12, 1)));
sysTime.roll!"months"(1);
_assertPred!"=="(sysTime, SysTime(Date(1, 1, 1)));
}
{
auto sysTime = SysTime(Date(4, 1, 1));
sysTime.roll!"months"(-48);
_assertPred!"=="(sysTime, SysTime(Date(4, 1, 1)));
sysTime.roll!"months"(48);
_assertPred!"=="(sysTime, SysTime(Date(4, 1, 1)));
}
{
auto sysTime = SysTime(Date(4, 3, 31));
sysTime.roll!"months"(-49);
_assertPred!"=="(sysTime, SysTime(Date(4, 3, 2)));
sysTime.roll!"months"(49);
_assertPred!"=="(sysTime, SysTime(Date(4, 4, 2)));
}
{
auto sysTime = SysTime(Date(4, 3, 31));
sysTime.roll!"months"(-85);
_assertPred!"=="(sysTime, SysTime(Date(4, 3, 2)));
sysTime.roll!"months"(85);
_assertPred!"=="(sysTime, SysTime(Date(4, 4, 2)));
}
{
auto sysTime = SysTime(Date(-1, 1, 1));
sysTime.roll!"months"(-1);
_assertPred!"=="(sysTime, SysTime(Date(-1, 12, 1)));
sysTime.roll!"months"(1);
_assertPred!"=="(sysTime, SysTime(Date(-1, 1, 1)));
}
{
auto sysTime = SysTime(Date(-4, 1, 1));
sysTime.roll!"months"(-48);
_assertPred!"=="(sysTime, SysTime(Date(-4, 1, 1)));
sysTime.roll!"months"(48);
_assertPred!"=="(sysTime, SysTime(Date(-4, 1, 1)));
}
{
auto sysTime = SysTime(Date(-4, 3, 31));
sysTime.roll!"months"(-49);
_assertPred!"=="(sysTime, SysTime(Date(-4, 3, 2)));
sysTime.roll!"months"(49);
_assertPred!"=="(sysTime, SysTime(Date(-4, 4, 2)));
}
{
auto sysTime = SysTime(Date(-4, 3, 31));
sysTime.roll!"months"(-85);
_assertPred!"=="(sysTime, SysTime(Date(-4, 3, 2)));
sysTime.roll!"months"(85);
_assertPred!"=="(sysTime, SysTime(Date(-4, 4, 2)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 7, 9), FracSec.from!"hnsecs"(17));
sysTime.roll!"months"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 12, 1, 0, 7, 9), FracSec.from!"hnsecs"(17)));
sysTime.roll!"months"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 7, 9), FracSec.from!"hnsecs"(17)));
}
{
auto sysTime = SysTime(DateTime(4, 3, 31, 12, 11, 10), FracSec.from!"msecs"(9));
sysTime.roll!"months"(-85);
_assertPred!"=="(sysTime, SysTime(DateTime(4, 3, 2, 12, 11, 10), FracSec.from!"msecs"(9)));
sysTime.roll!"months"(85);
_assertPred!"=="(sysTime, SysTime(DateTime(4, 4, 2, 12, 11, 10), FracSec.from!"msecs"(9)));
}
{
auto sysTime = SysTime(DateTime(-3, 3, 31, 12, 11, 10), FracSec.from!"msecs"(9));
sysTime.roll!"months"(85);
_assertPred!"=="(sysTime, SysTime(DateTime(-3, 5, 1, 12, 11, 10), FracSec.from!"msecs"(9)));
sysTime.roll!"months"(-85);
_assertPred!"=="(sysTime, SysTime(DateTime(-3, 4, 1, 12, 11, 10), FracSec.from!"msecs"(9)));
}
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.roll!"months"(4)));
//static assert(!__traits(compiles, ist.roll!"months"(4)));
//Verify Examples.
auto st1 = SysTime(DateTime(2010, 1, 1, 12, 33, 33));
st1.roll!"months"(1);
assert(st1 == SysTime(DateTime(2010, 2, 1, 12, 33, 33)));
auto st2 = SysTime(DateTime(2010, 1, 1, 12, 33, 33));
st2.roll!"months"(-1);
assert(st2 == SysTime(DateTime(2010, 12, 1, 12, 33, 33)));
auto st3 = SysTime(DateTime(1999, 1, 29, 12, 33, 33));
st3.roll!"months"(1);
assert(st3 == SysTime(DateTime(1999, 3, 1, 12, 33, 33)));
auto st4 = SysTime(DateTime(1999, 1, 29, 12, 33, 33));
st4.roll!"months"(1, AllowDayOverflow.no);
assert(st4 == SysTime(DateTime(1999, 2, 28, 12, 33, 33)));
}
}
//Test roll!"months"() with AllowDayOverlow.no
unittest
{
version(testStdDateTime)
{
//Test A.D.
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.roll!"months"(3, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 10, 6)));
sysTime.roll!"months"(-4, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.roll!"months"(6, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 1, 6)));
sysTime.roll!"months"(-6, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 7, 6)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.roll!"months"(27, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 10, 6)));
sysTime.roll!"months"(-28, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(1999, 5, 31));
sysTime.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 6, 30)));
}
{
auto sysTime = SysTime(Date(1999, 5, 31));
sysTime.roll!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 4, 30)));
}
{
auto sysTime = SysTime(Date(1999, 2, 28));
sysTime.roll!"months"(12, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 2, 28)));
}
{
auto sysTime = SysTime(Date(2000, 2, 29));
sysTime.roll!"months"(12, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(2000, 2, 29)));
}
{
auto sysTime = SysTime(Date(1999, 7, 31));
sysTime.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 8, 31)));
sysTime.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 9, 30)));
}
{
auto sysTime = SysTime(Date(1998, 8, 31));
sysTime.roll!"months"(13, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1998, 9, 30)));
sysTime.roll!"months"(-13, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1998, 8, 30)));
}
{
auto sysTime = SysTime(Date(1997, 12, 31));
sysTime.roll!"months"(13, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1997, 1, 31)));
sysTime.roll!"months"(-13, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1997, 12, 31)));
}
{
auto sysTime = SysTime(Date(1997, 12, 31));
sysTime.roll!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1997, 2, 28)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1997, 12, 28)));
}
{
auto sysTime = SysTime(Date(1998, 12, 31));
sysTime.roll!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1998, 2, 28)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1998, 12, 28)));
}
{
auto sysTime = SysTime(Date(1999, 12, 31));
sysTime.roll!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 2, 28)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1999, 12, 28)));
}
{
auto sysTime = SysTime(DateTime(1999, 7, 6, 12, 2, 7), FracSec.from!"usecs"(5007));
sysTime.roll!"months"(3, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 10, 6, 12, 2, 7), FracSec.from!"usecs"(5007)));
sysTime.roll!"months"(-4, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 6, 6, 12, 2, 7), FracSec.from!"usecs"(5007)));
}
{
auto sysTime = SysTime(DateTime(1998, 12, 31, 7, 7, 7), FracSec.from!"hnsecs"(422202));
sysTime.roll!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1998, 2, 28, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1998, 12, 28, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
}
{
auto sysTime = SysTime(DateTime(1999, 12, 31, 7, 7, 7), FracSec.from!"hnsecs"(422202));
sysTime.roll!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 2, 28, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 12, 28, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
}
//Test B.C.
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.roll!"months"(3, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 10, 6)));
sysTime.roll!"months"(-4, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.roll!"months"(6, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 1, 6)));
sysTime.roll!"months"(-6, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 7, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.roll!"months"(-27, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 4, 6)));
sysTime.roll!"months"(28, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 8, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 5, 31));
sysTime.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 6, 30)));
}
{
auto sysTime = SysTime(Date(-1999, 5, 31));
sysTime.roll!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 4, 30)));
}
{
auto sysTime = SysTime(Date(-1999, 2, 28));
sysTime.roll!"months"(-12, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 2, 28)));
}
{
auto sysTime = SysTime(Date(-2000, 2, 29));
sysTime.roll!"months"(-12, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-2000, 2, 29)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 31));
sysTime.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 8, 31)));
sysTime.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 9, 30)));
}
{
auto sysTime = SysTime(Date(-1998, 8, 31));
sysTime.roll!"months"(13, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1998, 9, 30)));
sysTime.roll!"months"(-13, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1998, 8, 30)));
}
{
auto sysTime = SysTime(Date(-1997, 12, 31));
sysTime.roll!"months"(13, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1997, 1, 31)));
sysTime.roll!"months"(-13, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1997, 12, 31)));
}
{
auto sysTime = SysTime(Date(-1997, 12, 31));
sysTime.roll!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1997, 2, 28)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1997, 12, 28)));
}
{
auto sysTime = SysTime(Date(-2002, 12, 31));
sysTime.roll!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-2002, 2, 28)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-2002, 12, 28)));
}
{
auto sysTime = SysTime(Date(-2001, 12, 31));
sysTime.roll!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-2001, 2, 28)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-2001, 12, 28)));
}
{
auto sysTime = SysTime(DateTime(-1999, 7, 6, 12, 2, 7), FracSec.from!"usecs"(5007));
sysTime.roll!"months"(3, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-1999, 10, 6, 12, 2, 7), FracSec.from!"usecs"(5007)));
sysTime.roll!"months"(-4, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-1999, 6, 6, 12, 2, 7), FracSec.from!"usecs"(5007)));
}
{
auto sysTime = SysTime(DateTime(-2002, 12, 31, 7, 7, 7), FracSec.from!"hnsecs"(422202));
sysTime.roll!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-2002, 2, 28, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-2002, 12, 28, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
}
{
auto sysTime = SysTime(DateTime(-2001, 12, 31, 7, 7, 7), FracSec.from!"hnsecs"(422202));
sysTime.roll!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-2001, 2, 28, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-2001, 12, 28, 7, 7, 7), FracSec.from!"hnsecs"(422202)));
}
//Test Both
{
auto sysTime = SysTime(Date(1, 1, 1));
sysTime.roll!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1, 12, 1)));
sysTime.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(1, 1, 1)));
}
{
auto sysTime = SysTime(Date(4, 1, 1));
sysTime.roll!"months"(-48, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(4, 1, 1)));
sysTime.roll!"months"(48, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(4, 1, 1)));
}
{
auto sysTime = SysTime(Date(4, 3, 31));
sysTime.roll!"months"(-49, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(4, 2, 29)));
sysTime.roll!"months"(49, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(4, 3, 29)));
}
{
auto sysTime = SysTime(Date(4, 3, 31));
sysTime.roll!"months"(-85, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(4, 2, 29)));
sysTime.roll!"months"(85, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(4, 3, 29)));
}
{
auto sysTime = SysTime(Date(-1, 1, 1));
sysTime.roll!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1, 12, 1)));
sysTime.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-1, 1, 1)));
}
{
auto sysTime = SysTime(Date(-4, 1, 1));
sysTime.roll!"months"(-48, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-4, 1, 1)));
sysTime.roll!"months"(48, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-4, 1, 1)));
}
{
auto sysTime = SysTime(Date(-4, 3, 31));
sysTime.roll!"months"(-49, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-4, 2, 29)));
sysTime.roll!"months"(49, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-4, 3, 29)));
}
{
auto sysTime = SysTime(Date(-4, 3, 31));
sysTime.roll!"months"(-85, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-4, 2, 29)));
sysTime.roll!"months"(85, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(Date(-4, 3, 29)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0));
sysTime.roll!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 12, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
sysTime.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.roll!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 12, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 1, 0, 0, 0), FracSec.from!"hnsecs"(0));
sysTime.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
sysTime.roll!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.roll!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 7, 9), FracSec.from!"hnsecs"(17));
sysTime.roll!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 12, 1, 0, 7, 9), FracSec.from!"hnsecs"(17)));
sysTime.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 7, 9), FracSec.from!"hnsecs"(17)));
}
{
auto sysTime = SysTime(DateTime(4, 3, 31, 12, 11, 10), FracSec.from!"msecs"(9));
sysTime.roll!"months"(-85, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(4, 2, 29, 12, 11, 10), FracSec.from!"msecs"(9)));
sysTime.roll!"months"(85, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(4, 3, 29, 12, 11, 10), FracSec.from!"msecs"(9)));
}
{
auto sysTime = SysTime(DateTime(-3, 3, 31, 12, 11, 10), FracSec.from!"msecs"(9));
sysTime.roll!"months"(85, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-3, 4, 30, 12, 11, 10), FracSec.from!"msecs"(9)));
sysTime.roll!"months"(-85, AllowDayOverflow.no);
_assertPred!"=="(sysTime, SysTime(DateTime(-3, 3, 30, 12, 11, 10), FracSec.from!"msecs"(9)));
}
}
}
/++
Adds the given number of units to this $(D SysTime). A negative number
will subtract.
The difference between rolling and adding is that rolling does not
affect larger units. So, for instance, if you roll a $(D SysTime) one
year's worth of days, then you get the exact same $(D SysTime).
Accepted units are $(D "days"), $(D "minutes"), $(D "hours"),
$(D "minutes"), $(D "seconds"), $(D "msecs"), $(D "usecs"), and
$(D "hnsecs").
Note that when rolling msecs, usecs or hnsecs, they all add up to a
second. So, for example, rolling 1000 msecs is exactly the same as
rolling 100,000 usecs.
Params:
units = The units to add.
value = The number of $(D_PARAM units) to add to this $(D SysTime).
Examples:
--------------------
auto st1 = SysTime(DateTime(2010, 1, 1, 11, 23, 12));
st1.roll!"days"(1);
assert(st1 == SysTime(DateTime(2010, 1, 2, 11, 23, 12)));
st1.roll!"days"(365);
assert(st1 == SysTime(DateTime(2010, 1, 26, 11, 23, 12)));
st1.roll!"days"(-32);
assert(st1 == SysTime(DateTime(2010, 1, 25, 11, 23, 12)));
auto st2 = SysTime(DateTime(2010, 7, 4, 12, 0, 0));
st2.roll!"hours"(1);
assert(st2 == SysTime(DateTime(2010, 7, 4, 13, 0, 0)));
auto st3 = SysTime(DateTime(2010, 1, 1, 0, 0, 0));
st3.roll!"seconds"(-1);
assert(st3 == SysTime(DateTime(2010, 1, 1, 0, 0, 59)));
auto st4 = SysTime(DateTime(2010, 1, 1, 0, 0, 0),
FracSec.from!"usecs"(2_400));
st4.roll!"usecs"(-1_200_000);
assert(st4 == SysTime(DateTime(2010, 1, 1, 0, 0, 0),
FracSec.from!"usecs"(802_400)));
--------------------
+/
/+ref SysTime+/ void roll(string units)(long value) nothrow
if(units == "days")
{
auto hnsecs = adjTime;
auto gdays = splitUnitsFromHNSecs!"days"(hnsecs) + 1;
if(hnsecs < 0)
{
hnsecs += convert!("hours", "hnsecs")(24);
--gdays;
}
auto date = Date(cast(int)gdays);
date.roll!"days"(value);
gdays = date.dayOfGregorianCal - 1;
if(gdays < 0)
{
hnsecs -= convert!("hours", "hnsecs")(24);
++gdays;
}
immutable newDaysHNSecs = convert!("days", "hnsecs")(gdays);
adjTime = newDaysHNSecs + hnsecs;
}
//Verify Examples.
unittest
{
version(testStdDateTime)
{
auto st1 = SysTime(DateTime(2010, 1, 1, 11, 23, 12));
st1.roll!"days"(1);
assert(st1 == SysTime(DateTime(2010, 1, 2, 11, 23, 12)));
st1.roll!"days"(365);
assert(st1 == SysTime(DateTime(2010, 1, 26, 11, 23, 12)));
st1.roll!"days"(-32);
assert(st1 == SysTime(DateTime(2010, 1, 25, 11, 23, 12)));
auto st2 = SysTime(DateTime(2010, 7, 4, 12, 0, 0));
st2.roll!"hours"(1);
assert(st2 == SysTime(DateTime(2010, 7, 4, 13, 0, 0)));
auto st3 = SysTime(DateTime(2010, 1, 1, 0, 0, 0));
st3.roll!"seconds"(-1);
assert(st3 == SysTime(DateTime(2010, 1, 1, 0, 0, 59)));
auto st4 = SysTime(DateTime(2010, 1, 1, 0, 0, 0),
FracSec.from!"usecs"(2_400));
st4.roll!"usecs"(-1_200_000);
assert(st4 == SysTime(DateTime(2010, 1, 1, 0, 0, 0),
FracSec.from!"usecs"(802_400)));
}
}
unittest
{
version(testStdDateTime)
{
//Test A.D.
{
auto sysTime = SysTime(Date(1999, 2, 28));
sysTime.roll!"days"(1);
_assertPred!"=="(sysTime, SysTime(Date(1999, 2, 1)));
sysTime.roll!"days"(-1);
_assertPred!"=="(sysTime, SysTime(Date(1999, 2, 28)));
}
{
auto sysTime = SysTime(Date(2000, 2, 28));
sysTime.roll!"days"(1);
_assertPred!"=="(sysTime, SysTime(Date(2000, 2, 29)));
sysTime.roll!"days"(1);
_assertPred!"=="(sysTime, SysTime(Date(2000, 2, 1)));
sysTime.roll!"days"(-1);
_assertPred!"=="(sysTime, SysTime(Date(2000, 2, 29)));
}
{
auto sysTime = SysTime(Date(1999, 6, 30));
sysTime.roll!"days"(1);
_assertPred!"=="(sysTime, SysTime(Date(1999, 6, 1)));
sysTime.roll!"days"(-1);
_assertPred!"=="(sysTime, SysTime(Date(1999, 6, 30)));
}
{
auto sysTime = SysTime(Date(1999, 7, 31));
sysTime.roll!"days"(1);
_assertPred!"=="(sysTime, SysTime(Date(1999, 7, 1)));
sysTime.roll!"days"(-1);
_assertPred!"=="(sysTime, SysTime(Date(1999, 7, 31)));
}
{
auto sysTime = SysTime(Date(1999, 1, 1));
sysTime.roll!"days"(-1);
_assertPred!"=="(sysTime, SysTime(Date(1999, 1, 31)));
sysTime.roll!"days"(1);
_assertPred!"=="(sysTime, SysTime(Date(1999, 1, 1)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.roll!"days"(9);
_assertPred!"=="(sysTime, SysTime(Date(1999, 7, 15)));
sysTime.roll!"days"(-11);
_assertPred!"=="(sysTime, SysTime(Date(1999, 7, 4)));
sysTime.roll!"days"(30);
_assertPred!"=="(sysTime, SysTime(Date(1999, 7, 3)));
sysTime.roll!"days"(-3);
_assertPred!"=="(sysTime, SysTime(Date(1999, 7, 31)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.roll!"days"(365);
_assertPred!"=="(sysTime, SysTime(Date(1999, 7, 30)));
sysTime.roll!"days"(-365);
_assertPred!"=="(sysTime, SysTime(Date(1999, 7, 6)));
sysTime.roll!"days"(366);
_assertPred!"=="(sysTime, SysTime(Date(1999, 7, 31)));
sysTime.roll!"days"(730);
_assertPred!"=="(sysTime, SysTime(Date(1999, 7, 17)));
sysTime.roll!"days"(-1096);
_assertPred!"=="(sysTime, SysTime(Date(1999, 7, 6)));
}
{
auto sysTime = SysTime(Date(1999, 2, 6));
sysTime.roll!"days"(365);
_assertPred!"=="(sysTime, SysTime(Date(1999, 2, 7)));
sysTime.roll!"days"(-365);
_assertPred!"=="(sysTime, SysTime(Date(1999, 2, 6)));
sysTime.roll!"days"(366);
_assertPred!"=="(sysTime, SysTime(Date(1999, 2, 8)));
sysTime.roll!"days"(730);
_assertPred!"=="(sysTime, SysTime(Date(1999, 2, 10)));
sysTime.roll!"days"(-1096);
_assertPred!"=="(sysTime, SysTime(Date(1999, 2, 6)));
}
{
auto sysTime = SysTime(DateTime(1999, 2, 28, 7, 9, 2), FracSec.from!"usecs"(234578));
sysTime.roll!"days"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 2, 1, 7, 9, 2), FracSec.from!"usecs"(234578)));
sysTime.roll!"days"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 2, 28, 7, 9, 2), FracSec.from!"usecs"(234578)));
}
{
auto sysTime = SysTime(DateTime(1999, 7, 6, 7, 9, 2), FracSec.from!"usecs"(234578));
sysTime.roll!"days"(9);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 7, 15, 7, 9, 2), FracSec.from!"usecs"(234578)));
sysTime.roll!"days"(-11);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 7, 4, 7, 9, 2), FracSec.from!"usecs"(234578)));
sysTime.roll!"days"(30);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 7, 3, 7, 9, 2), FracSec.from!"usecs"(234578)));
sysTime.roll!"days"(-3);
_assertPred!"=="(sysTime, SysTime(DateTime(1999, 7, 31, 7, 9, 2), FracSec.from!"usecs"(234578)));
}
//Test B.C.
{
auto sysTime = SysTime(Date(-1999, 2, 28));
sysTime.roll!"days"(1);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 2, 1)));
sysTime.roll!"days"(-1);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 2, 28)));
}
{
auto sysTime = SysTime(Date(-2000, 2, 28));
sysTime.roll!"days"(1);
_assertPred!"=="(sysTime, SysTime(Date(-2000, 2, 29)));
sysTime.roll!"days"(1);
_assertPred!"=="(sysTime, SysTime(Date(-2000, 2, 1)));
sysTime.roll!"days"(-1);
_assertPred!"=="(sysTime, SysTime(Date(-2000, 2, 29)));
}
{
auto sysTime = SysTime(Date(-1999, 6, 30));
sysTime.roll!"days"(1);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 6, 1)));
sysTime.roll!"days"(-1);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 6, 30)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 31));
sysTime.roll!"days"(1);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 7, 1)));
sysTime.roll!"days"(-1);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 7, 31)));
}
{
auto sysTime = SysTime(Date(-1999, 1, 1));
sysTime.roll!"days"(-1);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 1, 31)));
sysTime.roll!"days"(1);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 1, 1)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.roll!"days"(9);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 7, 15)));
sysTime.roll!"days"(-11);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 7, 4)));
sysTime.roll!"days"(30);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 7, 3)));
sysTime.roll!"days"(-3);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 7, 31)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.roll!"days"(365);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 7, 30)));
sysTime.roll!"days"(-365);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 7, 6)));
sysTime.roll!"days"(366);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 7, 31)));
sysTime.roll!"days"(730);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 7, 17)));
sysTime.roll!"days"(-1096);
_assertPred!"=="(sysTime, SysTime(Date(-1999, 7, 6)));
}
{
auto sysTime = SysTime(DateTime(-1999, 2, 28, 7, 9, 2), FracSec.from!"usecs"(234578));
sysTime.roll!"days"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(-1999, 2, 1, 7, 9, 2), FracSec.from!"usecs"(234578)));
sysTime.roll!"days"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(-1999, 2, 28, 7, 9, 2), FracSec.from!"usecs"(234578)));
}
{
auto sysTime = SysTime(DateTime(-1999, 7, 6, 7, 9, 2), FracSec.from!"usecs"(234578));
sysTime.roll!"days"(9);
_assertPred!"=="(sysTime, SysTime(DateTime(-1999, 7, 15, 7, 9, 2), FracSec.from!"usecs"(234578)));
sysTime.roll!"days"(-11);
_assertPred!"=="(sysTime, SysTime(DateTime(-1999, 7, 4, 7, 9, 2), FracSec.from!"usecs"(234578)));
sysTime.roll!"days"(30);
_assertPred!"=="(sysTime, SysTime(DateTime(-1999, 7, 3, 7, 9, 2), FracSec.from!"usecs"(234578)));
sysTime.roll!"days"(-3);
}
//Test Both
{
auto sysTime = SysTime(Date(1, 7, 6));
sysTime.roll!"days"(-365);
_assertPred!"=="(sysTime, SysTime(Date(1, 7, 13)));
sysTime.roll!"days"(365);
_assertPred!"=="(sysTime, SysTime(Date(1, 7, 6)));
sysTime.roll!"days"(-731);
_assertPred!"=="(sysTime, SysTime(Date(1, 7, 19)));
sysTime.roll!"days"(730);
_assertPred!"=="(sysTime, SysTime(Date(1, 7, 5)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0));
sysTime.roll!"days"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 31, 0, 0, 0), FracSec.from!"hnsecs"(0)));
sysTime.roll!"days"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.roll!"days"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.roll!"days"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 0, 0, 0), FracSec.from!"hnsecs"(0));
sysTime.roll!"days"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
sysTime.roll!"days"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 31, 0, 0, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.roll!"days"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.roll!"days"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(1, 7, 6, 13, 13, 9), FracSec.from!"msecs"(22));
sysTime.roll!"days"(-365);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 7, 13, 13, 13, 9), FracSec.from!"msecs"(22)));
sysTime.roll!"days"(365);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 7, 6, 13, 13, 9), FracSec.from!"msecs"(22)));
sysTime.roll!"days"(-731);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 7, 19, 13, 13, 9), FracSec.from!"msecs"(22)));
sysTime.roll!"days"(730);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 7, 5, 13, 13, 9), FracSec.from!"msecs"(22)));
}
{
auto sysTime = SysTime(DateTime(0, 7, 6, 13, 13, 9), FracSec.from!"msecs"(22));
sysTime.roll!"days"(-365);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 7, 13, 13, 13, 9), FracSec.from!"msecs"(22)));
sysTime.roll!"days"(365);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 7, 6, 13, 13, 9), FracSec.from!"msecs"(22)));
sysTime.roll!"days"(-731);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 7, 19, 13, 13, 9), FracSec.from!"msecs"(22)));
sysTime.roll!"days"(730);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 7, 5, 13, 13, 9), FracSec.from!"msecs"(22)));
}
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.roll!"days"(4)));
//static assert(!__traits(compiles, ist.roll!"days"(4)));
//Verify Examples.
auto st = SysTime(DateTime(2010, 1, 1, 11, 23, 12));
st.roll!"days"(1);
assert(st == SysTime(DateTime(2010, 1, 2, 11, 23, 12)));
st.roll!"days"(365);
assert(st == SysTime(DateTime(2010, 1, 26, 11, 23, 12)));
st.roll!"days"(-32);
assert(st == SysTime(DateTime(2010, 1, 25, 11, 23, 12)));
}
}
//Shares documentation with "days" version.
/+ref SysTime+/ void roll(string units)(long value) nothrow
if(units == "hours" ||
units == "minutes" ||
units == "seconds")
{
try
{
auto hnsecs = adjTime;
auto days = splitUnitsFromHNSecs!"days"(hnsecs) + 1;
if(hnsecs < 0)
{
hnsecs += convert!("hours", "hnsecs")(24);
--days;
}
immutable hour = splitUnitsFromHNSecs!"hours"(hnsecs);
immutable minute = splitUnitsFromHNSecs!"minutes"(hnsecs);
immutable second = splitUnitsFromHNSecs!"seconds"(hnsecs);
auto dateTime = DateTime(Date(cast(int)days), TimeOfDay(cast(int)hour, cast(int)minute, cast(int)second));
dateTime.roll!units(value);
--days;
hnsecs += convert!("hours", "hnsecs")(dateTime.hour);
hnsecs += convert!("minutes", "hnsecs")(dateTime.minute);
hnsecs += convert!("seconds", "hnsecs")(dateTime.second);
if(days < 0)
{
hnsecs -= convert!("hours", "hnsecs")(24);
++days;
}
immutable newDaysHNSecs = convert!("days", "hnsecs")(days);
adjTime = newDaysHNSecs + hnsecs;
}
catch(Exception e)
assert(0, "Either DateTime's constructor or TimeOfDay's constructor threw.");
}
//Test roll!"hours"().
unittest
{
version(testStdDateTime)
{
static void TestST(SysTime orig, int hours, in SysTime expected, size_t line = __LINE__)
{
orig.roll!"hours"(hours);
_assertPred!"=="(orig, expected, "", __FILE__, line);
}
//Test A.D.
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 0, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 1, SysTime(DateTime(1999, 7, 6, 13, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 2, SysTime(DateTime(1999, 7, 6, 14, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 3, SysTime(DateTime(1999, 7, 6, 15, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 4, SysTime(DateTime(1999, 7, 6, 16, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 5, SysTime(DateTime(1999, 7, 6, 17, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 6, SysTime(DateTime(1999, 7, 6, 18, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 7, SysTime(DateTime(1999, 7, 6, 19, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 8, SysTime(DateTime(1999, 7, 6, 20, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 9, SysTime(DateTime(1999, 7, 6, 21, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 10, SysTime(DateTime(1999, 7, 6, 22, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 11, SysTime(DateTime(1999, 7, 6, 23, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 12, SysTime(DateTime(1999, 7, 6, 0, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 13, SysTime(DateTime(1999, 7, 6, 1, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 14, SysTime(DateTime(1999, 7, 6, 2, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 15, SysTime(DateTime(1999, 7, 6, 3, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 16, SysTime(DateTime(1999, 7, 6, 4, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 17, SysTime(DateTime(1999, 7, 6, 5, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 18, SysTime(DateTime(1999, 7, 6, 6, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 19, SysTime(DateTime(1999, 7, 6, 7, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 20, SysTime(DateTime(1999, 7, 6, 8, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 21, SysTime(DateTime(1999, 7, 6, 9, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 22, SysTime(DateTime(1999, 7, 6, 10, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 23, SysTime(DateTime(1999, 7, 6, 11, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 24, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 25, SysTime(DateTime(1999, 7, 6, 13, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 50, SysTime(DateTime(1999, 7, 6, 14, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 10_000, SysTime(DateTime(1999, 7, 6, 4, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -1, SysTime(DateTime(1999, 7, 6, 11, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -2, SysTime(DateTime(1999, 7, 6, 10, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -3, SysTime(DateTime(1999, 7, 6, 9, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -4, SysTime(DateTime(1999, 7, 6, 8, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -5, SysTime(DateTime(1999, 7, 6, 7, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -6, SysTime(DateTime(1999, 7, 6, 6, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -7, SysTime(DateTime(1999, 7, 6, 5, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -8, SysTime(DateTime(1999, 7, 6, 4, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -9, SysTime(DateTime(1999, 7, 6, 3, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -10, SysTime(DateTime(1999, 7, 6, 2, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -11, SysTime(DateTime(1999, 7, 6, 1, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -12, SysTime(DateTime(1999, 7, 6, 0, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -13, SysTime(DateTime(1999, 7, 6, 23, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -14, SysTime(DateTime(1999, 7, 6, 22, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -15, SysTime(DateTime(1999, 7, 6, 21, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -16, SysTime(DateTime(1999, 7, 6, 20, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -17, SysTime(DateTime(1999, 7, 6, 19, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -18, SysTime(DateTime(1999, 7, 6, 18, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -19, SysTime(DateTime(1999, 7, 6, 17, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -20, SysTime(DateTime(1999, 7, 6, 16, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -21, SysTime(DateTime(1999, 7, 6, 15, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -22, SysTime(DateTime(1999, 7, 6, 14, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -23, SysTime(DateTime(1999, 7, 6, 13, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -24, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -25, SysTime(DateTime(1999, 7, 6, 11, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -50, SysTime(DateTime(1999, 7, 6, 10, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -10_000, SysTime(DateTime(1999, 7, 6, 20, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 0, 30, 33), FracSec.from!"msecs"(45)), 1, SysTime(DateTime(1999, 7, 6, 1, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 0, 30, 33), FracSec.from!"msecs"(45)), 0, SysTime(DateTime(1999, 7, 6, 0, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 0, 30, 33), FracSec.from!"msecs"(45)), -1, SysTime(DateTime(1999, 7, 6, 23, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 23, 30, 33), FracSec.from!"msecs"(45)), 1, SysTime(DateTime(1999, 7, 6, 0, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 23, 30, 33), FracSec.from!"msecs"(45)), 0, SysTime(DateTime(1999, 7, 6, 23, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 6, 23, 30, 33), FracSec.from!"msecs"(45)), -1, SysTime(DateTime(1999, 7, 6, 22, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 7, 31, 23, 30, 33), FracSec.from!"msecs"(45)), 1, SysTime(DateTime(1999, 7, 31, 0, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 8, 1, 0, 30, 33), FracSec.from!"msecs"(45)), -1, SysTime(DateTime(1999, 8, 1, 23, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 12, 31, 23, 30, 33), FracSec.from!"msecs"(45)), 1, SysTime(DateTime(1999, 12, 31, 0, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(2000, 1, 1, 0, 30, 33), FracSec.from!"msecs"(45)), -1, SysTime(DateTime(2000, 1, 1, 23, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 2, 28, 23, 30, 33), FracSec.from!"msecs"(45)), 25, SysTime(DateTime(1999, 2, 28, 0, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1999, 3, 2, 0, 30, 33), FracSec.from!"msecs"(45)), -25, SysTime(DateTime(1999, 3, 2, 23, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(2000, 2, 28, 23, 30, 33), FracSec.from!"msecs"(45)), 25, SysTime(DateTime(2000, 2, 28, 0, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(2000, 3, 1, 0, 30, 33), FracSec.from!"msecs"(45)), -25, SysTime(DateTime(2000, 3, 1, 23, 30, 33), FracSec.from!"msecs"(45)));
//Test B.C.
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 0, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 1, SysTime(DateTime(-1999, 7, 6, 13, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 2, SysTime(DateTime(-1999, 7, 6, 14, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 3, SysTime(DateTime(-1999, 7, 6, 15, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 4, SysTime(DateTime(-1999, 7, 6, 16, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 5, SysTime(DateTime(-1999, 7, 6, 17, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 6, SysTime(DateTime(-1999, 7, 6, 18, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 7, SysTime(DateTime(-1999, 7, 6, 19, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 8, SysTime(DateTime(-1999, 7, 6, 20, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 9, SysTime(DateTime(-1999, 7, 6, 21, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 10, SysTime(DateTime(-1999, 7, 6, 22, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 11, SysTime(DateTime(-1999, 7, 6, 23, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 12, SysTime(DateTime(-1999, 7, 6, 0, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 13, SysTime(DateTime(-1999, 7, 6, 1, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 14, SysTime(DateTime(-1999, 7, 6, 2, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 15, SysTime(DateTime(-1999, 7, 6, 3, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 16, SysTime(DateTime(-1999, 7, 6, 4, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 17, SysTime(DateTime(-1999, 7, 6, 5, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 18, SysTime(DateTime(-1999, 7, 6, 6, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 19, SysTime(DateTime(-1999, 7, 6, 7, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 20, SysTime(DateTime(-1999, 7, 6, 8, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 21, SysTime(DateTime(-1999, 7, 6, 9, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 22, SysTime(DateTime(-1999, 7, 6, 10, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 23, SysTime(DateTime(-1999, 7, 6, 11, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 24, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 25, SysTime(DateTime(-1999, 7, 6, 13, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 50, SysTime(DateTime(-1999, 7, 6, 14, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), 10_000, SysTime(DateTime(-1999, 7, 6, 4, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -1, SysTime(DateTime(-1999, 7, 6, 11, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -2, SysTime(DateTime(-1999, 7, 6, 10, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -3, SysTime(DateTime(-1999, 7, 6, 9, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -4, SysTime(DateTime(-1999, 7, 6, 8, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -5, SysTime(DateTime(-1999, 7, 6, 7, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -6, SysTime(DateTime(-1999, 7, 6, 6, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -7, SysTime(DateTime(-1999, 7, 6, 5, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -8, SysTime(DateTime(-1999, 7, 6, 4, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -9, SysTime(DateTime(-1999, 7, 6, 3, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -10, SysTime(DateTime(-1999, 7, 6, 2, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -11, SysTime(DateTime(-1999, 7, 6, 1, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -12, SysTime(DateTime(-1999, 7, 6, 0, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -13, SysTime(DateTime(-1999, 7, 6, 23, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -14, SysTime(DateTime(-1999, 7, 6, 22, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -15, SysTime(DateTime(-1999, 7, 6, 21, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -16, SysTime(DateTime(-1999, 7, 6, 20, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -17, SysTime(DateTime(-1999, 7, 6, 19, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -18, SysTime(DateTime(-1999, 7, 6, 18, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -19, SysTime(DateTime(-1999, 7, 6, 17, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -20, SysTime(DateTime(-1999, 7, 6, 16, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -21, SysTime(DateTime(-1999, 7, 6, 15, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -22, SysTime(DateTime(-1999, 7, 6, 14, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -23, SysTime(DateTime(-1999, 7, 6, 13, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -24, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -25, SysTime(DateTime(-1999, 7, 6, 11, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -50, SysTime(DateTime(-1999, 7, 6, 10, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(45)), -10_000, SysTime(DateTime(-1999, 7, 6, 20, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 0, 30, 33), FracSec.from!"msecs"(45)), 1, SysTime(DateTime(-1999, 7, 6, 1, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 0, 30, 33), FracSec.from!"msecs"(45)), 0, SysTime(DateTime(-1999, 7, 6, 0, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 0, 30, 33), FracSec.from!"msecs"(45)), -1, SysTime(DateTime(-1999, 7, 6, 23, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 23, 30, 33), FracSec.from!"msecs"(45)), 1, SysTime(DateTime(-1999, 7, 6, 0, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 23, 30, 33), FracSec.from!"msecs"(45)), 0, SysTime(DateTime(-1999, 7, 6, 23, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 6, 23, 30, 33), FracSec.from!"msecs"(45)), -1, SysTime(DateTime(-1999, 7, 6, 22, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 7, 31, 23, 30, 33), FracSec.from!"msecs"(45)), 1, SysTime(DateTime(-1999, 7, 31, 0, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-1999, 8, 1, 0, 30, 33), FracSec.from!"msecs"(45)), -1, SysTime(DateTime(-1999, 8, 1, 23, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-2001, 12, 31, 23, 30, 33), FracSec.from!"msecs"(45)), 1, SysTime(DateTime(-2001, 12, 31, 0, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-2000, 1, 1, 0, 30, 33), FracSec.from!"msecs"(45)), -1, SysTime(DateTime(-2000, 1, 1, 23, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-2001, 2, 28, 23, 30, 33), FracSec.from!"msecs"(45)), 25, SysTime(DateTime(-2001, 2, 28, 0, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-2001, 3, 2, 0, 30, 33), FracSec.from!"msecs"(45)), -25, SysTime(DateTime(-2001, 3, 2, 23, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-2000, 2, 28, 23, 30, 33), FracSec.from!"msecs"(45)), 25, SysTime(DateTime(-2000, 2, 28, 0, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(-2000, 3, 1, 0, 30, 33), FracSec.from!"msecs"(45)), -25, SysTime(DateTime(-2000, 3, 1, 23, 30, 33), FracSec.from!"msecs"(45)));
//Test Both
TestST(SysTime(DateTime(-1, 1, 1, 11, 30, 33), FracSec.from!"msecs"(45)), 17_546, SysTime(DateTime(-1, 1, 1, 13, 30, 33), FracSec.from!"msecs"(45)));
TestST(SysTime(DateTime(1, 1, 1, 13, 30, 33), FracSec.from!"msecs"(45)), -17_546, SysTime(DateTime(1, 1, 1, 11, 30, 33), FracSec.from!"msecs"(45)));
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0));
sysTime.roll!"hours"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 23, 0, 0), FracSec.from!"hnsecs"(0)));
sysTime.roll!"hours"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 59, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.roll!"hours"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.roll!"hours"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 23, 0, 0), FracSec.from!"hnsecs"(0));
sysTime.roll!"hours"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 31, 0, 0, 0), FracSec.from!"hnsecs"(0)));
sysTime.roll!"hours"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 31, 23, 0, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.roll!"hours"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 31, 0, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.roll!"hours"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.roll!"hours"(4)));
//static assert(!__traits(compiles, ist.roll!"hours"(4)));
//Verify Examples.
auto st1 = SysTime(DateTime(2010, 7, 4, 12, 0, 0));
st1.roll!"hours"(1);
assert(st1 == SysTime(DateTime(2010, 7, 4, 13, 0, 0)));
auto st2 = SysTime(DateTime(2010, 2, 12, 12, 0, 0));
st2.roll!"hours"(-1);
assert(st2 == SysTime(DateTime(2010, 2, 12, 11, 0, 0)));
auto st3 = SysTime(DateTime(2009, 12, 31, 0, 0, 0));
st3.roll!"minutes"(1);
assert(st3 == SysTime(DateTime(2009, 12, 31, 0, 1, 0)));
auto st4 = SysTime(DateTime(2010, 1, 1, 0, 0, 0));
st4.roll!"minutes"(-1);
assert(st4 == SysTime(DateTime(2010, 1, 1, 0, 59, 0)));
auto st5 = SysTime(DateTime(2009, 12, 31, 0, 0, 0));
st5.roll!"seconds"(1);
assert(st5 == SysTime(DateTime(2009, 12, 31, 0, 0, 1)));
auto st6 = SysTime(DateTime(2010, 1, 1, 0, 0, 0));
st6.roll!"seconds"(-1);
assert(st6 == SysTime(DateTime(2010, 1, 1, 0, 0, 59)));
}
}
//Test roll!"minutes"().
unittest
{
version(testStdDateTime)
{
static void TestST(SysTime orig, int minutes, in SysTime expected, size_t line = __LINE__)
{
orig.roll!"minutes"(minutes);
_assertPred!"=="(orig, expected, "", __FILE__, line);
}
//Test A.D.
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 0, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 1, SysTime(DateTime(1999, 7, 6, 12, 31, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 2, SysTime(DateTime(1999, 7, 6, 12, 32, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 3, SysTime(DateTime(1999, 7, 6, 12, 33, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 4, SysTime(DateTime(1999, 7, 6, 12, 34, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 5, SysTime(DateTime(1999, 7, 6, 12, 35, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 10, SysTime(DateTime(1999, 7, 6, 12, 40, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 15, SysTime(DateTime(1999, 7, 6, 12, 45, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 29, SysTime(DateTime(1999, 7, 6, 12, 59, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 30, SysTime(DateTime(1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 45, SysTime(DateTime(1999, 7, 6, 12, 15, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 60, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 75, SysTime(DateTime(1999, 7, 6, 12, 45, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 90, SysTime(DateTime(1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 100, SysTime(DateTime(1999, 7, 6, 12, 10, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 689, SysTime(DateTime(1999, 7, 6, 12, 59, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 690, SysTime(DateTime(1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 691, SysTime(DateTime(1999, 7, 6, 12, 1, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 960, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 1439, SysTime(DateTime(1999, 7, 6, 12, 29, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 1440, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 1441, SysTime(DateTime(1999, 7, 6, 12, 31, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 2880, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -1, SysTime(DateTime(1999, 7, 6, 12, 29, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -2, SysTime(DateTime(1999, 7, 6, 12, 28, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -3, SysTime(DateTime(1999, 7, 6, 12, 27, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -4, SysTime(DateTime(1999, 7, 6, 12, 26, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -5, SysTime(DateTime(1999, 7, 6, 12, 25, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -10, SysTime(DateTime(1999, 7, 6, 12, 20, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -15, SysTime(DateTime(1999, 7, 6, 12, 15, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -29, SysTime(DateTime(1999, 7, 6, 12, 1, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -30, SysTime(DateTime(1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -45, SysTime(DateTime(1999, 7, 6, 12, 45, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -60, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -75, SysTime(DateTime(1999, 7, 6, 12, 15, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -90, SysTime(DateTime(1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -100, SysTime(DateTime(1999, 7, 6, 12, 50, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -749, SysTime(DateTime(1999, 7, 6, 12, 1, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -750, SysTime(DateTime(1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -751, SysTime(DateTime(1999, 7, 6, 12, 59, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -960, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -1439, SysTime(DateTime(1999, 7, 6, 12, 31, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -1440, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -1441, SysTime(DateTime(1999, 7, 6, 12, 29, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -2880, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)), 1, SysTime(DateTime(1999, 7, 6, 12, 1, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)), 0, SysTime(DateTime(1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)), -1, SysTime(DateTime(1999, 7, 6, 12, 59, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 11, 59, 33), FracSec.from!"usecs"(7203)), 1, SysTime(DateTime(1999, 7, 6, 11, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 11, 59, 33), FracSec.from!"usecs"(7203)), 0, SysTime(DateTime(1999, 7, 6, 11, 59, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 11, 59, 33), FracSec.from!"usecs"(7203)), -1, SysTime(DateTime(1999, 7, 6, 11, 58, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 0, 0, 33), FracSec.from!"usecs"(7203)), 1, SysTime(DateTime(1999, 7, 6, 0, 1, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 0, 0, 33), FracSec.from!"usecs"(7203)), 0, SysTime(DateTime(1999, 7, 6, 0, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 6, 0, 0, 33), FracSec.from!"usecs"(7203)), -1, SysTime(DateTime(1999, 7, 6, 0, 59, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 5, 23, 59, 33), FracSec.from!"usecs"(7203)), 1, SysTime(DateTime(1999, 7, 5, 23, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 5, 23, 59, 33), FracSec.from!"usecs"(7203)), 0, SysTime(DateTime(1999, 7, 5, 23, 59, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1999, 7, 5, 23, 59, 33), FracSec.from!"usecs"(7203)), -1, SysTime(DateTime(1999, 7, 5, 23, 58, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1998, 12, 31, 23, 59, 33), FracSec.from!"usecs"(7203)), 1, SysTime(DateTime(1998, 12, 31, 23, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1998, 12, 31, 23, 59, 33), FracSec.from!"usecs"(7203)), 0, SysTime(DateTime(1998, 12, 31, 23, 59, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1998, 12, 31, 23, 59, 33), FracSec.from!"usecs"(7203)), -1, SysTime(DateTime(1998, 12, 31, 23, 58, 33), FracSec.from!"usecs"(7203)));
//Test B.C.
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 0, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 1, SysTime(DateTime(-1999, 7, 6, 12, 31, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 2, SysTime(DateTime(-1999, 7, 6, 12, 32, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 3, SysTime(DateTime(-1999, 7, 6, 12, 33, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 4, SysTime(DateTime(-1999, 7, 6, 12, 34, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 5, SysTime(DateTime(-1999, 7, 6, 12, 35, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 10, SysTime(DateTime(-1999, 7, 6, 12, 40, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 15, SysTime(DateTime(-1999, 7, 6, 12, 45, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 29, SysTime(DateTime(-1999, 7, 6, 12, 59, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 30, SysTime(DateTime(-1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 45, SysTime(DateTime(-1999, 7, 6, 12, 15, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 60, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 75, SysTime(DateTime(-1999, 7, 6, 12, 45, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 90, SysTime(DateTime(-1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 100, SysTime(DateTime(-1999, 7, 6, 12, 10, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 689, SysTime(DateTime(-1999, 7, 6, 12, 59, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 690, SysTime(DateTime(-1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 691, SysTime(DateTime(-1999, 7, 6, 12, 1, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 960, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 1439, SysTime(DateTime(-1999, 7, 6, 12, 29, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 1440, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 1441, SysTime(DateTime(-1999, 7, 6, 12, 31, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), 2880, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -1, SysTime(DateTime(-1999, 7, 6, 12, 29, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -2, SysTime(DateTime(-1999, 7, 6, 12, 28, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -3, SysTime(DateTime(-1999, 7, 6, 12, 27, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -4, SysTime(DateTime(-1999, 7, 6, 12, 26, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -5, SysTime(DateTime(-1999, 7, 6, 12, 25, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -10, SysTime(DateTime(-1999, 7, 6, 12, 20, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -15, SysTime(DateTime(-1999, 7, 6, 12, 15, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -29, SysTime(DateTime(-1999, 7, 6, 12, 1, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -30, SysTime(DateTime(-1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -45, SysTime(DateTime(-1999, 7, 6, 12, 45, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -60, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -75, SysTime(DateTime(-1999, 7, 6, 12, 15, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -90, SysTime(DateTime(-1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -100, SysTime(DateTime(-1999, 7, 6, 12, 50, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -749, SysTime(DateTime(-1999, 7, 6, 12, 1, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -750, SysTime(DateTime(-1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -751, SysTime(DateTime(-1999, 7, 6, 12, 59, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -960, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -1439, SysTime(DateTime(-1999, 7, 6, 12, 31, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -1440, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -1441, SysTime(DateTime(-1999, 7, 6, 12, 29, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)), -2880, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)), 1, SysTime(DateTime(-1999, 7, 6, 12, 1, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)), 0, SysTime(DateTime(-1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 0, 33), FracSec.from!"usecs"(7203)), -1, SysTime(DateTime(-1999, 7, 6, 12, 59, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 11, 59, 33), FracSec.from!"usecs"(7203)), 1, SysTime(DateTime(-1999, 7, 6, 11, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 11, 59, 33), FracSec.from!"usecs"(7203)), 0, SysTime(DateTime(-1999, 7, 6, 11, 59, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 11, 59, 33), FracSec.from!"usecs"(7203)), -1, SysTime(DateTime(-1999, 7, 6, 11, 58, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 0, 0, 33), FracSec.from!"usecs"(7203)), 1, SysTime(DateTime(-1999, 7, 6, 0, 1, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 0, 0, 33), FracSec.from!"usecs"(7203)), 0, SysTime(DateTime(-1999, 7, 6, 0, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 6, 0, 0, 33), FracSec.from!"usecs"(7203)), -1, SysTime(DateTime(-1999, 7, 6, 0, 59, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 5, 23, 59, 33), FracSec.from!"usecs"(7203)), 1, SysTime(DateTime(-1999, 7, 5, 23, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 5, 23, 59, 33), FracSec.from!"usecs"(7203)), 0, SysTime(DateTime(-1999, 7, 5, 23, 59, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1999, 7, 5, 23, 59, 33), FracSec.from!"usecs"(7203)), -1, SysTime(DateTime(-1999, 7, 5, 23, 58, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-2000, 12, 31, 23, 59, 33), FracSec.from!"usecs"(7203)), 1, SysTime(DateTime(-2000, 12, 31, 23, 0, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-2000, 12, 31, 23, 59, 33), FracSec.from!"usecs"(7203)), 0, SysTime(DateTime(-2000, 12, 31, 23, 59, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-2000, 12, 31, 23, 59, 33), FracSec.from!"usecs"(7203)), -1, SysTime(DateTime(-2000, 12, 31, 23, 58, 33), FracSec.from!"usecs"(7203)));
//Test Both
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0)), -1, SysTime(DateTime(1, 1, 1, 0, 59, 0)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 0)), 1, SysTime(DateTime(0, 12, 31, 23, 0, 0)));
TestST(SysTime(DateTime(0, 1, 1, 0, 0, 0)), -1, SysTime(DateTime(0, 1, 1, 0, 59, 0)));
TestST(SysTime(DateTime(-1, 12, 31, 23, 59, 0)), 1, SysTime(DateTime(-1, 12, 31, 23, 0, 0)));
TestST(SysTime(DateTime(-1, 1, 1, 11, 30, 33), FracSec.from!"usecs"(7203)), 1_052_760, SysTime(DateTime(-1, 1, 1, 11, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1, 1, 1, 13, 30, 33), FracSec.from!"usecs"(7203)), -1_052_760, SysTime(DateTime(1, 1, 1, 13, 30, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(-1, 1, 1, 11, 30, 33), FracSec.from!"usecs"(7203)), 1_052_782, SysTime(DateTime(-1, 1, 1, 11, 52, 33), FracSec.from!"usecs"(7203)));
TestST(SysTime(DateTime(1, 1, 1, 13, 52, 33), FracSec.from!"usecs"(7203)), -1_052_782, SysTime(DateTime(1, 1, 1, 13, 30, 33), FracSec.from!"usecs"(7203)));
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0));
sysTime.roll!"minutes"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 59, 0), FracSec.from!"hnsecs"(0)));
sysTime.roll!"minutes"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.roll!"minutes"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.roll!"minutes"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 0, 59), FracSec.from!"hnsecs"(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 23, 59, 0), FracSec.from!"hnsecs"(0));
sysTime.roll!"minutes"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 31, 23, 0, 0), FracSec.from!"hnsecs"(0)));
sysTime.roll!"minutes"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 31, 23, 59, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.roll!"minutes"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 31, 23, 0, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.roll!"minutes"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.roll!"minutes"(4)));
//static assert(!__traits(compiles, ist.roll!"minutes"(4)));
}
}
//Test roll!"seconds"().
unittest
{
version(testStdDateTime)
{
static void TestST(SysTime orig, int seconds, in SysTime expected, size_t line = __LINE__)
{
orig.roll!"seconds"(seconds);
_assertPred!"=="(orig, expected, "", __FILE__, line);
}
//Test A.D.
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 0, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 1, SysTime(DateTime(1999, 7, 6, 12, 30, 34), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 2, SysTime(DateTime(1999, 7, 6, 12, 30, 35), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 3, SysTime(DateTime(1999, 7, 6, 12, 30, 36), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 4, SysTime(DateTime(1999, 7, 6, 12, 30, 37), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 5, SysTime(DateTime(1999, 7, 6, 12, 30, 38), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 10, SysTime(DateTime(1999, 7, 6, 12, 30, 43), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 15, SysTime(DateTime(1999, 7, 6, 12, 30, 48), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 26, SysTime(DateTime(1999, 7, 6, 12, 30, 59), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 27, SysTime(DateTime(1999, 7, 6, 12, 30, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 30, SysTime(DateTime(1999, 7, 6, 12, 30, 3), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 59, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 60, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 61, SysTime(DateTime(1999, 7, 6, 12, 30, 34), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 1766, SysTime(DateTime(1999, 7, 6, 12, 30, 59), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 1767, SysTime(DateTime(1999, 7, 6, 12, 30, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 1768, SysTime(DateTime(1999, 7, 6, 12, 30, 1), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 2007, SysTime(DateTime(1999, 7, 6, 12, 30, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 3599, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 3600, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 3601, SysTime(DateTime(1999, 7, 6, 12, 30, 34), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 7200, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -1, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -2, SysTime(DateTime(1999, 7, 6, 12, 30, 31), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -3, SysTime(DateTime(1999, 7, 6, 12, 30, 30), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -4, SysTime(DateTime(1999, 7, 6, 12, 30, 29), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -5, SysTime(DateTime(1999, 7, 6, 12, 30, 28), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -10, SysTime(DateTime(1999, 7, 6, 12, 30, 23), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -15, SysTime(DateTime(1999, 7, 6, 12, 30, 18), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -33, SysTime(DateTime(1999, 7, 6, 12, 30, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -34, SysTime(DateTime(1999, 7, 6, 12, 30, 59), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -35, SysTime(DateTime(1999, 7, 6, 12, 30, 58), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -59, SysTime(DateTime(1999, 7, 6, 12, 30, 34), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -60, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -61, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 0), FracSec.from!"msecs"(274)), 1, SysTime(DateTime(1999, 7, 6, 12, 30, 1), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 0), FracSec.from!"msecs"(274)), 0, SysTime(DateTime(1999, 7, 6, 12, 30, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 0), FracSec.from!"msecs"(274)), -1, SysTime(DateTime(1999, 7, 6, 12, 30, 59), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 0, 0), FracSec.from!"msecs"(274)), 1, SysTime(DateTime(1999, 7, 6, 12, 0, 1), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 0, 0), FracSec.from!"msecs"(274)), 0, SysTime(DateTime(1999, 7, 6, 12, 0, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 0, 0), FracSec.from!"msecs"(274)), -1, SysTime(DateTime(1999, 7, 6, 12, 0, 59), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 0, 0, 0), FracSec.from!"msecs"(274)), 1, SysTime(DateTime(1999, 7, 6, 0, 0, 1), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 0, 0, 0), FracSec.from!"msecs"(274)), 0, SysTime(DateTime(1999, 7, 6, 0, 0, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 0, 0, 0), FracSec.from!"msecs"(274)), -1, SysTime(DateTime(1999, 7, 6, 0, 0, 59), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 5, 23, 59, 59), FracSec.from!"msecs"(274)), 1, SysTime(DateTime(1999, 7, 5, 23, 59, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 5, 23, 59, 59), FracSec.from!"msecs"(274)), 0, SysTime(DateTime(1999, 7, 5, 23, 59, 59), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 5, 23, 59, 59), FracSec.from!"msecs"(274)), -1, SysTime(DateTime(1999, 7, 5, 23, 59, 58), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1998, 12, 31, 23, 59, 59), FracSec.from!"msecs"(274)), 1, SysTime(DateTime(1998, 12, 31, 23, 59, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1998, 12, 31, 23, 59, 59), FracSec.from!"msecs"(274)), 0, SysTime(DateTime(1998, 12, 31, 23, 59, 59), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1998, 12, 31, 23, 59, 59), FracSec.from!"msecs"(274)), -1, SysTime(DateTime(1998, 12, 31, 23, 59, 58), FracSec.from!"msecs"(274)));
//Test B.C.
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 0, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 1, SysTime(DateTime(-1999, 7, 6, 12, 30, 34), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 2, SysTime(DateTime(-1999, 7, 6, 12, 30, 35), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 3, SysTime(DateTime(-1999, 7, 6, 12, 30, 36), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 4, SysTime(DateTime(-1999, 7, 6, 12, 30, 37), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 5, SysTime(DateTime(-1999, 7, 6, 12, 30, 38), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 10, SysTime(DateTime(-1999, 7, 6, 12, 30, 43), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 15, SysTime(DateTime(-1999, 7, 6, 12, 30, 48), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 26, SysTime(DateTime(-1999, 7, 6, 12, 30, 59), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 27, SysTime(DateTime(-1999, 7, 6, 12, 30, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 30, SysTime(DateTime(-1999, 7, 6, 12, 30, 3), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 59, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 60, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 61, SysTime(DateTime(-1999, 7, 6, 12, 30, 34), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 1766, SysTime(DateTime(-1999, 7, 6, 12, 30, 59), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 1767, SysTime(DateTime(-1999, 7, 6, 12, 30, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 1768, SysTime(DateTime(-1999, 7, 6, 12, 30, 1), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 2007, SysTime(DateTime(-1999, 7, 6, 12, 30, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 3599, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 3600, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 3601, SysTime(DateTime(-1999, 7, 6, 12, 30, 34), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 7200, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -1, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -2, SysTime(DateTime(-1999, 7, 6, 12, 30, 31), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -3, SysTime(DateTime(-1999, 7, 6, 12, 30, 30), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -4, SysTime(DateTime(-1999, 7, 6, 12, 30, 29), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -5, SysTime(DateTime(-1999, 7, 6, 12, 30, 28), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -10, SysTime(DateTime(-1999, 7, 6, 12, 30, 23), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -15, SysTime(DateTime(-1999, 7, 6, 12, 30, 18), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -33, SysTime(DateTime(-1999, 7, 6, 12, 30, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -34, SysTime(DateTime(-1999, 7, 6, 12, 30, 59), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -35, SysTime(DateTime(-1999, 7, 6, 12, 30, 58), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -59, SysTime(DateTime(-1999, 7, 6, 12, 30, 34), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -60, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -61, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 0), FracSec.from!"msecs"(274)), 1, SysTime(DateTime(-1999, 7, 6, 12, 30, 1), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 0), FracSec.from!"msecs"(274)), 0, SysTime(DateTime(-1999, 7, 6, 12, 30, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 0), FracSec.from!"msecs"(274)), -1, SysTime(DateTime(-1999, 7, 6, 12, 30, 59), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 0, 0), FracSec.from!"msecs"(274)), 1, SysTime(DateTime(-1999, 7, 6, 12, 0, 1), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 0, 0), FracSec.from!"msecs"(274)), 0, SysTime(DateTime(-1999, 7, 6, 12, 0, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 0, 0), FracSec.from!"msecs"(274)), -1, SysTime(DateTime(-1999, 7, 6, 12, 0, 59), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 0, 0, 0), FracSec.from!"msecs"(274)), 1, SysTime(DateTime(-1999, 7, 6, 0, 0, 1), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 0, 0, 0), FracSec.from!"msecs"(274)), 0, SysTime(DateTime(-1999, 7, 6, 0, 0, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 0, 0, 0), FracSec.from!"msecs"(274)), -1, SysTime(DateTime(-1999, 7, 6, 0, 0, 59), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 5, 23, 59, 59), FracSec.from!"msecs"(274)), 1, SysTime(DateTime(-1999, 7, 5, 23, 59, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 5, 23, 59, 59), FracSec.from!"msecs"(274)), 0, SysTime(DateTime(-1999, 7, 5, 23, 59, 59), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 5, 23, 59, 59), FracSec.from!"msecs"(274)), -1, SysTime(DateTime(-1999, 7, 5, 23, 59, 58), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-2000, 12, 31, 23, 59, 59), FracSec.from!"msecs"(274)), 1, SysTime(DateTime(-2000, 12, 31, 23, 59, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-2000, 12, 31, 23, 59, 59), FracSec.from!"msecs"(274)), 0, SysTime(DateTime(-2000, 12, 31, 23, 59, 59), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-2000, 12, 31, 23, 59, 59), FracSec.from!"msecs"(274)), -1, SysTime(DateTime(-2000, 12, 31, 23, 59, 58), FracSec.from!"msecs"(274)));
//Test Both
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"msecs"(274)), -1, SysTime(DateTime(1, 1, 1, 0, 0, 59), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"msecs"(274)), 1, SysTime(DateTime(0, 12, 31, 23, 59, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(0, 1, 1, 0, 0, 0), FracSec.from!"msecs"(274)), -1, SysTime(DateTime(0, 1, 1, 0, 0, 59), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1, 12, 31, 23, 59, 59), FracSec.from!"msecs"(274)), 1, SysTime(DateTime(-1, 12, 31, 23, 59, 0), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1, 1, 1, 11, 30, 33), FracSec.from!"msecs"(274)), 63_165_600L, SysTime(DateTime(-1, 1, 1, 11, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1, 1, 1, 13, 30, 33), FracSec.from!"msecs"(274)), -63_165_600L, SysTime(DateTime(1, 1, 1, 13, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1, 1, 1, 11, 30, 33), FracSec.from!"msecs"(274)), 63_165_617L, SysTime(DateTime(-1, 1, 1, 11, 30, 50), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1, 1, 1, 13, 30, 50), FracSec.from!"msecs"(274)), -63_165_617L, SysTime(DateTime(1, 1, 1, 13, 30, 33), FracSec.from!"msecs"(274)));
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0));
sysTime.roll!"seconds"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 0, 59), FracSec.from!"hnsecs"(0)));
sysTime.roll!"seconds"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_999_999));
sysTime.roll!"seconds"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 0, 59), FracSec.from!"hnsecs"(9_999_999)));
sysTime.roll!"seconds"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(0));
sysTime.roll!"seconds"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 31, 23, 59, 0), FracSec.from!"hnsecs"(0)));
sysTime.roll!"seconds"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(0)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999));
sysTime.roll!"seconds"(1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 31, 23, 59, 0), FracSec.from!"hnsecs"(9_999_999)));
sysTime.roll!"seconds"(-1);
_assertPred!"=="(sysTime, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.roll!"seconds"(4)));
//static assert(!__traits(compiles, ist.roll!"seconds"(4)));
}
}
//Shares documentation with "days" version.
/+ref SysTime+/ void roll(string units)(long value) nothrow
if(units == "msecs" ||
units == "usecs" ||
units == "hnsecs")
{
auto hnsecs = adjTime;
immutable days = splitUnitsFromHNSecs!"days"(hnsecs);
immutable negative = hnsecs < 0;
if(negative)
hnsecs += convert!("hours", "hnsecs")(24);
immutable seconds = splitUnitsFromHNSecs!"seconds"(hnsecs);
hnsecs += convert!(units, "hnsecs")(value);
hnsecs %= convert!("seconds", "hnsecs")(1);
if(hnsecs < 0)
hnsecs += convert!("seconds", "hnsecs")(1);
hnsecs += convert!("seconds", "hnsecs")(seconds);
if(negative)
hnsecs -= convert!("hours", "hnsecs")(24);
immutable newDaysHNSecs = convert!("days", "hnsecs")(days);
adjTime = newDaysHNSecs + hnsecs;
}
//Test roll!"msecs"().
unittest
{
version(testStdDateTime)
{
static void TestST(SysTime orig, int milliseconds, in SysTime expected, size_t line = __LINE__)
{
orig.roll!"msecs"(milliseconds);
_assertPred!"=="(orig, expected, "", __FILE__, line);
}
//Test A.D.
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 0, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 1, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(275)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 2, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(276)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 10, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(284)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 100, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(374)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(0)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 1000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 1001, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(275)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 2000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 26_725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 26_726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(0)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 26_727, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(1)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 1_766_725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 1_766_726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(0)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -1, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(273)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -2, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(272)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -10, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(264)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -100, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(174)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -274, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(0)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -275, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -1000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -1001, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(273)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -2000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -33_274, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(0)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -33_275, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -1_833_274, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(0)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -1_833_275, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(999)));
//Test B.C.
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 0, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 1, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(275)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 2, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(276)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 10, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(284)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 100, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(374)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(0)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 1000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 1001, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(275)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 2000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 26_725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 26_726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(0)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 26_727, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(1)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 1_766_725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), 1_766_726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(0)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -1, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(273)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -2, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(272)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -10, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(264)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -100, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(174)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(0)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -275, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -1000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -1001, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(273)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -2000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -33_274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(0)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -33_275, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -1_833_274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(0)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(274)), -1_833_275, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(999)));
//Test Both
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"msecs"(0)), 1, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"msecs"(1)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"msecs"(0)), 0, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"msecs"(0)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"msecs"(0)), -1, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"msecs"(999)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"msecs"(0)), -2, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"msecs"(998)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"msecs"(0)), -1000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"msecs"(0)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"msecs"(0)), -2000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"msecs"(0)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"msecs"(0)), -2555, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"msecs"(445)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), -1, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_989_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 0, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 1, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(19_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 1000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2555, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(5_549_999)));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.addMSecs(4)));
//static assert(!__traits(compiles, ist.addMSecs(4)));
}
}
//Test roll!"usecs"().
unittest
{
version(testStdDateTime)
{
static void TestST(SysTime orig, long microseconds, in SysTime expected, size_t line = __LINE__)
{
orig.roll!"usecs"(microseconds);
_assertPred!"=="(orig, expected, "", __FILE__, line);
}
//Test A.D.
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 0, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 1, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(275)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 2, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(276)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 10, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(284)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 100, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(374)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(1000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 1000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(1274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 1001, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(1275)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 2000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(2274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 26_725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(26_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 26_726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(27_000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 26_727, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(27_001)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 1_766_725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(766_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 1_766_726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(767_000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 1_000_000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 60_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 3_600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -1, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(273)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -2, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(272)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -10, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(264)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -100, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(174)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -274, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(0)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -275, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(999_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -1000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(999_274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -1001, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(999_273)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -2000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(998_274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -33_274, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(967_000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -33_275, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(966_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -1_833_274, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(167_000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -1_833_275, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(166_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -1_000_000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -60_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -3_600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)));
//Test B.C.
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 0, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 1, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(275)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 2, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(276)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 10, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(284)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 100, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(374)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(1000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 1000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(1274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 1001, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(1275)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 2000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(2274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 26_725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(26_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 26_726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(27_000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 26_727, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(27_001)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 1_766_725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(766_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 1_766_726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(767_000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 1_000_000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 60_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), 3_600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -1, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(273)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -2, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(272)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -10, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(264)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -100, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(174)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(0)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -275, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(999_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -1000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(999_274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -1001, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(999_273)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -2000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(998_274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -33_274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(967_000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -33_275, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(966_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -1_833_274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(167_000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -1_833_275, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(166_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -1_000_000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -60_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)), -3_600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(274)));
//Test Both
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(0)), 1, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(1)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(0)), 0, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(0)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(0)), -1, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(999_999)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(0)), -2, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(999_998)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(0)), -1000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(999_000)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(0)), -2000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(998_000)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(0)), -2555, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(997_445)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(0)), -1_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(0)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(0)), -2_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(0)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(0)), -2_333_333, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"usecs"(666_667)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), -1, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_989)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 0, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 1, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(19)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 1000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(19_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2555, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(25_549)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 1_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2_333_333, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(3_333_329)));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.roll!"usecs"(4)));
//static assert(!__traits(compiles, ist.roll!"usecs"(4)));
}
}
//Test roll!"hnsecs"().
unittest
{
version(testStdDateTime)
{
static void TestST(SysTime orig, long hnsecs, in SysTime expected, size_t line = __LINE__)
{
orig.roll!"hnsecs"(hnsecs);
_assertPred!"=="(orig, expected, "", __FILE__, line);
}
//Test A.D.
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 0, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(275)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 2, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(276)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 10, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(284)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 100, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(374)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1001, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1275)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 2000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 26_725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(26_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 26_726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(27_000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 26_727, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(27_001)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1_766_725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_766_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1_766_726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_767_000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1_000_000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_000_274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 60_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 3_600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 36_000_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(273)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -2, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(272)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -10, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(264)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -100, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(174)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -274, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(0)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -275, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(9_999_274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1001, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(9_999_273)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -2000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(9_998_274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -33_274, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(9_967_000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -33_275, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(9_966_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1_833_274, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(8_167_000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1_833_275, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(8_166_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1_000_000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(9_000_274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -60_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -3_600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -36_000_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
//Test B.C.
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 0, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(275)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 2, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(276)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 10, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(284)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 100, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(374)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1001, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1275)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 2000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 26_725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(26_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 26_726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(27_000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 26_727, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(27_001)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1_766_725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_766_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1_766_726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_767_000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1_000_000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_000_274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 60_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 3_600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 36_000_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(273)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -2, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(272)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -10, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(264)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -100, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(174)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(0)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -275, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(9_999_274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1001, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(9_999_273)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -2000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(9_998_274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -33_274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(9_967_000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -33_275, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(9_966_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1_833_274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(8_167_000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1_833_275, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(8_166_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1_000_000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(9_000_274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -60_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -3_600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -36_000_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
//Test Both
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), 1, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), 0, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -1, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -2, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_999_998)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -1000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_999_000)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -2000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_998_000)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -2555, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_997_445)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -1_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_000_000)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -2_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(8_000_000)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -2_333_333, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(7_666_667)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -10_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -20_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -20_888_888, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_111_112)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), -1, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_998)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 0, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 1, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(0)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(1)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 1000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(1999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2555, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(2554)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 1_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(1_999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2_333_333, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(2_333_332)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 10_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 20_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 20_888_888, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(888_887)));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.roll!"hnsecs"(4)));
//static assert(!__traits(compiles, ist.roll!"hnsecs"(4)));
}
}
/++
Gives the result of adding or subtracting a duration from this
$(D SysTime).
The legal types of arithmetic for $(D SysTime) using this operator are
$(BOOKTABLE,
$(TR $(TD SysTime) $(TD +) $(TD duration) $(TD -->) $(TD SysTime))
$(TR $(TD SysTime) $(TD -) $(TD duration) $(TD -->) $(TD SysTime))
)
Params:
duration = The duration to add to or subtract from this
$(D SysTime).
+/
SysTime opBinary(string op, D)(in D duration) const pure nothrow
if((op == "+" || op == "-") &&
(is(Unqual!D == Duration) ||
is(Unqual!D == TickDuration)))
{
SysTime retval = SysTime(this._stdTime, this._timezone);
static if(is(Unqual!D == Duration))
immutable hnsecs = duration.total!"hnsecs";
else static if(is(Unqual!D == TickDuration))
immutable hnsecs = duration.hnsecs;
//Ideally, this would just be
//retval._stdTime += unaryFun!(op ~ "a")(hnsecs);
//But there isn't currently a pure version of unaryFun!().
static if(op == "+")
immutable signedHNSecs = hnsecs;
else static if(op == "-")
immutable signedHNSecs = -hnsecs;
else
static assert(0);
retval._stdTime += signedHNSecs;
return retval;
}
unittest
{
version(testStdDateTime)
{
auto st = SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2_345_678));
_assertPred!"=="(st + dur!"weeks"(7), SysTime(DateTime(1999, 8, 24, 12, 30, 33), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st + dur!"weeks"(-7), SysTime(DateTime(1999, 5, 18, 12, 30, 33), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st + dur!"days"(7), SysTime(DateTime(1999, 7, 13, 12, 30, 33), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st + dur!"days"(-7), SysTime(DateTime(1999, 6, 29, 12, 30, 33), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st + dur!"hours"(7), SysTime(DateTime(1999, 7, 6, 19, 30, 33), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st + dur!"hours"(-7), SysTime(DateTime(1999, 7, 6, 5, 30, 33), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st + dur!"minutes"(7), SysTime(DateTime(1999, 7, 6, 12, 37, 33), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st + dur!"minutes"(-7), SysTime(DateTime(1999, 7, 6, 12, 23, 33), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st + dur!"seconds"(7), SysTime(DateTime(1999, 7, 6, 12, 30, 40), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st + dur!"seconds"(-7), SysTime(DateTime(1999, 7, 6, 12, 30, 26), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st + dur!"msecs"(7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2_415_678)));
_assertPred!"=="(st + dur!"msecs"(-7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2_275_678)));
_assertPred!"=="(st + dur!"usecs"(7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2_345_748)));
_assertPred!"=="(st + dur!"usecs"(-7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2_345_608)));
_assertPred!"=="(st + dur!"hnsecs"(7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2_345_685)));
_assertPred!"=="(st + dur!"hnsecs"(-7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2_345_671)));
//This probably only runs in cases where gettimeofday() is used, but it's
//hard to do this test correctly with variable ticksPerSec.
if(TickDuration.ticksPerSec == 1_000_000)
{
_assertPred!"=="(st + TickDuration.from!"usecs"(7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2_345_748)));
_assertPred!"=="(st + TickDuration.from!"usecs"(-7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2_345_608)));
}
_assertPred!"=="(st - dur!"weeks"(-7), SysTime(DateTime(1999, 8, 24, 12, 30, 33), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st - dur!"weeks"(7), SysTime(DateTime(1999, 5, 18, 12, 30, 33), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st - dur!"days"(-7), SysTime(DateTime(1999, 7, 13, 12, 30, 33), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st - dur!"days"(7), SysTime(DateTime(1999, 6, 29, 12, 30, 33), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st - dur!"hours"(-7), SysTime(DateTime(1999, 7, 6, 19, 30, 33), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st - dur!"hours"(7), SysTime(DateTime(1999, 7, 6, 5, 30, 33), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st - dur!"minutes"(-7), SysTime(DateTime(1999, 7, 6, 12, 37, 33), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st - dur!"minutes"(7), SysTime(DateTime(1999, 7, 6, 12, 23, 33), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st - dur!"seconds"(-7), SysTime(DateTime(1999, 7, 6, 12, 30, 40), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st - dur!"seconds"(7), SysTime(DateTime(1999, 7, 6, 12, 30, 26), FracSec.from!"hnsecs"(2_345_678)));
_assertPred!"=="(st - dur!"msecs"(-7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2_415_678)));
_assertPred!"=="(st - dur!"msecs"(7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2_275_678)));
_assertPred!"=="(st - dur!"usecs"(-7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2_345_748)));
_assertPred!"=="(st - dur!"usecs"(7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2_345_608)));
_assertPred!"=="(st - dur!"hnsecs"(-7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2_345_685)));
_assertPred!"=="(st - dur!"hnsecs"(7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2_345_671)));
//This probably only runs in cases where gettimeofday() is used, but it's
//hard to do this test correctly with variable ticksPerSec.
if(TickDuration.ticksPerSec == 1_000_000)
{
_assertPred!"=="(st - TickDuration.from!"usecs"(-7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2_345_748)));
_assertPred!"=="(st - TickDuration.from!"usecs"(7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2_345_608)));
}
static void TestST(in SysTime orig, long hnsecs, in SysTime expected, size_t line = __LINE__)
{
_assertPred!"=="(orig + dur!"hnsecs"(hnsecs), expected, "", __FILE__, line);
}
//Test A.D.
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 0, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(275)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 2, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(276)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 10, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(284)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 100, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(374)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1001, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1275)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 2000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 26_725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(26_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 26_726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(27_000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 26_727, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(27_001)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1_766_725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_766_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1_766_726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_767_000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1_000_000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_000_274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 60_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 39), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 3_600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 36, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 31, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 36_000_000_000L, SysTime(DateTime(1999, 7, 6, 13, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(273)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -2, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(272)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -10, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(264)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -100, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(174)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -274, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(0)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -275, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1000, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_999_274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1001, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_999_273)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -2000, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_998_274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -33_274, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_967_000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -33_275, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_966_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1_833_274, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(8_167_000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1_833_275, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(8_166_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1_000_000, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_000_274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -60_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 27), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -3_600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 24, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 29, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -36_000_000_000L, SysTime(DateTime(1999, 7, 6, 11, 30, 33), FracSec.from!"hnsecs"(274)));
//Test B.C.
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 0, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(275)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 2, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(276)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 10, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(284)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 100, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(374)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1001, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1275)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 2000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 26_725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(26_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 26_726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(27_000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 26_727, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(27_001)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1_766_725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_766_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1_766_726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_767_000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1_000_000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_000_274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 60_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 39), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 3_600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 36, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 31, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 36_000_000_000L, SysTime(DateTime(-1999, 7, 6, 13, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(273)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -2, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(272)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -10, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(264)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -100, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(174)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(0)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -275, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1000, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_999_274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1001, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_999_273)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -2000, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_998_274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -33_274, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_967_000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -33_275, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_966_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1_833_274, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(8_167_000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1_833_275, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(8_166_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1_000_000, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_000_274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -60_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 27), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -3_600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 24, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 29, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -36_000_000_000L, SysTime(DateTime(-1999, 7, 6, 11, 30, 33), FracSec.from!"hnsecs"(274)));
//Test Both
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), 1, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), 0, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -1, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -2, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_998)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -1000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_000)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -2000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_998_000)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -2555, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_997_445)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -1_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_000_000)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -2_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(8_000_000)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -2_333_333, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(7_666_667)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -10_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(0)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -20_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 58), FracSec.from!"hnsecs"(0)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -20_888_888, SysTime(DateTime(0, 12, 31, 23, 59, 57), FracSec.from!"hnsecs"(9_111_112)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), -1, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_998)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 0, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 1, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 1000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2555, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(2554)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 1_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1_999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2_333_333, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(2_333_332)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 10_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 20_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 1), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 20_888_888, SysTime(DateTime(1, 1, 1, 0, 0, 2), FracSec.from!"hnsecs"(888_887)));
auto duration = dur!"seconds"(12);
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cst + duration));
//static assert(__traits(compiles, ist + duration));
static assert(__traits(compiles, cst - duration));
//static assert(__traits(compiles, ist - duration));
}
}
/++
Gives the result of adding or subtracting a duration from this
$(D SysTime), as well as assigning the result to this $(D SysTime).
The legal types of arithmetic for $(D SysTime) using this operator are
$(BOOKTABLE,
$(TR $(TD SysTime) $(TD +) $(TD duration) $(TD -->) $(TD SysTime))
$(TR $(TD SysTime) $(TD -) $(TD duration) $(TD -->) $(TD SysTime))
)
Params:
duration = The duration to add to or subtract from this
$(D SysTime).
+/
/+ref+/ SysTime opOpAssign(string op, D)(in D duration) pure nothrow
if((op == "+" || op == "-") &&
(is(Unqual!D == Duration) ||
is(Unqual!D == TickDuration)))
{
static if(is(Unqual!D == Duration))
auto hnsecs = duration.total!"hnsecs";
else static if(is(Unqual!D == TickDuration))
auto hnsecs = duration.hnsecs;
//Ideally, this would just be
//_stdTime += unaryFun!(op ~ "a")(hnsecs);
//But there isn't currently a pure version of unaryFun!().
static if(op == "+")
immutable signedHNSecs = hnsecs;
else static if(op == "-")
immutable signedHNSecs = -hnsecs;
else
static assert(0);
_stdTime += signedHNSecs;
return this;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"+="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"weeks"(7), SysTime(DateTime(1999, 8, 24, 12, 30, 33)));
_assertPred!"+="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"weeks"(-7), SysTime(DateTime(1999, 5, 18, 12, 30, 33)));
_assertPred!"+="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"days"(7), SysTime(DateTime(1999, 7, 13, 12, 30, 33)));
_assertPred!"+="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"days"(-7), SysTime(DateTime(1999, 6, 29, 12, 30, 33)));
_assertPred!"+="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"hours"(7), SysTime(DateTime(1999, 7, 6, 19, 30, 33)));
_assertPred!"+="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"hours"(-7), SysTime(DateTime(1999, 7, 6, 5, 30, 33)));
_assertPred!"+="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"minutes"(7), SysTime(DateTime(1999, 7, 6, 12, 37, 33)));
_assertPred!"+="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"minutes"(-7), SysTime(DateTime(1999, 7, 6, 12, 23, 33)));
_assertPred!"+="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"seconds"(7), SysTime(DateTime(1999, 7, 6, 12, 30, 40)));
_assertPred!"+="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"seconds"(-7), SysTime(DateTime(1999, 7, 6, 12, 30, 26)));
_assertPred!"+="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"msecs"(7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(7)));
_assertPred!"+="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"msecs"(-7), SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"msecs"(993)));
_assertPred!"+="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"usecs"(7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7)));
_assertPred!"+="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"usecs"(-7), SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"usecs"(999_993)));
_assertPred!"+="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"hnsecs"(7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(7)));
_assertPred!"+="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"hnsecs"(-7), SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_999_993)));
_assertPred!"-="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"weeks"(-7), SysTime(DateTime(1999, 8, 24, 12, 30, 33)));
_assertPred!"-="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"weeks"(7), SysTime(DateTime(1999, 5, 18, 12, 30, 33)));
_assertPred!"-="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"days"(-7), SysTime(DateTime(1999, 7, 13, 12, 30, 33)));
_assertPred!"-="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"days"(7), SysTime(DateTime(1999, 6, 29, 12, 30, 33)));
_assertPred!"-="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"hours"(-7), SysTime(DateTime(1999, 7, 6, 19, 30, 33)));
_assertPred!"-="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"hours"(7), SysTime(DateTime(1999, 7, 6, 5, 30, 33)));
_assertPred!"-="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"minutes"(-7), SysTime(DateTime(1999, 7, 6, 12, 37, 33)));
_assertPred!"-="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"minutes"(7), SysTime(DateTime(1999, 7, 6, 12, 23, 33)));
_assertPred!"-="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"seconds"(-7), SysTime(DateTime(1999, 7, 6, 12, 30, 40)));
_assertPred!"-="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"seconds"(7), SysTime(DateTime(1999, 7, 6, 12, 30, 26)));
_assertPred!"-="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"msecs"(-7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(7)));
_assertPred!"-="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"msecs"(7), SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"msecs"(993)));
_assertPred!"-="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"usecs"(-7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(7)));
_assertPred!"-="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"usecs"(7), SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"usecs"(999_993)));
_assertPred!"-="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"hnsecs"(-7), SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(7)));
_assertPred!"-="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)), dur!"hnsecs"(7), SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_999_993)));
static void TestST(SysTime orig, long hnsecs, in SysTime expected, size_t line = __LINE__)
{
orig += dur!"hnsecs"(hnsecs);
_assertPred!"=="(orig, expected, "", __FILE__, line);
}
//Test A.D.
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 0, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(275)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 2, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(276)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 10, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(284)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 100, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(374)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1001, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1275)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 2000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 26_725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(26_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 26_726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(27_000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 26_727, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(27_001)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1_766_725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_766_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1_766_726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_767_000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1_000_000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_000_274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 60_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 39), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 3_600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 36, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 31, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 36_000_000_000L, SysTime(DateTime(1999, 7, 6, 13, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(273)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -2, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(272)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -10, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(264)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -100, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(174)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -274, SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(0)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -275, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1000, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_999_274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1001, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_999_273)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -2000, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_998_274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -33_274, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_967_000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -33_275, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_966_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1_833_274, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(8_167_000)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1_833_275, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(8_166_999)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1_000_000, SysTime(DateTime(1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_000_274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -60_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 27), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -3_600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 24, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 29, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -36_000_000_000L, SysTime(DateTime(1999, 7, 6, 11, 30, 33), FracSec.from!"hnsecs"(274)));
//Test B.C.
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 0, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(275)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 2, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(276)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 10, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(284)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 100, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(374)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1001, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1275)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 2000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(2274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 26_725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(26_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 26_726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(27_000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 26_727, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(27_001)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1_766_725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_766_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1_766_726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_767_000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 1_000_000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_000_274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 60_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 39), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 3_600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 36, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 31, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), 36_000_000_000L, SysTime(DateTime(-1999, 7, 6, 13, 30, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(273)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -2, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(272)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -10, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(264)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -100, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(174)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(0)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -275, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1000, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_999_274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1001, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_999_273)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -2000, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_998_274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -33_274, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_967_000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -33_275, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_966_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1_833_274, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(8_167_000)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1_833_275, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(8_166_999)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -1_000_000, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), FracSec.from!"hnsecs"(9_000_274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -60_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 27), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -3_600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 24, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 29, 33), FracSec.from!"hnsecs"(274)));
TestST(SysTime(DateTime(-1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(274)), -36_000_000_000L, SysTime(DateTime(-1999, 7, 6, 11, 30, 33), FracSec.from!"hnsecs"(274)));
//Test Both
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), 1, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), 0, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -1, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -2, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_998)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -1000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_000)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -2000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_998_000)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -2555, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_997_445)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -1_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_000_000)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -2_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(8_000_000)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -2_333_333, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(7_666_667)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -10_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(0)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -20_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 58), FracSec.from!"hnsecs"(0)));
TestST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), -20_888_888, SysTime(DateTime(0, 12, 31, 23, 59, 57), FracSec.from!"hnsecs"(9_111_112)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), -1, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_998)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 0, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 1, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 1000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2555, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(2554)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 1_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1_999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 2_333_333, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(2_333_332)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 10_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 20_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 1), FracSec.from!"hnsecs"(9_999_999)));
TestST(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 20_888_888, SysTime(DateTime(1, 1, 1, 0, 0, 2), FracSec.from!"hnsecs"(888_887)));
auto duration = dur!"seconds"(12);
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst += duration));
//static assert(!__traits(compiles, ist += duration));
static assert(!__traits(compiles, cst -= duration));
//static assert(!__traits(compiles, ist -= duration));
}
}
/++
Gives the difference between two $(D SysTime)s.
The legal types of arithmetic for $(D SysTime) using this operator are
$(BOOKTABLE,
$(TR $(TD SysTime) $(TD -) $(TD SysTime) $(TD -->) $(TD duration))
)
+/
Duration opBinary(string op)(in SysTime rhs) const pure nothrow
if(op == "-")
{
return dur!"hnsecs"(_stdTime - rhs._stdTime);
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)) - SysTime(DateTime(1998, 7, 6, 12, 30, 33)),
dur!"seconds"(31_536_000));
_assertPred!"=="(SysTime(DateTime(1998, 7, 6, 12, 30, 33)) - SysTime(DateTime(1999, 7, 6, 12, 30, 33)),
dur!"seconds"(-31_536_000));
_assertPred!"=="(SysTime(DateTime(1999, 8, 6, 12, 30, 33)) - SysTime(DateTime(1999, 7, 6, 12, 30, 33)),
dur!"seconds"(26_78_400));
_assertPred!"=="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)) - SysTime(DateTime(1999, 8, 6, 12, 30, 33)),
dur!"seconds"(-26_78_400));
_assertPred!"=="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)) - SysTime(DateTime(1999, 7, 5, 12, 30, 33)),
dur!"seconds"(86_400));
_assertPred!"=="(SysTime(DateTime(1999, 7, 5, 12, 30, 33)) - SysTime(DateTime(1999, 7, 6, 12, 30, 33)),
dur!"seconds"(-86_400));
_assertPred!"=="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)) - SysTime(DateTime(1999, 7, 6, 11, 30, 33)),
dur!"seconds"(3600));
_assertPred!"=="(SysTime(DateTime(1999, 7, 6, 11, 30, 33)) - SysTime(DateTime(1999, 7, 6, 12, 30, 33)),
dur!"seconds"(-3600));
_assertPred!"=="(SysTime(DateTime(1999, 7, 6, 12, 31, 33)) - SysTime(DateTime(1999, 7, 6, 12, 30, 33)),
dur!"seconds"(60));
_assertPred!"=="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)) - SysTime(DateTime(1999, 7, 6, 12, 31, 33)),
dur!"seconds"(-60));
_assertPred!"=="(SysTime(DateTime(1999, 7, 6, 12, 30, 34)) - SysTime(DateTime(1999, 7, 6, 12, 30, 33)),
dur!"seconds"(1));
_assertPred!"=="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)) - SysTime(DateTime(1999, 7, 6, 12, 30, 34)),
dur!"seconds"(-1));
_assertPred!"=="(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(532)) - SysTime(DateTime(1999, 7, 6, 12, 30, 33)),
dur!"msecs"(532));
_assertPred!"=="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)) - SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"msecs"(532)),
dur!"msecs"(-532));
_assertPred!"=="(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(333_347)) - SysTime(DateTime(1999, 7, 6, 12, 30, 33)),
dur!"usecs"(333_347));
_assertPred!"=="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)) - SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"usecs"(333_347)),
dur!"usecs"(-333_347));
_assertPred!"=="(SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_234_567)) - SysTime(DateTime(1999, 7, 6, 12, 30, 33)),
dur!"hnsecs"(1_234_567));
_assertPred!"=="(SysTime(DateTime(1999, 7, 6, 12, 30, 33)) - SysTime(DateTime(1999, 7, 6, 12, 30, 33), FracSec.from!"hnsecs"(1_234_567)),
dur!"hnsecs"(-1_234_567));
_assertPred!"=="(SysTime(DateTime(1, 1, 1, 12, 30, 33)) - SysTime(DateTime(1, 1, 1, 0, 0, 0)), dur!"seconds"(45033));
_assertPred!"=="(SysTime(DateTime(1, 1, 1, 0, 0, 0)) - SysTime(DateTime(1, 1, 1, 12, 30, 33)), dur!"seconds"(-45033));
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 12, 30, 33)) - SysTime(DateTime(1, 1, 1, 0, 0, 0)), dur!"seconds"(-41367));
_assertPred!"=="(SysTime(DateTime(1, 1, 1, 0, 0, 0)) - SysTime(DateTime(0, 12, 31, 12, 30, 33)), dur!"seconds"(41367));
_assertPred!"=="(SysTime(DateTime(1, 1, 1, 0, 0, 0)) - SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)),
dur!"hnsecs"(1));
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)) - SysTime(DateTime(1, 1, 1, 0, 0, 0)),
dur!"hnsecs"(-1));
auto tz = TimeZone.getTimeZone("America/Los_Angeles");
_assertPred!"=="(SysTime(DateTime(2011, 1, 13, 8, 17, 2), FracSec.from!"msecs"(296), tz) -
SysTime(DateTime(2011, 1, 13, 8, 17, 2), FracSec.from!"msecs"(296), tz),
dur!"hnsecs"(0));
_assertPred!"=="(SysTime(DateTime(2011, 1, 13, 8, 17, 2), FracSec.from!"msecs"(296), tz) -
SysTime(DateTime(2011, 1, 13, 8, 17, 2), FracSec.from!"msecs"(296), UTC()),
dur!"hours"(8));
_assertPred!"=="(SysTime(DateTime(2011, 1, 13, 8, 17, 2), FracSec.from!"msecs"(296), UTC()) -
SysTime(DateTime(2011, 1, 13, 8, 17, 2), FracSec.from!"msecs"(296), tz),
dur!"hours"(-8));
auto st = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, st - st));
static assert(__traits(compiles, cst - st));
//static assert(__traits(compiles, ist - st));
static assert(__traits(compiles, st - cst));
static assert(__traits(compiles, cst - cst));
//static assert(__traits(compiles, ist - cst));
//static assert(__traits(compiles, st - ist));
//static assert(__traits(compiles, cst - ist));
//static assert(__traits(compiles, ist - ist));
}
}
/++
Returns the difference between the two $(D SysTime)s in months.
You can get the difference in years by subtracting the year property
of two $(D SysTime)s, and you can get the difference in days or weeks by
subtracting the $(D SysTime)s themselves and using the $(D Duration)
that results, but because you cannot convert between months and smaller
units without a specific date (which $(D Duration)s don't have), you
cannot get the difference in months without doing some math using both
the year and month properties, so this is a convenience function for
getting the difference in months.
Note that the number of days in the months or how far into the month
either date is is irrelevant. It is the difference in the month property
combined with the difference in years * 12. So, for instance,
December 31st and January 1st are one month apart just as December 1st
and January 31st are one month apart.
Params:
rhs = The $(D SysTime) to subtract from this one.
Examples:
--------------------
assert(SysTime(Date(1999, 2, 1)).diffMonths(SysTime(Date(1999, 1, 31))) == 1);
assert(SysTime(Date(1999, 1, 31)).diffMonths(SysTime(Date(1999, 2, 1))) == -1);
assert(SysTime(Date(1999, 3, 1)).diffMonths(SysTime(Date(1999, 1, 1))) == 2);
assert(SysTime(Date(1999, 1, 1)).diffMonths(SysTime(Date(1999, 3, 31))) == -2);
--------------------
+/
int diffMonths(in SysTime rhs) const nothrow
{
return (cast(Date)this).diffMonths(cast(Date)rhs);
}
unittest
{
version(testStdDateTime)
{
auto st = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, st.diffMonths(st)));
static assert(__traits(compiles, cst.diffMonths(st)));
//static assert(__traits(compiles, ist.diffMonths(st)));
static assert(__traits(compiles, st.diffMonths(cst)));
static assert(__traits(compiles, cst.diffMonths(cst)));
//static assert(__traits(compiles, ist.diffMonths(cst)));
//static assert(__traits(compiles, st.diffMonths(ist)));
//static assert(__traits(compiles, cst.diffMonths(ist)));
//static assert(__traits(compiles, ist.diffMonths(ist)));
//Verify Examples.
assert(SysTime(Date(1999, 2, 1)).diffMonths(SysTime(Date(1999, 1, 31))) == 1);
assert(SysTime(Date(1999, 1, 31)).diffMonths(SysTime(Date(1999, 2, 1))) == -1);
assert(SysTime(Date(1999, 3, 1)).diffMonths(SysTime(Date(1999, 1, 1))) == 2);
assert(SysTime(Date(1999, 1, 1)).diffMonths(SysTime(Date(1999, 3, 31))) == -2);
}
}
/++
Whether this $(D SysTime) is in a leap year.
+/
@property bool isLeapYear() const nothrow
{
return (cast(Date)this).isLeapYear;
}
unittest
{
version(testStdDateTime)
{
auto st = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, st.isLeapYear));
static assert(__traits(compiles, cst.isLeapYear));
//static assert(__traits(compiles, ist.isLeapYear));
}
}
/++
Day of the week this $(D SysTime) is on.
+/
@property DayOfWeek dayOfWeek() const nothrow
{
return getDayOfWeek(dayOfGregorianCal);
}
unittest
{
version(testStdDateTime)
{
auto st = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, st.dayOfWeek));
static assert(__traits(compiles, cst.dayOfWeek));
//static assert(__traits(compiles, ist.dayOfWeek));
}
}
/++
Day of the year this $(D SysTime) is on.
Examples:
--------------------
assert(SysTime(DateTime(1999, 1, 1, 12, 22, 7)).dayOfYear == 1);
assert(SysTime(DateTime(1999, 12, 31, 7, 2, 59)).dayOfYear == 365);
assert(SysTime(DateTime(2000, 12, 31, 21, 20, 0)).dayOfYear == 366);
--------------------
+/
@property ushort dayOfYear() const nothrow
{
return (cast(Date)this).dayOfYear;
}
unittest
{
version(testStdDateTime)
{
auto st = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, st.dayOfYear));
static assert(__traits(compiles, cst.dayOfYear));
//static assert(__traits(compiles, ist.dayOfYear));
//Verify Examples.
assert(SysTime(DateTime(1999, 1, 1, 12, 22, 7)).dayOfYear == 1);
assert(SysTime(DateTime(1999, 12, 31, 7, 2, 59)).dayOfYear == 365);
assert(SysTime(DateTime(2000, 12, 31, 21, 20, 0)).dayOfYear == 366);
}
}
/++
Day of the year.
Params:
day = The day of the year to set which day of the year this
$(D SysTime) is on.
+/
@property void dayOfYear(int day)
{
immutable hnsecs = adjTime;
immutable days = convert!("hnsecs", "days")(hnsecs);
immutable theRest = hnsecs - convert!("days", "hnsecs")(days);
auto date = Date(cast(int)days);
date.dayOfYear = day;
immutable newDaysHNSecs = convert!("days", "hnsecs")(date.dayOfGregorianCal - 1);
adjTime = newDaysHNSecs + theRest;
}
unittest
{
version(testStdDateTime)
{
auto st = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, st.dayOfYear = 12));
static assert(!__traits(compiles, cst.dayOfYear = 12));
//static assert(!__traits(compiles, ist.dayOfYear = 12));
}
}
/++
The Xth day of the Gregorian Calendar that this $(D SysTime) is on.
Examples:
--------------------
assert(SysTime(DateTime(1, 1, 1, 0, 0, 0)).dayOfGregorianCal == 1);
assert(SysTime(DateTime(1, 12, 31, 23, 59, 59)).dayOfGregorianCal == 365);
assert(SysTime(DateTime(2, 1, 1, 2, 2, 2)).dayOfGregorianCal == 366);
assert(SysTime(DateTime(0, 12, 31, 7, 7, 7)).dayOfGregorianCal == 0);
assert(SysTime(DateTime(0, 1, 1, 19, 30, 0)).dayOfGregorianCal == -365);
assert(SysTime(DateTime(-1, 12, 31, 4, 7, 0)).dayOfGregorianCal == -366);
assert(SysTime(DateTime(2000, 1, 1, 9, 30, 20)).dayOfGregorianCal == 730_120);
assert(SysTime(DateTime(2010, 12, 31, 15, 45, 50)).dayOfGregorianCal == 734_137);
--------------------
+/
@property int dayOfGregorianCal() const nothrow
{
immutable adjustedTime = adjTime;
//We have to add one because 0 would be midnight, January 1st, 1 A.D.,
//which would be the 1st day of the Gregorian Calendar, not the 0th. So,
//simply casting to days is one day off.
if(adjustedTime > 0)
return cast(int)getUnitsFromHNSecs!"days"(adjustedTime) + 1;
auto hnsecs = adjustedTime;
immutable days = cast(int)splitUnitsFromHNSecs!"days"(hnsecs);
return hnsecs == 0 ? days + 1 : days;
}
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal, 1);
_assertPred!"=="(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1)).dayOfGregorianCal, 1);
_assertPred!"=="(SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal, 1);
_assertPred!"=="(SysTime(DateTime(1, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 1);
_assertPred!"=="(SysTime(DateTime(1, 1, 2, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 2);
_assertPred!"=="(SysTime(DateTime(1, 2, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 32);
_assertPred!"=="(SysTime(DateTime(2, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 366);
_assertPred!"=="(SysTime(DateTime(3, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 731);
_assertPred!"=="(SysTime(DateTime(4, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 1096);
_assertPred!"=="(SysTime(DateTime(5, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 1462);
_assertPred!"=="(SysTime(DateTime(50, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 17_898);
_assertPred!"=="(SysTime(DateTime(97, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 35_065);
_assertPred!"=="(SysTime(DateTime(100, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 36_160);
_assertPred!"=="(SysTime(DateTime(101, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 36_525);
_assertPred!"=="(SysTime(DateTime(105, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 37_986);
_assertPred!"=="(SysTime(DateTime(200, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 72_684);
_assertPred!"=="(SysTime(DateTime(201, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 73_049);
_assertPred!"=="(SysTime(DateTime(300, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 109_208);
_assertPred!"=="(SysTime(DateTime(301, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 109_573);
_assertPred!"=="(SysTime(DateTime(400, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 145_732);
_assertPred!"=="(SysTime(DateTime(401, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 146_098);
_assertPred!"=="(SysTime(DateTime(500, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 182_257);
_assertPred!"=="(SysTime(DateTime(501, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 182_622);
_assertPred!"=="(SysTime(DateTime(1000, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 364_878);
_assertPred!"=="(SysTime(DateTime(1001, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 365_243);
_assertPred!"=="(SysTime(DateTime(1600, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 584_023);
_assertPred!"=="(SysTime(DateTime(1601, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 584_389);
_assertPred!"=="(SysTime(DateTime(1900, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 693_596);
_assertPred!"=="(SysTime(DateTime(1901, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 693_961);
_assertPred!"=="(SysTime(DateTime(1945, 11, 12, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 710_347);
_assertPred!"=="(SysTime(DateTime(1999, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 729_755);
_assertPred!"=="(SysTime(DateTime(2000, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 730_120);
_assertPred!"=="(SysTime(DateTime(2001, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 730_486);
_assertPred!"=="(SysTime(DateTime(2010, 1, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 733_773);
_assertPred!"=="(SysTime(DateTime(2010, 1, 31, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 733_803);
_assertPred!"=="(SysTime(DateTime(2010, 2, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 733_804);
_assertPred!"=="(SysTime(DateTime(2010, 2, 28, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 733_831);
_assertPred!"=="(SysTime(DateTime(2010, 3, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 733_832);
_assertPred!"=="(SysTime(DateTime(2010, 3, 31, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 733_862);
_assertPred!"=="(SysTime(DateTime(2010, 4, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 733_863);
_assertPred!"=="(SysTime(DateTime(2010, 4, 30, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 733_892);
_assertPred!"=="(SysTime(DateTime(2010, 5, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 733_893);
_assertPred!"=="(SysTime(DateTime(2010, 5, 31, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 733_923);
_assertPred!"=="(SysTime(DateTime(2010, 6, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 733_924);
_assertPred!"=="(SysTime(DateTime(2010, 6, 30, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 733_953);
_assertPred!"=="(SysTime(DateTime(2010, 7, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 733_954);
_assertPred!"=="(SysTime(DateTime(2010, 7, 31, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 733_984);
_assertPred!"=="(SysTime(DateTime(2010, 8, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 733_985);
_assertPred!"=="(SysTime(DateTime(2010, 8, 31, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 734_015);
_assertPred!"=="(SysTime(DateTime(2010, 9, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 734_016);
_assertPred!"=="(SysTime(DateTime(2010, 9, 30, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 734_045);
_assertPred!"=="(SysTime(DateTime(2010, 10, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 734_046);
_assertPred!"=="(SysTime(DateTime(2010, 10, 31, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 734_076);
_assertPred!"=="(SysTime(DateTime(2010, 11, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 734_077);
_assertPred!"=="(SysTime(DateTime(2010, 11, 30, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 734_106);
_assertPred!"=="(SysTime(DateTime(2010, 12, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 734_107);
_assertPred!"=="(SysTime(DateTime(2010, 12, 31, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, 734_137);
_assertPred!"=="(SysTime(DateTime(2012, 2, 1, 0, 0, 0), FracSec.from!"msecs"(0)).dayOfGregorianCal, 734_534);
_assertPred!"=="(SysTime(DateTime(2012, 2, 28, 0, 0, 0), FracSec.from!"msecs"(0)).dayOfGregorianCal, 734_561);
_assertPred!"=="(SysTime(DateTime(2012, 2, 29, 0, 0, 0), FracSec.from!"msecs"(0)).dayOfGregorianCal, 734_562);
_assertPred!"=="(SysTime(DateTime(2012, 3, 1, 0, 0, 0), FracSec.from!"msecs"(0)).dayOfGregorianCal, 734_563);
//Test B.C.
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal, 0);
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_998)).dayOfGregorianCal, 0);
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(0)).dayOfGregorianCal, 0);
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 0, 0, 0), FracSec.from!"hnsecs"(1)).dayOfGregorianCal, 0);
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 0, 0, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal, 0);
_assertPred!"=="(SysTime(DateTime(-1, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal, -366);
_assertPred!"=="(SysTime(DateTime(-1, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_998)).dayOfGregorianCal, -366);
_assertPred!"=="(SysTime(DateTime(-1, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(0)).dayOfGregorianCal, -366);
_assertPred!"=="(SysTime(DateTime(-1, 12, 31, 0, 0, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal, -366);
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, 0);
_assertPred!"=="(SysTime(DateTime(0, 12, 30, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -1);
_assertPred!"=="(SysTime(DateTime(0, 12, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -30);
_assertPred!"=="(SysTime(DateTime(0, 11, 30, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -31);
_assertPred!"=="(SysTime(DateTime(-1, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -366);
_assertPred!"=="(SysTime(DateTime(-1, 12, 30, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -367);
_assertPred!"=="(SysTime(DateTime(-1, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -730);
_assertPred!"=="(SysTime(DateTime(-2, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -731);
_assertPred!"=="(SysTime(DateTime(-2, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -1095);
_assertPred!"=="(SysTime(DateTime(-3, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -1096);
_assertPred!"=="(SysTime(DateTime(-3, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -1460);
_assertPred!"=="(SysTime(DateTime(-4, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -1461);
_assertPred!"=="(SysTime(DateTime(-4, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -1826);
_assertPred!"=="(SysTime(DateTime(-5, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -1827);
_assertPred!"=="(SysTime(DateTime(-5, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -2191);
_assertPred!"=="(SysTime(DateTime(-9, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -3652);
_assertPred!"=="(SysTime(DateTime(-49, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -18_262);
_assertPred!"=="(SysTime(DateTime(-50, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -18_627);
_assertPred!"=="(SysTime(DateTime(-97, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -35_794);
_assertPred!"=="(SysTime(DateTime(-99, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -36_160);
_assertPred!"=="(SysTime(DateTime(-99, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -36_524);
_assertPred!"=="(SysTime(DateTime(-100, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -36_889);
_assertPred!"=="(SysTime(DateTime(-101, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -37_254);
_assertPred!"=="(SysTime(DateTime(-105, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -38_715);
_assertPred!"=="(SysTime(DateTime(-200, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -73_413);
_assertPred!"=="(SysTime(DateTime(-201, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -73_778);
_assertPred!"=="(SysTime(DateTime(-300, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -109_937);
_assertPred!"=="(SysTime(DateTime(-301, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -110_302);
_assertPred!"=="(SysTime(DateTime(-400, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -146_097);
_assertPred!"=="(SysTime(DateTime(-400, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -146_462);
_assertPred!"=="(SysTime(DateTime(-401, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -146_827);
_assertPred!"=="(SysTime(DateTime(-499, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -182_621);
_assertPred!"=="(SysTime(DateTime(-500, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -182_986);
_assertPred!"=="(SysTime(DateTime(-501, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -183_351);
_assertPred!"=="(SysTime(DateTime(-1000, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -365_607);
_assertPred!"=="(SysTime(DateTime(-1001, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -365_972);
_assertPred!"=="(SysTime(DateTime(-1599, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -584_387);
_assertPred!"=="(SysTime(DateTime(-1600, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -584_388);
_assertPred!"=="(SysTime(DateTime(-1600, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -584_753);
_assertPred!"=="(SysTime(DateTime(-1601, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -585_118);
_assertPred!"=="(SysTime(DateTime(-1900, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -694_325);
_assertPred!"=="(SysTime(DateTime(-1901, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -694_690);
_assertPred!"=="(SysTime(DateTime(-1999, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -730_484);
_assertPred!"=="(SysTime(DateTime(-2000, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -730_485);
_assertPred!"=="(SysTime(DateTime(-2000, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -730_850);
_assertPred!"=="(SysTime(DateTime(-2001, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)).dayOfGregorianCal, -731_215);
_assertPred!"=="(SysTime(DateTime(-2010, 1, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_502);
_assertPred!"=="(SysTime(DateTime(-2010, 1, 31, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_472);
_assertPred!"=="(SysTime(DateTime(-2010, 2, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_471);
_assertPred!"=="(SysTime(DateTime(-2010, 2, 28, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_444);
_assertPred!"=="(SysTime(DateTime(-2010, 3, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_443);
_assertPred!"=="(SysTime(DateTime(-2010, 3, 31, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_413);
_assertPred!"=="(SysTime(DateTime(-2010, 4, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_412);
_assertPred!"=="(SysTime(DateTime(-2010, 4, 30, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_383);
_assertPred!"=="(SysTime(DateTime(-2010, 5, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_382);
_assertPred!"=="(SysTime(DateTime(-2010, 5, 31, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_352);
_assertPred!"=="(SysTime(DateTime(-2010, 6, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_351);
_assertPred!"=="(SysTime(DateTime(-2010, 6, 30, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_322);
_assertPred!"=="(SysTime(DateTime(-2010, 7, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_321);
_assertPred!"=="(SysTime(DateTime(-2010, 7, 31, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_291);
_assertPred!"=="(SysTime(DateTime(-2010, 8, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_290);
_assertPred!"=="(SysTime(DateTime(-2010, 8, 31, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_260);
_assertPred!"=="(SysTime(DateTime(-2010, 9, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_259);
_assertPred!"=="(SysTime(DateTime(-2010, 9, 30, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_230);
_assertPred!"=="(SysTime(DateTime(-2010, 10, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_229);
_assertPred!"=="(SysTime(DateTime(-2010, 10, 31, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_199);
_assertPred!"=="(SysTime(DateTime(-2010, 11, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_198);
_assertPred!"=="(SysTime(DateTime(-2010, 11, 30, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_169);
_assertPred!"=="(SysTime(DateTime(-2010, 12, 1, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_168);
_assertPred!"=="(SysTime(DateTime(-2010, 12, 31, 23, 59, 59), FracSec.from!"msecs"(999)).dayOfGregorianCal, -734_138);
_assertPred!"=="(SysTime(DateTime(-2012, 2, 1, 0, 0, 0), FracSec.from!"msecs"(0)).dayOfGregorianCal, -735_202);
_assertPred!"=="(SysTime(DateTime(-2012, 2, 28, 0, 0, 0), FracSec.from!"msecs"(0)).dayOfGregorianCal, -735_175);
_assertPred!"=="(SysTime(DateTime(-2012, 2, 29, 0, 0, 0), FracSec.from!"msecs"(0)).dayOfGregorianCal, -735_174);
_assertPred!"=="(SysTime(DateTime(-2012, 3, 1, 0, 0, 0), FracSec.from!"msecs"(0)).dayOfGregorianCal, -735_173);
_assertPred!"=="(SysTime(DateTime(-3760, 9, 7, 0, 0, 0), FracSec.from!"msecs"(0)).dayOfGregorianCal, -1_373_427); //Start of Hebrew Calendar
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cst.dayOfGregorianCal));
//static assert(__traits(compiles, ist.dayOfGregorianCal));
//Verify Examples.
assert(SysTime(DateTime(1, 1, 1, 0, 0, 0)).dayOfGregorianCal == 1);
assert(SysTime(DateTime(1, 12, 31, 23, 59, 59)).dayOfGregorianCal == 365);
assert(SysTime(DateTime(2, 1, 1, 2, 2, 2)).dayOfGregorianCal == 366);
assert(SysTime(DateTime(0, 12, 31, 7, 7, 7)).dayOfGregorianCal == 0);
assert(SysTime(DateTime(0, 1, 1, 19, 30, 0)).dayOfGregorianCal == -365);
assert(SysTime(DateTime(-1, 12, 31, 4, 7, 0)).dayOfGregorianCal == -366);
assert(SysTime(DateTime(2000, 1, 1, 9, 30, 20)).dayOfGregorianCal == 730_120);
assert(SysTime(DateTime(2010, 12, 31, 15, 45, 50)).dayOfGregorianCal == 734_137);
}
}
//Test that the logic for the day of the Gregorian Calendar is consistent
//between Date and SysTime.
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(Date(1, 1, 1).dayOfGregorianCal, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(1, 1, 2).dayOfGregorianCal, SysTime(DateTime(1, 1, 2, 0, 0, 0), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(1, 2, 1).dayOfGregorianCal, SysTime(DateTime(1, 2, 1, 0, 0, 0), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(2, 1, 1).dayOfGregorianCal, SysTime(DateTime(2, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(3, 1, 1).dayOfGregorianCal, SysTime(DateTime(3, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(4, 1, 1).dayOfGregorianCal, SysTime(DateTime(4, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(5, 1, 1).dayOfGregorianCal, SysTime(DateTime(5, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(50, 1, 1).dayOfGregorianCal, SysTime(DateTime(50, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(97, 1, 1).dayOfGregorianCal, SysTime(DateTime(97, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(100, 1, 1).dayOfGregorianCal, SysTime(DateTime(100, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(101, 1, 1).dayOfGregorianCal, SysTime(DateTime(101, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(105, 1, 1).dayOfGregorianCal, SysTime(DateTime(105, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(200, 1, 1).dayOfGregorianCal, SysTime(DateTime(200, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(201, 1, 1).dayOfGregorianCal, SysTime(DateTime(201, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(300, 1, 1).dayOfGregorianCal, SysTime(DateTime(300, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(301, 1, 1).dayOfGregorianCal, SysTime(DateTime(301, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(400, 1, 1).dayOfGregorianCal, SysTime(DateTime(400, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(401, 1, 1).dayOfGregorianCal, SysTime(DateTime(401, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(500, 1, 1).dayOfGregorianCal, SysTime(DateTime(500, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(501, 1, 1).dayOfGregorianCal, SysTime(DateTime(501, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(1000, 1, 1).dayOfGregorianCal, SysTime(DateTime(1000, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(1001, 1, 1).dayOfGregorianCal, SysTime(DateTime(1001, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(1600, 1, 1).dayOfGregorianCal, SysTime(DateTime(1600, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(1601, 1, 1).dayOfGregorianCal, SysTime(DateTime(1601, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(1900, 1, 1).dayOfGregorianCal, SysTime(DateTime(1900, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(1901, 1, 1).dayOfGregorianCal, SysTime(DateTime(1901, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(1945, 11, 12).dayOfGregorianCal, SysTime(DateTime(1945, 11, 12, 0, 0, 0), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(1999, 1, 1).dayOfGregorianCal, SysTime(DateTime(1999, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(1999, 7, 6).dayOfGregorianCal, SysTime(DateTime(1999, 7, 6, 12, 13, 14), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(2000, 1, 1).dayOfGregorianCal, SysTime(DateTime(2000, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(2001, 1, 1).dayOfGregorianCal, SysTime(DateTime(2001, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 1, 1).dayOfGregorianCal, SysTime(DateTime(2010, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 1, 31).dayOfGregorianCal, SysTime(DateTime(2010, 1, 31, 23, 0, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 2, 1).dayOfGregorianCal, SysTime(DateTime(2010, 2, 1, 23, 59, 59), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 2, 28).dayOfGregorianCal, SysTime(DateTime(2010, 2, 28, 23, 59, 59), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 3, 1).dayOfGregorianCal, SysTime(DateTime(2010, 3, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 3, 31).dayOfGregorianCal, SysTime(DateTime(2010, 3, 31, 0, 0, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 4, 1).dayOfGregorianCal, SysTime(DateTime(2010, 4, 1, 0, 0, 0), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 4, 30).dayOfGregorianCal, SysTime(DateTime(2010, 4, 30, 0, 0, 0), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 5, 1).dayOfGregorianCal, SysTime(DateTime(2010, 5, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 5, 31).dayOfGregorianCal, SysTime(DateTime(2010, 5, 31, 12, 13, 14), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 6, 1).dayOfGregorianCal, SysTime(DateTime(2010, 6, 1, 12, 13, 14), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 6, 30).dayOfGregorianCal, SysTime(DateTime(2010, 6, 30, 12, 13, 14), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 7, 1).dayOfGregorianCal, SysTime(DateTime(2010, 7, 1, 12, 13, 14), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 7, 31).dayOfGregorianCal, SysTime(DateTime(2010, 7, 31, 23, 59, 59), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 8, 1).dayOfGregorianCal, SysTime(DateTime(2010, 8, 1, 23, 59, 59), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 8, 31).dayOfGregorianCal, SysTime(DateTime(2010, 8, 31, 23, 59, 59), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 9, 1).dayOfGregorianCal, SysTime(DateTime(2010, 9, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 9, 30).dayOfGregorianCal, SysTime(DateTime(2010, 9, 30, 12, 0, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 10, 1).dayOfGregorianCal, SysTime(DateTime(2010, 10, 1, 0, 12, 0), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 10, 31).dayOfGregorianCal, SysTime(DateTime(2010, 10, 31, 0, 0, 12), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 11, 1).dayOfGregorianCal, SysTime(DateTime(2010, 11, 1, 23, 0, 0), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 11, 30).dayOfGregorianCal, SysTime(DateTime(2010, 11, 30, 0, 59, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 12, 1).dayOfGregorianCal, SysTime(DateTime(2010, 12, 1, 0, 0, 59), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(2010, 12, 31).dayOfGregorianCal, SysTime(DateTime(2010, 12, 31, 0, 59, 59), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(2012, 2, 1).dayOfGregorianCal, SysTime(DateTime(2012, 2, 1, 23, 0, 59), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(2012, 2, 28).dayOfGregorianCal, SysTime(DateTime(2012, 2, 28, 23, 59, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(2012, 2, 29).dayOfGregorianCal, SysTime(DateTime(2012, 2, 29, 7, 7, 7), FracSec.from!"hnsecs"(7)).dayOfGregorianCal);
_assertPred!"=="(Date(2012, 3, 1).dayOfGregorianCal, SysTime(DateTime(2012, 3, 1, 7, 7, 7), FracSec.from!"hnsecs"(7)).dayOfGregorianCal);
//Test B.C.
_assertPred!"=="(Date(0, 12, 31).dayOfGregorianCal, SysTime(DateTime(0, 12, 31, 0, 0, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(0, 12, 30).dayOfGregorianCal, SysTime(DateTime(0, 12, 30, 0, 0, 0), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(0, 12, 1).dayOfGregorianCal, SysTime(DateTime(0, 12, 1, 0, 0, 0), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(0, 11, 30).dayOfGregorianCal, SysTime(DateTime(0, 11, 30, 0, 0, 0), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(-1, 12, 31).dayOfGregorianCal, SysTime(DateTime(-1, 12, 31, 12, 13, 14), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(-1, 12, 30).dayOfGregorianCal, SysTime(DateTime(-1, 12, 30, 12, 13, 14), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(-1, 1, 1).dayOfGregorianCal, SysTime(DateTime(-1, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(-2, 12, 31).dayOfGregorianCal, SysTime(DateTime(-2, 12, 31, 12, 13, 14), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(-2, 1, 1).dayOfGregorianCal, SysTime(DateTime(-2, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(-3, 12, 31).dayOfGregorianCal, SysTime(DateTime(-3, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(-3, 1, 1).dayOfGregorianCal, SysTime(DateTime(-3, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(-4, 12, 31).dayOfGregorianCal, SysTime(DateTime(-4, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(-4, 1, 1).dayOfGregorianCal, SysTime(DateTime(-4, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(-5, 12, 31).dayOfGregorianCal, SysTime(DateTime(-5, 12, 31, 0, 0, 0), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(-5, 1, 1).dayOfGregorianCal, SysTime(DateTime(-5, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(-9, 1, 1).dayOfGregorianCal, SysTime(DateTime(-9, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(-49, 1, 1).dayOfGregorianCal, SysTime(DateTime(-49, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(-50, 1, 1).dayOfGregorianCal, SysTime(DateTime(-50, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(-97, 1, 1).dayOfGregorianCal, SysTime(DateTime(-97, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(-99, 12, 31).dayOfGregorianCal, SysTime(DateTime(-99, 12, 31, 12, 13, 14), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(-99, 1, 1).dayOfGregorianCal, SysTime(DateTime(-99, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(-100, 1, 1).dayOfGregorianCal, SysTime(DateTime(-100, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(-101, 1, 1).dayOfGregorianCal, SysTime(DateTime(-101, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(-105, 1, 1).dayOfGregorianCal, SysTime(DateTime(-105, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(-200, 1, 1).dayOfGregorianCal, SysTime(DateTime(-200, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(-201, 1, 1).dayOfGregorianCal, SysTime(DateTime(-201, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(-300, 1, 1).dayOfGregorianCal, SysTime(DateTime(-300, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(-301, 1, 1).dayOfGregorianCal, SysTime(DateTime(-301, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(-400, 12, 31).dayOfGregorianCal, SysTime(DateTime(-400, 12, 31, 12, 13, 14), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(-400, 1, 1).dayOfGregorianCal, SysTime(DateTime(-400, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(-401, 1, 1).dayOfGregorianCal, SysTime(DateTime(-401, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(-499, 1, 1).dayOfGregorianCal, SysTime(DateTime(-499, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(-500, 1, 1).dayOfGregorianCal, SysTime(DateTime(-500, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(-501, 1, 1).dayOfGregorianCal, SysTime(DateTime(-501, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(-1000, 1, 1).dayOfGregorianCal, SysTime(DateTime(-1000, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(-1001, 1, 1).dayOfGregorianCal, SysTime(DateTime(-1001, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(-1599, 1, 1).dayOfGregorianCal, SysTime(DateTime(-1599, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(-1600, 12, 31).dayOfGregorianCal, SysTime(DateTime(-1600, 12, 31, 0, 0, 0), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(-1600, 1, 1).dayOfGregorianCal, SysTime(DateTime(-1600, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(-1601, 1, 1).dayOfGregorianCal, SysTime(DateTime(-1601, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(-1900, 1, 1).dayOfGregorianCal, SysTime(DateTime(-1900, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(-1901, 1, 1).dayOfGregorianCal, SysTime(DateTime(-1901, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(-1999, 1, 1).dayOfGregorianCal, SysTime(DateTime(-1999, 1, 1, 12, 13, 14), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(-1999, 7, 6).dayOfGregorianCal, SysTime(DateTime(-1999, 7, 6, 12, 13, 14), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(-2000, 12, 31).dayOfGregorianCal, SysTime(DateTime(-2000, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(-2000, 1, 1).dayOfGregorianCal, SysTime(DateTime(-2000, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(-2001, 1, 1).dayOfGregorianCal, SysTime(DateTime(-2001, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 1, 1).dayOfGregorianCal, SysTime(DateTime(-2010, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 1, 31).dayOfGregorianCal, SysTime(DateTime(-2010, 1, 31, 0, 0, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 2, 1).dayOfGregorianCal, SysTime(DateTime(-2010, 2, 1, 0, 0, 0), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 2, 28).dayOfGregorianCal, SysTime(DateTime(-2010, 2, 28, 0, 0, 0), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 3, 1).dayOfGregorianCal, SysTime(DateTime(-2010, 3, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 3, 31).dayOfGregorianCal, SysTime(DateTime(-2010, 3, 31, 12, 13, 14), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 4, 1).dayOfGregorianCal, SysTime(DateTime(-2010, 4, 1, 12, 13, 14), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 4, 30).dayOfGregorianCal, SysTime(DateTime(-2010, 4, 30, 12, 13, 14), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 5, 1).dayOfGregorianCal, SysTime(DateTime(-2010, 5, 1, 12, 13, 14), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 5, 31).dayOfGregorianCal, SysTime(DateTime(-2010, 5, 31, 23, 59, 59), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 6, 1).dayOfGregorianCal, SysTime(DateTime(-2010, 6, 1, 23, 59, 59), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 6, 30).dayOfGregorianCal, SysTime(DateTime(-2010, 6, 30, 23, 59, 59), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 7, 1).dayOfGregorianCal, SysTime(DateTime(-2010, 7, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 7, 31).dayOfGregorianCal, SysTime(DateTime(-2010, 7, 31, 0, 0, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 8, 1).dayOfGregorianCal, SysTime(DateTime(-2010, 8, 1, 0, 0, 0), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 8, 31).dayOfGregorianCal, SysTime(DateTime(-2010, 8, 31, 0, 0, 0), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 9, 1).dayOfGregorianCal, SysTime(DateTime(-2010, 9, 1, 0, 0, 0), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 9, 30).dayOfGregorianCal, SysTime(DateTime(-2010, 9, 30, 12, 0, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 10, 1).dayOfGregorianCal, SysTime(DateTime(-2010, 10, 1, 0, 12, 0), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 10, 31).dayOfGregorianCal, SysTime(DateTime(-2010, 10, 31, 0, 0, 12), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 11, 1).dayOfGregorianCal, SysTime(DateTime(-2010, 11, 1, 23, 0, 0), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 11, 30).dayOfGregorianCal, SysTime(DateTime(-2010, 11, 30, 0, 59, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 12, 1).dayOfGregorianCal, SysTime(DateTime(-2010, 12, 1, 0, 0, 59), FracSec.from!"hnsecs"(500)).dayOfGregorianCal);
_assertPred!"=="(Date(-2010, 12, 31).dayOfGregorianCal, SysTime(DateTime(-2010, 12, 31, 0, 59, 59), FracSec.from!"hnsecs"(50_000)).dayOfGregorianCal);
_assertPred!"=="(Date(-2012, 2, 1).dayOfGregorianCal, SysTime(DateTime(-2012, 2, 1, 23, 0, 59), FracSec.from!"hnsecs"(9_999_999)).dayOfGregorianCal);
_assertPred!"=="(Date(-2012, 2, 28).dayOfGregorianCal, SysTime(DateTime(-2012, 2, 28, 23, 59, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
_assertPred!"=="(Date(-2012, 2, 29).dayOfGregorianCal, SysTime(DateTime(-2012, 2, 29, 7, 7, 7), FracSec.from!"hnsecs"(7)).dayOfGregorianCal);
_assertPred!"=="(Date(-2012, 3, 1).dayOfGregorianCal, SysTime(DateTime(-2012, 3, 1, 7, 7, 7), FracSec.from!"hnsecs"(7)).dayOfGregorianCal);
_assertPred!"=="(Date(-3760, 9, 7).dayOfGregorianCal, SysTime(DateTime(-3760, 9, 7, 0, 0, 0), FracSec.from!"hnsecs"(0)).dayOfGregorianCal);
}
}
/++
The Xth day of the Gregorian Calendar that this $(D SysTime) is on.
Setting this property does not affect the time portion of $(D SysTime).
Params:
days = The day of the Gregorian Calendar to set this $(D SysTime)
to.
Examples:
--------------------
auto st = SysTime(DateTime(0, 0, 0, 12, 0, 0));
st.dayOfGregorianCal = 1;
assert(st == SysTime(DateTime(1, 1, 1, 12, 0, 0)));
st.dayOfGregorianCal = 365;
assert(st == SysTime(DateTime(1, 12, 31, 12, 0, 0)));
st.dayOfGregorianCal = 366;
assert(st == SysTime(DateTime(2, 1, 1, 12, 0, 0)));
st.dayOfGregorianCal = 0;
assert(st == SysTime(DateTime(0, 12, 31, 12, 0, 0)));
st.dayOfGregorianCal = -365;
assert(st == SysTime(DateTime(-0, 1, 1, 12, 0, 0)));
st.dayOfGregorianCal = -366;
assert(st == SysTime(DateTime(-1, 12, 31, 12, 0, 0)));
st.dayOfGregorianCal = 730_120;
assert(st == SysTime(DateTime(2000, 1, 1, 12, 0, 0)));
st.dayOfGregorianCal = 734_137;
assert(st == SysTime(DateTime(2010, 12, 31, 12, 0, 0)));
--------------------
+/
@property void dayOfGregorianCal(int days) nothrow
{
auto hnsecs = adjTime;
hnsecs = removeUnitsFromHNSecs!"days"(hnsecs);
if(hnsecs < 0)
hnsecs += convert!("hours", "hnsecs")(24);
if(--days < 0)
{
hnsecs -= convert!("hours", "hnsecs")(24);
++days;
}
immutable newDaysHNSecs = convert!("days", "hnsecs")(days);
adjTime = newDaysHNSecs + hnsecs;
}
unittest
{
version(testStdDateTime)
{
void testST(SysTime orig, int day, in SysTime expected, size_t line = __LINE__)
{
orig.dayOfGregorianCal = day;
_assertPred!"=="(orig, expected, "", __FILE__, line);
}
//Test A.D.
testST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), 1, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
testST(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1)), 1, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1)));
testST(SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 1, SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
//Test B.C.
testST(SysTime(DateTime(0, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)), 0, SysTime(DateTime(0, 12, 31, 0, 0, 0), FracSec.from!"hnsecs"(0)));
testST(SysTime(DateTime(0, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 0, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
testST(SysTime(DateTime(0, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(1)), 0, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(1)));
testST(SysTime(DateTime(0, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(0)), 0, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(0)));
//Test Both.
testST(SysTime(DateTime(-512, 7, 20, 0, 0, 0), FracSec.from!"hnsecs"(0)), 1, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(0)));
testST(SysTime(DateTime(-513, 6, 6, 0, 0, 0), FracSec.from!"hnsecs"(1)), 1, SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1)));
testST(SysTime(DateTime(-511, 5, 7, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 1, SysTime(DateTime(1, 1, 1, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
testST(SysTime(DateTime(1607, 4, 8, 0, 0, 0), FracSec.from!"hnsecs"(0)), 0, SysTime(DateTime(0, 12, 31, 0, 0, 0), FracSec.from!"hnsecs"(0)));
testST(SysTime(DateTime(1500, 3, 9, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)), 0, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
testST(SysTime(DateTime(999, 2, 10, 23, 59, 59), FracSec.from!"hnsecs"(1)), 0, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(1)));
testST(SysTime(DateTime(2007, 12, 11, 23, 59, 59), FracSec.from!"hnsecs"(0)), 0, SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(0)));
auto sysTime = SysTime(DateTime(1, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212));
void testST2(int day, in SysTime expected, size_t line = __LINE__)
{
sysTime.dayOfGregorianCal = day;
_assertPred!"=="(sysTime, expected, "", __FILE__, line);
}
//Test A.D.
testST2(1, SysTime(DateTime(1, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(2, SysTime(DateTime(1, 1, 2, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(32, SysTime(DateTime(1, 2, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(366, SysTime(DateTime(2, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(731, SysTime(DateTime(3, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(1096, SysTime(DateTime(4, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(1462, SysTime(DateTime(5, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(17_898, SysTime(DateTime(50, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(35_065, SysTime(DateTime(97, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(36_160, SysTime(DateTime(100, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(36_525, SysTime(DateTime(101, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(37_986, SysTime(DateTime(105, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(72_684, SysTime(DateTime(200, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(73_049, SysTime(DateTime(201, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(109_208, SysTime(DateTime(300, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(109_573, SysTime(DateTime(301, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(145_732, SysTime(DateTime(400, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(146_098, SysTime(DateTime(401, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(182_257, SysTime(DateTime(500, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(182_622, SysTime(DateTime(501, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(364_878, SysTime(DateTime(1000, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(365_243, SysTime(DateTime(1001, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(584_023, SysTime(DateTime(1600, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(584_389, SysTime(DateTime(1601, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(693_596, SysTime(DateTime(1900, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(693_961, SysTime(DateTime(1901, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(729_755, SysTime(DateTime(1999, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(730_120, SysTime(DateTime(2000, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(730_486, SysTime(DateTime(2001, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(733_773, SysTime(DateTime(2010, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(733_803, SysTime(DateTime(2010, 1, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(733_804, SysTime(DateTime(2010, 2, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(733_831, SysTime(DateTime(2010, 2, 28, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(733_832, SysTime(DateTime(2010, 3, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(733_862, SysTime(DateTime(2010, 3, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(733_863, SysTime(DateTime(2010, 4, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(733_892, SysTime(DateTime(2010, 4, 30, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(733_893, SysTime(DateTime(2010, 5, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(733_923, SysTime(DateTime(2010, 5, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(733_924, SysTime(DateTime(2010, 6, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(733_953, SysTime(DateTime(2010, 6, 30, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(733_954, SysTime(DateTime(2010, 7, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(733_984, SysTime(DateTime(2010, 7, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(733_985, SysTime(DateTime(2010, 8, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(734_015, SysTime(DateTime(2010, 8, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(734_016, SysTime(DateTime(2010, 9, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(734_045, SysTime(DateTime(2010, 9, 30, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(734_046, SysTime(DateTime(2010, 10, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(734_076, SysTime(DateTime(2010, 10, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(734_077, SysTime(DateTime(2010, 11, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(734_106, SysTime(DateTime(2010, 11, 30, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(734_107, SysTime(DateTime(2010, 12, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(734_137, SysTime(DateTime(2010, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(734_534, SysTime(DateTime(2012, 2, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(734_561, SysTime(DateTime(2012, 2, 28, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(734_562, SysTime(DateTime(2012, 2, 29, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(734_563, SysTime(DateTime(2012, 3, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(734_534, SysTime(DateTime(2012, 2, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(734_561, SysTime(DateTime(2012, 2, 28, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(734_562, SysTime(DateTime(2012, 2, 29, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(734_563, SysTime(DateTime(2012, 3, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
//Test B.C.
testST2(0, SysTime(DateTime(0, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-1, SysTime(DateTime(0, 12, 30, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-30, SysTime(DateTime(0, 12, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-31, SysTime(DateTime(0, 11, 30, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-366, SysTime(DateTime(-1, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-367, SysTime(DateTime(-1, 12, 30, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-730, SysTime(DateTime(-1, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-731, SysTime(DateTime(-2, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-1095, SysTime(DateTime(-2, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-1096, SysTime(DateTime(-3, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-1460, SysTime(DateTime(-3, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-1461, SysTime(DateTime(-4, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-1826, SysTime(DateTime(-4, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-1827, SysTime(DateTime(-5, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-2191, SysTime(DateTime(-5, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-3652, SysTime(DateTime(-9, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-18_262, SysTime(DateTime(-49, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-18_627, SysTime(DateTime(-50, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-35_794, SysTime(DateTime(-97, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-36_160, SysTime(DateTime(-99, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-36_524, SysTime(DateTime(-99, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-36_889, SysTime(DateTime(-100, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-37_254, SysTime(DateTime(-101, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-38_715, SysTime(DateTime(-105, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-73_413, SysTime(DateTime(-200, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-73_778, SysTime(DateTime(-201, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-109_937, SysTime(DateTime(-300, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-110_302, SysTime(DateTime(-301, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-146_097, SysTime(DateTime(-400, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-146_462, SysTime(DateTime(-400, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-146_827, SysTime(DateTime(-401, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-182_621, SysTime(DateTime(-499, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-182_986, SysTime(DateTime(-500, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-183_351, SysTime(DateTime(-501, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-365_607, SysTime(DateTime(-1000, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-365_972, SysTime(DateTime(-1001, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-584_387, SysTime(DateTime(-1599, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-584_388, SysTime(DateTime(-1600, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-584_753, SysTime(DateTime(-1600, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-585_118, SysTime(DateTime(-1601, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-694_325, SysTime(DateTime(-1900, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-694_690, SysTime(DateTime(-1901, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-730_484, SysTime(DateTime(-1999, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-730_485, SysTime(DateTime(-2000, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-730_850, SysTime(DateTime(-2000, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-731_215, SysTime(DateTime(-2001, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_502, SysTime(DateTime(-2010, 1, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_472, SysTime(DateTime(-2010, 1, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_471, SysTime(DateTime(-2010, 2, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_444, SysTime(DateTime(-2010, 2, 28, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_443, SysTime(DateTime(-2010, 3, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_413, SysTime(DateTime(-2010, 3, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_412, SysTime(DateTime(-2010, 4, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_383, SysTime(DateTime(-2010, 4, 30, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_382, SysTime(DateTime(-2010, 5, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_352, SysTime(DateTime(-2010, 5, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_351, SysTime(DateTime(-2010, 6, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_322, SysTime(DateTime(-2010, 6, 30, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_321, SysTime(DateTime(-2010, 7, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_291, SysTime(DateTime(-2010, 7, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_290, SysTime(DateTime(-2010, 8, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_260, SysTime(DateTime(-2010, 8, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_259, SysTime(DateTime(-2010, 9, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_230, SysTime(DateTime(-2010, 9, 30, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_229, SysTime(DateTime(-2010, 10, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_199, SysTime(DateTime(-2010, 10, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_198, SysTime(DateTime(-2010, 11, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_169, SysTime(DateTime(-2010, 11, 30, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_168, SysTime(DateTime(-2010, 12, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-734_138, SysTime(DateTime(-2010, 12, 31, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-735_202, SysTime(DateTime(-2012, 2, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-735_175, SysTime(DateTime(-2012, 2, 28, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-735_174, SysTime(DateTime(-2012, 2, 29, 12, 2, 9), FracSec.from!"msecs"(212)));
testST2(-735_173, SysTime(DateTime(-2012, 3, 1, 12, 2, 9), FracSec.from!"msecs"(212)));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(!__traits(compiles, cst.dayOfGregorianCal = 7));
//static assert(!__traits(compiles, ist.dayOfGregorianCal = 7));
//Verify Examples.
auto st = SysTime(DateTime(0, 1, 1, 12, 0, 0));
st.dayOfGregorianCal = 1;
assert(st == SysTime(DateTime(1, 1, 1, 12, 0, 0)));
st.dayOfGregorianCal = 365;
assert(st == SysTime(DateTime(1, 12, 31, 12, 0, 0)));
st.dayOfGregorianCal = 366;
assert(st == SysTime(DateTime(2, 1, 1, 12, 0, 0)));
st.dayOfGregorianCal = 0;
assert(st == SysTime(DateTime(0, 12, 31, 12, 0, 0)));
st.dayOfGregorianCal = -365;
assert(st == SysTime(DateTime(-0, 1, 1, 12, 0, 0)));
st.dayOfGregorianCal = -366;
assert(st == SysTime(DateTime(-1, 12, 31, 12, 0, 0)));
st.dayOfGregorianCal = 730_120;
assert(st == SysTime(DateTime(2000, 1, 1, 12, 0, 0)));
st.dayOfGregorianCal = 734_137;
assert(st == SysTime(DateTime(2010, 12, 31, 12, 0, 0)));
}
}
/++
The ISO 8601 week of the year that this $(D SysTime) is in.
See_Also:
$(WEB en.wikipedia.org/wiki/ISO_week_date, ISO Week Date).
+/
@property ubyte isoWeek() const nothrow
{
return (cast(Date)this).isoWeek;
}
unittest
{
version(testStdDateTime)
{
auto st = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, st.isoWeek));
static assert(__traits(compiles, cst.isoWeek));
//static assert(__traits(compiles, ist.isoWeek));
}
}
/++
$(D SysTime) for the last day in the month that this Date is in.
The time portion of endOfMonth is always 23:59:59.9999999.
Examples:
--------------------
assert(SysTime(DateTime(1999, 1, 6, 0, 0, 0)).endOfMonth ==
SysTime(DateTime(1999, 1, 31, 23, 59, 59),
FracSec.from!"hnsecs"(9_999_999)));
assert(SysTime(DateTime(1999, 2, 7, 19, 30, 0),
FracSec.from!"msecs"(24)).endOfMonth ==
SysTime(DateTime(1999, 2, 28, 23, 59, 59),
FracSec.from!"hnsecs"(9_999_999)));
assert(SysTime(DateTime(2000, 2, 7, 5, 12, 27),
FracSec.from!"usecs"(5203)).endOfMonth ==
SysTime(DateTime(2000, 2, 29, 23, 59, 59),
FracSec.from!"hnsecs"(9_999_999)));
assert(SysTime(DateTime(2000, 6, 4, 12, 22, 9),
FracSec.from!"hnsecs"(12345)).endOfMonth ==
SysTime(DateTime(2000, 6, 30, 23, 59, 59),
FracSec.from!"hnsecs"(9_999_999)));
--------------------
+/
@property SysTime endOfMonth() const nothrow
{
immutable hnsecs = adjTime;
immutable days = getUnitsFromHNSecs!"days"(hnsecs);
auto date = Date(cast(int)days + 1).endOfMonth;
auto newDays = date.dayOfGregorianCal - 1;
long theTimeHNSecs;
if(newDays < 0)
{
theTimeHNSecs = -1;
++newDays;
}
else
theTimeHNSecs = convert!("days", "hnsecs")(1) - 1;
immutable newDaysHNSecs = convert!("days", "hnsecs")(newDays);
auto retval = SysTime(this._stdTime, this._timezone);
retval.adjTime = newDaysHNSecs + theTimeHNSecs;
return retval;
}
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(SysTime(Date(1999, 1, 1)).endOfMonth, SysTime(DateTime(1999, 1, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(1999, 2, 1)).endOfMonth, SysTime(DateTime(1999, 2, 28, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(2000, 2, 1)).endOfMonth, SysTime(DateTime(2000, 2, 29, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(1999, 3, 1)).endOfMonth, SysTime(DateTime(1999, 3, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(1999, 4, 1)).endOfMonth, SysTime(DateTime(1999, 4, 30, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(1999, 5, 1)).endOfMonth, SysTime(DateTime(1999, 5, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(1999, 6, 1)).endOfMonth, SysTime(DateTime(1999, 6, 30, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(1999, 7, 1)).endOfMonth, SysTime(DateTime(1999, 7, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(1999, 8, 1)).endOfMonth, SysTime(DateTime(1999, 8, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(1999, 9, 1)).endOfMonth, SysTime(DateTime(1999, 9, 30, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(1999, 10, 1)).endOfMonth, SysTime(DateTime(1999, 10, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(1999, 11, 1)).endOfMonth, SysTime(DateTime(1999, 11, 30, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(1999, 12, 1)).endOfMonth, SysTime(DateTime(1999, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
//Test B.C.
_assertPred!"=="(SysTime(Date(-1999, 1, 1)).endOfMonth, SysTime(DateTime(-1999, 1, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(-1999, 2, 1)).endOfMonth, SysTime(DateTime(-1999, 2, 28, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(-2000, 2, 1)).endOfMonth, SysTime(DateTime(-2000, 2, 29, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(-1999, 3, 1)).endOfMonth, SysTime(DateTime(-1999, 3, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(-1999, 4, 1)).endOfMonth, SysTime(DateTime(-1999, 4, 30, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(-1999, 5, 1)).endOfMonth, SysTime(DateTime(-1999, 5, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(-1999, 6, 1)).endOfMonth, SysTime(DateTime(-1999, 6, 30, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(-1999, 7, 1)).endOfMonth, SysTime(DateTime(-1999, 7, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(-1999, 8, 1)).endOfMonth, SysTime(DateTime(-1999, 8, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(-1999, 9, 1)).endOfMonth, SysTime(DateTime(-1999, 9, 30, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(-1999, 10, 1)).endOfMonth, SysTime(DateTime(-1999, 10, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(-1999, 11, 1)).endOfMonth, SysTime(DateTime(-1999, 11, 30, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
_assertPred!"=="(SysTime(Date(-1999, 12, 1)).endOfMonth, SysTime(DateTime(-1999, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cst.endOfMonth));
//static assert(__traits(compiles, ist.endOfMonth));
//Verify Examples.
assert(SysTime(DateTime(1999, 1, 6, 0, 0, 0)).endOfMonth == SysTime(DateTime(1999, 1, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
assert(SysTime(DateTime(1999, 2, 7, 19, 30, 0), FracSec.from!"msecs"(24)).endOfMonth == SysTime(DateTime(1999, 2, 28, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
assert(SysTime(DateTime(2000, 2, 7, 5, 12, 27), FracSec.from!"usecs"(5203)).endOfMonth == SysTime(DateTime(2000, 2, 29, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
assert(SysTime(DateTime(2000, 6, 4, 12, 22, 9), FracSec.from!"hnsecs"(12345)).endOfMonth == SysTime(DateTime(2000, 6, 30, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999)));
}
}
/++
The last day in the month that this $(D SysTime) is in.
Examples:
--------------------
assert(SysTime(DateTime(1999, 1, 6, 0, 0, 0)).daysInMonth == 31);
assert(SysTime(DateTime(1999, 2, 7, 19, 30, 0)).daysInMonth == 28);
assert(SysTime(DateTime(2000, 2, 7, 5, 12, 27)).daysInMonth == 29);
assert(SysTime(DateTime(2000, 6, 4, 12, 22, 9)).daysInMonth == 30);
--------------------
+/
@property ubyte daysInMonth() const nothrow
{
return Date(dayOfGregorianCal).daysInMonth;
}
/++
$(RED Scheduled for deprecation in January 2012.
Please use daysInMonth instead.)
+/
alias daysInMonth endofMonthDay;
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(SysTime(DateTime(1999, 1, 1, 12, 1, 13)).daysInMonth, 31);
_assertPred!"=="(SysTime(DateTime(1999, 2, 1, 17, 13, 12)).daysInMonth, 28);
_assertPred!"=="(SysTime(DateTime(2000, 2, 1, 13, 2, 12)).daysInMonth, 29);
_assertPred!"=="(SysTime(DateTime(1999, 3, 1, 12, 13, 12)).daysInMonth, 31);
_assertPred!"=="(SysTime(DateTime(1999, 4, 1, 12, 6, 13)).daysInMonth, 30);
_assertPred!"=="(SysTime(DateTime(1999, 5, 1, 15, 13, 12)).daysInMonth, 31);
_assertPred!"=="(SysTime(DateTime(1999, 6, 1, 13, 7, 12)).daysInMonth, 30);
_assertPred!"=="(SysTime(DateTime(1999, 7, 1, 12, 13, 17)).daysInMonth, 31);
_assertPred!"=="(SysTime(DateTime(1999, 8, 1, 12, 3, 13)).daysInMonth, 31);
_assertPred!"=="(SysTime(DateTime(1999, 9, 1, 12, 13, 12)).daysInMonth, 30);
_assertPred!"=="(SysTime(DateTime(1999, 10, 1, 13, 19, 12)).daysInMonth, 31);
_assertPred!"=="(SysTime(DateTime(1999, 11, 1, 12, 13, 17)).daysInMonth, 30);
_assertPred!"=="(SysTime(DateTime(1999, 12, 1, 12, 52, 13)).daysInMonth, 31);
//Test B.C.
_assertPred!"=="(SysTime(DateTime(-1999, 1, 1, 12, 1, 13)).daysInMonth, 31);
_assertPred!"=="(SysTime(DateTime(-1999, 2, 1, 7, 13, 12)).daysInMonth, 28);
_assertPred!"=="(SysTime(DateTime(-2000, 2, 1, 13, 2, 12)).daysInMonth, 29);
_assertPred!"=="(SysTime(DateTime(-1999, 3, 1, 12, 13, 12)).daysInMonth, 31);
_assertPred!"=="(SysTime(DateTime(-1999, 4, 1, 12, 6, 13)).daysInMonth, 30);
_assertPred!"=="(SysTime(DateTime(-1999, 5, 1, 5, 13, 12)).daysInMonth, 31);
_assertPred!"=="(SysTime(DateTime(-1999, 6, 1, 13, 7, 12)).daysInMonth, 30);
_assertPred!"=="(SysTime(DateTime(-1999, 7, 1, 12, 13, 17)).daysInMonth, 31);
_assertPred!"=="(SysTime(DateTime(-1999, 8, 1, 12, 3, 13)).daysInMonth, 31);
_assertPred!"=="(SysTime(DateTime(-1999, 9, 1, 12, 13, 12)).daysInMonth, 30);
_assertPred!"=="(SysTime(DateTime(-1999, 10, 1, 13, 19, 12)).daysInMonth, 31);
_assertPred!"=="(SysTime(DateTime(-1999, 11, 1, 12, 13, 17)).daysInMonth, 30);
_assertPred!"=="(SysTime(DateTime(-1999, 12, 1, 12, 52, 13)).daysInMonth, 31);
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cst.daysInMonth));
//static assert(__traits(compiles, ist.daysInMonth));
//Verify Examples.
assert(SysTime(DateTime(1999, 1, 6, 0, 0, 0)).daysInMonth == 31);
assert(SysTime(DateTime(1999, 2, 7, 19, 30, 0)).daysInMonth == 28);
assert(SysTime(DateTime(2000, 2, 7, 5, 12, 27)).daysInMonth == 29);
assert(SysTime(DateTime(2000, 6, 4, 12, 22, 9)).daysInMonth == 30);
}
}
/++
Whether the current year is a date in A.D.
Examples:
--------------------
assert(SysTime(DateTime(1, 1, 1, 12, 7, 0)).isAD);
assert(SysTime(DateTime(2010, 12, 31, 0, 0, 0)).isAD);
assert(!SysTime(DateTime(0, 12, 31, 23, 59, 59)).isAD);
assert(!SysTime(DateTime(-2010, 1, 1, 2, 2, 2)).isAD);
--------------------
+/
@property bool isAD() const nothrow
{
return adjTime >= 0;
}
unittest
{
version(testStdDateTime)
{
assert(SysTime(DateTime(2010, 7, 4, 12, 0, 9)).isAD);
assert(SysTime(DateTime(1, 1, 1, 0, 0, 0)).isAD);
assert(!SysTime(DateTime(0, 12, 31, 23, 59, 59)).isAD);
assert(!SysTime(DateTime(0, 1, 1, 23, 59, 59)).isAD);
assert(!SysTime(DateTime(-1, 1, 1, 23 ,59 ,59)).isAD);
assert(!SysTime(DateTime(-2010, 7, 4, 12, 2, 2)).isAD);
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cst.isAD));
//static assert(__traits(compiles, ist.isAD));
//Verify Examples.
assert(SysTime(DateTime(1, 1, 1, 12, 7, 0)).isAD);
assert(SysTime(DateTime(2010, 12, 31, 0, 0, 0)).isAD);
assert(!SysTime(DateTime(0, 12, 31, 23, 59, 59)).isAD);
assert(!SysTime(DateTime(-2010, 1, 1, 2, 2, 2)).isAD);
}
}
/++
The julian day for this $(D SysTime) at the given time. For example,
prior to noon, 1996-03-31 would be the julian day number 2_450_173, so
this function returns 2_450_173, while from noon onward, the julian
day number would be 2_450_174, so this function returns 2_450_174.
+/
@property long julianDay() const nothrow
{
immutable jd = dayOfGregorianCal + 1_721_425;
return hour < 12 ? jd - 1 : jd;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(SysTime(DateTime(-4713, 11, 24, 0, 0, 0)).julianDay, -1);
_assertPred!"=="(SysTime(DateTime(-4713, 11, 24, 12, 0, 0)).julianDay, 0);
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 0, 0, 0)).julianDay, 1_721_424);
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 12, 0, 0)).julianDay, 1_721_425);
_assertPred!"=="(SysTime(DateTime(1, 1, 1, 0, 0, 0)).julianDay, 1_721_425);
_assertPred!"=="(SysTime(DateTime(1, 1, 1, 12, 0, 0)).julianDay, 1_721_426);
_assertPred!"=="(SysTime(DateTime(1582, 10, 15, 0, 0, 0)).julianDay, 2_299_160);
_assertPred!"=="(SysTime(DateTime(1582, 10, 15, 12, 0, 0)).julianDay, 2_299_161);
_assertPred!"=="(SysTime(DateTime(1858, 11, 17, 0, 0, 0)).julianDay, 2_400_000);
_assertPred!"=="(SysTime(DateTime(1858, 11, 17, 12, 0, 0)).julianDay, 2_400_001);
_assertPred!"=="(SysTime(DateTime(1982, 1, 4, 0, 0, 0)).julianDay, 2_444_973);
_assertPred!"=="(SysTime(DateTime(1982, 1, 4, 12, 0, 0)).julianDay, 2_444_974);
_assertPred!"=="(SysTime(DateTime(1996, 3, 31, 0, 0, 0)).julianDay, 2_450_173);
_assertPred!"=="(SysTime(DateTime(1996, 3, 31, 12, 0, 0)).julianDay, 2_450_174);
_assertPred!"=="(SysTime(DateTime(2010, 8, 24, 0, 0, 0)).julianDay, 2_455_432);
_assertPred!"=="(SysTime(DateTime(2010, 8, 24, 12, 0, 0)).julianDay, 2_455_433);
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cst.julianDay));
//static assert(__traits(compiles, ist.julianDay));
}
}
/++
The modified julian day for any time on this date (since, the modified
julian day changes at midnight).
+/
@property long modJulianDay() const nothrow
{
return (dayOfGregorianCal + 1_721_425) - 2_400_001;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(SysTime(DateTime(1858, 11, 17, 0, 0, 0)).modJulianDay, 0);
_assertPred!"=="(SysTime(DateTime(1858, 11, 17, 12, 0, 0)).modJulianDay, 0);
_assertPred!"=="(SysTime(DateTime(2010, 8, 24, 0, 0, 0)).modJulianDay, 55_432);
_assertPred!"=="(SysTime(DateTime(2010, 8, 24, 12, 0, 0)).modJulianDay, 55_432);
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cst.modJulianDay));
//static assert(__traits(compiles, ist.modJulianDay));
}
}
/++
Returns a $(D Date) equivalent to this $(D SysTime).
+/
Date opCast(T)() const nothrow
if(is(Unqual!T == Date))
{
return Date(dayOfGregorianCal);
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(cast(Date)SysTime(Date(1999, 7, 6)), Date(1999, 7, 6));
_assertPred!"=="(cast(Date)SysTime(Date(2000, 12, 31)), Date(2000, 12, 31));
_assertPred!"=="(cast(Date)SysTime(Date(2001, 1, 1)), Date(2001, 1, 1));
_assertPred!"=="(cast(Date)SysTime(DateTime(1999, 7, 6, 12, 10, 9)), Date(1999, 7, 6));
_assertPred!"=="(cast(Date)SysTime(DateTime(2000, 12, 31, 13, 11, 10)), Date(2000, 12, 31));
_assertPred!"=="(cast(Date)SysTime(DateTime(2001, 1, 1, 14, 12, 11)), Date(2001, 1, 1));
_assertPred!"=="(cast(Date)SysTime(Date(-1999, 7, 6)), Date(-1999, 7, 6));
_assertPred!"=="(cast(Date)SysTime(Date(-2000, 12, 31)), Date(-2000, 12, 31));
_assertPred!"=="(cast(Date)SysTime(Date(-2001, 1, 1)), Date(-2001, 1, 1));
_assertPred!"=="(cast(Date)SysTime(DateTime(-1999, 7, 6, 12, 10, 9)), Date(-1999, 7, 6));
_assertPred!"=="(cast(Date)SysTime(DateTime(-2000, 12, 31, 13, 11, 10)), Date(-2000, 12, 31));
_assertPred!"=="(cast(Date)SysTime(DateTime(-2001, 1, 1, 14, 12, 11)), Date(-2001, 1, 1));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cast(Date)cst));
//static assert(__traits(compiles, cast(Date)ist));
}
}
/++
Returns a $(D DateTime) equivalent to this $(D SysTime).
+/
DateTime opCast(T)() const nothrow
if(is(Unqual!T == DateTime))
{
try
{
auto hnsecs = adjTime;
auto days = splitUnitsFromHNSecs!"days"(hnsecs) + 1;
if(hnsecs < 0)
{
hnsecs += convert!("hours", "hnsecs")(24);
--days;
}
immutable hour = splitUnitsFromHNSecs!"hours"(hnsecs);
immutable minute = splitUnitsFromHNSecs!"minutes"(hnsecs);
immutable second = getUnitsFromHNSecs!"seconds"(hnsecs);
return DateTime(Date(cast(int)days), TimeOfDay(cast(int)hour, cast(int)minute, cast(int)second));
}
catch(Exception e)
assert(0, "Either DateTime's constructor or TimeOfDay's constructor threw.");
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(cast(DateTime)SysTime(DateTime(1, 1, 6, 7, 12, 22)), DateTime(1, 1, 6, 7, 12, 22));
_assertPred!"=="(cast(DateTime)SysTime(DateTime(1, 1, 6, 7, 12, 22), FracSec.from!"msecs"(22)), DateTime(1, 1, 6, 7, 12, 22));
_assertPred!"=="(cast(DateTime)SysTime(Date(1999, 7, 6)), DateTime(1999, 7, 6, 0, 0, 0));
_assertPred!"=="(cast(DateTime)SysTime(Date(2000, 12, 31)), DateTime(2000, 12, 31, 0, 0, 0));
_assertPred!"=="(cast(DateTime)SysTime(Date(2001, 1, 1)), DateTime(2001, 1, 1, 0, 0, 0));
_assertPred!"=="(cast(DateTime)SysTime(DateTime(1999, 7, 6, 12, 10, 9)), DateTime(1999, 7, 6, 12, 10, 9));
_assertPred!"=="(cast(DateTime)SysTime(DateTime(2000, 12, 31, 13, 11, 10)), DateTime(2000, 12, 31, 13, 11, 10));
_assertPred!"=="(cast(DateTime)SysTime(DateTime(2001, 1, 1, 14, 12, 11)), DateTime(2001, 1, 1, 14, 12, 11));
_assertPred!"=="(cast(DateTime)SysTime(DateTime(-1, 1, 6, 7, 12, 22)), DateTime(-1, 1, 6, 7, 12, 22));
_assertPred!"=="(cast(DateTime)SysTime(DateTime(-1, 1, 6, 7, 12, 22), FracSec.from!"msecs"(22)), DateTime(-1, 1, 6, 7, 12, 22));
_assertPred!"=="(cast(DateTime)SysTime(Date(-1999, 7, 6)), DateTime(-1999, 7, 6, 0, 0, 0));
_assertPred!"=="(cast(DateTime)SysTime(Date(-2000, 12, 31)), DateTime(-2000, 12, 31, 0, 0, 0));
_assertPred!"=="(cast(DateTime)SysTime(Date(-2001, 1, 1)), DateTime(-2001, 1, 1, 0, 0, 0));
_assertPred!"=="(cast(DateTime)SysTime(DateTime(-1999, 7, 6, 12, 10, 9)), DateTime(-1999, 7, 6, 12, 10, 9));
_assertPred!"=="(cast(DateTime)SysTime(DateTime(-2000, 12, 31, 13, 11, 10)), DateTime(-2000, 12, 31, 13, 11, 10));
_assertPred!"=="(cast(DateTime)SysTime(DateTime(-2001, 1, 1, 14, 12, 11)), DateTime(-2001, 1, 1, 14, 12, 11));
_assertPred!"=="(cast(DateTime)SysTime(DateTime(2011, 1, 13, 8, 17, 2), FracSec.from!"msecs"(296), LocalTime()),
DateTime(2011, 1, 13, 8, 17, 2));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cast(DateTime)cst));
//static assert(__traits(compiles, cast(DateTime)ist));
}
}
/++
Returns a $(D TimeOfDay) equivalent to this $(D SysTime).
+/
TimeOfDay opCast(T)() const nothrow
if(is(Unqual!T == TimeOfDay))
{
try
{
auto hnsecs = adjTime;
hnsecs = removeUnitsFromHNSecs!"days"(hnsecs);
if(hnsecs < 0)
hnsecs += convert!("hours", "hnsecs")(24);
immutable hour = splitUnitsFromHNSecs!"hours"(hnsecs);
immutable minute = splitUnitsFromHNSecs!"minutes"(hnsecs);
immutable second = getUnitsFromHNSecs!"seconds"(hnsecs);
return TimeOfDay(cast(int)hour, cast(int)minute, cast(int)second);
}
catch(Exception e)
assert(0, "TimeOfDay's constructor threw.");
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(cast(TimeOfDay)SysTime(Date(1999, 7, 6)), TimeOfDay(0, 0, 0));
_assertPred!"=="(cast(TimeOfDay)SysTime(Date(2000, 12, 31)), TimeOfDay(0, 0, 0));
_assertPred!"=="(cast(TimeOfDay)SysTime(Date(2001, 1, 1)), TimeOfDay(0, 0, 0));
_assertPred!"=="(cast(TimeOfDay)SysTime(DateTime(1999, 7, 6, 12, 10, 9)), TimeOfDay(12, 10, 9));
_assertPred!"=="(cast(TimeOfDay)SysTime(DateTime(2000, 12, 31, 13, 11, 10)), TimeOfDay(13, 11, 10));
_assertPred!"=="(cast(TimeOfDay)SysTime(DateTime(2001, 1, 1, 14, 12, 11)), TimeOfDay(14, 12, 11));
_assertPred!"=="(cast(TimeOfDay)SysTime(Date(-1999, 7, 6)), TimeOfDay(0, 0, 0));
_assertPred!"=="(cast(TimeOfDay)SysTime(Date(-2000, 12, 31)), TimeOfDay(0, 0, 0));
_assertPred!"=="(cast(TimeOfDay)SysTime(Date(-2001, 1, 1)), TimeOfDay(0, 0, 0));
_assertPred!"=="(cast(TimeOfDay)SysTime(DateTime(-1999, 7, 6, 12, 10, 9)), TimeOfDay(12, 10, 9));
_assertPred!"=="(cast(TimeOfDay)SysTime(DateTime(-2000, 12, 31, 13, 11, 10)), TimeOfDay(13, 11, 10));
_assertPred!"=="(cast(TimeOfDay)SysTime(DateTime(-2001, 1, 1, 14, 12, 11)), TimeOfDay(14, 12, 11));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cast(TimeOfDay)cst));
//static assert(__traits(compiles, cast(TimeOfDay)ist));
}
}
//Temporary hack until bug http://d.puremagic.com/issues/show_bug.cgi?id=4867 is fixed.
//This allows assignment from const(SysTime) to SysTime.
//It may be a good idea to keep it though, since casting from a type to itself
//should be allowed, and it doesn't work without this opCast() since opCast()
//has already been defined for other types.
SysTime opCast(T)() const pure nothrow
if(is(Unqual!T == SysTime))
{
return SysTime(_stdTime, _timezone);
}
/++
Converts this $(D SysTime) to a string with the format
YYYYMMDDTHHMMSS.FFFFFFFTZ (where F is fractional seconds and TZ is time
zone).
Note that the number of digits in the fractional seconds varies with the
number of fractional seconds. It's a maximum of 7 (which would be
hnsecs), but only has as many as are necessary to hold the correct value
(so no trailing zeroes), and if there are no fractional seconds, then
there is no decimal point.
If this $(D SysTime)'s time zone is $(D LocalTime), then TZ is empty.
If its time zone is $(D UTC), then it is "Z". Otherwise, it is the
offset from UTC (e.g. +1:00 or -7:00). Note that the offset from UTC
is $(I not) enough to uniquely identify the time zone.
Time zone offsets will be in the form +HH:MM or -HH:MM.
Examples:
--------------------
assert(SysTime(DateTime(2010, 7, 4, 7, 6, 12)).toISOString() ==
"20100704T070612");
assert(SysTime(DateTime(1998, 12, 25, 2, 15, 0),
FracSec.from!"msecs"(24)).toISOString() ==
"19981225T021500.024");
assert(SysTime(DateTime(0, 1, 5, 23, 9, 59)).toISOString() ==
"00000105T230959");
assert(SysTime(DateTime(-4, 1, 5, 0, 0, 2),
FracSec.from!"hnsecs"(520_920)).toISOString() ==
"-00040105T000002.052092");
--------------------
+/
string toISOString() const nothrow
{
try
{
immutable adjustedTime = adjTime;
long hnsecs = adjustedTime;
auto days = splitUnitsFromHNSecs!"days"(hnsecs) + 1;
if(hnsecs < 0)
{
hnsecs += convert!("hours", "hnsecs")(24);
--days;
}
auto hour = splitUnitsFromHNSecs!"hours"(hnsecs);
auto minute = splitUnitsFromHNSecs!"minutes"(hnsecs);
auto second = splitUnitsFromHNSecs!"seconds"(hnsecs);
auto dateTime = DateTime(Date(cast(int)days), TimeOfDay(cast(int)hour, cast(int)minute, cast(int)second));
auto fracSecStr = fracSecToISOString(cast(int)hnsecs);
if(_timezone is LocalTime())
return dateTime.toISOString() ~ fracSecToISOString(cast(int)hnsecs);
if(_timezone is UTC())
return dateTime.toISOString() ~ fracSecToISOString(cast(int)hnsecs) ~ "Z";
immutable utcOffset = cast(int)convert!("hnsecs", "minutes")(adjustedTime - stdTime);
return dateTime.toISOString() ~ fracSecToISOString(cast(int)hnsecs) ~ SimpleTimeZone.toISOString(utcOffset);
}
catch(Exception e)
assert(0, "format() threw.");
}
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(SysTime(DateTime.init, UTC()).toISOString(), "00010101T000000Z");
_assertPred!"=="(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1), UTC()).toISOString(), "00010101T000000.0000001Z");
_assertPred!"=="(SysTime(DateTime(9, 12, 4, 0, 0, 0)).toISOString(), "00091204T000000");
_assertPred!"=="(SysTime(DateTime(99, 12, 4, 5, 6, 12)).toISOString(), "00991204T050612");
_assertPred!"=="(SysTime(DateTime(999, 12, 4, 13, 44, 59)).toISOString(), "09991204T134459");
_assertPred!"=="(SysTime(DateTime(9999, 7, 4, 23, 59, 59)).toISOString(), "99990704T235959");
_assertPred!"=="(SysTime(DateTime(10000, 10, 20, 1, 1, 1)).toISOString(), "+100001020T010101");
_assertPred!"=="(SysTime(DateTime(9, 12, 4, 0, 0, 0), FracSec.from!"msecs"(42)).toISOString(), "00091204T000000.042");
_assertPred!"=="(SysTime(DateTime(99, 12, 4, 5, 6, 12), FracSec.from!"msecs"(100)).toISOString(), "00991204T050612.1");
_assertPred!"=="(SysTime(DateTime(999, 12, 4, 13, 44, 59), FracSec.from!"usecs"(45020)).toISOString(), "09991204T134459.04502");
_assertPred!"=="(SysTime(DateTime(9999, 7, 4, 23, 59, 59), FracSec.from!"hnsecs"(12)).toISOString(), "99990704T235959.0000012");
_assertPred!"=="(SysTime(DateTime(10000, 10, 20, 1, 1, 1), FracSec.from!"hnsecs"(507890)).toISOString(), "+100001020T010101.050789");
_assertPred!"=="(SysTime(DateTime(2012, 12, 21, 12, 12, 12),
new SimpleTimeZone(-360)).toISOString(),
"20121221T121212-06:00");
_assertPred!"=="(SysTime(DateTime(2012, 12, 21, 12, 12, 12),
new SimpleTimeZone(420)).toISOString(),
"20121221T121212+07:00");
//Test B.C.
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999), UTC()).toISOString(), "00001231T235959.9999999Z");
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(1), UTC()).toISOString(), "00001231T235959.0000001Z");
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 23, 59, 59), UTC()).toISOString(), "00001231T235959Z");
_assertPred!"=="(SysTime(DateTime(0, 12, 4, 0, 12, 4)).toISOString(), "00001204T001204");
_assertPred!"=="(SysTime(DateTime(-9, 12, 4, 0, 0, 0)).toISOString(), "-00091204T000000");
_assertPred!"=="(SysTime(DateTime(-99, 12, 4, 5, 6, 12)).toISOString(), "-00991204T050612");
_assertPred!"=="(SysTime(DateTime(-999, 12, 4, 13, 44, 59)).toISOString(), "-09991204T134459");
_assertPred!"=="(SysTime(DateTime(-9999, 7, 4, 23, 59, 59)).toISOString(), "-99990704T235959");
_assertPred!"=="(SysTime(DateTime(-10000, 10, 20, 1, 1, 1)).toISOString(), "-100001020T010101");
_assertPred!"=="(SysTime(DateTime(0, 12, 4, 0, 0, 0), FracSec.from!"msecs"(7)).toISOString(), "00001204T000000.007");
_assertPred!"=="(SysTime(DateTime(-9, 12, 4, 0, 0, 0), FracSec.from!"msecs"(42)).toISOString(), "-00091204T000000.042");
_assertPred!"=="(SysTime(DateTime(-99, 12, 4, 5, 6, 12), FracSec.from!"msecs"(100)).toISOString(), "-00991204T050612.1");
_assertPred!"=="(SysTime(DateTime(-999, 12, 4, 13, 44, 59), FracSec.from!"usecs"(45020)).toISOString(), "-09991204T134459.04502");
_assertPred!"=="(SysTime(DateTime(-9999, 7, 4, 23, 59, 59), FracSec.from!"hnsecs"(12)).toISOString(), "-99990704T235959.0000012");
_assertPred!"=="(SysTime(DateTime(-10000, 10, 20, 1, 1, 1), FracSec.from!"hnsecs"(507890)).toISOString(), "-100001020T010101.050789");
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cast(TimeOfDay)cst));
//static assert(__traits(compiles, cast(TimeOfDay)ist));
//Verify Examples.
assert(SysTime(DateTime(2010, 7, 4, 7, 6, 12)).toISOString() ==
"20100704T070612");
assert(SysTime(DateTime(1998, 12, 25, 2, 15, 0),
FracSec.from!"msecs"(24)).toISOString() ==
"19981225T021500.024");
assert(SysTime(DateTime(0, 1, 5, 23, 9, 59)).toISOString() ==
"00000105T230959");
assert(SysTime(DateTime(-4, 1, 5, 0, 0, 2),
FracSec.from!"hnsecs"(520_920)).toISOString() ==
"-00040105T000002.052092");
}
}
/++
Converts this $(D SysTime) to a string with the format
YYYY-MM-DDTHH:MM:SS.FFFFFFFTZ (where F is fractional seconds and TZ
is the time zone).
Note that the number of digits in the fractional seconds varies with the
number of fractional seconds. It's a maximum of 7 (which would be
hnsecs), but only has as many as are necessary to hold the correct value
(so no trailing zeroes), and if there are no fractional seconds, then
there is no decimal point.
If this $(D SysTime)'s time zone is $(D LocalTime), then TZ is empty. If
its time zone is $(D UTC), then it is "Z". Otherwise, it is the offset
from UTC (e.g. +1:00 or -7:00). Note that the offset from UTC is
$(I not) enough to uniquely identify the time zone.
Time zone offsets will be in the form +HH:MM or -HH:MM.
Examples:
--------------------
assert(SysTime(DateTime(2010, 7, 4, 7, 6, 12)).toISOExtString() ==
"2010-07-04T07:06:12");
assert(SysTime(DateTime(1998, 12, 25, 2, 15, 0),
FracSec.from!"msecs"(24)).toISOExtString() ==
"1998-12-25T02:15:00.024");
assert(SysTime(DateTime(0, 1, 5, 23, 9, 59)).toISOExtString() ==
"0000-01-05T23:09:59");
assert(SysTime(DateTime(-4, 1, 5, 0, 0, 2),
FracSec.from!"hnsecs"(520_920)).toISOExtString() ==
"-0004-01-05T00:00:02.052092");
--------------------
+/
string toISOExtString() const nothrow
{
try
{
immutable adjustedTime = adjTime;
long hnsecs = adjustedTime;
auto days = splitUnitsFromHNSecs!"days"(hnsecs) + 1;
if(hnsecs < 0)
{
hnsecs += convert!("hours", "hnsecs")(24);
--days;
}
auto hour = splitUnitsFromHNSecs!"hours"(hnsecs);
auto minute = splitUnitsFromHNSecs!"minutes"(hnsecs);
auto second = splitUnitsFromHNSecs!"seconds"(hnsecs);
auto dateTime = DateTime(Date(cast(int)days), TimeOfDay(cast(int)hour, cast(int)minute, cast(int)second));
auto fracSecStr = fracSecToISOString(cast(int)hnsecs);
if(_timezone is LocalTime())
return dateTime.toISOExtString() ~ fracSecToISOString(cast(int)hnsecs);
if(_timezone is UTC())
return dateTime.toISOExtString() ~ fracSecToISOString(cast(int)hnsecs) ~ "Z";
immutable utcOffset = cast(int)convert!("hnsecs", "minutes")(adjustedTime - stdTime);
return dateTime.toISOExtString() ~ fracSecToISOString(cast(int)hnsecs) ~ SimpleTimeZone.toISOString(utcOffset);
}
catch(Exception e)
assert(0, "format() threw.");
}
/++
$(RED Scheduled for deprecation in November 2011.
Please use toISOExtString instead.)
+/
alias toISOExtString toISOExtendedString;
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(SysTime(DateTime.init, UTC()).toISOExtString(), "0001-01-01T00:00:00Z");
_assertPred!"=="(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1), UTC()).toISOExtString(), "0001-01-01T00:00:00.0000001Z");
_assertPred!"=="(SysTime(DateTime(9, 12, 4, 0, 0, 0)).toISOExtString(), "0009-12-04T00:00:00");
_assertPred!"=="(SysTime(DateTime(99, 12, 4, 5, 6, 12)).toISOExtString(), "0099-12-04T05:06:12");
_assertPred!"=="(SysTime(DateTime(999, 12, 4, 13, 44, 59)).toISOExtString(), "0999-12-04T13:44:59");
_assertPred!"=="(SysTime(DateTime(9999, 7, 4, 23, 59, 59)).toISOExtString(), "9999-07-04T23:59:59");
_assertPred!"=="(SysTime(DateTime(10000, 10, 20, 1, 1, 1)).toISOExtString(), "+10000-10-20T01:01:01");
_assertPred!"=="(SysTime(DateTime(9, 12, 4, 0, 0, 0), FracSec.from!"msecs"(42)).toISOExtString(), "0009-12-04T00:00:00.042");
_assertPred!"=="(SysTime(DateTime(99, 12, 4, 5, 6, 12), FracSec.from!"msecs"(100)).toISOExtString(), "0099-12-04T05:06:12.1");
_assertPred!"=="(SysTime(DateTime(999, 12, 4, 13, 44, 59), FracSec.from!"usecs"(45020)).toISOExtString(), "0999-12-04T13:44:59.04502");
_assertPred!"=="(SysTime(DateTime(9999, 7, 4, 23, 59, 59), FracSec.from!"hnsecs"(12)).toISOExtString(), "9999-07-04T23:59:59.0000012");
_assertPred!"=="(SysTime(DateTime(10000, 10, 20, 1, 1, 1), FracSec.from!"hnsecs"(507890)).toISOExtString(), "+10000-10-20T01:01:01.050789");
_assertPred!"=="(SysTime(DateTime(2012, 12, 21, 12, 12, 12),
new SimpleTimeZone(-360)).toISOExtString(),
"2012-12-21T12:12:12-06:00");
_assertPred!"=="(SysTime(DateTime(2012, 12, 21, 12, 12, 12),
new SimpleTimeZone(420)).toISOExtString(),
"2012-12-21T12:12:12+07:00");
//Test B.C.
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999), UTC()).toISOExtString(), "0000-12-31T23:59:59.9999999Z");
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(1), UTC()).toISOExtString(), "0000-12-31T23:59:59.0000001Z");
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 23, 59, 59), UTC()).toISOExtString(), "0000-12-31T23:59:59Z");
_assertPred!"=="(SysTime(DateTime(0, 12, 4, 0, 12, 4)).toISOExtString(), "0000-12-04T00:12:04");
_assertPred!"=="(SysTime(DateTime(-9, 12, 4, 0, 0, 0)).toISOExtString(), "-0009-12-04T00:00:00");
_assertPred!"=="(SysTime(DateTime(-99, 12, 4, 5, 6, 12)).toISOExtString(), "-0099-12-04T05:06:12");
_assertPred!"=="(SysTime(DateTime(-999, 12, 4, 13, 44, 59)).toISOExtString(), "-0999-12-04T13:44:59");
_assertPred!"=="(SysTime(DateTime(-9999, 7, 4, 23, 59, 59)).toISOExtString(), "-9999-07-04T23:59:59");
_assertPred!"=="(SysTime(DateTime(-10000, 10, 20, 1, 1, 1)).toISOExtString(), "-10000-10-20T01:01:01");
_assertPred!"=="(SysTime(DateTime(0, 12, 4, 0, 0, 0), FracSec.from!"msecs"(7)).toISOExtString(), "0000-12-04T00:00:00.007");
_assertPred!"=="(SysTime(DateTime(-9, 12, 4, 0, 0, 0), FracSec.from!"msecs"(42)).toISOExtString(), "-0009-12-04T00:00:00.042");
_assertPred!"=="(SysTime(DateTime(-99, 12, 4, 5, 6, 12), FracSec.from!"msecs"(100)).toISOExtString(), "-0099-12-04T05:06:12.1");
_assertPred!"=="(SysTime(DateTime(-999, 12, 4, 13, 44, 59), FracSec.from!"usecs"(45020)).toISOExtString(), "-0999-12-04T13:44:59.04502");
_assertPred!"=="(SysTime(DateTime(-9999, 7, 4, 23, 59, 59), FracSec.from!"hnsecs"(12)).toISOExtString(), "-9999-07-04T23:59:59.0000012");
_assertPred!"=="(SysTime(DateTime(-10000, 10, 20, 1, 1, 1), FracSec.from!"hnsecs"(507890)).toISOExtString(), "-10000-10-20T01:01:01.050789");
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cast(TimeOfDay)cst));
//static assert(__traits(compiles, cast(TimeOfDay)ist));
//Verify Examples.
assert(SysTime(DateTime(2010, 7, 4, 7, 6, 12)).toISOExtString() ==
"2010-07-04T07:06:12");
assert(SysTime(DateTime(1998, 12, 25, 2, 15, 0),
FracSec.from!"msecs"(24)).toISOExtString() ==
"1998-12-25T02:15:00.024");
assert(SysTime(DateTime(0, 1, 5, 23, 9, 59)).toISOExtString() ==
"0000-01-05T23:09:59");
assert(SysTime(DateTime(-4, 1, 5, 0, 0, 2),
FracSec.from!"hnsecs"(520_920)).toISOExtString() ==
"-0004-01-05T00:00:02.052092");
}
}
/++
Converts this $(D SysTime) to a string with the format
YYYY-Mon-DD HH:MM:SS.FFFFFFFTZ (where F is fractional seconds and TZ
is the time zone).
Note that the number of digits in the fractional seconds varies with the
number of fractional seconds. It's a maximum of 7 (which would be
hnsecs), but only has as many as are necessary to hold the correct value
(so no trailing zeroes), and if there are no fractional seconds, then
there is no decimal point.
If this $(D SysTime)'s time zone is $(D LocalTime), then TZ is empty. If
its time zone is $(D UTC), then it is "Z". Otherwise, it is the offset
from UTC (e.g. +1:00 or -7:00). Note that the offset from UTC is
$(I not) enough to uniquely identify the time zone.
Time zone offsets will be in the form +HH:MM or -HH:MM.
Examples:
--------------------
assert(SysTime(DateTime(2010, 7, 4, 7, 6, 12)).toSimpleString() ==
"2010-Jul-04 07:06:12");
assert(SysTime(DateTime(1998, 12, 25, 2, 15, 0),
FracSec.from!"msecs"(24)).toSimpleString() ==
"1998-Dec-25 02:15:00.024");
assert(SysTime(DateTime(0, 1, 5, 23, 9, 59)).toSimpleString() ==
"0000-Jan-05 23:09:59");
assert(SysTime(DateTime(-4, 1, 5, 0, 0, 2),
FracSec.from!"hnsecs"(520_920)).toSimpleString() ==
"-0004-Jan-05 00:00:02.052092");
--------------------
+/
string toSimpleString() const nothrow
{
try
{
immutable adjustedTime = adjTime;
long hnsecs = adjustedTime;
auto days = splitUnitsFromHNSecs!"days"(hnsecs) + 1;
if(hnsecs < 0)
{
hnsecs += convert!("hours", "hnsecs")(24);
--days;
}
auto hour = splitUnitsFromHNSecs!"hours"(hnsecs);
auto minute = splitUnitsFromHNSecs!"minutes"(hnsecs);
auto second = splitUnitsFromHNSecs!"seconds"(hnsecs);
auto dateTime = DateTime(Date(cast(int)days), TimeOfDay(cast(int)hour, cast(int)minute, cast(int)second));
auto fracSecStr = fracSecToISOString(cast(int)hnsecs);
if(_timezone is LocalTime())
return dateTime.toSimpleString() ~ fracSecToISOString(cast(int)hnsecs);
if(_timezone is UTC())
return dateTime.toSimpleString() ~ fracSecToISOString(cast(int)hnsecs) ~ "Z";
immutable utcOffset = cast(int)convert!("hnsecs", "minutes")(adjustedTime - stdTime);
return dateTime.toSimpleString() ~ fracSecToISOString(cast(int)hnsecs) ~ SimpleTimeZone.toISOString(utcOffset);
}
catch(Exception e)
assert(0, "format() threw.");
}
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(SysTime(DateTime.init, UTC()).toString(), "0001-Jan-01 00:00:00Z");
_assertPred!"=="(SysTime(DateTime(1, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1), UTC()).toString(), "0001-Jan-01 00:00:00.0000001Z");
_assertPred!"=="(SysTime(DateTime(9, 12, 4, 0, 0, 0)).toSimpleString(), "0009-Dec-04 00:00:00");
_assertPred!"=="(SysTime(DateTime(99, 12, 4, 5, 6, 12)).toSimpleString(), "0099-Dec-04 05:06:12");
_assertPred!"=="(SysTime(DateTime(999, 12, 4, 13, 44, 59)).toSimpleString(), "0999-Dec-04 13:44:59");
_assertPred!"=="(SysTime(DateTime(9999, 7, 4, 23, 59, 59)).toSimpleString(), "9999-Jul-04 23:59:59");
_assertPred!"=="(SysTime(DateTime(10000, 10, 20, 1, 1, 1)).toSimpleString(), "+10000-Oct-20 01:01:01");
_assertPred!"=="(SysTime(DateTime(9, 12, 4, 0, 0, 0), FracSec.from!"msecs"(42)).toSimpleString(), "0009-Dec-04 00:00:00.042");
_assertPred!"=="(SysTime(DateTime(99, 12, 4, 5, 6, 12), FracSec.from!"msecs"(100)).toSimpleString(), "0099-Dec-04 05:06:12.1");
_assertPred!"=="(SysTime(DateTime(999, 12, 4, 13, 44, 59), FracSec.from!"usecs"(45020)).toSimpleString(), "0999-Dec-04 13:44:59.04502");
_assertPred!"=="(SysTime(DateTime(9999, 7, 4, 23, 59, 59), FracSec.from!"hnsecs"(12)).toSimpleString(), "9999-Jul-04 23:59:59.0000012");
_assertPred!"=="(SysTime(DateTime(10000, 10, 20, 1, 1, 1), FracSec.from!"hnsecs"(507890)).toSimpleString(), "+10000-Oct-20 01:01:01.050789");
_assertPred!"=="(SysTime(DateTime(2012, 12, 21, 12, 12, 12),
new SimpleTimeZone(-360)).toSimpleString(),
"2012-Dec-21 12:12:12-06:00");
_assertPred!"=="(SysTime(DateTime(2012, 12, 21, 12, 12, 12),
new SimpleTimeZone(420)).toSimpleString(),
"2012-Dec-21 12:12:12+07:00");
//Test B.C.
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999), UTC()).toSimpleString(), "0000-Dec-31 23:59:59.9999999Z");
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(1), UTC()).toSimpleString(), "0000-Dec-31 23:59:59.0000001Z");
_assertPred!"=="(SysTime(DateTime(0, 12, 31, 23, 59, 59), UTC()).toSimpleString(), "0000-Dec-31 23:59:59Z");
_assertPred!"=="(SysTime(DateTime(0, 12, 4, 0, 12, 4)).toSimpleString(), "0000-Dec-04 00:12:04");
_assertPred!"=="(SysTime(DateTime(-9, 12, 4, 0, 0, 0)).toSimpleString(), "-0009-Dec-04 00:00:00");
_assertPred!"=="(SysTime(DateTime(-99, 12, 4, 5, 6, 12)).toSimpleString(), "-0099-Dec-04 05:06:12");
_assertPred!"=="(SysTime(DateTime(-999, 12, 4, 13, 44, 59)).toSimpleString(), "-0999-Dec-04 13:44:59");
_assertPred!"=="(SysTime(DateTime(-9999, 7, 4, 23, 59, 59)).toSimpleString(), "-9999-Jul-04 23:59:59");
_assertPred!"=="(SysTime(DateTime(-10000, 10, 20, 1, 1, 1)).toSimpleString(), "-10000-Oct-20 01:01:01");
_assertPred!"=="(SysTime(DateTime(0, 12, 4, 0, 0, 0), FracSec.from!"msecs"(7)).toSimpleString(), "0000-Dec-04 00:00:00.007");
_assertPred!"=="(SysTime(DateTime(-9, 12, 4, 0, 0, 0), FracSec.from!"msecs"(42)).toSimpleString(), "-0009-Dec-04 00:00:00.042");
_assertPred!"=="(SysTime(DateTime(-99, 12, 4, 5, 6, 12), FracSec.from!"msecs"(100)).toSimpleString(), "-0099-Dec-04 05:06:12.1");
_assertPred!"=="(SysTime(DateTime(-999, 12, 4, 13, 44, 59), FracSec.from!"usecs"(45020)).toSimpleString(), "-0999-Dec-04 13:44:59.04502");
_assertPred!"=="(SysTime(DateTime(-9999, 7, 4, 23, 59, 59), FracSec.from!"hnsecs"(12)).toSimpleString(), "-9999-Jul-04 23:59:59.0000012");
_assertPred!"=="(SysTime(DateTime(-10000, 10, 20, 1, 1, 1), FracSec.from!"hnsecs"(507890)).toSimpleString(), "-10000-Oct-20 01:01:01.050789");
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, cast(TimeOfDay)cst));
//static assert(__traits(compiles, cast(TimeOfDay)ist));
//Verify Examples.
assert(SysTime(DateTime(2010, 7, 4, 7, 6, 12)).toSimpleString() ==
"2010-Jul-04 07:06:12");
assert(SysTime(DateTime(1998, 12, 25, 2, 15, 0),
FracSec.from!"msecs"(24)).toSimpleString() ==
"1998-Dec-25 02:15:00.024");
assert(SysTime(DateTime(0, 1, 5, 23, 9, 59)).toSimpleString() ==
"0000-Jan-05 23:09:59");
assert(SysTime(DateTime(-4, 1, 5, 0, 0, 2),
FracSec.from!"hnsecs"(520_920)).toSimpleString() ==
"-0004-Jan-05 00:00:02.052092");
}
}
/+
Converts this $(D SysTime) to a string.
+/
//Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
//have versions of toString() with extra modifiers, so we define one version
//with modifiers and one without.
string toString()
{
return toSimpleString();
}
/++
Converts this $(D SysTime) to a string.
+/
//Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
//have versions of toString() with extra modifiers, so we define one version
//with modifiers and one without.
string toString() const nothrow
{
return toSimpleString();
}
unittest
{
version(testStdDateTime)
{
auto st = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
const cst = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
//immutable ist = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
static assert(__traits(compiles, st.toString()));
static assert(__traits(compiles, cst.toString()));
//static assert(__traits(compiles, ist.toString()));
}
}
/++
Creates a $(D SysTime) from a string with the format
YYYYMMDDTHHMMSS.FFFFFFFTZ (where F is fractional seconds is the time
zone). Whitespace is stripped from the given string.
The exact format is exactly as described in $(D toISOString) except that
trailing zeroes are permitted - including having fractional seconds with
all zeroes. However, a decimal point with nothing following it is
invalid.
If there is no time zone in the string, then $(D LocalTime) is used. If
the time zone is "Z", then $(D UTC) is used. Otherwise, a
$(D SimpleTimeZone) which corresponds to the given offset from UTC is
used. If you wish the returned $(D SysTime) to be a particular time
zone, then pass in that time zone and the $(D SysTime) to be returned
will be converted to that time zone (though it will still be read in as
whatever time zone is in its string).
The accepted formats for time zone offsets
are +H, -H, +HH, -HH, +H:MM, -H:MM, +HH:MM, and -HH:MM.
Params:
isoString = A string formatted in the ISO format for dates and times.
tz = The time zone to convert the given time to (no
conversion occurs if null).
Throws:
$(D DateTimeException) if the given string is not in the ISO format
or if the resulting $(D SysTime) would not be valid.
Examples:
--------------------
assert(SysTime.fromISOString("20100704T070612") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12)));
assert(SysTime.fromISOString("19981225T021500.007") ==
SysTime(DateTime(1998, 12, 25, 2, 15, 0), FracSec.from!"msecs"(7)));
assert(SysTime.fromISOString("00000105T230959.00002") ==
SysTime(DateTime(0, 1, 5, 23, 9, 59), FracSec.from!"usecs"(20)));
assert(SysTime.fromISOString("-00040105T000002") ==
SysTime(DateTime(-4, 1, 5, 0, 0, 2)));
assert(SysTime.fromISOString(" 20100704T070612 ") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12)));
assert(SysTime.fromISOString("20100704T070612Z") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12), UTC()));
assert(SysTime.fromISOString("20100704T070612-8:00") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12), new SimpleTimeZone(-480)));
assert(SysTime.fromISOString("20100704T070612+8:00") ==
SysTime(DateTime(2010, 7, 3, 7, 6, 12), new SimpleTimeZone(480)));
--------------------
+/
static SysTime fromISOString(S)(in S isoString, immutable TimeZone tz = null)
if(isSomeString!S)
{
auto dstr = to!dstring(strip(isoString));
immutable skipFirst = dstr.startsWith("+", "-") != 0;
auto found = (skipFirst ? dstr[1..$] : dstr).find(".", "Z", "+", "-");
auto dateTimeStr = dstr[0 .. $ - found[0].length];
dstring fracSecStr;
dstring zoneStr;
if(found[1] != 0)
{
if(found[1] == 1)
{
auto foundTZ = found[0].find("Z", "+", "-");
if(foundTZ[1] != 0)
{
fracSecStr = found[0][0 .. $ - foundTZ[0].length];
zoneStr = foundTZ[0];
}
else
fracSecStr = found[0];
}
else
zoneStr = found[0];
}
try
{
auto dateTime = DateTime.fromISOString(dateTimeStr);
auto fracSec = fracSecFromISOString(fracSecStr);
Rebindable!(immutable TimeZone) parsedZone;
if(zoneStr.empty)
parsedZone = LocalTime();
else if(zoneStr == "Z")
parsedZone = UTC();
else
parsedZone = SimpleTimeZone.fromISOString(zoneStr);
auto retval = SysTime(dateTime, fracSec, parsedZone);
if(tz !is null)
retval.timezone = tz;
return retval;
}
catch(DateTimeException dte)
throw new DateTimeException(format("Invalid ISO String: %s", isoString));
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException(SysTime.fromISOString(""));
assertThrown!DateTimeException(SysTime.fromISOString("20100704000000"));
assertThrown!DateTimeException(SysTime.fromISOString("20100704 000000"));
assertThrown!DateTimeException(SysTime.fromISOString("20100704t000000"));
assertThrown!DateTimeException(SysTime.fromISOString("20100704T000000."));
assertThrown!DateTimeException(SysTime.fromISOString("20100704T000000.A"));
assertThrown!DateTimeException(SysTime.fromISOString("20100704T000000.Z"));
assertThrown!DateTimeException(SysTime.fromISOString("20100704T000000.00000000"));
assertThrown!DateTimeException(SysTime.fromISOString("20100704T000000.00000000"));
assertThrown!DateTimeException(SysTime.fromISOString("20100704T000000+"));
assertThrown!DateTimeException(SysTime.fromISOString("20100704T000000-"));
assertThrown!DateTimeException(SysTime.fromISOString("20100704T000000:"));
assertThrown!DateTimeException(SysTime.fromISOString("20100704T000000-:"));
assertThrown!DateTimeException(SysTime.fromISOString("20100704T000000+:"));
assertThrown!DateTimeException(SysTime.fromISOString("20100704T000000-1:"));
assertThrown!DateTimeException(SysTime.fromISOString("20100704T000000+1:"));
assertThrown!DateTimeException(SysTime.fromISOString("20100704T000000+1:0"));
assertThrown!DateTimeException(SysTime.fromISOString("20100704T000000-24.00"));
assertThrown!DateTimeException(SysTime.fromISOString("20100704T000000+24.00"));
assertThrown!DateTimeException(SysTime.fromISOString("2010-07-0400:00:00"));
assertThrown!DateTimeException(SysTime.fromISOString("2010-07-04 00:00:00"));
assertThrown!DateTimeException(SysTime.fromISOString("2010-07-04t00:00:00"));
assertThrown!DateTimeException(SysTime.fromISOString("2010-07-04T00:00:00."));
assertThrown!DateTimeException(SysTime.fromISOString("2010-Jul-0400:00:00"));
assertThrown!DateTimeException(SysTime.fromISOString("2010-Jul-04 00:00:00"));
assertThrown!DateTimeException(SysTime.fromISOString("2010-Jul-04t00:00:00"));
assertThrown!DateTimeException(SysTime.fromISOString("2010-Jul-04T00:00:00"));
assertThrown!DateTimeException(SysTime.fromISOString("2010-Jul-04 00:00:00."));
assertThrown!DateTimeException(SysTime.fromISOString("2010-12-22T172201"));
assertThrown!DateTimeException(SysTime.fromISOString("2010-Dec-22 17:22:01"));
_assertPred!"=="(SysTime.fromISOString("20101222T172201"), SysTime(DateTime(2010, 12, 22, 17, 22, 01)));
_assertPred!"=="(SysTime.fromISOString("19990706T123033"), SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
_assertPred!"=="(SysTime.fromISOString("-19990706T123033"), SysTime(DateTime(-1999, 7, 6, 12, 30, 33)));
_assertPred!"=="(SysTime.fromISOString("+019990706T123033"), SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
_assertPred!"=="(SysTime.fromISOString("19990706T123033 "), SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
_assertPred!"=="(SysTime.fromISOString(" 19990706T123033"), SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
_assertPred!"=="(SysTime.fromISOString(" 19990706T123033 "), SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
_assertPred!"=="(SysTime.fromISOString("19070707T121212.0"), SysTime(DateTime(1907, 07, 07, 12, 12, 12)));
_assertPred!"=="(SysTime.fromISOString("19070707T121212.0000000"), SysTime(DateTime(1907, 07, 07, 12, 12, 12)));
_assertPred!"=="(SysTime.fromISOString("19070707T121212.0000001"), SysTime(DateTime(1907, 07, 07, 12, 12, 12), FracSec.from!"hnsecs"(1)));
_assertPred!"=="(SysTime.fromISOString("19070707T121212.000001"), SysTime(DateTime(1907, 07, 07, 12, 12, 12), FracSec.from!"usecs"(1)));
_assertPred!"=="(SysTime.fromISOString("19070707T121212.0000010"), SysTime(DateTime(1907, 07, 07, 12, 12, 12), FracSec.from!"usecs"(1)));
_assertPred!"=="(SysTime.fromISOString("19070707T121212.001"), SysTime(DateTime(1907, 07, 07, 12, 12, 12), FracSec.from!"msecs"(1)));
_assertPred!"=="(SysTime.fromISOString("19070707T121212.0010000"), SysTime(DateTime(1907, 07, 07, 12, 12, 12), FracSec.from!"msecs"(1)));
_assertPred!"=="(SysTime.fromISOString("20101222T172201Z"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), UTC()));
_assertPred!"=="(SysTime.fromISOString("20101222T172201-1:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(-60)));
_assertPred!"=="(SysTime.fromISOString("20101222T172201-1"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(-60)));
_assertPred!"=="(SysTime.fromISOString("20101222T172201-1:30"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(-90)));
_assertPred!"=="(SysTime.fromISOString("20101222T172201-8:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(-480)));
_assertPred!"=="(SysTime.fromISOString("20101222T172201+1:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(60)));
_assertPred!"=="(SysTime.fromISOString("20101222T172201+1"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(60)));
_assertPred!"=="(SysTime.fromISOString("20101222T172201+1:30"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(90)));
_assertPred!"=="(SysTime.fromISOString("20101222T172201+8:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(480)));
_assertPred!"=="(SysTime.fromISOString("20101103T065106.57159Z"), SysTime(DateTime(2010, 11, 3, 6, 51, 6), FracSec.from!"hnsecs"(5715900), UTC()));
_assertPred!"=="(SysTime.fromISOString("20101222T172201.23412Z"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(2_341_200), UTC()));
_assertPred!"=="(SysTime.fromISOString("20101222T172201.23112-1:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(2_311_200), new SimpleTimeZone(-60)));
_assertPred!"=="(SysTime.fromISOString("20101222T172201.45-1"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(4_500_000), new SimpleTimeZone(-60)));
_assertPred!"=="(SysTime.fromISOString("20101222T172201.1-1:30"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(1_000_000), new SimpleTimeZone(-90)));
_assertPred!"=="(SysTime.fromISOString("20101222T172201.55-8:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(5_500_000), new SimpleTimeZone(-480)));
_assertPred!"=="(SysTime.fromISOString("20101222T172201.1234567+1:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(1_234_567), new SimpleTimeZone(60)));
_assertPred!"=="(SysTime.fromISOString("20101222T172201.0+1"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(0), new SimpleTimeZone(60)));
_assertPred!"=="(SysTime.fromISOString("20101222T172201.0000000+1:30"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(0), new SimpleTimeZone(90)));
_assertPred!"=="(SysTime.fromISOString("20101222T172201.45+8:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(4_500_000), new SimpleTimeZone(480)));
//Verify Examples.
assert(SysTime.fromISOString("20100704T070612") == SysTime(DateTime(2010, 7, 4, 7, 6, 12)));
assert(SysTime.fromISOString("19981225T021500.007") == SysTime(DateTime(1998, 12, 25, 2, 15, 0), FracSec.from!"msecs"(7)));
assert(SysTime.fromISOString("00000105T230959.00002") == SysTime(DateTime(0, 1, 5, 23, 9, 59), FracSec.from!"usecs"(20)));
assert(SysTime.fromISOString("-00040105T000002") == SysTime(DateTime(-4, 1, 5, 0, 0, 2)));
assert(SysTime.fromISOString(" 20100704T070612 ") == SysTime(DateTime(2010, 7, 4, 7, 6, 12)));
assert(SysTime.fromISOString("20100704T070612Z") == SysTime(DateTime(2010, 7, 4, 7, 6, 12), UTC()));
assert(SysTime.fromISOString("20100704T070612-8:00") == SysTime(DateTime(2010, 7, 4, 7, 6, 12), new SimpleTimeZone(-480)));
assert(SysTime.fromISOString("20100704T070612+8:00") == SysTime(DateTime(2010, 7, 4, 7, 6, 12), new SimpleTimeZone(480)));
}
}
/++
Creates a $(D SysTime) from a string with the format
YYYY-MM-DDTHH:MM:SS.FFFFFFFTZ (where F is fractional seconds is the
time zone). Whitespace is stripped from the given string.
The exact format is exactly as described in $(D toISOExtString)
except that trailing zeroes are permitted - including having fractional
seconds with all zeroes. However, a decimal point with nothing following
it is invalid.
If there is no time zone in the string, then $(D LocalTime) is used. If
the time zone is "Z", then $(D UTC) is used. Otherwise, a
$(D SimpleTimeZone) which corresponds to the given offset from UTC is
used. If you wish the returned $(D SysTime) to be a particular time
zone, then pass in that time zone and the $(D SysTime) to be returned
will be converted to that time zone (though it will still be read in as
whatever time zone is in its string).
The accepted formats for time zone offsets
are +H, -H, +HH, -HH, +H:MM, -H:MM, +HH:MM, and -HH:MM.
Params:
isoString = A string formatted in the ISO Extended format for dates
and times.
tz = The time zone to convert the given time to (no
conversion occurs if null).
Throws:
$(D DateTimeException) if the given string is not in the ISO format
or if the resulting $(D SysTime) would not be valid.
Examples:
--------------------
assert(SysTime.fromISOExtString("2010-07-04T07:06:12") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12)));
assert(SysTime.fromISOExtString("1998-12-25T02:15:00.007") ==
SysTime(DateTime(1998, 12, 25, 2, 15, 0), FracSec.from!"msecs"(7)));
assert(SysTime.fromISOExtString("0000-01-05T23:09:59.00002") ==
SysTime(DateTime(0, 1, 5, 23, 9, 59), FracSec.from!"usecs"(20)));
assert(SysTime.fromISOExtString("-0004-01-05T00:00:02") ==
SysTime(DateTime(-4, 1, 5, 0, 0, 2)));
assert(SysTime.fromISOExtString(" 2010-07-04T07:06:12 ") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12)));
assert(SysTime.fromISOExtString("2010-07-04T07:06:12Z") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12), UTC()));
assert(SysTime.fromISOExtString("2010-07-04T07:06:12-8:00") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12), new SimpleTimeZone(-480)));
assert(SysTime.fromISOExtString("2010-07-04T07:06:12+8:00") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12), new SimpleTimeZone(480)));
--------------------
+/
static SysTime fromISOExtString(S)(in S isoExtString, immutable TimeZone tz = null)
if(isSomeString!(S))
{
auto dstr = to!dstring(strip(isoExtString));
auto tIndex = dstr.stds_indexOf("T");
enforce(tIndex != -1, new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
auto found = dstr[tIndex + 1 .. $].find(".", "Z", "+", "-");
auto dateTimeStr = dstr[0 .. $ - found[0].length];
dstring fracSecStr;
dstring zoneStr;
if(found[1] != 0)
{
if(found[1] == 1)
{
auto foundTZ = found[0].find("Z", "+", "-");
if(foundTZ[1] != 0)
{
fracSecStr = found[0][0 .. $ - foundTZ[0].length];
zoneStr = foundTZ[0];
}
else
fracSecStr = found[0];
}
else
zoneStr = found[0];
}
try
{
auto dateTime = DateTime.fromISOExtString(dateTimeStr);
auto fracSec = fracSecFromISOString(fracSecStr);
Rebindable!(immutable TimeZone) parsedZone;
if(zoneStr.empty)
parsedZone = LocalTime();
else if(zoneStr == "Z")
parsedZone = UTC();
else
parsedZone = SimpleTimeZone.fromISOString(zoneStr);
auto retval = SysTime(dateTime, fracSec, parsedZone);
if(tz !is null)
retval.timezone = tz;
return retval;
}
catch(DateTimeException dte)
throw new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString));
}
/++
$(RED Scheduled for deprecation in November 2011.
Please use fromISOExtString instead.)
+/
static SysTime fromISOExtendedString(S)(in S isoExtString, immutable TimeZone tz = null)
if(isSomeString!(S))
{
pragma(msg, softDeprec!("2.053", "November 2011", "fromISOExtendedString", "fromISOExtString"));
return fromISOExtString!string(isoExtString, tz);
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException(SysTime.fromISOExtString(""));
assertThrown!DateTimeException(SysTime.fromISOExtString("20100704000000"));
assertThrown!DateTimeException(SysTime.fromISOExtString("20100704 000000"));
assertThrown!DateTimeException(SysTime.fromISOExtString("20100704t000000"));
assertThrown!DateTimeException(SysTime.fromISOExtString("20100704T000000."));
assertThrown!DateTimeException(SysTime.fromISOExtString("20100704T000000.0"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07:0400:00:00"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07-04 00:00:00"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07-04 00:00:00"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07-04t00:00:00"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07-04T00:00:00."));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07-04T00:00:00.A"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07-04T00:00:00.Z"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07-04T00:00:00.00000000"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07-04T00:00:00.00000000"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07-04T00:00:00+"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07-04T00:00:00-"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07-04T00:00:00:"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07-04T00:00:00-:"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07-04T00:00:00+:"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07-04T00:00:00-1:"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07-04T00:00:00+1:"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07-04T00:00:00+1:0"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07-04T00:00:00-24.00"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-07-04T00:00:00+24.00"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-Jul-0400:00:00"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-Jul-04t00:00:00"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-Jul-04 00:00:00."));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-Jul-04 00:00:00.0"));
assertThrown!DateTimeException(SysTime.fromISOExtString("20101222T172201"));
assertThrown!DateTimeException(SysTime.fromISOExtString("2010-Dec-22 17:22:01"));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01"), SysTime(DateTime(2010, 12, 22, 17, 22, 01)));
_assertPred!"=="(SysTime.fromISOExtString("1999-07-06T12:30:33"), SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
_assertPred!"=="(SysTime.fromISOExtString("-1999-07-06T12:30:33"), SysTime(DateTime(-1999, 7, 6, 12, 30, 33)));
_assertPred!"=="(SysTime.fromISOExtString("+01999-07-06T12:30:33"), SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
_assertPred!"=="(SysTime.fromISOExtString("1999-07-06T12:30:33 "), SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
_assertPred!"=="(SysTime.fromISOExtString(" 1999-07-06T12:30:33"), SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
_assertPred!"=="(SysTime.fromISOExtString(" 1999-07-06T12:30:33 "), SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
_assertPred!"=="(SysTime.fromISOExtString("1907-07-07T12:12:12.0"), SysTime(DateTime(1907, 07, 07, 12, 12, 12)));
_assertPred!"=="(SysTime.fromISOExtString("1907-07-07T12:12:12.0000000"), SysTime(DateTime(1907, 07, 07, 12, 12, 12)));
_assertPred!"=="(SysTime.fromISOExtString("1907-07-07T12:12:12.0000001"), SysTime(DateTime(1907, 07, 07, 12, 12, 12), FracSec.from!"hnsecs"(1)));
_assertPred!"=="(SysTime.fromISOExtString("1907-07-07T12:12:12.000001"), SysTime(DateTime(1907, 07, 07, 12, 12, 12), FracSec.from!"usecs"(1)));
_assertPred!"=="(SysTime.fromISOExtString("1907-07-07T12:12:12.0000010"), SysTime(DateTime(1907, 07, 07, 12, 12, 12), FracSec.from!"usecs"(1)));
_assertPred!"=="(SysTime.fromISOExtString("1907-07-07T12:12:12.001"), SysTime(DateTime(1907, 07, 07, 12, 12, 12), FracSec.from!"msecs"(1)));
_assertPred!"=="(SysTime.fromISOExtString("1907-07-07T12:12:12.0010000"), SysTime(DateTime(1907, 07, 07, 12, 12, 12), FracSec.from!"msecs"(1)));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01Z"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), UTC()));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01-1:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(-60)));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01-1"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(-60)));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01-1:30"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(-90)));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01-8:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(-480)));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01+1:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(60)));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01+1"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(60)));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01+1:30"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(90)));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01+8:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(480)));
_assertPred!"=="(SysTime.fromISOExtString("2010-11-03T06:51:06.57159Z"), SysTime(DateTime(2010, 11, 3, 6, 51, 6), FracSec.from!"hnsecs"(5715900), UTC()));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01.23412Z"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(2_341_200), UTC()));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01.23112-1:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(2_311_200), new SimpleTimeZone(-60)));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01.45-1"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(4_500_000), new SimpleTimeZone(-60)));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01.1-1:30"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(1_000_000), new SimpleTimeZone(-90)));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01.55-8:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(5_500_000), new SimpleTimeZone(-480)));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01.1234567+1:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(1_234_567), new SimpleTimeZone(60)));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01.0+1"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(0), new SimpleTimeZone(60)));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01.0000000+1:30"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(0), new SimpleTimeZone(90)));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01.45+8:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(4_500_000), new SimpleTimeZone(480)));
//Verify Examples.
assert(SysTime.fromISOExtString("2010-07-04T07:06:12") == SysTime(DateTime(2010, 7, 4, 7, 6, 12)));
assert(SysTime.fromISOExtString("1998-12-25T02:15:00.007") == SysTime(DateTime(1998, 12, 25, 2, 15, 0), FracSec.from!"msecs"(7)));
assert(SysTime.fromISOExtString("0000-01-05T23:09:59.00002") == SysTime(DateTime(0, 1, 5, 23, 9, 59), FracSec.from!"usecs"(20)));
assert(SysTime.fromISOExtString("-0004-01-05T00:00:02") == SysTime(DateTime(-4, 1, 5, 0, 0, 2)));
assert(SysTime.fromISOExtString(" 2010-07-04T07:06:12 ") == SysTime(DateTime(2010, 7, 4, 7, 6, 12)));
assert(SysTime.fromISOExtString("2010-07-04T07:06:12Z") == SysTime(DateTime(2010, 7, 4, 7, 6, 12), UTC()));
assert(SysTime.fromISOExtString("2010-07-04T07:06:12-8:00") == SysTime(DateTime(2010, 7, 4, 7, 6, 12), new SimpleTimeZone(-480)));
assert(SysTime.fromISOExtString("2010-07-04T07:06:12+8:00") == SysTime(DateTime(2010, 7, 4, 7, 6, 12), new SimpleTimeZone(480)));
}
}
/++
Creates a $(D SysTime) from a string with the format
YYYY-MM-DD HH:MM:SS.FFFFFFFTZ (where F is fractional seconds is the
time zone). Whitespace is stripped from the given string.
The exact format is exactly as described in $(D toSimpleString) except
that trailing zeroes are permitted - including having fractional seconds
with all zeroes. However, a decimal point with nothing following it is
invalid.
If there is no time zone in the string, then $(D LocalTime) is used. If
the time zone is "Z", then $(D UTC) is used. Otherwise, a
$(D SimpleTimeZone) which corresponds to the given offset from UTC is
used. If you wish the returned $(D SysTime) to be a particular time
zone, then pass in that time zone and the $(D SysTime) to be returned
will be converted to that time zone (though it will still be read in as
whatever time zone is in its string).
The accepted formats for time zone offsets
are +H, -H, +HH, -HH, +H:MM, -H:MM, +HH:MM, and -HH:MM.
Params:
simpleString = A string formatted in the way that
$(D toSimpleString) formats dates and times.
tz = The time zone to convert the given time to (no
conversion occurs if null).
Throws:
$(D DateTimeException) if the given string is not in the ISO format
or if the resulting $(D SysTime) would not be valid.
Examples:
--------------------
assert(SysTime.fromSimpleString("2010-Jul-04 07:06:12") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12)));
assert(SysTime.fromSimpleString("1998-Dec-25 02:15:00.007") ==
SysTime(DateTime(1998, 12, 25, 2, 15, 0), FracSec.from!"msecs"(7)));
assert(SysTime.fromSimpleString("0000-Jan-05 23:09:59.00002") ==
SysTime(DateTime(0, 1, 5, 23, 9, 59), FracSec.from!"usecs"(20)));
assert(SysTime.fromSimpleString("-0004-Jan-05 00:00:02") ==
SysTime(DateTime(-4, 1, 5, 0, 0, 2)));
assert(SysTime.fromSimpleString(" 2010-Jul-04 07:06:12 ") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12)));
assert(SysTime.fromSimpleString("2010-Jul-04 07:06:12Z") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12), UTC()));
assert(SysTime.fromSimpleString("2010-Jul-04 07:06:12-8:00") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12), new SimpleTimeZone(-480)));
assert(SysTime.fromSimpleString("2010-Jul-04 07:06:12+8:00") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12), new SimpleTimeZone(480)));
--------------------
+/
static SysTime fromSimpleString(S)(in S simpleString, immutable TimeZone tz = null)
if(isSomeString!(S))
{
auto dstr = to!dstring(strip(simpleString));
auto spaceIndex = dstr.stds_indexOf(" ");
enforce(spaceIndex != -1, new DateTimeException(format("Invalid Simple String: %s", simpleString)));
auto found = dstr[spaceIndex + 1 .. $].find(".", "Z", "+", "-");
auto dateTimeStr = dstr[0 .. $ - found[0].length];
dstring fracSecStr;
dstring zoneStr;
if(found[1] != 0)
{
if(found[1] == 1)
{
auto foundTZ = found[0].find("Z", "+", "-");
if(foundTZ[1] != 0)
{
fracSecStr = found[0][0 .. $ - foundTZ[0].length];
zoneStr = foundTZ[0];
}
else
fracSecStr = found[0];
}
else
zoneStr = found[0];
}
try
{
auto dateTime = DateTime.fromSimpleString(dateTimeStr);
auto fracSec = fracSecFromISOString(fracSecStr);
Rebindable!(immutable TimeZone) parsedZone;
if(zoneStr.empty)
parsedZone = LocalTime();
else if(zoneStr == "Z")
parsedZone = UTC();
else
parsedZone = SimpleTimeZone.fromISOString(zoneStr);
auto retval = SysTime(dateTime, fracSec, parsedZone);
if(tz !is null)
retval.timezone = tz;
return retval;
}
catch(DateTimeException dte)
throw new DateTimeException(format("Invalid Simple String: %s", simpleString));
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException(SysTime.fromSimpleString(""));
assertThrown!DateTimeException(SysTime.fromSimpleString("20100704000000"));
assertThrown!DateTimeException(SysTime.fromSimpleString("20100704 000000"));
assertThrown!DateTimeException(SysTime.fromSimpleString("20100704t000000"));
assertThrown!DateTimeException(SysTime.fromSimpleString("20100704T000000."));
assertThrown!DateTimeException(SysTime.fromSimpleString("20100704T000000.0"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-07-0400:00:00"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-07-04 00:00:00"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-07-04t00:00:00"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-07-04T00:00:00."));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-07-04T00:00:00.0"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-Jul-0400:00:00"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-Jul-04t00:00:00"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-Jul-04T00:00:00"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-Jul-04 00:00:00."));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-Jul-04 00:00:00.A"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-Jul-04 00:00:00.Z"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-Jul-04 00:00:00.00000000"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-Jul-04 00:00:00.00000000"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-Jul-04 00:00:00+"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-Jul-04 00:00:00-"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-Jul-04 00:00:00:"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-Jul-04 00:00:00-:"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-Jul-04 00:00:00+:"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-Jul-04 00:00:00-1:"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-Jul-04 00:00:00+1:"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-Jul-04 00:00:00+1:0"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-Jul-04 00:00:00-24.00"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-Jul-04 00:00:00+24.00"));
assertThrown!DateTimeException(SysTime.fromSimpleString("20101222T172201"));
assertThrown!DateTimeException(SysTime.fromSimpleString("2010-12-22T172201"));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01"), SysTime(DateTime(2010, 12, 22, 17, 22, 01)));
_assertPred!"=="(SysTime.fromSimpleString("1999-Jul-06 12:30:33"), SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
_assertPred!"=="(SysTime.fromSimpleString("-1999-Jul-06 12:30:33"), SysTime(DateTime(-1999, 7, 6, 12, 30, 33)));
_assertPred!"=="(SysTime.fromSimpleString("+01999-Jul-06 12:30:33"), SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
_assertPred!"=="(SysTime.fromSimpleString("1999-Jul-06 12:30:33 "), SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
_assertPred!"=="(SysTime.fromSimpleString(" 1999-Jul-06 12:30:33"), SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
_assertPred!"=="(SysTime.fromSimpleString(" 1999-Jul-06 12:30:33 "), SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
_assertPred!"=="(SysTime.fromSimpleString("1907-Jul-07 12:12:12.0"), SysTime(DateTime(1907, 07, 07, 12, 12, 12)));
_assertPred!"=="(SysTime.fromSimpleString("1907-Jul-07 12:12:12.0000000"), SysTime(DateTime(1907, 07, 07, 12, 12, 12)));
_assertPred!"=="(SysTime.fromSimpleString("1907-Jul-07 12:12:12.0000001"), SysTime(DateTime(1907, 07, 07, 12, 12, 12), FracSec.from!"hnsecs"(1)));
_assertPred!"=="(SysTime.fromSimpleString("1907-Jul-07 12:12:12.000001"), SysTime(DateTime(1907, 07, 07, 12, 12, 12), FracSec.from!"usecs"(1)));
_assertPred!"=="(SysTime.fromSimpleString("1907-Jul-07 12:12:12.0000010"), SysTime(DateTime(1907, 07, 07, 12, 12, 12), FracSec.from!"usecs"(1)));
_assertPred!"=="(SysTime.fromSimpleString("1907-Jul-07 12:12:12.001"), SysTime(DateTime(1907, 07, 07, 12, 12, 12), FracSec.from!"msecs"(1)));
_assertPred!"=="(SysTime.fromSimpleString("1907-Jul-07 12:12:12.0010000"), SysTime(DateTime(1907, 07, 07, 12, 12, 12), FracSec.from!"msecs"(1)));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01Z"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), UTC()));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01-1:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(-60)));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01-1"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(-60)));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01-1:30"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(-90)));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01-8:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(-480)));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01+1:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(60)));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01+1"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(60)));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01+1:30"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(90)));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01+8:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(480)));
_assertPred!"=="(SysTime.fromSimpleString("2010-Nov-03 06:51:06.57159Z"), SysTime(DateTime(2010, 11, 3, 6, 51, 6), FracSec.from!"hnsecs"(5715900), UTC()));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01.23412Z"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(2_341_200), UTC()));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01.23112-1:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(2_311_200), new SimpleTimeZone(-60)));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01.45-1"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(4_500_000), new SimpleTimeZone(-60)));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01.1-1:30"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(1_000_000), new SimpleTimeZone(-90)));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01.55-8:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(5_500_000), new SimpleTimeZone(-480)));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01.1234567+1:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(1_234_567), new SimpleTimeZone(60)));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01.0+1"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(0), new SimpleTimeZone(60)));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01.0000000+1:30"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(0), new SimpleTimeZone(90)));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01.45+8:00"), SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(4_500_000), new SimpleTimeZone(480)));
//Verify Examples.
assert(SysTime.fromSimpleString("2010-Jul-04 07:06:12") == SysTime(DateTime(2010, 7, 4, 7, 6, 12)));
assert(SysTime.fromSimpleString("1998-Dec-25 02:15:00.007") == SysTime(DateTime(1998, 12, 25, 2, 15, 0), FracSec.from!"msecs"(7)));
assert(SysTime.fromSimpleString("0000-Jan-05 23:09:59.00002") == SysTime(DateTime(0, 1, 5, 23, 9, 59), FracSec.from!"usecs"(20)));
assert(SysTime.fromSimpleString("-0004-Jan-05 00:00:02") == SysTime(DateTime(-4, 1, 5, 0, 0, 2)));
assert(SysTime.fromSimpleString(" 2010-Jul-04 07:06:12 ") == SysTime(DateTime(2010, 7, 4, 7, 6, 12)));
assert(SysTime.fromSimpleString("2010-Jul-04 07:06:12Z") == SysTime(DateTime(2010, 7, 4, 7, 6, 12), UTC()));
assert(SysTime.fromSimpleString("2010-Jul-04 07:06:12-8:00") == SysTime(DateTime(2010, 7, 4, 7, 6, 12), new SimpleTimeZone(-480)));
assert(SysTime.fromSimpleString("2010-Jul-04 07:06:12+8:00") == SysTime(DateTime(2010, 7, 4, 7, 6, 12), new SimpleTimeZone(480)));
}
}
//TODO Add function which takes a user-specified time format and produces a SysTime
//TODO Add function which takes pretty much any time-string and produces a SysTime.
// Obviously, it will be less efficient, and it probably won't manage _every_
// possible date format, but a smart conversion function would be nice.
/++
Returns the $(D SysTime) farthest in the past which is representable
by $(D SysTime).
The $(D SysTime) which is returned is in UTC.
+/
@property static SysTime min() pure nothrow
{
return SysTime(long.min, UTC());
}
unittest
{
version(testStdDateTime)
{
assert(SysTime.min.year < 0);
assert(SysTime.min < SysTime.max);
}
}
/++
Returns the $(D SysTime) farthest in the future which is representable
by $(D SysTime).
The $(D SysTime) which is returned is in UTC.
+/
@property static SysTime max() pure nothrow
{
return SysTime(long.max, UTC());
}
unittest
{
version(testStdDateTime)
{
assert(SysTime.max.year > 0);
assert(SysTime.max > SysTime.min);
}
}
private:
/+
Returns $(D stdTime) converted to $(D SysTime)'s time zone.
+/
@property long adjTime() const nothrow
{
return _timezone.utcToTZ(_stdTime);
}
/+
Converts the given hnsecs from $(D SysTime)'s time zone to std time.
+/
@property void adjTime(long adjTime) nothrow
{
_stdTime = _timezone.tzToUTC(adjTime);
}
//Commented out due to bug http://d.puremagic.com/issues/show_bug.cgi?id=5058
/+
invariant()
{
assert(_timezone !is null, "Invariant Failure: timezone is null. Were you foolish enough to use SysTime.init? (since timezone for SysTime.init can't be set at compile time).");
}
+/
long _stdTime;
Rebindable!(immutable TimeZone) _timezone;
}
/++
Represents a date in the Proleptic Gregorian Calendar ranging from
32,768 B.C. to 32,767 A.D. Positive years are A.D. Non-positive years are
B.C.
Year, month, and day are kept separately internally so that $(D Date) is
optimized for calendar-based operations.
$(D Date) uses the Proleptic Gregorian Calendar, so it assumes the Gregorian
leap year calculations for its entire length. And, as per
$(WEB en.wikipedia.org/wiki/ISO_8601, ISO 8601), it also treats 1 B.C. as
year 0. So, 1 B.C. is 0, 2 B.C. is -1, etc. Use $(D yearBC) if want B.C. as
a positive integer with 1 B.C. being the year prior to 1 A.D.
Year 0 is a leap year.
+/
struct Date
{
public:
/++
Throws:
$(D DateTimeException) if the resulting $(D Date) would not be valid.
Params:
year = Year of the Gregorian Calendar. Positive values are A.D.
Non-positive values are B.C. with year 0 being the year
prior to 1 A.D.
month = Month of the year.
day = Day of the month.
+/
this(int year, int month, int day) pure
{
enforceValid!"months"(cast(Month)month);
enforceValid!"days"(year, cast(Month)month, day);
_year = cast(short)year;
_month = cast(Month)month;
_day = cast(ubyte)day;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(Date(1, 1, 1), Date.init);
static void testDate(in Date date, int year, int month, int day, size_t line = __LINE__)
{
_assertPred!"=="(date._year, year, "", __FILE__, line);
_assertPred!"=="(date._month, month, "", __FILE__, line);
_assertPred!"=="(date._day, day, "", __FILE__, line);
}
testDate(Date(1999, 1 , 1), 1999, Month.jan, 1);
testDate(Date(1999, 7 , 1), 1999, Month.jul, 1);
testDate(Date(1999, 7 , 6), 1999, Month.jul, 6);
//Test A.D.
assertThrown!DateTimeException(Date(1, 0, 1));
assertThrown!DateTimeException(Date(1, 1, 0));
assertThrown!DateTimeException(Date(1999, 13, 1));
assertThrown!DateTimeException(Date(1999, 1, 32));
assertThrown!DateTimeException(Date(1999, 2, 29));
assertThrown!DateTimeException(Date(2000, 2, 30));
assertThrown!DateTimeException(Date(1999, 3, 32));
assertThrown!DateTimeException(Date(1999, 4, 31));
assertThrown!DateTimeException(Date(1999, 5, 32));
assertThrown!DateTimeException(Date(1999, 6, 31));
assertThrown!DateTimeException(Date(1999, 7, 32));
assertThrown!DateTimeException(Date(1999, 8, 32));
assertThrown!DateTimeException(Date(1999, 9, 31));
assertThrown!DateTimeException(Date(1999, 10, 32));
assertThrown!DateTimeException(Date(1999, 11, 31));
assertThrown!DateTimeException(Date(1999, 12, 32));
assertNotThrown!DateTimeException(Date(1999, 1, 31));
assertNotThrown!DateTimeException(Date(1999, 2, 28));
assertNotThrown!DateTimeException(Date(2000, 2, 29));
assertNotThrown!DateTimeException(Date(1999, 3, 31));
assertNotThrown!DateTimeException(Date(1999, 4, 30));
assertNotThrown!DateTimeException(Date(1999, 5, 31));
assertNotThrown!DateTimeException(Date(1999, 6, 30));
assertNotThrown!DateTimeException(Date(1999, 7, 31));
assertNotThrown!DateTimeException(Date(1999, 8, 31));
assertNotThrown!DateTimeException(Date(1999, 9, 30));
assertNotThrown!DateTimeException(Date(1999, 10, 31));
assertNotThrown!DateTimeException(Date(1999, 11, 30));
assertNotThrown!DateTimeException(Date(1999, 12, 31));
//Test B.C.
assertNotThrown!DateTimeException(Date(0, 1, 1));
assertNotThrown!DateTimeException(Date(-1, 1, 1));
assertNotThrown!DateTimeException(Date(-1, 12, 31));
assertNotThrown!DateTimeException(Date(-1, 2, 28));
assertNotThrown!DateTimeException(Date(-4, 2, 29));
assertThrown!DateTimeException(Date(-1, 2, 29));
assertThrown!DateTimeException(Date(-2, 2, 29));
assertThrown!DateTimeException(Date(-3, 2, 29));
}
}
/++
Params:
day = The Xth day of the Gregorian Calendar that the constructed
$(D Date) will be for.
+/
this(int day) pure nothrow
{
if(day > 0)
{
int years = (day / daysIn400Years) * 400 + 1;
day %= daysIn400Years;
{
immutable tempYears = day / daysIn100Years;
if(tempYears == 4)
{
years += 300;
day -= daysIn100Years * 3;
}
else
{
years += tempYears * 100;
day %= daysIn100Years;
}
}
years += (day / daysIn4Years) * 4;
day %= daysIn4Years;
{
immutable tempYears = day / daysInYear;
if(tempYears == 4)
{
years += 3;
day -= daysInYear * 3;
}
else
{
years += tempYears;
day %= daysInYear;
}
}
if(day == 0)
{
_year = cast(short)(years - 1);
_month = Month.dec;
_day = 31;
}
else
{
_year = cast(short)years;
try
dayOfYear = day;
catch(Exception e)
assert(0, "dayOfYear assignment threw.");
}
}
else if(day <= 0 && -day < daysInLeapYear)
{
_year = 0;
try
dayOfYear = (daysInLeapYear + day);
catch(Exception e)
assert(0, "dayOfYear assignment threw.");
}
else
{
day += daysInLeapYear - 1;
int years = (day / daysIn400Years) * 400 - 1;
day %= daysIn400Years;
{
immutable tempYears = day / daysIn100Years;
if(tempYears == -4)
{
years -= 300;
day += daysIn100Years * 3;
}
else
{
years += tempYears * 100;
day %= daysIn100Years;
}
}
years += (day / daysIn4Years) * 4;
day %= daysIn4Years;
{
immutable tempYears = day / daysInYear;
if(tempYears == -4)
{
years -= 3;
day += daysInYear * 3;
}
else
{
years += tempYears;
day %= daysInYear;
}
}
if(day == 0)
{
_year = cast(short)(years + 1);
_month = Month.jan;
_day = 1;
}
else
{
_year = cast(short)years;
immutable newDoY = (yearIsLeapYear(_year) ? daysInLeapYear : daysInYear) + day + 1;
try
dayOfYear = newDoY;
catch(Exception e)
assert(0, "dayOfYear assignment threw.");
}
}
}
version(testStdDateTime) unittest
{
//Test A.D.
foreach(gd; chain(testGregDaysBC, testGregDaysAD))
_assertPred!"=="(Date(gd.day), gd.date);
}
/++
Compares this $(D Date) with the given $(D Date).
Returns:
$(BOOKTABLE,
$(TR $(TD this < rhs) $(TD < 0))
$(TR $(TD this == rhs) $(TD 0))
$(TR $(TD this > rhs) $(TD > 0))
)
+/
int opCmp(in Date rhs) const pure nothrow
{
if(_year < rhs._year)
return -1;
if(_year > rhs._year)
return 1;
if(_month < rhs._month)
return -1;
if(_month > rhs._month)
return 1;
if(_day < rhs._day)
return -1;
if(_day > rhs._day)
return 1;
return 0;
}
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!("opCmp", "==")(Date(1, 1, 1), Date.init);
_assertPred!("opCmp", "==")(Date(1999, 1, 1), Date(1999, 1, 1));
_assertPred!("opCmp", "==")(Date(1, 7, 1), Date(1, 7, 1));
_assertPred!("opCmp", "==")(Date(1, 1, 6), Date(1, 1, 6));
_assertPred!("opCmp", "==")(Date(1999, 7, 1), Date(1999, 7, 1));
_assertPred!("opCmp", "==")(Date(1999, 7, 6), Date(1999, 7, 6));
_assertPred!("opCmp", "==")(Date(1, 7, 6), Date(1, 7, 6));
_assertPred!("opCmp", "<")(Date(1999, 7, 6), Date(2000, 7, 6));
_assertPred!("opCmp", ">")(Date(2000, 7, 6), Date(1999, 7, 6));
_assertPred!("opCmp", "<")(Date(1999, 7, 6), Date(1999, 8, 6));
_assertPred!("opCmp", ">")(Date(1999, 8, 6), Date(1999, 7, 6));
_assertPred!("opCmp", "<")(Date(1999, 7, 6), Date(1999, 7, 7));
_assertPred!("opCmp", ">")(Date(1999, 7, 7), Date(1999, 7, 6));
_assertPred!("opCmp", "<")(Date(1999, 8, 7), Date(2000, 7, 6));
_assertPred!("opCmp", ">")(Date(2000, 8, 6), Date(1999, 7, 7));
_assertPred!("opCmp", "<")(Date(1999, 7, 7), Date(2000, 7, 6));
_assertPred!("opCmp", ">")(Date(2000, 7, 6), Date(1999, 7, 7));
_assertPred!("opCmp", "<")(Date(1999, 7, 7), Date(1999, 8, 6));
_assertPred!("opCmp", ">")(Date(1999, 8, 6), Date(1999, 7, 7));
//Test B.C.
_assertPred!("opCmp", "==")(Date(0, 1, 1), Date(0, 1, 1));
_assertPred!("opCmp", "==")(Date(-1, 1, 1), Date(-1, 1, 1));
_assertPred!("opCmp", "==")(Date(-1, 7, 1), Date(-1, 7, 1));
_assertPred!("opCmp", "==")(Date(-1, 1, 6), Date(-1, 1, 6));
_assertPred!("opCmp", "==")(Date(-1999, 7, 1), Date(-1999, 7, 1));
_assertPred!("opCmp", "==")(Date(-1999, 7, 6), Date(-1999, 7, 6));
_assertPred!("opCmp", "==")(Date(-1, 7, 6), Date(-1, 7, 6));
_assertPred!("opCmp", "<")(Date(-2000, 7, 6), Date(-1999, 7, 6));
_assertPred!("opCmp", ">")(Date(-1999, 7, 6), Date(-2000, 7, 6));
_assertPred!("opCmp", "<")(Date(-1999, 7, 6), Date(-1999, 8, 6));
_assertPred!("opCmp", ">")(Date(-1999, 8, 6), Date(-1999, 7, 6));
_assertPred!("opCmp", "<")(Date(-1999, 7, 6), Date(-1999, 7, 7));
_assertPred!("opCmp", ">")(Date(-1999, 7, 7), Date(-1999, 7, 6));
_assertPred!("opCmp", "<")(Date(-2000, 8, 6), Date(-1999, 7, 7));
_assertPred!("opCmp", ">")(Date(-1999, 8, 7), Date(-2000, 7, 6));
_assertPred!("opCmp", "<")(Date(-2000, 7, 6), Date(-1999, 7, 7));
_assertPred!("opCmp", ">")(Date(-1999, 7, 7), Date(-2000, 7, 6));
_assertPred!("opCmp", "<")(Date(-1999, 7, 7), Date(-1999, 8, 6));
_assertPred!("opCmp", ">")(Date(-1999, 8, 6), Date(-1999, 7, 7));
//Test Both
_assertPred!("opCmp", "<")(Date(-1999, 7, 6), Date(1999, 7, 6));
_assertPred!("opCmp", ">")(Date(1999, 7, 6), Date(-1999, 7, 6));
_assertPred!("opCmp", "<")(Date(-1999, 8, 6), Date(1999, 7, 6));
_assertPred!("opCmp", ">")(Date(1999, 7, 6), Date(-1999, 8, 6));
_assertPred!("opCmp", "<")(Date(-1999, 7, 7), Date(1999, 7, 6));
_assertPred!("opCmp", ">")(Date(1999, 7, 6), Date(-1999, 7, 7));
_assertPred!("opCmp", "<")(Date(-1999, 8, 7), Date(1999, 7, 6));
_assertPred!("opCmp", ">")(Date(1999, 7, 6), Date(-1999, 8, 7));
_assertPred!("opCmp", "<")(Date(-1999, 8, 6), Date(1999, 6, 6));
_assertPred!("opCmp", ">")(Date(1999, 6, 8), Date(-1999, 7, 6));
auto date = Date(1999, 7, 6);
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, date.opCmp(date)));
static assert(__traits(compiles, date.opCmp(cdate)));
static assert(__traits(compiles, date.opCmp(idate)));
static assert(__traits(compiles, cdate.opCmp(date)));
static assert(__traits(compiles, cdate.opCmp(cdate)));
static assert(__traits(compiles, cdate.opCmp(idate)));
static assert(__traits(compiles, idate.opCmp(date)));
static assert(__traits(compiles, idate.opCmp(cdate)));
static assert(__traits(compiles, idate.opCmp(idate)));
}
}
/++
Year of the Gregorian Calendar. Positive numbers are A.D. Non-positive
are B.C.
Examples:
--------------------
assert(Date(1999, 7, 6).year == 1999);
assert(Date(2010, 10, 4).year == 2010);
assert(Date(-7, 4, 5).year == -7);
--------------------
+/
@property short year() const pure nothrow
{
return _year;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(Date.init.year, 1);
_assertPred!"=="(Date(1999, 7, 6).year, 1999);
_assertPred!"=="(Date(-1999, 7, 6).year, -1999);
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, cdate.year == 1999));
static assert(__traits(compiles, idate.year == 1999));
//Verify Examples.
assert(Date(1999, 7, 6).year == 1999);
assert(Date(2010, 10, 4).year == 2010);
assert(Date(-7, 4, 5).year == -7);
}
}
/++
Year of the Gregorian Calendar. Positive numbers are A.D. Non-positive
are B.C.
Params:
year = The year to set this Date's year to.
Throws:
$(D DateTimeException) if the new year is not a leap year and the
resulting date would be on February 29th.
+/
@property void year(int year) pure
{
enforceValid!"days"(year, _month, _day);
_year = cast(short)year;
}
unittest
{
version(testStdDateTime)
{
static void testDateInvalid(Date date, int year)
{
date.year = year;
}
static void testDate(Date date, int year, in Date expected, size_t line = __LINE__)
{
date.year = year;
_assertPred!"=="(date, expected, "", __FILE__, line);
}
assertThrown!DateTimeException(testDateInvalid(Date(4, 2, 29), 1));
testDate(Date(1, 1, 1), 1999, Date(1999, 1, 1));
testDate(Date(1, 1, 1), 0, Date(0, 1, 1));
testDate(Date(1, 1, 1), -1999, Date(-1999, 1, 1));
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(!__traits(compiles, cdate.year = 1999));
static assert(!__traits(compiles, idate.year = 1999));
//Verify Examples.
assert(Date(1999, 7, 6).year == 1999);
assert(Date(2010, 10, 4).year == 2010);
assert(Date(-7, 4, 5).year == -7);
}
}
/++
Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.
Throws:
$(D DateTimeException) if $(D isAD) is true.
Examples:
--------------------
assert(Date(0, 1, 1).yearBC == 1);
assert(Date(-1, 1, 1).yearBC == 2);
assert(Date(-100, 1, 1).yearBC == 101);
--------------------
+/
@property ushort yearBC() const pure
{
if(isAD)
throw new DateTimeException("Year " ~ numToString(_year) ~ " is A.D.");
//Once format is pure, this would be a better error message.
//throw new DateTimeException(format("%s is A.D.", this));
return cast(ushort)((_year * -1) + 1);
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException((in Date date){date.yearBC;}(Date(1, 1, 1)));
auto date = Date(0, 7, 6);
const cdate = Date(0, 7, 6);
immutable idate = Date(0, 7, 6);
static assert(__traits(compiles, date.yearBC));
static assert(__traits(compiles, cdate.yearBC));
static assert(__traits(compiles, idate.yearBC));
//Verify Examples.
assert(Date(0, 1, 1).yearBC == 1);
assert(Date(-1, 1, 1).yearBC == 2);
assert(Date(-100, 1, 1).yearBC == 101);
}
}
/++
Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.
Params:
year = The year B.C. to set this $(D Date)'s year to.
Throws:
$(D DateTimeException) if a non-positive value is given.
Examples:
--------------------
auto date = Date(2010, 1, 1);
date.yearBC = 1;
assert(date == Date(0, 1, 1));
date.yearBC = 10;
assert(date == Date(-9, 1, 1));
--------------------
+/
@property void yearBC(int year) pure
{
if(year <= 0)
throw new DateTimeException("The given year is not a year B.C.");
_year = cast(short)((year - 1) * -1);
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException((Date date){date.yearBC = -1;}(Date(1, 1, 1)));
{
auto date = Date(0, 7, 6);
const cdate = Date(0, 7, 6);
immutable idate = Date(0, 7, 6);
static assert(__traits(compiles, date.yearBC = 7));
static assert(!__traits(compiles, cdate.yearBC = 7));
static assert(!__traits(compiles, idate.yearBC = 7));
}
//Verify Examples.
{
auto date = Date(2010, 1, 1);
date.yearBC = 1;
assert(date == Date(0, 1, 1));
date.yearBC = 10;
assert(date == Date(-9, 1, 1));
}
}
}
/++
Month of a Gregorian Year.
Examples:
--------------------
assert(Date(1999, 7, 6).month == 7);
assert(Date(2010, 10, 4).month == 10);
assert(Date(-7, 4, 5).month == 4);
--------------------
+/
@property Month month() const pure nothrow
{
return _month;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(Date.init.month, 1);
_assertPred!"=="(Date(1999, 7, 6).month, 7);
_assertPred!"=="(Date(-1999, 7, 6).month, 7);
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, cdate.month == 7));
static assert(__traits(compiles, idate.month == 7));
//Verify Examples.
assert(Date(1999, 7, 6).month == 7);
assert(Date(2010, 10, 4).month == 10);
assert(Date(-7, 4, 5).month == 4);
}
}
/++
Month of a Gregorian Year.
Params:
month = The month to set this $(D Date)'s month to.
Throws:
$(D DateTimeException) if the given month is not a valid month or if
the current day would not be valid in the given month.
+/
@property void month(Month month) pure
{
enforceValid!"months"(month);
enforceValid!"days"(_year, month, _day);
_month = cast(Month)month;
}
unittest
{
version(testStdDateTime)
{
static void testDate(Date date, Month month, in Date expected = Date.init, size_t line = __LINE__)
{
date.month = month;
assert(expected != Date.init);
_assertPred!"=="(date, expected, "", __FILE__, line);
}
assertThrown!DateTimeException(testDate(Date(1, 1, 1), cast(Month)0));
assertThrown!DateTimeException(testDate(Date(1, 1, 1), cast(Month)13));
assertThrown!DateTimeException(testDate(Date(1, 1, 29), cast(Month)2));
assertThrown!DateTimeException(testDate(Date(0, 1, 30), cast(Month)2));
testDate(Date(1, 1, 1), cast(Month)7, Date(1, 7, 1));
testDate(Date(-1, 1, 1), cast(Month)7, Date(-1, 7, 1));
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(!__traits(compiles, cdate.month = 7));
static assert(!__traits(compiles, idate.month = 7));
}
}
/++
Day of a Gregorian Month.
Examples:
--------------------
assert(Date(1999, 7, 6).day == 6);
assert(Date(2010, 10, 4).day == 4);
assert(Date(-7, 4, 5).day == 5);
--------------------
+/
@property ubyte day() const pure nothrow
{
return _day;
}
//Verify Examples.
version(testStdDateTime) unittest
{
assert(Date(1999, 7, 6).day == 6);
assert(Date(2010, 10, 4).day == 4);
assert(Date(-7, 4, 5).day == 5);
}
version(testStdDateTime) unittest
{
static void test(Date date, int expected, size_t line = __LINE__)
{
_assertPred!"=="(date.day, expected,
format("Value given: %s", date), __FILE__, line);
}
foreach(year; chain(testYearsBC, testYearsAD))
{
foreach(md; testMonthDays)
test(Date(year, md.month, md.day), md.day);
}
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, cdate.day == 6));
static assert(__traits(compiles, idate.day == 6));
}
/++
Day of a Gregorian Month.
Params:
day = The day of the month to set this $(D Date)'s day to.
Throws:
$(D DateTimeException) if the given day is not a valid day of the
current month.
+/
@property void day(int day) pure
{
enforceValid!"days"(_year, _month, day);
_day = cast(ubyte)day;
}
unittest
{
version(testStdDateTime)
{
static void testDate(Date date, int day)
{
date.day = day;
}
//Test A.D.
assertThrown!DateTimeException(testDate(Date(1, 1, 1), 0));
assertThrown!DateTimeException(testDate(Date(1, 1, 1), 32));
assertThrown!DateTimeException(testDate(Date(1, 2, 1), 29));
assertThrown!DateTimeException(testDate(Date(4, 2, 1), 30));
assertThrown!DateTimeException(testDate(Date(1, 3, 1), 32));
assertThrown!DateTimeException(testDate(Date(1, 4, 1), 31));
assertThrown!DateTimeException(testDate(Date(1, 5, 1), 32));
assertThrown!DateTimeException(testDate(Date(1, 6, 1), 31));
assertThrown!DateTimeException(testDate(Date(1, 7, 1), 32));
assertThrown!DateTimeException(testDate(Date(1, 8, 1), 32));
assertThrown!DateTimeException(testDate(Date(1, 9, 1), 31));
assertThrown!DateTimeException(testDate(Date(1, 10, 1), 32));
assertThrown!DateTimeException(testDate(Date(1, 11, 1), 31));
assertThrown!DateTimeException(testDate(Date(1, 12, 1), 32));
assertNotThrown!DateTimeException(testDate(Date(1, 1, 1), 31));
assertNotThrown!DateTimeException(testDate(Date(1, 2, 1), 28));
assertNotThrown!DateTimeException(testDate(Date(4, 2, 1), 29));
assertNotThrown!DateTimeException(testDate(Date(1, 3, 1), 31));
assertNotThrown!DateTimeException(testDate(Date(1, 4, 1), 30));
assertNotThrown!DateTimeException(testDate(Date(1, 5, 1), 31));
assertNotThrown!DateTimeException(testDate(Date(1, 6, 1), 30));
assertNotThrown!DateTimeException(testDate(Date(1, 7, 1), 31));
assertNotThrown!DateTimeException(testDate(Date(1, 8, 1), 31));
assertNotThrown!DateTimeException(testDate(Date(1, 9, 1), 30));
assertNotThrown!DateTimeException(testDate(Date(1, 10, 1), 31));
assertNotThrown!DateTimeException(testDate(Date(1, 11, 1), 30));
assertNotThrown!DateTimeException(testDate(Date(1, 12, 1), 31));
{
auto date = Date(1, 1, 1);
date.day = 6;
_assertPred!"=="(date, Date(1, 1, 6));
}
//Test B.C.
assertThrown!DateTimeException(testDate(Date(-1, 1, 1), 0));
assertThrown!DateTimeException(testDate(Date(-1, 1, 1), 32));
assertThrown!DateTimeException(testDate(Date(-1, 2, 1), 29));
assertThrown!DateTimeException(testDate(Date(0, 2, 1), 30));
assertThrown!DateTimeException(testDate(Date(-1, 3, 1), 32));
assertThrown!DateTimeException(testDate(Date(-1, 4, 1), 31));
assertThrown!DateTimeException(testDate(Date(-1, 5, 1), 32));
assertThrown!DateTimeException(testDate(Date(-1, 6, 1), 31));
assertThrown!DateTimeException(testDate(Date(-1, 7, 1), 32));
assertThrown!DateTimeException(testDate(Date(-1, 8, 1), 32));
assertThrown!DateTimeException(testDate(Date(-1, 9, 1), 31));
assertThrown!DateTimeException(testDate(Date(-1, 10, 1), 32));
assertThrown!DateTimeException(testDate(Date(-1, 11, 1), 31));
assertThrown!DateTimeException(testDate(Date(-1, 12, 1), 32));
assertNotThrown!DateTimeException(testDate(Date(-1, 1, 1), 31));
assertNotThrown!DateTimeException(testDate(Date(-1, 2, 1), 28));
assertNotThrown!DateTimeException(testDate(Date(0, 2, 1), 29));
assertNotThrown!DateTimeException(testDate(Date(-1, 3, 1), 31));
assertNotThrown!DateTimeException(testDate(Date(-1, 4, 1), 30));
assertNotThrown!DateTimeException(testDate(Date(-1, 5, 1), 31));
assertNotThrown!DateTimeException(testDate(Date(-1, 6, 1), 30));
assertNotThrown!DateTimeException(testDate(Date(-1, 7, 1), 31));
assertNotThrown!DateTimeException(testDate(Date(-1, 8, 1), 31));
assertNotThrown!DateTimeException(testDate(Date(-1, 9, 1), 30));
assertNotThrown!DateTimeException(testDate(Date(-1, 10, 1), 31));
assertNotThrown!DateTimeException(testDate(Date(-1, 11, 1), 30));
assertNotThrown!DateTimeException(testDate(Date(-1, 12, 1), 31));
{
auto date = Date(-1, 1, 1);
date.day = 6;
_assertPred!"=="(date, Date(-1, 1, 6));
}
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(!__traits(compiles, cdate.day = 6));
static assert(!__traits(compiles, idate.day = 6));
}
}
/++
Adds the given number of years or months to this $(D Date). A negative
number will subtract.
Note that if day overflow is allowed, and the date with the adjusted
year/month overflows the number of days in the new month, then the month
will be incremented by one, and the day set to the number of days
overflowed. (e.g. if the day were 31 and the new month were June, then
the month would be incremented to July, and the new day would be 1). If
day overflow is not allowed, then the day will be set to the last valid
day in the month (e.g. June 31st would become June 30th).
Params:
units = The type of units to add ("years" or "months").
value = The number of months or years to add to this
$(D Date).
allowOverflow = Whether the day should be allowed to overflow,
causing the month to increment.
Examples:
--------------------
auto d1 = Date(2010, 1, 1);
d1.add!"months"(11);
assert(d1 == Date(2010, 12, 1));
auto d2 = Date(2010, 1, 1);
d2.add!"months"(-11);
assert(d2 == Date(2009, 2, 1));
auto d3 = Date(2000, 2, 29);
d3.add!"years"(1);
assert(d3 == Date(2001, 3, 1));
auto d4 = Date(2000, 2, 29);
d4.add!"years"(1, AllowDayOverflow.no);
assert(d4 == Date(2001, 2, 28));
--------------------
+/
/+ref Date+/ void add(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) pure nothrow
if(units == "years")
{
immutable newYear = _year + value;
_year += value;
if(_month == Month.feb && _day == 29 && !yearIsLeapYear(_year))
{
if(allowOverflow == AllowDayOverflow.yes)
{
_month = Month.mar;
_day = 1;
}
else
_day = 28;
}
}
//Verify Examples.
unittest
{
version(stdStdDateTime)
{
auto d1 = Date(2010, 1, 1);
d1.add!"months"(11);
assert(d1 == Date(2010, 12, 1));
auto d2 = Date(2010, 1, 1);
d2.add!"months"(-11);
assert(d2 == Date(2009, 2, 1));
auto d3 = Date(2000, 2, 29);
d3.add!"years"(1);
assert(d3 == Date(2001, 3, 1));
auto d4 = Date(2000, 2, 29);
d4.add!"years"(1, AllowDayOverflow.no);
assert(d4 == Date(2001, 2, 28));
}
}
//Test add!"years"() with AllowDayOverlow.yes
unittest
{
version(testStdDateTime)
{
//Test A.D.
{
auto date = Date(1999, 7, 6);
date.add!"years"(7);
_assertPred!"=="(date, Date(2006, 7, 6));
date.add!"years"(-9);
_assertPred!"=="(date, Date(1997, 7, 6));
}
{
auto date = Date(1999, 2, 28);
date.add!"years"(1);
_assertPred!"=="(date, Date(2000, 2, 28));
}
{
auto date = Date(2000, 2, 29);
date.add!"years"(-1);
_assertPred!"=="(date, Date(1999, 3, 1));
}
//Test B.C.
{
auto date = Date(-1999, 7, 6);
date.add!"years"(-7);
_assertPred!"=="(date, Date(-2006, 7, 6));
date.add!"years"(9);
_assertPred!"=="(date, Date(-1997, 7, 6));
}
{
auto date = Date(-1999, 2, 28);
date.add!"years"(-1);
_assertPred!"=="(date, Date(-2000, 2, 28));
}
{
auto date = Date(-2000, 2, 29);
date.add!"years"(1);
_assertPred!"=="(date, Date(-1999, 3, 1));
}
//Test Both
{
auto date = Date(4, 7, 6);
date.add!"years"(-5);
_assertPred!"=="(date, Date(-1, 7, 6));
date.add!"years"(5);
_assertPred!"=="(date, Date(4, 7, 6));
}
{
auto date = Date(-4, 7, 6);
date.add!"years"(5);
_assertPred!"=="(date, Date(1, 7, 6));
date.add!"years"(-5);
_assertPred!"=="(date, Date(-4, 7, 6));
}
{
auto date = Date(4, 7, 6);
date.add!"years"(-8);
_assertPred!"=="(date, Date(-4, 7, 6));
date.add!"years"(8);
_assertPred!"=="(date, Date(4, 7, 6));
}
{
auto date = Date(-4, 7, 6);
date.add!"years"(8);
_assertPred!"=="(date, Date(4, 7, 6));
date.add!"years"(-8);
_assertPred!"=="(date, Date(-4, 7, 6));
}
{
auto date = Date(-4, 2, 29);
date.add!"years"(5);
_assertPred!"=="(date, Date(1, 3, 1));
}
{
auto date = Date(4, 2, 29);
date.add!"years"(-5);
_assertPred!"=="(date, Date(-1, 3, 1));
}
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(!__traits(compiles, cdate.add!"years"(7)));
static assert(!__traits(compiles, idate.add!"years"(7)));
}
}
//Test add!"years"() with AllowDayOverlow.no
unittest
{
version(testStdDateTime)
{
//Test A.D.
{
auto date = Date(1999, 7, 6);
date.add!"years"(7, AllowDayOverflow.no);
_assertPred!"=="(date, Date(2006, 7, 6));
date.add!"years"(-9, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1997, 7, 6));
}
{
auto date = Date(1999, 2, 28);
date.add!"years"(1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(2000, 2, 28));
}
{
auto date = Date(2000, 2, 29);
date.add!"years"(-1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 2, 28));
}
//Test B.C.
{
auto date = Date(-1999, 7, 6);
date.add!"years"(-7, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-2006, 7, 6));
date.add!"years"(9, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1997, 7, 6));
}
{
auto date = Date(-1999, 2, 28);
date.add!"years"(-1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-2000, 2, 28));
}
{
auto date = Date(-2000, 2, 29);
date.add!"years"(1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 2, 28));
}
//Test Both
{
auto date = Date(4, 7, 6);
date.add!"years"(-5, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1, 7, 6));
date.add!"years"(5, AllowDayOverflow.no);
_assertPred!"=="(date, Date(4, 7, 6));
}
{
auto date = Date(-4, 7, 6);
date.add!"years"(5, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1, 7, 6));
date.add!"years"(-5, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-4, 7, 6));
}
{
auto date = Date(4, 7, 6);
date.add!"years"(-8, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-4, 7, 6));
date.add!"years"(8, AllowDayOverflow.no);
_assertPred!"=="(date, Date(4, 7, 6));
}
{
auto date = Date(-4, 7, 6);
date.add!"years"(8, AllowDayOverflow.no);
_assertPred!"=="(date, Date(4, 7, 6));
date.add!"years"(-8, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-4, 7, 6));
}
{
auto date = Date(-4, 2, 29);
date.add!"years"(5, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1, 2, 28));
}
{
auto date = Date(4, 2, 29);
date.add!"years"(-5, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1, 2, 28));
}
}
}
//Shares documentation with "years" version.
/+ref Date+/ void add(string units)(long months, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) pure nothrow
if(units == "months")
{
auto years = months / 12;
months %= 12;
auto newMonth = _month + months;
if(months < 0)
{
if(newMonth < 1)
{
newMonth += 12;
--years;
}
}
else if(newMonth > 12)
{
newMonth -= 12;
++years;
}
_year += years;
_month = cast(Month)newMonth;
immutable currMaxDay = maxDay(_year, _month);
immutable overflow = _day - currMaxDay;
if(overflow > 0)
{
if(allowOverflow == AllowDayOverflow.yes)
{
++_month;
_day = cast(ubyte)overflow;
}
else
_day = cast(ubyte)currMaxDay;
}
}
//Test add!"months"() with AllowDayOverlow.yes
unittest
{
version(testStdDateTime)
{
//Test A.D.
{
auto date = Date(1999, 7, 6);
date.add!"months"(3);
_assertPred!"=="(date, Date(1999, 10, 6));
date.add!"months"(-4);
_assertPred!"=="(date, Date(1999, 6, 6));
}
{
auto date = Date(1999, 7, 6);
date.add!"months"(6);
_assertPred!"=="(date, Date(2000, 1, 6));
date.add!"months"(-6);
_assertPred!"=="(date, Date(1999, 7, 6));
}
{
auto date = Date(1999, 7, 6);
date.add!"months"(27);
_assertPred!"=="(date, Date(2001, 10, 6));
date.add!"months"(-28);
_assertPred!"=="(date, Date(1999, 6, 6));
}
{
auto date = Date(1999, 5, 31);
date.add!"months"(1);
_assertPred!"=="(date, Date(1999, 7, 1));
}
{
auto date = Date(1999, 5, 31);
date.add!"months"(-1);
_assertPred!"=="(date, Date(1999, 5, 1));
}
{
auto date = Date(1999, 2, 28);
date.add!"months"(12);
_assertPred!"=="(date, Date(2000, 2, 28));
}
{
auto date = Date(2000, 2, 29);
date.add!"months"(12);
_assertPred!"=="(date, Date(2001, 3, 1));
}
{
auto date = Date(1999, 7, 31);
date.add!"months"(1);
_assertPred!"=="(date, Date(1999, 8, 31));
date.add!"months"(1);
_assertPred!"=="(date, Date(1999, 10, 1));
}
{
auto date = Date(1998, 8, 31);
date.add!"months"(13);
_assertPred!"=="(date, Date(1999, 10, 1));
date.add!"months"(-13);
_assertPred!"=="(date, Date(1998, 9, 1));
}
{
auto date = Date(1997, 12, 31);
date.add!"months"(13);
_assertPred!"=="(date, Date(1999, 1, 31));
date.add!"months"(-13);
_assertPred!"=="(date, Date(1997, 12, 31));
}
{
auto date = Date(1997, 12, 31);
date.add!"months"(14);
_assertPred!"=="(date, Date(1999, 3, 3));
date.add!"months"(-14);
_assertPred!"=="(date, Date(1998, 1, 3));
}
{
auto date = Date(1998, 12, 31);
date.add!"months"(14);
_assertPred!"=="(date, Date(2000, 3, 2));
date.add!"months"(-14);
_assertPred!"=="(date, Date(1999, 1, 2));
}
{
auto date = Date(1999, 12, 31);
date.add!"months"(14);
_assertPred!"=="(date, Date(2001, 3, 3));
date.add!"months"(-14);
_assertPred!"=="(date, Date(2000, 1, 3));
}
//Test B.C.
{
auto date = Date(-1999, 7, 6);
date.add!"months"(3);
_assertPred!"=="(date, Date(-1999, 10, 6));
date.add!"months"(-4);
_assertPred!"=="(date, Date(-1999, 6, 6));
}
{
auto date = Date(-1999, 7, 6);
date.add!"months"(6);
_assertPred!"=="(date, Date(-1998, 1, 6));
date.add!"months"(-6);
_assertPred!"=="(date, Date(-1999, 7, 6));
}
{
auto date = Date(-1999, 7, 6);
date.add!"months"(-27);
_assertPred!"=="(date, Date(-2001, 4, 6));
date.add!"months"(28);
_assertPred!"=="(date, Date(-1999, 8, 6));
}
{
auto date = Date(-1999, 5, 31);
date.add!"months"(1);
_assertPred!"=="(date, Date(-1999, 7, 1));
}
{
auto date = Date(-1999, 5, 31);
date.add!"months"(-1);
_assertPred!"=="(date, Date(-1999, 5, 1));
}
{
auto date = Date(-1999, 2, 28);
date.add!"months"(-12);
_assertPred!"=="(date, Date(-2000, 2, 28));
}
{
auto date = Date(-2000, 2, 29);
date.add!"months"(-12);
_assertPred!"=="(date, Date(-2001, 3, 1));
}
{
auto date = Date(-1999, 7, 31);
date.add!"months"(1);
_assertPred!"=="(date, Date(-1999, 8, 31));
date.add!"months"(1);
_assertPred!"=="(date, Date(-1999, 10, 1));
}
{
auto date = Date(-1998, 8, 31);
date.add!"months"(13);
_assertPred!"=="(date, Date(-1997, 10, 1));
date.add!"months"(-13);
_assertPred!"=="(date, Date(-1998, 9, 1));
}
{
auto date = Date(-1997, 12, 31);
date.add!"months"(13);
_assertPred!"=="(date, Date(-1995, 1, 31));
date.add!"months"(-13);
_assertPred!"=="(date, Date(-1997, 12, 31));
}
{
auto date = Date(-1997, 12, 31);
date.add!"months"(14);
_assertPred!"=="(date, Date(-1995, 3, 3));
date.add!"months"(-14);
_assertPred!"=="(date, Date(-1996, 1, 3));
}
{
auto date = Date(-2002, 12, 31);
date.add!"months"(14);
_assertPred!"=="(date, Date(-2000, 3, 2));
date.add!"months"(-14);
_assertPred!"=="(date, Date(-2001, 1, 2));
}
{
auto date = Date(-2001, 12, 31);
date.add!"months"(14);
_assertPred!"=="(date, Date(-1999, 3, 3));
date.add!"months"(-14);
_assertPred!"=="(date, Date(-2000, 1, 3));
}
//Test Both
{
auto date = Date(1, 1, 1);
date.add!"months"(-1);
_assertPred!"=="(date, Date(0, 12, 1));
date.add!"months"(1);
_assertPred!"=="(date, Date(1, 1, 1));
}
{
auto date = Date(4, 1, 1);
date.add!"months"(-48);
_assertPred!"=="(date, Date(0, 1, 1));
date.add!"months"(48);
_assertPred!"=="(date, Date(4, 1, 1));
}
{
auto date = Date(4, 3, 31);
date.add!"months"(-49);
_assertPred!"=="(date, Date(0, 3, 2));
date.add!"months"(49);
_assertPred!"=="(date, Date(4, 4, 2));
}
{
auto date = Date(4, 3, 31);
date.add!"months"(-85);
_assertPred!"=="(date, Date(-3, 3, 3));
date.add!"months"(85);
_assertPred!"=="(date, Date(4, 4, 3));
}
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(!__traits(compiles, cdate.add!"months"(3)));
static assert(!__traits(compiles, idate.add!"months"(3)));
}
}
//Test add!"months"() with AllowDayOverlow.no
unittest
{
version(testStdDateTime)
{
//Test A.D.
{
auto date = Date(1999, 7, 6);
date.add!"months"(3, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 10, 6));
date.add!"months"(-4, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 6, 6));
}
{
auto date = Date(1999, 7, 6);
date.add!"months"(6, AllowDayOverflow.no);
_assertPred!"=="(date, Date(2000, 1, 6));
date.add!"months"(-6, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 7, 6));
}
{
auto date = Date(1999, 7, 6);
date.add!"months"(27, AllowDayOverflow.no);
_assertPred!"=="(date, Date(2001, 10, 6));
date.add!"months"(-28, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 6, 6));
}
{
auto date = Date(1999, 5, 31);
date.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 6, 30));
}
{
auto date = Date(1999, 5, 31);
date.add!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 4, 30));
}
{
auto date = Date(1999, 2, 28);
date.add!"months"(12, AllowDayOverflow.no);
_assertPred!"=="(date, Date(2000, 2, 28));
}
{
auto date = Date(2000, 2, 29);
date.add!"months"(12, AllowDayOverflow.no);
_assertPred!"=="(date, Date(2001, 2, 28));
}
{
auto date = Date(1999, 7, 31);
date.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 8, 31));
date.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 9, 30));
}
{
auto date = Date(1998, 8, 31);
date.add!"months"(13, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 9, 30));
date.add!"months"(-13, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1998, 8, 30));
}
{
auto date = Date(1997, 12, 31);
date.add!"months"(13, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 1, 31));
date.add!"months"(-13, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1997, 12, 31));
}
{
auto date = Date(1997, 12, 31);
date.add!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 2, 28));
date.add!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1997, 12, 28));
}
{
auto date = Date(1998, 12, 31);
date.add!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(2000, 2, 29));
date.add!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1998, 12, 29));
}
{
auto date = Date(1999, 12, 31);
date.add!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(2001, 2, 28));
date.add!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 12, 28));
}
//Test B.C.
{
auto date = Date(-1999, 7, 6);
date.add!"months"(3, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 10, 6));
date.add!"months"(-4, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 6, 6));
}
{
auto date = Date(-1999, 7, 6);
date.add!"months"(6, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1998, 1, 6));
date.add!"months"(-6, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 7, 6));
}
{
auto date = Date(-1999, 7, 6);
date.add!"months"(-27, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-2001, 4, 6));
date.add!"months"(28, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 8, 6));
}
{
auto date = Date(-1999, 5, 31);
date.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 6, 30));
}
{
auto date = Date(-1999, 5, 31);
date.add!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 4, 30));
}
{
auto date = Date(-1999, 2, 28);
date.add!"months"(-12, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-2000, 2, 28));
}
{
auto date = Date(-2000, 2, 29);
date.add!"months"(-12, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-2001, 2, 28));
}
{
auto date = Date(-1999, 7, 31);
date.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 8, 31));
date.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 9, 30));
}
{
auto date = Date(-1998, 8, 31);
date.add!"months"(13, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1997, 9, 30));
date.add!"months"(-13, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1998, 8, 30));
}
{
auto date = Date(-1997, 12, 31);
date.add!"months"(13, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1995, 1, 31));
date.add!"months"(-13, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1997, 12, 31));
}
{
auto date = Date(-1997, 12, 31);
date.add!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1995, 2, 28));
date.add!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1997, 12, 28));
}
{
auto date = Date(-2002, 12, 31);
date.add!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-2000, 2, 29));
date.add!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-2002, 12, 29));
}
{
auto date = Date(-2001, 12, 31);
date.add!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 2, 28));
date.add!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-2001, 12, 28));
}
//Test Both
{
auto date = Date(1, 1, 1);
date.add!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(0, 12, 1));
date.add!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1, 1, 1));
}
{
auto date = Date(4, 1, 1);
date.add!"months"(-48, AllowDayOverflow.no);
_assertPred!"=="(date, Date(0, 1, 1));
date.add!"months"(48, AllowDayOverflow.no);
_assertPred!"=="(date, Date(4, 1, 1));
}
{
auto date = Date(4, 3, 31);
date.add!"months"(-49, AllowDayOverflow.no);
_assertPred!"=="(date, Date(0, 2, 29));
date.add!"months"(49, AllowDayOverflow.no);
_assertPred!"=="(date, Date(4, 3, 29));
}
{
auto date = Date(4, 3, 31);
date.add!"months"(-85, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-3, 2, 28));
date.add!"months"(85, AllowDayOverflow.no);
_assertPred!"=="(date, Date(4, 3, 28));
}
}
}
/++
Adds the given number of years or months to this $(D Date). A negative
number will subtract.
The difference between rolling and adding is that rolling does not
affect larger units. So, if you roll a $(D Date) 12 months, you get
the exact same $(D Date). However, the days can still be affected due to
the differing number of days in each month.
Because there are no units larger than years, there is no difference
between adding and rolling years.
Params:
units = The type of units to add ("years" or "months").
value = The number of months or years to add to this
$(D Date).
Examples:
--------------------
auto d1 = Date(2010, 1, 1);
d1.roll!"months"(1);
assert(d1 == Date(2010, 2, 1));
auto d2 = Date(2010, 1, 1);
d2.roll!"months"(-1);
assert(d2 == Date(2010, 12, 1));
auto d3 = Date(1999, 1, 29);
d3.roll!"months"(1);
assert(d3 == Date(1999, 3, 1));
auto d4 = Date(1999, 1, 29);
d4.roll!"months"(1, AllowDayOverflow.no);
assert(d4 == Date(1999, 2, 28));
auto d5 = Date(2000, 2, 29);
d5.roll!"years"(1);
assert(d5 == Date(2001, 3, 1));
auto d6 = Date(2000, 2, 29);
d6.roll!"years"(1, AllowDayOverflow.no);
assert(d6 == Date(2001, 2, 28));
--------------------
+/
/+ref Date+/ void roll(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) pure nothrow
if(units == "years")
{
add!"years"(value, allowOverflow);
}
//Verify Examples.
unittest
{
version(testStdDateTime)
{
auto d1 = Date(2010, 1, 1);
d1.roll!"months"(1);
assert(d1 == Date(2010, 2, 1));
auto d2 = Date(2010, 1, 1);
d2.roll!"months"(-1);
assert(d2 == Date(2010, 12, 1));
auto d3 = Date(1999, 1, 29);
d3.roll!"months"(1);
assert(d3 == Date(1999, 3, 1));
auto d4 = Date(1999, 1, 29);
d4.roll!"months"(1, AllowDayOverflow.no);
assert(d4 == Date(1999, 2, 28));
auto d5 = Date(2000, 2, 29);
d5.roll!"years"(1);
assert(d5 == Date(2001, 3, 1));
auto d6 = Date(2000, 2, 29);
d6.roll!"years"(1, AllowDayOverflow.no);
assert(d6 == Date(2001, 2, 28));
}
}
unittest
{
version(testStdDateTime)
{
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(!__traits(compiles, cdate.roll!"years"(3)));
static assert(!__traits(compiles, idate.rolYears(3)));
}
}
//Shares documentation with "years" version.
/+ref Date+/ void roll(string units)(long months, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) pure nothrow
if(units == "months")
{
months %= 12;
auto newMonth = _month + months;
if(months < 0)
{
if(newMonth < 1)
newMonth += 12;
}
else
{
if(newMonth > 12)
newMonth -= 12;
}
_month = cast(Month)newMonth;
immutable currMaxDay = maxDay(_year, _month);
immutable overflow = _day - currMaxDay;
if(overflow > 0)
{
if(allowOverflow == AllowDayOverflow.yes)
{
++_month;
_day = cast(ubyte)overflow;
}
else
_day = cast(ubyte)currMaxDay;
}
}
//Test roll!"months"() with AllowDayOverlow.yes
unittest
{
version(testStdDateTime)
{
//Test A.D.
{
auto date = Date(1999, 7, 6);
date.roll!"months"(3);
_assertPred!"=="(date, Date(1999, 10, 6));
date.roll!"months"(-4);
_assertPred!"=="(date, Date(1999, 6, 6));
}
{
auto date = Date(1999, 7, 6);
date.roll!"months"(6);
_assertPred!"=="(date, Date(1999, 1, 6));
date.roll!"months"(-6);
_assertPred!"=="(date, Date(1999, 7, 6));
}
{
auto date = Date(1999, 7, 6);
date.roll!"months"(27);
_assertPred!"=="(date, Date(1999, 10, 6));
date.roll!"months"(-28);
_assertPred!"=="(date, Date(1999, 6, 6));
}
{
auto date = Date(1999, 5, 31);
date.roll!"months"(1);
_assertPred!"=="(date, Date(1999, 7, 1));
}
{
auto date = Date(1999, 5, 31);
date.roll!"months"(-1);
_assertPred!"=="(date, Date(1999, 5, 1));
}
{
auto date = Date(1999, 2, 28);
date.roll!"months"(12);
_assertPred!"=="(date, Date(1999, 2, 28));
}
{
auto date = Date(2000, 2, 29);
date.roll!"months"(12);
_assertPred!"=="(date, Date(2000, 2, 29));
}
{
auto date = Date(1999, 7, 31);
date.roll!"months"(1);
_assertPred!"=="(date, Date(1999, 8, 31));
date.roll!"months"(1);
_assertPred!"=="(date, Date(1999, 10, 1));
}
{
auto date = Date(1998, 8, 31);
date.roll!"months"(13);
_assertPred!"=="(date, Date(1998, 10, 1));
date.roll!"months"(-13);
_assertPred!"=="(date, Date(1998, 9, 1));
}
{
auto date = Date(1997, 12, 31);
date.roll!"months"(13);
_assertPred!"=="(date, Date(1997, 1, 31));
date.roll!"months"(-13);
_assertPred!"=="(date, Date(1997, 12, 31));
}
{
auto date = Date(1997, 12, 31);
date.roll!"months"(14);
_assertPred!"=="(date, Date(1997, 3, 3));
date.roll!"months"(-14);
_assertPred!"=="(date, Date(1997, 1, 3));
}
{
auto date = Date(1998, 12, 31);
date.roll!"months"(14);
_assertPred!"=="(date, Date(1998, 3, 3));
date.roll!"months"(-14);
_assertPred!"=="(date, Date(1998, 1, 3));
}
{
auto date = Date(1999, 12, 31);
date.roll!"months"(14);
_assertPred!"=="(date, Date(1999, 3, 3));
date.roll!"months"(-14);
_assertPred!"=="(date, Date(1999, 1, 3));
}
//Test B.C.
{
auto date = Date(-1999, 7, 6);
date.roll!"months"(3);
_assertPred!"=="(date, Date(-1999, 10, 6));
date.roll!"months"(-4);
_assertPred!"=="(date, Date(-1999, 6, 6));
}
{
auto date = Date(-1999, 7, 6);
date.roll!"months"(6);
_assertPred!"=="(date, Date(-1999, 1, 6));
date.roll!"months"(-6);
_assertPred!"=="(date, Date(-1999, 7, 6));
}
{
auto date = Date(-1999, 7, 6);
date.roll!"months"(-27);
_assertPred!"=="(date, Date(-1999, 4, 6));
date.roll!"months"(28);
_assertPred!"=="(date, Date(-1999, 8, 6));
}
{
auto date = Date(-1999, 5, 31);
date.roll!"months"(1);
_assertPred!"=="(date, Date(-1999, 7, 1));
}
{
auto date = Date(-1999, 5, 31);
date.roll!"months"(-1);
_assertPred!"=="(date, Date(-1999, 5, 1));
}
{
auto date = Date(-1999, 2, 28);
date.roll!"months"(-12);
_assertPred!"=="(date, Date(-1999, 2, 28));
}
{
auto date = Date(-2000, 2, 29);
date.roll!"months"(-12);
_assertPred!"=="(date, Date(-2000, 2, 29));
}
{
auto date = Date(-1999, 7, 31);
date.roll!"months"(1);
_assertPred!"=="(date, Date(-1999, 8, 31));
date.roll!"months"(1);
_assertPred!"=="(date, Date(-1999, 10, 1));
}
{
auto date = Date(-1998, 8, 31);
date.roll!"months"(13);
_assertPred!"=="(date, Date(-1998, 10, 1));
date.roll!"months"(-13);
_assertPred!"=="(date, Date(-1998, 9, 1));
}
{
auto date = Date(-1997, 12, 31);
date.roll!"months"(13);
_assertPred!"=="(date, Date(-1997, 1, 31));
date.roll!"months"(-13);
_assertPred!"=="(date, Date(-1997, 12, 31));
}
{
auto date = Date(-1997, 12, 31);
date.roll!"months"(14);
_assertPred!"=="(date, Date(-1997, 3, 3));
date.roll!"months"(-14);
_assertPred!"=="(date, Date(-1997, 1, 3));
}
{
auto date = Date(-2002, 12, 31);
date.roll!"months"(14);
_assertPred!"=="(date, Date(-2002, 3, 3));
date.roll!"months"(-14);
_assertPred!"=="(date, Date(-2002, 1, 3));
}
{
auto date = Date(-2001, 12, 31);
date.roll!"months"(14);
_assertPred!"=="(date, Date(-2001, 3, 3));
date.roll!"months"(-14);
_assertPred!"=="(date, Date(-2001, 1, 3));
}
//Test Both
{
auto date = Date(1, 1, 1);
date.roll!"months"(-1);
_assertPred!"=="(date, Date(1, 12, 1));
date.roll!"months"(1);
_assertPred!"=="(date, Date(1, 1, 1));
}
{
auto date = Date(4, 1, 1);
date.roll!"months"(-48);
_assertPred!"=="(date, Date(4, 1, 1));
date.roll!"months"(48);
_assertPred!"=="(date, Date(4, 1, 1));
}
{
auto date = Date(4, 3, 31);
date.roll!"months"(-49);
_assertPred!"=="(date, Date(4, 3, 2));
date.roll!"months"(49);
_assertPred!"=="(date, Date(4, 4, 2));
}
{
auto date = Date(4, 3, 31);
date.roll!"months"(-85);
_assertPred!"=="(date, Date(4, 3, 2));
date.roll!"months"(85);
_assertPred!"=="(date, Date(4, 4, 2));
}
{
auto date = Date(-1, 1, 1);
date.roll!"months"(-1);
_assertPred!"=="(date, Date(-1, 12, 1));
date.roll!"months"(1);
_assertPred!"=="(date, Date(-1, 1, 1));
}
{
auto date = Date(-4, 1, 1);
date.roll!"months"(-48);
_assertPred!"=="(date, Date(-4, 1, 1));
date.roll!"months"(48);
_assertPred!"=="(date, Date(-4, 1, 1));
}
{
auto date = Date(-4, 3, 31);
date.roll!"months"(-49);
_assertPred!"=="(date, Date(-4, 3, 2));
date.roll!"months"(49);
_assertPred!"=="(date, Date(-4, 4, 2));
}
{
auto date = Date(-4, 3, 31);
date.roll!"months"(-85);
_assertPred!"=="(date, Date(-4, 3, 2));
date.roll!"months"(85);
_assertPred!"=="(date, Date(-4, 4, 2));
}
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(!__traits(compiles, cdate.roll!"months"(3)));
static assert(!__traits(compiles, idate.roll!"months"(3)));
//Verify Examples.
auto date1 = Date(2010, 1, 1);
date1.roll!"months"(1);
assert(date1 == Date(2010, 2, 1));
auto date2 = Date(2010, 1, 1);
date2.roll!"months"(-1);
assert(date2 == Date(2010, 12, 1));
auto date3 = Date(1999, 1, 29);
date3.roll!"months"(1);
assert(date3 == Date(1999, 3, 1));
auto date4 = Date(1999, 1, 29);
date4.roll!"months"(1, AllowDayOverflow.no);
assert(date4 == Date(1999, 2, 28));
}
}
//Test roll!"months"() with AllowDayOverlow.no
unittest
{
version(testStdDateTime)
{
//Test A.D.
{
auto date = Date(1999, 7, 6);
date.roll!"months"(3, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 10, 6));
date.roll!"months"(-4, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 6, 6));
}
{
auto date = Date(1999, 7, 6);
date.roll!"months"(6, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 1, 6));
date.roll!"months"(-6, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 7, 6));
}
{
auto date = Date(1999, 7, 6);
date.roll!"months"(27, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 10, 6));
date.roll!"months"(-28, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 6, 6));
}
{
auto date = Date(1999, 5, 31);
date.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 6, 30));
}
{
auto date = Date(1999, 5, 31);
date.roll!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 4, 30));
}
{
auto date = Date(1999, 2, 28);
date.roll!"months"(12, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 2, 28));
}
{
auto date = Date(2000, 2, 29);
date.roll!"months"(12, AllowDayOverflow.no);
_assertPred!"=="(date, Date(2000, 2, 29));
}
{
auto date = Date(1999, 7, 31);
date.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 8, 31));
date.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 9, 30));
}
{
auto date = Date(1998, 8, 31);
date.roll!"months"(13, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1998, 9, 30));
date.roll!"months"(-13, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1998, 8, 30));
}
{
auto date = Date(1997, 12, 31);
date.roll!"months"(13, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1997, 1, 31));
date.roll!"months"(-13, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1997, 12, 31));
}
{
auto date = Date(1997, 12, 31);
date.roll!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1997, 2, 28));
date.roll!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1997, 12, 28));
}
{
auto date = Date(1998, 12, 31);
date.roll!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1998, 2, 28));
date.roll!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1998, 12, 28));
}
{
auto date = Date(1999, 12, 31);
date.roll!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 2, 28));
date.roll!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1999, 12, 28));
}
//Test B.C.
{
auto date = Date(-1999, 7, 6);
date.roll!"months"(3, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 10, 6));
date.roll!"months"(-4, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 6, 6));
}
{
auto date = Date(-1999, 7, 6);
date.roll!"months"(6, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 1, 6));
date.roll!"months"(-6, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 7, 6));
}
{
auto date = Date(-1999, 7, 6);
date.roll!"months"(-27, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 4, 6));
date.roll!"months"(28, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 8, 6));
}
{
auto date = Date(-1999, 5, 31);
date.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 6, 30));
}
{
auto date = Date(-1999, 5, 31);
date.roll!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 4, 30));
}
{
auto date = Date(-1999, 2, 28);
date.roll!"months"(-12, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 2, 28));
}
{
auto date = Date(-2000, 2, 29);
date.roll!"months"(-12, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-2000, 2, 29));
}
{
auto date = Date(-1999, 7, 31);
date.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 8, 31));
date.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1999, 9, 30));
}
{
auto date = Date(-1998, 8, 31);
date.roll!"months"(13, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1998, 9, 30));
date.roll!"months"(-13, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1998, 8, 30));
}
{
auto date = Date(-1997, 12, 31);
date.roll!"months"(13, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1997, 1, 31));
date.roll!"months"(-13, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1997, 12, 31));
}
{
auto date = Date(-1997, 12, 31);
date.roll!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1997, 2, 28));
date.roll!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1997, 12, 28));
}
{
auto date = Date(-2002, 12, 31);
date.roll!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-2002, 2, 28));
date.roll!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-2002, 12, 28));
}
{
auto date = Date(-2001, 12, 31);
date.roll!"months"(14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-2001, 2, 28));
date.roll!"months"(-14, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-2001, 12, 28));
}
//Test Both
{
auto date = Date(1, 1, 1);
date.roll!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1, 12, 1));
date.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(1, 1, 1));
}
{
auto date = Date(4, 1, 1);
date.roll!"months"(-48, AllowDayOverflow.no);
_assertPred!"=="(date, Date(4, 1, 1));
date.roll!"months"(48, AllowDayOverflow.no);
_assertPred!"=="(date, Date(4, 1, 1));
}
{
auto date = Date(4, 3, 31);
date.roll!"months"(-49, AllowDayOverflow.no);
_assertPred!"=="(date, Date(4, 2, 29));
date.roll!"months"(49, AllowDayOverflow.no);
_assertPred!"=="(date, Date(4, 3, 29));
}
{
auto date = Date(4, 3, 31);
date.roll!"months"(-85, AllowDayOverflow.no);
_assertPred!"=="(date, Date(4, 2, 29));
date.roll!"months"(85, AllowDayOverflow.no);
_assertPred!"=="(date, Date(4, 3, 29));
}
{
auto date = Date(-1, 1, 1);
date.roll!"months"(-1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1, 12, 1));
date.roll!"months"(1, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-1, 1, 1));
}
{
auto date = Date(-4, 1, 1);
date.roll!"months"(-48, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-4, 1, 1));
date.roll!"months"(48, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-4, 1, 1));
}
{
auto date = Date(-4, 3, 31);
date.roll!"months"(-49, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-4, 2, 29));
date.roll!"months"(49, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-4, 3, 29));
}
{
auto date = Date(-4, 3, 31);
date.roll!"months"(-85, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-4, 2, 29));
date.roll!"months"(85, AllowDayOverflow.no);
_assertPred!"=="(date, Date(-4, 3, 29));
}
}
}
/++
Adds the given number of units to this $(D Date). A negative number will
subtract.
The difference between rolling and adding is that rolling does not
affect larger units. So, for instance, if you roll a $(D Date) one
year's worth of days, then you get the exact same $(D Date).
The only accepted units are $(D "days").
Params:
units = The units to add. Must be $(D "days").
value = The number of days to add to this $(D Date).
Examples:
--------------------
auto d = Date(2010, 1, 1);
d.roll!"days"(1);
assert(d == Date(2010, 1, 2));
d.roll!"days"(365);
assert(d == Date(2010, 1, 26));
d.roll!"days"(-32);
assert(d == Date(2010, 1, 25));
--------------------
+/
/+ref Date+/ void roll(string units)(long days) pure nothrow
if(units == "days")
{
immutable limit = maxDay(_year, _month);
days %= limit;
auto newDay = _day + days;
if(days < 0)
{
if(newDay < 1)
newDay += limit;
}
else if(newDay > limit)
newDay -= limit;
_day = cast(ubyte)newDay;
}
//Verify Examples.
unittest
{
version(testStdDateTime)
{
auto d = Date(2010, 1, 1);
d.roll!"days"(1);
assert(d == Date(2010, 1, 2));
d.roll!"days"(365);
assert(d == Date(2010, 1, 26));
d.roll!"days"(-32);
assert(d == Date(2010, 1, 25));
}
}
unittest
{
version(testStdDateTime)
{
//Test A.D.
{
auto date = Date(1999, 2, 28);
date.roll!"days"(1);
_assertPred!"=="(date, Date(1999, 2, 1));
date.roll!"days"(-1);
_assertPred!"=="(date, Date(1999, 2, 28));
}
{
auto date = Date(2000, 2, 28);
date.roll!"days"(1);
_assertPred!"=="(date, Date(2000, 2, 29));
date.roll!"days"(1);
_assertPred!"=="(date, Date(2000, 2, 1));
date.roll!"days"(-1);
_assertPred!"=="(date, Date(2000, 2, 29));
}
{
auto date = Date(1999, 6, 30);
date.roll!"days"(1);
_assertPred!"=="(date, Date(1999, 6, 1));
date.roll!"days"(-1);
_assertPred!"=="(date, Date(1999, 6, 30));
}
{
auto date = Date(1999, 7, 31);
date.roll!"days"(1);
_assertPred!"=="(date, Date(1999, 7, 1));
date.roll!"days"(-1);
_assertPred!"=="(date, Date(1999, 7, 31));
}
{
auto date = Date(1999, 1, 1);
date.roll!"days"(-1);
_assertPred!"=="(date, Date(1999, 1, 31));
date.roll!"days"(1);
_assertPred!"=="(date, Date(1999, 1, 1));
}
{
auto date = Date(1999, 7, 6);
date.roll!"days"(9);
_assertPred!"=="(date, Date(1999, 7, 15));
date.roll!"days"(-11);
_assertPred!"=="(date, Date(1999, 7, 4));
date.roll!"days"(30);
_assertPred!"=="(date, Date(1999, 7, 3));
date.roll!"days"(-3);
_assertPred!"=="(date, Date(1999, 7, 31));
}
{
auto date = Date(1999, 7, 6);
date.roll!"days"(365);
_assertPred!"=="(date, Date(1999, 7, 30));
date.roll!"days"(-365);
_assertPred!"=="(date, Date(1999, 7, 6));
date.roll!"days"(366);
_assertPred!"=="(date, Date(1999, 7, 31));
date.roll!"days"(730);
_assertPred!"=="(date, Date(1999, 7, 17));
date.roll!"days"(-1096);
_assertPred!"=="(date, Date(1999, 7, 6));
}
{
auto date = Date(1999, 2, 6);
date.roll!"days"(365);
_assertPred!"=="(date, Date(1999, 2, 7));
date.roll!"days"(-365);
_assertPred!"=="(date, Date(1999, 2, 6));
date.roll!"days"(366);
_assertPred!"=="(date, Date(1999, 2, 8));
date.roll!"days"(730);
_assertPred!"=="(date, Date(1999, 2, 10));
date.roll!"days"(-1096);
_assertPred!"=="(date, Date(1999, 2, 6));
}
//Test B.C.
{
auto date = Date(-1999, 2, 28);
date.roll!"days"(1);
_assertPred!"=="(date, Date(-1999, 2, 1));
date.roll!"days"(-1);
_assertPred!"=="(date, Date(-1999, 2, 28));
}
{
auto date = Date(-2000, 2, 28);
date.roll!"days"(1);
_assertPred!"=="(date, Date(-2000, 2, 29));
date.roll!"days"(1);
_assertPred!"=="(date, Date(-2000, 2, 1));
date.roll!"days"(-1);
_assertPred!"=="(date, Date(-2000, 2, 29));
}
{
auto date = Date(-1999, 6, 30);
date.roll!"days"(1);
_assertPred!"=="(date, Date(-1999, 6, 1));
date.roll!"days"(-1);
_assertPred!"=="(date, Date(-1999, 6, 30));
}
{
auto date = Date(-1999, 7, 31);
date.roll!"days"(1);
_assertPred!"=="(date, Date(-1999, 7, 1));
date.roll!"days"(-1);
_assertPred!"=="(date, Date(-1999, 7, 31));
}
{
auto date = Date(-1999, 1, 1);
date.roll!"days"(-1);
_assertPred!"=="(date, Date(-1999, 1, 31));
date.roll!"days"(1);
_assertPred!"=="(date, Date(-1999, 1, 1));
}
{
auto date = Date(-1999, 7, 6);
date.roll!"days"(9);
_assertPred!"=="(date, Date(-1999, 7, 15));
date.roll!"days"(-11);
_assertPred!"=="(date, Date(-1999, 7, 4));
date.roll!"days"(30);
_assertPred!"=="(date, Date(-1999, 7, 3));
date.roll!"days"(-3);
_assertPred!"=="(date, Date(-1999, 7, 31));
}
{
auto date = Date(-1999, 7, 6);
date.roll!"days"(365);
_assertPred!"=="(date, Date(-1999, 7, 30));
date.roll!"days"(-365);
_assertPred!"=="(date, Date(-1999, 7, 6));
date.roll!"days"(366);
_assertPred!"=="(date, Date(-1999, 7, 31));
date.roll!"days"(730);
_assertPred!"=="(date, Date(-1999, 7, 17));
date.roll!"days"(-1096);
_assertPred!"=="(date, Date(-1999, 7, 6));
}
//Test Both
{
auto date = Date(1, 7, 6);
date.roll!"days"(-365);
_assertPred!"=="(date, Date(1, 7, 13));
date.roll!"days"(365);
_assertPred!"=="(date, Date(1, 7, 6));
date.roll!"days"(-731);
_assertPred!"=="(date, Date(1, 7, 19));
date.roll!"days"(730);
_assertPred!"=="(date, Date(1, 7, 5));
}
{
auto date = Date(0, 7, 6);
date.roll!"days"(-365);
_assertPred!"=="(date, Date(0, 7, 13));
date.roll!"days"(365);
_assertPred!"=="(date, Date(0, 7, 6));
date.roll!"days"(-731);
_assertPred!"=="(date, Date(0, 7, 19));
date.roll!"days"(730);
_assertPred!"=="(date, Date(0, 7, 5));
}
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(!__traits(compiles, cdate.roll!"days"(12)));
static assert(!__traits(compiles, idate.roll!"days"(12)));
//Verify Examples.
auto date = Date(2010, 1, 1);
date.roll!"days"(1);
assert(date == Date(2010, 1, 2));
date.roll!"days"(365);
assert(date == Date(2010, 1, 26));
date.roll!"days"(-32);
assert(date == Date(2010, 1, 25));
}
}
/++
Gives the result of adding or subtracting a duration from this
$(D Date).
The legal types of arithmetic for Date using this operator are
$(BOOKTABLE,
$(TR $(TD Date) $(TD +) $(TD duration) $(TD -->) $(TD Date))
$(TR $(TD Date) $(TD -) $(TD duration) $(TD -->) $(TD Date))
)
Params:
duration = The duration to add to or subtract from this $(D Date).
+/
Date opBinary(string op, D)(in D duration) const pure nothrow
if((op == "+" || op == "-") &&
(is(Unqual!D == Duration) ||
is(Unqual!D == TickDuration)))
{
Date retval = this;
static if(is(Unqual!D == Duration))
immutable days = duration.total!"days";
else static if(is(Unqual!D == TickDuration))
immutable days = convert!("hnsecs", "days")(duration.hnsecs);
//Ideally, this would just be
//return retval.addDays(unaryFun!(op ~ "a")(days));
//But there isn't currently a pure version of unaryFun!().
static if(op == "+")
immutable signedDays = days;
else static if(op == "-")
immutable signedDays = -days;
else
static assert(0);
return retval.addDays(signedDays);
}
unittest
{
version(testStdDateTime)
{
auto date = Date(1999, 7, 6);
_assertPred!"=="(date + dur!"weeks"(7), Date(1999, 8, 24));
_assertPred!"=="(date + dur!"weeks"(-7), Date(1999, 5, 18));
_assertPred!"=="(date + dur!"days"(7), Date(1999, 7, 13));
_assertPred!"=="(date + dur!"days"(-7), Date(1999, 6, 29));
_assertPred!"=="(date + dur!"hours"(24), Date(1999, 7, 7));
_assertPred!"=="(date + dur!"hours"(-24), Date(1999, 7, 5));
_assertPred!"=="(date + dur!"minutes"(1440), Date(1999, 7, 7));
_assertPred!"=="(date + dur!"minutes"(-1440), Date(1999, 7, 5));
_assertPred!"=="(date + dur!"seconds"(86_400), Date(1999, 7, 7));
_assertPred!"=="(date + dur!"seconds"(-86_400), Date(1999, 7, 5));
_assertPred!"=="(date + dur!"msecs"(86_400_000), Date(1999, 7, 7));
_assertPred!"=="(date + dur!"msecs"(-86_400_000), Date(1999, 7, 5));
_assertPred!"=="(date + dur!"usecs"(86_400_000_000), Date(1999, 7, 7));
_assertPred!"=="(date + dur!"usecs"(-86_400_000_000), Date(1999, 7, 5));
_assertPred!"=="(date + dur!"hnsecs"(864_000_000_000), Date(1999, 7, 7));
_assertPred!"=="(date + dur!"hnsecs"(-864_000_000_000), Date(1999, 7, 5));
//This probably only runs in cases where gettimeofday() is used, but it's
//hard to do this test correctly with variable ticksPerSec.
if(TickDuration.ticksPerSec == 1_000_000)
{
_assertPred!"=="(date + TickDuration.from!"usecs"(86_400_000_000), Date(1999, 7, 7));
_assertPred!"=="(date + TickDuration.from!"usecs"(-86_400_000_000), Date(1999, 7, 5));
}
_assertPred!"=="(date - dur!"weeks"(-7), Date(1999, 8, 24));
_assertPred!"=="(date - dur!"weeks"(7), Date(1999, 5, 18));
_assertPred!"=="(date - dur!"days"(-7), Date(1999, 7, 13));
_assertPred!"=="(date - dur!"days"(7), Date(1999, 6, 29));
_assertPred!"=="(date - dur!"hours"(-24), Date(1999, 7, 7));
_assertPred!"=="(date - dur!"hours"(24), Date(1999, 7, 5));
_assertPred!"=="(date - dur!"minutes"(-1440), Date(1999, 7, 7));
_assertPred!"=="(date - dur!"minutes"(1440), Date(1999, 7, 5));
_assertPred!"=="(date - dur!"seconds"(-86_400), Date(1999, 7, 7));
_assertPred!"=="(date - dur!"seconds"(86_400), Date(1999, 7, 5));
_assertPred!"=="(date - dur!"msecs"(-86_400_000), Date(1999, 7, 7));
_assertPred!"=="(date - dur!"msecs"(86_400_000), Date(1999, 7, 5));
_assertPred!"=="(date - dur!"usecs"(-86_400_000_000), Date(1999, 7, 7));
_assertPred!"=="(date - dur!"usecs"(86_400_000_000), Date(1999, 7, 5));
_assertPred!"=="(date - dur!"hnsecs"(-864_000_000_000), Date(1999, 7, 7));
_assertPred!"=="(date - dur!"hnsecs"(864_000_000_000), Date(1999, 7, 5));
//This probably only runs in cases where gettimeofday() is used, but it's
//hard to do this test correctly with variable ticksPerSec.
if(TickDuration.ticksPerSec == 1_000_000)
{
_assertPred!"=="(date - TickDuration.from!"usecs"(-86_400_000_000), Date(1999, 7, 7));
_assertPred!"=="(date - TickDuration.from!"usecs"(86_400_000_000), Date(1999, 7, 5));
}
auto duration = dur!"days"(12);
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, date + duration));
static assert(__traits(compiles, cdate + duration));
static assert(__traits(compiles, idate + duration));
static assert(__traits(compiles, date - duration));
static assert(__traits(compiles, cdate - duration));
static assert(__traits(compiles, idate - duration));
}
}
/++
Gives the result of adding or subtracting a duration from this
$(D Date), as well as assigning the result to this $(D Date).
The legal types of arithmetic for $(D Date) using this operator are
$(BOOKTABLE,
$(TR $(TD Date) $(TD +) $(TD duration) $(TD -->) $(TD Date))
$(TR $(TD Date) $(TD -) $(TD duration) $(TD -->) $(TD Date))
)
Params:
duration = The duration to add to or subtract from this $(D Date).
+/
/+ref+/ Date opOpAssign(string op, D)(in D duration) pure nothrow
if((op == "+" || op == "-") &&
(is(Unqual!D == Duration) ||
is(Unqual!D == TickDuration)))
{
static if(is(Unqual!D == Duration))
immutable days = duration.total!"days";
else static if(is(Unqual!D == TickDuration))
immutable days = convert!("hnsecs", "days")(duration.hnsecs);
//Ideally, this would just be
//return addDays(unaryFun!(op ~ "a")(days));
//But there isn't currently a pure version of unaryFun!().
static if(op == "+")
immutable signedDays = days;
else static if(op == "-")
immutable signedDays = -days;
else
static assert(0);
return addDays(signedDays);
}
unittest
{
version(testStdDateTime)
{
_assertPred!"+="(Date(1999, 7, 6), dur!"weeks"(7), Date(1999, 8, 24));
_assertPred!"+="(Date(1999, 7, 6), dur!"weeks"(-7), Date(1999, 5, 18));
_assertPred!"+="(Date(1999, 7, 6), dur!"days"(7), Date(1999, 7, 13));
_assertPred!"+="(Date(1999, 7, 6), dur!"days"(-7), Date(1999, 6, 29));
_assertPred!"+="(Date(1999, 7, 6), dur!"hours"(24), Date(1999, 7, 7));
_assertPred!"+="(Date(1999, 7, 6), dur!"hours"(-24), Date(1999, 7, 5));
_assertPred!"+="(Date(1999, 7, 6), dur!"minutes"(1440), Date(1999, 7, 7));
_assertPred!"+="(Date(1999, 7, 6), dur!"minutes"(-1440), Date(1999, 7, 5));
_assertPred!"+="(Date(1999, 7, 6), dur!"seconds"(86_400), Date(1999, 7, 7));
_assertPred!"+="(Date(1999, 7, 6), dur!"seconds"(-86_400), Date(1999, 7, 5));
_assertPred!"+="(Date(1999, 7, 6), dur!"msecs"(86_400_000), Date(1999, 7, 7));
_assertPred!"+="(Date(1999, 7, 6), dur!"msecs"(-86_400_000), Date(1999, 7, 5));
_assertPred!"+="(Date(1999, 7, 6), dur!"usecs"(86_400_000_000), Date(1999, 7, 7));
_assertPred!"+="(Date(1999, 7, 6), dur!"usecs"(-86_400_000_000), Date(1999, 7, 5));
_assertPred!"+="(Date(1999, 7, 6), dur!"hnsecs"(864_000_000_000), Date(1999, 7, 7));
_assertPred!"+="(Date(1999, 7, 6), dur!"hnsecs"(-864_000_000_000), Date(1999, 7, 5));
_assertPred!"-="(Date(1999, 7, 6), dur!"weeks"(-7), Date(1999, 8, 24));
_assertPred!"-="(Date(1999, 7, 6), dur!"weeks"(7), Date(1999, 5, 18));
_assertPred!"-="(Date(1999, 7, 6), dur!"days"(-7), Date(1999, 7, 13));
_assertPred!"-="(Date(1999, 7, 6), dur!"days"(7), Date(1999, 6, 29));
_assertPred!"-="(Date(1999, 7, 6), dur!"hours"(-24), Date(1999, 7, 7));
_assertPred!"-="(Date(1999, 7, 6), dur!"hours"(24), Date(1999, 7, 5));
_assertPred!"-="(Date(1999, 7, 6), dur!"minutes"(-1440), Date(1999, 7, 7));
_assertPred!"-="(Date(1999, 7, 6), dur!"minutes"(1440), Date(1999, 7, 5));
_assertPred!"-="(Date(1999, 7, 6), dur!"seconds"(-86_400), Date(1999, 7, 7));
_assertPred!"-="(Date(1999, 7, 6), dur!"seconds"(86_400), Date(1999, 7, 5));
_assertPred!"-="(Date(1999, 7, 6), dur!"msecs"(-86_400_000), Date(1999, 7, 7));
_assertPred!"-="(Date(1999, 7, 6), dur!"msecs"(86_400_000), Date(1999, 7, 5));
_assertPred!"-="(Date(1999, 7, 6), dur!"usecs"(-86_400_000_000), Date(1999, 7, 7));
_assertPred!"-="(Date(1999, 7, 6), dur!"usecs"(86_400_000_000), Date(1999, 7, 5));
_assertPred!"-="(Date(1999, 7, 6), dur!"hnsecs"(-864_000_000_000), Date(1999, 7, 7));
_assertPred!"-="(Date(1999, 7, 6), dur!"hnsecs"(864_000_000_000), Date(1999, 7, 5));
auto duration = dur!"days"(12);
auto date = Date(1999, 7, 6);
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, date += duration));
static assert(!__traits(compiles, cdate += duration));
static assert(!__traits(compiles, idate += duration));
static assert(__traits(compiles, date -= duration));
static assert(!__traits(compiles, cdate -= duration));
static assert(!__traits(compiles, idate -= duration));
}
}
/++
Gives the difference between two $(D Date)s.
The legal types of arithmetic for Date using this operator are
$(BOOKTABLE,
$(TR $(TD Date) $(TD -) $(TD Date) $(TD -->) $(TD duration))
)
+/
Duration opBinary(string op)(in Date rhs) const pure nothrow
if(op == "-")
{
return dur!"days"(this.dayOfGregorianCal - rhs.dayOfGregorianCal);
}
unittest
{
version(testStdDateTime)
{
auto date = Date(1999, 7, 6);
_assertPred!"=="(Date(1999, 7, 6) - Date(1998, 7, 6), dur!"days"(365));
_assertPred!"=="(Date(1998, 7, 6) - Date(1999, 7, 6), dur!"days"(-365));
_assertPred!"=="(Date(1999, 6, 6) - Date(1999, 5, 6), dur!"days"(31));
_assertPred!"=="(Date(1999, 5, 6) - Date(1999, 6, 6), dur!"days"(-31));
_assertPred!"=="(Date(1999, 1, 1) - Date(1998, 12, 31), dur!"days"(1));
_assertPred!"=="(Date(1998, 12, 31) - Date(1999, 1, 1), dur!"days"(-1));
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, date - date));
static assert(__traits(compiles, cdate - date));
static assert(__traits(compiles, idate - date));
static assert(__traits(compiles, date - cdate));
static assert(__traits(compiles, cdate - cdate));
static assert(__traits(compiles, idate - cdate));
static assert(__traits(compiles, date - idate));
static assert(__traits(compiles, cdate - idate));
static assert(__traits(compiles, idate - idate));
}
}
/++
Returns the difference between the two $(D Date)s in months.
You can get the difference in years by subtracting the year property
of two $(D Date)s, and you can get the difference in days or weeks by
subtracting the $(D Date)s themselves and using the $(D Duration) that
results, but because you cannot convert between months and smaller units
without a specific date (which $(D Duration)s don't have), you cannot
get the difference in months without doing some math using both the year
and month properties, so this is a convenience function for getting the
difference in months.
Note that the number of days in the months or how far into the month
either $(D Date) is is irrelevant. It is the difference in the month
property combined with the difference in years * 12. So, for instance,
December 31st and January 1st are one month apart just as December 1st
and January 31st are one month apart.
Params:
rhs = The $(D Date) to subtract from this one.
Examples:
--------------------
assert(Date(1999, 2, 1).diffMonths(Date(1999, 1, 31)) == 1);
assert(Date(1999, 1, 31).diffMonths(Date(1999, 2, 1)) == -1);
assert(Date(1999, 3, 1).diffMonths(Date(1999, 1, 1)) == 2);
assert(Date(1999, 1, 1).diffMonths(Date(1999, 3, 31)) == -2);
--------------------
+/
int diffMonths(in Date rhs) const pure nothrow
{
immutable yearDiff = _year - rhs._year;
immutable monthDiff = _month - rhs._month;
return yearDiff * 12 + monthDiff;
}
unittest
{
version(testStdDateTime)
{
auto date = Date(1999, 7, 6);
//Test A.D.
_assertPred!"=="(date.diffMonths(Date(1998, 6, 5)), 13);
_assertPred!"=="(date.diffMonths(Date(1998, 7, 5)), 12);
_assertPred!"=="(date.diffMonths(Date(1998, 8, 5)), 11);
_assertPred!"=="(date.diffMonths(Date(1998, 9, 5)), 10);
_assertPred!"=="(date.diffMonths(Date(1998, 10, 5)), 9);
_assertPred!"=="(date.diffMonths(Date(1998, 11, 5)), 8);
_assertPred!"=="(date.diffMonths(Date(1998, 12, 5)), 7);
_assertPred!"=="(date.diffMonths(Date(1999, 1, 5)), 6);
_assertPred!"=="(date.diffMonths(Date(1999, 2, 6)), 5);
_assertPred!"=="(date.diffMonths(Date(1999, 3, 6)), 4);
_assertPred!"=="(date.diffMonths(Date(1999, 4, 6)), 3);
_assertPred!"=="(date.diffMonths(Date(1999, 5, 6)), 2);
_assertPred!"=="(date.diffMonths(Date(1999, 6, 6)), 1);
_assertPred!"=="(date.diffMonths(date), 0);
_assertPred!"=="(date.diffMonths(Date(1999, 8, 6)), -1);
_assertPred!"=="(date.diffMonths(Date(1999, 9, 6)), -2);
_assertPred!"=="(date.diffMonths(Date(1999, 10, 6)), -3);
_assertPred!"=="(date.diffMonths(Date(1999, 11, 6)), -4);
_assertPred!"=="(date.diffMonths(Date(1999, 12, 6)), -5);
_assertPred!"=="(date.diffMonths(Date(2000, 1, 6)), -6);
_assertPred!"=="(date.diffMonths(Date(2000, 2, 6)), -7);
_assertPred!"=="(date.diffMonths(Date(2000, 3, 6)), -8);
_assertPred!"=="(date.diffMonths(Date(2000, 4, 6)), -9);
_assertPred!"=="(date.diffMonths(Date(2000, 5, 6)), -10);
_assertPred!"=="(date.diffMonths(Date(2000, 6, 6)), -11);
_assertPred!"=="(date.diffMonths(Date(2000, 7, 6)), -12);
_assertPred!"=="(date.diffMonths(Date(2000, 8, 6)), -13);
_assertPred!"=="(Date(1998, 6, 5).diffMonths(date), -13);
_assertPred!"=="(Date(1998, 7, 5).diffMonths(date), -12);
_assertPred!"=="(Date(1998, 8, 5).diffMonths(date), -11);
_assertPred!"=="(Date(1998, 9, 5).diffMonths(date), -10);
_assertPred!"=="(Date(1998, 10, 5).diffMonths(date), -9);
_assertPred!"=="(Date(1998, 11, 5).diffMonths(date), -8);
_assertPred!"=="(Date(1998, 12, 5).diffMonths(date), -7);
_assertPred!"=="(Date(1999, 1, 5).diffMonths(date), -6);
_assertPred!"=="(Date(1999, 2, 6).diffMonths(date), -5);
_assertPred!"=="(Date(1999, 3, 6).diffMonths(date), -4);
_assertPred!"=="(Date(1999, 4, 6).diffMonths(date), -3);
_assertPred!"=="(Date(1999, 5, 6).diffMonths(date), -2);
_assertPred!"=="(Date(1999, 6, 6).diffMonths(date), -1);
_assertPred!"=="(Date(1999, 8, 6).diffMonths(date), 1);
_assertPred!"=="(Date(1999, 9, 6).diffMonths(date), 2);
_assertPred!"=="(Date(1999, 10, 6).diffMonths(date), 3);
_assertPred!"=="(Date(1999, 11, 6).diffMonths(date), 4);
_assertPred!"=="(Date(1999, 12, 6).diffMonths(date), 5);
_assertPred!"=="(Date(2000, 1, 6).diffMonths(date), 6);
_assertPred!"=="(Date(2000, 2, 6).diffMonths(date), 7);
_assertPred!"=="(Date(2000, 3, 6).diffMonths(date), 8);
_assertPred!"=="(Date(2000, 4, 6).diffMonths(date), 9);
_assertPred!"=="(Date(2000, 5, 6).diffMonths(date), 10);
_assertPred!"=="(Date(2000, 6, 6).diffMonths(date), 11);
_assertPred!"=="(Date(2000, 7, 6).diffMonths(date), 12);
_assertPred!"=="(Date(2000, 8, 6).diffMonths(date), 13);
_assertPred!"=="(date.diffMonths(Date(1999, 6, 30)), 1);
_assertPred!"=="(date.diffMonths(Date(1999, 7, 1)), 0);
_assertPred!"=="(date.diffMonths(Date(1999, 7, 6)), 0);
_assertPred!"=="(date.diffMonths(Date(1999, 7, 11)), 0);
_assertPred!"=="(date.diffMonths(Date(1999, 7, 16)), 0);
_assertPred!"=="(date.diffMonths(Date(1999, 7, 21)), 0);
_assertPred!"=="(date.diffMonths(Date(1999, 7, 26)), 0);
_assertPred!"=="(date.diffMonths(Date(1999, 7, 31)), 0);
_assertPred!"=="(date.diffMonths(Date(1999, 8, 1)), -1);
_assertPred!"=="(date.diffMonths(Date(1990, 6, 30)), 109);
_assertPred!"=="(date.diffMonths(Date(1990, 7, 1)), 108);
_assertPred!"=="(date.diffMonths(Date(1990, 7, 6)), 108);
_assertPred!"=="(date.diffMonths(Date(1990, 7, 11)), 108);
_assertPred!"=="(date.diffMonths(Date(1990, 7, 16)), 108);
_assertPred!"=="(date.diffMonths(Date(1990, 7, 21)), 108);
_assertPred!"=="(date.diffMonths(Date(1990, 7, 26)), 108);
_assertPred!"=="(date.diffMonths(Date(1990, 7, 31)), 108);
_assertPred!"=="(date.diffMonths(Date(1990, 8, 1)), 107);
_assertPred!"=="(Date(1999, 6, 30).diffMonths(date), -1);
_assertPred!"=="(Date(1999, 7, 1).diffMonths(date), 0);
_assertPred!"=="(Date(1999, 7, 6).diffMonths(date), 0);
_assertPred!"=="(Date(1999, 7, 11).diffMonths(date), 0);
_assertPred!"=="(Date(1999, 7, 16).diffMonths(date), 0);
_assertPred!"=="(Date(1999, 7, 21).diffMonths(date), 0);
_assertPred!"=="(Date(1999, 7, 26).diffMonths(date), 0);
_assertPred!"=="(Date(1999, 7, 31).diffMonths(date), 0);
_assertPred!"=="(Date(1999, 8, 1).diffMonths(date), 1);
_assertPred!"=="(Date(1990, 6, 30).diffMonths(date), -109);
_assertPred!"=="(Date(1990, 7, 1).diffMonths(date), -108);
_assertPred!"=="(Date(1990, 7, 6).diffMonths(date), -108);
_assertPred!"=="(Date(1990, 7, 11).diffMonths(date), -108);
_assertPred!"=="(Date(1990, 7, 16).diffMonths(date), -108);
_assertPred!"=="(Date(1990, 7, 21).diffMonths(date), -108);
_assertPred!"=="(Date(1990, 7, 26).diffMonths(date), -108);
_assertPred!"=="(Date(1990, 7, 31).diffMonths(date), -108);
_assertPred!"=="(Date(1990, 8, 1).diffMonths(date), -107);
//Test B.C.
auto dateBC = Date(-1999, 7, 6);
_assertPred!"=="(dateBC.diffMonths(Date(-2000, 6, 5)), 13);
_assertPred!"=="(dateBC.diffMonths(Date(-2000, 7, 5)), 12);
_assertPred!"=="(dateBC.diffMonths(Date(-2000, 8, 5)), 11);
_assertPred!"=="(dateBC.diffMonths(Date(-2000, 9, 5)), 10);
_assertPred!"=="(dateBC.diffMonths(Date(-2000, 10, 5)), 9);
_assertPred!"=="(dateBC.diffMonths(Date(-2000, 11, 5)), 8);
_assertPred!"=="(dateBC.diffMonths(Date(-2000, 12, 5)), 7);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 1, 5)), 6);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 2, 6)), 5);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 3, 6)), 4);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 4, 6)), 3);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 5, 6)), 2);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 6, 6)), 1);
_assertPred!"=="(dateBC.diffMonths(dateBC), 0);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 8, 6)), -1);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 9, 6)), -2);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 10, 6)), -3);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 11, 6)), -4);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 12, 6)), -5);
_assertPred!"=="(dateBC.diffMonths(Date(-1998, 1, 6)), -6);
_assertPred!"=="(dateBC.diffMonths(Date(-1998, 2, 6)), -7);
_assertPred!"=="(dateBC.diffMonths(Date(-1998, 3, 6)), -8);
_assertPred!"=="(dateBC.diffMonths(Date(-1998, 4, 6)), -9);
_assertPred!"=="(dateBC.diffMonths(Date(-1998, 5, 6)), -10);
_assertPred!"=="(dateBC.diffMonths(Date(-1998, 6, 6)), -11);
_assertPred!"=="(dateBC.diffMonths(Date(-1998, 7, 6)), -12);
_assertPred!"=="(dateBC.diffMonths(Date(-1998, 8, 6)), -13);
_assertPred!"=="(Date(-2000, 6, 5).diffMonths(dateBC), -13);
_assertPred!"=="(Date(-2000, 7, 5).diffMonths(dateBC), -12);
_assertPred!"=="(Date(-2000, 8, 5).diffMonths(dateBC), -11);
_assertPred!"=="(Date(-2000, 9, 5).diffMonths(dateBC), -10);
_assertPred!"=="(Date(-2000, 10, 5).diffMonths(dateBC), -9);
_assertPred!"=="(Date(-2000, 11, 5).diffMonths(dateBC), -8);
_assertPred!"=="(Date(-2000, 12, 5).diffMonths(dateBC), -7);
_assertPred!"=="(Date(-1999, 1, 5).diffMonths(dateBC), -6);
_assertPred!"=="(Date(-1999, 2, 6).diffMonths(dateBC), -5);
_assertPred!"=="(Date(-1999, 3, 6).diffMonths(dateBC), -4);
_assertPred!"=="(Date(-1999, 4, 6).diffMonths(dateBC), -3);
_assertPred!"=="(Date(-1999, 5, 6).diffMonths(dateBC), -2);
_assertPred!"=="(Date(-1999, 6, 6).diffMonths(dateBC), -1);
_assertPred!"=="(Date(-1999, 8, 6).diffMonths(dateBC), 1);
_assertPred!"=="(Date(-1999, 9, 6).diffMonths(dateBC), 2);
_assertPred!"=="(Date(-1999, 10, 6).diffMonths(dateBC), 3);
_assertPred!"=="(Date(-1999, 11, 6).diffMonths(dateBC), 4);
_assertPred!"=="(Date(-1999, 12, 6).diffMonths(dateBC), 5);
_assertPred!"=="(Date(-1998, 1, 6).diffMonths(dateBC), 6);
_assertPred!"=="(Date(-1998, 2, 6).diffMonths(dateBC), 7);
_assertPred!"=="(Date(-1998, 3, 6).diffMonths(dateBC), 8);
_assertPred!"=="(Date(-1998, 4, 6).diffMonths(dateBC), 9);
_assertPred!"=="(Date(-1998, 5, 6).diffMonths(dateBC), 10);
_assertPred!"=="(Date(-1998, 6, 6).diffMonths(dateBC), 11);
_assertPred!"=="(Date(-1998, 7, 6).diffMonths(dateBC), 12);
_assertPred!"=="(Date(-1998, 8, 6).diffMonths(dateBC), 13);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 6, 30)), 1);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 7, 1)), 0);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 7, 6)), 0);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 7, 11)), 0);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 7, 16)), 0);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 7, 21)), 0);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 7, 26)), 0);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 7, 31)), 0);
_assertPred!"=="(dateBC.diffMonths(Date(-1999, 8, 1)), -1);
_assertPred!"=="(dateBC.diffMonths(Date(-2008, 6, 30)), 109);
_assertPred!"=="(dateBC.diffMonths(Date(-2008, 7, 1)), 108);
_assertPred!"=="(dateBC.diffMonths(Date(-2008, 7, 6)), 108);
_assertPred!"=="(dateBC.diffMonths(Date(-2008, 7, 11)), 108);
_assertPred!"=="(dateBC.diffMonths(Date(-2008, 7, 16)), 108);
_assertPred!"=="(dateBC.diffMonths(Date(-2008, 7, 21)), 108);
_assertPred!"=="(dateBC.diffMonths(Date(-2008, 7, 26)), 108);
_assertPred!"=="(dateBC.diffMonths(Date(-2008, 7, 31)), 108);
_assertPred!"=="(dateBC.diffMonths(Date(-2008, 8, 1)), 107);
_assertPred!"=="(Date(-1999, 6, 30).diffMonths(dateBC), -1);
_assertPred!"=="(Date(-1999, 7, 1).diffMonths(dateBC), 0);
_assertPred!"=="(Date(-1999, 7, 6).diffMonths(dateBC), 0);
_assertPred!"=="(Date(-1999, 7, 11).diffMonths(dateBC), 0);
_assertPred!"=="(Date(-1999, 7, 16).diffMonths(dateBC), 0);
_assertPred!"=="(Date(-1999, 7, 21).diffMonths(dateBC), 0);
_assertPred!"=="(Date(-1999, 7, 26).diffMonths(dateBC), 0);
_assertPred!"=="(Date(-1999, 7, 31).diffMonths(dateBC), 0);
_assertPred!"=="(Date(-1999, 8, 1).diffMonths(dateBC), 1);
_assertPred!"=="(Date(-2008, 6, 30).diffMonths(dateBC), -109);
_assertPred!"=="(Date(-2008, 7, 1).diffMonths(dateBC), -108);
_assertPred!"=="(Date(-2008, 7, 6).diffMonths(dateBC), -108);
_assertPred!"=="(Date(-2008, 7, 11).diffMonths(dateBC), -108);
_assertPred!"=="(Date(-2008, 7, 16).diffMonths(dateBC), -108);
_assertPred!"=="(Date(-2008, 7, 21).diffMonths(dateBC), -108);
_assertPred!"=="(Date(-2008, 7, 26).diffMonths(dateBC), -108);
_assertPred!"=="(Date(-2008, 7, 31).diffMonths(dateBC), -108);
_assertPred!"=="(Date(-2008, 8, 1).diffMonths(dateBC), -107);
//Test Both
_assertPred!"=="(Date(3, 3, 3).diffMonths(Date(-5, 5, 5)), 94);
_assertPred!"=="(Date(-5, 5, 5).diffMonths(Date(3, 3, 3)), -94);
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, date.diffMonths(date)));
static assert(__traits(compiles, cdate.diffMonths(date)));
static assert(__traits(compiles, idate.diffMonths(date)));
static assert(__traits(compiles, date.diffMonths(cdate)));
static assert(__traits(compiles, cdate.diffMonths(cdate)));
static assert(__traits(compiles, idate.diffMonths(cdate)));
static assert(__traits(compiles, date.diffMonths(idate)));
static assert(__traits(compiles, cdate.diffMonths(idate)));
static assert(__traits(compiles, idate.diffMonths(idate)));
//Verify Examples.
assert(Date(1999, 2, 1).diffMonths(Date(1999, 1, 31)) == 1);
assert(Date(1999, 1, 31).diffMonths(Date(1999, 2, 1)) == -1);
assert(Date(1999, 3, 1).diffMonths(Date(1999, 1, 1)) == 2);
assert(Date(1999, 1, 1).diffMonths(Date(1999, 3, 31)) == -2);
}
}
/++
Whether this $(D Date) is in a leap year.
+/
@property bool isLeapYear() const pure nothrow
{
return yearIsLeapYear(_year);
}
unittest
{
version(testStdDateTime)
{
auto date = Date(1999, 7, 6);
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(!__traits(compiles, date.isLeapYear = true));
static assert(!__traits(compiles, cdate.isLeapYear = true));
static assert(!__traits(compiles, idate.isLeapYear = true));
}
}
/++
Day of the week this $(D Date) is on.
+/
@property DayOfWeek dayOfWeek() const pure nothrow
{
return getDayOfWeek(dayOfGregorianCal);
}
unittest
{
version(testStdDateTime)
{
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, cdate.dayOfWeek == DayOfWeek.sun));
static assert(!__traits(compiles, cdate.dayOfWeek = DayOfWeek.sun));
static assert(__traits(compiles, idate.dayOfWeek == DayOfWeek.sun));
static assert(!__traits(compiles, idate.dayOfWeek = DayOfWeek.sun));
}
}
/++
Day of the year this $(D Date) is on.
Examples:
--------------------
assert(Date(1999, 1, 1).dayOfYear == 1);
assert(Date(1999, 12, 31).dayOfYear == 365);
assert(Date(2000, 12, 31).dayOfYear == 366);
--------------------
+/
@property ushort dayOfYear() const pure nothrow
{
switch(_month)
{
case Month.jan:
return _day;
case Month.feb:
return cast(ushort)(31 + _day);
case Month.mar:
return cast(ushort)((isLeapYear ? 60 : 59) + _day);
case Month.apr:
return cast(ushort)((isLeapYear ? 91 : 90) + _day);
case Month.may:
return cast(ushort)((isLeapYear ? 121 : 120) + _day);
case Month.jun:
return cast(ushort)((isLeapYear ? 152 : 151) + _day);
case Month.jul:
return cast(ushort)((isLeapYear ? 182 : 181) + _day);
case Month.aug:
return cast(ushort)((isLeapYear ? 213 : 212) + _day);
case Month.sep:
return cast(ushort)((isLeapYear ? 244 : 243) + _day);
case Month.oct:
return cast(ushort)((isLeapYear ? 274 : 273) + _day);
case Month.nov:
return cast(ushort)((isLeapYear ? 305 : 304) + _day);
case Month.dec:
return cast(ushort)((isLeapYear ? 335 : 334) + _day);
default:
assert(0, "Invalid month.");
}
}
//Verify Examples.
version(testStdDateTime) unittest
{
assert(Date(1999, 1, 1).dayOfYear == 1);
assert(Date(1999, 12, 31).dayOfYear == 365);
assert(Date(2000, 12, 31).dayOfYear == 366);
}
version(testStdDateTime) unittest
{
foreach(year; filter!((a){return !yearIsLeapYear(a);})
(chain(testYearsBC, testYearsAD)))
{
foreach(doy; testDaysOfYear)
{
_assertPred!"=="(Date(year, doy.md.month, doy.md.day).dayOfYear,
doy.day);
}
}
foreach(year; filter!((a){return yearIsLeapYear(a);})
(chain(testYearsBC, testYearsAD)))
{
foreach(doy; testDaysOfLeapYear)
{
_assertPred!"=="(Date(year, doy.md.month, doy.md.day).dayOfYear,
doy.day);
}
}
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, cdate.dayOfYear == 187));
static assert(__traits(compiles, idate.dayOfYear == 187));
}
/++
Day of the year.
Params:
day = The day of the year to set which day of the year this
$(D Date) is on.
Throws:
$(D DateTimeException) if the given day is an invalid day of the
year.
+/
@property void dayOfYear(int day) pure
{
if(isLeapYear)
{
if(day <= 0 || day > daysInLeapYear)
throw new DateTimeException("Invalid day of the year.");
switch(day)
{
case 1: .. case 31:
{
_month = Month.jan;
_day = cast(ubyte)day;
break;
}
case 32: .. case 60:
{
_month = Month.feb;
_day = cast(ubyte)(day - 31);
break;
}
case 61: .. case 91:
{
_month = Month.mar;
_day = cast(ubyte)(day - 60);
break;
}
case 92: .. case 121:
{
_month = Month.apr;
_day = cast(ubyte)(day - 91);
break;
}
case 122: .. case 152:
{
_month = Month.may;
_day = cast(ubyte)(day - 121);
break;
}
case 153: .. case 182:
{
_month = Month.jun;
_day = cast(ubyte)(day - 152);
break;
}
case 183: .. case 213:
{
_month = Month.jul;
_day = cast(ubyte)(day - 182);
break;
}
case 214: .. case 244:
{
_month = Month.aug;
_day = cast(ubyte)(day - 213);
break;
}
case 245: .. case 274:
{
_month = Month.sep;
_day = cast(ubyte)(day - 244);
break;
}
case 275: .. case 305:
{
_month = Month.oct;
_day = cast(ubyte)(day - 274);
break;
}
case 306: .. case 335:
{
_month = Month.nov;
_day = cast(ubyte)(day - 305);
break;
}
case 336: .. case 366:
{
_month = Month.dec;
_day = cast(ubyte)(day - 335);
break;
}
default:
assert(0, "Invalid day of the year.");
}
}
else
{
if(day <= 0 || day > daysInYear)
throw new DateTimeException("Invalid day of the year.");
switch(day)
{
case 1: .. case 31:
{
_month = Month.jan;
_day = cast(ubyte)day;
break;
}
case 32: .. case 59:
{
_month = Month.feb;
_day = cast(ubyte)(day - 31);
break;
}
case 60: .. case 90:
{
_month = Month.mar;
_day = cast(ubyte)(day - 59);
break;
}
case 91: .. case 120:
{
_month = Month.apr;
_day = cast(ubyte)(day - 90);
break;
}
case 121: .. case 151:
{
_month = Month.may;
_day = cast(ubyte)(day - 120);
break;
}
case 152: .. case 181:
{
_month = Month.jun;
_day = cast(ubyte)(day - 151);
break;
}
case 182: .. case 212:
{
_month = Month.jul;
_day = cast(ubyte)(day - 181);
break;
}
case 213: .. case 243:
{
_month = Month.aug;
_day = cast(ubyte)(day - 212);
break;
}
case 244: .. case 273:
{
_month = Month.sep;
_day = cast(ubyte)(day - 243);
break;
}
case 274: .. case 304:
{
_month = Month.oct;
_day = cast(ubyte)(day - 273);
break;
}
case 305: .. case 334:
{
_month = Month.nov;
_day = cast(ubyte)(day - 304);
break;
}
case 335: .. case 365:
{
_month = Month.dec;
_day = cast(ubyte)(day - 334);
break;
}
default:
assert(0, "Invalid day of the year.");
}
}
}
version(testStdDateTime) unittest
{
static void test(Date date, int day, MonthDay expected, size_t line = __LINE__)
{
date.dayOfYear = day;
_assertPred!"=="(date.month, expected.month, "", __FILE__, line);
_assertPred!"=="(date.day, expected.day, "", __FILE__, line);
}
foreach(doy; testDaysOfYear)
{
test(Date(1999, 1, 1), doy.day, doy.md);
test(Date(-1, 1, 1), doy.day, doy.md);
}
foreach(doy; testDaysOfLeapYear)
{
test(Date(2000, 1, 1), doy.day, doy.md);
test(Date(-4, 1, 1), doy.day, doy.md);
}
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(!__traits(compiles, cdate.dayOfYear = 187));
static assert(!__traits(compiles, idate.dayOfYear = 187));
}
/++
The Xth day of the Gregorian Calendar that this $(D Date) is on.
Examples:
--------------------
assert(Date(1, 1, 1).dayOfGregorianCal == 1);
assert(Date(1, 12, 31).dayOfGregorianCal == 365);
assert(Date(2, 1, 1).dayOfGregorianCal == 366);
assert(Date(0, 12, 31).dayOfGregorianCal == 0);
assert(Date(0, 1, 1).dayOfGregorianCal == -365);
assert(Date(-1, 12, 31).dayOfGregorianCal == -366);
assert(Date(2000, 1, 1).dayOfGregorianCal == 730_120);
assert(Date(2010, 12, 31).dayOfGregorianCal == 734_137);
--------------------
+/
@property int dayOfGregorianCal() const pure nothrow
{
if(isAD)
{
if(_year == 1)
return dayOfYear;
int years = _year - 1;
auto days = (years / 400) * daysIn400Years;
years %= 400;
days += (years / 100) * daysIn100Years;
years %= 100;
days += (years / 4) * daysIn4Years;
years %= 4;
days += years * daysInYear;
days += dayOfYear;
return days;
}
else if(_year == 0)
return dayOfYear - daysInLeapYear;
else
{
int years = _year;
auto days = (years / 400) * daysIn400Years;
years %= 400;
days += (years / 100) * daysIn100Years;
years %= 100;
days += (years / 4) * daysIn4Years;
years %= 4;
if(years < 0)
{
days -= daysInLeapYear;
++years;
days += years * daysInYear;
days -= daysInYear - dayOfYear;
}
else
days -= daysInLeapYear - dayOfYear;
return days;
}
}
//Verify Examples.
version(testStdDateTime) unittest
{
assert(Date(1, 1, 1).dayOfGregorianCal == 1);
assert(Date(1, 12, 31).dayOfGregorianCal == 365);
assert(Date(2, 1, 1).dayOfGregorianCal == 366);
assert(Date(0, 12, 31).dayOfGregorianCal == 0);
assert(Date(0, 1, 1).dayOfGregorianCal == -365);
assert(Date(-1, 12, 31).dayOfGregorianCal == -366);
assert(Date(2000, 1, 1).dayOfGregorianCal == 730_120);
assert(Date(2010, 12, 31).dayOfGregorianCal == 734_137);
}
version(testStdDateTime) unittest
{
foreach(gd; chain(testGregDaysBC, testGregDaysAD))
_assertPred!"=="(gd.date.dayOfGregorianCal, gd.day);
auto date = Date(1999, 7, 6);
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, date.dayOfGregorianCal));
static assert(__traits(compiles, cdate.dayOfGregorianCal));
static assert(__traits(compiles, idate.dayOfGregorianCal));
}
/++
The Xth day of the Gregorian Calendar that this $(D Date) is on.
Params:
day = The day of the Gregorian Calendar to set this $(D Date) to.
Examples:
--------------------
auto date = Date.init;
date.dayOfGregorianCal = 1;
assert(date == Date(1, 1, 1));
date.dayOfGregorianCal = 365;
assert(date == Date(1, 12, 31));
date.dayOfGregorianCal = 366;
assert(date == Date(2, 1, 1));
date.dayOfGregorianCal = 0;
assert(date == Date(0, 12, 31));
date.dayOfGregorianCal = -365;
assert(date == Date(-0, 1, 1));
date.dayOfGregorianCal = -366;
assert(date == Date(-1, 12, 31));
date.dayOfGregorianCal = 730_120;
assert(date == Date(2000, 1, 1));
date.dayOfGregorianCal = 734_137;
assert(date == Date(2010, 12, 31));
--------------------
+/
@property void dayOfGregorianCal(int day) pure nothrow
{
this = Date(day);
}
unittest
{
version(testStdDateTime)
{
{
auto date = Date(1999, 7, 6);
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, date.dayOfGregorianCal = 187));
static assert(!__traits(compiles, cdate.dayOfGregorianCal = 187));
static assert(!__traits(compiles, idate.dayOfGregorianCal = 187));
}
//Verify Examples.
{
auto date = Date.init;
date.dayOfGregorianCal = 1;
assert(date == Date(1, 1, 1));
date.dayOfGregorianCal = 365;
assert(date == Date(1, 12, 31));
date.dayOfGregorianCal = 366;
assert(date == Date(2, 1, 1));
date.dayOfGregorianCal = 0;
assert(date == Date(0, 12, 31));
date.dayOfGregorianCal = -365;
assert(date == Date(-0, 1, 1));
date.dayOfGregorianCal = -366;
assert(date == Date(-1, 12, 31));
date.dayOfGregorianCal = 730_120;
assert(date == Date(2000, 1, 1));
date.dayOfGregorianCal = 734_137;
assert(date == Date(2010, 12, 31));
}
}
}
/++
The ISO 8601 week of the year that this $(D Date) is in.
See_Also:
$(WEB en.wikipedia.org/wiki/ISO_week_date, ISO Week Date)
+/
@property ubyte isoWeek() const pure nothrow
{
immutable weekday = dayOfWeek;
immutable adjustedWeekday = weekday == DayOfWeek.sun ? 7 : weekday;
immutable week = (dayOfYear - adjustedWeekday + 10) / 7;
try
{
if(week == 53)
{
switch(Date(_year + 1, 1, 1).dayOfWeek)
{
case DayOfWeek.mon:
case DayOfWeek.tue:
case DayOfWeek.wed:
case DayOfWeek.thu:
return 1;
case DayOfWeek.fri:
case DayOfWeek.sat:
case DayOfWeek.sun:
return 53;
default:
assert(0, "Invalid ISO Week");
}
}
else if(week > 0)
return cast(ubyte)week;
else
return Date(_year - 1, 12, 31).isoWeek;
}
catch(Exception e)
assert(0, "Date's constructor threw.");
}
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(Date(2009, 12, 28).isoWeek, 53);
_assertPred!"=="(Date(2009, 12, 29).isoWeek, 53);
_assertPred!"=="(Date(2009, 12, 30).isoWeek, 53);
_assertPred!"=="(Date(2009, 12, 31).isoWeek, 53);
_assertPred!"=="(Date(2010, 1, 1).isoWeek, 53);
_assertPred!"=="(Date(2010, 1, 2).isoWeek, 53);
_assertPred!"=="(Date(2010, 1, 3).isoWeek, 53);
_assertPred!"=="(Date(2010, 1, 4).isoWeek, 1);
_assertPred!"=="(Date(2010, 1, 5).isoWeek, 1);
_assertPred!"=="(Date(2010, 1, 6).isoWeek, 1);
_assertPred!"=="(Date(2010, 1, 7).isoWeek, 1);
_assertPred!"=="(Date(2010, 1, 8).isoWeek, 1);
_assertPred!"=="(Date(2010, 1, 9).isoWeek, 1);
_assertPred!"=="(Date(2010, 1, 10).isoWeek, 1);
_assertPred!"=="(Date(2010, 1, 11).isoWeek, 2);
_assertPred!"=="(Date(2010, 12, 31).isoWeek, 52);
_assertPred!"=="(Date(2004, 12, 26).isoWeek, 52);
_assertPred!"=="(Date(2004, 12, 27).isoWeek, 53);
_assertPred!"=="(Date(2004, 12, 28).isoWeek, 53);
_assertPred!"=="(Date(2004, 12, 29).isoWeek, 53);
_assertPred!"=="(Date(2004, 12, 30).isoWeek, 53);
_assertPred!"=="(Date(2004, 12, 31).isoWeek, 53);
_assertPred!"=="(Date(2005, 1, 1).isoWeek, 53);
_assertPred!"=="(Date(2005, 1, 2).isoWeek, 53);
_assertPred!"=="(Date(2005, 12, 31).isoWeek, 52);
_assertPred!"=="(Date(2007, 1, 1).isoWeek, 1);
_assertPred!"=="(Date(2007, 12, 30).isoWeek, 52);
_assertPred!"=="(Date(2007, 12, 31).isoWeek, 1);
_assertPred!"=="(Date(2008, 1, 1).isoWeek, 1);
_assertPred!"=="(Date(2008, 12, 28).isoWeek, 52);
_assertPred!"=="(Date(2008, 12, 29).isoWeek, 1);
_assertPred!"=="(Date(2008, 12, 30).isoWeek, 1);
_assertPred!"=="(Date(2008, 12, 31).isoWeek, 1);
_assertPred!"=="(Date(2009, 1, 1).isoWeek, 1);
_assertPred!"=="(Date(2009, 1, 2).isoWeek, 1);
_assertPred!"=="(Date(2009, 1, 3).isoWeek, 1);
_assertPred!"=="(Date(2009, 1, 4).isoWeek, 1);
//Test B.C.
//The algorithm should work identically for both A.D. and B.C. since
//it doesn't really take the year into account, so B.C. testing
//probably isn't really needed.
_assertPred!"=="(Date(0, 12, 31).isoWeek, 52);
_assertPred!"=="(Date(0, 1, 4).isoWeek, 1);
_assertPred!"=="(Date(0, 1, 1).isoWeek, 52);
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, cdate.isoWeek == 3));
static assert(!__traits(compiles, cdate.isoWeek = 3));
static assert(__traits(compiles, idate.isoWeek == 3));
static assert(!__traits(compiles, idate.isoWeek = 3));
}
}
/++
$(D Date) for the last day in the month that this $(D Date) is in.
Examples:
--------------------
assert(Date(1999, 1, 6).endOfMonth == Date(1999, 1, 31));
assert(Date(1999, 2, 7).endOfMonth == Date(1999, 2, 28));
assert(Date(2000, 2, 7).endOfMonth == Date(1999, 2, 29));
assert(Date(2000, 6, 4).endOfMonth == Date(1999, 6, 30));
--------------------
+/
@property Date endOfMonth() const pure nothrow
{
try
return Date(_year, _month, maxDay(_year, _month));
catch(Exception e)
assert(0, "Date's constructor threw.");
}
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(Date(1999, 1, 1).endOfMonth, Date(1999, 1, 31));
_assertPred!"=="(Date(1999, 2, 1).endOfMonth, Date(1999, 2, 28));
_assertPred!"=="(Date(2000, 2, 1).endOfMonth, Date(2000, 2, 29));
_assertPred!"=="(Date(1999, 3, 1).endOfMonth, Date(1999, 3, 31));
_assertPred!"=="(Date(1999, 4, 1).endOfMonth, Date(1999, 4, 30));
_assertPred!"=="(Date(1999, 5, 1).endOfMonth, Date(1999, 5, 31));
_assertPred!"=="(Date(1999, 6, 1).endOfMonth, Date(1999, 6, 30));
_assertPred!"=="(Date(1999, 7, 1).endOfMonth, Date(1999, 7, 31));
_assertPred!"=="(Date(1999, 8, 1).endOfMonth, Date(1999, 8, 31));
_assertPred!"=="(Date(1999, 9, 1).endOfMonth, Date(1999, 9, 30));
_assertPred!"=="(Date(1999, 10, 1).endOfMonth, Date(1999, 10, 31));
_assertPred!"=="(Date(1999, 11, 1).endOfMonth, Date(1999, 11, 30));
_assertPred!"=="(Date(1999, 12, 1).endOfMonth, Date(1999, 12, 31));
//Test B.C.
_assertPred!"=="(Date(-1999, 1, 1).endOfMonth, Date(-1999, 1, 31));
_assertPred!"=="(Date(-1999, 2, 1).endOfMonth, Date(-1999, 2, 28));
_assertPred!"=="(Date(-2000, 2, 1).endOfMonth, Date(-2000, 2, 29));
_assertPred!"=="(Date(-1999, 3, 1).endOfMonth, Date(-1999, 3, 31));
_assertPred!"=="(Date(-1999, 4, 1).endOfMonth, Date(-1999, 4, 30));
_assertPred!"=="(Date(-1999, 5, 1).endOfMonth, Date(-1999, 5, 31));
_assertPred!"=="(Date(-1999, 6, 1).endOfMonth, Date(-1999, 6, 30));
_assertPred!"=="(Date(-1999, 7, 1).endOfMonth, Date(-1999, 7, 31));
_assertPred!"=="(Date(-1999, 8, 1).endOfMonth, Date(-1999, 8, 31));
_assertPred!"=="(Date(-1999, 9, 1).endOfMonth, Date(-1999, 9, 30));
_assertPred!"=="(Date(-1999, 10, 1).endOfMonth, Date(-1999, 10, 31));
_assertPred!"=="(Date(-1999, 11, 1).endOfMonth, Date(-1999, 11, 30));
_assertPred!"=="(Date(-1999, 12, 1).endOfMonth, Date(-1999, 12, 31));
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(!__traits(compiles, cdate.endOfMonth = Date(1999, 7, 30)));
static assert(!__traits(compiles, idate.endOfMonth = Date(1999, 7, 30)));
//Verify Examples.
assert(Date(1999, 1, 6).endOfMonth == Date(1999, 1, 31));
assert(Date(1999, 2, 7).endOfMonth == Date(1999, 2, 28));
assert(Date(2000, 2, 7).endOfMonth == Date(2000, 2, 29));
assert(Date(2000, 6, 4).endOfMonth == Date(2000, 6, 30));
}
}
/++
The last day in the month that this $(D Date) is in.
Examples:
--------------------
assert(Date(1999, 1, 6).daysInMonth == 31);
assert(Date(1999, 2, 7).daysInMonth == 28);
assert(Date(2000, 2, 7).daysInMonth == 29);
assert(Date(2000, 6, 4).daysInMonth == 30);
--------------------
+/
@property ubyte daysInMonth() const pure nothrow
{
return maxDay(_year, _month);
}
/++
$(RED Scheduled for deprecation in January 2012.
Please use daysInMonth instead.)
+/
alias daysInMonth endofMonthDay;
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(Date(1999, 1, 1).daysInMonth, 31);
_assertPred!"=="(Date(1999, 2, 1).daysInMonth, 28);
_assertPred!"=="(Date(2000, 2, 1).daysInMonth, 29);
_assertPred!"=="(Date(1999, 3, 1).daysInMonth, 31);
_assertPred!"=="(Date(1999, 4, 1).daysInMonth, 30);
_assertPred!"=="(Date(1999, 5, 1).daysInMonth, 31);
_assertPred!"=="(Date(1999, 6, 1).daysInMonth, 30);
_assertPred!"=="(Date(1999, 7, 1).daysInMonth, 31);
_assertPred!"=="(Date(1999, 8, 1).daysInMonth, 31);
_assertPred!"=="(Date(1999, 9, 1).daysInMonth, 30);
_assertPred!"=="(Date(1999, 10, 1).daysInMonth, 31);
_assertPred!"=="(Date(1999, 11, 1).daysInMonth, 30);
_assertPred!"=="(Date(1999, 12, 1).daysInMonth, 31);
//Test B.C.
_assertPred!"=="(Date(-1999, 1, 1).daysInMonth, 31);
_assertPred!"=="(Date(-1999, 2, 1).daysInMonth, 28);
_assertPred!"=="(Date(-2000, 2, 1).daysInMonth, 29);
_assertPred!"=="(Date(-1999, 3, 1).daysInMonth, 31);
_assertPred!"=="(Date(-1999, 4, 1).daysInMonth, 30);
_assertPred!"=="(Date(-1999, 5, 1).daysInMonth, 31);
_assertPred!"=="(Date(-1999, 6, 1).daysInMonth, 30);
_assertPred!"=="(Date(-1999, 7, 1).daysInMonth, 31);
_assertPred!"=="(Date(-1999, 8, 1).daysInMonth, 31);
_assertPred!"=="(Date(-1999, 9, 1).daysInMonth, 30);
_assertPred!"=="(Date(-1999, 10, 1).daysInMonth, 31);
_assertPred!"=="(Date(-1999, 11, 1).daysInMonth, 30);
_assertPred!"=="(Date(-1999, 12, 1).daysInMonth, 31);
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(!__traits(compiles, cdate.daysInMonth = 30));
static assert(!__traits(compiles, idate.daysInMonth = 30));
//Verify Examples.
assert(Date(1999, 1, 6).daysInMonth == 31);
assert(Date(1999, 2, 7).daysInMonth == 28);
assert(Date(2000, 2, 7).daysInMonth == 29);
assert(Date(2000, 6, 4).daysInMonth == 30);
}
}
/++
Whether the current year is a date in A.D.
Examples:
--------------------
assert(Date(1, 1, 1).isAD);
assert(Date(2010, 12, 31).isAD);
assert(!Date(0, 12, 31).isAD);
assert(!Date(-2010, 1, 1).isAD);
--------------------
+/
@property bool isAD() const pure nothrow
{
return _year > 0;
}
unittest
{
version(testStdDateTime)
{
assert(Date(2010, 7, 4).isAD);
assert(Date(1, 1, 1).isAD);
assert(!Date(0, 1, 1).isAD);
assert(!Date(-1, 1, 1).isAD);
assert(!Date(-2010, 7, 4).isAD);
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, cdate.isAD));
static assert(__traits(compiles, idate.isAD));
//Verify Examples.
assert(Date(1, 1, 1).isAD);
assert(Date(2010, 12, 31).isAD);
assert(!Date(0, 12, 31).isAD);
assert(!Date(-2010, 1, 1).isAD);
}
}
/++
The julian day for this $(D Date) at noon (since the julian day changes
at noon).
+/
@property long julianDay() const pure nothrow
{
return dayOfGregorianCal + 1_721_425;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(Date(-4713, 11, 24).julianDay, 0);
_assertPred!"=="(Date(0, 12, 31).julianDay, 1_721_425);
_assertPred!"=="(Date(1, 1, 1).julianDay, 1_721_426);
_assertPred!"=="(Date(1582, 10, 15).julianDay, 2_299_161);
_assertPred!"=="(Date(1858, 11, 17).julianDay, 2_400_001);
_assertPred!"=="(Date(1982, 1, 4).julianDay, 2_444_974);
_assertPred!"=="(Date(1996, 3, 31).julianDay, 2_450_174);
_assertPred!"=="(Date(2010, 8, 24).julianDay, 2_455_433);
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, cdate.julianDay));
static assert(__traits(compiles, idate.julianDay));
}
}
/++
The modified julian day for any time on this date (since, the modified
julian day changes at midnight).
+/
@property long modJulianDay() const pure nothrow
{
return julianDay - 2_400_001;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(Date(1858, 11, 17).modJulianDay, 0);
_assertPred!"=="(Date(2010, 8, 24).modJulianDay, 55_432);
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, cdate.modJulianDay));
static assert(__traits(compiles, idate.modJulianDay));
}
}
/++
Converts this $(D Date) to a string with the format YYYYMMDD.
Examples:
--------------------
assert(Date(2010, 7, 4).toISOString() == "20100704");
assert(Date(1998, 12, 25).toISOString() == "19981225");
assert(Date(0, 1, 5).toISOString() == "00000105");
assert(Date(-4, 1, 5).toISOString() == "-00040105");
--------------------
+/
string toISOString() const nothrow
{
try
{
if(_year >= 0)
{
if(_year < 10_000)
return format("%04d%02d%02d", _year, _month, _day);
else
return format("+%05d%02d%02d", _year, _month, _day);
}
else if(_year > -10_000)
return format("%05d%02d%02d", _year, _month, _day);
else
return format("%06d%02d%02d", _year, _month, _day);
}
catch(Exception e)
assert(0, "format() threw.");
}
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(Date(9, 12, 4).toISOString(), "00091204");
_assertPred!"=="(Date(99, 12, 4).toISOString(), "00991204");
_assertPred!"=="(Date(999, 12, 4).toISOString(), "09991204");
_assertPred!"=="(Date(9999, 7, 4).toISOString(), "99990704");
_assertPred!"=="(Date(10000, 10, 20).toISOString(), "+100001020");
//Test B.C.
_assertPred!"=="(Date(0, 12, 4).toISOString(), "00001204");
_assertPred!"=="(Date(-9, 12, 4).toISOString(), "-00091204");
_assertPred!"=="(Date(-99, 12, 4).toISOString(), "-00991204");
_assertPred!"=="(Date(-999, 12, 4).toISOString(), "-09991204");
_assertPred!"=="(Date(-9999, 7, 4).toISOString(), "-99990704");
_assertPred!"=="(Date(-10000, 10, 20).toISOString(), "-100001020");
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, cdate.toISOString()));
static assert(__traits(compiles, idate.toISOString()));
//Verify Examples.
assert(Date(2010, 7, 4).toISOString() == "20100704");
assert(Date(1998, 12, 25).toISOString() == "19981225");
assert(Date(0, 1, 5).toISOString() == "00000105");
assert(Date(-4, 1, 5).toISOString() == "-00040105");
}
}
/++
Converts this $(D Date) to a string with the format YYYY-MM-DD.
Examples:
--------------------
assert(Date(2010, 7, 4).toISOExtString() == "2010-07-04");
assert(Date(1998, 12, 25).toISOExtString() == "1998-12-25");
assert(Date(0, 1, 5).toISOExtString() == "0000-01-05");
assert(Date(-4, 1, 5).toISOExtString() == "-0004-01-05");
--------------------
+/
string toISOExtString() const nothrow
{
try
{
if(_year >= 0)
{
if(_year < 10_000)
return format("%04d-%02d-%02d", _year, _month, _day);
else
return format("+%05d-%02d-%02d", _year, _month, _day);
}
else if(_year > -10_000)
return format("%05d-%02d-%02d", _year, _month, _day);
else
return format("%06d-%02d-%02d", _year, _month, _day);
}
catch(Exception e)
assert(0, "format() threw.");
}
/++
$(RED Scheduled for deprecation in November 2011.
Please use toISOExtString instead.)
+/
alias toISOExtString toISOExtendedString;
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(Date(9, 12, 4).toISOExtString(), "0009-12-04");
_assertPred!"=="(Date(99, 12, 4).toISOExtString(), "0099-12-04");
_assertPred!"=="(Date(999, 12, 4).toISOExtString(), "0999-12-04");
_assertPred!"=="(Date(9999, 7, 4).toISOExtString(), "9999-07-04");
_assertPred!"=="(Date(10000, 10, 20).toISOExtString(), "+10000-10-20");
//Test B.C.
_assertPred!"=="(Date(0, 12, 4).toISOExtString(), "0000-12-04");
_assertPred!"=="(Date(-9, 12, 4).toISOExtString(), "-0009-12-04");
_assertPred!"=="(Date(-99, 12, 4).toISOExtString(), "-0099-12-04");
_assertPred!"=="(Date(-999, 12, 4).toISOExtString(), "-0999-12-04");
_assertPred!"=="(Date(-9999, 7, 4).toISOExtString(), "-9999-07-04");
_assertPred!"=="(Date(-10000, 10, 20).toISOExtString(), "-10000-10-20");
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, cdate.toISOExtString()));
static assert(__traits(compiles, idate.toISOExtString()));
//Verify Examples.
assert(Date(2010, 7, 4).toISOExtString() == "2010-07-04");
assert(Date(1998, 12, 25).toISOExtString() == "1998-12-25");
assert(Date(0, 1, 5).toISOExtString() == "0000-01-05");
assert(Date(-4, 1, 5).toISOExtString() == "-0004-01-05");
}
}
/++
Converts this $(D Date) to a string with the format YYYY-Mon-DD.
Examples:
--------------------
assert(Date(2010, 7, 4).toSimpleString() == "2010-Jul-04");
assert(Date(1998, 12, 25).toSimpleString() == "1998-Dec-25");
assert(Date(0, 1, 5).toSimpleString() == "0000-Jan-05");
assert(Date(-4, 1, 5).toSimpleString() == "-0004-Jan-05");
--------------------
+/
string toSimpleString() const nothrow
{
try
{
if(_year >= 0)
{
if(_year < 10_000)
return format("%04d-%s-%02d", _year, monthToString(_month, false), _day);
else
return format("+%05d-%s-%02d", _year, monthToString(_month, false), _day);
}
else if(_year > -10_000)
return format("%05d-%s-%02d", _year, monthToString(_month, false), _day);
else
return format("%06d-%s-%02d", _year, monthToString(_month, false), _day);
}
catch(Exception e)
assert(0, "format() threw.");
}
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(Date(9, 12, 4).toSimpleString(), "0009-Dec-04");
_assertPred!"=="(Date(99, 12, 4).toSimpleString(), "0099-Dec-04");
_assertPred!"=="(Date(999, 12, 4).toSimpleString(), "0999-Dec-04");
_assertPred!"=="(Date(9999, 7, 4).toSimpleString(), "9999-Jul-04");
_assertPred!"=="(Date(10000, 10, 20).toSimpleString(), "+10000-Oct-20");
//Test B.C.
_assertPred!"=="(Date(0, 12, 4).toSimpleString(), "0000-Dec-04");
_assertPred!"=="(Date(-9, 12, 4).toSimpleString(), "-0009-Dec-04");
_assertPred!"=="(Date(-99, 12, 4).toSimpleString(), "-0099-Dec-04");
_assertPred!"=="(Date(-999, 12, 4).toSimpleString(), "-0999-Dec-04");
_assertPred!"=="(Date(-9999, 7, 4).toSimpleString(), "-9999-Jul-04");
_assertPred!"=="(Date(-10000, 10, 20).toSimpleString(), "-10000-Oct-20");
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, cdate.toSimpleString()));
static assert(__traits(compiles, idate.toSimpleString()));
//Verify Examples.
assert(Date(2010, 7, 4).toSimpleString() == "2010-Jul-04");
assert(Date(1998, 12, 25).toSimpleString() == "1998-Dec-25");
assert(Date(0, 1, 5).toSimpleString() == "0000-Jan-05");
assert(Date(-4, 1, 5).toSimpleString() == "-0004-Jan-05");
}
}
//TODO Add a function which returns a string in a user-specified format.
/+
Converts this $(D Date) to a string.
+/
//Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
//have versions of toString() with extra modifiers, so we define one version
//with modifiers and one without.
string toString()
{
return toSimpleString();
}
/++
Converts this $(D Date) to a string.
+/
//Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
//have versions of toString() with extra modifiers, so we define one version
//with modifiers and one without.
string toString() const nothrow
{
return toSimpleString();
}
unittest
{
version(testStdDateTime)
{
auto date = Date(1999, 7, 6);
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(__traits(compiles, date.toString()));
static assert(__traits(compiles, cdate.toString()));
static assert(__traits(compiles, idate.toString()));
}
}
/++
Creates a $(D Date) from a string with the format YYYYMMDD. Whitespace
is stripped from the given string.
Params:
isoString = A string formatted in the ISO format for dates.
Throws:
$(D DateTimeException) if the given string is not in the ISO format
or if the resulting $(D Date) would not be valid.
Examples:
--------------------
assert(Date.fromISOString("20100704") == Date(2010, 7, 4));
assert(Date.fromISOString("19981225") == Date(1998, 12, 25));
assert(Date.fromISOString("00000105") == Date(0, 1, 5));
assert(Date.fromISOString("-00040105") == Date(-4, 1, 5));
assert(Date.fromISOString(" 20100704 ") == Date(2010, 7, 4));
--------------------
+/
static Date fromISOString(S)(in S isoString)
if(isSomeString!S)
{
auto dstr = to!dstring(strip(isoString));
enforce(dstr.length >= 8, new DateTimeException(format("Invalid ISO String: %s", isoString)));
auto day = dstr[$-2 .. $];
auto month = dstr[$-4 .. $-2];
auto year = dstr[0 .. $-4];
enforce(!canFind!(not!isDigit)(day), new DateTimeException(format("Invalid ISO String: %s", isoString)));
enforce(!canFind!(not!isDigit)(month), new DateTimeException(format("Invalid ISO String: %s", isoString)));
if(year.length > 4)
{
enforce(year.startsWith("-") || year.startsWith("+"),
new DateTimeException(format("Invalid ISO String: %s", isoString)));
enforce(!canFind!(not!isDigit)(year[1..$]),
new DateTimeException(format("Invalid ISO String: %s", isoString)));
}
else
enforce(!canFind!(not!isDigit)(year), new DateTimeException(format("Invalid ISO String: %s", isoString)));
return Date(to!short(year), to!ubyte(month), to!ubyte(day));
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException(Date.fromISOString(""));
assertThrown!DateTimeException(Date.fromISOString("990704"));
assertThrown!DateTimeException(Date.fromISOString("0100704"));
assertThrown!DateTimeException(Date.fromISOString("2010070"));
assertThrown!DateTimeException(Date.fromISOString("2010070 "));
assertThrown!DateTimeException(Date.fromISOString("120100704"));
assertThrown!DateTimeException(Date.fromISOString("-0100704"));
assertThrown!DateTimeException(Date.fromISOString("+0100704"));
assertThrown!DateTimeException(Date.fromISOString("2010070a"));
assertThrown!DateTimeException(Date.fromISOString("20100a04"));
assertThrown!DateTimeException(Date.fromISOString("2010a704"));
assertThrown!DateTimeException(Date.fromISOString("99-07-04"));
assertThrown!DateTimeException(Date.fromISOString("010-07-04"));
assertThrown!DateTimeException(Date.fromISOString("2010-07-0"));
assertThrown!DateTimeException(Date.fromISOString("2010-07-0 "));
assertThrown!DateTimeException(Date.fromISOString("12010-07-04"));
assertThrown!DateTimeException(Date.fromISOString("-010-07-04"));
assertThrown!DateTimeException(Date.fromISOString("+010-07-04"));
assertThrown!DateTimeException(Date.fromISOString("2010-07-0a"));
assertThrown!DateTimeException(Date.fromISOString("2010-0a-04"));
assertThrown!DateTimeException(Date.fromISOString("2010-a7-04"));
assertThrown!DateTimeException(Date.fromISOString("2010/07/04"));
assertThrown!DateTimeException(Date.fromISOString("2010/7/04"));
assertThrown!DateTimeException(Date.fromISOString("2010/7/4"));
assertThrown!DateTimeException(Date.fromISOString("2010/07/4"));
assertThrown!DateTimeException(Date.fromISOString("2010-7-04"));
assertThrown!DateTimeException(Date.fromISOString("2010-7-4"));
assertThrown!DateTimeException(Date.fromISOString("2010-07-4"));
assertThrown!DateTimeException(Date.fromISOString("99Jul04"));
assertThrown!DateTimeException(Date.fromISOString("010Jul04"));
assertThrown!DateTimeException(Date.fromISOString("2010Jul0"));
assertThrown!DateTimeException(Date.fromISOString("2010Jul0 "));
assertThrown!DateTimeException(Date.fromISOString("12010Jul04"));
assertThrown!DateTimeException(Date.fromISOString("-010Jul04"));
assertThrown!DateTimeException(Date.fromISOString("+010Jul04"));
assertThrown!DateTimeException(Date.fromISOString("2010Jul0a"));
assertThrown!DateTimeException(Date.fromISOString("2010Jua04"));
assertThrown!DateTimeException(Date.fromISOString("2010aul04"));
assertThrown!DateTimeException(Date.fromISOString("99-Jul-04"));
assertThrown!DateTimeException(Date.fromISOString("010-Jul-04"));
assertThrown!DateTimeException(Date.fromISOString("2010-Jul-0"));
assertThrown!DateTimeException(Date.fromISOString("2010-Jul-0 "));
assertThrown!DateTimeException(Date.fromISOString("12010-Jul-04"));
assertThrown!DateTimeException(Date.fromISOString("-010-Jul-04"));
assertThrown!DateTimeException(Date.fromISOString("+010-Jul-04"));
assertThrown!DateTimeException(Date.fromISOString("2010-Jul-0a"));
assertThrown!DateTimeException(Date.fromISOString("2010-Jua-04"));
assertThrown!DateTimeException(Date.fromISOString("2010-Jal-04"));
assertThrown!DateTimeException(Date.fromISOString("2010-aul-04"));
assertThrown!DateTimeException(Date.fromISOString("2010-07-04"));
assertThrown!DateTimeException(Date.fromISOString("2010-Jul-04"));
_assertPred!"=="(Date.fromISOString("19990706"), Date(1999, 7, 6));
_assertPred!"=="(Date.fromISOString("-19990706"), Date(-1999, 7, 6));
_assertPred!"=="(Date.fromISOString("+019990706"), Date(1999, 7, 6));
_assertPred!"=="(Date.fromISOString("19990706 "), Date(1999, 7, 6));
_assertPred!"=="(Date.fromISOString(" 19990706"), Date(1999, 7, 6));
_assertPred!"=="(Date.fromISOString(" 19990706 "), Date(1999, 7, 6));
//Verify Examples.
assert(Date.fromISOString("20100704") == Date(2010, 7, 4));
assert(Date.fromISOString("19981225") == Date(1998, 12, 25));
assert(Date.fromISOString("00000105") == Date(0, 1, 5));
assert(Date.fromISOString("-00040105") == Date(-4, 1, 5));
assert(Date.fromISOString(" 20100704 ") == Date(2010, 7, 4));
}
}
/++
Creates a $(D Date) from a string with the format YYYY-MM-DD. Whitespace
is stripped from the given string.
Params:
isoExtString = A string formatted in the ISO Extended format for
dates.
Throws:
$(D DateTimeException) if the given string is not in the ISO
Extended format or if the resulting $(D Date) would not be valid.
Examples:
--------------------
assert(Date.fromISOExtString("2010-07-04") == Date(2010, 7, 4));
assert(Date.fromISOExtString("1998-12-25") == Date(1998, 12, 25));
assert(Date.fromISOExtString("0000-01-05") == Date(0, 1, 5));
assert(Date.fromISOExtString("-0004-01-05") == Date(-4, 1, 5));
assert(Date.fromISOExtString(" 2010-07-04 ") == Date(2010, 7, 4));
--------------------
+/
static Date fromISOExtString(S)(in S isoExtString)
if(isSomeString!(S))
{
auto dstr = to!dstring(strip(isoExtString));
enforce(dstr.length >= 10, new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
auto day = dstr[$-2 .. $];
auto month = dstr[$-5 .. $-3];
auto year = dstr[0 .. $-6];
enforce(dstr[$-3] == '-', new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
enforce(dstr[$-6] == '-', new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
enforce(!canFind!(not!isDigit)(day),
new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
enforce(!canFind!(not!isDigit)(month),
new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
if(year.length > 4)
{
enforce(year.startsWith("-") || year.startsWith("+"),
new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
enforce(!canFind!(not!isDigit)(year[1..$]),
new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
}
else
enforce(!canFind!(not!isDigit)(year),
new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
return Date(to!short(year), to!ubyte(month), to!ubyte(day));
}
/++
$(RED Scheduled for deprecation in November 2011.
Please use fromISOExtString instead.)
+/
static Date fromISOExtendedString(S)(in S isoExtString)
if(isSomeString!(S))
{
pragma(msg, softDeprec!("2.053", "November 2011", "fromISOExtendedString", "fromISOExtString"));
return fromISOExtString!string(isoExtString);
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException(Date.fromISOExtString(""));
assertThrown!DateTimeException(Date.fromISOExtString("990704"));
assertThrown!DateTimeException(Date.fromISOExtString("0100704"));
assertThrown!DateTimeException(Date.fromISOExtString("2010070"));
assertThrown!DateTimeException(Date.fromISOExtString("2010070 "));
assertThrown!DateTimeException(Date.fromISOExtString("120100704"));
assertThrown!DateTimeException(Date.fromISOExtString("-0100704"));
assertThrown!DateTimeException(Date.fromISOExtString("+0100704"));
assertThrown!DateTimeException(Date.fromISOExtString("2010070a"));
assertThrown!DateTimeException(Date.fromISOExtString("20100a04"));
assertThrown!DateTimeException(Date.fromISOExtString("2010a704"));
assertThrown!DateTimeException(Date.fromISOExtString("99-07-04"));
assertThrown!DateTimeException(Date.fromISOExtString("010-07-04"));
assertThrown!DateTimeException(Date.fromISOExtString("2010-07-0"));
assertThrown!DateTimeException(Date.fromISOExtString("2010-07-0 "));
assertThrown!DateTimeException(Date.fromISOExtString("12010-07-04"));
assertThrown!DateTimeException(Date.fromISOExtString("-010-07-04"));
assertThrown!DateTimeException(Date.fromISOExtString("+010-07-04"));
assertThrown!DateTimeException(Date.fromISOExtString("2010-07-0a"));
assertThrown!DateTimeException(Date.fromISOExtString("2010-0a-04"));
assertThrown!DateTimeException(Date.fromISOExtString("2010-a7-04"));
assertThrown!DateTimeException(Date.fromISOExtString("2010/07/04"));
assertThrown!DateTimeException(Date.fromISOExtString("2010/7/04"));
assertThrown!DateTimeException(Date.fromISOExtString("2010/7/4"));
assertThrown!DateTimeException(Date.fromISOExtString("2010/07/4"));
assertThrown!DateTimeException(Date.fromISOExtString("2010-7-04"));
assertThrown!DateTimeException(Date.fromISOExtString("2010-7-4"));
assertThrown!DateTimeException(Date.fromISOExtString("2010-07-4"));
assertThrown!DateTimeException(Date.fromISOExtString("99Jul04"));
assertThrown!DateTimeException(Date.fromISOExtString("010Jul04"));
assertThrown!DateTimeException(Date.fromISOExtString("2010Jul0"));
assertThrown!DateTimeException(Date.fromISOExtString("2010-Jul-0 "));
assertThrown!DateTimeException(Date.fromISOExtString("12010Jul04"));
assertThrown!DateTimeException(Date.fromISOExtString("-010Jul04"));
assertThrown!DateTimeException(Date.fromISOExtString("+010Jul04"));
assertThrown!DateTimeException(Date.fromISOExtString("2010Jul0a"));
assertThrown!DateTimeException(Date.fromISOExtString("2010Jua04"));
assertThrown!DateTimeException(Date.fromISOExtString("2010aul04"));
assertThrown!DateTimeException(Date.fromISOExtString("99-Jul-04"));
assertThrown!DateTimeException(Date.fromISOExtString("010-Jul-04"));
assertThrown!DateTimeException(Date.fromISOExtString("2010-Jul-0"));
assertThrown!DateTimeException(Date.fromISOExtString("2010Jul0 "));
assertThrown!DateTimeException(Date.fromISOExtString("12010-Jul-04"));
assertThrown!DateTimeException(Date.fromISOExtString("-010-Jul-04"));
assertThrown!DateTimeException(Date.fromISOExtString("+010-Jul-04"));
assertThrown!DateTimeException(Date.fromISOExtString("2010-Jul-0a"));
assertThrown!DateTimeException(Date.fromISOExtString("2010-Jua-04"));
assertThrown!DateTimeException(Date.fromISOExtString("2010-Jal-04"));
assertThrown!DateTimeException(Date.fromISOExtString("2010-aul-04"));
assertThrown!DateTimeException(Date.fromISOExtString("20100704"));
assertThrown!DateTimeException(Date.fromISOExtString("2010-Jul-04"));
_assertPred!"=="(Date.fromISOExtString("1999-07-06"), Date(1999, 7, 6));
_assertPred!"=="(Date.fromISOExtString("-1999-07-06"), Date(-1999, 7, 6));
_assertPred!"=="(Date.fromISOExtString("+01999-07-06"), Date(1999, 7, 6));
_assertPred!"=="(Date.fromISOExtString("1999-07-06 "), Date(1999, 7, 6));
_assertPred!"=="(Date.fromISOExtString(" 1999-07-06"), Date(1999, 7, 6));
_assertPred!"=="(Date.fromISOExtString(" 1999-07-06 "), Date(1999, 7, 6));
//Verify Examples.
assert(Date.fromISOExtString("2010-07-04") == Date(2010, 7, 4));
assert(Date.fromISOExtString("1998-12-25") == Date(1998, 12, 25));
assert(Date.fromISOExtString("0000-01-05") == Date(0, 1, 5));
assert(Date.fromISOExtString("-0004-01-05") == Date(-4, 1, 5));
assert(Date.fromISOExtString(" 2010-07-04 ") == Date(2010, 7, 4));
}
}
/++
Creates a $(D Date) from a string with the format YYYY-Mon-DD.
Whitespace is stripped from the given string.
Params:
simpleString = A string formatted in the way that toSimpleString
formats dates.
Throws:
$(D DateTimeException) if the given string is not in the correct
format or if the resulting $(D Date) would not be valid.
Examples:
--------------------
assert(Date.fromSimpleString("2010-Jul-04") == Date(2010, 7, 4));
assert(Date.fromSimpleString("1998-Dec-25") == Date(1998, 12, 25));
assert(Date.fromSimpleString("0000-Jan-05") == Date(0, 1, 5));
assert(Date.fromSimpleString("-0004-Jan-05") == Date(-4, 1, 5));
assert(Date.fromSimpleString(" 2010-Jul-04 ") == Date(2010, 7, 4));
--------------------
+/
static Date fromSimpleString(S)(in S simpleString)
if(isSomeString!(S))
{
auto dstr = to!dstring(strip(simpleString));
enforce(dstr.length >= 11, new DateTimeException(format("Invalid string format: %s", simpleString)));
auto day = dstr[$-2 .. $];
auto month = monthFromString(to!string(dstr[$-6 .. $-3]));
auto year = dstr[0 .. $-7];
enforce(dstr[$-3] == '-', new DateTimeException(format("Invalid string format: %s", simpleString)));
enforce(dstr[$-7] == '-', new DateTimeException(format("Invalid string format: %s", simpleString)));
enforce(!canFind!(not!isDigit)(day), new DateTimeException(format("Invalid string format: %s", simpleString)));
if(year.length > 4)
{
enforce(year.startsWith("-") || year.startsWith("+"),
new DateTimeException(format("Invalid string format: %s", simpleString)));
enforce(!canFind!(not!isDigit)(year[1..$]),
new DateTimeException(format("Invalid string format: %s", simpleString)));
}
else
enforce(!canFind!(not!isDigit)(year),
new DateTimeException(format("Invalid string format: %s", simpleString)));
return Date(to!short(year), month, to!ubyte(day));
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException(Date.fromSimpleString(""));
assertThrown!DateTimeException(Date.fromSimpleString("990704"));
assertThrown!DateTimeException(Date.fromSimpleString("0100704"));
assertThrown!DateTimeException(Date.fromSimpleString("2010070"));
assertThrown!DateTimeException(Date.fromSimpleString("2010070 "));
assertThrown!DateTimeException(Date.fromSimpleString("120100704"));
assertThrown!DateTimeException(Date.fromSimpleString("-0100704"));
assertThrown!DateTimeException(Date.fromSimpleString("+0100704"));
assertThrown!DateTimeException(Date.fromSimpleString("2010070a"));
assertThrown!DateTimeException(Date.fromSimpleString("20100a04"));
assertThrown!DateTimeException(Date.fromSimpleString("2010a704"));
assertThrown!DateTimeException(Date.fromSimpleString("99-07-04"));
assertThrown!DateTimeException(Date.fromSimpleString("010-07-04"));
assertThrown!DateTimeException(Date.fromSimpleString("2010-07-0"));
assertThrown!DateTimeException(Date.fromSimpleString("2010-07-0 "));
assertThrown!DateTimeException(Date.fromSimpleString("12010-07-04"));
assertThrown!DateTimeException(Date.fromSimpleString("-010-07-04"));
assertThrown!DateTimeException(Date.fromSimpleString("+010-07-04"));
assertThrown!DateTimeException(Date.fromSimpleString("2010-07-0a"));
assertThrown!DateTimeException(Date.fromSimpleString("2010-0a-04"));
assertThrown!DateTimeException(Date.fromSimpleString("2010-a7-04"));
assertThrown!DateTimeException(Date.fromSimpleString("2010/07/04"));
assertThrown!DateTimeException(Date.fromSimpleString("2010/7/04"));
assertThrown!DateTimeException(Date.fromSimpleString("2010/7/4"));
assertThrown!DateTimeException(Date.fromSimpleString("2010/07/4"));
assertThrown!DateTimeException(Date.fromSimpleString("2010-7-04"));
assertThrown!DateTimeException(Date.fromSimpleString("2010-7-4"));
assertThrown!DateTimeException(Date.fromSimpleString("2010-07-4"));
assertThrown!DateTimeException(Date.fromSimpleString("99Jul04"));
assertThrown!DateTimeException(Date.fromSimpleString("010Jul04"));
assertThrown!DateTimeException(Date.fromSimpleString("2010Jul0"));
assertThrown!DateTimeException(Date.fromSimpleString("2010Jul0 "));
assertThrown!DateTimeException(Date.fromSimpleString("12010Jul04"));
assertThrown!DateTimeException(Date.fromSimpleString("-010Jul04"));
assertThrown!DateTimeException(Date.fromSimpleString("+010Jul04"));
assertThrown!DateTimeException(Date.fromSimpleString("2010Jul0a"));
assertThrown!DateTimeException(Date.fromSimpleString("2010Jua04"));
assertThrown!DateTimeException(Date.fromSimpleString("2010aul04"));
assertThrown!DateTimeException(Date.fromSimpleString("99-Jul-04"));
assertThrown!DateTimeException(Date.fromSimpleString("010-Jul-04"));
assertThrown!DateTimeException(Date.fromSimpleString("2010-Jul-0"));
assertThrown!DateTimeException(Date.fromSimpleString("2010-Jul-0 "));
assertThrown!DateTimeException(Date.fromSimpleString("12010-Jul-04"));
assertThrown!DateTimeException(Date.fromSimpleString("-010-Jul-04"));
assertThrown!DateTimeException(Date.fromSimpleString("+010-Jul-04"));
assertThrown!DateTimeException(Date.fromSimpleString("2010-Jul-0a"));
assertThrown!DateTimeException(Date.fromSimpleString("2010-Jua-04"));
assertThrown!DateTimeException(Date.fromSimpleString("2010-Jal-04"));
assertThrown!DateTimeException(Date.fromSimpleString("2010-aul-04"));
assertThrown!DateTimeException(Date.fromSimpleString("20100704"));
assertThrown!DateTimeException(Date.fromSimpleString("2010-07-04"));
_assertPred!"=="(Date.fromSimpleString("1999-Jul-06"), Date(1999, 7, 6));
_assertPred!"=="(Date.fromSimpleString("-1999-Jul-06"), Date(-1999, 7, 6));
_assertPred!"=="(Date.fromSimpleString("+01999-Jul-06"), Date(1999, 7, 6));
_assertPred!"=="(Date.fromSimpleString("1999-Jul-06 "), Date(1999, 7, 6));
_assertPred!"=="(Date.fromSimpleString(" 1999-Jul-06"), Date(1999, 7, 6));
_assertPred!"=="(Date.fromSimpleString(" 1999-Jul-06 "), Date(1999, 7, 6));
//Verify Examples.
assert(Date.fromSimpleString("2010-Jul-04") == Date(2010, 7, 4));
assert(Date.fromSimpleString("1998-Dec-25") == Date(1998, 12, 25));
assert(Date.fromSimpleString("0000-Jan-05") == Date(0, 1, 5));
assert(Date.fromSimpleString("-0004-Jan-05") == Date(-4, 1, 5));
assert(Date.fromSimpleString(" 2010-Jul-04 ") == Date(2010, 7, 4));
}
}
//TODO Add function which takes a user-specified time format and produces a Date
//TODO Add function which takes pretty much any time-string and produces a Date
// Obviously, it will be less efficient, and it probably won't manage _every_
// possible date format, but a smart conversion function would be nice.
/++
Returns the $(D Date) farthest in the past which is representable by
$(D Date).
+/
@property static Date min() pure nothrow
{
auto date = Date.init;
date._year = short.min;
date._month = Month.jan;
date._day = 1;
return date;
}
unittest
{
version(testStdDateTime)
{
assert(Date.min.year < 0);
assert(Date.min < Date.max);
}
}
/++
Returns the $(D Date) farthest in the future which is representable by
$(D Date).
+/
@property static Date max() pure nothrow
{
auto date = Date.init;
date._year = short.max;
date._month = Month.dec;
date._day = 31;
return date;
}
unittest
{
version(testStdDateTime)
{
assert(Date.max.year > 0);
assert(Date.max > Date.min);
}
}
private:
/+
Whether the given values form a valid date.
Params:
year = The year to test.
month = The month of the Gregorian Calendar to test.
day = The day of the month to test.
+/
static bool _valid(int year, int month, int day) pure nothrow
{
if(!valid!"months"(month))
return false;
return valid!"days"(year, month, day);
}
/+
Adds the given number of days to this $(D Date). A negative number will
subtract.
The month will be adjusted along with the day if the number of days
added (or subtracted) would overflow (or underflow) the current month.
The year will be adjusted along with the month if the increase (or
decrease) to the month would cause it to overflow (or underflow) the
current year.
$(D addDays(numDays)) is effectively equivalent to
$(D date.dayOfGregorianCal = date.dayOfGregorianCal + days).
Params:
days = The number of days to add to this Date.
+/
ref Date addDays(long days) pure nothrow
{
dayOfGregorianCal = cast(int)(dayOfGregorianCal + days);
return this;
}
unittest
{
version(testStdDateTime)
{
//Test A.D.
{
auto date = Date(1999, 2, 28);
date.addDays(1);
_assertPred!"=="(date, Date(1999, 3, 1));
date.addDays(-1);
_assertPred!"=="(date, Date(1999, 2, 28));
}
{
auto date = Date(2000, 2, 28);
date.addDays(1);
_assertPred!"=="(date, Date(2000, 2, 29));
date.addDays(1);
_assertPred!"=="(date, Date(2000, 3, 1));
date.addDays(-1);
_assertPred!"=="(date, Date(2000, 2, 29));
}
{
auto date = Date(1999, 6, 30);
date.addDays(1);
_assertPred!"=="(date, Date(1999, 7, 1));
date.addDays(-1);
_assertPred!"=="(date, Date(1999, 6, 30));
}
{
auto date = Date(1999, 7, 31);
date.addDays(1);
_assertPred!"=="(date, Date(1999, 8, 1));
date.addDays(-1);
_assertPred!"=="(date, Date(1999, 7, 31));
}
{
auto date = Date(1999, 1, 1);
date.addDays(-1);
_assertPred!"=="(date, Date(1998, 12, 31));
date.addDays(1);
_assertPred!"=="(date, Date(1999, 1, 1));
}
{
auto date = Date(1999, 7, 6);
date.addDays(9);
_assertPred!"=="(date, Date(1999, 7, 15));
date.addDays(-11);
_assertPred!"=="(date, Date(1999, 7, 4));
date.addDays(30);
_assertPred!"=="(date, Date(1999, 8, 3));
date.addDays(-3);
_assertPred!"=="(date, Date(1999, 7, 31));
}
{
auto date = Date(1999, 7, 6);
date.addDays(365);
_assertPred!"=="(date, Date(2000, 7, 5));
date.addDays(-365);
_assertPred!"=="(date, Date(1999, 7, 6));
date.addDays(366);
_assertPred!"=="(date, Date(2000, 7, 6));
date.addDays(730);
_assertPred!"=="(date, Date(2002, 7, 6));
date.addDays(-1096);
_assertPred!"=="(date, Date(1999, 7, 6));
}
//Test B.C.
{
auto date = Date(-1999, 2, 28);
date.addDays(1);
_assertPred!"=="(date, Date(-1999, 3, 1));
date.addDays(-1);
_assertPred!"=="(date, Date(-1999, 2, 28));
}
{
auto date = Date(-2000, 2, 28);
date.addDays(1);
_assertPred!"=="(date, Date(-2000, 2, 29));
date.addDays(1);
_assertPred!"=="(date, Date(-2000, 3, 1));
date.addDays(-1);
_assertPred!"=="(date, Date(-2000, 2, 29));
}
{
auto date = Date(-1999, 6, 30);
date.addDays(1);
_assertPred!"=="(date, Date(-1999, 7, 1));
date.addDays(-1);
_assertPred!"=="(date, Date(-1999, 6, 30));
}
{
auto date = Date(-1999, 7, 31);
date.addDays(1);
_assertPred!"=="(date, Date(-1999, 8, 1));
date.addDays(-1);
_assertPred!"=="(date, Date(-1999, 7, 31));
}
{
auto date = Date(-1999, 1, 1);
date.addDays(-1);
_assertPred!"=="(date, Date(-2000, 12, 31));
date.addDays(1);
_assertPred!"=="(date, Date(-1999, 1, 1));
}
{
auto date = Date(-1999, 7, 6);
date.addDays(9);
_assertPred!"=="(date, Date(-1999, 7, 15));
date.addDays(-11);
_assertPred!"=="(date, Date(-1999, 7, 4));
date.addDays(30);
_assertPred!"=="(date, Date(-1999, 8, 3));
date.addDays(-3);
}
{
auto date = Date(-1999, 7, 6);
date.addDays(365);
_assertPred!"=="(date, Date(-1998, 7, 6));
date.addDays(-365);
_assertPred!"=="(date, Date(-1999, 7, 6));
date.addDays(366);
_assertPred!"=="(date, Date(-1998, 7, 7));
date.addDays(730);
_assertPred!"=="(date, Date(-1996, 7, 6));
date.addDays(-1096);
_assertPred!"=="(date, Date(-1999, 7, 6));
}
//Test Both
{
auto date = Date(1, 7, 6);
date.addDays(-365);
_assertPred!"=="(date, Date(0, 7, 6));
date.addDays(365);
_assertPred!"=="(date, Date(1, 7, 6));
date.addDays(-731);
_assertPred!"=="(date, Date(-1, 7, 6));
date.addDays(730);
_assertPred!"=="(date, Date(1, 7, 5));
}
const cdate = Date(1999, 7, 6);
immutable idate = Date(1999, 7, 6);
static assert(!__traits(compiles, cdate.addDays(12)));
static assert(!__traits(compiles, idate.addDays(12)));
}
}
pure invariant()
{
assert(valid!"months"(_month), "Invariant Failure: year [" ~
numToString(_year) ~
"] month [" ~
numToString(_month) ~
"] day [" ~
numToString(_day) ~
"]");
assert(valid!"days"(_year, _month, _day), "Invariant Failure: year [" ~
numToString(_year) ~
"] month [" ~
numToString(_month) ~
"] day [" ~
numToString(_day) ~
"]");
}
short _year = 1;
Month _month = Month.jan;
ubyte _day = 1;
}
/++
Represents a time of day with hours, minutes, and seconds. It uses 24 hour
time.
+/
struct TimeOfDay
{
public:
/++
Params:
hour = Hour of the day [0 - 24$(RPAREN).
minute = Minute of the hour [0 - 60$(RPAREN).
second = Second of the minute [0 - 60$(RPAREN).
Throws:
$(D DateTimeException) if the resulting $(D TimeOfDay) would be not
be valid.
+/
this(int hour, int minute, int second = 0) pure
{
enforceValid!"hours"(hour);
enforceValid!"minutes"(minute);
enforceValid!"seconds"(second);
_hour = cast(ubyte)hour;
_minute = cast(ubyte)minute;
_second = cast(ubyte)second;
}
unittest
{
version(testStdDateTime)
{
assert(TimeOfDay(0, 0) == TimeOfDay.init);
{
auto tod = TimeOfDay(0, 0);
_assertPred!"=="(tod._hour, 0);
_assertPred!"=="(tod._minute, 0);
_assertPred!"=="(tod._second, 0);
}
{
auto tod = TimeOfDay(12, 30, 33);
_assertPred!"=="(tod._hour, 12);
_assertPred!"=="(tod._minute, 30);
_assertPred!"=="(tod._second, 33);
}
{
auto tod = TimeOfDay(23, 59, 59);
_assertPred!"=="(tod._hour, 23);
_assertPred!"=="(tod._minute, 59);
_assertPred!"=="(tod._second, 59);
}
assertThrown!DateTimeException(TimeOfDay(24, 0, 0));
assertThrown!DateTimeException(TimeOfDay(0, 60, 0));
assertThrown!DateTimeException(TimeOfDay(0, 0, 60));
}
}
/++
Compares this $(D TimeOfDay) with the given $(D TimeOfDay).
Returns:
$(BOOKTABLE,
$(TR $(TD this < rhs) $(TD < 0))
$(TR $(TD this == rhs) $(TD 0))
$(TR $(TD this > rhs) $(TD > 0))
)
+/
int opCmp(in TimeOfDay rhs) const pure nothrow
{
if(_hour < rhs._hour)
return -1;
if(_hour > rhs._hour)
return 1;
if(_minute < rhs._minute)
return -1;
if(_minute > rhs._minute)
return 1;
if(_second < rhs._second)
return -1;
if(_second > rhs._second)
return 1;
return 0;
}
unittest
{
version(testStdDateTime)
{
_assertPred!("opCmp", "==")(TimeOfDay(0, 0, 0), TimeOfDay.init);
_assertPred!("opCmp", "==")(TimeOfDay(0, 0, 0), TimeOfDay(0, 0, 0));
_assertPred!("opCmp", "==")(TimeOfDay(12, 0, 0), TimeOfDay(12, 0, 0));
_assertPred!("opCmp", "==")(TimeOfDay(0, 30, 0), TimeOfDay(0, 30, 0));
_assertPred!("opCmp", "==")(TimeOfDay(0, 0, 33), TimeOfDay(0, 0, 33));
_assertPred!("opCmp", "==")(TimeOfDay(12, 30, 0), TimeOfDay(12, 30, 0));
_assertPred!("opCmp", "==")(TimeOfDay(12, 30, 33), TimeOfDay(12, 30, 33));
_assertPred!("opCmp", "==")(TimeOfDay(0, 30, 33), TimeOfDay(0, 30, 33));
_assertPred!("opCmp", "==")(TimeOfDay(0, 0, 33), TimeOfDay(0, 0, 33));
_assertPred!("opCmp", "<")(TimeOfDay(12, 30, 33), TimeOfDay(13, 30, 33));
_assertPred!("opCmp", ">")(TimeOfDay(13, 30, 33), TimeOfDay(12, 30, 33));
_assertPred!("opCmp", "<")(TimeOfDay(12, 30, 33), TimeOfDay(12, 31, 33));
_assertPred!("opCmp", ">")(TimeOfDay(12, 31, 33), TimeOfDay(12, 30, 33));
_assertPred!("opCmp", "<")(TimeOfDay(12, 30, 33), TimeOfDay(12, 30, 34));
_assertPred!("opCmp", ">")(TimeOfDay(12, 30, 34), TimeOfDay(12, 30, 33));
_assertPred!("opCmp", ">")(TimeOfDay(13, 30, 33), TimeOfDay(12, 30, 34));
_assertPred!("opCmp", "<")(TimeOfDay(12, 30, 34), TimeOfDay(13, 30, 33));
_assertPred!("opCmp", ">")(TimeOfDay(13, 30, 33), TimeOfDay(12, 31, 33));
_assertPred!("opCmp", "<")(TimeOfDay(12, 31, 33), TimeOfDay(13, 30, 33));
_assertPred!("opCmp", ">")(TimeOfDay(12, 31, 33), TimeOfDay(12, 30, 34));
_assertPred!("opCmp", "<")(TimeOfDay(12, 30, 34), TimeOfDay(12, 31, 33));
const ctod = TimeOfDay(12, 30, 33);
immutable itod = TimeOfDay(12, 30, 33);
static assert(__traits(compiles, ctod.opCmp(itod)));
static assert(__traits(compiles, itod.opCmp(ctod)));
}
}
/++
Hours passed midnight.
+/
@property ubyte hour() const pure nothrow
{
return _hour;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(TimeOfDay.init.hour, 0);
_assertPred!"=="(TimeOfDay(12, 0, 0).hour, 12);
const ctod = TimeOfDay(12, 0, 0);
immutable itod = TimeOfDay(12, 0, 0);
static assert(__traits(compiles, ctod.hour == 12));
static assert(__traits(compiles, itod.hour == 12));
}
}
/++
Hours passed midnight.
Params:
hour = The hour of the day to set this $(D TimeOfDay)'s hour to.
Throws:
$(D DateTimeException) if the given hour would result in an invalid
$(D TimeOfDay).
+/
@property void hour(int hour) pure
{
enforceValid!"hours"(hour);
_hour = cast(ubyte)hour;
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException((){TimeOfDay(0, 0, 0).hour = 24;}());
auto tod = TimeOfDay(0, 0, 0);
tod.hour = 12;
_assertPred!"=="(tod, TimeOfDay(12, 0, 0));
const ctod = TimeOfDay(0, 0, 0);
immutable itod = TimeOfDay(0, 0, 0);
static assert(!__traits(compiles, ctod.hour = 12));
static assert(!__traits(compiles, itod.hour = 12));
}
}
/++
Minutes passed the hour.
+/
@property ubyte minute() const pure nothrow
{
return _minute;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(TimeOfDay.init.minute, 0);
_assertPred!"=="(TimeOfDay(0, 30, 0).minute, 30);
const ctod = TimeOfDay(0, 30, 0);
immutable itod = TimeOfDay(0, 30, 0);
static assert(__traits(compiles, ctod.minute == 30));
static assert(__traits(compiles, itod.minute == 30));
}
}
/++
Minutes passed the hour.
Params:
minute = The minute to set this $(D TimeOfDay)'s minute to.
Throws:
$(D DateTimeException) if the given minute would result in an
invalid $(D TimeOfDay).
+/
@property void minute(int minute) pure
{
enforceValid!"minutes"(minute);
_minute = cast(ubyte)minute;
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException((){TimeOfDay(0, 0, 0).minute = 60;}());
auto tod = TimeOfDay(0, 0, 0);
tod.minute = 30;
_assertPred!"=="(tod, TimeOfDay(0, 30, 0));
const ctod = TimeOfDay(0, 0, 0);
immutable itod = TimeOfDay(0, 0, 0);
static assert(!__traits(compiles, ctod.minute = 30));
static assert(!__traits(compiles, itod.minute = 30));
}
}
/++
Seconds passed the minute.
+/
@property ubyte second() const pure nothrow
{
return _second;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(TimeOfDay.init.second, 0);
_assertPred!"=="(TimeOfDay(0, 0, 33).second, 33);
const ctod = TimeOfDay(0, 0, 33);
immutable itod = TimeOfDay(0, 0, 33);
static assert(__traits(compiles, ctod.second == 33));
static assert(__traits(compiles, itod.second == 33));
}
}
/++
Seconds passed the minute.
Params:
second = The second to set this $(D TimeOfDay)'s second to.
Throws:
$(D DateTimeException) if the given second would result in an
invalid $(D TimeOfDay).
+/
@property void second(int second) pure
{
enforceValid!"seconds"(second);
_second = cast(ubyte)second;
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException((){TimeOfDay(0, 0, 0).second = 60;}());
auto tod = TimeOfDay(0, 0, 0);
tod.second = 33;
_assertPred!"=="(tod, TimeOfDay(0, 0, 33));
const ctod = TimeOfDay(0, 0, 0);
immutable itod = TimeOfDay(0, 0, 0);
static assert(!__traits(compiles, ctod.second = 33));
static assert(!__traits(compiles, itod.second = 33));
}
}
/++
Adds the given number of units to this $(D TimeOfDay). A negative number
will subtract.
The difference between rolling and adding is that rolling does not
affect larger units. So, for instance, if you roll a $(D TimeOfDay)
one hours's worth of minutes, then you get the exact same
$(D TimeOfDay).
Accepted units are $(D "hours"), $(D "minutes"), and $(D "seconds").
Params:
units = The units to add.
value = The number of $(D_PARAM units) to add to this
$(D TimeOfDay).
Examples:
--------------------
auto tod1 = TimeOfDay(7, 12, 0);
tod1.roll!"hours"(1);
assert(tod1 == TimeOfDay(8, 12, 0));
auto tod2 = TimeOfDay(7, 12, 0);
tod2.roll!"hours"(-1);
assert(tod2 == TimeOfDay(6, 12, 0));
auto tod3 = TimeOfDay(23, 59, 0);
tod3.roll!"minutes"(1);
assert(tod3 == TimeOfDay(23, 0, 0));
auto tod4 = TimeOfDay(0, 0, 0);
tod4.roll!"minutes"(-1);
assert(tod4 == TimeOfDay(0, 59, 0));
auto tod5 = TimeOfDay(23, 59, 59);
tod5.roll!"seconds"(1);
assert(tod5 == TimeOfDay(23, 59, 0));
auto tod6 = TimeOfDay(0, 0, 0);
tod6.roll!"seconds"(-1);
assert(tod6 == TimeOfDay(0, 0, 59));
--------------------
+/
/+ref TimeOfDay+/ void roll(string units)(long value) pure nothrow
if(units == "hours")
{
this += dur!"hours"(value);
}
//Verify Examples.
unittest
{
version(testStdDateTime)
{
auto tod1 = TimeOfDay(7, 12, 0);
tod1.roll!"hours"(1);
assert(tod1 == TimeOfDay(8, 12, 0));
auto tod2 = TimeOfDay(7, 12, 0);
tod2.roll!"hours"(-1);
assert(tod2 == TimeOfDay(6, 12, 0));
auto tod3 = TimeOfDay(23, 59, 0);
tod3.roll!"minutes"(1);
assert(tod3 == TimeOfDay(23, 0, 0));
auto tod4 = TimeOfDay(0, 0, 0);
tod4.roll!"minutes"(-1);
assert(tod4 == TimeOfDay(0, 59, 0));
auto tod5 = TimeOfDay(23, 59, 59);
tod5.roll!"seconds"(1);
assert(tod5 == TimeOfDay(23, 59, 0));
auto tod6 = TimeOfDay(0, 0, 0);
tod6.roll!"seconds"(-1);
assert(tod6 == TimeOfDay(0, 0, 59));
}
}
unittest
{
version(testStdDateTime)
{
const ctod = TimeOfDay(0, 0, 0);
immutable itod = TimeOfDay(0, 0, 0);
static assert(!__traits(compiles, ctod.roll!"hours"(53)));
static assert(!__traits(compiles, itod.roll!"hours"(53)));
}
}
//Shares documentation with "hours" version.
/+ref TimeOfDay+/ void roll(string units)(long value) pure nothrow
if(units == "minutes" ||
units == "seconds")
{
static if(units == "minutes")
enum memberVarStr = "minute";
else static if(units == "seconds")
enum memberVarStr = "second";
else
static assert(0);
value %= 60;
mixin("auto newVal = cast(ubyte)(_" ~ memberVarStr ~ ") + value;");
if(value < 0)
{
if(newVal < 0)
newVal += 60;
}
else if(newVal >= 60)
newVal -= 60;
mixin("_" ~ memberVarStr ~ " = cast(ubyte)newVal;");
}
//Test roll!"minutes"().
unittest
{
version(testStdDateTime)
{
static void testTOD(TimeOfDay orig, int minutes, in TimeOfDay expected, size_t line = __LINE__)
{
orig.roll!"minutes"(minutes);
_assertPred!"=="(orig, expected, "", __FILE__, line);
}
testTOD(TimeOfDay(12, 30, 33), 0, TimeOfDay(12, 30, 33));
testTOD(TimeOfDay(12, 30, 33), 1, TimeOfDay(12, 31, 33));
testTOD(TimeOfDay(12, 30, 33), 2, TimeOfDay(12, 32, 33));
testTOD(TimeOfDay(12, 30, 33), 3, TimeOfDay(12, 33, 33));
testTOD(TimeOfDay(12, 30, 33), 4, TimeOfDay(12, 34, 33));
testTOD(TimeOfDay(12, 30, 33), 5, TimeOfDay(12, 35, 33));
testTOD(TimeOfDay(12, 30, 33), 10, TimeOfDay(12, 40, 33));
testTOD(TimeOfDay(12, 30, 33), 15, TimeOfDay(12, 45, 33));
testTOD(TimeOfDay(12, 30, 33), 29, TimeOfDay(12, 59, 33));
testTOD(TimeOfDay(12, 30, 33), 30, TimeOfDay(12, 0, 33));
testTOD(TimeOfDay(12, 30, 33), 45, TimeOfDay(12, 15, 33));
testTOD(TimeOfDay(12, 30, 33), 60, TimeOfDay(12, 30, 33));
testTOD(TimeOfDay(12, 30, 33), 75, TimeOfDay(12, 45, 33));
testTOD(TimeOfDay(12, 30, 33), 90, TimeOfDay(12, 0, 33));
testTOD(TimeOfDay(12, 30, 33), 100, TimeOfDay(12, 10, 33));
testTOD(TimeOfDay(12, 30, 33), 689, TimeOfDay(12, 59, 33));
testTOD(TimeOfDay(12, 30, 33), 690, TimeOfDay(12, 0, 33));
testTOD(TimeOfDay(12, 30, 33), 691, TimeOfDay(12, 1, 33));
testTOD(TimeOfDay(12, 30, 33), 960, TimeOfDay(12, 30, 33));
testTOD(TimeOfDay(12, 30, 33), 1439, TimeOfDay(12, 29, 33));
testTOD(TimeOfDay(12, 30, 33), 1440, TimeOfDay(12, 30, 33));
testTOD(TimeOfDay(12, 30, 33), 1441, TimeOfDay(12, 31, 33));
testTOD(TimeOfDay(12, 30, 33), 2880, TimeOfDay(12, 30, 33));
testTOD(TimeOfDay(12, 30, 33), -1, TimeOfDay(12, 29, 33));
testTOD(TimeOfDay(12, 30, 33), -2, TimeOfDay(12, 28, 33));
testTOD(TimeOfDay(12, 30, 33), -3, TimeOfDay(12, 27, 33));
testTOD(TimeOfDay(12, 30, 33), -4, TimeOfDay(12, 26, 33));
testTOD(TimeOfDay(12, 30, 33), -5, TimeOfDay(12, 25, 33));
testTOD(TimeOfDay(12, 30, 33), -10, TimeOfDay(12, 20, 33));
testTOD(TimeOfDay(12, 30, 33), -15, TimeOfDay(12, 15, 33));
testTOD(TimeOfDay(12, 30, 33), -29, TimeOfDay(12, 1, 33));
testTOD(TimeOfDay(12, 30, 33), -30, TimeOfDay(12, 0, 33));
testTOD(TimeOfDay(12, 30, 33), -45, TimeOfDay(12, 45, 33));
testTOD(TimeOfDay(12, 30, 33), -60, TimeOfDay(12, 30, 33));
testTOD(TimeOfDay(12, 30, 33), -75, TimeOfDay(12, 15, 33));
testTOD(TimeOfDay(12, 30, 33), -90, TimeOfDay(12, 0, 33));
testTOD(TimeOfDay(12, 30, 33), -100, TimeOfDay(12, 50, 33));
testTOD(TimeOfDay(12, 30, 33), -749, TimeOfDay(12, 1, 33));
testTOD(TimeOfDay(12, 30, 33), -750, TimeOfDay(12, 0, 33));
testTOD(TimeOfDay(12, 30, 33), -751, TimeOfDay(12, 59, 33));
testTOD(TimeOfDay(12, 30, 33), -960, TimeOfDay(12, 30, 33));
testTOD(TimeOfDay(12, 30, 33), -1439, TimeOfDay(12, 31, 33));
testTOD(TimeOfDay(12, 30, 33), -1440, TimeOfDay(12, 30, 33));
testTOD(TimeOfDay(12, 30, 33), -1441, TimeOfDay(12, 29, 33));
testTOD(TimeOfDay(12, 30, 33), -2880, TimeOfDay(12, 30, 33));
testTOD(TimeOfDay(12, 0, 33), 1, TimeOfDay(12, 1, 33));
testTOD(TimeOfDay(12, 0, 33), 0, TimeOfDay(12, 0, 33));
testTOD(TimeOfDay(12, 0, 33), -1, TimeOfDay(12, 59, 33));
testTOD(TimeOfDay(11, 59, 33), 1, TimeOfDay(11, 0, 33));
testTOD(TimeOfDay(11, 59, 33), 0, TimeOfDay(11, 59, 33));
testTOD(TimeOfDay(11, 59, 33), -1, TimeOfDay(11, 58, 33));
testTOD(TimeOfDay(0, 0, 33), 1, TimeOfDay(0, 1, 33));
testTOD(TimeOfDay(0, 0, 33), 0, TimeOfDay(0, 0, 33));
testTOD(TimeOfDay(0, 0, 33), -1, TimeOfDay(0, 59, 33));
testTOD(TimeOfDay(23, 59, 33), 1, TimeOfDay(23, 0, 33));
testTOD(TimeOfDay(23, 59, 33), 0, TimeOfDay(23, 59, 33));
testTOD(TimeOfDay(23, 59, 33), -1, TimeOfDay(23, 58, 33));
const ctod = TimeOfDay(0, 0, 0);
immutable itod = TimeOfDay(0, 0, 0);
static assert(!__traits(compiles, ctod.roll!"minutes"(7)));
static assert(!__traits(compiles, itod.roll!"minutes"(7)));
//Verify Examples.
auto tod1 = TimeOfDay(7, 12, 0);
tod1.roll!"minutes"(1);
assert(tod1 == TimeOfDay(7, 13, 0));
auto tod2 = TimeOfDay(7, 12, 0);
tod2.roll!"minutes"(-1);
assert(tod2 == TimeOfDay(7, 11, 0));
auto tod3 = TimeOfDay(23, 59, 0);
tod3.roll!"minutes"(1);
assert(tod3 == TimeOfDay(23, 0, 0));
auto tod4 = TimeOfDay(0, 0, 0);
tod4.roll!"minutes"(-1);
assert(tod4 == TimeOfDay(0, 59, 0));
auto tod5 = TimeOfDay(7, 32, 12);
tod5.roll!"seconds"(1);
assert(tod5 == TimeOfDay(7, 32, 13));
auto tod6 = TimeOfDay(7, 32, 12);
tod6.roll!"seconds"(-1);
assert(tod6 == TimeOfDay(7, 32, 11));
auto tod7 = TimeOfDay(23, 59, 59);
tod7.roll!"seconds"(1);
assert(tod7 == TimeOfDay(23, 59, 0));
auto tod8 = TimeOfDay(0, 0, 0);
tod8.roll!"seconds"(-1);
assert(tod8 == TimeOfDay(0, 0, 59));
}
}
//Test roll!"seconds"().
unittest
{
version(testStdDateTime)
{
static void testTOD(TimeOfDay orig, int seconds, in TimeOfDay expected, size_t line = __LINE__)
{
orig.roll!"seconds"(seconds);
_assertPred!"=="(orig, expected, "", __FILE__, line);
}
testTOD(TimeOfDay(12, 30, 33), 0, TimeOfDay(12, 30, 33));
testTOD(TimeOfDay(12, 30, 33), 1, TimeOfDay(12, 30, 34));
testTOD(TimeOfDay(12, 30, 33), 2, TimeOfDay(12, 30, 35));
testTOD(TimeOfDay(12, 30, 33), 3, TimeOfDay(12, 30, 36));
testTOD(TimeOfDay(12, 30, 33), 4, TimeOfDay(12, 30, 37));
testTOD(TimeOfDay(12, 30, 33), 5, TimeOfDay(12, 30, 38));
testTOD(TimeOfDay(12, 30, 33), 10, TimeOfDay(12, 30, 43));
testTOD(TimeOfDay(12, 30, 33), 15, TimeOfDay(12, 30, 48));
testTOD(TimeOfDay(12, 30, 33), 26, TimeOfDay(12, 30, 59));
testTOD(TimeOfDay(12, 30, 33), 27, TimeOfDay(12, 30, 0));
testTOD(TimeOfDay(12, 30, 33), 30, TimeOfDay(12, 30, 3));
testTOD(TimeOfDay(12, 30, 33), 59, TimeOfDay(12, 30, 32));
testTOD(TimeOfDay(12, 30, 33), 60, TimeOfDay(12, 30, 33));
testTOD(TimeOfDay(12, 30, 33), 61, TimeOfDay(12, 30, 34));
testTOD(TimeOfDay(12, 30, 33), 1766, TimeOfDay(12, 30, 59));
testTOD(TimeOfDay(12, 30, 33), 1767, TimeOfDay(12, 30, 0));
testTOD(TimeOfDay(12, 30, 33), 1768, TimeOfDay(12, 30, 1));
testTOD(TimeOfDay(12, 30, 33), 2007, TimeOfDay(12, 30, 0));
testTOD(TimeOfDay(12, 30, 33), 3599, TimeOfDay(12, 30, 32));
testTOD(TimeOfDay(12, 30, 33), 3600, TimeOfDay(12, 30, 33));
testTOD(TimeOfDay(12, 30, 33), 3601, TimeOfDay(12, 30, 34));
testTOD(TimeOfDay(12, 30, 33), 7200, TimeOfDay(12, 30, 33));
testTOD(TimeOfDay(12, 30, 33), -1, TimeOfDay(12, 30, 32));
testTOD(TimeOfDay(12, 30, 33), -2, TimeOfDay(12, 30, 31));
testTOD(TimeOfDay(12, 30, 33), -3, TimeOfDay(12, 30, 30));
testTOD(TimeOfDay(12, 30, 33), -4, TimeOfDay(12, 30, 29));
testTOD(TimeOfDay(12, 30, 33), -5, TimeOfDay(12, 30, 28));
testTOD(TimeOfDay(12, 30, 33), -10, TimeOfDay(12, 30, 23));
testTOD(TimeOfDay(12, 30, 33), -15, TimeOfDay(12, 30, 18));
testTOD(TimeOfDay(12, 30, 33), -33, TimeOfDay(12, 30, 0));
testTOD(TimeOfDay(12, 30, 33), -34, TimeOfDay(12, 30, 59));
testTOD(TimeOfDay(12, 30, 33), -35, TimeOfDay(12, 30, 58));
testTOD(TimeOfDay(12, 30, 33), -59, TimeOfDay(12, 30, 34));
testTOD(TimeOfDay(12, 30, 33), -60, TimeOfDay(12, 30, 33));
testTOD(TimeOfDay(12, 30, 33), -61, TimeOfDay(12, 30, 32));
testTOD(TimeOfDay(12, 30, 0), 1, TimeOfDay(12, 30, 1));
testTOD(TimeOfDay(12, 30, 0), 0, TimeOfDay(12, 30, 0));
testTOD(TimeOfDay(12, 30, 0), -1, TimeOfDay(12, 30, 59));
testTOD(TimeOfDay(12, 0, 0), 1, TimeOfDay(12, 0, 1));
testTOD(TimeOfDay(12, 0, 0), 0, TimeOfDay(12, 0, 0));
testTOD(TimeOfDay(12, 0, 0), -1, TimeOfDay(12, 0, 59));
testTOD(TimeOfDay(0, 0, 0), 1, TimeOfDay(0, 0, 1));
testTOD(TimeOfDay(0, 0, 0), 0, TimeOfDay(0, 0, 0));
testTOD(TimeOfDay(0, 0, 0), -1, TimeOfDay(0, 0, 59));
testTOD(TimeOfDay(23, 59, 59), 1, TimeOfDay(23, 59, 0));
testTOD(TimeOfDay(23, 59, 59), 0, TimeOfDay(23, 59, 59));
testTOD(TimeOfDay(23, 59, 59), -1, TimeOfDay(23, 59, 58));
const ctod = TimeOfDay(0, 0, 0);
immutable itod = TimeOfDay(0, 0, 0);
static assert(!__traits(compiles, ctod.roll!"seconds"(7)));
static assert(!__traits(compiles, itod.roll!"seconds"(7)));
}
}
/++
Gives the result of adding or subtracting a duration from this
$(D TimeOfDay).
The legal types of arithmetic for $(D TimeOfDay) using this operator are
$(BOOKTABLE,
$(TR $(TD TimeOfDay) $(TD +) $(TD duration) $(TD -->) $(TD TimeOfDay))
$(TR $(TD TimeOfDay) $(TD -) $(TD duration) $(TD -->) $(TD TimeOfDay))
)
Params:
duration = The duration to add to or subtract from this
$(D TimeOfDay).
+/
TimeOfDay opBinary(string op, D)(in D duration) const pure nothrow
if((op == "+" || op == "-") &&
(is(Unqual!D == Duration) ||
is(Unqual!D == TickDuration)))
{
TimeOfDay retval = this;
static if(is(Unqual!D == Duration))
immutable hnsecs = duration.total!"hnsecs";
else static if(is(Unqual!D == TickDuration))
immutable hnsecs = duration.hnsecs;
//Ideally, this would just be
//return retval.addSeconds(convert!("hnsecs", "seconds")(unaryFun!(op ~ "a")(hnsecs)));
//But there isn't currently a pure version of unaryFun!().
static if(op == "+")
immutable signedHNSecs = hnsecs;
else static if(op == "-")
immutable signedHNSecs = -hnsecs;
else
static assert(0);
return retval.addSeconds(convert!("hnsecs", "seconds")(signedHNSecs));
}
unittest
{
version(testStdDateTime)
{
auto tod = TimeOfDay(12, 30, 33);
_assertPred!"=="(tod + dur!"hours"(7), TimeOfDay(19, 30, 33));
_assertPred!"=="(tod + dur!"hours"(-7), TimeOfDay(5, 30, 33));
_assertPred!"=="(tod + dur!"minutes"(7), TimeOfDay(12, 37, 33));
_assertPred!"=="(tod + dur!"minutes"(-7), TimeOfDay(12, 23, 33));
_assertPred!"=="(tod + dur!"seconds"(7), TimeOfDay(12, 30, 40));
_assertPred!"=="(tod + dur!"seconds"(-7), TimeOfDay(12, 30, 26));
_assertPred!"=="(tod + dur!"msecs"(7000), TimeOfDay(12, 30, 40));
_assertPred!"=="(tod + dur!"msecs"(-7000), TimeOfDay(12, 30, 26));
_assertPred!"=="(tod + dur!"usecs"(7_000_000), TimeOfDay(12, 30, 40));
_assertPred!"=="(tod + dur!"usecs"(-7_000_000), TimeOfDay(12, 30, 26));
_assertPred!"=="(tod + dur!"hnsecs"(70_000_000), TimeOfDay(12, 30, 40));
_assertPred!"=="(tod + dur!"hnsecs"(-70_000_000), TimeOfDay(12, 30, 26));
//This probably only runs in cases where gettimeofday() is used, but it's
//hard to do this test correctly with variable ticksPerSec.
if(TickDuration.ticksPerSec == 1_000_000)
{
_assertPred!"=="(tod + TickDuration.from!"usecs"(7_000_000), TimeOfDay(12, 30, 40));
_assertPred!"=="(tod + TickDuration.from!"usecs"(-7_000_000), TimeOfDay(12, 30, 26));
}
_assertPred!"=="(tod - dur!"hours"(-7), TimeOfDay(19, 30, 33));
_assertPred!"=="(tod - dur!"hours"(7), TimeOfDay(5, 30, 33));
_assertPred!"=="(tod - dur!"minutes"(-7), TimeOfDay(12, 37, 33));
_assertPred!"=="(tod - dur!"minutes"(7), TimeOfDay(12, 23, 33));
_assertPred!"=="(tod - dur!"seconds"(-7), TimeOfDay(12, 30, 40));
_assertPred!"=="(tod - dur!"seconds"(7), TimeOfDay(12, 30, 26));
_assertPred!"=="(tod - dur!"msecs"(-7000), TimeOfDay(12, 30, 40));
_assertPred!"=="(tod - dur!"msecs"(7000), TimeOfDay(12, 30, 26));
_assertPred!"=="(tod - dur!"usecs"(-7_000_000), TimeOfDay(12, 30, 40));
_assertPred!"=="(tod - dur!"usecs"(7_000_000), TimeOfDay(12, 30, 26));
_assertPred!"=="(tod - dur!"hnsecs"(-70_000_000), TimeOfDay(12, 30, 40));
_assertPred!"=="(tod - dur!"hnsecs"(70_000_000), TimeOfDay(12, 30, 26));
//This probably only runs in cases where gettimeofday() is used, but it's
//hard to do this test correctly with variable ticksPerSec.
if(TickDuration.ticksPerSec == 1_000_000)
{
_assertPred!"=="(tod - TickDuration.from!"usecs"(-7_000_000), TimeOfDay(12, 30, 40));
_assertPred!"=="(tod - TickDuration.from!"usecs"(7_000_000), TimeOfDay(12, 30, 26));
}
auto duration = dur!"hours"(11);
const ctod = TimeOfDay(12, 33, 30);
immutable itod = TimeOfDay(12, 33, 30);
static assert(__traits(compiles, tod + duration));
static assert(__traits(compiles, ctod + duration));
static assert(__traits(compiles, itod + duration));
static assert(__traits(compiles, tod - duration));
static assert(__traits(compiles, ctod - duration));
static assert(__traits(compiles, itod - duration));
}
}
/++
Gives the result of adding or subtracting a duration from this
$(D TimeOfDay), as well as assigning the result to this
$(D TimeOfDay).
The legal types of arithmetic for $(D TimeOfDay) using this operator are
$(BOOKTABLE,
$(TR $(TD TimeOfDay) $(TD +) $(TD duration) $(TD -->) $(TD TimeOfDay))
$(TR $(TD TimeOfDay) $(TD -) $(TD duration) $(TD -->) $(TD TimeOfDay))
)
Params:
duration = The duration to add to or subtract from this
$(D TimeOfDay).
+/
/+ref+/ TimeOfDay opOpAssign(string op, D)(in D duration) pure nothrow
if((op == "+" || op == "-") &&
(is(Unqual!D == Duration) ||
is(Unqual!D == TickDuration)))
{
static if(is(Unqual!D == Duration))
immutable hnsecs = duration.total!"hnsecs";
else static if(is(Unqual!D == TickDuration))
immutable hnsecs = duration.hnsecs;
//Ideally, this would just be
//return addSeconds(convert!("hnsecs", "seconds")(unaryFun!(op ~ "a")(hnsecs)));
//But there isn't currently a pure version of unaryFun!().
static if(op == "+")
immutable signedHNSecs = hnsecs;
else static if(op == "-")
immutable signedHNSecs = -hnsecs;
else
static assert(0);
return addSeconds(convert!("hnsecs", "seconds")(signedHNSecs));
}
unittest
{
version(testStdDateTime)
{
auto duration = dur!"hours"(12);
_assertPred!"+="(TimeOfDay(12, 30, 33), dur!"hours"(7), TimeOfDay(19, 30, 33));
_assertPred!"+="(TimeOfDay(12, 30, 33), dur!"hours"(-7), TimeOfDay(5, 30, 33));
_assertPred!"+="(TimeOfDay(12, 30, 33), dur!"minutes"(7), TimeOfDay(12, 37, 33));
_assertPred!"+="(TimeOfDay(12, 30, 33), dur!"minutes"(-7), TimeOfDay(12, 23, 33));
_assertPred!"+="(TimeOfDay(12, 30, 33), dur!"seconds"(7), TimeOfDay(12, 30, 40));
_assertPred!"+="(TimeOfDay(12, 30, 33), dur!"seconds"(-7), TimeOfDay(12, 30, 26));
_assertPred!"+="(TimeOfDay(12, 30, 33), dur!"msecs"(7000), TimeOfDay(12, 30, 40));
_assertPred!"+="(TimeOfDay(12, 30, 33), dur!"msecs"(-7000), TimeOfDay(12, 30, 26));
_assertPred!"+="(TimeOfDay(12, 30, 33), dur!"usecs"(7_000_000), TimeOfDay(12, 30, 40));
_assertPred!"+="(TimeOfDay(12, 30, 33), dur!"usecs"(-7_000_000), TimeOfDay(12, 30, 26));
_assertPred!"+="(TimeOfDay(12, 30, 33), dur!"hnsecs"(70_000_000), TimeOfDay(12, 30, 40));
_assertPred!"+="(TimeOfDay(12, 30, 33), dur!"hnsecs"(-70_000_000), TimeOfDay(12, 30, 26));
_assertPred!"-="(TimeOfDay(12, 30, 33), dur!"hours"(-7), TimeOfDay(19, 30, 33));
_assertPred!"-="(TimeOfDay(12, 30, 33), dur!"hours"(7), TimeOfDay(5, 30, 33));
_assertPred!"-="(TimeOfDay(12, 30, 33), dur!"minutes"(-7), TimeOfDay(12, 37, 33));
_assertPred!"-="(TimeOfDay(12, 30, 33), dur!"minutes"(7), TimeOfDay(12, 23, 33));
_assertPred!"-="(TimeOfDay(12, 30, 33), dur!"seconds"(-7), TimeOfDay(12, 30, 40));
_assertPred!"-="(TimeOfDay(12, 30, 33), dur!"seconds"(7), TimeOfDay(12, 30, 26));
_assertPred!"-="(TimeOfDay(12, 30, 33), dur!"msecs"(-7000), TimeOfDay(12, 30, 40));
_assertPred!"-="(TimeOfDay(12, 30, 33), dur!"msecs"(7000), TimeOfDay(12, 30, 26));
_assertPred!"-="(TimeOfDay(12, 30, 33), dur!"usecs"(-7_000_000), TimeOfDay(12, 30, 40));
_assertPred!"-="(TimeOfDay(12, 30, 33), dur!"usecs"(7_000_000), TimeOfDay(12, 30, 26));
_assertPred!"-="(TimeOfDay(12, 30, 33), dur!"hnsecs"(-70_000_000), TimeOfDay(12, 30, 40));
_assertPred!"-="(TimeOfDay(12, 30, 33), dur!"hnsecs"(70_000_000), TimeOfDay(12, 30, 26));
const ctod = TimeOfDay(12, 33, 30);
immutable itod = TimeOfDay(12, 33, 30);
static assert(!__traits(compiles, ctod += duration));
static assert(!__traits(compiles, itod += duration));
static assert(!__traits(compiles, ctod -= duration));
static assert(!__traits(compiles, itod -= duration));
}
}
/++
Gives the difference between two $(D TimeOfDay)s.
The legal types of arithmetic for $(D TimeOfDay) using this operator are
$(BOOKTABLE,
$(TR $(TD TimeOfDay) $(TD -) $(TD TimeOfDay) $(TD -->) $(TD duration))
)
Params:
rhs = The $(D TimeOfDay) to subtract from this one.
+/
Duration opBinary(string op)(in TimeOfDay rhs) const pure nothrow
if(op == "-")
{
immutable lhsSec = _hour * 3600 + _minute * 60 + _second;
immutable rhsSec = rhs._hour * 3600 + rhs._minute * 60 + rhs._second;
return dur!"seconds"(lhsSec - rhsSec);
}
unittest
{
version(testStdDateTime)
{
auto tod = TimeOfDay(12, 30, 33);
_assertPred!"=="(TimeOfDay(7, 12, 52) - TimeOfDay(12, 30, 33), dur!"seconds"(-19_061));
_assertPred!"=="(TimeOfDay(12, 30, 33) - TimeOfDay(7, 12, 52), dur!"seconds"(19_061));
_assertPred!"=="(TimeOfDay(12, 30, 33) - TimeOfDay(14, 30, 33), dur!"seconds"(-7200));
_assertPred!"=="(TimeOfDay(14, 30, 33) - TimeOfDay(12, 30, 33), dur!"seconds"(7200));
_assertPred!"=="(TimeOfDay(12, 30, 33) - TimeOfDay(12, 34, 33), dur!"seconds"(-240));
_assertPred!"=="(TimeOfDay(12, 34, 33) - TimeOfDay(12, 30, 33), dur!"seconds"(240));
_assertPred!"=="(TimeOfDay(12, 30, 33) - TimeOfDay(12, 30, 34), dur!"seconds"(-1));
_assertPred!"=="(TimeOfDay(12, 30, 34) - TimeOfDay(12, 30, 33), dur!"seconds"(1));
const ctod = TimeOfDay(12, 30, 33);
immutable itod = TimeOfDay(12, 30, 33);
static assert(__traits(compiles, tod - tod));
static assert(__traits(compiles, ctod - tod));
static assert(__traits(compiles, itod - tod));
static assert(__traits(compiles, tod - ctod));
static assert(__traits(compiles, ctod - ctod));
static assert(__traits(compiles, itod - ctod));
static assert(__traits(compiles, tod - itod));
static assert(__traits(compiles, ctod - itod));
static assert(__traits(compiles, itod - itod));
}
}
/++
Converts this $(D TimeOfDay) to a string with the format HHMMSS.
Examples:
--------------------
assert(TimeOfDay(0, 0, 0).toISOString() == "000000");
assert(TimeOfDay(12, 30, 33).toISOString() == "123033");
--------------------
+/
string toISOString() const nothrow
{
try
return format("%02d%02d%02d", _hour, _minute, _second);
catch(Exception e)
assert(0, "format() threw.");
}
unittest
{
version(testStdDateTime)
{
auto tod = TimeOfDay(12, 30, 33);
const ctod = TimeOfDay(12, 30, 33);
immutable itod = TimeOfDay(12, 30, 33);
static assert(__traits(compiles, tod.toISOString()));
static assert(__traits(compiles, ctod.toISOString()));
static assert(__traits(compiles, itod.toISOString()));
//Verify Examples.
assert(TimeOfDay(0, 0, 0).toISOString() == "000000");
assert(TimeOfDay(12, 30, 33).toISOString() == "123033");
}
}
/++
Converts this $(D TimeOfDay) to a string with the format HH:MM:SS.
Examples:
--------------------
assert(TimeOfDay(0, 0, 0).toISOExtString() == "000000");
assert(TimeOfDay(12, 30, 33).toISOExtString() == "123033");
--------------------
+/
string toISOExtString() const nothrow
{
try
return format("%02d:%02d:%02d", _hour, _minute, _second);
catch(Exception e)
assert(0, "format() threw.");
}
/++
$(RED Scheduled for deprecation in November 2011.
Please use toISOExtString instead.)
+/
alias toISOExtString toISOExtendedString;
unittest
{
version(testStdDateTime)
{
auto tod = TimeOfDay(12, 30, 33);
const ctod = TimeOfDay(12, 30, 33);
immutable itod = TimeOfDay(12, 30, 33);
static assert(__traits(compiles, tod.toISOExtString()));
static assert(__traits(compiles, ctod.toISOExtString()));
static assert(__traits(compiles, itod.toISOExtString()));
//Verify Examples.
assert(TimeOfDay(0, 0, 0).toISOExtString() == "00:00:00");
assert(TimeOfDay(12, 30, 33).toISOExtString() == "12:30:33");
}
}
/+
Converts this $(D TimeOfDay) to a string.
+/
//Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
//have versions of toString() with extra modifiers, so we define one version
//with modifiers and one without.
string toString()
{
return toISOExtString();
}
/++
Converts this TimeOfDay to a string.
+/
//Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
//have versions of toString() with extra modifiers, so we define one version
//with modifiers and one without.
string toString() const nothrow
{
return toISOExtString();
}
unittest
{
version(testStdDateTime)
{
auto tod = TimeOfDay(12, 30, 33);
const ctod = TimeOfDay(12, 30, 33);
immutable itod = TimeOfDay(12, 30, 33);
static assert(__traits(compiles, tod.toString()));
static assert(__traits(compiles, ctod.toString()));
static assert(__traits(compiles, itod.toString()));
}
}
//TODO Add a function which returns a string in a user-specified format.
/++
Creates a $(D TimeOfDay) from a string with the format HHMMSS.
Whitespace is stripped from the given string.
Params:
isoString = A string formatted in the ISO format for times.
Throws:
$(D DateTimeException) if the given string is not in the ISO format
or if the resulting $(D TimeOfDay) would not be valid.
Examples:
--------------------
assert(TimeOfDay.fromISOString("000000") == TimeOfDay(0, 0, 0));
assert(TimeOfDay.fromISOString("123033") == TimeOfDay(12, 30, 33));
assert(TimeOfDay.fromISOString(" 123033 ") == TimeOfDay(12, 30, 33));
--------------------
+/
static TimeOfDay fromISOString(S)(in S isoString)
if(isSomeString!S)
{
auto dstr = to!dstring(strip(isoString));
enforce(dstr.length == 6, new DateTimeException(format("Invalid ISO String: %s", isoString)));
auto hours = dstr[0 .. 2];
auto minutes = dstr[2 .. 4];
auto seconds = dstr[4 .. $];
enforce(!canFind!(not!isDigit)(hours), new DateTimeException(format("Invalid ISO String: %s", isoString)));
enforce(!canFind!(not!isDigit)(minutes), new DateTimeException(format("Invalid ISO String: %s", isoString)));
enforce(!canFind!(not!isDigit)(seconds), new DateTimeException(format("Invalid ISO String: %s", isoString)));
return TimeOfDay(to!int(hours), to!int(minutes), to!int(seconds));
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException(TimeOfDay.fromISOString(""));
assertThrown!DateTimeException(TimeOfDay.fromISOString("0"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("00"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("000"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("0000"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("00000"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("13033"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("1277"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("12707"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("12070"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("12303a"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("1230a3"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("123a33"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("12a033"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("1a0033"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("a20033"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("1200330"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("0120033"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("-120033"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("+120033"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("120033am"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("120033pm"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("0::"));
assertThrown!DateTimeException(TimeOfDay.fromISOString(":0:"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("::0"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("0:0:0"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("0:0:00"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("0:00:0"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("00:0:0"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("00:00:0"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("00:0:00"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("13:0:33"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("12:7:7"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("12:7:07"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("12:07:0"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("12:30:3a"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("12:30:a3"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("12:3a:33"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("12:a0:33"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("1a:00:33"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("a2:00:33"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("12:003:30"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("120:03:30"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("012:00:33"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("01:200:33"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("-12:00:33"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("+12:00:33"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("12:00:33am"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("12:00:33pm"));
assertThrown!DateTimeException(TimeOfDay.fromISOString("12:00:33"));
_assertPred!"=="(TimeOfDay.fromISOString("011217"), TimeOfDay(1, 12, 17));
_assertPred!"=="(TimeOfDay.fromISOString("001412"), TimeOfDay(0, 14, 12));
_assertPred!"=="(TimeOfDay.fromISOString("000007"), TimeOfDay(0, 0, 7));
_assertPred!"=="(TimeOfDay.fromISOString("011217 "), TimeOfDay(1, 12, 17));
_assertPred!"=="(TimeOfDay.fromISOString(" 011217"), TimeOfDay(1, 12, 17));
_assertPred!"=="(TimeOfDay.fromISOString(" 011217 "), TimeOfDay(1, 12, 17));
//Verify Examples.
assert(TimeOfDay.fromISOString("000000") == TimeOfDay(0, 0, 0));
assert(TimeOfDay.fromISOString("123033") == TimeOfDay(12, 30, 33));
assert(TimeOfDay.fromISOString(" 123033 ") == TimeOfDay(12, 30, 33));
}
}
/++
Creates a $(D TimeOfDay) from a string with the format HH:MM:SS.
Whitespace is stripped from the given string.
Params:
isoString = A string formatted in the ISO Extended format for times.
Throws:
$(D DateTimeException) if the given string is not in the ISO
Extended format or if the resulting $(D TimeOfDay) would not be
valid.
Examples:
--------------------
assert(TimeOfDay.fromISOExtString("00:00:00") == TimeOfDay(0, 0, 0));
assert(TimeOfDay.fromISOExtString("12:30:33") == TimeOfDay(12, 30, 33));
assert(TimeOfDay.fromISOExtString(" 12:30:33 ") == TimeOfDay(12, 30, 33));
--------------------
+/
static TimeOfDay fromISOExtString(S)(in S isoExtString)
if(isSomeString!S)
{
auto dstr = to!dstring(strip(isoExtString));
enforce(dstr.length == 8, new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
auto hours = dstr[0 .. 2];
auto minutes = dstr[3 .. 5];
auto seconds = dstr[6 .. $];
enforce(dstr[2] == ':', new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
enforce(dstr[5] == ':', new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
enforce(!canFind!(not!isDigit)(hours),
new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
enforce(!canFind!(not!isDigit)(minutes),
new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
enforce(!canFind!(not!isDigit)(seconds),
new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
return TimeOfDay(to!int(hours), to!int(minutes), to!int(seconds));
}
/++
$(RED Scheduled for deprecation in November 2011.
Please use fromISOExtString instead.)
+/
static TimeOfDay fromISOExtendedString(S)(in S isoExtString)
if(isSomeString!(S))
{
pragma(msg, softDeprec!("2.053", "November 2011", "fromISOExtendedString", "fromISOExtString"));
return fromISOExtString!string(isoExtString);
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException(TimeOfDay.fromISOExtString(""));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("0"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("00"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("000"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("0000"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("00000"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("13033"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("1277"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("12707"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("12070"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("12303a"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("1230a3"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("123a33"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("12a033"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("1a0033"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("a20033"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("1200330"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("0120033"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("-120033"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("+120033"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("120033am"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("120033pm"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("0::"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString(":0:"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("::0"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("0:0:0"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("0:0:00"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("0:00:0"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("00:0:0"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("00:00:0"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("00:0:00"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("13:0:33"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("12:7:7"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("12:7:07"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("12:07:0"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("12:30:3a"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("12:30:a3"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("12:3a:33"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("12:a0:33"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("1a:00:33"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("a2:00:33"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("12:003:30"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("120:03:30"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("012:00:33"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("01:200:33"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("-12:00:33"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("+12:00:33"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("12:00:33am"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("12:00:33pm"));
assertThrown!DateTimeException(TimeOfDay.fromISOExtString("120033"));
_assertPred!"=="(TimeOfDay.fromISOExtString("01:12:17"), TimeOfDay(1, 12, 17));
_assertPred!"=="(TimeOfDay.fromISOExtString("00:14:12"), TimeOfDay(0, 14, 12));
_assertPred!"=="(TimeOfDay.fromISOExtString("00:00:07"), TimeOfDay(0, 0, 7));
_assertPred!"=="(TimeOfDay.fromISOExtString("01:12:17 "), TimeOfDay(1, 12, 17));
_assertPred!"=="(TimeOfDay.fromISOExtString(" 01:12:17"), TimeOfDay(1, 12, 17));
_assertPred!"=="(TimeOfDay.fromISOExtString(" 01:12:17 "), TimeOfDay(1, 12, 17));
//Verify Examples.
assert(TimeOfDay.fromISOExtString("00:00:00") == TimeOfDay(0, 0, 0));
assert(TimeOfDay.fromISOExtString("12:30:33") == TimeOfDay(12, 30, 33));
assert(TimeOfDay.fromISOExtString(" 12:30:33 ") == TimeOfDay(12, 30, 33));
}
}
//TODO Add function which takes a user-specified time format and produces a TimeOfDay
//TODO Add function which takes pretty much any time-string and produces a TimeOfDay
// Obviously, it will be less efficient, and it probably won't manage _every_
// possible date format, but a smart conversion function would be nice.
/++
Returns midnight.
+/
@property static TimeOfDay min() pure nothrow
{
return TimeOfDay.init;
}
unittest
{
version(testStdDateTime)
{
assert(TimeOfDay.min.hour == 0);
assert(TimeOfDay.min.minute == 0);
assert(TimeOfDay.min.second == 0);
assert(TimeOfDay.min < TimeOfDay.max);
}
}
/++
Returns one second short of midnight.
+/
@property static TimeOfDay max() pure nothrow
{
auto tod = TimeOfDay.init;
tod._hour = maxHour;
tod._minute = maxMinute;
tod._second = maxSecond;
return tod;
}
unittest
{
version(testStdDateTime)
{
assert(TimeOfDay.max.hour == 23);
assert(TimeOfDay.max.minute == 59);
assert(TimeOfDay.max.second == 59);
assert(TimeOfDay.max > TimeOfDay.min);
}
}
private:
/+
Add seconds to the time of day. Negative values will subtract. If the
number of seconds overflows (or underflows), then the seconds will wrap,
increasing (or decreasing) the number of minutes accordingly. If the
number of minutes overflows (or underflows), then the minutes will wrap.
If the number of minutes overflows(or underflows), then the hour will
wrap. (e.g. adding 90 seconds to 23:59:00 would result in 00:00:30).
Params:
seconds = The number of seconds to add to this TimeOfDay.
+/
ref TimeOfDay addSeconds(long seconds) pure nothrow
{
long hnsecs = convert!("seconds", "hnsecs")(seconds);
hnsecs += convert!("hours", "hnsecs")(_hour);
hnsecs += convert!("minutes", "hnsecs")(_minute);
hnsecs += convert!("seconds", "hnsecs")(_second);
hnsecs %= convert!("days", "hnsecs")(1);
if(hnsecs < 0)
hnsecs += convert!("days", "hnsecs")(1);
immutable newHours = splitUnitsFromHNSecs!"hours"(hnsecs);
immutable newMinutes = splitUnitsFromHNSecs!"minutes"(hnsecs);
immutable newSeconds = splitUnitsFromHNSecs!"seconds"(hnsecs);
_hour = cast(ubyte)newHours;
_minute = cast(ubyte)newMinutes;
_second = cast(ubyte)newSeconds;
return this;
}
unittest
{
version(testStdDateTime)
{
static void testTOD(TimeOfDay orig, int seconds, in TimeOfDay expected, size_t line = __LINE__)
{
orig.addSeconds(seconds);
_assertPred!"=="(orig, expected, "", __FILE__, line);
}
testTOD(TimeOfDay(12, 30, 33), 0, TimeOfDay(12, 30, 33));
testTOD(TimeOfDay(12, 30, 33), 1, TimeOfDay(12, 30, 34));
testTOD(TimeOfDay(12, 30, 33), 2, TimeOfDay(12, 30, 35));
testTOD(TimeOfDay(12, 30, 33), 3, TimeOfDay(12, 30, 36));
testTOD(TimeOfDay(12, 30, 33), 4, TimeOfDay(12, 30, 37));
testTOD(TimeOfDay(12, 30, 33), 5, TimeOfDay(12, 30, 38));
testTOD(TimeOfDay(12, 30, 33), 10, TimeOfDay(12, 30, 43));
testTOD(TimeOfDay(12, 30, 33), 15, TimeOfDay(12, 30, 48));
testTOD(TimeOfDay(12, 30, 33), 26, TimeOfDay(12, 30, 59));
testTOD(TimeOfDay(12, 30, 33), 27, TimeOfDay(12, 31, 0));
testTOD(TimeOfDay(12, 30, 33), 30, TimeOfDay(12, 31, 3));
testTOD(TimeOfDay(12, 30, 33), 59, TimeOfDay(12, 31, 32));
testTOD(TimeOfDay(12, 30, 33), 60, TimeOfDay(12, 31, 33));
testTOD(TimeOfDay(12, 30, 33), 61, TimeOfDay(12, 31, 34));
testTOD(TimeOfDay(12, 30, 33), 1766, TimeOfDay(12, 59, 59));
testTOD(TimeOfDay(12, 30, 33), 1767, TimeOfDay(13, 0, 0));
testTOD(TimeOfDay(12, 30, 33), 1768, TimeOfDay(13, 0, 1));
testTOD(TimeOfDay(12, 30, 33), 2007, TimeOfDay(13, 4, 0));
testTOD(TimeOfDay(12, 30, 33), 3599, TimeOfDay(13, 30, 32));
testTOD(TimeOfDay(12, 30, 33), 3600, TimeOfDay(13, 30, 33));
testTOD(TimeOfDay(12, 30, 33), 3601, TimeOfDay(13, 30, 34));
testTOD(TimeOfDay(12, 30, 33), 7200, TimeOfDay(14, 30, 33));
testTOD(TimeOfDay(12, 30, 33), -1, TimeOfDay(12, 30, 32));
testTOD(TimeOfDay(12, 30, 33), -2, TimeOfDay(12, 30, 31));
testTOD(TimeOfDay(12, 30, 33), -3, TimeOfDay(12, 30, 30));
testTOD(TimeOfDay(12, 30, 33), -4, TimeOfDay(12, 30, 29));
testTOD(TimeOfDay(12, 30, 33), -5, TimeOfDay(12, 30, 28));
testTOD(TimeOfDay(12, 30, 33), -10, TimeOfDay(12, 30, 23));
testTOD(TimeOfDay(12, 30, 33), -15, TimeOfDay(12, 30, 18));
testTOD(TimeOfDay(12, 30, 33), -33, TimeOfDay(12, 30, 0));
testTOD(TimeOfDay(12, 30, 33), -34, TimeOfDay(12, 29, 59));
testTOD(TimeOfDay(12, 30, 33), -35, TimeOfDay(12, 29, 58));
testTOD(TimeOfDay(12, 30, 33), -59, TimeOfDay(12, 29, 34));
testTOD(TimeOfDay(12, 30, 33), -60, TimeOfDay(12, 29, 33));
testTOD(TimeOfDay(12, 30, 33), -61, TimeOfDay(12, 29, 32));
testTOD(TimeOfDay(12, 30, 33), -1833, TimeOfDay(12, 0, 0));
testTOD(TimeOfDay(12, 30, 33), -1834, TimeOfDay(11, 59, 59));
testTOD(TimeOfDay(12, 30, 33), -3600, TimeOfDay(11, 30, 33));
testTOD(TimeOfDay(12, 30, 33), -3601, TimeOfDay(11, 30, 32));
testTOD(TimeOfDay(12, 30, 33), -5134, TimeOfDay(11, 4, 59));
testTOD(TimeOfDay(12, 30, 33), -7200, TimeOfDay(10, 30, 33));
testTOD(TimeOfDay(12, 30, 0), 1, TimeOfDay(12, 30, 1));
testTOD(TimeOfDay(12, 30, 0), 0, TimeOfDay(12, 30, 0));
testTOD(TimeOfDay(12, 30, 0), -1, TimeOfDay(12, 29, 59));
testTOD(TimeOfDay(12, 0, 0), 1, TimeOfDay(12, 0, 1));
testTOD(TimeOfDay(12, 0, 0), 0, TimeOfDay(12, 0, 0));
testTOD(TimeOfDay(12, 0, 0), -1, TimeOfDay(11, 59, 59));
testTOD(TimeOfDay(0, 0, 0), 1, TimeOfDay(0, 0, 1));
testTOD(TimeOfDay(0, 0, 0), 0, TimeOfDay(0, 0, 0));
testTOD(TimeOfDay(0, 0, 0), -1, TimeOfDay(23, 59, 59));
testTOD(TimeOfDay(23, 59, 59), 1, TimeOfDay(0, 0, 0));
testTOD(TimeOfDay(23, 59, 59), 0, TimeOfDay(23, 59, 59));
testTOD(TimeOfDay(23, 59, 59), -1, TimeOfDay(23, 59, 58));
const ctod = TimeOfDay(0, 0, 0);
immutable itod = TimeOfDay(0, 0, 0);
static assert(!__traits(compiles, ctod.addSeconds(7)));
static assert(!__traits(compiles, itod.addSeconds(7)));
}
}
/+
Whether the given values form a valid $(D TimeOfDay).
+/
static bool _valid(int hour, int minute, int second) pure nothrow
{
return valid!"hours"(hour) && valid!"minutes"(minute) && valid!"seconds"(second);
}
pure invariant()
{
assert(_valid(_hour, _minute, _second),
"Invariant Failure: hour [" ~
numToString(_hour) ~
"] minute [" ~
numToString(_minute) ~
"] second [" ~
numToString(_second) ~
"]");
}
ubyte _hour;
ubyte _minute;
ubyte _second;
enum ubyte maxHour = 24 - 1;
enum ubyte maxMinute = 60 - 1;
enum ubyte maxSecond = 60 - 1;
}
/++
Combines the $(D Date) and $(D TimeOfDay) structs to give you an object
which holds both the date and the time. It is optimized for calendar-based
operations and has no concept of time zone. If you want an object which is
optimized for time operations based on the system time, then use
$(D SysTime). $(D SysTime) has a concept of time zone and has much higher
precision (hnsecs). $(D DateTime) is intended primarily for calendar-based
uses rather than precise time operations.
+/
struct DateTime
{
public:
/++
Params:
date = The date portion of $(D DateTime).
tod = The time portion of $(D DateTime).
+/
this(in Date date, in TimeOfDay tod = TimeOfDay.init) pure nothrow
{
_date = date;
_tod = tod;
}
unittest
{
version(testStdDateTime)
{
{
auto dt = DateTime.init;
_assertPred!"=="(dt._date, Date.init);
_assertPred!"=="(dt._tod, TimeOfDay.init);
}
{
auto dt = DateTime(Date(1999, 7 ,6));
_assertPred!"=="(dt._date, Date(1999, 7, 6));
_assertPred!"=="(dt._tod, TimeOfDay.init);
}
{
auto dt = DateTime(Date(1999, 7 ,6), TimeOfDay(12, 30, 33));
_assertPred!"=="(dt._date, Date(1999, 7, 6));
_assertPred!"=="(dt._tod, TimeOfDay(12, 30, 33));
}
}
}
/++
Params:
year = The year portion of the date.
month = The month portion of the date.
day = The day portion of the date.
hour = The hour portion of the time;
minute = The minute portion of the time;
second = The second portion of the time;
+/
this(int year, int month, int day,
int hour = 0, int minute = 0, int second = 0) pure
{
_date = Date(year, month, day);
_tod = TimeOfDay(hour, minute, second);
}
unittest
{
version(testStdDateTime)
{
{
auto dt = DateTime(1999, 7 ,6);
_assertPred!"=="(dt._date, Date(1999, 7, 6));
_assertPred!"=="(dt._tod, TimeOfDay.init);
}
{
auto dt = DateTime(1999, 7 ,6, 12, 30, 33);
_assertPred!"=="(dt._date, Date(1999, 7, 6));
_assertPred!"=="(dt._tod, TimeOfDay(12, 30, 33));
}
}
}
/++
Compares this $(D DateTime) with the given $(D DateTime.).
Returns:
$(BOOKTABLE,
$(TR $(TD this < rhs) $(TD < 0))
$(TR $(TD this == rhs) $(TD 0))
$(TR $(TD this > rhs) $(TD > 0))
)
+/
int opCmp(in DateTime rhs) const pure nothrow
{
immutable dateResult = _date.opCmp(rhs._date);
if(dateResult != 0)
return dateResult;
return _tod.opCmp(rhs._tod);
}
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!("opCmp", "==")(DateTime(Date.init, TimeOfDay.init), DateTime.init);
_assertPred!("opCmp", "==")(DateTime(Date(1999, 1, 1)), DateTime(Date(1999, 1, 1)));
_assertPred!("opCmp", "==")(DateTime(Date(1, 7, 1)), DateTime(Date(1, 7, 1)));
_assertPred!("opCmp", "==")(DateTime(Date(1, 1, 6)), DateTime(Date(1, 1, 6)));
_assertPred!("opCmp", "==")(DateTime(Date(1999, 7, 1)), DateTime(Date(1999, 7, 1)));
_assertPred!("opCmp", "==")(DateTime(Date(1999, 7, 6)), DateTime(Date(1999, 7, 6)));
_assertPred!("opCmp", "==")(DateTime(Date(1, 7, 6)), DateTime(Date(1, 7, 6)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 6)), DateTime(Date(2000, 7, 6)));
_assertPred!("opCmp", ">")(DateTime(Date(2000, 7, 6)), DateTime(Date(1999, 7, 6)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 6)), DateTime(Date(1999, 8, 6)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 8, 6)), DateTime(Date(1999, 7, 6)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 6)), DateTime(Date(1999, 7, 7)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 7, 7)), DateTime(Date(1999, 7, 6)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 8, 7)), DateTime(Date(2000, 7, 6)));
_assertPred!("opCmp", ">")(DateTime(Date(2000, 8, 6)), DateTime(Date(1999, 7, 7)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 7)), DateTime(Date(2000, 7, 6)));
_assertPred!("opCmp", ">")(DateTime(Date(2000, 7, 6)), DateTime(Date(1999, 7, 7)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 7)), DateTime(Date(1999, 8, 6)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 8, 6)), DateTime(Date(1999, 7, 7)));
_assertPred!("opCmp", "==")(DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 0)),
DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 0)));
_assertPred!("opCmp", "==")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 0)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 0)));
_assertPred!("opCmp", "==")(DateTime(Date(1999, 7, 6), TimeOfDay(0, 30, 0)),
DateTime(Date(1999, 7, 6), TimeOfDay(0, 30, 0)));
_assertPred!("opCmp", "==")(DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 33)));
_assertPred!("opCmp", "==")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 0)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 0)));
_assertPred!("opCmp", "==")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "==")(DateTime(Date(1999, 7, 6), TimeOfDay(0, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(0, 30, 33)));
_assertPred!("opCmp", "==")(DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)),
DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)),
DateTime(Date(2000, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(2000, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)),
DateTime(Date(2000, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(2000, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)),
DateTime(Date(2000, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(2000, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)),
DateTime(Date(1999, 8, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 8, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)),
DateTime(Date(1999, 8, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 8, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)),
DateTime(Date(1999, 8, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 8, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)),
DateTime(Date(1999, 7, 7), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 7, 7), TimeOfDay(12, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)),
DateTime(Date(1999, 7, 7), TimeOfDay(12, 31, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 7, 7), TimeOfDay(12, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)),
DateTime(Date(1999, 7, 7), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 7, 7), TimeOfDay(12, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)));
//Test B.C.
_assertPred!("opCmp", "==")(DateTime(Date(-1, 1, 1), TimeOfDay(12, 30, 33)),
DateTime(Date(-1, 1, 1), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "==")(DateTime(Date(-1, 7, 1), TimeOfDay(12, 30, 33)),
DateTime(Date(-1, 7, 1), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "==")(DateTime(Date(-1, 1, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(-1, 1, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "==")(DateTime(Date(-1999, 7, 1), TimeOfDay(12, 30, 33)),
DateTime(Date(-1999, 7, 1), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "==")(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "==")(DateTime(Date(-1, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(-1, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(-2000, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(-2000, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(-1999, 8, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(-1999, 8, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(-1999, 7, 7), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(-1999, 7, 7), TimeOfDay(12, 30, 33)),
DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(-2000, 8, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(-1999, 7, 7), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(-1999, 8, 7), TimeOfDay(12, 30, 33)),
DateTime(Date(-2000, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(-2000, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(-1999, 7, 7), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(-1999, 7, 7), TimeOfDay(12, 30, 33)),
DateTime(Date(-2000, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(-1999, 7, 7), TimeOfDay(12, 30, 33)),
DateTime(Date(-1999, 8, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(-1999, 8, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(-1999, 7, 7), TimeOfDay(12, 30, 33)));
//Test Both
_assertPred!("opCmp", "<")(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(-1999, 8, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(-1999, 8, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(-1999, 7, 7), TimeOfDay(12, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(-1999, 7, 7), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(-1999, 8, 7), TimeOfDay(12, 30, 33)),
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(-1999, 8, 7), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", "<")(DateTime(Date(-1999, 8, 6), TimeOfDay(12, 30, 33)),
DateTime(Date(1999, 6, 6), TimeOfDay(12, 30, 33)));
_assertPred!("opCmp", ">")(DateTime(Date(1999, 6, 8), TimeOfDay(12, 30, 33)),
DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
auto dt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 33, 30));
const cdt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 33, 30));
immutable idt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 33, 30));
static assert(__traits(compiles, dt.opCmp(dt)));
static assert(__traits(compiles, dt.opCmp(cdt)));
static assert(__traits(compiles, dt.opCmp(idt)));
static assert(__traits(compiles, cdt.opCmp(dt)));
static assert(__traits(compiles, cdt.opCmp(cdt)));
static assert(__traits(compiles, cdt.opCmp(idt)));
static assert(__traits(compiles, idt.opCmp(dt)));
static assert(__traits(compiles, idt.opCmp(cdt)));
static assert(__traits(compiles, idt.opCmp(idt)));
}
}
/++
The date portion of $(D DateTime).
+/
@property Date date() const pure nothrow
{
return _date;
}
unittest
{
version(testStdDateTime)
{
{
auto dt = DateTime.init;
_assertPred!"=="(dt.date, Date.init);
}
{
auto dt = DateTime(Date(1999, 7, 6));
_assertPred!"=="(dt.date, Date(1999, 7, 6));
}
const cdt = DateTime(1999, 7, 6);
immutable idt = DateTime(1999, 7, 6);
static assert(__traits(compiles, cdt.date == Date(2010, 1, 1)));
static assert(__traits(compiles, idt.date == Date(2010, 1, 1)));
}
}
/++
The date portion of $(D DateTime).
Params:
date = The Date to set this $(D DateTime)'s date portion to.
+/
@property void date(in Date date) pure nothrow
{
_date = date;
}
unittest
{
version(testStdDateTime)
{
auto dt = DateTime.init;
dt.date = Date(1999, 7, 6);
_assertPred!"=="(dt._date, Date(1999, 7, 6));
_assertPred!"=="(dt._tod, TimeOfDay.init);
const cdt = DateTime(1999, 7, 6);
immutable idt = DateTime(1999, 7, 6);
static assert(!__traits(compiles, cdt.date = Date(2010, 1, 1)));
static assert(!__traits(compiles, idt.date = Date(2010, 1, 1)));
}
}
/++
The time portion of $(D DateTime).
+/
@property TimeOfDay timeOfDay() const pure nothrow
{
return _tod;
}
unittest
{
version(testStdDateTime)
{
{
auto dt = DateTime.init;
_assertPred!"=="(dt.timeOfDay, TimeOfDay.init);
}
{
auto dt = DateTime(Date.init, TimeOfDay(12, 30, 33));
_assertPred!"=="(dt.timeOfDay, TimeOfDay(12, 30, 33));
}
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(__traits(compiles, cdt.timeOfDay == TimeOfDay(12, 30, 33)));
static assert(__traits(compiles, idt.timeOfDay == TimeOfDay(12, 30, 33)));
}
}
/++
The time portion of $(D DateTime).
Params:
tod = The $(D TimeOfDay) to set this $(D DateTime)'s time portion
to.
+/
@property void timeOfDay(in TimeOfDay tod) pure nothrow
{
_tod = tod;
}
unittest
{
version(testStdDateTime)
{
auto dt = DateTime.init;
dt.timeOfDay = TimeOfDay(12, 30, 33);
_assertPred!"=="(dt._date, date.init);
_assertPred!"=="(dt._tod, TimeOfDay(12, 30, 33));
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(!__traits(compiles, cdt.timeOfDay = TimeOfDay(12, 30, 33)));
static assert(!__traits(compiles, idt.timeOfDay = TimeOfDay(12, 30, 33)));
}
}
/++
Year of the Gregorian Calendar. Positive numbers are A.D. Non-positive
are B.C.
+/
@property short year() const pure nothrow
{
return _date.year;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(Date.init.year, 1);
_assertPred!"=="(Date(1999, 7, 6).year, 1999);
_assertPred!"=="(Date(-1999, 7, 6).year, -1999);
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(__traits(compiles, idt.year));
static assert(__traits(compiles, idt.year));
}
}
/++
Year of the Gregorian Calendar. Positive numbers are A.D. Non-positive
are B.C.
Params:
year = The year to set this $(D DateTime)'s year to.
Throws:
$(D DateTimeException) if the new year is not a leap year and if the
resulting date would be on February 29th.
Examples:
--------------------
assert(DateTime(Date(1999, 7, 6), TimeOfDay(9, 7, 5)).year == 1999);
assert(DateTime(Date(2010, 10, 4), TimeOfDay(0, 0, 30)).year == 2010);
assert(DateTime(Date(-7, 4, 5), TimeOfDay(7, 45, 2)).year == -7);
--------------------
+/
@property void year(int year) pure
{
_date.year = year;
}
unittest
{
version(testStdDateTime)
{
static void testDT(DateTime dt, int year, in DateTime expected, size_t line = __LINE__)
{
dt.year = year;
_assertPred!"=="(dt, expected, "", __FILE__, line);
}
testDT(DateTime(Date(1, 1, 1), TimeOfDay(12, 30, 33)), 1999, DateTime(Date(1999, 1, 1), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1, 1, 1), TimeOfDay(12, 30, 33)), 0, DateTime(Date(0, 1, 1), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1, 1, 1), TimeOfDay(12, 30, 33)), -1999, DateTime(Date(-1999, 1, 1), TimeOfDay(12, 30, 33)));
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(!__traits(compiles, cdt.year = 7));
static assert(!__traits(compiles, idt.year = 7));
//Verify Examples.
assert(DateTime(Date(1999, 7, 6), TimeOfDay(9, 7, 5)).year == 1999);
assert(DateTime(Date(2010, 10, 4), TimeOfDay(0, 0, 30)).year == 2010);
assert(DateTime(Date(-7, 4, 5), TimeOfDay(7, 45, 2)).year == -7);
}
}
/++
Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.
Throws:
$(D DateTimeException) if $(D isAD) is true.
Examples:
--------------------
assert(DateTime(Date(0, 1, 1), TimeOfDay(12, 30, 33)).yearBC == 1);
assert(DateTime(Date(-1, 1, 1), TimeOfDay(10, 7, 2)).yearBC == 2);
assert(DateTime(Date(-100, 1, 1), TimeOfDay(4, 59, 0)).yearBC == 101);
--------------------
+/
@property short yearBC() const pure
{
return _date.yearBC;
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException((in DateTime dt){dt.yearBC;}(DateTime(Date(1, 1, 1))));
auto dt = DateTime(1999, 7, 6, 12, 30, 33);
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(__traits(compiles, dt.yearBC = 12));
static assert(!__traits(compiles, cdt.yearBC = 12));
static assert(!__traits(compiles, idt.yearBC = 12));
//Verify Examples.
assert(DateTime(Date(0, 1, 1), TimeOfDay(12, 30, 33)).yearBC == 1);
assert(DateTime(Date(-1, 1, 1), TimeOfDay(10, 7, 2)).yearBC == 2);
assert(DateTime(Date(-100, 1, 1), TimeOfDay(4, 59, 0)).yearBC == 101);
}
}
/++
Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.
Params:
year = The year B.C. to set this $(D DateTime)'s year to.
Throws:
$(D DateTimeException) if a non-positive value is given.
Examples:
--------------------
auto dt = DateTime(Date(2010, 1, 1), TimeOfDay(7, 30, 0));
dt.yearBC = 1;
assert(dt == DateTime(Date(0, 1, 1), TimeOfDay(7, 30, 0)));
dt.yearBC = 10;
assert(dt == DateTime(Date(-9, 1, 1), TimeOfDay(7, 30, 0)));
--------------------
+/
@property void yearBC(int year) pure
{
_date.yearBC = year;
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException((DateTime dt){dt.yearBC = -1;}(DateTime(Date(1, 1, 1))));
{
auto dt = DateTime(1999, 7, 6, 12, 30, 33);
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(__traits(compiles, dt.yearBC = 12));
static assert(!__traits(compiles, cdt.yearBC = 12));
static assert(!__traits(compiles, idt.yearBC = 12));
}
//Verify Examples.
{
auto dt = DateTime(Date(2010, 1, 1), TimeOfDay(7, 30, 0));
dt.yearBC = 1;
assert(dt == DateTime(Date(0, 1, 1), TimeOfDay(7, 30, 0)));
dt.yearBC = 10;
assert(dt == DateTime(Date(-9, 1, 1), TimeOfDay(7, 30, 0)));
}
}
}
/++
Month of a Gregorian Year.
Examples:
--------------------
assert(DateTime(Date(1999, 7, 6), TimeOfDay(9, 7, 5)).month == 7);
assert(DateTime(Date(2010, 10, 4), TimeOfDay(0, 0, 30)).month == 10);
assert(DateTime(Date(-7, 4, 5), TimeOfDay(7, 45, 2)).month == 4);
--------------------
+/
@property Month month() const pure nothrow
{
return _date.month;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(DateTime.init.month, 1);
_assertPred!"=="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)).month, 7);
_assertPred!"=="(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)).month, 7);
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(__traits(compiles, cdt.month));
static assert(__traits(compiles, idt.month));
//Verify Examples.
assert(DateTime(Date(1999, 7, 6), TimeOfDay(9, 7, 5)).month == 7);
assert(DateTime(Date(2010, 10, 4), TimeOfDay(0, 0, 30)).month == 10);
assert(DateTime(Date(-7, 4, 5), TimeOfDay(7, 45, 2)).month == 4);
}
}
/++
Month of a Gregorian Year.
Params:
month = The month to set this $(D DateTime)'s month to.
Throws:
$(D DateTimeException) if the given month is not a valid month.
+/
@property void month(Month month) pure
{
_date.month = month;
}
unittest
{
version(testStdDateTime)
{
static void testDT(DateTime dt, Month month, in DateTime expected = DateTime.init, size_t line = __LINE__)
{
dt.month = month;
assert(expected != DateTime.init);
_assertPred!"=="(dt, expected, "", __FILE__, line);
}
assertThrown!DateTimeException(testDT(DateTime(Date(1, 1, 1), TimeOfDay(12, 30, 33)), cast(Month)0));
assertThrown!DateTimeException(testDT(DateTime(Date(1, 1, 1), TimeOfDay(12, 30, 33)), cast(Month)13));
testDT(DateTime(Date(1, 1, 1), TimeOfDay(12, 30, 33)), cast(Month)7, DateTime(Date(1, 7, 1), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(-1, 1, 1), TimeOfDay(12, 30, 33)), cast(Month)7, DateTime(Date(-1, 7, 1), TimeOfDay(12, 30, 33)));
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(!__traits(compiles, cdt.month = 12));
static assert(!__traits(compiles, idt.month = 12));
}
}
/++
Day of a Gregorian Month.
Examples:
--------------------
assert(DateTime(Date(1999, 7, 6), TimeOfDay(9, 7, 5)).day == 6);
assert(DateTime(Date(2010, 10, 4), TimeOfDay(0, 0, 30)).day == 4);
assert(DateTime(Date(-7, 4, 5), TimeOfDay(7, 45, 2)).day == 5);
--------------------
+/
@property ubyte day() const pure nothrow
{
return _date.day;
}
//Verify Examples.
version(testStdDateTime) unittest
{
assert(DateTime(Date(1999, 7, 6), TimeOfDay(9, 7, 5)).day == 6);
assert(DateTime(Date(2010, 10, 4), TimeOfDay(0, 0, 30)).day == 4);
assert(DateTime(Date(-7, 4, 5), TimeOfDay(7, 45, 2)).day == 5);
}
version(testStdDateTime) unittest
{
static void test(DateTime dateTime, int expected, size_t line = __LINE__)
{
_assertPred!"=="(dateTime.day, expected,
format("Value given: %s", dateTime), __FILE__, line);
}
foreach(year; chain(testYearsBC, testYearsAD))
{
foreach(md; testMonthDays)
{
foreach(tod; testTODs)
test(DateTime(Date(year, md.month, md.day), tod), md.day);
}
}
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(__traits(compiles, cdt.day));
static assert(__traits(compiles, idt.day));
}
/++
Day of a Gregorian Month.
Params:
day = The day of the month to set this $(D DateTime)'s day to.
Throws:
$(D DateTimeException) if the given day is not a valid day of the
current month.
+/
@property void day(int day) pure
{
_date.day = day;
}
unittest
{
version(testStdDateTime)
{
static void testDT(DateTime dt, int day)
{
dt.day = day;
}
//Test A.D.
assertThrown!DateTimeException(testDT(DateTime(Date(1, 1, 1)), 0));
assertThrown!DateTimeException(testDT(DateTime(Date(1, 1, 1)), 32));
assertThrown!DateTimeException(testDT(DateTime(Date(1, 2, 1)), 29));
assertThrown!DateTimeException(testDT(DateTime(Date(4, 2, 1)), 30));
assertThrown!DateTimeException(testDT(DateTime(Date(1, 3, 1)), 32));
assertThrown!DateTimeException(testDT(DateTime(Date(1, 4, 1)), 31));
assertThrown!DateTimeException(testDT(DateTime(Date(1, 5, 1)), 32));
assertThrown!DateTimeException(testDT(DateTime(Date(1, 6, 1)), 31));
assertThrown!DateTimeException(testDT(DateTime(Date(1, 7, 1)), 32));
assertThrown!DateTimeException(testDT(DateTime(Date(1, 8, 1)), 32));
assertThrown!DateTimeException(testDT(DateTime(Date(1, 9, 1)), 31));
assertThrown!DateTimeException(testDT(DateTime(Date(1, 10, 1)), 32));
assertThrown!DateTimeException(testDT(DateTime(Date(1, 11, 1)), 31));
assertThrown!DateTimeException(testDT(DateTime(Date(1, 12, 1)), 32));
assertNotThrown!DateTimeException(testDT(DateTime(Date(1, 1, 1)), 31));
assertNotThrown!DateTimeException(testDT(DateTime(Date(1, 2, 1)), 28));
assertNotThrown!DateTimeException(testDT(DateTime(Date(4, 2, 1)), 29));
assertNotThrown!DateTimeException(testDT(DateTime(Date(1, 3, 1)), 31));
assertNotThrown!DateTimeException(testDT(DateTime(Date(1, 4, 1)), 30));
assertNotThrown!DateTimeException(testDT(DateTime(Date(1, 5, 1)), 31));
assertNotThrown!DateTimeException(testDT(DateTime(Date(1, 6, 1)), 30));
assertNotThrown!DateTimeException(testDT(DateTime(Date(1, 7, 1)), 31));
assertNotThrown!DateTimeException(testDT(DateTime(Date(1, 8, 1)), 31));
assertNotThrown!DateTimeException(testDT(DateTime(Date(1, 9, 1)), 30));
assertNotThrown!DateTimeException(testDT(DateTime(Date(1, 10, 1)), 31));
assertNotThrown!DateTimeException(testDT(DateTime(Date(1, 11, 1)), 30));
assertNotThrown!DateTimeException(testDT(DateTime(Date(1, 12, 1)), 31));
{
auto dt = DateTime(Date(1, 1, 1), TimeOfDay(7, 12, 22));
dt.day = 6;
_assertPred!"=="(dt, DateTime(Date(1, 1, 6), TimeOfDay(7, 12, 22)));
}
//Test B.C.
assertThrown!DateTimeException(testDT(DateTime(Date(-1, 1, 1)), 0));
assertThrown!DateTimeException(testDT(DateTime(Date(-1, 1, 1)), 32));
assertThrown!DateTimeException(testDT(DateTime(Date(-1, 2, 1)), 29));
assertThrown!DateTimeException(testDT(DateTime(Date(0, 2, 1)), 30));
assertThrown!DateTimeException(testDT(DateTime(Date(-1, 3, 1)), 32));
assertThrown!DateTimeException(testDT(DateTime(Date(-1, 4, 1)), 31));
assertThrown!DateTimeException(testDT(DateTime(Date(-1, 5, 1)), 32));
assertThrown!DateTimeException(testDT(DateTime(Date(-1, 6, 1)), 31));
assertThrown!DateTimeException(testDT(DateTime(Date(-1, 7, 1)), 32));
assertThrown!DateTimeException(testDT(DateTime(Date(-1, 8, 1)), 32));
assertThrown!DateTimeException(testDT(DateTime(Date(-1, 9, 1)), 31));
assertThrown!DateTimeException(testDT(DateTime(Date(-1, 10, 1)), 32));
assertThrown!DateTimeException(testDT(DateTime(Date(-1, 11, 1)), 31));
assertThrown!DateTimeException(testDT(DateTime(Date(-1, 12, 1)), 32));
assertNotThrown!DateTimeException(testDT(DateTime(Date(-1, 1, 1)), 31));
assertNotThrown!DateTimeException(testDT(DateTime(Date(-1, 2, 1)), 28));
assertNotThrown!DateTimeException(testDT(DateTime(Date(0, 2, 1)), 29));
assertNotThrown!DateTimeException(testDT(DateTime(Date(-1, 3, 1)), 31));
assertNotThrown!DateTimeException(testDT(DateTime(Date(-1, 4, 1)), 30));
assertNotThrown!DateTimeException(testDT(DateTime(Date(-1, 5, 1)), 31));
assertNotThrown!DateTimeException(testDT(DateTime(Date(-1, 6, 1)), 30));
assertNotThrown!DateTimeException(testDT(DateTime(Date(-1, 7, 1)), 31));
assertNotThrown!DateTimeException(testDT(DateTime(Date(-1, 8, 1)), 31));
assertNotThrown!DateTimeException(testDT(DateTime(Date(-1, 9, 1)), 30));
assertNotThrown!DateTimeException(testDT(DateTime(Date(-1, 10, 1)), 31));
assertNotThrown!DateTimeException(testDT(DateTime(Date(-1, 11, 1)), 30));
assertNotThrown!DateTimeException(testDT(DateTime(Date(-1, 12, 1)), 31));
auto dt = DateTime(Date(-1, 1, 1), TimeOfDay(7, 12, 22));
dt.day = 6;
_assertPred!"=="(dt, DateTime(Date(-1, 1, 6), TimeOfDay(7, 12, 22)));
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(!__traits(compiles, cdt.day = 27));
static assert(!__traits(compiles, idt.day = 27));
}
}
/++
Hours passed midnight.
+/
@property ubyte hour() const pure nothrow
{
return _tod.hour;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(DateTime.init.hour, 0);
_assertPred!"=="(DateTime(Date.init, TimeOfDay(12, 0, 0)).hour, 12);
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(__traits(compiles, cdt.hour));
static assert(__traits(compiles, idt.hour));
}
}
/++
Hours passed midnight.
Params:
hour = The hour of the day to set this $(D DateTime)'s hour to.
Throws:
$(D DateTimeException) if the given hour would result in an invalid
$(D DateTime).
+/
@property void hour(int hour) pure
{
_tod.hour = hour;
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException((){DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 0)).hour = 24;}());
auto dt = DateTime.init;
dt.hour = 12;
_assertPred!"=="(dt, DateTime(1, 1, 1, 12, 0, 0));
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(!__traits(compiles, cdt.hour = 27));
static assert(!__traits(compiles, idt.hour = 27));
}
}
/++
Minutes passed the hour.
+/
@property ubyte minute() const pure nothrow
{
return _tod.minute;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(DateTime.init.minute, 0);
_assertPred!"=="(DateTime(1, 1, 1, 0, 30, 0).minute, 30);
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(__traits(compiles, cdt.minute));
static assert(__traits(compiles, idt.minute));
}
}
/++
Minutes passed the hour.
Params:
minute = The minute to set this $(D DateTime)'s minute to.
Throws:
$(D DateTimeException) if the given minute would result in an
invalid $(D DateTime).
+/
@property void minute(int minute) pure
{
_tod.minute = minute;
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException((){DateTime.init.minute = 60;}());
auto dt = DateTime.init;
dt.minute = 30;
_assertPred!"=="(dt, DateTime(1, 1, 1, 0, 30, 0));
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(!__traits(compiles, cdt.minute = 27));
static assert(!__traits(compiles, idt.minute = 27));
}
}
/++
Seconds passed the minute.
+/
@property ubyte second() const pure nothrow
{
return _tod.second;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(DateTime.init.second, 0);
_assertPred!"=="(DateTime(1, 1, 1, 0, 0, 33).second, 33);
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(__traits(compiles, cdt.second));
static assert(__traits(compiles, idt.second));
}
}
/++
Seconds passed the minute.
Params:
second = The second to set this $(D DateTime)'s second to.
Throws:
$(D DateTimeException) if the given seconds would result in an
invalid $(D DateTime).
+/
@property void second(int second) pure
{
_tod.second = second;
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException((){DateTime.init.second = 60;}());
auto dt = DateTime.init;
dt.second = 33;
_assertPred!"=="(dt, DateTime(1, 1, 1, 0, 0, 33));
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(!__traits(compiles, cdt.second = 27));
static assert(!__traits(compiles, idt.second = 27));
}
}
/++
Adds the given number of years or months to this $(D DateTime). A
negative number will subtract.
Note that if day overflow is allowed, and the date with the adjusted
year/month overflows the number of days in the new month, then the month
will be incremented by one, and the day set to the number of days
overflowed. (e.g. if the day were 31 and the new month were June, then
the month would be incremented to July, and the new day would be 1). If
day overflow is not allowed, then the day will be set to the last valid
day in the month (e.g. June 31st would become June 30th).
Params:
units = The type of units to add ("years" or "months").
value = The number of months or years to add to this
$(D DateTime).
allowOverflow = Whether the days should be allowed to overflow,
causing the month to increment.
Examples:
--------------------
auto dt1 = DateTime(2010, 1, 1, 12, 30, 33);
dt1.add!"months"(11);
assert(dt1 == DateTime(2010, 12, 1, 12, 30, 33));
auto dt2 = DateTime(2010, 1, 1, 12, 30, 33);
dt2.add!"months"(-11);
assert(dt2 == DateTime(2009, 2, 1, 12, 30, 33));
auto dt3 = DateTime(2000, 2, 29, 12, 30, 33);
dt3.add!"years"(1);
assert(dt3 == DateTime(2001, 3, 1, 12, 30, 33));
auto dt4 = DateTime(2000, 2, 29, 12, 30, 33);
dt4.add!"years"(1, AllowDayOverflow.no);
assert(dt4 == DateTime(2001, 2, 28, 12, 30, 33));
--------------------
+/
/+ref DateTime+/ void add(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) pure nothrow
if(units == "years" ||
units == "months")
{
_date.add!units(value, allowOverflow);
}
//Verify Examples.
unittest
{
version(testStdDateTime)
{
auto dt1 = DateTime(2010, 1, 1, 12, 30, 33);
dt1.add!"months"(11);
assert(dt1 == DateTime(2010, 12, 1, 12, 30, 33));
auto dt2 = DateTime(2010, 1, 1, 12, 30, 33);
dt2.add!"months"(-11);
assert(dt2 == DateTime(2009, 2, 1, 12, 30, 33));
auto dt3 = DateTime(2000, 2, 29, 12, 30, 33);
dt3.add!"years"(1);
assert(dt3 == DateTime(2001, 3, 1, 12, 30, 33));
auto dt4 = DateTime(2000, 2, 29, 12, 30, 33);
dt4.add!"years"(1, AllowDayOverflow.no);
assert(dt4 == DateTime(2001, 2, 28, 12, 30, 33));
}
}
unittest
{
version(testStdDateTime)
{
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(!__traits(compiles, cdt.add!"years"(4)));
static assert(!__traits(compiles, idt.add!"years"(4)));
static assert(!__traits(compiles, cdt.add!"months"(4)));
static assert(!__traits(compiles, idt.add!"months"(4)));
}
}
/++
Adds the given number of years or months to this $(D DateTime). A
negative number will subtract.
The difference between rolling and adding is that rolling does not
affect larger units. So, if you roll a $(D DateTime) 12 months, you
get the exact same $(D DateTime). However, the days can still be
affected due to the differing number of days in each month.
Because there are no units larger than years, there is no difference
between adding and rolling years.
Params:
units = The type of units to add ("years" or "months").
value = The number of months or years to add to this
$(D DateTime).
allowOverflow = Whether the days should be allowed to overflow,
causing the month to increment.
Examples:
--------------------
auto dt1 = DateTime(2010, 1, 1, 12, 33, 33);
dt1.roll!"months"(1);
assert(dt1 == DateTime(2010, 2, 1, 12, 33, 33));
auto dt2 = DateTime(2010, 1, 1, 12, 33, 33);
dt2.roll!"months"(-1);
assert(dt2 == DateTime(2010, 12, 1, 12, 33, 33));
auto dt3 = DateTime(1999, 1, 29, 12, 33, 33);
dt3.roll!"months"(1);
assert(dt3 == DateTime(1999, 3, 1, 12, 33, 33));
auto dt4 = DateTime(1999, 1, 29, 12, 33, 33);
dt4.roll!"months"(1, AllowDayOverflow.no);
assert(dt4 == DateTime(1999, 2, 28, 12, 33, 33));
auto dt5 = DateTime(2000, 2, 29, 12, 30, 33);
dt5.roll!"years"(1);
assert(dt5 == DateTime(2001, 3, 1, 12, 30, 33));
auto dt6 = DateTime(2000, 2, 29, 12, 30, 33);
dt6.roll!"years"(1, AllowDayOverflow.no);
assert(dt6 == DateTime(2001, 2, 28, 12, 30, 33));
--------------------
+/
/+ref DateTime+/ void roll(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) pure nothrow
if(units == "years" ||
units == "months")
{
_date.roll!units(value, allowOverflow);
}
//Verify Examples.
unittest
{
version(testdStdDateTime)
{
auto dt1 = DateTime(2010, 1, 1, 12, 33, 33);
dt1.roll!"months"(1);
assert(dt1 == DateTime(2010, 2, 1, 12, 33, 33));
auto dt2 = DateTime(2010, 1, 1, 12, 33, 33);
dt2.roll!"months"(-1);
assert(dt2 == DateTime(2010, 12, 1, 12, 33, 33));
auto dt3 = DateTime(1999, 1, 29, 12, 33, 33);
dt3.roll!"months"(1);
assert(dt3 == DateTime(1999, 3, 1, 12, 33, 33));
auto dt4 = DateTime(1999, 1, 29, 12, 33, 33);
dt4.roll!"months"(1, AllowDayOverflow.no);
assert(dt4 == DateTime(1999, 2, 28, 12, 33, 33));
auto dt5 = DateTime(2000, 2, 29, 12, 30, 33);
dt5.roll!"years"(1);
assert(dt5 == DateTime(2001, 3, 1, 12, 30, 33));
auto dt6 = DateTime(2000, 2, 29, 12, 30, 33);
dt6.roll!"years"(1, AllowDayOverflow.no);
assert(dt6 == DateTime(2001, 2, 28, 12, 30, 33));
}
}
unittest
{
version(testStdDateTime)
{
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(!__traits(compiles, cdt.roll!"years"(4)));
static assert(!__traits(compiles, idt.roll!"years"(4)));
static assert(!__traits(compiles, cdt.roll!"months"(4)));
static assert(!__traits(compiles, idt.roll!"months"(4)));
static assert(!__traits(compiles, cdt.roll!"days"(4)));
static assert(!__traits(compiles, idt.roll!"days"(4)));
}
}
/++
Adds the given number of units to this $(D DateTime). A negative number
will subtract.
The difference between rolling and adding is that rolling does not
affect larger units. So, for instance, if you roll a $(D DateTime) one
year's worth of days, then you get the exact same $(D DateTime).
Accepted units are $(D "days"), $(D "minutes"), $(D "hours"),
$(D "minutes"), and $(D "seconds").
Params:
units = The units to add.
value = The number of $(D_PARAM units) to add to this $(D DateTime).
Examples:
--------------------
auto dt1 = DateTime(2010, 1, 1, 11, 23, 12);
dt1.roll!"days"(1);
assert(dt1 == DateTime(2010, 1, 2, 11, 23, 12));
dt1.roll!"days"(365);
assert(dt1 == DateTime(2010, 1, 26, 11, 23, 12));
dt1.roll!"days"(-32);
assert(dt1 == DateTime(2010, 1, 25, 11, 23, 12));
auto dt2 = DateTime(2010, 7, 4, 12, 0, 0);
dt2.roll!"hours"(1);
assert(dt2 == DateTime(2010, 7, 4, 13, 0, 0));
auto dt3 = DateTime(2010, 1, 1, 0, 0, 0);
dt3.roll!"seconds"(-1);
assert(dt3 == DateTime(2010, 1, 1, 0, 0, 59));
--------------------
+/
/+ref DateTime+/ void roll(string units)(long days) pure nothrow
if(units == "days")
{
_date.roll!"days"(days);
}
//Verify Examples.
unittest
{
version(testStdDateTime)
{
auto dt1 = DateTime(2010, 1, 1, 11, 23, 12);
dt1.roll!"days"(1);
assert(dt1 == DateTime(2010, 1, 2, 11, 23, 12));
dt1.roll!"days"(365);
assert(dt1 == DateTime(2010, 1, 26, 11, 23, 12));
dt1.roll!"days"(-32);
assert(dt1 == DateTime(2010, 1, 25, 11, 23, 12));
auto dt2 = DateTime(2010, 7, 4, 12, 0, 0);
dt2.roll!"hours"(1);
assert(dt2 == DateTime(2010, 7, 4, 13, 0, 0));
auto dt3 = DateTime(2010, 1, 1, 0, 0, 0);
dt3.roll!"seconds"(-1);
assert(dt3 == DateTime(2010, 1, 1, 0, 0, 59));
}
}
unittest
{
version(testStdDateTime)
{
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(!__traits(compiles, cdt.roll!"days"(4)));
static assert(!__traits(compiles, idt.roll!"days"(4)));
}
}
//Shares documentation with "days" version.
/+ref DateTime+/ void roll(string units)(long value) pure nothrow
if(units == "hours" ||
units == "minutes" ||
units == "seconds")
{
_tod.roll!units(value);
}
//Test roll!"hours"().
unittest
{
version(testStdDateTime)
{
static void testDT(DateTime orig, int hours, in DateTime expected, size_t line = __LINE__)
{
orig.roll!"hours"(hours);
_assertPred!"=="(orig, expected, "", __FILE__, line);
}
//Test A.D.
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 0, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 1, DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 2, DateTime(Date(1999, 7, 6), TimeOfDay(14, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 3, DateTime(Date(1999, 7, 6), TimeOfDay(15, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 4, DateTime(Date(1999, 7, 6), TimeOfDay(16, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 5, DateTime(Date(1999, 7, 6), TimeOfDay(17, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 6, DateTime(Date(1999, 7, 6), TimeOfDay(18, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 7, DateTime(Date(1999, 7, 6), TimeOfDay(19, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 8, DateTime(Date(1999, 7, 6), TimeOfDay(20, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 9, DateTime(Date(1999, 7, 6), TimeOfDay(21, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 10, DateTime(Date(1999, 7, 6), TimeOfDay(22, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 11, DateTime(Date(1999, 7, 6), TimeOfDay(23, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 12, DateTime(Date(1999, 7, 6), TimeOfDay(0, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 13, DateTime(Date(1999, 7, 6), TimeOfDay(1, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 14, DateTime(Date(1999, 7, 6), TimeOfDay(2, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 15, DateTime(Date(1999, 7, 6), TimeOfDay(3, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 16, DateTime(Date(1999, 7, 6), TimeOfDay(4, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 17, DateTime(Date(1999, 7, 6), TimeOfDay(5, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 18, DateTime(Date(1999, 7, 6), TimeOfDay(6, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 19, DateTime(Date(1999, 7, 6), TimeOfDay(7, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 20, DateTime(Date(1999, 7, 6), TimeOfDay(8, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 21, DateTime(Date(1999, 7, 6), TimeOfDay(9, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 22, DateTime(Date(1999, 7, 6), TimeOfDay(10, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 23, DateTime(Date(1999, 7, 6), TimeOfDay(11, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 24, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 25, DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -1, DateTime(Date(1999, 7, 6), TimeOfDay(11, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -2, DateTime(Date(1999, 7, 6), TimeOfDay(10, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -3, DateTime(Date(1999, 7, 6), TimeOfDay(9, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -4, DateTime(Date(1999, 7, 6), TimeOfDay(8, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -5, DateTime(Date(1999, 7, 6), TimeOfDay(7, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -6, DateTime(Date(1999, 7, 6), TimeOfDay(6, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -7, DateTime(Date(1999, 7, 6), TimeOfDay(5, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -8, DateTime(Date(1999, 7, 6), TimeOfDay(4, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -9, DateTime(Date(1999, 7, 6), TimeOfDay(3, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -10, DateTime(Date(1999, 7, 6), TimeOfDay(2, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -11, DateTime(Date(1999, 7, 6), TimeOfDay(1, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -12, DateTime(Date(1999, 7, 6), TimeOfDay(0, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -13, DateTime(Date(1999, 7, 6), TimeOfDay(23, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -14, DateTime(Date(1999, 7, 6), TimeOfDay(22, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -15, DateTime(Date(1999, 7, 6), TimeOfDay(21, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -16, DateTime(Date(1999, 7, 6), TimeOfDay(20, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -17, DateTime(Date(1999, 7, 6), TimeOfDay(19, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -18, DateTime(Date(1999, 7, 6), TimeOfDay(18, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -19, DateTime(Date(1999, 7, 6), TimeOfDay(17, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -20, DateTime(Date(1999, 7, 6), TimeOfDay(16, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -21, DateTime(Date(1999, 7, 6), TimeOfDay(15, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -22, DateTime(Date(1999, 7, 6), TimeOfDay(14, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -23, DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -24, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -25, DateTime(Date(1999, 7, 6), TimeOfDay(11, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(0, 30, 33)), 1, DateTime(Date(1999, 7, 6), TimeOfDay(1, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(0, 30, 33)), 0, DateTime(Date(1999, 7, 6), TimeOfDay(0, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(0, 30, 33)), -1, DateTime(Date(1999, 7, 6), TimeOfDay(23, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(23, 30, 33)), 1, DateTime(Date(1999, 7, 6), TimeOfDay(0, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(23, 30, 33)), 0, DateTime(Date(1999, 7, 6), TimeOfDay(23, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(23, 30, 33)), -1, DateTime(Date(1999, 7, 6), TimeOfDay(22, 30, 33)));
testDT(DateTime(Date(1999, 7, 31), TimeOfDay(23, 30, 33)), 1, DateTime(Date(1999, 7, 31), TimeOfDay(0, 30, 33)));
testDT(DateTime(Date(1999, 8, 1), TimeOfDay(0, 30, 33)), -1, DateTime(Date(1999, 8, 1), TimeOfDay(23, 30, 33)));
testDT(DateTime(Date(1999, 12, 31), TimeOfDay(23, 30, 33)), 1, DateTime(Date(1999, 12, 31), TimeOfDay(0, 30, 33)));
testDT(DateTime(Date(2000, 1, 1), TimeOfDay(0, 30, 33)), -1, DateTime(Date(2000, 1, 1), TimeOfDay(23, 30, 33)));
testDT(DateTime(Date(1999, 2, 28), TimeOfDay(23, 30, 33)), 25, DateTime(Date(1999, 2, 28), TimeOfDay(0, 30, 33)));
testDT(DateTime(Date(1999, 3, 2), TimeOfDay(0, 30, 33)), -25, DateTime(Date(1999, 3, 2), TimeOfDay(23, 30, 33)));
testDT(DateTime(Date(2000, 2, 28), TimeOfDay(23, 30, 33)), 25, DateTime(Date(2000, 2, 28), TimeOfDay(0, 30, 33)));
testDT(DateTime(Date(2000, 3, 1), TimeOfDay(0, 30, 33)), -25, DateTime(Date(2000, 3, 1), TimeOfDay(23, 30, 33)));
//Test B.C.
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 0, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 1, DateTime(Date(-1999, 7, 6), TimeOfDay(13, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 2, DateTime(Date(-1999, 7, 6), TimeOfDay(14, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 3, DateTime(Date(-1999, 7, 6), TimeOfDay(15, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 4, DateTime(Date(-1999, 7, 6), TimeOfDay(16, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 5, DateTime(Date(-1999, 7, 6), TimeOfDay(17, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 6, DateTime(Date(-1999, 7, 6), TimeOfDay(18, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 7, DateTime(Date(-1999, 7, 6), TimeOfDay(19, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 8, DateTime(Date(-1999, 7, 6), TimeOfDay(20, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 9, DateTime(Date(-1999, 7, 6), TimeOfDay(21, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 10, DateTime(Date(-1999, 7, 6), TimeOfDay(22, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 11, DateTime(Date(-1999, 7, 6), TimeOfDay(23, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 12, DateTime(Date(-1999, 7, 6), TimeOfDay(0, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 13, DateTime(Date(-1999, 7, 6), TimeOfDay(1, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 14, DateTime(Date(-1999, 7, 6), TimeOfDay(2, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 15, DateTime(Date(-1999, 7, 6), TimeOfDay(3, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 16, DateTime(Date(-1999, 7, 6), TimeOfDay(4, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 17, DateTime(Date(-1999, 7, 6), TimeOfDay(5, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 18, DateTime(Date(-1999, 7, 6), TimeOfDay(6, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 19, DateTime(Date(-1999, 7, 6), TimeOfDay(7, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 20, DateTime(Date(-1999, 7, 6), TimeOfDay(8, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 21, DateTime(Date(-1999, 7, 6), TimeOfDay(9, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 22, DateTime(Date(-1999, 7, 6), TimeOfDay(10, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 23, DateTime(Date(-1999, 7, 6), TimeOfDay(11, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 24, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 25, DateTime(Date(-1999, 7, 6), TimeOfDay(13, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -1, DateTime(Date(-1999, 7, 6), TimeOfDay(11, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -2, DateTime(Date(-1999, 7, 6), TimeOfDay(10, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -3, DateTime(Date(-1999, 7, 6), TimeOfDay(9, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -4, DateTime(Date(-1999, 7, 6), TimeOfDay(8, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -5, DateTime(Date(-1999, 7, 6), TimeOfDay(7, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -6, DateTime(Date(-1999, 7, 6), TimeOfDay(6, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -7, DateTime(Date(-1999, 7, 6), TimeOfDay(5, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -8, DateTime(Date(-1999, 7, 6), TimeOfDay(4, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -9, DateTime(Date(-1999, 7, 6), TimeOfDay(3, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -10, DateTime(Date(-1999, 7, 6), TimeOfDay(2, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -11, DateTime(Date(-1999, 7, 6), TimeOfDay(1, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -12, DateTime(Date(-1999, 7, 6), TimeOfDay(0, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -13, DateTime(Date(-1999, 7, 6), TimeOfDay(23, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -14, DateTime(Date(-1999, 7, 6), TimeOfDay(22, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -15, DateTime(Date(-1999, 7, 6), TimeOfDay(21, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -16, DateTime(Date(-1999, 7, 6), TimeOfDay(20, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -17, DateTime(Date(-1999, 7, 6), TimeOfDay(19, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -18, DateTime(Date(-1999, 7, 6), TimeOfDay(18, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -19, DateTime(Date(-1999, 7, 6), TimeOfDay(17, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -20, DateTime(Date(-1999, 7, 6), TimeOfDay(16, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -21, DateTime(Date(-1999, 7, 6), TimeOfDay(15, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -22, DateTime(Date(-1999, 7, 6), TimeOfDay(14, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -23, DateTime(Date(-1999, 7, 6), TimeOfDay(13, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -24, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -25, DateTime(Date(-1999, 7, 6), TimeOfDay(11, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(0, 30, 33)), 1, DateTime(Date(-1999, 7, 6), TimeOfDay(1, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(0, 30, 33)), 0, DateTime(Date(-1999, 7, 6), TimeOfDay(0, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(0, 30, 33)), -1, DateTime(Date(-1999, 7, 6), TimeOfDay(23, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(23, 30, 33)), 1, DateTime(Date(-1999, 7, 6), TimeOfDay(0, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(23, 30, 33)), 0, DateTime(Date(-1999, 7, 6), TimeOfDay(23, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(23, 30, 33)), -1, DateTime(Date(-1999, 7, 6), TimeOfDay(22, 30, 33)));
testDT(DateTime(Date(-1999, 7, 31), TimeOfDay(23, 30, 33)), 1, DateTime(Date(-1999, 7, 31), TimeOfDay(0, 30, 33)));
testDT(DateTime(Date(-1999, 8, 1), TimeOfDay(0, 30, 33)), -1, DateTime(Date(-1999, 8, 1), TimeOfDay(23, 30, 33)));
testDT(DateTime(Date(-2001, 12, 31), TimeOfDay(23, 30, 33)), 1, DateTime(Date(-2001, 12, 31), TimeOfDay(0, 30, 33)));
testDT(DateTime(Date(-2000, 1, 1), TimeOfDay(0, 30, 33)), -1, DateTime(Date(-2000, 1, 1), TimeOfDay(23, 30, 33)));
testDT(DateTime(Date(-2001, 2, 28), TimeOfDay(23, 30, 33)), 25, DateTime(Date(-2001, 2, 28), TimeOfDay(0, 30, 33)));
testDT(DateTime(Date(-2001, 3, 2), TimeOfDay(0, 30, 33)), -25, DateTime(Date(-2001, 3, 2), TimeOfDay(23, 30, 33)));
testDT(DateTime(Date(-2000, 2, 28), TimeOfDay(23, 30, 33)), 25, DateTime(Date(-2000, 2, 28), TimeOfDay(0, 30, 33)));
testDT(DateTime(Date(-2000, 3, 1), TimeOfDay(0, 30, 33)), -25, DateTime(Date(-2000, 3, 1), TimeOfDay(23, 30, 33)));
//Test Both
testDT(DateTime(Date(-1, 1, 1), TimeOfDay(11, 30, 33)), 17_546, DateTime(Date(-1, 1, 1), TimeOfDay(13, 30, 33)));
testDT(DateTime(Date(1, 1, 1), TimeOfDay(13, 30, 33)), -17_546, DateTime(Date(1, 1, 1), TimeOfDay(11, 30, 33)));
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(!__traits(compiles, cdt.roll!"hours"(4)));
static assert(!__traits(compiles, idt.roll!"hours"(4)));
//Verify Examples.
auto dt1 = DateTime(Date(2010, 7, 4), TimeOfDay(12, 0, 0));
dt1.roll!"hours"(1);
assert(dt1 == DateTime(Date(2010, 7, 4), TimeOfDay(13, 0, 0)));
auto dt2 = DateTime(Date(2010, 2, 12), TimeOfDay(12, 0, 0));
dt2.roll!"hours"(-1);
assert(dt2 == DateTime(Date(2010, 2, 12), TimeOfDay(11, 0, 0)));
auto dt3 = DateTime(Date(2009, 12, 31), TimeOfDay(23, 0, 0));
dt3.roll!"hours"(1);
assert(dt3 == DateTime(Date(2009, 12, 31), TimeOfDay(0, 0, 0)));
auto dt4 = DateTime(Date(2010, 1, 1), TimeOfDay(0, 0, 0));
dt4.roll!"hours"(-1);
assert(dt4 == DateTime(Date(2010, 1, 1), TimeOfDay(23, 0, 0)));
}
}
//Test roll!"minutes"().
unittest
{
version(testStdDateTime)
{
static void testDT(DateTime orig, int minutes, in DateTime expected, size_t line = __LINE__)
{
orig.roll!"minutes"(minutes);
_assertPred!"=="(orig, expected, "", __FILE__, line);
}
//Test A.D.
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 0, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 1, DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 2, DateTime(Date(1999, 7, 6), TimeOfDay(12, 32, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 3, DateTime(Date(1999, 7, 6), TimeOfDay(12, 33, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 4, DateTime(Date(1999, 7, 6), TimeOfDay(12, 34, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 5, DateTime(Date(1999, 7, 6), TimeOfDay(12, 35, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 10, DateTime(Date(1999, 7, 6), TimeOfDay(12, 40, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 15, DateTime(Date(1999, 7, 6), TimeOfDay(12, 45, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 29, DateTime(Date(1999, 7, 6), TimeOfDay(12, 59, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 30, DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 45, DateTime(Date(1999, 7, 6), TimeOfDay(12, 15, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 60, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 75, DateTime(Date(1999, 7, 6), TimeOfDay(12, 45, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 90, DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 100, DateTime(Date(1999, 7, 6), TimeOfDay(12, 10, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 689, DateTime(Date(1999, 7, 6), TimeOfDay(12, 59, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 690, DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 691, DateTime(Date(1999, 7, 6), TimeOfDay(12, 1, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 960, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 1439, DateTime(Date(1999, 7, 6), TimeOfDay(12, 29, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 1440, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 1441, DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 2880, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -1, DateTime(Date(1999, 7, 6), TimeOfDay(12, 29, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -2, DateTime(Date(1999, 7, 6), TimeOfDay(12, 28, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -3, DateTime(Date(1999, 7, 6), TimeOfDay(12, 27, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -4, DateTime(Date(1999, 7, 6), TimeOfDay(12, 26, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -5, DateTime(Date(1999, 7, 6), TimeOfDay(12, 25, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -10, DateTime(Date(1999, 7, 6), TimeOfDay(12, 20, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -15, DateTime(Date(1999, 7, 6), TimeOfDay(12, 15, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -29, DateTime(Date(1999, 7, 6), TimeOfDay(12, 1, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -30, DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -45, DateTime(Date(1999, 7, 6), TimeOfDay(12, 45, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -60, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -75, DateTime(Date(1999, 7, 6), TimeOfDay(12, 15, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -90, DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -100, DateTime(Date(1999, 7, 6), TimeOfDay(12, 50, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -749, DateTime(Date(1999, 7, 6), TimeOfDay(12, 1, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -750, DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -751, DateTime(Date(1999, 7, 6), TimeOfDay(12, 59, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -960, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -1439, DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -1440, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -1441, DateTime(Date(1999, 7, 6), TimeOfDay(12, 29, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -2880, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 33)), 1, DateTime(Date(1999, 7, 6), TimeOfDay(12, 1, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 33)), 0, DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 33)), -1, DateTime(Date(1999, 7, 6), TimeOfDay(12, 59, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(11, 59, 33)), 1, DateTime(Date(1999, 7, 6), TimeOfDay(11, 0, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(11, 59, 33)), 0, DateTime(Date(1999, 7, 6), TimeOfDay(11, 59, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(11, 59, 33)), -1, DateTime(Date(1999, 7, 6), TimeOfDay(11, 58, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 33)), 1, DateTime(Date(1999, 7, 6), TimeOfDay(0, 1, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 33)), 0, DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 33)), -1, DateTime(Date(1999, 7, 6), TimeOfDay(0, 59, 33)));
testDT(DateTime(Date(1999, 7, 5), TimeOfDay(23, 59, 33)), 1, DateTime(Date(1999, 7, 5), TimeOfDay(23, 0, 33)));
testDT(DateTime(Date(1999, 7, 5), TimeOfDay(23, 59, 33)), 0, DateTime(Date(1999, 7, 5), TimeOfDay(23, 59, 33)));
testDT(DateTime(Date(1999, 7, 5), TimeOfDay(23, 59, 33)), -1, DateTime(Date(1999, 7, 5), TimeOfDay(23, 58, 33)));
testDT(DateTime(Date(1998, 12, 31), TimeOfDay(23, 59, 33)), 1, DateTime(Date(1998, 12, 31), TimeOfDay(23, 0, 33)));
testDT(DateTime(Date(1998, 12, 31), TimeOfDay(23, 59, 33)), 0, DateTime(Date(1998, 12, 31), TimeOfDay(23, 59, 33)));
testDT(DateTime(Date(1998, 12, 31), TimeOfDay(23, 59, 33)), -1, DateTime(Date(1998, 12, 31), TimeOfDay(23, 58, 33)));
//Test B.C.
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 0, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 1, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 31, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 2, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 32, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 3, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 33, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 4, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 34, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 5, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 35, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 10, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 40, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 15, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 45, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 29, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 59, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 30, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 0, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 45, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 15, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 60, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 75, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 45, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 90, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 0, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 100, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 10, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 689, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 59, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 690, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 0, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 691, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 1, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 960, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 1439, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 29, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 1440, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 1441, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 31, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 2880, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -1, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 29, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -2, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 28, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -3, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 27, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -4, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 26, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -5, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 25, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -10, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 20, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -15, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 15, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -29, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 1, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -30, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 0, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -45, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 45, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -60, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -75, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 15, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -90, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 0, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -100, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 50, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -749, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 1, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -750, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 0, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -751, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 59, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -960, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -1439, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 31, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -1440, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -1441, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 29, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -2880, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 0, 33)), 1, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 1, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 0, 33)), 0, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 0, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 0, 33)), -1, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 59, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(11, 59, 33)), 1, DateTime(Date(-1999, 7, 6), TimeOfDay(11, 0, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(11, 59, 33)), 0, DateTime(Date(-1999, 7, 6), TimeOfDay(11, 59, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(11, 59, 33)), -1, DateTime(Date(-1999, 7, 6), TimeOfDay(11, 58, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(0, 0, 33)), 1, DateTime(Date(-1999, 7, 6), TimeOfDay(0, 1, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(0, 0, 33)), 0, DateTime(Date(-1999, 7, 6), TimeOfDay(0, 0, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(0, 0, 33)), -1, DateTime(Date(-1999, 7, 6), TimeOfDay(0, 59, 33)));
testDT(DateTime(Date(-1999, 7, 5), TimeOfDay(23, 59, 33)), 1, DateTime(Date(-1999, 7, 5), TimeOfDay(23, 0, 33)));
testDT(DateTime(Date(-1999, 7, 5), TimeOfDay(23, 59, 33)), 0, DateTime(Date(-1999, 7, 5), TimeOfDay(23, 59, 33)));
testDT(DateTime(Date(-1999, 7, 5), TimeOfDay(23, 59, 33)), -1, DateTime(Date(-1999, 7, 5), TimeOfDay(23, 58, 33)));
testDT(DateTime(Date(-2000, 12, 31), TimeOfDay(23, 59, 33)), 1, DateTime(Date(-2000, 12, 31), TimeOfDay(23, 0, 33)));
testDT(DateTime(Date(-2000, 12, 31), TimeOfDay(23, 59, 33)), 0, DateTime(Date(-2000, 12, 31), TimeOfDay(23, 59, 33)));
testDT(DateTime(Date(-2000, 12, 31), TimeOfDay(23, 59, 33)), -1, DateTime(Date(-2000, 12, 31), TimeOfDay(23, 58, 33)));
//Test Both
testDT(DateTime(Date(1, 1, 1), TimeOfDay(0, 0, 0)), -1, DateTime(Date(1, 1, 1), TimeOfDay(0, 59, 0)));
testDT(DateTime(Date(0, 12, 31), TimeOfDay(23, 59, 0)), 1, DateTime(Date(0, 12, 31), TimeOfDay(23, 0, 0)));
testDT(DateTime(Date(0, 1, 1), TimeOfDay(0, 0, 0)), -1, DateTime(Date(0, 1, 1), TimeOfDay(0, 59, 0)));
testDT(DateTime(Date(-1, 12, 31), TimeOfDay(23, 59, 0)), 1, DateTime(Date(-1, 12, 31), TimeOfDay(23, 0, 0)));
testDT(DateTime(Date(-1, 1, 1), TimeOfDay(11, 30, 33)), 1_052_760, DateTime(Date(-1, 1, 1), TimeOfDay(11, 30, 33)));
testDT(DateTime(Date(1, 1, 1), TimeOfDay(13, 30, 33)), -1_052_760, DateTime(Date(1, 1, 1), TimeOfDay(13, 30, 33)));
testDT(DateTime(Date(-1, 1, 1), TimeOfDay(11, 30, 33)), 1_052_782, DateTime(Date(-1, 1, 1), TimeOfDay(11, 52, 33)));
testDT(DateTime(Date(1, 1, 1), TimeOfDay(13, 52, 33)), -1_052_782, DateTime(Date(1, 1, 1), TimeOfDay(13, 30, 33)));
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(!__traits(compiles, cdt.roll!"minutes"(4)));
static assert(!__traits(compiles, idt.roll!"minutes"(4)));
}
}
//Test roll!"seconds"().
unittest
{
version(testStdDateTime)
{
static void testDT(DateTime orig, int seconds, in DateTime expected, size_t line = __LINE__)
{
orig.roll!"seconds"(seconds);
_assertPred!"=="(orig, expected, "", __FILE__, line);
}
//Test A.D.
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 0, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 1, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 2, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 35)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 3, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 36)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 4, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 37)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 5, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 38)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 10, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 43)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 15, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 48)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 26, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 59)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 27, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 0)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 30, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 3)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 59, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 32)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 60, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 61, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 1766, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 59)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 1767, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 0)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 1768, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 1)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 2007, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 0)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 3599, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 32)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 3600, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 3601, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), 7200, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -1, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 32)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -2, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 31)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -3, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 30)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -4, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 29)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -5, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 28)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -10, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 23)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -15, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 18)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -33, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 0)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -34, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 59)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -35, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 58)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -59, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -60, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), -61, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 32)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 0)), 1, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 1)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 0)), 0, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 0)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 0)), -1, DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 59)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 0)), 1, DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 1)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 0)), 0, DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 0)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 0)), -1, DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 59)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 0)), 1, DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 1)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 0)), 0, DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 0)));
testDT(DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 0)), -1, DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 59)));
testDT(DateTime(Date(1999, 7, 5), TimeOfDay(23, 59, 59)), 1, DateTime(Date(1999, 7, 5), TimeOfDay(23, 59, 0)));
testDT(DateTime(Date(1999, 7, 5), TimeOfDay(23, 59, 59)), 0, DateTime(Date(1999, 7, 5), TimeOfDay(23, 59, 59)));
testDT(DateTime(Date(1999, 7, 5), TimeOfDay(23, 59, 59)), -1, DateTime(Date(1999, 7, 5), TimeOfDay(23, 59, 58)));
testDT(DateTime(Date(1998, 12, 31), TimeOfDay(23, 59, 59)), 1, DateTime(Date(1998, 12, 31), TimeOfDay(23, 59, 0)));
testDT(DateTime(Date(1998, 12, 31), TimeOfDay(23, 59, 59)), 0, DateTime(Date(1998, 12, 31), TimeOfDay(23, 59, 59)));
testDT(DateTime(Date(1998, 12, 31), TimeOfDay(23, 59, 59)), -1, DateTime(Date(1998, 12, 31), TimeOfDay(23, 59, 58)));
//Test B.C.
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 0, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 1, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 34)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 2, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 35)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 3, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 36)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 4, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 37)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 5, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 38)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 10, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 43)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 15, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 48)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 26, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 59)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 27, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 0)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 30, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 3)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 59, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 32)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 60, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 61, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 34)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 1766, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 59)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 1767, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 0)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 1768, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 1)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 2007, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 0)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 3599, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 32)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 3600, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 3601, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 34)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), 7200, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -1, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 32)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -2, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 31)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -3, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 30)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -4, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 29)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -5, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 28)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -10, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 23)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -15, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 18)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -33, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 0)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -34, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 59)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -35, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 58)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -59, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 34)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -60, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)), -61, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 32)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 0)), 1, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 1)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 0)), 0, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 0)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 0)), -1, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 59)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 0, 0)), 1, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 0, 1)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 0, 0)), 0, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 0, 0)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 0, 0)), -1, DateTime(Date(-1999, 7, 6), TimeOfDay(12, 0, 59)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(0, 0, 0)), 1, DateTime(Date(-1999, 7, 6), TimeOfDay(0, 0, 1)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(0, 0, 0)), 0, DateTime(Date(-1999, 7, 6), TimeOfDay(0, 0, 0)));
testDT(DateTime(Date(-1999, 7, 6), TimeOfDay(0, 0, 0)), -1, DateTime(Date(-1999, 7, 6), TimeOfDay(0, 0, 59)));
testDT(DateTime(Date(-1999, 7, 5), TimeOfDay(23, 59, 59)), 1, DateTime(Date(-1999, 7, 5), TimeOfDay(23, 59, 0)));
testDT(DateTime(Date(-1999, 7, 5), TimeOfDay(23, 59, 59)), 0, DateTime(Date(-1999, 7, 5), TimeOfDay(23, 59, 59)));
testDT(DateTime(Date(-1999, 7, 5), TimeOfDay(23, 59, 59)), -1, DateTime(Date(-1999, 7, 5), TimeOfDay(23, 59, 58)));
testDT(DateTime(Date(-2000, 12, 31), TimeOfDay(23, 59, 59)), 1, DateTime(Date(-2000, 12, 31), TimeOfDay(23, 59, 0)));
testDT(DateTime(Date(-2000, 12, 31), TimeOfDay(23, 59, 59)), 0, DateTime(Date(-2000, 12, 31), TimeOfDay(23, 59, 59)));
testDT(DateTime(Date(-2000, 12, 31), TimeOfDay(23, 59, 59)), -1, DateTime(Date(-2000, 12, 31), TimeOfDay(23, 59, 58)));
//Test Both
testDT(DateTime(Date(1, 1, 1), TimeOfDay(0, 0, 0)), -1, DateTime(Date(1, 1, 1), TimeOfDay(0, 0, 59)));
testDT(DateTime(Date(0, 12, 31), TimeOfDay(23, 59, 59)), 1, DateTime(Date(0, 12, 31), TimeOfDay(23, 59, 0)));
testDT(DateTime(Date(0, 1, 1), TimeOfDay(0, 0, 0)), -1, DateTime(Date(0, 1, 1), TimeOfDay(0, 0, 59)));
testDT(DateTime(Date(-1, 12, 31), TimeOfDay(23, 59, 59)), 1, DateTime(Date(-1, 12, 31), TimeOfDay(23, 59, 0)));
testDT(DateTime(Date(-1, 1, 1), TimeOfDay(11, 30, 33)), 63_165_600L, DateTime(Date(-1, 1, 1), TimeOfDay(11, 30, 33)));
testDT(DateTime(Date(1, 1, 1), TimeOfDay(13, 30, 33)), -63_165_600L, DateTime(Date(1, 1, 1), TimeOfDay(13, 30, 33)));
testDT(DateTime(Date(-1, 1, 1), TimeOfDay(11, 30, 33)), 63_165_617L, DateTime(Date(-1, 1, 1), TimeOfDay(11, 30, 50)));
testDT(DateTime(Date(1, 1, 1), TimeOfDay(13, 30, 50)), -63_165_617L, DateTime(Date(1, 1, 1), TimeOfDay(13, 30, 33)));
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(!__traits(compiles, cdt.roll!"seconds"(4)));
static assert(!__traits(compiles, idt.roll!"seconds"(4)));
}
}
/++
Gives the result of adding or subtracting a duration from this
$(D DateTime).
The legal types of arithmetic for $(D DateTime) using this operator are
$(BOOKTABLE,
$(TR $(TD DateTime) $(TD +) $(TD duration) $(TD -->) $(TD DateTime))
$(TR $(TD DateTime) $(TD -) $(TD duration) $(TD -->) $(TD DateTime))
)
Params:
duration = The duration to add to or subtract from this
$(D DateTime).
+/
DateTime opBinary(string op, D)(in D duration) const pure nothrow
if((op == "+" || op == "-") &&
(is(Unqual!D == Duration) ||
is(Unqual!D == TickDuration)))
{
DateTime retval = this;
static if(is(Unqual!D == Duration))
immutable hnsecs = duration.total!"hnsecs";
else static if(is(Unqual!D == TickDuration))
immutable hnsecs = duration.hnsecs;
//Ideally, this would just be
//return retval.addSeconds(convert!("hnsecs", "seconds")(unaryFun!(op ~ "a")(hnsecs)));
//But there isn't currently a pure version of unaryFun!().
static if(op == "+")
immutable signedHNSecs = hnsecs;
else static if(op == "-")
immutable signedHNSecs = -hnsecs;
else
static assert(0);
return retval.addSeconds(convert!("hnsecs", "seconds")(signedHNSecs));
}
unittest
{
version(testStdDateTime)
{
auto dt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
_assertPred!"=="(dt + dur!"weeks"(7), DateTime(Date(1999, 8, 24), TimeOfDay(12, 30, 33)));
_assertPred!"=="(dt + dur!"weeks"(-7), DateTime(Date(1999, 5, 18), TimeOfDay(12, 30, 33)));
_assertPred!"=="(dt + dur!"days"(7), DateTime(Date(1999, 7, 13), TimeOfDay(12, 30, 33)));
_assertPred!"=="(dt + dur!"days"(-7), DateTime(Date(1999, 6, 29), TimeOfDay(12, 30, 33)));
_assertPred!"=="(dt + dur!"hours"(7), DateTime(Date(1999, 7, 6), TimeOfDay(19, 30, 33)));
_assertPred!"=="(dt + dur!"hours"(-7), DateTime(Date(1999, 7, 6), TimeOfDay(5, 30, 33)));
_assertPred!"=="(dt + dur!"minutes"(7), DateTime(Date(1999, 7, 6), TimeOfDay(12, 37, 33)));
_assertPred!"=="(dt + dur!"minutes"(-7), DateTime(Date(1999, 7, 6), TimeOfDay(12, 23, 33)));
_assertPred!"=="(dt + dur!"seconds"(7), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
_assertPred!"=="(dt + dur!"seconds"(-7), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
_assertPred!"=="(dt + dur!"msecs"(7_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
_assertPred!"=="(dt + dur!"msecs"(-7_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
_assertPred!"=="(dt + dur!"usecs"(7_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
_assertPred!"=="(dt + dur!"usecs"(-7_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
_assertPred!"=="(dt + dur!"hnsecs"(70_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
_assertPred!"=="(dt + dur!"hnsecs"(-70_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
//This probably only runs in cases where gettimeofday() is used, but it's
//hard to do this test correctly with variable ticksPerSec.
if(TickDuration.ticksPerSec == 1_000_000)
{
_assertPred!"=="(dt + TickDuration.from!"usecs"(7_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
_assertPred!"=="(dt + TickDuration.from!"usecs"(-7_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
}
_assertPred!"=="(dt - dur!"weeks"(-7), DateTime(Date(1999, 8, 24), TimeOfDay(12, 30, 33)));
_assertPred!"=="(dt - dur!"weeks"(7), DateTime(Date(1999, 5, 18), TimeOfDay(12, 30, 33)));
_assertPred!"=="(dt - dur!"days"(-7), DateTime(Date(1999, 7, 13), TimeOfDay(12, 30, 33)));
_assertPred!"=="(dt - dur!"days"(7), DateTime(Date(1999, 6, 29), TimeOfDay(12, 30, 33)));
_assertPred!"=="(dt - dur!"hours"(-7), DateTime(Date(1999, 7, 6), TimeOfDay(19, 30, 33)));
_assertPred!"=="(dt - dur!"hours"(7), DateTime(Date(1999, 7, 6), TimeOfDay(5, 30, 33)));
_assertPred!"=="(dt - dur!"minutes"(-7), DateTime(Date(1999, 7, 6), TimeOfDay(12, 37, 33)));
_assertPred!"=="(dt - dur!"minutes"(7), DateTime(Date(1999, 7, 6), TimeOfDay(12, 23, 33)));
_assertPred!"=="(dt - dur!"seconds"(-7), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
_assertPred!"=="(dt - dur!"seconds"(7), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
_assertPred!"=="(dt - dur!"msecs"(-7_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
_assertPred!"=="(dt - dur!"msecs"(7_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
_assertPred!"=="(dt - dur!"usecs"(-7_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
_assertPred!"=="(dt - dur!"usecs"(7_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
_assertPred!"=="(dt - dur!"hnsecs"(-70_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
_assertPred!"=="(dt - dur!"hnsecs"(70_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
//This probably only runs in cases where gettimeofday() is used, but it's
//hard to do this test correctly with variable ticksPerSec.
if(TickDuration.ticksPerSec == 1_000_000)
{
_assertPred!"=="(dt - TickDuration.from!"usecs"(-7_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
_assertPred!"=="(dt - TickDuration.from!"usecs"(7_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
}
auto duration = dur!"seconds"(12);
const cdt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
immutable idt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
static assert(__traits(compiles, cdt + duration));
static assert(__traits(compiles, idt + duration));
static assert(__traits(compiles, cdt - duration));
static assert(__traits(compiles, idt - duration));
}
}
/++
Gives the result of adding or subtracting a duration from this
$(D DateTime), as well as assigning the result to this $(D DateTime).
The legal types of arithmetic for $(D DateTime) using this operator are
$(BOOKTABLE,
$(TR $(TD DateTime) $(TD +) $(TD duration) $(TD -->) $(TD DateTime))
$(TR $(TD DateTime) $(TD -) $(TD duration) $(TD -->) $(TD DateTime))
)
Params:
duration = The duration to add to or subtract from this
$(D DateTime).
+/
/+ref+/ DateTime opOpAssign(string op, D)(in D duration) pure nothrow
if((op == "+" || op == "-") &&
(is(Unqual!D == Duration) ||
is(Unqual!D == TickDuration)))
{
DateTime retval = this;
static if(is(Unqual!D == Duration))
immutable hnsecs = duration.total!"hnsecs";
else static if(is(Unqual!D == TickDuration))
immutable hnsecs = duration.hnsecs;
//Ideally, this would just be
//return addSeconds(convert!("hnsecs", "seconds")(unaryFun!(op ~ "a")(hnsecs)));
//But there isn't currently a pure version of unaryFun!().
static if(op == "+")
immutable signedHNSecs = hnsecs;
else static if(op == "-")
immutable signedHNSecs = -hnsecs;
else
static assert(0);
return addSeconds(convert!("hnsecs", "seconds")(signedHNSecs));
}
unittest
{
version(testStdDateTime)
{
_assertPred!"+="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"weeks"(7), DateTime(Date(1999, 8, 24), TimeOfDay(12, 30, 33)));
_assertPred!"+="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"weeks"(-7), DateTime(Date(1999, 5, 18), TimeOfDay(12, 30, 33)));
_assertPred!"+="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"days"(7), DateTime(Date(1999, 7, 13), TimeOfDay(12, 30, 33)));
_assertPred!"+="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"days"(-7), DateTime(Date(1999, 6, 29), TimeOfDay(12, 30, 33)));
_assertPred!"+="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"hours"(7), DateTime(Date(1999, 7, 6), TimeOfDay(19, 30, 33)));
_assertPred!"+="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"hours"(-7), DateTime(Date(1999, 7, 6), TimeOfDay(5, 30, 33)));
_assertPred!"+="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"minutes"(7), DateTime(Date(1999, 7, 6), TimeOfDay(12, 37, 33)));
_assertPred!"+="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"minutes"(-7), DateTime(Date(1999, 7, 6), TimeOfDay(12, 23, 33)));
_assertPred!"+="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"seconds"(7), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
_assertPred!"+="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"seconds"(-7), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
_assertPred!"+="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"msecs"(7_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
_assertPred!"+="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"msecs"(-7_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
_assertPred!"+="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"usecs"(7_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
_assertPred!"+="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"usecs"(-7_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
_assertPred!"+="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"hnsecs"(70_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
_assertPred!"+="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"hnsecs"(-70_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
_assertPred!"-="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"weeks"(-7), DateTime(Date(1999, 8, 24), TimeOfDay(12, 30, 33)));
_assertPred!"-="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"weeks"(7), DateTime(Date(1999, 5, 18), TimeOfDay(12, 30, 33)));
_assertPred!"-="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"days"(-7), DateTime(Date(1999, 7, 13), TimeOfDay(12, 30, 33)));
_assertPred!"-="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"days"(7), DateTime(Date(1999, 6, 29), TimeOfDay(12, 30, 33)));
_assertPred!"-="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"hours"(-7), DateTime(Date(1999, 7, 6), TimeOfDay(19, 30, 33)));
_assertPred!"-="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"hours"(7), DateTime(Date(1999, 7, 6), TimeOfDay(5, 30, 33)));
_assertPred!"-="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"minutes"(-7), DateTime(Date(1999, 7, 6), TimeOfDay(12, 37, 33)));
_assertPred!"-="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"minutes"(7), DateTime(Date(1999, 7, 6), TimeOfDay(12, 23, 33)));
_assertPred!"-="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"seconds"(-7), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
_assertPred!"-="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"seconds"(7), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
_assertPred!"-="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"msecs"(-7_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
_assertPred!"-="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"msecs"(7_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
_assertPred!"-="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"usecs"(-7_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
_assertPred!"-="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"usecs"(7_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
_assertPred!"-="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"hnsecs"(-70_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
_assertPred!"-="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)), dur!"hnsecs"(70_000_000), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
auto duration = dur!"seconds"(12);
const cdt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
immutable idt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
static assert(!__traits(compiles, cdt += duration));
static assert(!__traits(compiles, idt += duration));
static assert(!__traits(compiles, cdt -= duration));
static assert(!__traits(compiles, idt -= duration));
}
}
/++
Gives the difference between two $(D DateTime)s.
The legal types of arithmetic for $(D DateTime) using this operator are
$(BOOKTABLE,
$(TR $(TD DateTime) $(TD -) $(TD DateTime) $(TD -->) $(TD duration))
)
+/
Duration opBinary(string op)(in DateTime rhs) const pure nothrow
if(op == "-")
{
immutable dateResult = _date - rhs.date;
immutable todResult = _tod - rhs._tod;
return dur!"hnsecs"(dateResult.total!"hnsecs" + todResult.total!"hnsecs");
}
unittest
{
version(testStdDateTime)
{
auto dt = DateTime(1999, 7, 6, 12, 30, 33);
_assertPred!"=="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) -
DateTime(Date(1998, 7, 6), TimeOfDay(12, 30, 33)),
dur!"seconds"(31_536_000));
_assertPred!"=="(DateTime(Date(1998, 7, 6), TimeOfDay(12, 30, 33)) -
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)),
dur!"seconds"(-31_536_000));
_assertPred!"=="(DateTime(Date(1999, 8, 6), TimeOfDay(12, 30, 33)) -
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)),
dur!"seconds"(26_78_400));
_assertPred!"=="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) -
DateTime(Date(1999, 8, 6), TimeOfDay(12, 30, 33)),
dur!"seconds"(-26_78_400));
_assertPred!"=="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) -
DateTime(Date(1999, 7, 5), TimeOfDay(12, 30, 33)),
dur!"seconds"(86_400));
_assertPred!"=="(DateTime(Date(1999, 7, 5), TimeOfDay(12, 30, 33)) -
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)),
dur!"seconds"(-86_400));
_assertPred!"=="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) -
DateTime(Date(1999, 7, 6), TimeOfDay(11, 30, 33)),
dur!"seconds"(3600));
_assertPred!"=="(DateTime(Date(1999, 7, 6), TimeOfDay(11, 30, 33)) -
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)),
dur!"seconds"(-3600));
_assertPred!"=="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)) -
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)),
dur!"seconds"(60));
_assertPred!"=="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) -
DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)),
dur!"seconds"(-60));
_assertPred!"=="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)) -
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)),
dur!"seconds"(1));
_assertPred!"=="(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) -
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)),
dur!"seconds"(-1));
_assertPred!"=="(DateTime(1, 1, 1, 12, 30, 33) - DateTime(1, 1, 1, 0, 0, 0), dur!"seconds"(45033));
_assertPred!"=="(DateTime(1, 1, 1, 0, 0, 0) - DateTime(1, 1, 1, 12, 30, 33), dur!"seconds"(-45033));
_assertPred!"=="(DateTime(0, 12, 31, 12, 30, 33) - DateTime(1, 1, 1, 0, 0, 0), dur!"seconds"(-41367));
_assertPred!"=="(DateTime(1, 1, 1, 0, 0, 0) - DateTime(0, 12, 31, 12, 30, 33), dur!"seconds"(41367));
const cdt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
immutable idt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
static assert(__traits(compiles, dt - dt));
static assert(__traits(compiles, cdt - dt));
static assert(__traits(compiles, idt - dt));
static assert(__traits(compiles, dt - cdt));
static assert(__traits(compiles, cdt - cdt));
static assert(__traits(compiles, idt - cdt));
static assert(__traits(compiles, dt - idt));
static assert(__traits(compiles, cdt - idt));
static assert(__traits(compiles, idt - idt));
}
}
/++
Returns the difference between the two $(D DateTime)s in months.
You can get the difference in years by subtracting the year property
of two $(D DateTime)s, and you can get the difference in days or weeks
by subtracting the $(D DateTime)s themselves and using the Duration that
results, but because you cannot convert between months and smaller units
without a specific date (which $(D Duration)s don't have), you cannot
get the difference in months without doing some math using both the year
and month properties, so this is a convenience function for getting the
difference in months.
Note that the number of days in the months or how far into the month
either date is is irrelevant. It is the difference in the month property
combined with the difference in years * 12. So, for instance,
December 31st and January 1st are one month apart just as December 1st
and January 31st are one month apart.
Params:
rhs = The $(D DateTime) to subtract from this one.
Examples:
--------------------
assert(DateTime(1999, 2, 1, 12, 2, 3).diffMonths(
DateTime(1999, 1, 31, 23, 59, 59)) == 1);
assert(DateTime(1999, 1, 31, 0, 0, 0).diffMonths(
DateTime(1999, 2, 1, 12, 3, 42)) == -1);
assert(DateTime(1999, 3, 1, 5, 30, 0).diffMonths(
DateTime(1999, 1, 1, 2, 4, 7)) == 2);
assert(DateTime(1999, 1, 1, 7, 2, 4).diffMonths(
DateTime(1999, 3, 31, 0, 30, 58)) == -2);
--------------------
+/
int diffMonths(in DateTime rhs) const pure nothrow
{
return _date.diffMonths(rhs._date);
}
unittest
{
version(testStdDateTime)
{
auto dt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
const cdt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
immutable idt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
static assert(__traits(compiles, dt.diffMonths(dt)));
static assert(__traits(compiles, cdt.diffMonths(dt)));
static assert(__traits(compiles, idt.diffMonths(dt)));
static assert(__traits(compiles, dt.diffMonths(cdt)));
static assert(__traits(compiles, cdt.diffMonths(cdt)));
static assert(__traits(compiles, idt.diffMonths(cdt)));
static assert(__traits(compiles, dt.diffMonths(idt)));
static assert(__traits(compiles, cdt.diffMonths(idt)));
static assert(__traits(compiles, idt.diffMonths(idt)));
//Verify Examples.
assert(DateTime(1999, 2, 1, 12, 2, 3).diffMonths(DateTime(1999, 1, 31, 23, 59, 59)) == 1);
assert(DateTime(1999, 1, 31, 0, 0, 0).diffMonths(DateTime(1999, 2, 1, 12, 3, 42)) == -1);
assert(DateTime(1999, 3, 1, 5, 30, 0).diffMonths(DateTime(1999, 1, 1, 2, 4, 7)) == 2);
assert(DateTime(1999, 1, 1, 7, 2, 4).diffMonths(DateTime(1999, 3, 31, 0, 30, 58)) == -2);
}
}
/++
Whether this $(D DateTime) is in a leap year.
+/
@property bool isLeapYear() const pure nothrow
{
return _date.isLeapYear;
}
unittest
{
version(testStdDateTime)
{
auto dt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
const cdt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
immutable idt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
static assert(__traits(compiles, dt.isLeapYear));
static assert(__traits(compiles, cdt.isLeapYear));
static assert(__traits(compiles, idt.isLeapYear));
}
}
/++
Day of the week this $(D DateTime) is on.
+/
@property DayOfWeek dayOfWeek() const pure nothrow
{
return _date.dayOfWeek;
}
unittest
{
version(testStdDateTime)
{
auto dt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
const cdt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
immutable idt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
static assert(__traits(compiles, dt.dayOfWeek));
static assert(__traits(compiles, cdt.dayOfWeek));
static assert(__traits(compiles, idt.dayOfWeek));
}
}
/++
Day of the year this $(D DateTime) is on.
Examples:
--------------------
assert(DateTime(Date(1999, 1, 1), TimeOfDay(12, 22, 7)).dayOfYear == 1);
assert(DateTime(Date(1999, 12, 31), TimeOfDay(7, 2, 59)).dayOfYear == 365);
assert(DateTime(Date(2000, 12, 31), TimeOfDay(21, 20, 0)).dayOfYear == 366);
--------------------
+/
@property ushort dayOfYear() const pure nothrow
{
return _date.dayOfYear;
}
unittest
{
version(testStdDateTime)
{
auto dt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
const cdt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
immutable idt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
static assert(__traits(compiles, dt.dayOfYear));
static assert(__traits(compiles, cdt.dayOfYear));
static assert(__traits(compiles, idt.dayOfYear));
//Verify Examples.
assert(DateTime(Date(1999, 1, 1), TimeOfDay(12, 22, 7)).dayOfYear == 1);
assert(DateTime(Date(1999, 12, 31), TimeOfDay(7, 2, 59)).dayOfYear == 365);
assert(DateTime(Date(2000, 12, 31), TimeOfDay(21, 20, 0)).dayOfYear == 366);
}
}
/++
Day of the year.
Params:
day = The day of the year to set which day of the year this
$(D DateTime) is on.
+/
@property void dayOfYear(int day) pure
{
_date.dayOfYear = day;
}
unittest
{
version(testStdDateTime)
{
auto dt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
const cdt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
immutable idt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
static assert(__traits(compiles, dt.dayOfYear = 12));
static assert(!__traits(compiles, cdt.dayOfYear = 12));
static assert(!__traits(compiles, idt.dayOfYear = 12));
}
}
/++
The Xth day of the Gregorian Calendar that this $(D DateTime) is on.
Examples:
--------------------
assert(DateTime(Date(1, 1, 1), TimeOfDay(0, 0, 0)).dayOfGregorianCal ==
1);
assert(DateTime(Date(1, 12, 31), TimeOfDay(23, 59, 59)).dayOfGregorianCal ==
365);
assert(DateTime(Date(2, 1, 1), TimeOfDay(2, 2, 2)).dayOfGregorianCal ==
366);
assert(DateTime(Date(0, 12, 31), TimeOfDay(7, 7, 7)).dayOfGregorianCal ==
0);
assert(DateTime(Date(0, 1, 1), TimeOfDay(19, 30, 0)).dayOfGregorianCal ==
-365);
assert(DateTime(Date(-1, 12, 31), TimeOfDay(4, 7, 0)).dayOfGregorianCal ==
-366);
assert(DateTime(Date(2000, 1, 1), TimeOfDay(9, 30, 20)).dayOfGregorianCal ==
730_120);
assert(DateTime(Date(2010, 12, 31), TimeOfDay(15, 45, 50)).dayOfGregorianCal ==
734_137);
--------------------
+/
@property int dayOfGregorianCal() const pure nothrow
{
return _date.dayOfGregorianCal;
}
unittest
{
version(testStdDateTime)
{
const cdt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
immutable idt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
static assert(__traits(compiles, cdt.dayOfGregorianCal));
static assert(__traits(compiles, idt.dayOfGregorianCal));
//Verify Examples.
assert(DateTime(Date(1, 1, 1), TimeOfDay(0, 0, 0)).dayOfGregorianCal == 1);
assert(DateTime(Date(1, 12, 31), TimeOfDay(23, 59, 59)).dayOfGregorianCal == 365);
assert(DateTime(Date(2, 1, 1), TimeOfDay(2, 2, 2)).dayOfGregorianCal == 366);
assert(DateTime(Date(0, 12, 31), TimeOfDay(7, 7, 7)).dayOfGregorianCal == 0);
assert(DateTime(Date(0, 1, 1), TimeOfDay(19, 30, 0)).dayOfGregorianCal == -365);
assert(DateTime(Date(-1, 12, 31), TimeOfDay(4, 7, 0)).dayOfGregorianCal == -366);
assert(DateTime(Date(2000, 1, 1), TimeOfDay(9, 30, 20)).dayOfGregorianCal == 730_120);
assert(DateTime(Date(2010, 12, 31), TimeOfDay(15, 45, 50)).dayOfGregorianCal == 734_137);
}
}
/++
The Xth day of the Gregorian Calendar that this $(D DateTime) is on.
Setting this property does not affect the time portion of
$(D DateTime).
Params:
days = The day of the Gregorian Calendar to set this $(D DateTime)
to.
Examples:
--------------------
auto dt = DateTime(Date.init, TimeOfDay(12, 0, 0));
dt.dayOfGregorianCal = 1;
assert(dt == DateTime(Date(1, 1, 1), TimeOfDay(12, 0, 0)));
dt.dayOfGregorianCal = 365;
assert(dt == DateTime(Date(1, 12, 31), TimeOfDay(12, 0, 0)));
dt.dayOfGregorianCal = 366;
assert(dt == DateTime(Date(2, 1, 1), TimeOfDay(12, 0, 0)));
dt.dayOfGregorianCal = 0;
assert(dt == DateTime(Date(0, 12, 31), TimeOfDay(12, 0, 0)));
dt.dayOfGregorianCal = -365;
assert(dt == DateTime(Date(-0, 1, 1), TimeOfDay(12, 0, 0)));
dt.dayOfGregorianCal = -366;
assert(dt == DateTime(Date(-1, 12, 31), TimeOfDay(12, 0, 0)));
dt.dayOfGregorianCal = 730_120;
assert(dt == DateTime(Date(2000, 1, 1), TimeOfDay(12, 0, 0)));
dt.dayOfGregorianCal = 734_137;
assert(dt == DateTime(Date(2010, 12, 31), TimeOfDay(12, 0, 0)));
--------------------
+/
@property void dayOfGregorianCal(int days) pure nothrow
{
_date.dayOfGregorianCal = days;
}
unittest
{
version(testStdDateTime)
{
const cdt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
immutable idt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
static assert(!__traits(compiles, cdt.dayOfGregorianCal = 7));
static assert(!__traits(compiles, idt.dayOfGregorianCal = 7));
//Verify Examples.
auto dt = DateTime(Date.init, TimeOfDay(12, 0, 0));
dt.dayOfGregorianCal = 1;
assert(dt == DateTime(Date(1, 1, 1), TimeOfDay(12, 0, 0)));
dt.dayOfGregorianCal = 365;
assert(dt == DateTime(Date(1, 12, 31), TimeOfDay(12, 0, 0)));
dt.dayOfGregorianCal = 366;
assert(dt == DateTime(Date(2, 1, 1), TimeOfDay(12, 0, 0)));
dt.dayOfGregorianCal = 0;
assert(dt == DateTime(Date(0, 12, 31), TimeOfDay(12, 0, 0)));
dt.dayOfGregorianCal = -365;
assert(dt == DateTime(Date(-0, 1, 1), TimeOfDay(12, 0, 0)));
dt.dayOfGregorianCal = -366;
assert(dt == DateTime(Date(-1, 12, 31), TimeOfDay(12, 0, 0)));
dt.dayOfGregorianCal = 730_120;
assert(dt == DateTime(Date(2000, 1, 1), TimeOfDay(12, 0, 0)));
dt.dayOfGregorianCal = 734_137;
assert(dt == DateTime(Date(2010, 12, 31), TimeOfDay(12, 0, 0)));
}
}
/++
The ISO 8601 week of the year that this $(D DateTime) is in.
See_Also:
$(WEB en.wikipedia.org/wiki/ISO_week_date, ISO Week Date)
+/
@property ubyte isoWeek() const pure nothrow
{
return _date.isoWeek;
}
unittest
{
version(testStdDateTime)
{
auto dt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
const cdt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
immutable idt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
static assert(__traits(compiles, dt.isoWeek));
static assert(__traits(compiles, cdt.isoWeek));
static assert(__traits(compiles, idt.isoWeek));
}
}
/++
$(D DateTime) for the last day in the month that this $(D DateTime) is
in. The time portion of endOfMonth is always 23:59:59.
Examples:
--------------------
assert(DateTime(Date(1999, 1, 6), TimeOfDay(0, 0, 0)).endOfMonth ==
DateTime(Date(1999, 1, 31), TimeOfDay(23, 59, 59)));
assert(DateTime(Date(1999, 2, 7), TimeOfDay(19, 30, 0)).endOfMonth ==
DateTime(Date(1999, 2, 28), TimeOfDay(23, 59, 59)));
assert(DateTime(Date(2000, 2, 7), TimeOfDay(5, 12, 27)).endOfMonth ==
DateTime(Date(2000, 2, 29), TimeOfDay(23, 59, 59)));
assert(DateTime(Date(2000, 6, 4), TimeOfDay(12, 22, 9)).endOfMonth ==
DateTime(Date(2000, 6, 30), TimeOfDay(23, 59, 59)));
--------------------
+/
@property DateTime endOfMonth() const pure nothrow
{
try
return DateTime(_date.endOfMonth, TimeOfDay(23, 59, 59));
catch(Exception e)
assert(0, "DateTime constructor threw.");
}
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(DateTime(1999, 1, 1, 0, 13, 26).endOfMonth, DateTime(1999, 1, 31, 23, 59, 59));
_assertPred!"=="(DateTime(1999, 2, 1, 1, 14, 27).endOfMonth, DateTime(1999, 2, 28, 23, 59, 59));
_assertPred!"=="(DateTime(2000, 2, 1, 2, 15, 28).endOfMonth, DateTime(2000, 2, 29, 23, 59, 59));
_assertPred!"=="(DateTime(1999, 3, 1, 3, 16, 29).endOfMonth, DateTime(1999, 3, 31, 23, 59, 59));
_assertPred!"=="(DateTime(1999, 4, 1, 4, 17, 30).endOfMonth, DateTime(1999, 4, 30, 23, 59, 59));
_assertPred!"=="(DateTime(1999, 5, 1, 5, 18, 31).endOfMonth, DateTime(1999, 5, 31, 23, 59, 59));
_assertPred!"=="(DateTime(1999, 6, 1, 6, 19, 32).endOfMonth, DateTime(1999, 6, 30, 23, 59, 59));
_assertPred!"=="(DateTime(1999, 7, 1, 7, 20, 33).endOfMonth, DateTime(1999, 7, 31, 23, 59, 59));
_assertPred!"=="(DateTime(1999, 8, 1, 8, 21, 34).endOfMonth, DateTime(1999, 8, 31, 23, 59, 59));
_assertPred!"=="(DateTime(1999, 9, 1, 9, 22, 35).endOfMonth, DateTime(1999, 9, 30, 23, 59, 59));
_assertPred!"=="(DateTime(1999, 10, 1, 10, 23, 36).endOfMonth, DateTime(1999, 10, 31, 23, 59, 59));
_assertPred!"=="(DateTime(1999, 11, 1, 11, 24, 37).endOfMonth, DateTime(1999, 11, 30, 23, 59, 59));
_assertPred!"=="(DateTime(1999, 12, 1, 12, 25, 38).endOfMonth, DateTime(1999, 12, 31, 23, 59, 59));
//Test B.C.
_assertPred!"=="(DateTime(-1999, 1, 1, 0, 13, 26).endOfMonth, DateTime(-1999, 1, 31, 23, 59, 59));
_assertPred!"=="(DateTime(-1999, 2, 1, 1, 14, 27).endOfMonth, DateTime(-1999, 2, 28, 23, 59, 59));
_assertPred!"=="(DateTime(-2000, 2, 1, 2, 15, 28).endOfMonth, DateTime(-2000, 2, 29, 23, 59, 59));
_assertPred!"=="(DateTime(-1999, 3, 1, 3, 16, 29).endOfMonth, DateTime(-1999, 3, 31, 23, 59, 59));
_assertPred!"=="(DateTime(-1999, 4, 1, 4, 17, 30).endOfMonth, DateTime(-1999, 4, 30, 23, 59, 59));
_assertPred!"=="(DateTime(-1999, 5, 1, 5, 18, 31).endOfMonth, DateTime(-1999, 5, 31, 23, 59, 59));
_assertPred!"=="(DateTime(-1999, 6, 1, 6, 19, 32).endOfMonth, DateTime(-1999, 6, 30, 23, 59, 59));
_assertPred!"=="(DateTime(-1999, 7, 1, 7, 20, 33).endOfMonth, DateTime(-1999, 7, 31, 23, 59, 59));
_assertPred!"=="(DateTime(-1999, 8, 1, 8, 21, 34).endOfMonth, DateTime(-1999, 8, 31, 23, 59, 59));
_assertPred!"=="(DateTime(-1999, 9, 1, 9, 22, 35).endOfMonth, DateTime(-1999, 9, 30, 23, 59, 59));
_assertPred!"=="(DateTime(-1999, 10, 1, 10, 23, 36).endOfMonth, DateTime(-1999, 10, 31, 23, 59, 59));
_assertPred!"=="(DateTime(-1999, 11, 1, 11, 24, 37).endOfMonth, DateTime(-1999, 11, 30, 23, 59, 59));
_assertPred!"=="(DateTime(-1999, 12, 1, 12, 25, 38).endOfMonth, DateTime(-1999, 12, 31, 23, 59, 59));
const cdt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
immutable idt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
static assert(__traits(compiles, cdt.endOfMonth));
static assert(__traits(compiles, idt.endOfMonth));
//Verify Examples.
assert(DateTime(Date(1999, 1, 6), TimeOfDay(0, 0, 0)).endOfMonth == DateTime(Date(1999, 1, 31), TimeOfDay(23, 59, 59)));
assert(DateTime(Date(1999, 2, 7), TimeOfDay(19, 30, 0)).endOfMonth == DateTime(Date(1999, 2, 28), TimeOfDay(23, 59, 59)));
assert(DateTime(Date(2000, 2, 7), TimeOfDay(5, 12, 27)).endOfMonth == DateTime(Date(2000, 2, 29), TimeOfDay(23, 59, 59)));
assert(DateTime(Date(2000, 6, 4), TimeOfDay(12, 22, 9)).endOfMonth == DateTime(Date(2000, 6, 30), TimeOfDay(23, 59, 59)));
}
}
/++
The last day in the month that this $(D DateTime) is in.
Examples:
--------------------
assert(DateTime(Date(1999, 1, 6), TimeOfDay(0, 0, 0)).daysInMonth == 31);
assert(DateTime(Date(1999, 2, 7), TimeOfDay(19, 30, 0)).daysInMonth == 28);
assert(DateTime(Date(2000, 2, 7), TimeOfDay(5, 12, 27)).daysInMonth == 29);
assert(DateTime(Date(2000, 6, 4), TimeOfDay(12, 22, 9)).daysInMonth == 30);
--------------------
+/
@property ubyte daysInMonth() const pure nothrow
{
return _date.daysInMonth;
}
/++
$(RED Scheduled for deprecation in January 2012.
Please use daysInMonth instead.)
+/
alias daysInMonth endofMonthDay;
unittest
{
version(testStdDateTime)
{
const cdt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
immutable idt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
static assert(__traits(compiles, cdt.daysInMonth));
static assert(__traits(compiles, idt.daysInMonth));
//Verify Examples.
assert(DateTime(Date(1999, 1, 6), TimeOfDay(0, 0, 0)).daysInMonth == 31);
assert(DateTime(Date(1999, 2, 7), TimeOfDay(19, 30, 0)).daysInMonth == 28);
assert(DateTime(Date(2000, 2, 7), TimeOfDay(5, 12, 27)).daysInMonth == 29);
assert(DateTime(Date(2000, 6, 4), TimeOfDay(12, 22, 9)).daysInMonth == 30);
}
}
/++
Whether the current year is a date in A.D.
Examples:
--------------------
assert(DateTime(Date(1, 1, 1), TimeOfDay(12, 7, 0)).isAD);
assert(DateTime(Date(2010, 12, 31), TimeOfDay(0, 0, 0)).isAD);
assert(!DateTime(Date(0, 12, 31), TimeOfDay(23, 59, 59)).isAD);
assert(!DateTime(Date(-2010, 1, 1), TimeOfDay(2, 2, 2)).isAD);
--------------------
+/
@property bool isAD() const pure nothrow
{
return _date.isAD;
}
unittest
{
version(testStdDateTime)
{
const cdt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
immutable idt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
static assert(__traits(compiles, cdt.isAD));
static assert(__traits(compiles, idt.isAD));
//Verify Examples.
assert(DateTime(Date(1, 1, 1), TimeOfDay(12, 7, 0)).isAD);
assert(DateTime(Date(2010, 12, 31), TimeOfDay(0, 0, 0)).isAD);
assert(!DateTime(Date(0, 12, 31), TimeOfDay(23, 59, 59)).isAD);
assert(!DateTime(Date(-2010, 1, 1), TimeOfDay(2, 2, 2)).isAD);
}
}
/++
The julian day for this $(D DateTime) at the given time. For example,
prior to noon, 1996-03-31 would be the julian day number 2_450_173, so
this function returns 2_450_173, while from noon onward, the julian
day number would be 2_450_174, so this function returns 2_450_174.
+/
@property long julianDay() const pure nothrow
{
if(_tod._hour < 12)
return _date.julianDay - 1;
else
return _date.julianDay;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(DateTime(Date(-4713, 11, 24), TimeOfDay(0, 0, 0)).julianDay, -1);
_assertPred!"=="(DateTime(Date(-4713, 11, 24), TimeOfDay(12, 0, 0)).julianDay, 0);
_assertPred!"=="(DateTime(Date(0, 12, 31), TimeOfDay(0, 0, 0)).julianDay, 1_721_424);
_assertPred!"=="(DateTime(Date(0, 12, 31), TimeOfDay(12, 0, 0)).julianDay, 1_721_425);
_assertPred!"=="(DateTime(Date(1, 1, 1), TimeOfDay(0, 0, 0)).julianDay, 1_721_425);
_assertPred!"=="(DateTime(Date(1, 1, 1), TimeOfDay(12, 0, 0)).julianDay, 1_721_426);
_assertPred!"=="(DateTime(Date(1582, 10, 15), TimeOfDay(0, 0, 0)).julianDay, 2_299_160);
_assertPred!"=="(DateTime(Date(1582, 10, 15), TimeOfDay(12, 0, 0)).julianDay, 2_299_161);
_assertPred!"=="(DateTime(Date(1858, 11, 17), TimeOfDay(0, 0, 0)).julianDay, 2_400_000);
_assertPred!"=="(DateTime(Date(1858, 11, 17), TimeOfDay(12, 0, 0)).julianDay, 2_400_001);
_assertPred!"=="(DateTime(Date(1982, 1, 4), TimeOfDay(0, 0, 0)).julianDay, 2_444_973);
_assertPred!"=="(DateTime(Date(1982, 1, 4), TimeOfDay(12, 0, 0)).julianDay, 2_444_974);
_assertPred!"=="(DateTime(Date(1996, 3, 31), TimeOfDay(0, 0, 0)).julianDay, 2_450_173);
_assertPred!"=="(DateTime(Date(1996, 3, 31), TimeOfDay(12, 0, 0)).julianDay, 2_450_174);
_assertPred!"=="(DateTime(Date(2010, 8, 24), TimeOfDay(0, 0, 0)).julianDay, 2_455_432);
_assertPred!"=="(DateTime(Date(2010, 8, 24), TimeOfDay(12, 0, 0)).julianDay, 2_455_433);
const cdt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
immutable idt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
static assert(__traits(compiles, cdt.julianDay));
static assert(__traits(compiles, idt.julianDay));
}
}
/++
The modified julian day for any time on this date (since, the modified
julian day changes at midnight).
+/
@property long modJulianDay() const pure nothrow
{
return _date.modJulianDay;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(DateTime(Date(1858, 11, 17), TimeOfDay(0, 0, 0)).modJulianDay, 0);
_assertPred!"=="(DateTime(Date(1858, 11, 17), TimeOfDay(12, 0, 0)).modJulianDay, 0);
_assertPred!"=="(DateTime(Date(2010, 8, 24), TimeOfDay(0, 0, 0)).modJulianDay, 55_432);
_assertPred!"=="(DateTime(Date(2010, 8, 24), TimeOfDay(12, 0, 0)).modJulianDay, 55_432);
const cdt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
immutable idt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
static assert(__traits(compiles, cdt.modJulianDay));
static assert(__traits(compiles, idt.modJulianDay));
}
}
/++
Converts this $(D DateTime) to a string with the format YYYYMMDDTHHMMSS.
Examples:
--------------------
assert(DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)).toISOString() ==
"20100704T070612");
assert(DateTime(Date(1998, 12, 25), TimeOfDay(2, 15, 0)).toISOString() ==
"19981225T021500");
assert(DateTime(Date(0, 1, 5), TimeOfDay(23, 9, 59)).toISOString() ==
"00000105T230959");
assert(DateTime(Date(-4, 1, 5), TimeOfDay(0, 0, 2)).toISOString() ==
"-00040105T000002");
--------------------
+/
string toISOString() const nothrow
{
try
return format("%sT%s", _date.toISOString(), _tod.toISOString());
catch(Exception e)
assert(0, "format() threw.");
}
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(DateTime(Date(9, 12, 4), TimeOfDay(0, 0, 0)).toISOString(), "00091204T000000");
_assertPred!"=="(DateTime(Date(99, 12, 4), TimeOfDay(5, 6, 12)).toISOString(), "00991204T050612");
_assertPred!"=="(DateTime(Date(999, 12, 4), TimeOfDay(13, 44, 59)).toISOString(), "09991204T134459");
_assertPred!"=="(DateTime(Date(9999, 7, 4), TimeOfDay(23, 59, 59)).toISOString(), "99990704T235959");
_assertPred!"=="(DateTime(Date(10000, 10, 20), TimeOfDay(1, 1, 1)).toISOString(), "+100001020T010101");
//Test B.C.
_assertPred!"=="(DateTime(Date(0, 12, 4), TimeOfDay(0, 12, 4)).toISOString(), "00001204T001204");
_assertPred!"=="(DateTime(Date(-9, 12, 4), TimeOfDay(0, 0, 0)).toISOString(), "-00091204T000000");
_assertPred!"=="(DateTime(Date(-99, 12, 4), TimeOfDay(5, 6, 12)).toISOString(), "-00991204T050612");
_assertPred!"=="(DateTime(Date(-999, 12, 4), TimeOfDay(13, 44, 59)).toISOString(), "-09991204T134459");
_assertPred!"=="(DateTime(Date(-9999, 7, 4), TimeOfDay(23, 59, 59)).toISOString(), "-99990704T235959");
_assertPred!"=="(DateTime(Date(-10000, 10, 20), TimeOfDay(1, 1, 1)).toISOString(), "-100001020T010101");
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(__traits(compiles, cdt.toISOString()));
static assert(__traits(compiles, idt.toISOString()));
//Verify Examples.
assert(DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)).toISOString() == "20100704T070612");
assert(DateTime(Date(1998, 12, 25), TimeOfDay(2, 15, 0)).toISOString() == "19981225T021500");
assert(DateTime(Date(0, 1, 5), TimeOfDay(23, 9, 59)).toISOString() == "00000105T230959");
assert(DateTime(Date(-4, 1, 5), TimeOfDay(0, 0, 2)).toISOString() == "-00040105T000002");
}
}
/++
Converts this $(D DateTime) to a string with the format
YYYY-MM-DDTHH:MM:SS.
Examples:
--------------------
assert(DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)).toISOExtString() ==
"2010-07-04T07:06:12");
assert(DateTime(Date(1998, 12, 25), TimeOfDay(2, 15, 0)).toISOExtString() ==
"1998-12-25T02:15:00");
assert(DateTime(Date(0, 1, 5), TimeOfDay(23, 9, 59)).toISOExtString() ==
"0000-01-05T23:09:59");
assert(DateTime(Date(-4, 1, 5), TimeOfDay(0, 0, 2)).toISOExtString() ==
"-0004-01-05T00:00:02");
--------------------
+/
string toISOExtString() const nothrow
{
try
return format("%sT%s", _date.toISOExtString(), _tod.toISOExtString());
catch(Exception e)
assert(0, "format() threw.");
}
/++
$(RED Scheduled for deprecation in November 2011.
Please use toISOExtString instead.)
+/
alias toISOExtString toISOExtendedString;
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(DateTime(Date(9, 12, 4), TimeOfDay(0, 0, 0)).toISOExtString(), "0009-12-04T00:00:00");
_assertPred!"=="(DateTime(Date(99, 12, 4), TimeOfDay(5, 6, 12)).toISOExtString(), "0099-12-04T05:06:12");
_assertPred!"=="(DateTime(Date(999, 12, 4), TimeOfDay(13, 44, 59)).toISOExtString(), "0999-12-04T13:44:59");
_assertPred!"=="(DateTime(Date(9999, 7, 4), TimeOfDay(23, 59, 59)).toISOExtString(), "9999-07-04T23:59:59");
_assertPred!"=="(DateTime(Date(10000, 10, 20), TimeOfDay(1, 1, 1)).toISOExtString(), "+10000-10-20T01:01:01");
//Test B.C.
_assertPred!"=="(DateTime(Date(0, 12, 4), TimeOfDay(0, 12, 4)).toISOExtString(), "0000-12-04T00:12:04");
_assertPred!"=="(DateTime(Date(-9, 12, 4), TimeOfDay(0, 0, 0)).toISOExtString(), "-0009-12-04T00:00:00");
_assertPred!"=="(DateTime(Date(-99, 12, 4), TimeOfDay(5, 6, 12)).toISOExtString(), "-0099-12-04T05:06:12");
_assertPred!"=="(DateTime(Date(-999, 12, 4), TimeOfDay(13, 44, 59)).toISOExtString(), "-0999-12-04T13:44:59");
_assertPred!"=="(DateTime(Date(-9999, 7, 4), TimeOfDay(23, 59, 59)).toISOExtString(), "-9999-07-04T23:59:59");
_assertPred!"=="(DateTime(Date(-10000, 10, 20), TimeOfDay(1, 1, 1)).toISOExtString(), "-10000-10-20T01:01:01");
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(__traits(compiles, cdt.toISOExtString()));
static assert(__traits(compiles, idt.toISOExtString()));
//Verify Examples.
assert(DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)).toISOExtString() == "2010-07-04T07:06:12");
assert(DateTime(Date(1998, 12, 25), TimeOfDay(2, 15, 0)).toISOExtString() == "1998-12-25T02:15:00");
assert(DateTime(Date(0, 1, 5), TimeOfDay(23, 9, 59)).toISOExtString() == "0000-01-05T23:09:59");
assert(DateTime(Date(-4, 1, 5), TimeOfDay(0, 0, 2)).toISOExtString() == "-0004-01-05T00:00:02");
}
}
/++
Converts this $(D DateTime) to a string with the format
YYYY-Mon-DD HH:MM:SS.
Examples:
--------------------
assert(DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)).toSimpleString() ==
"2010-Jul-04 07:06:12");
assert(DateTime(Date(1998, 12, 25), TimeOfDay(2, 15, 0)).toSimpleString() ==
"1998-Dec-25 02:15:00");
assert(DateTime(Date(0, 1, 5), TimeOfDay(23, 9, 59)).toSimpleString() ==
"0000-Jan-05 23:09:59");
assert(DateTime(Dte(-4, 1, 5), TimeOfDay(0, 0, 2)).toSimpleString() ==
"-0004-Jan-05 00:00:02");
--------------------
+/
string toSimpleString() const nothrow
{
try
return format("%s %s", _date.toSimpleString(), _tod.toString());
catch(Exception e)
assert(0, "format() threw.");
}
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(DateTime(Date(9, 12, 4), TimeOfDay(0, 0, 0)).toSimpleString(), "0009-Dec-04 00:00:00");
_assertPred!"=="(DateTime(Date(99, 12, 4), TimeOfDay(5, 6, 12)).toSimpleString(), "0099-Dec-04 05:06:12");
_assertPred!"=="(DateTime(Date(999, 12, 4), TimeOfDay(13, 44, 59)).toSimpleString(), "0999-Dec-04 13:44:59");
_assertPred!"=="(DateTime(Date(9999, 7, 4), TimeOfDay(23, 59, 59)).toSimpleString(), "9999-Jul-04 23:59:59");
_assertPred!"=="(DateTime(Date(10000, 10, 20), TimeOfDay(1, 1, 1)).toSimpleString(), "+10000-Oct-20 01:01:01");
//Test B.C.
_assertPred!"=="(DateTime(Date(0, 12, 4), TimeOfDay(0, 12, 4)).toSimpleString(), "0000-Dec-04 00:12:04");
_assertPred!"=="(DateTime(Date(-9, 12, 4), TimeOfDay(0, 0, 0)).toSimpleString(), "-0009-Dec-04 00:00:00");
_assertPred!"=="(DateTime(Date(-99, 12, 4), TimeOfDay(5, 6, 12)).toSimpleString(), "-0099-Dec-04 05:06:12");
_assertPred!"=="(DateTime(Date(-999, 12, 4), TimeOfDay(13, 44, 59)).toSimpleString(), "-0999-Dec-04 13:44:59");
_assertPred!"=="(DateTime(Date(-9999, 7, 4), TimeOfDay(23, 59, 59)).toSimpleString(), "-9999-Jul-04 23:59:59");
_assertPred!"=="(DateTime(Date(-10000, 10, 20), TimeOfDay(1, 1, 1)).toSimpleString(), "-10000-Oct-20 01:01:01");
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(__traits(compiles, cdt.toSimpleString()));
static assert(__traits(compiles, idt.toSimpleString()));
//Verify Examples.
assert(DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)).toSimpleString() == "2010-Jul-04 07:06:12");
assert(DateTime(Date(1998, 12, 25), TimeOfDay(2, 15, 0)).toSimpleString() == "1998-Dec-25 02:15:00");
assert(DateTime(Date(0, 1, 5), TimeOfDay(23, 9, 59)).toSimpleString() == "0000-Jan-05 23:09:59");
assert(DateTime(Date(-4, 1, 5), TimeOfDay(0, 0, 2)).toSimpleString() == "-0004-Jan-05 00:00:02");
}
}
/+
Converts this $(D DateTime) to a string.
+/
//Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
//have versions of toString() with extra modifiers, so we define one version
//with modifiers and one without.
string toString()
{
return toSimpleString();
}
/++
Converts this $(D DateTime) to a string.
+/
//Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
//have versions of toString() with extra modifiers, so we define one version
//with modifiers and one without.
string toString() const nothrow
{
return toSimpleString();
}
unittest
{
version(testStdDateTime)
{
auto dt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
const cdt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
immutable idt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
static assert(__traits(compiles, dt.toString()));
static assert(__traits(compiles, cdt.toString()));
static assert(__traits(compiles, idt.toString()));
}
}
/++
Creates a $(D DateTime) from a string with the format YYYYMMDDTHHMMSS.
Whitespace is stripped from the given string.
Params:
isoString = A string formatted in the ISO format for dates and times.
Throws:
$(D DateTimeException) if the given string is not in the ISO format
or if the resulting $(D DateTime) would not be valid.
Examples:
--------------------
assert(DateTime.fromISOString("20100704T070612") ==
DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)));
assert(DateTime.fromISOString("19981225T021500") ==
DateTime(Date(1998, 12, 25), TimeOfDay(2, 15, 0)));
assert(DateTime.fromISOString("00000105T230959") ==
DateTime(Date(0, 1, 5), TimeOfDay(23, 9, 59)));
assert(DateTime.fromISOString("-00040105T000002") ==
DateTime(Date(-4, 1, 5), TimeOfDay(0, 0, 2)));
assert(DateTime.fromISOString(" 20100704T070612 ") ==
DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)));
--------------------
+/
static DateTime fromISOString(S)(in S isoString)
if(isSomeString!S)
{
immutable dstr = to!dstring(strip(isoString));
enforce(dstr.length >= 15, new DateTimeException(format("Invalid ISO String: %s", isoString)));
auto t = dstr.stds_indexOf('T');
enforce(t != -1, new DateTimeException(format("Invalid ISO String: %s", isoString)));
immutable date = Date.fromISOString(dstr[0..t]);
immutable tod = TimeOfDay.fromISOString(dstr[t+1 .. $]);
return DateTime(date, tod);
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException(DateTime.fromISOString(""));
assertThrown!DateTimeException(DateTime.fromISOString("20100704000000"));
assertThrown!DateTimeException(DateTime.fromISOString("20100704 000000"));
assertThrown!DateTimeException(DateTime.fromISOString("20100704t000000"));
assertThrown!DateTimeException(DateTime.fromISOString("20100704T000000."));
assertThrown!DateTimeException(DateTime.fromISOString("20100704T000000.0"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-07-0400:00:00"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-07-04 00:00:00"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-07-04t00:00:00"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-07-04T00:00:00."));
assertThrown!DateTimeException(DateTime.fromISOString("2010-07-04T00:00:00.0"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-Jul-0400:00:00"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-Jul-04 00:00:00"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-Jul-04t00:00:00"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-Jul-04T00:00:00"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-Jul-04 00:00:00."));
assertThrown!DateTimeException(DateTime.fromISOString("2010-Jul-04 00:00:00.0"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-12-22T172201"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-Dec-22 17:22:01"));
_assertPred!"=="(DateTime.fromISOString("20101222T172201"), DateTime(Date(2010, 12, 22), TimeOfDay(17, 22, 01)));
_assertPred!"=="(DateTime.fromISOString("19990706T123033"), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!"=="(DateTime.fromISOString("-19990706T123033"), DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!"=="(DateTime.fromISOString("+019990706T123033"), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!"=="(DateTime.fromISOString("19990706T123033 "), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!"=="(DateTime.fromISOString(" 19990706T123033"), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!"=="(DateTime.fromISOString(" 19990706T123033 "), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
//Verify Examples.
assert(DateTime.fromISOString("20100704T070612") == DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)));
assert(DateTime.fromISOString("19981225T021500") == DateTime(Date(1998, 12, 25), TimeOfDay(2, 15, 0)));
assert(DateTime.fromISOString("00000105T230959") == DateTime(Date(0, 1, 5), TimeOfDay(23, 9, 59)));
assert(DateTime.fromISOString("-00040105T000002") == DateTime(Date(-4, 1, 5), TimeOfDay(0, 0, 2)));
assert(DateTime.fromISOString(" 20100704T070612 ") == DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)));
}
}
/++
Creates a $(D DateTime) from a string with the format
YYYY-MM-DDTHH:MM:SS. Whitespace is stripped from the given string.
Params:
isoString = A string formatted in the ISO Extended format for dates
and times.
Throws:
$(D DateTimeException) if the given string is not in the ISO
Extended format or if the resulting $(D DateTime) would not be
valid.
Examples:
--------------------
assert(DateTime.fromISOExtString("2010-07-04T07:06:12") ==
DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)));
assert(DateTime.fromISOExtString("1998-12-25T02:15:00") ==
DateTime(Date(1998, 12, 25), TimeOfDay(2, 15, 0)));
assert(DateTime.fromISOExtString("0000-01-05T23:09:59") ==
DateTime(Date(0, 1, 5), TimeOfDay(23, 9, 59)));
assert(DateTime.fromISOExtString("-0004-01-05T00:00:02") ==
DateTime(Date(-4, 1, 5), TimeOfDay(0, 0, 2)));
assert(DateTime.fromISOExtString(" 2010-07-04T07:06:12 ") ==
DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)));
--------------------
+/
static DateTime fromISOExtString(S)(in S isoExtString)
if(isSomeString!(S))
{
immutable dstr = to!dstring(strip(isoExtString));
enforce(dstr.length >= 15, new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
auto t = dstr.stds_indexOf('T');
enforce(t != -1, new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
immutable date = Date.fromISOExtString(dstr[0..t]);
immutable tod = TimeOfDay.fromISOExtString(dstr[t+1 .. $]);
return DateTime(date, tod);
}
/++
$(RED Scheduled for deprecation in November 2011.
Please use fromISOExtString instead.)
+/
static DateTime fromISOExtendedString(S)(in S isoExtString)
if(isSomeString!(S))
{
pragma(msg, softDeprec!("2.053", "November 2011", "fromISOExtendedString", "fromISOExtString"));
return fromISOExtString!string(isoExtString);
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException(DateTime.fromISOExtString(""));
assertThrown!DateTimeException(DateTime.fromISOExtString("20100704000000"));
assertThrown!DateTimeException(DateTime.fromISOExtString("20100704 000000"));
assertThrown!DateTimeException(DateTime.fromISOExtString("20100704t000000"));
assertThrown!DateTimeException(DateTime.fromISOExtString("20100704T000000."));
assertThrown!DateTimeException(DateTime.fromISOExtString("20100704T000000.0"));
assertThrown!DateTimeException(DateTime.fromISOExtString("2010-07:0400:00:00"));
assertThrown!DateTimeException(DateTime.fromISOExtString("2010-07-04 00:00:00"));
assertThrown!DateTimeException(DateTime.fromISOExtString("2010-07-04 00:00:00"));
assertThrown!DateTimeException(DateTime.fromISOExtString("2010-07-04t00:00:00"));
assertThrown!DateTimeException(DateTime.fromISOExtString("2010-07-04T00:00:00."));
assertThrown!DateTimeException(DateTime.fromISOExtString("2010-07-04T00:00:00.0"));
assertThrown!DateTimeException(DateTime.fromISOExtString("2010-Jul-0400:00:00"));
assertThrown!DateTimeException(DateTime.fromISOExtString("2010-Jul-04t00:00:00"));
assertThrown!DateTimeException(DateTime.fromISOExtString("2010-Jul-04 00:00:00."));
assertThrown!DateTimeException(DateTime.fromISOExtString("2010-Jul-04 00:00:00.0"));
assertThrown!DateTimeException(DateTime.fromISOExtString("20101222T172201"));
assertThrown!DateTimeException(DateTime.fromISOExtString("2010-Dec-22 17:22:01"));
_assertPred!"=="(DateTime.fromISOExtString("2010-12-22T17:22:01"), DateTime(Date(2010, 12, 22), TimeOfDay(17, 22, 01)));
_assertPred!"=="(DateTime.fromISOExtString("1999-07-06T12:30:33"), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!"=="(DateTime.fromISOExtString("-1999-07-06T12:30:33"), DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!"=="(DateTime.fromISOExtString("+01999-07-06T12:30:33"), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!"=="(DateTime.fromISOExtString("1999-07-06T12:30:33 "), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!"=="(DateTime.fromISOExtString(" 1999-07-06T12:30:33"), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!"=="(DateTime.fromISOExtString(" 1999-07-06T12:30:33 "), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
//Verify Examples.
assert(DateTime.fromISOExtString("2010-07-04T07:06:12") == DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)));
assert(DateTime.fromISOExtString("1998-12-25T02:15:00") == DateTime(Date(1998, 12, 25), TimeOfDay(2, 15, 0)));
assert(DateTime.fromISOExtString("0000-01-05T23:09:59") == DateTime(Date(0, 1, 5), TimeOfDay(23, 9, 59)));
assert(DateTime.fromISOExtString("-0004-01-05T00:00:02") == DateTime(Date(-4, 1, 5), TimeOfDay(0, 0, 2)));
assert(DateTime.fromISOExtString(" 2010-07-04T07:06:12 ") == DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)));
}
}
/++
Creates a $(D DateTime) from a string with the format
YYYY-Mon-DD HH:MM:SS. Whitespace is stripped from the given string.
Params:
simpleString = A string formatted in the way that toSimpleString
formats dates and times.
Throws:
$(D DateTimeException) if the given string is not in the correct
format or if the resulting $(D DateTime) would not be valid.
Examples:
--------------------
assert(DateTime.fromSimpleString("2010-Jul-04 07:06:12") ==
DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)));
assert(DateTime.fromSimpleString("1998-Dec-25 02:15:00") ==
DateTime(Date(1998, 12, 25), TimeOfDay(2, 15, 0)));
assert(DateTime.fromSimpleString("0000-Jan-05 23:09:59") ==
DateTime(Date(0, 1, 5), TimeOfDay(23, 9, 59)));
assert(DateTime.fromSimpleString("-0004-Jan-05 00:00:02") ==
DateTime(Date(-4, 1, 5), TimeOfDay(0, 0, 2)));
assert(DateTime.fromSimpleString(" 2010-Jul-04 07:06:12 ") ==
DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)));
--------------------
+/
static DateTime fromSimpleString(S)(in S simpleString)
if(isSomeString!(S))
{
immutable dstr = to!dstring(strip(simpleString));
enforce(dstr.length >= 15, new DateTimeException(format("Invalid string format: %s", simpleString)));
auto t = dstr.stds_indexOf(' ');
enforce(t != -1, new DateTimeException(format("Invalid string format: %s", simpleString)));
immutable date = Date.fromSimpleString(dstr[0..t]);
immutable tod = TimeOfDay.fromISOExtString(dstr[t+1 .. $]);
return DateTime(date, tod);
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException(DateTime.fromISOString(""));
assertThrown!DateTimeException(DateTime.fromISOString("20100704000000"));
assertThrown!DateTimeException(DateTime.fromISOString("20100704 000000"));
assertThrown!DateTimeException(DateTime.fromISOString("20100704t000000"));
assertThrown!DateTimeException(DateTime.fromISOString("20100704T000000."));
assertThrown!DateTimeException(DateTime.fromISOString("20100704T000000.0"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-07-0400:00:00"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-07-04 00:00:00"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-07-04t00:00:00"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-07-04T00:00:00."));
assertThrown!DateTimeException(DateTime.fromISOString("2010-07-04T00:00:00.0"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-Jul-0400:00:00"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-Jul-04 00:00:00"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-Jul-04t00:00:00"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-Jul-04T00:00:00"));
assertThrown!DateTimeException(DateTime.fromISOString("2010-Jul-04 00:00:00."));
assertThrown!DateTimeException(DateTime.fromISOString("2010-Jul-04 00:00:00.0"));
assertThrown!DateTimeException(DateTime.fromSimpleString("20101222T172201"));
assertThrown!DateTimeException(DateTime.fromSimpleString("2010-12-22T172201"));
_assertPred!"=="(DateTime.fromSimpleString("2010-Dec-22 17:22:01"), DateTime(Date(2010, 12, 22), TimeOfDay(17, 22, 01)));
_assertPred!"=="(DateTime.fromSimpleString("1999-Jul-06 12:30:33"), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!"=="(DateTime.fromSimpleString("-1999-Jul-06 12:30:33"), DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!"=="(DateTime.fromSimpleString("+01999-Jul-06 12:30:33"), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!"=="(DateTime.fromSimpleString("1999-Jul-06 12:30:33 "), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!"=="(DateTime.fromSimpleString(" 1999-Jul-06 12:30:33"), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
_assertPred!"=="(DateTime.fromSimpleString(" 1999-Jul-06 12:30:33 "), DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
//Verify Examples.
assert(DateTime.fromSimpleString("2010-Jul-04 07:06:12") == DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)));
assert(DateTime.fromSimpleString("1998-Dec-25 02:15:00") == DateTime(Date(1998, 12, 25), TimeOfDay(2, 15, 0)));
assert(DateTime.fromSimpleString("0000-Jan-05 23:09:59") == DateTime(Date(0, 1, 5), TimeOfDay(23, 9, 59)));
assert(DateTime.fromSimpleString("-0004-Jan-05 00:00:02") == DateTime(Date(-4, 1, 5), TimeOfDay(0, 0, 2)));
assert(DateTime.fromSimpleString(" 2010-Jul-04 07:06:12 ") == DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)));
}
}
//TODO Add function which takes a user-specified time format and produces a DateTime
//TODO Add function which takes pretty much any time-string and produces a DateTime
// Obviously, it will be less efficient, and it probably won't manage _every_
// possible date format, but a smart conversion function would be nice.
/++
Returns the $(D DateTime) farthest in the past which is representable by
$(D DateTime).
+/
@property static DateTime min() pure nothrow
out(result)
{
assert(result._date == Date.min);
assert(result._tod == TimeOfDay.min);
}
body
{
auto dt = DateTime.init;
dt._date._year = short.min;
dt._date._month = Month.jan;
dt._date._day = 1;
return dt;
}
unittest
{
version(testStdDateTime)
{
assert(DateTime.min.year < 0);
assert(DateTime.min < DateTime.max);
}
}
/++
Returns the $(D DateTime) farthest in the future which is representable
by $(D DateTime).
+/
@property static DateTime max() pure nothrow
out(result)
{
assert(result._date == Date.max);
assert(result._tod == TimeOfDay.max);
}
body
{
auto dt = DateTime.init;
dt._date._year = short.max;
dt._date._month = Month.dec;
dt._date._day = 31;
dt._tod._hour = TimeOfDay.maxHour;
dt._tod._minute = TimeOfDay.maxMinute;
dt._tod._second = TimeOfDay.maxSecond;
return dt;
}
unittest
{
version(testStdDateTime)
{
assert(DateTime.max.year > 0);
assert(DateTime.max > DateTime.min);
}
}
private:
/+
Add seconds to the time of day. Negative values will subtract. If the
number of seconds overflows (or underflows), then the seconds will wrap,
increasing (or decreasing) the number of minutes accordingly. The
same goes for any larger units.
Params:
seconds = The number of seconds to add to this $(D DateTime).
+/
ref DateTime addSeconds(long seconds) pure nothrow
{
long hnsecs = convert!("seconds", "hnsecs")(seconds);
hnsecs += convert!("hours", "hnsecs")(_tod._hour);
hnsecs += convert!("minutes", "hnsecs")(_tod._minute);
hnsecs += convert!("seconds", "hnsecs")(_tod._second);
auto days = splitUnitsFromHNSecs!"days"(hnsecs);
if(hnsecs < 0)
{
hnsecs += convert!("days", "hnsecs")(1);
--days;
}
_date.addDays(days);
immutable newHours = splitUnitsFromHNSecs!"hours"(hnsecs);
immutable newMinutes = splitUnitsFromHNSecs!"minutes"(hnsecs);
immutable newSeconds = splitUnitsFromHNSecs!"seconds"(hnsecs);
_tod._hour = cast(ubyte)newHours;
_tod._minute = cast(ubyte)newMinutes;
_tod._second = cast(ubyte)newSeconds;
return this;
}
unittest
{
version(testStdDateTime)
{
static void testDT(DateTime orig, int seconds, in DateTime expected, size_t line = __LINE__)
{
orig.addSeconds(seconds);
_assertPred!"=="(orig, expected, "", __FILE__, line);
}
//Test A.D.
testDT(DateTime(1999, 7, 6, 12, 30, 33), 0, DateTime(1999, 7, 6, 12, 30, 33));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 1, DateTime(1999, 7, 6, 12, 30, 34));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 2, DateTime(1999, 7, 6, 12, 30, 35));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 3, DateTime(1999, 7, 6, 12, 30, 36));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 4, DateTime(1999, 7, 6, 12, 30, 37));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 5, DateTime(1999, 7, 6, 12, 30, 38));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 10, DateTime(1999, 7, 6, 12, 30, 43));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 15, DateTime(1999, 7, 6, 12, 30, 48));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 26, DateTime(1999, 7, 6, 12, 30, 59));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 27, DateTime(1999, 7, 6, 12, 31, 0));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 30, DateTime(1999, 7, 6, 12, 31, 3));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 59, DateTime(1999, 7, 6, 12, 31, 32));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 60, DateTime(1999, 7, 6, 12, 31, 33));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 61, DateTime(1999, 7, 6, 12, 31, 34));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 1766, DateTime(1999, 7, 6, 12, 59, 59));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 1767, DateTime(1999, 7, 6, 13, 0, 0));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 1768, DateTime(1999, 7, 6, 13, 0, 1));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 2007, DateTime(1999, 7, 6, 13, 4, 0));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 3599, DateTime(1999, 7, 6, 13, 30, 32));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 3600, DateTime(1999, 7, 6, 13, 30, 33));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 3601, DateTime(1999, 7, 6, 13, 30, 34));
testDT(DateTime(1999, 7, 6, 12, 30, 33), 7200, DateTime(1999, 7, 6, 14, 30, 33));
testDT(DateTime(1999, 7, 6, 23, 0, 0), 432_123, DateTime(1999, 7, 11, 23, 2, 3));
testDT(DateTime(1999, 7, 6, 12, 30, 33), -1, DateTime(1999, 7, 6, 12, 30, 32));
testDT(DateTime(1999, 7, 6, 12, 30, 33), -2, DateTime(1999, 7, 6, 12, 30, 31));
testDT(DateTime(1999, 7, 6, 12, 30, 33), -3, DateTime(1999, 7, 6, 12, 30, 30));
testDT(DateTime(1999, 7, 6, 12, 30, 33), -4, DateTime(1999, 7, 6, 12, 30, 29));
testDT(DateTime(1999, 7, 6, 12, 30, 33), -5, DateTime(1999, 7, 6, 12, 30, 28));
testDT(DateTime(1999, 7, 6, 12, 30, 33), -10, DateTime(1999, 7, 6, 12, 30, 23));
testDT(DateTime(1999, 7, 6, 12, 30, 33), -15, DateTime(1999, 7, 6, 12, 30, 18));
testDT(DateTime(1999, 7, 6, 12, 30, 33), -33, DateTime(1999, 7, 6, 12, 30, 0));
testDT(DateTime(1999, 7, 6, 12, 30, 33), -34, DateTime(1999, 7, 6, 12, 29, 59));
testDT(DateTime(1999, 7, 6, 12, 30, 33), -35, DateTime(1999, 7, 6, 12, 29, 58));
testDT(DateTime(1999, 7, 6, 12, 30, 33), -59, DateTime(1999, 7, 6, 12, 29, 34));
testDT(DateTime(1999, 7, 6, 12, 30, 33), -60, DateTime(1999, 7, 6, 12, 29, 33));
testDT(DateTime(1999, 7, 6, 12, 30, 33), -61, DateTime(1999, 7, 6, 12, 29, 32));
testDT(DateTime(1999, 7, 6, 12, 30, 33), -1833, DateTime(1999, 7, 6, 12, 0, 0));
testDT(DateTime(1999, 7, 6, 12, 30, 33), -1834, DateTime(1999, 7, 6, 11, 59, 59));
testDT(DateTime(1999, 7, 6, 12, 30, 33), -3600, DateTime(1999, 7, 6, 11, 30, 33));
testDT(DateTime(1999, 7, 6, 12, 30, 33), -3601, DateTime(1999, 7, 6, 11, 30, 32));
testDT(DateTime(1999, 7, 6, 12, 30, 33), -5134, DateTime(1999, 7, 6, 11, 4, 59));
testDT(DateTime(1999, 7, 6, 23, 0, 0), -432_123, DateTime(1999, 7, 1, 22, 57, 57));
testDT(DateTime(1999, 7, 6, 12, 30, 0), 1, DateTime(1999, 7, 6, 12, 30, 1));
testDT(DateTime(1999, 7, 6, 12, 30, 0), 0, DateTime(1999, 7, 6, 12, 30, 0));
testDT(DateTime(1999, 7, 6, 12, 30, 0), -1, DateTime(1999, 7, 6, 12, 29, 59));
testDT(DateTime(1999, 7, 6, 12, 0, 0), 1, DateTime(1999, 7, 6, 12, 0, 1));
testDT(DateTime(1999, 7, 6, 12, 0, 0), 0, DateTime(1999, 7, 6, 12, 0, 0));
testDT(DateTime(1999, 7, 6, 12, 0, 0), -1, DateTime(1999, 7, 6, 11, 59, 59));
testDT(DateTime(1999, 7, 6, 0, 0, 0), 1, DateTime(1999, 7, 6, 0, 0, 1));
testDT(DateTime(1999, 7, 6, 0, 0, 0), 0, DateTime(1999, 7, 6, 0, 0, 0));
testDT(DateTime(1999, 7, 6, 0, 0, 0), -1, DateTime(1999, 7, 5, 23, 59, 59));
testDT(DateTime(1999, 7, 5, 23, 59, 59), 1, DateTime(1999, 7, 6, 0, 0, 0));
testDT(DateTime(1999, 7, 5, 23, 59, 59), 0, DateTime(1999, 7, 5, 23, 59, 59));
testDT(DateTime(1999, 7, 5, 23, 59, 59), -1, DateTime(1999, 7, 5, 23, 59, 58));
testDT(DateTime(1998, 12, 31, 23, 59, 59), 1, DateTime(1999, 1, 1, 0, 0, 0));
testDT(DateTime(1998, 12, 31, 23, 59, 59), 0, DateTime(1998, 12, 31, 23, 59, 59));
testDT(DateTime(1998, 12, 31, 23, 59, 59), -1, DateTime(1998, 12, 31, 23, 59, 58));
testDT(DateTime(1998, 1, 1, 0, 0, 0), 1, DateTime(1998, 1, 1, 0, 0, 1));
testDT(DateTime(1998, 1, 1, 0, 0, 0), 0, DateTime(1998, 1, 1, 0, 0, 0));
testDT(DateTime(1998, 1, 1, 0, 0, 0), -1, DateTime(1997, 12, 31, 23, 59, 59));
//Test B.C.
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 0, DateTime(-1999, 7, 6, 12, 30, 33));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 1, DateTime(-1999, 7, 6, 12, 30, 34));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 2, DateTime(-1999, 7, 6, 12, 30, 35));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 3, DateTime(-1999, 7, 6, 12, 30, 36));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 4, DateTime(-1999, 7, 6, 12, 30, 37));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 5, DateTime(-1999, 7, 6, 12, 30, 38));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 10, DateTime(-1999, 7, 6, 12, 30, 43));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 15, DateTime(-1999, 7, 6, 12, 30, 48));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 26, DateTime(-1999, 7, 6, 12, 30, 59));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 27, DateTime(-1999, 7, 6, 12, 31, 0));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 30, DateTime(-1999, 7, 6, 12, 31, 3));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 59, DateTime(-1999, 7, 6, 12, 31, 32));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 60, DateTime(-1999, 7, 6, 12, 31, 33));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 61, DateTime(-1999, 7, 6, 12, 31, 34));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 1766, DateTime(-1999, 7, 6, 12, 59, 59));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 1767, DateTime(-1999, 7, 6, 13, 0, 0));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 1768, DateTime(-1999, 7, 6, 13, 0, 1));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 2007, DateTime(-1999, 7, 6, 13, 4, 0));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 3599, DateTime(-1999, 7, 6, 13, 30, 32));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 3600, DateTime(-1999, 7, 6, 13, 30, 33));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 3601, DateTime(-1999, 7, 6, 13, 30, 34));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), 7200, DateTime(-1999, 7, 6, 14, 30, 33));
testDT(DateTime(-1999, 7, 6, 23, 0, 0), 432_123, DateTime(-1999, 7, 11, 23, 2, 3));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -1, DateTime(-1999, 7, 6, 12, 30, 32));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -2, DateTime(-1999, 7, 6, 12, 30, 31));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -3, DateTime(-1999, 7, 6, 12, 30, 30));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -4, DateTime(-1999, 7, 6, 12, 30, 29));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -5, DateTime(-1999, 7, 6, 12, 30, 28));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -10, DateTime(-1999, 7, 6, 12, 30, 23));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -15, DateTime(-1999, 7, 6, 12, 30, 18));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -33, DateTime(-1999, 7, 6, 12, 30, 0));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -34, DateTime(-1999, 7, 6, 12, 29, 59));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -35, DateTime(-1999, 7, 6, 12, 29, 58));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -59, DateTime(-1999, 7, 6, 12, 29, 34));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -60, DateTime(-1999, 7, 6, 12, 29, 33));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -61, DateTime(-1999, 7, 6, 12, 29, 32));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -1833, DateTime(-1999, 7, 6, 12, 0, 0));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -1834, DateTime(-1999, 7, 6, 11, 59, 59));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -3600, DateTime(-1999, 7, 6, 11, 30, 33));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -3601, DateTime(-1999, 7, 6, 11, 30, 32));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -5134, DateTime(-1999, 7, 6, 11, 4, 59));
testDT(DateTime(-1999, 7, 6, 12, 30, 33), -7200, DateTime(-1999, 7, 6, 10, 30, 33));
testDT(DateTime(-1999, 7, 6, 23, 0, 0), -432_123, DateTime(-1999, 7, 1, 22, 57, 57));
testDT(DateTime(-1999, 7, 6, 12, 30, 0), 1, DateTime(-1999, 7, 6, 12, 30, 1));
testDT(DateTime(-1999, 7, 6, 12, 30, 0), 0, DateTime(-1999, 7, 6, 12, 30, 0));
testDT(DateTime(-1999, 7, 6, 12, 30, 0), -1, DateTime(-1999, 7, 6, 12, 29, 59));
testDT(DateTime(-1999, 7, 6, 12, 0, 0), 1, DateTime(-1999, 7, 6, 12, 0, 1));
testDT(DateTime(-1999, 7, 6, 12, 0, 0), 0, DateTime(-1999, 7, 6, 12, 0, 0));
testDT(DateTime(-1999, 7, 6, 12, 0, 0), -1, DateTime(-1999, 7, 6, 11, 59, 59));
testDT(DateTime(-1999, 7, 6, 0, 0, 0), 1, DateTime(-1999, 7, 6, 0, 0, 1));
testDT(DateTime(-1999, 7, 6, 0, 0, 0), 0, DateTime(-1999, 7, 6, 0, 0, 0));
testDT(DateTime(-1999, 7, 6, 0, 0, 0), -1, DateTime(-1999, 7, 5, 23, 59, 59));
testDT(DateTime(-1999, 7, 5, 23, 59, 59), 1, DateTime(-1999, 7, 6, 0, 0, 0));
testDT(DateTime(-1999, 7, 5, 23, 59, 59), 0, DateTime(-1999, 7, 5, 23, 59, 59));
testDT(DateTime(-1999, 7, 5, 23, 59, 59), -1, DateTime(-1999, 7, 5, 23, 59, 58));
testDT(DateTime(-2000, 12, 31, 23, 59, 59), 1, DateTime(-1999, 1, 1, 0, 0, 0));
testDT(DateTime(-2000, 12, 31, 23, 59, 59), 0, DateTime(-2000, 12, 31, 23, 59, 59));
testDT(DateTime(-2000, 12, 31, 23, 59, 59), -1, DateTime(-2000, 12, 31, 23, 59, 58));
testDT(DateTime(-2000, 1, 1, 0, 0, 0), 1, DateTime(-2000, 1, 1, 0, 0, 1));
testDT(DateTime(-2000, 1, 1, 0, 0, 0), 0, DateTime(-2000, 1, 1, 0, 0, 0));
testDT(DateTime(-2000, 1, 1, 0, 0, 0), -1, DateTime(-2001, 12, 31, 23, 59, 59));
//Test Both
testDT(DateTime(1, 1, 1, 0, 0, 0), -1, DateTime(0, 12, 31, 23, 59, 59));
testDT(DateTime(0, 12, 31, 23, 59, 59), 1, DateTime(1, 1, 1, 0, 0, 0));
testDT(DateTime(0, 1, 1, 0, 0, 0), -1, DateTime(-1, 12, 31, 23, 59, 59));
testDT(DateTime(-1, 12, 31, 23, 59, 59), 1, DateTime(0, 1, 1, 0, 0, 0));
testDT(DateTime(-1, 1, 1, 11, 30, 33), 63_165_600L, DateTime(1, 1, 1, 13, 30, 33));
testDT(DateTime(1, 1, 1, 13, 30, 33), -63_165_600L, DateTime(-1, 1, 1, 11, 30, 33));
testDT(DateTime(-1, 1, 1, 11, 30, 33), 63_165_617L, DateTime(1, 1, 1, 13, 30, 50));
testDT(DateTime(1, 1, 1, 13, 30, 50), -63_165_617L, DateTime(-1, 1, 1, 11, 30, 33));
const cdt = DateTime(1999, 7, 6, 12, 30, 33);
immutable idt = DateTime(1999, 7, 6, 12, 30, 33);
static assert(!__traits(compiles, cdt.addSeconds(4)));
static assert(!__traits(compiles, idt.addSeconds(4)));
}
}
Date _date;
TimeOfDay _tod;
}
//==============================================================================
// Section with intervals.
//==============================================================================
/++
Represents an interval of time.
An $(D Interval) has a starting point and an end point. The interval of time
is therefore the time starting at the starting point up to, but not
including, the end point. e.g.
$(BOOKTABLE,
$(TR $(TD [January 5th, 2010 - March 10th, 2010$(RPAREN)))
$(TR $(TD [05:00:30 - 12:00:00$(RPAREN)))
$(TR $(TD [1982-01-04T08:59:00 - 2010-07-04T12:00:00$(RPAREN)))
)
A range can be obtained from an $(D Interval), allowing you to iterate over
that interval, with the exact time points which are iterated over depending
on the function which generates the range.
+/
struct Interval(TP)
{
public:
/++
Params:
begin = The time point which begins the interval.
end = The time point which ends (but is not included in) the
interval.
Throws:
$(D DateTimeException) if $(D_PARAM end) is before $(D_PARAM begin).
Examples:
--------------------
Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));
--------------------
+/
this(U)(in TP begin, in U end) pure
if(is(Unqual!TP == Unqual!U))
{
if(!_valid(begin, end))
throw new DateTimeException("Arguments would result in an invalid Interval.");
_begin = cast(TP)begin;
_end = cast(TP)end;
}
/++
Params:
begin = The time point which begins the interval.
duration = The duration from the starting point to the end point.
Throws:
$(D DateTimeException) if the resulting $(D end) is before
$(D begin).
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Dur.years(3)) ==
Interval!Date(Date(1996, 1, 2), Date(1999, 1, 2)));
--------------------
+/
this(D)(in TP begin, in D duration) pure
if(__traits(compiles, begin + duration))
{
_begin = cast(TP)begin;
_end = begin + duration;
if(!_valid(_begin, _end))
throw new DateTimeException("Arguments would result in an invalid Interval.");
}
/++
Params:
rhs = The $(D Interval) to assign to this one.
+/
/+ref+/ Interval opAssign(const ref Interval rhs) pure nothrow
{
_begin = cast(TP)rhs._begin;
_end = cast(TP)rhs._end;
return this;
}
/++
Params:
rhs = The $(D Interval) to assign to this one.
+/
/+ref+/ Interval opAssign(Interval rhs) pure nothrow
{
_begin = cast(TP)rhs._begin;
_end = cast(TP)rhs._end;
return this;
}
/++
The starting point of the interval. It is included in the interval.
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).begin ==
Date(1996, 1, 2));
--------------------
+/
@property TP begin() const pure nothrow
{
return cast(TP)_begin;
}
/++
The starting point of the interval. It is included in the interval.
Params:
timePoint = The time point to set $(D begin) to.
Throws:
$(D DateTimeException) if the resulting interval would be invalid.
+/
@property void begin(TP timePoint) pure
{
if(!_valid(timePoint, _end))
throw new DateTimeException("Arguments would result in an invalid Interval.");
_begin = timePoint;
}
/++
The end point of the interval. It is excluded from the interval.
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).end ==
Date(2012, 3, 1));
--------------------
+/
@property TP end() const pure nothrow
{
return cast(TP)_end;
}
/++
The end point of the interval. It is excluded from the interval.
Params:
timePoint = The time point to set end to.
Throws:
$(D DateTimeException) if the resulting interval would be invalid.
+/
@property void end(TP timePoint) pure
{
if(!_valid(_begin, timePoint))
throw new DateTimeException("Arguments would result in an invalid Interval.");
_end = timePoint;
}
/++
Returns the duration between $(D begin) and $(D end).
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).length ==
dur!"days"(5903));
--------------------
+/
@property typeof(end - begin) length() const pure nothrow
{
return _end - _begin;
}
/++
Whether the interval's length is 0, that is, whether $(D begin == end).
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(1996, 1, 2)).empty);
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).empty);
--------------------
+/
@property bool empty() const pure nothrow
{
return _begin == _end;
}
/++
Whether the given time point is within this interval.
Params:
timePoint = The time point to check for inclusion in this interval.
Throws:
$(D DateTimeException) if this interval is empty.
Examples:
--------------------
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(
Date(1994, 12, 24)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(
Date(2000, 1, 5)));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(
Date(2012, 3, 1)));
--------------------
+/
bool contains(in TP timePoint) const pure
{
_enforceNotEmpty();
return timePoint >= _begin && timePoint < _end;
}
/++
Whether the given interval is completely within this interval.
Params:
interval = The interval to check for inclusion in this interval.
Throws:
$(D DateTimeException) if either interval is empty.
Examples:
--------------------
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(
Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(
Interval!Date(Date(1998, 2, 28), Date(2013, 5, 1))));
--------------------
+/
bool contains(in Interval interval) const pure
{
_enforceNotEmpty();
interval._enforceNotEmpty();
return interval._begin >= _begin &&
interval._begin < _end &&
interval._end <= _end;
}
/++
Whether the given interval is completely within this interval.
Always returns false (unless this interval is empty), because an
interval going to positive infinity can never be contained in a finite
interval.
Params:
interval = The interval to check for inclusion in this interval.
Throws:
$(D DateTimeException) if this interval is empty.
Examples:
--------------------
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(
PosInfInterval!Date(Date(1999, 5, 4))));
--------------------
+/
bool contains(in PosInfInterval!TP interval) const pure
{
_enforceNotEmpty();
return false;
}
/++
Whether the given interval is completely within this interval.
Always returns false (unless this interval is empty), because an
interval beginning at negative infinity can never be contained in a
finite interval.
Params:
interval = The interval to check for inclusion in this interval.
Throws:
$(D DateTimeException) if this interval is empty.
Examples:
--------------------
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(
NegInfInterval!Date(Date(1996, 5, 4))));
--------------------
+/
bool contains(in NegInfInterval!TP interval) const pure
{
_enforceNotEmpty();
return false;
}
/++
Whether this interval is before the given time point.
Params:
timePoint = The time point to check whether this interval is before
it.
Throws:
$(D DateTimeException) if this interval is empty.
Examples:
--------------------
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(
Date(1994, 12, 24)));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(
Date(2000, 1, 5)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(
Date(2012, 3, 1)));
--------------------
+/
bool isBefore(in TP timePoint) const pure
{
_enforceNotEmpty();
return _end <= timePoint;
}
/++
Whether this interval is before the given interval and does not
intersect with it.
Params:
interval = The interval to check for against this interval.
Throws:
$(D DateTimeException) if either interval is empty.
Examples:
--------------------
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(
Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(
Interval!Date(Date(2012, 3, 1), Date(2013, 5, 1))));
--------------------
+/
bool isBefore(in Interval interval) const pure
{
_enforceNotEmpty();
interval._enforceNotEmpty();
return _end <= interval._begin;
}
/++
Whether this interval is before the given interval and does not
intersect with it.
Params:
interval = The interval to check for against this interval.
Throws:
$(D DateTimeException) if this interval is empty.
Examples:
--------------------
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(
PosInfInterval!Date(Date(1999, 5, 4))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(
PosInfInterval!Date(Date(2013, 3, 7))));
--------------------
+/
bool isBefore(in PosInfInterval!TP interval) const pure
{
_enforceNotEmpty();
return _end <= interval._begin;
}
/++
Whether this interval is before the given interval and does not
intersect with it.
Always returns false (unless this interval is empty) because a finite
interval can never be before an interval beginning at negative infinity.
Params:
interval = The interval to check for against this interval.
Throws:
$(D DateTimeException) if this interval is empty.
Examples:
--------------------
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(
NegInfInterval!Date(Date(1996, 5, 4))));
--------------------
+/
bool isBefore(in NegInfInterval!TP interval) const pure
{
_enforceNotEmpty();
return false;
}
/++
Whether this interval is after the given time point.
Params:
timePoint = The time point to check whether this interval is after
it.
Throws:
$(D DateTimeException) if this interval is empty.
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(
Date(1994, 12, 24)));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(
Date(2000, 1, 5)));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(
Date(2012, 3, 1)));
--------------------
+/
bool isAfter(in TP timePoint) const pure
{
_enforceNotEmpty();
return timePoint < _begin;
}
/++
Whether this interval is after the given interval and does not intersect
it.
Params:
interval = The interval to check against this interval.
Throws:
$(D DateTimeException) if either interval is empty.
Examples:
--------------------
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(
Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(
Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));
--------------------
+/
bool isAfter(in Interval interval) const pure
{
_enforceNotEmpty();
interval._enforceNotEmpty();
return _begin >= interval._end;
}
/++
Whether this interval is after the given interval and does not intersect
it.
Always returns false (unless this interval is empty) because a finite
interval can never be after an interval going to positive infinity.
Params:
interval = The interval to check against this interval.
Throws:
$(D DateTimeException) if this interval is empty.
Examples:
--------------------
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(
PosInfInterval!Date(Date(1999, 5, 4))));
--------------------
+/
bool isAfter(in PosInfInterval!TP interval) const pure
{
_enforceNotEmpty();
return false;
}
/++
Whether this interval is after the given interval and does not intersect
it.
Params:
interval = The interval to check against this interval.
Throws:
$(D DateTimeException) if this interval is empty.
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(
NegInfInterval!Date(Date(1996, 1, 2))));
--------------------
+/
bool isAfter(in NegInfInterval!TP interval) const pure
{
_enforceNotEmpty();
return _begin >= interval._end;
}
/++
Whether the given interval overlaps this interval.
Params:
interval = The interval to check for intersection with this interval.
Throws:
$(D DateTimeException) if either interval is empty.
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(
Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(
Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));
--------------------
+/
bool intersects(in Interval interval) const pure
{
_enforceNotEmpty();
interval._enforceNotEmpty();
return interval._begin < _end && interval._end > _begin;
}
/++
Whether the given interval overlaps this interval.
Params:
interval = The interval to check for intersection with this interval.
Throws:
$(D DateTimeException) if this interval is empty.
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(
PosInfInterval!Date(Date(1999, 5, 4))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(
PosInfInterval!Date(Date(2012, 3, 1))));
--------------------
+/
bool intersects(in PosInfInterval!TP interval) const pure
{
_enforceNotEmpty();
return _end > interval._begin;
}
/++
Whether the given interval overlaps this interval.
Params:
interval = The interval to check for intersection with this interval.
Throws:
$(D DateTimeException) if this interval is empty.
Examples:
--------------------
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(
NegInfInterval!Date(Date(1996, 1, 2))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(
NegInfInterval!Date(Date(2000, 1, 2))));
--------------------
+/
bool intersects(in NegInfInterval!TP interval) const pure
{
_enforceNotEmpty();
return _begin < interval._end;
}
/++
Returns the intersection of two intervals
Params:
interval = The interval to intersect with this interval.
Throws:
$(D DateTimeException) if the two intervals do not intersect or if
either interval is empty.
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) ==
Interval!Date(Date(1996, 1 , 2), Date(2000, 8, 2)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(
Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))) ==
Interval!Date(Date(1999, 1 , 12), Date(2011, 9, 17)));
--------------------
+/
Interval intersection(in Interval interval) const
{
enforce(this.intersects(interval), new DateTimeException(format("%s and %s do not intersect.", this, interval)));
auto begin = _begin > interval._begin ? _begin : interval._begin;
auto end = _end < interval._end ? _end : interval._end;
return Interval(begin, end);
}
/++
Returns the intersection of two intervals
Params:
interval = The interval to intersect with this interval.
Throws:
$(D DateTimeException) if the two intervals do not intersect or if
this interval is empty.
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(
PosInfInterval!Date(Date(1990, 7, 6))) ==
Interval!Date(Date(1996, 1 , 2), Date(2012, 3, 1)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(
PosInfInterval!Date(Date(1999, 1, 12))) ==
Interval!Date(Date(1999, 1 , 12), Date(2012, 3, 1)));
--------------------
+/
Interval intersection(in PosInfInterval!TP interval) const
{
enforce(this.intersects(interval), new DateTimeException(format("%s and %s do not intersect.", this, interval)));
return Interval(_begin > interval._begin ? _begin : interval._begin, _end);
}
/++
Returns the intersection of two intervals
Params:
interval = The interval to intersect with this interval.
Throws:
$(D DateTimeException) if the two intervals do not intersect or if
this interval is empty.
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(
NegInfInterval!Date(Date(1999, 7, 6))) ==
Interval!Date(Date(1996, 1 , 2), Date(1999, 7, 6)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(
NegInfInterval!Date(Date(2013, 1, 12))) ==
Interval!Date(Date(1996, 1 , 2), Date(2012, 3, 1)));
--------------------
+/
Interval intersection(in NegInfInterval!TP interval) const
{
enforce(this.intersects(interval), new DateTimeException(format("%s and %s do not intersect.", this, interval)));
return Interval(_begin, _end < interval._end ? _end : interval._end);
}
/++
Whether the given interval is adjacent to this interval.
Params:
interval = The interval to check whether its adjecent to this
interval.
Throws:
$(D DateTimeException) if either interval is empty.
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(
Interval!Date(Date(1990, 7, 6), Date(1996, 1, 2))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(
Interval!Date(Date(2012, 3, 1), Date(2013, 9, 17))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(
Interval!Date(Date(1989, 3, 1), Date(2012, 3, 1))));
--------------------
+/
bool isAdjacent(in Interval interval) const pure
{
_enforceNotEmpty();
interval._enforceNotEmpty();
return _begin == interval._end || _end == interval._begin;
}
/++
Whether the given interval is adjacent to this interval.
Params:
interval = The interval to check whether its adjecent to this
interval.
Throws:
$(D DateTimeException) if this interval is empty.
Examples:
--------------------
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(
PosInfInterval!Date(Date(1999, 5, 4))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(
PosInfInterval!Date(Date(2012, 3, 1))));
--------------------
+/
bool isAdjacent(in PosInfInterval!TP interval) const pure
{
_enforceNotEmpty();
return _end == interval._begin;
}
/++
Whether the given interval is adjacent to this interval.
Params:
interval = The interval to check whether its adjecent to this
interval.
Throws:
$(D DateTimeException) if this interval is empty.
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(
NegInfInterval!Date(Date(1996, 1, 2))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(
NegInfInterval!Date(Date(2000, 1, 2))));
--------------------
+/
bool isAdjacent(in NegInfInterval!TP interval) const pure
{
_enforceNotEmpty();
return _begin == interval._end;
}
/++
Returns the union of two intervals
Params:
interval = The interval to merge with this interval.
Throws:
$(D DateTimeException) if the two intervals do not intersect and are
not adjacent or if either interval is empty.
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) ==
Interval!Date(Date(1990, 7 , 6), Date(2012, 3, 1)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge(
Interval!Date(Date(2012, 3, 1), Date(2013, 5, 7))) ==
Interval!Date(Date(1996, 1 , 2), Date(2013, 5, 7)));
--------------------
+/
Interval merge(in Interval interval) const
{
enforce(this.isAdjacent(interval) || this.intersects(interval),
new DateTimeException(format("%s and %s are not adjacent and do not intersect.", this, interval)));
auto begin = _begin < interval._begin ? _begin : interval._begin;
auto end = _end > interval._end ? _end : interval._end;
return Interval(begin, end);
}
/++
Returns the union of two intervals
Params:
interval = The interval to merge with this interval.
Throws:
$(D DateTimeException) if the two intervals do not intersect and are
not adjacent or if this interval is empty.
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge(
PosInfInterval!Date(Date(1990, 7, 6))) ==
PosInfInterval!Date(Date(1990, 7 , 6)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge(
PosInfInterval!Date(Date(2012, 3, 1))) ==
PosInfInterval!Date(Date(1996, 1 , 2)));
--------------------
+/
PosInfInterval!TP merge(in PosInfInterval!TP interval) const
{
enforce(this.isAdjacent(interval) || this.intersects(interval),
new DateTimeException(format("%s and %s are not adjacent and do not intersect.", this, interval)));
return PosInfInterval!TP(_begin < interval._begin ? _begin : interval._begin);
}
/++
Returns the union of two intervals
Params:
interval = The interval to merge with this interval.
Throws:
$(D DateTimeException) if the two intervals do not intersect and are not
adjacent or if this interval is empty.
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge(
NegInfInterval!Date(Date(1996, 1, 2))) ==
NegInfInterval!Date(Date(2012, 3 , 1)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge(
NegInfInterval!Date(Date(2013, 1, 12))) ==
NegInfInterval!Date(Date(2013, 1 , 12)));
--------------------
+/
NegInfInterval!TP merge(in NegInfInterval!TP interval) const
{
enforce(this.isAdjacent(interval) || this.intersects(interval),
new DateTimeException(format("%s and %s are not adjacent and do not intersect.", this, interval)));
return NegInfInterval!TP(_end > interval._end ? _end : interval._end);
}
/++
Returns an interval that covers from the earliest time point of two
intervals up to (but not including) the latest time point of two
intervals.
Params:
interval = The interval to create a span together with this interval.
Throws:
$(D DateTimeException) if either interval is empty.
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span(
Interval!Date(Date(1990, 7, 6), Date(1991, 1, 8))) ==
Interval!Date(Date(1990, 7 , 6), Date(2012, 3, 1)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span(
Interval!Date(Date(2012, 3, 1), Date(2013, 5, 7))) ==
Interval!Date(Date(1996, 1 , 2), Date(2013, 5, 7)));
--------------------
+/
Interval span(in Interval interval) const pure
{
_enforceNotEmpty();
interval._enforceNotEmpty();
auto begin = _begin < interval._begin ? _begin : interval._begin;
auto end = _end > interval._end ? _end : interval._end;
return Interval(begin, end);
}
/++
Returns an interval that covers from the earliest time point of two
intervals up to (but not including) the latest time point of two
intervals.
Params:
interval = The interval to create a span together with this interval.
Throws:
$(D DateTimeException) if this interval is empty.
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span(
PosInfInterval!Date(Date(1990, 7, 6))) ==
PosInfInterval!Date(Date(1990, 7 , 6)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span(
PosInfInterval!Date(Date(2050, 1, 1))) ==
PosInfInterval!Date(Date(1996, 1 , 2)));
--------------------
+/
PosInfInterval!TP span(in PosInfInterval!TP interval) const pure
{
_enforceNotEmpty();
return PosInfInterval!TP(_begin < interval._begin ? _begin : interval._begin);
}
/++
Returns an interval that covers from the earliest time point of two
intervals up to (but not including) the latest time point of two
intervals.
Params:
interval = The interval to create a span together with this interval.
Throws:
$(D DateTimeException) if this interval is empty.
Examples:
--------------------
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span(
NegInfInterval!Date(Date(1602, 5, 21))) ==
NegInfInterval!Date(Date(2012, 3 , 1)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span(
NegInfInterval!Date(Date(2013, 1, 12))) ==
NegInfInterval!Date(Date(2013, 1 , 12)));
--------------------
+/
NegInfInterval!TP span(in NegInfInterval!TP interval) const pure
{
_enforceNotEmpty();
return NegInfInterval!TP(_end > interval._end ? _end : interval._end);
}
/++
Shifts the interval forward or backwards in time by the given duration
(a positive duration shifts the interval forward; a negative duration
shifts it backward). Effectively, it does $(D begin += duration) and
$(D end += duration).
Params:
duration = The duration to shift the interval by.
Throws:
$(D DateTimeException) this interval is empty or if the resulting
interval would be invalid.
Examples:
--------------------
auto interval1 = Interval!Date(Date(1996, 1, 2), Date(2012, 4, 5));
auto interval2 = Interval!Date(Date(1996, 1, 2), Date(2012, 4, 5));
interval1.shift(dur!"days"(50));
assert(interval1 == Interval!Date(Date(1996, 2, 21), Date(2012, 5, 25)));
interval2.shift(dur!"days"(-50));
assert(interval2 == Interval!Date(Date(1995, 11, 13), Date(2012, 2, 15)));
--------------------
+/
void shift(D)(D duration) pure
if(__traits(compiles, begin + duration))
{
_enforceNotEmpty();
auto begin = _begin + duration;
auto end = _end + duration;
if(!_valid(begin, end))
throw new DateTimeException("Argument would result in an invalid Interval.");
_begin = begin;
_end = end;
}
static if(__traits(compiles, begin.add!"months"(1)) &&
__traits(compiles, begin.add!"years"(1)))
{
/++
Shifts the interval forward or backwards in time by the given number
of years and/or months (a positive number of years and months shifts
the interval forward; a negative number shifts it backward).
It adds the years the given years and months to both begin and end.
It effectively calls $(D add!"years"()) and then $(D add!"months"())
on begin and end with the given number of years and months.
Params:
years = The number of years to shift the interval by.
months = The number of months to shift the interval by.
allowOverflow = Whether the days should be allowed to overflow
on $(D begin) and $(D end), causing their month
to increment.
Throws:
$(D DateTimeException) if this interval is empty or if the
resulting interval would be invalid.
Examples:
--------------------
auto interval1 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));
auto interval2 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));
interval1.shift(2);
assert(interval1 == Interval!Date(Date(1998, 1, 2), Date(2014, 3, 1)));
interval2.shift(-2);
assert(interval2 == Interval!Date(Date(1994, 1, 2), Date(2010, 3, 1)));
--------------------
+/
void shift(T)(T years, T months = 0, AllowDayOverflow allowOverflow = AllowDayOverflow.yes)
if(isIntegral!T)
{
_enforceNotEmpty();
auto begin = _begin;
auto end = _end;
begin.add!"years"(years, allowOverflow);
begin.add!"months"(months, allowOverflow);
end.add!"years"(years, allowOverflow);
end.add!"months"(months, allowOverflow);
enforce(_valid(begin, end), new DateTimeException("Argument would result in an invalid Interval."));
_begin = begin;
_end = end;
}
}
/++
Expands the interval forwards and/or backwards in time. Effectively,
it does $(D begin -= duration) and/or $(D end += duration). Whether
it expands forwards and/or backwards in time is determined by
$(D_PARAM dir).
Params:
duration = The duration to expand the interval by.
dir = The direction in time to expand the interval.
Throws:
$(D DateTimeException) this interval is empty or if the resulting
interval would be invalid.
Examples:
--------------------
auto interval1 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));
auto interval2 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));
interval1.expand(2);
assert(interval1 == Interval!Date(Date(1994, 1, 2), Date(2014, 3, 1)));
interval2.expand(-2);
assert(interval2 == Interval!Date(Date(1998, 1, 2), Date(2010, 3, 1)));
--------------------
+/
void expand(D)(D duration, Direction dir = Direction.both) pure
if(__traits(compiles, begin + duration))
{
_enforceNotEmpty();
switch(dir)
{
case Direction.both:
{
auto begin = _begin - duration;
auto end = _end + duration;
if(!_valid(begin, end))
throw new DateTimeException("Argument would result in an invalid Interval.");
_begin = begin;
_end = end;
return;
}
case Direction.fwd:
{
auto end = _end + duration;
if(!_valid(_begin, end))
throw new DateTimeException("Argument would result in an invalid Interval.");
_end = end;
return;
}
case Direction.bwd:
{
auto begin = _begin - duration;
if(!_valid(begin, _end))
throw new DateTimeException("Argument would result in an invalid Interval.");
_begin = begin;
return;
}
default:
assert(0, "Invalid Direction.");
}
}
static if(__traits(compiles, begin.add!"months"(1)) &&
__traits(compiles, begin.add!"years"(1)))
{
/++
Expands the interval forwards and/or backwards in time. Effectively,
it subtracts the given number of months/years from $(D begin) and
adds them to $(D end). Whether it expands forwards and/or backwards
in time is determined by $(D_PARAM dir).
Params:
years = The number of years to expand the interval by.
months = The number of months to expand the interval by.
allowOverflow = Whether the days should be allowed to overflow
on $(D begin) and $(D end), causing their month
to increment.
Throws:
$(D DateTimeException) if this interval is empty or if the
resulting interval would be invalid.
Examples:
--------------------
auto interval1 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));
auto interval2 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));
interval1.expand(2);
assert(interval1 == Interval!Date(Date(1994, 1, 2), Date(2014, 3, 1)));
interval2.expand(-2);
assert(interval2 == Interval!Date(Date(1998, 1, 2), Date(2010, 3, 1)));
--------------------
+/
void expand(T)(T years, T months = 0, AllowDayOverflow allowOverflow = AllowDayOverflow.yes, Direction dir = Direction.both)
if(isIntegral!T)
{
_enforceNotEmpty();
switch(dir)
{
case Direction.both:
{
auto begin = _begin;
auto end = _end;
begin.add!"years"(-years, allowOverflow);
begin.add!"months"(-months, allowOverflow);
end.add!"years"(years, allowOverflow);
end.add!"months"(months, allowOverflow);
enforce(_valid(begin, end), new DateTimeException("Argument would result in an invalid Interval."));
_begin = begin;
_end = end;
return;
}
case Direction.fwd:
{
auto end = _end;
end.add!"years"(years, allowOverflow);
end.add!"months"(months, allowOverflow);
enforce(_valid(_begin, end), new DateTimeException("Argument would result in an invalid Interval."));
_end = end;
return;
}
case Direction.bwd:
{
auto begin = _begin;
begin.add!"years"(-years, allowOverflow);
begin.add!"months"(-months, allowOverflow);
enforce(_valid(begin, _end), new DateTimeException("Argument would result in an invalid Interval."));
_begin = begin;
return;
}
default:
assert(0, "Invalid Direction.");
}
}
}
/++
Returns a range which iterates forward over the interval, starting
at $(D begin), using $(D_PARAM func) to generate each successive time
point.
The range's $(D front) is the interval's $(D begin). $(D_PARAM func) is
used to generate the next $(D front) when $(D popFront) is called. If
$(D_PARAM popFirst) is $(D PopFirst.yes), then $(D popFront) is called
before the range is returned (so that $(D front) is a time point which
$(D_PARAM func) would generate).
If $(D_PARAM func) ever generates a time point less than or equal to the
current $(D front) of the range, then a $(D DateTimeException) will be
thrown. The range will be empty and iteration complete when
$(D_PARAM func) generates a time point equal to or beyond the $(D end)
of the interval.
There are helper functions in this module which generate common
delegates to pass to $(D fwdRange). Their documentation starts with
"Range-generating function," so you can easily search for them.
Params:
func = The function used to generate the time points of the
range over the interval.
popFirst = Whether $(D popFront) should be called on the range
before returning it.
Throws:
$(D DateTimeException) if this interval is empty.
Warning:
$(D_PARAM func) must be logically pure. Ideally, $(D_PARAM func)
would be a function pointer to a pure function, but forcing
$(D_PARAM func) to be pure is far too restrictive to be useful, and
in order to have the ease of use of having functions which generate
functions to pass to $(D fwdRange), $(D_PARAM func) must be a
delegate.
If $(D_PARAM func) retains state which changes as it is called, then
some algorithms will not work correctly, because the range's
$(D save) will have failed to have really saved the range's state.
So, if you want to avoid such bugs, don't pass a delegate which is
not logically pure to $(D fwdRange). If $(D_PARAM func) is given the
same time point with two different calls, it must return the same
result both times.
Of course, none of the functions in this module have this problem,
so it's only relevant if you're creating your own delegate.
Examples:
--------------------
auto interval = Interval!Date(Date(2010, 9, 1), Date(2010, 9, 9));
auto func = (in Date date) //For iterating over even-numbered days.
{
if((date.day & 1) == 0)
return date + dur!"days"(2);
return date + dur!"days"(1);
};
auto range = interval.fwdRange(func);
//An odd day. Using PopFirst.yes would have made this Date(2010, 9, 2).
assert(range.front == Date(2010, 9, 1));
range.popFront();
assert(range.front == Date(2010, 9, 2));
range.popFront();
assert(range.front == Date(2010, 9, 4));
range.popFront();
assert(range.front == Date(2010, 9, 6));
range.popFront();
assert(range.front == Date(2010, 9, 8));
range.popFront();
assert(range.empty);
--------------------
+/
IntervalRange!(TP, Direction.fwd) fwdRange(TP delegate(in TP) func, PopFirst popFirst = PopFirst.no) const
{
_enforceNotEmpty();
auto range = IntervalRange!(TP, Direction.fwd)(this, func);
if(popFirst == PopFirst.yes)
range.popFront();
return range;
}
/++
Returns a range which iterates backwards over the interval, starting
at $(D end), using $(D_PARAM func) to generate each successive time
point.
The range's $(D front) is the interval's $(D end). $(D_PARAM func) is
used to generate the next $(D front) when $(D popFront) is called. If
$(D_PARAM popFirst) is $(D PopFirst.yes), then $(D popFront) is called
before the range is returned (so that $(D front) is a time point which
$(D_PARAM func) would generate).
If $(D_PARAM func) ever generates a time point greater than or equal to
the current $(D front) of the range, then a $(D DateTimeException) will
be thrown. The range will be empty and iteration complete when
$(D_PARAM func) generates a time point equal to or less than the
$(D begin) of the interval.
There are helper functions in this module which generate common
delegates to pass to $(D bwdRange). Their documentation starts with
"Range-generating function," so you can easily search for them.
Params:
func = The function used to generate the time points of the
range over the interval.
popFirst = Whether $(D popFront) should be called on the range
before returning it.
Throws:
$(D DateTimeException) if this interval is empty.
Warning:
$(D_PARAM func) must be logically pure. Ideally, $(D_PARAM func)
would be a function pointer to a pure function, but forcing
$(D_PARAM func) to be pure is far too restrictive to be useful, and
in order to have the ease of use of having functions which generate
functions to pass to $(D fwdRange), $(D_PARAM func) must be a
delegate.
If $(D_PARAM func) retains state which changes as it is called, then
some algorithms will not work correctly, because the range's
$(D save) will have failed to have really saved the range's state.
So, if you want to avoid such bugs, don't pass a delegate which is
not logically pure to $(D fwdRange). If $(D_PARAM func) is given the
same time point with two different calls, it must return the same
result both times.
Of course, none of the functions in this module have this problem,
so it's only relevant if you're creating your own delegate.
Examples:
--------------------
auto interval = Interval!Date(Date(2010, 9, 1), Date(2010, 9, 9));
auto func = (in Date date) //For iterating over even-numbered days.
{
if((date.day & 1) == 0)
return date - dur!"days"(2);
return date - dur!"days"(1);
};
auto range = interval.bwdRange(func);
//An odd day. Using PopFirst.yes would have made this Date(2010, 9, 8).
assert(range.front == Date(2010, 9, 9));
range.popFront();
assert(range.front == Date(2010, 9, 8));
range.popFront();
assert(range.front == Date(2010, 9, 6));
range.popFront();
assert(range.front == Date(2010, 9, 4));
range.popFront();
assert(range.front == Date(2010, 9, 2));
range.popFront();
assert(range.empty);
--------------------
+/
IntervalRange!(TP, Direction.bwd) bwdRange(TP delegate(in TP) func, PopFirst popFirst = PopFirst.no) const
{
_enforceNotEmpty();
auto range = IntervalRange!(TP, Direction.bwd)(this, func);
if(popFirst == PopFirst.yes)
range.popFront();
return range;
}
/+
Converts this interval to a string.
+/
//Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
//have versions of toString() with extra modifiers, so we define one version
//with modifiers and one without.
string toString()
{
return _toStringImpl();
}
/++
Converts this interval to a string.
+/
//Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
//have versions of toString() with extra modifiers, so we define one version
//with modifiers and one without.
string toString() const nothrow
{
return _toStringImpl();
}
private:
/+
Since we have two versions of toString, we have _toStringImpl
so that they can share implementations.
+/
string _toStringImpl() const nothrow
{
try
return format("[%s - %s)", _begin, _end);
catch(Exception e)
assert(0, "format() threw.");
}
/+
Throws:
$(D DateTimeException) if this interval is empty.
+/
void _enforceNotEmpty(size_t line = __LINE__) const pure
{
if(empty)
throw new DateTimeException("Invalid operation for an empty Interval.", __FILE__, line);
}
/+
Whether the given values form a valid time interval.
Params:
begin = The starting point of the interval.
end = The end point of the interval.
+/
static bool _valid(in TP begin, in TP end) pure nothrow
{
return begin <= end;
}
pure invariant()
{
assert(_valid(_begin, _end), "Invariant Failure: begin is not before or equal to end.");
}
TP _begin;
TP _end;
}
//Test Interval's constructors.
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException(Interval!Date(Date(2010, 1, 1), Date(1, 1, 1)));
Interval!Date(Date.init, Date.init);
Interval!TimeOfDay(TimeOfDay.init, TimeOfDay.init);
Interval!DateTime(DateTime.init, DateTime.init);
Interval!SysTime(SysTime(0), SysTime(0));
Interval!DateTime(DateTime.init, dur!"days"(7));
//Verify Examples.
Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));
assert(Interval!Date(Date(1996, 1, 2), dur!"weeks"(3)) == Interval!Date(Date(1996, 1, 2), Date(1996, 1, 23)));
assert(Interval!Date(Date(1996, 1, 2), dur!"days"(3)) == Interval!Date(Date(1996, 1, 2), Date(1996, 1, 5)));
assert(Interval!DateTime(DateTime(1996, 1, 2, 12, 0, 0), dur!"hours"(3)) == Interval!DateTime(DateTime(1996, 1, 2, 12, 0, 0), DateTime(1996, 1, 2, 15, 0, 0)));
assert(Interval!DateTime(DateTime(1996, 1, 2, 12, 0, 0), dur!"minutes"(3)) == Interval!DateTime(DateTime(1996, 1, 2, 12, 0, 0), DateTime(1996, 1, 2, 12, 3, 0)));
assert(Interval!DateTime(DateTime(1996, 1, 2, 12, 0, 0), dur!"seconds"(3)) == Interval!DateTime(DateTime(1996, 1, 2, 12, 0, 0), DateTime(1996, 1, 2, 12, 0, 3)));
assert(Interval!DateTime(DateTime(1996, 1, 2, 12, 0, 0), dur!"msecs"(3000)) == Interval!DateTime(DateTime(1996, 1, 2, 12, 0, 0), DateTime(1996, 1, 2, 12, 0, 3)));
}
}
//Test Interval's begin.
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(Interval!Date(Date(1, 1, 1), Date(2010, 1, 1)).begin, Date(1, 1, 1));
_assertPred!"=="(Interval!Date(Date(2010, 1, 1), Date(2010, 1, 1)).begin, Date(2010, 1, 1));
_assertPred!"=="(Interval!Date(Date(1997, 12, 31), Date(1998, 1, 1)).begin, Date(1997, 12, 31));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static assert(__traits(compiles, cInterval.begin));
static assert(__traits(compiles, iInterval.begin));
//Verify Examples.
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).begin == Date(1996, 1, 2));
}
}
//Test Interval's end.
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(Interval!Date(Date(1, 1, 1), Date(2010, 1, 1)).end, Date(2010, 1, 1));
_assertPred!"=="(Interval!Date(Date(2010, 1, 1), Date(2010, 1, 1)).end, Date(2010, 1, 1));
_assertPred!"=="(Interval!Date(Date(1997, 12, 31), Date(1998, 1, 1)).end, Date(1998, 1, 1));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static assert(__traits(compiles, cInterval.end));
static assert(__traits(compiles, iInterval.end));
//Verify Examples.
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).end == Date(2012, 3, 1));
}
}
//Test Interval's length.
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(Interval!Date(Date(2010, 1, 1), Date(2010, 1, 1)).length, dur!"days"(0));
_assertPred!"=="(Interval!Date(Date(2010, 1, 1), Date(2010, 4, 1)).length, dur!"days"(90));
_assertPred!"=="(Interval!TimeOfDay(TimeOfDay(0, 30, 0), TimeOfDay(12, 22, 7)).length, dur!"seconds"(42_727));
_assertPred!"=="(Interval!DateTime(DateTime(2010, 1, 1, 0, 30, 0), DateTime(2010, 1, 2, 12, 22, 7)).length, dur!"seconds"(129_127));
_assertPred!"=="(Interval!SysTime(SysTime(DateTime(2010, 1, 1, 0, 30, 0)), SysTime(DateTime(2010, 1, 2, 12, 22, 7))).length, dur!"seconds"(129_127));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static assert(__traits(compiles, cInterval.length));
static assert(__traits(compiles, iInterval.length));
//Verify Examples.
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).length == dur!"days"(5903));
}
}
//Test Interval's empty.
unittest
{
version(testStdDateTime)
{
assert(Interval!Date(Date(2010, 1, 1), Date(2010, 1, 1)).empty);
assert(!Interval!Date(Date(2010, 1, 1), Date(2010, 4, 1)).empty);
assert(!Interval!TimeOfDay(TimeOfDay(0, 30, 0), TimeOfDay(12, 22, 7)).empty);
assert(!Interval!DateTime(DateTime(2010, 1, 1, 0, 30, 0), DateTime(2010, 1, 2, 12, 22, 7)).empty);
assert(!Interval!SysTime(SysTime(DateTime(2010, 1, 1, 0, 30, 0)), SysTime(DateTime(2010, 1, 2, 12, 22, 7))).empty);
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static assert(__traits(compiles, cInterval.empty));
static assert(__traits(compiles, iInterval.empty));
//Verify Examples.
assert(Interval!Date(Date(1996, 1, 2), Date(1996, 1, 2)).empty);
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).empty);
}
}
//Test Interval's contains(time point).
unittest
{
version(testStdDateTime)
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
assertThrown!DateTimeException(Interval!Date(Date(2010, 7, 4), dur!"days"(0)).contains(Date(2010, 7, 4)));
assert(!interval.contains(Date(2009, 7, 4)));
assert(!interval.contains(Date(2010, 7, 3)));
assert(interval.contains(Date(2010, 7, 4)));
assert(interval.contains(Date(2010, 7, 5)));
assert(interval.contains(Date(2011, 7, 1)));
assert(interval.contains(Date(2012, 1, 6)));
assert(!interval.contains(Date(2012, 1, 7)));
assert(!interval.contains(Date(2012, 1, 8)));
assert(!interval.contains(Date(2013, 1, 7)));
const cdate = Date(2010, 7, 6);
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static assert(__traits(compiles, interval.contains(cdate)));
static assert(__traits(compiles, cInterval.contains(cdate)));
static assert(__traits(compiles, iInterval.contains(cdate)));
//Verify Examples.
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(Date(1994, 12, 24)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(Date(2000, 1, 5)));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(Date(2012, 3, 1)));
}
}
//Test Interval's contains(Interval).
unittest
{
version(testStdDateTime)
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
assertThrown!DateTimeException(interval.contains(Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assertThrown!DateTimeException(Interval!Date(Date(2010, 7, 4), dur!"days"(0)).contains(interval));
assertThrown!DateTimeException(Interval!Date(Date(2010, 7, 4), dur!"days"(0)).contains(Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assert(interval.contains(interval));
assert(!interval.contains(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
assert(!interval.contains(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))));
assert(!interval.contains(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))));
assert(!interval.contains(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))));
assert(!interval.contains(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))));
assert(!interval.contains(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))));
assert(interval.contains(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))));
assert(interval.contains(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))));
assert(interval.contains(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))));
assert(!interval.contains(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))));
assert(!interval.contains(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))));
assert(!interval.contains(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
assert(!Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3)).contains(interval));
assert(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)).contains(interval));
assert(!Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4)).contains(interval));
assert(!Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5)).contains(interval));
assert(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)).contains(interval));
assert(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)).contains(interval));
assert(!Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)).contains(interval));
assert(!Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)).contains(interval));
assert(!Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)).contains(interval));
assert(!Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8)).contains(interval));
assert(!Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8)).contains(interval));
assert(!Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9)).contains(interval));
assert(!interval.contains(PosInfInterval!Date(Date(2010, 7, 3))));
assert(!interval.contains(PosInfInterval!Date(Date(2010, 7, 4))));
assert(!interval.contains(PosInfInterval!Date(Date(2010, 7, 5))));
assert(!interval.contains(PosInfInterval!Date(Date(2012, 1, 6))));
assert(!interval.contains(PosInfInterval!Date(Date(2012, 1, 7))));
assert(!interval.contains(PosInfInterval!Date(Date(2012, 1, 8))));
assert(!interval.contains(NegInfInterval!Date(Date(2010, 7, 3))));
assert(!interval.contains(NegInfInterval!Date(Date(2010, 7, 4))));
assert(!interval.contains(NegInfInterval!Date(Date(2010, 7, 5))));
assert(!interval.contains(NegInfInterval!Date(Date(2012, 1, 6))));
assert(!interval.contains(NegInfInterval!Date(Date(2012, 1, 7))));
assert(!interval.contains(NegInfInterval!Date(Date(2012, 1, 8))));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, interval.contains(interval)));
static assert(__traits(compiles, interval.contains(cInterval)));
static assert(__traits(compiles, interval.contains(iInterval)));
static assert(__traits(compiles, interval.contains(posInfInterval)));
static assert(__traits(compiles, interval.contains(cPosInfInterval)));
static assert(__traits(compiles, interval.contains(iPosInfInterval)));
static assert(__traits(compiles, interval.contains(negInfInterval)));
static assert(__traits(compiles, interval.contains(cNegInfInterval)));
static assert(__traits(compiles, interval.contains(iNegInfInterval)));
static assert(__traits(compiles, cInterval.contains(interval)));
static assert(__traits(compiles, cInterval.contains(cInterval)));
static assert(__traits(compiles, cInterval.contains(iInterval)));
static assert(__traits(compiles, cInterval.contains(posInfInterval)));
static assert(__traits(compiles, cInterval.contains(cPosInfInterval)));
static assert(__traits(compiles, cInterval.contains(iPosInfInterval)));
static assert(__traits(compiles, cInterval.contains(negInfInterval)));
static assert(__traits(compiles, cInterval.contains(cNegInfInterval)));
static assert(__traits(compiles, cInterval.contains(iNegInfInterval)));
static assert(__traits(compiles, iInterval.contains(interval)));
static assert(__traits(compiles, iInterval.contains(cInterval)));
static assert(__traits(compiles, iInterval.contains(iInterval)));
static assert(__traits(compiles, iInterval.contains(posInfInterval)));
static assert(__traits(compiles, iInterval.contains(cPosInfInterval)));
static assert(__traits(compiles, iInterval.contains(iPosInfInterval)));
static assert(__traits(compiles, iInterval.contains(negInfInterval)));
static assert(__traits(compiles, iInterval.contains(cNegInfInterval)));
static assert(__traits(compiles, iInterval.contains(iNegInfInterval)));
//Verify Examples.
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(Interval!Date(Date(1998, 2, 28), Date(2013, 5, 1))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(PosInfInterval!Date(Date(1999, 5, 4))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(NegInfInterval!Date(Date(1996, 5, 4))));
}
}
//Test Interval's isBefore(time point).
unittest
{
version(testStdDateTime)
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
assertThrown!DateTimeException(Interval!Date(Date(2010, 7, 4), dur!"days"(0)).isBefore(Date(2010, 7, 4)));
assert(!interval.isBefore(Date(2009, 7, 3)));
assert(!interval.isBefore(Date(2010, 7, 3)));
assert(!interval.isBefore(Date(2010, 7, 4)));
assert(!interval.isBefore(Date(2010, 7, 5)));
assert(!interval.isBefore(Date(2011, 7, 1)));
assert(!interval.isBefore(Date(2012, 1, 6)));
assert(interval.isBefore(Date(2012, 1, 7)));
assert(interval.isBefore(Date(2012, 1, 8)));
assert(interval.isBefore(Date(2013, 1, 7)));
const cdate = Date(2010, 7, 6);
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static assert(__traits(compiles, interval.isBefore(cdate)));
static assert(__traits(compiles, cInterval.isBefore(cdate)));
static assert(__traits(compiles, iInterval.isBefore(cdate)));
//Verify Examples.
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(Date(1994, 12, 24)));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(Date(2000, 1, 5)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(Date(2012, 3, 1)));
}
}
//Test Interval's isBefore(Interval).
unittest
{
version(testStdDateTime)
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
assertThrown!DateTimeException(interval.isBefore(Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assertThrown!DateTimeException(Interval!Date(Date(2010, 7, 4), dur!"days"(0)).isBefore(interval));
assertThrown!DateTimeException(Interval!Date(Date(2010, 7, 4), dur!"days"(0)).isBefore(Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assert(!interval.isBefore(interval));
assert(!interval.isBefore(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
assert(!interval.isBefore(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))));
assert(!interval.isBefore(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))));
assert(!interval.isBefore(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))));
assert(!interval.isBefore(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))));
assert(!interval.isBefore(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))));
assert(!interval.isBefore(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))));
assert(!interval.isBefore(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))));
assert(!interval.isBefore(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))));
assert(!interval.isBefore(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))));
assert(interval.isBefore(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))));
assert(interval.isBefore(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
assert(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3)).isBefore(interval));
assert(!Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)).isBefore(interval));
assert(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4)).isBefore(interval));
assert(!Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5)).isBefore(interval));
assert(!Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)).isBefore(interval));
assert(!Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)).isBefore(interval));
assert(!Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)).isBefore(interval));
assert(!Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)).isBefore(interval));
assert(!Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)).isBefore(interval));
assert(!Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8)).isBefore(interval));
assert(!Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8)).isBefore(interval));
assert(!Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9)).isBefore(interval));
assert(!interval.isBefore(PosInfInterval!Date(Date(2010, 7, 3))));
assert(!interval.isBefore(PosInfInterval!Date(Date(2010, 7, 4))));
assert(!interval.isBefore(PosInfInterval!Date(Date(2010, 7, 5))));
assert(!interval.isBefore(PosInfInterval!Date(Date(2012, 1, 6))));
assert(interval.isBefore(PosInfInterval!Date(Date(2012, 1, 7))));
assert(interval.isBefore(PosInfInterval!Date(Date(2012, 1, 8))));
assert(!interval.isBefore(NegInfInterval!Date(Date(2010, 7, 3))));
assert(!interval.isBefore(NegInfInterval!Date(Date(2010, 7, 4))));
assert(!interval.isBefore(NegInfInterval!Date(Date(2010, 7, 5))));
assert(!interval.isBefore(NegInfInterval!Date(Date(2012, 1, 6))));
assert(!interval.isBefore(NegInfInterval!Date(Date(2012, 1, 7))));
assert(!interval.isBefore(NegInfInterval!Date(Date(2012, 1, 8))));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, interval.isBefore(interval)));
static assert(__traits(compiles, interval.isBefore(cInterval)));
static assert(__traits(compiles, interval.isBefore(iInterval)));
static assert(__traits(compiles, interval.isBefore(posInfInterval)));
static assert(__traits(compiles, interval.isBefore(cPosInfInterval)));
static assert(__traits(compiles, interval.isBefore(iPosInfInterval)));
static assert(__traits(compiles, interval.isBefore(negInfInterval)));
static assert(__traits(compiles, interval.isBefore(cNegInfInterval)));
static assert(__traits(compiles, interval.isBefore(iNegInfInterval)));
static assert(__traits(compiles, cInterval.isBefore(interval)));
static assert(__traits(compiles, cInterval.isBefore(cInterval)));
static assert(__traits(compiles, cInterval.isBefore(iInterval)));
static assert(__traits(compiles, cInterval.isBefore(posInfInterval)));
static assert(__traits(compiles, cInterval.isBefore(cPosInfInterval)));
static assert(__traits(compiles, cInterval.isBefore(iPosInfInterval)));
static assert(__traits(compiles, cInterval.isBefore(negInfInterval)));
static assert(__traits(compiles, cInterval.isBefore(cNegInfInterval)));
static assert(__traits(compiles, cInterval.isBefore(iNegInfInterval)));
static assert(__traits(compiles, iInterval.isBefore(interval)));
static assert(__traits(compiles, iInterval.isBefore(cInterval)));
static assert(__traits(compiles, iInterval.isBefore(iInterval)));
static assert(__traits(compiles, iInterval.isBefore(posInfInterval)));
static assert(__traits(compiles, iInterval.isBefore(cPosInfInterval)));
static assert(__traits(compiles, iInterval.isBefore(iPosInfInterval)));
static assert(__traits(compiles, iInterval.isBefore(negInfInterval)));
static assert(__traits(compiles, iInterval.isBefore(cNegInfInterval)));
static assert(__traits(compiles, iInterval.isBefore(iNegInfInterval)));
//Verify Examples.
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(Interval!Date(Date(2012, 3, 1), Date(2013, 5, 1))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(PosInfInterval!Date(Date(1999, 5, 4))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(PosInfInterval!Date(Date(2013, 3, 7))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(NegInfInterval!Date(Date(1996, 5, 4))));
}
}
//Test Interval's isAfter(time point).
unittest
{
version(testStdDateTime)
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
assertThrown!DateTimeException(Interval!Date(Date(2010, 7, 4), dur!"days"(0)).isAfter(Date(2010, 7, 4)));
assert(interval.isAfter(Date(2009, 7, 4)));
assert(interval.isAfter(Date(2010, 7, 3)));
assert(!interval.isAfter(Date(2010, 7, 4)));
assert(!interval.isAfter(Date(2010, 7, 5)));
assert(!interval.isAfter(Date(2011, 7, 1)));
assert(!interval.isAfter(Date(2012, 1, 6)));
assert(!interval.isAfter(Date(2012, 1, 7)));
assert(!interval.isAfter(Date(2012, 1, 8)));
assert(!interval.isAfter(Date(2013, 1, 7)));
const cdate = Date(2010, 7, 6);
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static assert(__traits(compiles, interval.isAfter(cdate)));
static assert(__traits(compiles, cInterval.isAfter(cdate)));
static assert(__traits(compiles, iInterval.isAfter(cdate)));
//Verify Examples.
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(Date(1994, 12, 24)));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(Date(2000, 1, 5)));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(Date(2012, 3, 1)));
}
}
//Test Interval's isAfter(Interval).
unittest
{
version(testStdDateTime)
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
assertThrown!DateTimeException(interval.isAfter(Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assertThrown!DateTimeException(Interval!Date(Date(2010, 7, 4), dur!"days"(0)).isAfter(interval));
assertThrown!DateTimeException(Interval!Date(Date(2010, 7, 4), dur!"days"(0)).isAfter(Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assert(!interval.isAfter(interval));
assert(interval.isAfter(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
assert(!interval.isAfter(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))));
assert(interval.isAfter(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))));
assert(!interval.isAfter(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))));
assert(!interval.isAfter(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))));
assert(!interval.isAfter(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))));
assert(!interval.isAfter(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))));
assert(!interval.isAfter(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))));
assert(!interval.isAfter(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))));
assert(!interval.isAfter(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))));
assert(!interval.isAfter(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))));
assert(!interval.isAfter(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
assert(!Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3)).isAfter(interval));
assert(!Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)).isAfter(interval));
assert(!Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4)).isAfter(interval));
assert(!Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5)).isAfter(interval));
assert(!Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)).isAfter(interval));
assert(!Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)).isAfter(interval));
assert(!Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)).isAfter(interval));
assert(!Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)).isAfter(interval));
assert(!Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)).isAfter(interval));
assert(!Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8)).isAfter(interval));
assert(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8)).isAfter(interval));
assert(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9)).isAfter(interval));
assert(!interval.isAfter(PosInfInterval!Date(Date(2010, 7, 3))));
assert(!interval.isAfter(PosInfInterval!Date(Date(2010, 7, 4))));
assert(!interval.isAfter(PosInfInterval!Date(Date(2010, 7, 5))));
assert(!interval.isAfter(PosInfInterval!Date(Date(2012, 1, 6))));
assert(!interval.isAfter(PosInfInterval!Date(Date(2012, 1, 7))));
assert(!interval.isAfter(PosInfInterval!Date(Date(2012, 1, 8))));
assert(interval.isAfter(NegInfInterval!Date(Date(2010, 7, 3))));
assert(interval.isAfter(NegInfInterval!Date(Date(2010, 7, 4))));
assert(!interval.isAfter(NegInfInterval!Date(Date(2010, 7, 5))));
assert(!interval.isAfter(NegInfInterval!Date(Date(2012, 1, 6))));
assert(!interval.isAfter(NegInfInterval!Date(Date(2012, 1, 7))));
assert(!interval.isAfter(NegInfInterval!Date(Date(2012, 1, 8))));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, interval.isAfter(interval)));
static assert(__traits(compiles, interval.isAfter(cInterval)));
static assert(__traits(compiles, interval.isAfter(iInterval)));
static assert(__traits(compiles, interval.isAfter(posInfInterval)));
static assert(__traits(compiles, interval.isAfter(cPosInfInterval)));
static assert(__traits(compiles, interval.isAfter(iPosInfInterval)));
static assert(__traits(compiles, interval.isAfter(negInfInterval)));
static assert(__traits(compiles, interval.isAfter(cNegInfInterval)));
static assert(__traits(compiles, interval.isAfter(iNegInfInterval)));
static assert(__traits(compiles, cInterval.isAfter(interval)));
static assert(__traits(compiles, cInterval.isAfter(cInterval)));
static assert(__traits(compiles, cInterval.isAfter(iInterval)));
static assert(__traits(compiles, cInterval.isAfter(posInfInterval)));
static assert(__traits(compiles, cInterval.isAfter(cPosInfInterval)));
static assert(__traits(compiles, cInterval.isAfter(iPosInfInterval)));
static assert(__traits(compiles, cInterval.isAfter(negInfInterval)));
static assert(__traits(compiles, cInterval.isAfter(cNegInfInterval)));
static assert(__traits(compiles, cInterval.isAfter(iNegInfInterval)));
static assert(__traits(compiles, iInterval.isAfter(interval)));
static assert(__traits(compiles, iInterval.isAfter(cInterval)));
static assert(__traits(compiles, iInterval.isAfter(iInterval)));
static assert(__traits(compiles, iInterval.isAfter(posInfInterval)));
static assert(__traits(compiles, iInterval.isAfter(cPosInfInterval)));
static assert(__traits(compiles, iInterval.isAfter(iPosInfInterval)));
static assert(__traits(compiles, iInterval.isAfter(negInfInterval)));
static assert(__traits(compiles, iInterval.isAfter(cNegInfInterval)));
static assert(__traits(compiles, iInterval.isAfter(iNegInfInterval)));
//Verify Examples.
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(PosInfInterval!Date(Date(1999, 5, 4))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(NegInfInterval!Date(Date(1996, 1, 2))));
}
}
//Test Interval's intersects().
unittest
{
version(testStdDateTime)
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
assertThrown!DateTimeException(interval.intersects(Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assertThrown!DateTimeException(Interval!Date(Date(2010, 7, 4), dur!"days"(0)).intersects(interval));
assertThrown!DateTimeException(Interval!Date(Date(2010, 7, 4), dur!"days"(0)).intersects(Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assert(interval.intersects(interval));
assert(!interval.intersects(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
assert(interval.intersects(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))));
assert(!interval.intersects(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))));
assert(interval.intersects(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))));
assert(interval.intersects(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))));
assert(interval.intersects(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))));
assert(interval.intersects(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))));
assert(interval.intersects(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))));
assert(interval.intersects(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))));
assert(interval.intersects(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))));
assert(!interval.intersects(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))));
assert(!interval.intersects(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
assert(!Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3)).intersects(interval));
assert(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)).intersects(interval));
assert(!Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4)).intersects(interval));
assert(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5)).intersects(interval));
assert(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)).intersects(interval));
assert(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)).intersects(interval));
assert(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)).intersects(interval));
assert(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)).intersects(interval));
assert(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)).intersects(interval));
assert(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8)).intersects(interval));
assert(!Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8)).intersects(interval));
assert(!Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9)).intersects(interval));
assert(interval.intersects(PosInfInterval!Date(Date(2010, 7, 3))));
assert(interval.intersects(PosInfInterval!Date(Date(2010, 7, 4))));
assert(interval.intersects(PosInfInterval!Date(Date(2010, 7, 5))));
assert(interval.intersects(PosInfInterval!Date(Date(2012, 1, 6))));
assert(!interval.intersects(PosInfInterval!Date(Date(2012, 1, 7))));
assert(!interval.intersects(PosInfInterval!Date(Date(2012, 1, 8))));
assert(!interval.intersects(NegInfInterval!Date(Date(2010, 7, 3))));
assert(!interval.intersects(NegInfInterval!Date(Date(2010, 7, 4))));
assert(interval.intersects(NegInfInterval!Date(Date(2010, 7, 5))));
assert(interval.intersects(NegInfInterval!Date(Date(2012, 1, 6))));
assert(interval.intersects(NegInfInterval!Date(Date(2012, 1, 7))));
assert(interval.intersects(NegInfInterval!Date(Date(2012, 1, 8))));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, interval.intersects(interval)));
static assert(__traits(compiles, interval.intersects(cInterval)));
static assert(__traits(compiles, interval.intersects(iInterval)));
static assert(__traits(compiles, interval.intersects(posInfInterval)));
static assert(__traits(compiles, interval.intersects(cPosInfInterval)));
static assert(__traits(compiles, interval.intersects(iPosInfInterval)));
static assert(__traits(compiles, interval.intersects(negInfInterval)));
static assert(__traits(compiles, interval.intersects(cNegInfInterval)));
static assert(__traits(compiles, interval.intersects(iNegInfInterval)));
static assert(__traits(compiles, cInterval.intersects(interval)));
static assert(__traits(compiles, cInterval.intersects(cInterval)));
static assert(__traits(compiles, cInterval.intersects(iInterval)));
static assert(__traits(compiles, cInterval.intersects(posInfInterval)));
static assert(__traits(compiles, cInterval.intersects(cPosInfInterval)));
static assert(__traits(compiles, cInterval.intersects(iPosInfInterval)));
static assert(__traits(compiles, cInterval.intersects(negInfInterval)));
static assert(__traits(compiles, cInterval.intersects(cNegInfInterval)));
static assert(__traits(compiles, cInterval.intersects(iNegInfInterval)));
static assert(__traits(compiles, iInterval.intersects(interval)));
static assert(__traits(compiles, iInterval.intersects(cInterval)));
static assert(__traits(compiles, iInterval.intersects(iInterval)));
static assert(__traits(compiles, iInterval.intersects(posInfInterval)));
static assert(__traits(compiles, iInterval.intersects(cPosInfInterval)));
static assert(__traits(compiles, iInterval.intersects(iPosInfInterval)));
static assert(__traits(compiles, iInterval.intersects(negInfInterval)));
static assert(__traits(compiles, iInterval.intersects(cNegInfInterval)));
static assert(__traits(compiles, iInterval.intersects(iNegInfInterval)));
//Verify Examples.
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(PosInfInterval!Date(Date(1999, 5, 4))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(PosInfInterval!Date(Date(2012, 3, 1))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(NegInfInterval!Date(Date(1996, 1, 2))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(NegInfInterval!Date(Date(2000, 1, 2))));
}
}
//Test Interval's intersection().
unittest
{
version(testStdDateTime)
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
assertThrown!DateTimeException(interval.intersection(Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assertThrown!DateTimeException(Interval!Date(Date(2010, 7, 4), dur!"days"(0)).intersection(interval));
assertThrown!DateTimeException(Interval!Date(Date(2010, 7, 4), dur!"days"(0)).intersection(Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assertThrown!DateTimeException(interval.intersection(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
assertThrown!DateTimeException(interval.intersection(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))));
assertThrown!DateTimeException(interval.intersection(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))));
assertThrown!DateTimeException(interval.intersection(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
assertThrown!DateTimeException(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3)).intersection(interval));
assertThrown!DateTimeException(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4)).intersection(interval));
assertThrown!DateTimeException(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8)).intersection(interval));
assertThrown!DateTimeException(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9)).intersection(interval));
assertThrown!DateTimeException(interval.intersection(PosInfInterval!Date(Date(2012, 1, 7))));
assertThrown!DateTimeException(interval.intersection(PosInfInterval!Date(Date(2012, 1, 8))));
assertThrown!DateTimeException(interval.intersection(NegInfInterval!Date(Date(2010, 7, 3))));
assertThrown!DateTimeException(interval.intersection(NegInfInterval!Date(Date(2010, 7, 4))));
_assertPred!"=="(interval.intersection(interval), interval);
_assertPred!"=="(interval.intersection(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(interval.intersection(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))),
Interval!Date(Date(2010, 7, 4), Date(2010, 7, 5)));
_assertPred!"=="(interval.intersection(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(interval.intersection(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(interval.intersection(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))),
Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)));
_assertPred!"=="(interval.intersection(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))),
Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)));
_assertPred!"=="(interval.intersection(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))),
Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)));
_assertPred!"=="(interval.intersection(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))),
Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)).intersection(interval),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5)).intersection(interval),
Interval!Date(Date(2010, 7, 4), Date(2010, 7, 5)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)).intersection(interval),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)).intersection(interval),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)).intersection(interval),
Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)).intersection(interval),
Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)).intersection(interval),
Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8)).intersection(interval),
Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)));
_assertPred!"=="(interval.intersection(PosInfInterval!Date(Date(2010, 7, 3))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(interval.intersection(PosInfInterval!Date(Date(2010, 7, 4))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(interval.intersection(PosInfInterval!Date(Date(2010, 7, 5))),
Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)));
_assertPred!"=="(interval.intersection(PosInfInterval!Date(Date(2012, 1, 6))),
Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)));
_assertPred!"=="(interval.intersection(NegInfInterval!Date(Date(2010, 7, 5))),
Interval!Date(Date(2010, 7, 4), Date(2010, 7, 5)));
_assertPred!"=="(interval.intersection(NegInfInterval!Date(Date(2012, 1, 6))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 6)));
_assertPred!"=="(interval.intersection(NegInfInterval!Date(Date(2012, 1, 7))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(interval.intersection(NegInfInterval!Date(Date(2012, 1, 8))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, interval.intersection(interval)));
static assert(__traits(compiles, interval.intersection(cInterval)));
static assert(__traits(compiles, interval.intersection(iInterval)));
static assert(__traits(compiles, interval.intersection(posInfInterval)));
static assert(__traits(compiles, interval.intersection(cPosInfInterval)));
static assert(__traits(compiles, interval.intersection(iPosInfInterval)));
static assert(__traits(compiles, interval.intersection(negInfInterval)));
static assert(__traits(compiles, interval.intersection(cNegInfInterval)));
static assert(__traits(compiles, interval.intersection(iNegInfInterval)));
static assert(__traits(compiles, cInterval.intersection(interval)));
static assert(__traits(compiles, cInterval.intersection(cInterval)));
static assert(__traits(compiles, cInterval.intersection(iInterval)));
static assert(__traits(compiles, cInterval.intersection(posInfInterval)));
static assert(__traits(compiles, cInterval.intersection(cPosInfInterval)));
static assert(__traits(compiles, cInterval.intersection(iPosInfInterval)));
static assert(__traits(compiles, cInterval.intersection(negInfInterval)));
static assert(__traits(compiles, cInterval.intersection(cNegInfInterval)));
static assert(__traits(compiles, cInterval.intersection(iNegInfInterval)));
static assert(__traits(compiles, iInterval.intersection(interval)));
static assert(__traits(compiles, iInterval.intersection(cInterval)));
static assert(__traits(compiles, iInterval.intersection(iInterval)));
static assert(__traits(compiles, iInterval.intersection(posInfInterval)));
static assert(__traits(compiles, iInterval.intersection(cPosInfInterval)));
static assert(__traits(compiles, iInterval.intersection(iPosInfInterval)));
static assert(__traits(compiles, iInterval.intersection(negInfInterval)));
static assert(__traits(compiles, iInterval.intersection(cNegInfInterval)));
static assert(__traits(compiles, iInterval.intersection(iNegInfInterval)));
//Verify Examples.
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) == Interval!Date(Date(1996, 1 , 2), Date(2000, 8, 2)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))) == Interval!Date(Date(1999, 1 , 12), Date(2011, 9, 17)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(PosInfInterval!Date(Date(1990, 7, 6))) == Interval!Date(Date(1996, 1 , 2), Date(2012, 3, 1)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(PosInfInterval!Date(Date(1999, 1, 12))) == Interval!Date(Date(1999, 1 , 12), Date(2012, 3, 1)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(NegInfInterval!Date(Date(1999, 7, 6))) == Interval!Date(Date(1996, 1 , 2), Date(1999, 7, 6)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(NegInfInterval!Date(Date(2013, 1, 12))) == Interval!Date(Date(1996, 1 , 2), Date(2012, 3, 1)));
}
}
//Test Interval's isAdjacent().
unittest
{
version(testStdDateTime)
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static void testInterval(in Interval!Date interval1, in Interval!Date interval2)
{
interval1.isAdjacent(interval2);
}
assertThrown!DateTimeException(testInterval(interval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assertThrown!DateTimeException(testInterval(Interval!Date(Date(2010, 7, 4), dur!"days"(0)), interval));
assertThrown!DateTimeException(testInterval(Interval!Date(Date(2010, 7, 4), dur!"days"(0)), Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assert(!interval.isAdjacent(interval));
assert(!interval.isAdjacent(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
assert(!interval.isAdjacent(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))));
assert(interval.isAdjacent(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))));
assert(!interval.isAdjacent(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))));
assert(!interval.isAdjacent(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))));
assert(!interval.isAdjacent(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))));
assert(!interval.isAdjacent(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))));
assert(!interval.isAdjacent(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))));
assert(!interval.isAdjacent(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))));
assert(!interval.isAdjacent(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))));
assert(interval.isAdjacent(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))));
assert(!interval.isAdjacent(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
assert(!Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3)).isAdjacent(interval));
assert(!Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)).isAdjacent(interval));
assert(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4)).isAdjacent(interval));
assert(!Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5)).isAdjacent(interval));
assert(!Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)).isAdjacent(interval));
assert(!Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)).isAdjacent(interval));
assert(!Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)).isAdjacent(interval));
assert(!Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)).isAdjacent(interval));
assert(!Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)).isAdjacent(interval));
assert(!Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8)).isAdjacent(interval));
assert(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8)).isAdjacent(interval));
assert(!Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9)).isAdjacent(interval));
assert(!interval.isAdjacent(PosInfInterval!Date(Date(2010, 7, 3))));
assert(!interval.isAdjacent(PosInfInterval!Date(Date(2010, 7, 4))));
assert(!interval.isAdjacent(PosInfInterval!Date(Date(2010, 7, 5))));
assert(!interval.isAdjacent(PosInfInterval!Date(Date(2012, 1, 6))));
assert(interval.isAdjacent(PosInfInterval!Date(Date(2012, 1, 7))));
assert(!interval.isAdjacent(PosInfInterval!Date(Date(2012, 1, 8))));
assert(!interval.isAdjacent(NegInfInterval!Date(Date(2010, 7, 3))));
assert(interval.isAdjacent(NegInfInterval!Date(Date(2010, 7, 4))));
assert(!interval.isAdjacent(NegInfInterval!Date(Date(2010, 7, 5))));
assert(!interval.isAdjacent(NegInfInterval!Date(Date(2012, 1, 6))));
assert(!interval.isAdjacent(NegInfInterval!Date(Date(2012, 1, 7))));
assert(!interval.isAdjacent(NegInfInterval!Date(Date(2012, 1, 8))));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, interval.isAdjacent(interval)));
static assert(__traits(compiles, interval.isAdjacent(cInterval)));
static assert(__traits(compiles, interval.isAdjacent(iInterval)));
static assert(__traits(compiles, interval.isAdjacent(posInfInterval)));
static assert(__traits(compiles, interval.isAdjacent(cPosInfInterval)));
static assert(__traits(compiles, interval.isAdjacent(iPosInfInterval)));
static assert(__traits(compiles, interval.isAdjacent(negInfInterval)));
static assert(__traits(compiles, interval.isAdjacent(cNegInfInterval)));
static assert(__traits(compiles, interval.isAdjacent(iNegInfInterval)));
static assert(__traits(compiles, cInterval.isAdjacent(interval)));
static assert(__traits(compiles, cInterval.isAdjacent(cInterval)));
static assert(__traits(compiles, cInterval.isAdjacent(iInterval)));
static assert(__traits(compiles, cInterval.isAdjacent(posInfInterval)));
static assert(__traits(compiles, cInterval.isAdjacent(cPosInfInterval)));
static assert(__traits(compiles, cInterval.isAdjacent(iPosInfInterval)));
static assert(__traits(compiles, cInterval.isAdjacent(negInfInterval)));
static assert(__traits(compiles, cInterval.isAdjacent(cNegInfInterval)));
static assert(__traits(compiles, cInterval.isAdjacent(iNegInfInterval)));
static assert(__traits(compiles, iInterval.isAdjacent(interval)));
static assert(__traits(compiles, iInterval.isAdjacent(cInterval)));
static assert(__traits(compiles, iInterval.isAdjacent(iInterval)));
static assert(__traits(compiles, iInterval.isAdjacent(posInfInterval)));
static assert(__traits(compiles, iInterval.isAdjacent(cPosInfInterval)));
static assert(__traits(compiles, iInterval.isAdjacent(iPosInfInterval)));
static assert(__traits(compiles, iInterval.isAdjacent(negInfInterval)));
static assert(__traits(compiles, iInterval.isAdjacent(cNegInfInterval)));
static assert(__traits(compiles, iInterval.isAdjacent(iNegInfInterval)));
//Verify Examples.
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(Interval!Date(Date(1990, 7, 6), Date(1996, 1, 2))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(Interval!Date(Date(2012, 3, 1), Date(2013, 9, 17))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(Interval!Date(Date(1989, 3, 1), Date(2012, 3, 1))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(PosInfInterval!Date(Date(1999, 5, 4))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(PosInfInterval!Date(Date(2012, 3, 1))));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(NegInfInterval!Date(Date(1996, 1, 2))));
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(NegInfInterval!Date(Date(2000, 1, 2))));
}
}
//Test Interval's merge().
unittest
{
version(testStdDateTime)
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static void testInterval(I)(in Interval!Date interval1, in I interval2)
{
interval1.merge(interval2);
}
assertThrown!DateTimeException(testInterval(interval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assertThrown!DateTimeException(testInterval(Interval!Date(Date(2010, 7, 4), dur!"days"(0)), interval));
assertThrown!DateTimeException(testInterval(Interval!Date(Date(2010, 7, 4), dur!"days"(0)), Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assertThrown!DateTimeException(testInterval(interval, Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
assertThrown!DateTimeException(testInterval(interval, Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
assertThrown!DateTimeException(testInterval(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3)), interval));
assertThrown!DateTimeException(testInterval(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9)), interval));
assertThrown!DateTimeException(testInterval(interval, PosInfInterval!Date(Date(2012, 1, 8))));
assertThrown!DateTimeException(testInterval(interval, NegInfInterval!Date(Date(2010, 7, 3))));
_assertPred!"=="(interval.merge(interval), interval);
_assertPred!"=="(interval.merge(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))),
Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)));
_assertPred!"=="(interval.merge(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))),
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
_assertPred!"=="(interval.merge(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))),
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
_assertPred!"=="(interval.merge(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))),
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
_assertPred!"=="(interval.merge(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))),
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)));
_assertPred!"=="(interval.merge(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(interval.merge(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(interval.merge(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(interval.merge(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
_assertPred!"=="(interval.merge(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)).merge(interval),
Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4)).merge(interval),
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5)).merge(interval),
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)).merge(interval),
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)).merge(interval),
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)).merge(interval),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)).merge(interval),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)).merge(interval),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8)).merge(interval),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
_assertPred!"=="(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8)).merge(interval),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
_assertPred!"=="(interval.merge(PosInfInterval!Date(Date(2010, 7, 3))),
PosInfInterval!Date(Date(2010, 7, 3)));
_assertPred!"=="(interval.merge(PosInfInterval!Date(Date(2010, 7, 4))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(interval.merge(PosInfInterval!Date(Date(2010, 7, 5))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(interval.merge(PosInfInterval!Date(Date(2012, 1, 6))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(interval.merge(PosInfInterval!Date(Date(2012, 1, 7))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(interval.merge(NegInfInterval!Date(Date(2010, 7, 4))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(interval.merge(NegInfInterval!Date(Date(2010, 7, 5))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(interval.merge(NegInfInterval!Date(Date(2012, 1, 6))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(interval.merge(NegInfInterval!Date(Date(2012, 1, 7))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(interval.merge(NegInfInterval!Date(Date(2012, 1, 8))),
NegInfInterval!Date(Date(2012, 1, 8)));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, interval.merge(interval)));
static assert(__traits(compiles, interval.merge(cInterval)));
static assert(__traits(compiles, interval.merge(iInterval)));
static assert(__traits(compiles, interval.merge(posInfInterval)));
static assert(__traits(compiles, interval.merge(cPosInfInterval)));
static assert(__traits(compiles, interval.merge(iPosInfInterval)));
static assert(__traits(compiles, interval.merge(negInfInterval)));
static assert(__traits(compiles, interval.merge(cNegInfInterval)));
static assert(__traits(compiles, interval.merge(iNegInfInterval)));
static assert(__traits(compiles, cInterval.merge(interval)));
static assert(__traits(compiles, cInterval.merge(cInterval)));
static assert(__traits(compiles, cInterval.merge(iInterval)));
static assert(__traits(compiles, cInterval.merge(posInfInterval)));
static assert(__traits(compiles, cInterval.merge(cPosInfInterval)));
static assert(__traits(compiles, cInterval.merge(iPosInfInterval)));
static assert(__traits(compiles, cInterval.merge(negInfInterval)));
static assert(__traits(compiles, cInterval.merge(cNegInfInterval)));
static assert(__traits(compiles, cInterval.merge(iNegInfInterval)));
static assert(__traits(compiles, iInterval.merge(interval)));
static assert(__traits(compiles, iInterval.merge(cInterval)));
static assert(__traits(compiles, iInterval.merge(iInterval)));
static assert(__traits(compiles, iInterval.merge(posInfInterval)));
static assert(__traits(compiles, iInterval.merge(cPosInfInterval)));
static assert(__traits(compiles, iInterval.merge(iPosInfInterval)));
static assert(__traits(compiles, iInterval.merge(negInfInterval)));
static assert(__traits(compiles, iInterval.merge(cNegInfInterval)));
static assert(__traits(compiles, iInterval.merge(iNegInfInterval)));
//Verify Examples.
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) == Interval!Date(Date(1990, 7 , 6), Date(2012, 3, 1)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge(Interval!Date(Date(2012, 3, 1), Date(2013, 5, 7))) == Interval!Date(Date(1996, 1 , 2), Date(2013, 5, 7)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge(PosInfInterval!Date(Date(1990, 7, 6))) == PosInfInterval!Date(Date(1990, 7 , 6)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge(PosInfInterval!Date(Date(2012, 3, 1))) == PosInfInterval!Date(Date(1996, 1 , 2)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge(NegInfInterval!Date(Date(1996, 1, 2))) == NegInfInterval!Date(Date(2012, 3 , 1)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge(NegInfInterval!Date(Date(2013, 1, 12))) == NegInfInterval!Date(Date(2013, 1 , 12)));
}
}
//Test Interval's span().
unittest
{
version(testStdDateTime)
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static void testInterval(in Interval!Date interval1, in Interval!Date interval2)
{
interval1.span(interval2);
}
assertThrown!DateTimeException(testInterval(interval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assertThrown!DateTimeException(testInterval(Interval!Date(Date(2010, 7, 4), dur!"days"(0)), interval));
assertThrown!DateTimeException(testInterval(Interval!Date(Date(2010, 7, 4), dur!"days"(0)), Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
_assertPred!"=="(interval.span(interval), interval);
_assertPred!"=="(interval.span(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))),
Interval!Date(Date(2010, 7, 1), Date(2012, 1, 7)));
_assertPred!"=="(interval.span(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))),
Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)));
_assertPred!"=="(interval.span(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))),
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
_assertPred!"=="(interval.span(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))),
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
_assertPred!"=="(interval.span(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))),
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
_assertPred!"=="(interval.span(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))),
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)));
_assertPred!"=="(interval.span(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(interval.span(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(interval.span(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(interval.span(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
_assertPred!"=="(interval.span(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
_assertPred!"=="(interval.span(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 9)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3)).span(interval),
Interval!Date(Date(2010, 7, 1), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)).span(interval),
Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4)).span(interval),
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5)).span(interval),
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)).span(interval),
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)).span(interval),
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)).span(interval),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)).span(interval),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)).span(interval),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8)).span(interval),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
_assertPred!"=="(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8)).span(interval),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
_assertPred!"=="(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9)).span(interval),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 9)));
_assertPred!"=="(interval.span(PosInfInterval!Date(Date(2010, 7, 3))),
PosInfInterval!Date(Date(2010, 7, 3)));
_assertPred!"=="(interval.span(PosInfInterval!Date(Date(2010, 7, 4))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(interval.span(PosInfInterval!Date(Date(2010, 7, 5))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(interval.span(PosInfInterval!Date(Date(2012, 1, 6))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(interval.span(PosInfInterval!Date(Date(2012, 1, 7))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(interval.span(PosInfInterval!Date(Date(2012, 1, 8))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(interval.span(NegInfInterval!Date(Date(2010, 7, 3))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(interval.span(NegInfInterval!Date(Date(2010, 7, 4))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(interval.span(NegInfInterval!Date(Date(2010, 7, 5))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(interval.span(NegInfInterval!Date(Date(2012, 1, 6))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(interval.span(NegInfInterval!Date(Date(2012, 1, 7))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(interval.span(NegInfInterval!Date(Date(2012, 1, 8))),
NegInfInterval!Date(Date(2012, 1, 8)));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, interval.span(interval)));
static assert(__traits(compiles, interval.span(cInterval)));
static assert(__traits(compiles, interval.span(iInterval)));
static assert(__traits(compiles, interval.span(posInfInterval)));
static assert(__traits(compiles, interval.span(cPosInfInterval)));
static assert(__traits(compiles, interval.span(iPosInfInterval)));
static assert(__traits(compiles, interval.span(negInfInterval)));
static assert(__traits(compiles, interval.span(cNegInfInterval)));
static assert(__traits(compiles, interval.span(iNegInfInterval)));
static assert(__traits(compiles, cInterval.span(interval)));
static assert(__traits(compiles, cInterval.span(cInterval)));
static assert(__traits(compiles, cInterval.span(iInterval)));
static assert(__traits(compiles, cInterval.span(posInfInterval)));
static assert(__traits(compiles, cInterval.span(cPosInfInterval)));
static assert(__traits(compiles, cInterval.span(iPosInfInterval)));
static assert(__traits(compiles, cInterval.span(negInfInterval)));
static assert(__traits(compiles, cInterval.span(cNegInfInterval)));
static assert(__traits(compiles, cInterval.span(iNegInfInterval)));
static assert(__traits(compiles, iInterval.span(interval)));
static assert(__traits(compiles, iInterval.span(cInterval)));
static assert(__traits(compiles, iInterval.span(iInterval)));
static assert(__traits(compiles, iInterval.span(posInfInterval)));
static assert(__traits(compiles, iInterval.span(cPosInfInterval)));
static assert(__traits(compiles, iInterval.span(iPosInfInterval)));
static assert(__traits(compiles, iInterval.span(negInfInterval)));
static assert(__traits(compiles, iInterval.span(cNegInfInterval)));
static assert(__traits(compiles, iInterval.span(iNegInfInterval)));
//Verify Examples.
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span(Interval!Date(Date(1990, 7, 6), Date(1991, 1, 8))) == Interval!Date(Date(1990, 7 , 6), Date(2012, 3, 1)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span(Interval!Date(Date(2012, 3, 1), Date(2013, 5, 7))) == Interval!Date(Date(1996, 1 , 2), Date(2013, 5, 7)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span(PosInfInterval!Date(Date(1990, 7, 6))) == PosInfInterval!Date(Date(1990, 7 , 6)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span(PosInfInterval!Date(Date(2050, 1, 1))) == PosInfInterval!Date(Date(1996, 1 , 2)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span(NegInfInterval!Date(Date(1602, 5, 21))) == NegInfInterval!Date(Date(2012, 3 , 1)));
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span(NegInfInterval!Date(Date(2013, 1, 12))) == NegInfInterval!Date(Date(2013, 1 , 12)));
}
}
//Test Interval's shift(duration).
unittest
{
version(testStdDateTime)
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static void testIntervalFail(Interval!Date interval, in Duration duration)
{
interval.shift(duration);
}
assertThrown!DateTimeException(testIntervalFail(Interval!Date(Date(2010, 7, 4), dur!"days"(0)), dur!"days"(1)));
static void testInterval(I)(I interval, in Duration duration, in I expected, size_t line = __LINE__)
{
interval.shift(duration);
_assertPred!"=="(interval, expected, "", __FILE__, line);
}
testInterval(interval, dur!"days"(22), Interval!Date(Date(2010, 7, 26), Date(2012, 1, 29)));
testInterval(interval, dur!"days"(-22), Interval!Date(Date(2010, 6, 12), Date(2011, 12, 16)));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static assert(!__traits(compiles, cInterval.shift(dur!"days"(5))));
static assert(!__traits(compiles, iInterval.shift(dur!"days"(5))));
//Verify Examples.
auto interval1 = Interval!Date(Date(1996, 1, 2), Date(2012, 4, 5));
auto interval2 = Interval!Date(Date(1996, 1, 2), Date(2012, 4, 5));
interval1.shift(dur!"days"(50));
assert(interval1 == Interval!Date(Date(1996, 2, 21), Date(2012, 5, 25)));
interval2.shift(dur!"days"(-50));
assert(interval2 == Interval!Date(Date(1995, 11, 13), Date(2012, 2, 15)));
}
}
//Test Interval's shift(int, int, AllowDayOverflow).
unittest
{
version(testStdDateTime)
{
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static void testIntervalFail(Interval!Date interval, int years, int months)
{
interval.shift(years, months);
}
assertThrown!DateTimeException(testIntervalFail(Interval!Date(Date(2010, 7, 4), dur!"days"(0)), 1, 0));
static void testInterval(I)(I interval, int years, int months, AllowDayOverflow allow, in I expected, size_t line = __LINE__)
{
interval.shift(years, months, allow);
_assertPred!"=="(interval, expected, "", __FILE__, line);
}
testInterval(interval, 5, 0, AllowDayOverflow.yes, Interval!Date(Date(2015, 7, 4), Date(2017, 1, 7)));
testInterval(interval, -5, 0, AllowDayOverflow.yes, Interval!Date(Date(2005, 7, 4), Date(2007, 1, 7)));
auto interval2 = Interval!Date(Date(2000, 1, 29), Date(2010, 5, 31));
testInterval(interval2, 1, 1, AllowDayOverflow.yes, Interval!Date(Date(2001, 3, 1), Date(2011, 7, 1)));
testInterval(interval2, 1, -1, AllowDayOverflow.yes, Interval!Date(Date(2000, 12, 29), Date(2011, 5, 1)));
testInterval(interval2, -1, -1, AllowDayOverflow.yes, Interval!Date(Date(1998, 12, 29), Date(2009, 5, 1)));
testInterval(interval2, -1, 1, AllowDayOverflow.yes, Interval!Date(Date(1999, 3, 1), Date(2009, 7, 1)));
testInterval(interval2, 1, 1, AllowDayOverflow.no, Interval!Date(Date(2001, 2, 28), Date(2011, 6, 30)));
testInterval(interval2, 1, -1, AllowDayOverflow.no, Interval!Date(Date(2000, 12, 29), Date(2011, 4, 30)));
testInterval(interval2, -1, -1, AllowDayOverflow.no, Interval!Date(Date(1998, 12, 29), Date(2009, 4, 30)));
testInterval(interval2, -1, 1, AllowDayOverflow.no, Interval!Date(Date(1999, 2, 28), Date(2009, 6, 30)));
}
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static assert(!__traits(compiles, cInterval.shift(5)));
static assert(!__traits(compiles, iInterval.shift(5)));
//Verify Examples.
auto interval1 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));
auto interval2 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));
interval1.shift(2);
assert(interval1 == Interval!Date(Date(1998, 1, 2), Date(2014, 3, 1)));
interval2.shift(-2);
assert(interval2 == Interval!Date(Date(1994, 1, 2), Date(2010, 3, 1)));
}
}
//Test Interval's expand(Duration).
unittest
{
version(testStdDateTime)
{
auto interval = Interval!Date(Date(2000, 7, 4), Date(2012, 1, 7));
static void testIntervalFail(I)(I interval, in Duration duration)
{
interval.expand(duration);
}
assertThrown!DateTimeException(testIntervalFail(Interval!Date(Date(2010, 7, 4), dur!"days"(0)), dur!"days"(1)));
assertThrown!DateTimeException(testIntervalFail(Interval!Date(Date(2010, 7, 4), Date(2010, 7, 5)), dur!"days"(-5)));
static void testInterval(I)(I interval, in Duration duration, in I expected, size_t line = __LINE__)
{
interval.expand(duration);
_assertPred!"=="(interval, expected, "", __FILE__, line);
}
testInterval(interval, dur!"days"(22), Interval!Date(Date(2000, 6, 12), Date(2012, 1, 29)));
testInterval(interval, dur!"days"(-22), Interval!Date(Date(2000, 7, 26), Date(2011, 12, 16)));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static assert(!__traits(compiles, cInterval.expand(dur!"days"(5))));
static assert(!__traits(compiles, iInterval.expand(dur!"days"(5))));
//Verify Examples.
auto interval1 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));
auto interval2 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));
interval1.expand(dur!"days"(2));
assert(interval1 == Interval!Date(Date(1995, 12, 31), Date(2012, 3, 3)));
interval2.expand(dur!"days"(-2));
assert(interval2 == Interval!Date(Date(1996, 1, 4), Date(2012, 2, 28)));
}
}
//Test Interval's expand(int, int, AllowDayOverflow, Direction)
unittest
{
version(testStdDateTime)
{
{
auto interval = Interval!Date(Date(2000, 7, 4), Date(2012, 1, 7));
static void testIntervalFail(Interval!Date interval, int years, int months)
{
interval.expand(years, months);
}
assertThrown!DateTimeException(testIntervalFail(Interval!Date(Date(2010, 7, 4), dur!"days"(0)), 1, 0));
assertThrown!DateTimeException(testIntervalFail(Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)), -5, 0));
static void testInterval(I)(I interval, int years, int months, AllowDayOverflow allow, Direction dir, in I expected, size_t line = __LINE__)
{
interval.expand(years, months, allow, dir);
_assertPred!"=="(interval, expected, "", __FILE__, line);
}
testInterval(interval, 5, 0, AllowDayOverflow.yes, Direction.both, Interval!Date(Date(1995, 7, 4), Date(2017, 1, 7)));
testInterval(interval, -5, 0, AllowDayOverflow.yes, Direction.both, Interval!Date(Date(2005, 7, 4), Date(2007, 1, 7)));
testInterval(interval, 5, 0, AllowDayOverflow.yes, Direction.fwd, Interval!Date(Date(2000, 7, 4), Date(2017, 1, 7)));
testInterval(interval, -5, 0, AllowDayOverflow.yes, Direction.fwd, Interval!Date(Date(2000, 7, 4), Date(2007, 1, 7)));
testInterval(interval, 5, 0, AllowDayOverflow.yes, Direction.bwd, Interval!Date(Date(1995, 7, 4), Date(2012, 1, 7)));
testInterval(interval, -5, 0, AllowDayOverflow.yes, Direction.bwd, Interval!Date(Date(2005, 7, 4), Date(2012, 1, 7)));
auto interval2 = Interval!Date(Date(2000, 1, 29), Date(2010, 5, 31));
testInterval(interval2, 1, 1, AllowDayOverflow.yes, Direction.both, Interval!Date(Date(1998, 12, 29), Date(2011, 7, 1)));
testInterval(interval2, 1, -1, AllowDayOverflow.yes, Direction.both, Interval!Date(Date(1999, 3, 1), Date(2011, 5, 1)));
testInterval(interval2, -1, -1, AllowDayOverflow.yes, Direction.both, Interval!Date(Date(2001, 3, 1), Date(2009, 5, 1)));
testInterval(interval2, -1, 1, AllowDayOverflow.yes, Direction.both, Interval!Date(Date(2000, 12, 29), Date(2009, 7, 1)));
testInterval(interval2, 1, 1, AllowDayOverflow.no, Direction.both, Interval!Date(Date(1998, 12, 29), Date(2011, 6, 30)));
testInterval(interval2, 1, -1, AllowDayOverflow.no, Direction.both, Interval!Date(Date(1999, 2, 28), Date(2011, 4, 30)));
testInterval(interval2, -1, -1, AllowDayOverflow.no, Direction.both, Interval!Date(Date(2001, 2, 28), Date(2009, 4, 30)));
testInterval(interval2, -1, 1, AllowDayOverflow.no, Direction.both, Interval!Date(Date(2000, 12, 29), Date(2009, 6, 30)));
testInterval(interval2, 1, 1, AllowDayOverflow.yes, Direction.fwd, Interval!Date(Date(2000, 1, 29), Date(2011, 7, 1)));
testInterval(interval2, 1, -1, AllowDayOverflow.yes, Direction.fwd, Interval!Date(Date(2000, 1, 29), Date(2011, 5, 1)));
testInterval(interval2, -1, -1, AllowDayOverflow.yes, Direction.fwd, Interval!Date(Date(2000, 1, 29), Date(2009, 5, 1)));
testInterval(interval2, -1, 1, AllowDayOverflow.yes, Direction.fwd, Interval!Date(Date(2000, 1, 29), Date(2009, 7, 1)));
testInterval(interval2, 1, 1, AllowDayOverflow.no, Direction.fwd, Interval!Date(Date(2000, 1, 29), Date(2011, 6, 30)));
testInterval(interval2, 1, -1, AllowDayOverflow.no, Direction.fwd, Interval!Date(Date(2000, 1, 29), Date(2011, 4, 30)));
testInterval(interval2, -1, -1, AllowDayOverflow.no, Direction.fwd, Interval!Date(Date(2000, 1, 29), Date(2009, 4, 30)));
testInterval(interval2, -1, 1, AllowDayOverflow.no, Direction.fwd, Interval!Date(Date(2000, 1, 29), Date(2009, 6, 30)));
testInterval(interval2, 1, 1, AllowDayOverflow.yes, Direction.bwd, Interval!Date(Date(1998, 12, 29), Date(2010, 5, 31)));
testInterval(interval2, 1, -1, AllowDayOverflow.yes, Direction.bwd, Interval!Date(Date(1999, 3, 1), Date(2010, 5, 31)));
testInterval(interval2, -1, -1, AllowDayOverflow.yes, Direction.bwd, Interval!Date(Date(2001, 3, 1), Date(2010, 5, 31)));
testInterval(interval2, -1, 1, AllowDayOverflow.yes, Direction.bwd, Interval!Date(Date(2000, 12, 29), Date(2010, 5, 31)));
testInterval(interval2, 1, 1, AllowDayOverflow.no, Direction.bwd, Interval!Date(Date(1998, 12, 29), Date(2010, 5, 31)));
testInterval(interval2, 1, -1, AllowDayOverflow.no, Direction.bwd, Interval!Date(Date(1999, 2, 28), Date(2010, 5, 31)));
testInterval(interval2, -1, -1, AllowDayOverflow.no, Direction.bwd, Interval!Date(Date(2001, 2, 28), Date(2010, 5, 31)));
testInterval(interval2, -1, 1, AllowDayOverflow.no, Direction.bwd, Interval!Date(Date(2000, 12, 29), Date(2010, 5, 31)));
}
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static assert(!__traits(compiles, cInterval.expand(5)));
static assert(!__traits(compiles, iInterval.expand(5)));
//Verify Examples.
auto interval1 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));
auto interval2 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));
interval1.expand(2);
assert(interval1 == Interval!Date(Date(1994, 1, 2), Date(2014, 3, 1)));
interval2.expand(-2);
assert(interval2 == Interval!Date(Date(1998, 1, 2), Date(2010, 3, 1)));
}
}
//Test Interval's fwdRange.
unittest
{
version(testStdDateTime)
{
{
auto interval = Interval!Date(Date(2010, 9, 19), Date(2010, 9, 21));
static void testInterval1(Interval!Date interval)
{
interval.fwdRange(everyDayOfWeek!Date(DayOfWeek.fri));
}
assertThrown!DateTimeException(testInterval1(Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
static void testInterval2(Interval!Date interval)
{
interval.fwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri)).popFront();
}
assertThrown!DateTimeException(testInterval2(interval));
assert(!interval.fwdRange(everyDayOfWeek!Date(DayOfWeek.fri)).empty);
assert(interval.fwdRange(everyDayOfWeek!Date(DayOfWeek.fri), PopFirst.yes).empty);
_assertPred!"=="(Interval!Date(Date(2010, 9, 12), Date(2010, 10, 1)).fwdRange(everyDayOfWeek!Date(DayOfWeek.fri)).front,
Date(2010, 9, 12));
_assertPred!"=="(Interval!Date(Date(2010, 9, 12), Date(2010, 10, 1)).fwdRange(everyDayOfWeek!Date(DayOfWeek.fri), PopFirst.yes).front,
Date(2010, 9, 17));
}
//Verify Examples.
{
auto interval = Interval!Date(Date(2010, 9, 1), Date(2010, 9, 9));
auto func = (in Date date)
{
if((date.day & 1) == 0)
return date + dur!"days"(2);
return date + dur!"days"(1);
};
auto range = interval.fwdRange(func);
assert(range.front == Date(2010, 9, 1)); //An odd day. Using PopFirst.yes would have made this Date(2010, 9, 2).
range.popFront();
assert(range.front == Date(2010, 9, 2));
range.popFront();
assert(range.front == Date(2010, 9, 4));
range.popFront();
assert(range.front == Date(2010, 9, 6));
range.popFront();
assert(range.front == Date(2010, 9, 8));
range.popFront();
assert(range.empty);
}
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static assert(__traits(compiles, cInterval.fwdRange(everyDayOfWeek!Date(DayOfWeek.fri))));
static assert(__traits(compiles, iInterval.fwdRange(everyDayOfWeek!Date(DayOfWeek.fri))));
}
}
//Test Interval's bwdRange.
unittest
{
version(testStdDateTime)
{
{
auto interval = Interval!Date(Date(2010, 9, 19), Date(2010, 9, 21));
static void testInterval1(Interval!Date interval)
{
interval.bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri));
}
assertThrown!DateTimeException(testInterval1(Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
static void testInterval2(Interval!Date interval)
{
interval.bwdRange(everyDayOfWeek!(Date, Direction.fwd)(DayOfWeek.fri)).popFront();
}
assertThrown!DateTimeException(testInterval2(interval));
assert(!interval.bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri)).empty);
assert(interval.bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri), PopFirst.yes).empty);
_assertPred!"=="(Interval!Date(Date(2010, 9, 19), Date(2010, 10, 1)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri)).front,
Date(2010, 10, 1));
_assertPred!"=="(Interval!Date(Date(2010, 9, 19), Date(2010, 10, 1)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri), PopFirst.yes).front,
Date(2010, 9, 24));
}
//Verify Examples.
{
auto interval = Interval!Date(Date(2010, 9, 1), Date(2010, 9, 9));
auto func = (in Date date)
{
if((date.day & 1) == 0)
return date - dur!"days"(2);
return date - dur!"days"(1);
};
auto range = interval.bwdRange(func);
assert(range.front == Date(2010, 9, 9)); //An odd day. Using PopFirst.yes would have made this Date(2010, 9, 8).
range.popFront();
assert(range.front == Date(2010, 9, 8));
range.popFront();
assert(range.front == Date(2010, 9, 6));
range.popFront();
assert(range.front == Date(2010, 9, 4));
range.popFront();
assert(range.front == Date(2010, 9, 2));
range.popFront();
assert(range.empty);
}
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static assert(__traits(compiles, cInterval.bwdRange(everyDayOfWeek!Date(DayOfWeek.fri))));
static assert(__traits(compiles, iInterval.bwdRange(everyDayOfWeek!Date(DayOfWeek.fri))));
}
}
//Test Interval's toString().
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)).toString(), "[2010-Jul-04 - 2012-Jan-07)");
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static assert(__traits(compiles, cInterval.toString()));
static assert(__traits(compiles, iInterval.toString()));
}
}
/++
Represents an interval of time which has positive infinity as its end point.
Any ranges which iterate over a $(D PosInfInterval) are infinite. So, the
main purpose of using $(D PosInfInterval) is to create an infinite range
which starts at a fixed point in time and goes to positive infinity.
+/
struct PosInfInterval(TP)
{
public:
/++
Params:
begin = The time point which begins the interval.
Examples:
--------------------
auto interval = PosInfInterval!Date(Date(1996, 1, 2));
--------------------
+/
this(in TP begin) pure nothrow
{
_begin = cast(TP)begin;
}
/++
Params:
rhs = The $(D PosInfInterval) to assign to this one.
+/
/+ref+/ PosInfInterval opAssign(const ref PosInfInterval rhs) pure nothrow
{
_begin = cast(TP)rhs._begin;
return this;
}
/++
Params:
rhs = The $(D PosInfInterval) to assign to this one.
+/
/+ref+/ PosInfInterval opAssign(PosInfInterval rhs) pure nothrow
{
_begin = cast(TP)rhs._begin;
return this;
}
/++
The starting point of the interval. It is included in the interval.
Examples:
--------------------
assert(PosInfInterval!Date(Date(1996, 1, 2)).begin == Date(1996, 1, 2));
--------------------
+/
@property TP begin() const pure nothrow
{
return cast(TP)_begin;
}
/++
The starting point of the interval. It is included in the interval.
Params:
timePoint = The time point to set $(D begin) to.
+/
@property void begin(TP timePoint) pure nothrow
{
_begin = timePoint;
}
/++
Whether the interval's length is 0. Always returns false.
Examples:
--------------------
assert(!PosInfInterval!Date(Date(1996, 1, 2)).empty);
--------------------
+/
@property bool empty() const pure nothrow
{
return false;
}
/++
Whether the given time point is within this interval.
Params:
timePoint = The time point to check for inclusion in this interval.
Examples:
--------------------
assert(!PosInfInterval!Date(Date(1996, 1, 2)).contains(Date(1994, 12, 24)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).contains(Date(2000, 1, 5)));
--------------------
+/
bool contains(TP timePoint) const pure nothrow
{
return timePoint >= _begin;
}
/++
Whether the given interval is completely within this interval.
Params:
interval = The interval to check for inclusion in this interval.
Throws:
$(D DateTimeException) if the given interval is empty.
Examples:
--------------------
assert(!PosInfInterval!Date(Date(1996, 1, 2)).contains(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(PosInfInterval!Date(Date(1996, 1, 2)).contains(
Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(PosInfInterval!Date(Date(1996, 1, 2)).contains(
Interval!Date(Date(1998, 2, 28), Date(2013, 5, 1))));
--------------------
+/
bool contains(in Interval!TP interval) const pure
{
interval._enforceNotEmpty();
return interval._begin >= _begin;
}
/++
Whether the given interval is completely within this interval.
Params:
interval = The interval to check for inclusion in this interval.
Examples:
--------------------
assert(PosInfInterval!Date(Date(1996, 1, 2)).contains(
PosInfInterval!Date(Date(1999, 5, 4))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).contains(
PosInfInterval!Date(Date(1995, 7, 2))));
--------------------
+/
bool contains(in PosInfInterval interval) const pure nothrow
{
return interval._begin >= _begin;
}
/++
Whether the given interval is completely within this interval.
Always returns false because an interval going to positive infinity
can never contain an interval beginning at negative infinity.
Params:
interval = The interval to check for inclusion in this interval.
Examples:
--------------------
assert(!PosInfInterval!Date(Date(1996, 1, 2)).contains(
NegInfInterval!Date(Date(1996, 5, 4))));
--------------------
+/
bool contains(in NegInfInterval!TP interval) const pure nothrow
{
return false;
}
/++
Whether this interval is before the given time point.
Always returns false because an interval going to positive infinity
can never be before any time point.
Params:
timePoint = The time point to check whether this interval is before
it.
Examples:
--------------------
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(Date(1994, 12, 24)));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(Date(2000, 1, 5)));
--------------------
+/
bool isBefore(in TP timePoint) const pure nothrow
{
return false;
}
/++
Whether this interval is before the given interval and does not
intersect it.
Always returns false (unless the given interval is empty) because an
interval going to positive infinity can never be before any other
interval.
Params:
interval = The interval to check for against this interval.
Throws:
$(D DateTimeException) if the given interval is empty.
Examples:
--------------------
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(
Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
--------------------
+/
bool isBefore(in Interval!TP interval) const pure
{
interval._enforceNotEmpty();
return false;
}
/++
Whether this interval is before the given interval and does not
intersect it.
Always returns false because an interval going to positive infinity can
never be before any other interval.
Params:
interval = The interval to check for against this interval.
Examples:
--------------------
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(
PosInfInterval!Date(Date(1992, 5, 4))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(
PosInfInterval!Date(Date(2013, 3, 7))));
--------------------
+/
bool isBefore(in PosInfInterval interval) const pure nothrow
{
return false;
}
/++
Whether this interval is before the given interval and does not
intersect it.
Always returns false because an interval going to positive infinity can
never be before any other interval.
Params:
interval = The interval to check for against this interval.
Examples:
--------------------
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(
NegInfInterval!Date(Date(1996, 5, 4))));
--------------------
+/
bool isBefore(in NegInfInterval!TP interval) const pure nothrow
{
return false;
}
/++
Whether this interval is after the given time point.
Params:
timePoint = The time point to check whether this interval is after
it.
Examples:
--------------------
assert(PosInfInterval!Date(Date(1996, 1, 2)).isAfter(Date(1994, 12, 24)));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(Date(2000, 1, 5)));
--------------------
+/
bool isAfter(in TP timePoint) const pure nothrow
{
return timePoint < _begin;
}
/++
Whether this interval is after the given interval and does not intersect
it.
Params:
interval = The interval to check against this interval.
Throws:
$(D DateTimeException) if the given interval is empty.
Examples:
--------------------
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(
Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(PosInfInterval!Date(Date(1996, 1, 2)).isAfter(
Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));
--------------------
+/
bool isAfter(in Interval!TP interval) const pure
{
interval._enforceNotEmpty();
return _begin >= interval._end;
}
/++
Whether this interval is after the given interval and does not intersect
it.
Always returns false because an interval going to positive infinity can
never be after another interval going to positive infinity.
Params:
interval = The interval to check against this interval.
Examples:
--------------------
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(
PosInfInterval!Date(Date(1990, 1, 7))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(
PosInfInterval!Date(Date(1999, 5, 4))));
--------------------
+/
bool isAfter(in PosInfInterval interval) const pure nothrow
{
return false;
}
/++
Whether this interval is after the given interval and does not intersect
it.
Params:
interval = The interval to check against this interval.
Examples:
--------------------
assert(PosInfInterval!Date(Date(1996, 1, 2)).isAfter(
NegInfInterval!Date(Date(1996, 1, 2))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(
NegInfInterval!Date(Date(2000, 7, 1))));
--------------------
+/
bool isAfter(in NegInfInterval!TP interval) const pure nothrow
{
return _begin >= interval._end;
}
/++
Whether the given interval overlaps this interval.
Params:
interval = The interval to check for intersection with this interval.
Throws:
$(D DateTimeException) if the given interval is empty.
Examples:
--------------------
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects(
Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).intersects(
Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));
--------------------
+/
bool intersects(in Interval!TP interval) const pure
{
interval._enforceNotEmpty();
return interval._end > _begin;
}
/++
Whether the given interval overlaps this interval.
Always returns true because two intervals going to positive infinity
always overlap.
Params:
interval = The interval to check for intersection with this
interval.
Examples:
--------------------
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects(
PosInfInterval!Date(Date(1990, 1, 7))));
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects(
PosInfInterval!Date(Date(1999, 5, 4))));
--------------------
+/
bool intersects(in PosInfInterval interval) const pure nothrow
{
return true;
}
/++
Whether the given interval overlaps this interval.
Params:
interval = The interval to check for intersection with this
interval.
Examples:
--------------------
assert(!PosInfInterval!Date(Date(1996, 1, 2)).intersects(
NegInfInterval!Date(Date(1996, 1, 2))));
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects(
NegInfInterval!Date(Date(2000, 7, 1))));
--------------------
+/
bool intersects(in NegInfInterval!TP interval) const pure nothrow
{
return _begin < interval._end;
}
/++
Returns the intersection of two intervals
Params:
interval = The interval to intersect with this interval.
Throws:
$(D DateTimeException) if the two intervals do not intersect or if
the given interval is empty.
Examples:
--------------------
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) ==
Interval!Date(Date(1996, 1 , 2), Date(2000, 8, 2)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection(
Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))) ==
Interval!Date(Date(1999, 1 , 12), Date(2011, 9, 17)));
--------------------
+/
Interval!TP intersection(in Interval!TP interval) const
{
enforce(this.intersects(interval), new DateTimeException(format("%s and %s do not intersect.", this, interval)));
auto begin = _begin > interval._begin ? _begin : interval._begin;
return Interval!TP(begin, interval._end);
}
/++
Returns the intersection of two intervals
Params:
interval = The interval to intersect with this interval.
Examples:
--------------------
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection(
PosInfInterval!Date(Date(1990, 7, 6))) ==
PosInfInterval!Date(Date(1996, 1 , 2)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection(
PosInfInterval!Date(Date(1999, 1, 12))) ==
PosInfInterval!Date(Date(1999, 1 , 12)));
--------------------
+/
PosInfInterval intersection(in PosInfInterval interval) const pure nothrow
{
return PosInfInterval(_begin < interval._begin ? interval._begin : _begin);
}
/++
Returns the intersection of two intervals
Params:
interval = The interval to intersect with this interval.
Throws:
$(D DateTimeException) if the two intervals do not intersect.
Examples:
--------------------
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection(
NegInfInterval!Date(Date(1999, 7, 6))) ==
Interval!Date(Date(1996, 1 , 2), Date(1999, 7, 6)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection(
NegInfInterval!Date(Date(2013, 1, 12))) ==
Interval!Date(Date(1996, 1 , 2), Date(2013, 1, 12)));
--------------------
+/
Interval!TP intersection(in NegInfInterval!TP interval) const
{
enforce(this.intersects(interval), new DateTimeException(format("%s and %s do not intersect.", this, interval)));
return Interval!TP(_begin, interval._end);
}
/++
Whether the given interval is adjacent to this interval.
Params:
interval = The interval to check whether its adjecent to this
interval.
Throws:
$(D DateTimeException) if the given interval is empty.
Examples:
--------------------
assert(PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent(
Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));
assert(!PosInfInterval!Date(Date(1999, 1, 12)).isAdjacent(
Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
--------------------
+/
bool isAdjacent(in Interval!TP interval) const pure
{
interval._enforceNotEmpty();
return _begin == interval._end;
}
/++
Whether the given interval is adjacent to this interval.
Always returns false because two intervals going to positive infinity
can never be adjacent to one another.
Params:
interval = The interval to check whether its adjecent to this
interval.
Examples:
--------------------
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent(
PosInfInterval!Date(Date(1990, 1, 7))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent(
PosInfInterval!Date(Date(1996, 1, 2))));
--------------------
+/
bool isAdjacent(in PosInfInterval interval) const pure nothrow
{
return false;
}
/++
Whether the given interval is adjacent to this interval.
Params:
interval = The interval to check whether its adjecent to this
interval.
Examples:
--------------------
assert(PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent(
NegInfInterval!Date(Date(1996, 1, 2))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent(
NegInfInterval!Date(Date(2000, 7, 1))));
--------------------
+/
bool isAdjacent(in NegInfInterval!TP interval) const pure nothrow
{
return _begin == interval._end;
}
/++
Returns the union of two intervals
Params:
interval = The interval to merge with this interval.
Throws:
$(D DateTimeException) if the two intervals do not intersect and are
not adjacent or if the given interval is empty.
Note:
There is no overload for $(D merge) which takes a
$(D NegInfInterval). This is because you can't have an interval
which goes from negative infinity to positive infinity.
Examples:
--------------------
assert(PosInfInterval!Date(Date(1996, 1, 2)).merge(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) ==
PosInfInterval!Date(Date(1990, 7 , 6)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).merge(
Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))) ==
PosInfInterval!Date(Date(1996, 1 , 2)));
--------------------
+/
PosInfInterval merge(in Interval!TP interval) const
{
enforce(this.isAdjacent(interval) || this.intersects(interval),
new DateTimeException(format("%s and %s are not adjacent and do not intersect.", this, interval)));
return PosInfInterval(_begin < interval._begin ? _begin : interval._begin);
}
/++
Returns the union of two intervals
Params:
interval = The interval to merge with this interval.
Note:
There is no overload for $(D merge) which takes a
$(D NegInfInterval). This is because you can't have an interval
which goes from negative infinity to positive infinity.
Examples:
--------------------
assert(PosInfInterval!Date(Date(1996, 1, 2)).merge(
PosInfInterval!Date(Date(1990, 7, 6))) ==
PosInfInterval!Date(Date(1990, 7 , 6)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).merge(
PosInfInterval!Date(Date(1999, 1, 12))) ==
PosInfInterval!Date(Date(1996, 1 , 2)));
--------------------
+/
PosInfInterval merge(in PosInfInterval interval) const pure nothrow
{
return PosInfInterval(_begin < interval._begin ? _begin : interval._begin);
}
/++
Returns an interval that covers from the earliest time point of two
intervals up to (but not including) the latest time point of two
intervals.
Params:
interval = The interval to create a span together with this
interval.
Throws:
$(D DateTimeException) if the given interval is empty.
Note:
There is no overload for $(D span) which takes a
$(D NegInfInterval). This is because you can't have an interval
which goes from negative infinity to positive infinity.
Examples:
--------------------
assert(PosInfInterval!Date(Date(1996, 1, 2)).span(
Interval!Date(Date(500, 8, 9), Date(1602, 1, 31))) ==
PosInfInterval!Date(Date(500, 8, 9)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).span(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) ==
PosInfInterval!Date(Date(1990, 7 , 6)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).span(
Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))) ==
PosInfInterval!Date(Date(1996, 1 , 2)));
--------------------
+/
PosInfInterval span(in Interval!TP interval) const pure
{
interval._enforceNotEmpty();
return PosInfInterval(_begin < interval._begin ? _begin : interval._begin);
}
/++
Returns an interval that covers from the earliest time point of two
intervals up to (but not including) the latest time point of two
intervals.
Params:
interval = The interval to create a span together with this
interval.
Note:
There is no overload for $(D span) which takes a
$(D NegInfInterval). This is because you can't have an interval
which goes from negative infinity to positive infinity.
Examples:
--------------------
assert(PosInfInterval!Date(Date(1996, 1, 2)).span(
PosInfInterval!Date(Date(1990, 7, 6))) ==
PosInfInterval!Date(Date(1990, 7 , 6)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).span(
PosInfInterval!Date(Date(1999, 1, 12))) ==
PosInfInterval!Date(Date(1996, 1 , 2)));
--------------------
+/
PosInfInterval span(in PosInfInterval interval) const pure nothrow
{
return PosInfInterval(_begin < interval._begin ? _begin : interval._begin);
}
/++
Shifts the $(D begin) of this interval forward or backwards in time by
the given duration (a positive duration shifts the interval forward; a
negative duration shifts it backward). Effectively, it does
$(D begin += duration).
Params:
duration = The duration to shift the interval by.
Examples:
--------------------
auto interval1 = PosInfInterval!Date(Date(1996, 1, 2));
auto interval2 = PosInfInterval!Date(Date(1996, 1, 2));
interval1.shift(dur!"days"(50));
assert(interval1 == PosInfInterval!Date(Date(1996, 2, 21)));
interval2.shift(dur!"days"(-50));
assert(interval2 == PosInfInterval!Date(Date(1995, 11, 13)));
--------------------
+/
void shift(D)(D duration) pure nothrow
if(__traits(compiles, begin + duration))
{
_begin += duration;
}
static if(__traits(compiles, begin.add!"months"(1)) &&
__traits(compiles, begin.add!"years"(1)))
{
/++
Shifts the $(D begin) of this interval forward or backwards in time
by the given number of years and/or months (a positive number of years
and months shifts the interval forward; a negative number shifts it
backward). It adds the years the given years and months to
$(D begin). It effectively calls $(D add!"years"()) and then
$(D add!"months"()) on $(D begin) with the given number of years and
months.
Params:
years = The number of years to shift the interval by.
months = The number of months to shift the interval by.
allowOverflow = Whether the days should be allowed to overflow
on $(D begin), causing its month to increment.
Throws:
$(D DateTimeException) if this interval is empty or if the
resulting interval would be invalid.
Examples:
--------------------
auto interval1 = PosInfInterval!Date(Date(1996, 1, 2));
auto interval2 = PosInfInterval!Date(Date(1996, 1, 2));
interval1.shift(dur!"days"(50));
assert(interval1 == PosInfInterval!Date(Date(1996, 2, 21)));
interval2.shift(dur!"days"(-50));
assert(interval2 == PosInfInterval!Date(Date(1995, 11, 13)));
--------------------
+/
void shift(T)(T years, T months = 0, AllowDayOverflow allowOverflow = AllowDayOverflow.yes)
if(isIntegral!T)
{
auto begin = _begin;
begin.add!"years"(years, allowOverflow);
begin.add!"months"(months, allowOverflow);
_begin = begin;
}
}
/++
Expands the interval backwards in time. Effectively, it does
$(D begin -= duration).
Params:
duration = The duration to expand the interval by.
dir = The direction in time to expand the interval.
Examples:
--------------------
auto interval1 = PosInfInterval!Date(Date(1996, 1, 2));
auto interval2 = PosInfInterval!Date(Date(1996, 1, 2));
interval1.expand(dur!"days"(2));
assert(interval1 == PosInfInterval!Date(Date(1995, 12, 31)));
interval2.expand(dur!"days"(-2));
assert(interval2 == PosInfInterval!Date(Date(1996, 1, 4)));
--------------------
+/
void expand(D)(D duration) pure nothrow
if(__traits(compiles, begin + duration))
{
_begin -= duration;
}
static if(__traits(compiles, begin.add!"months"(1)) &&
__traits(compiles, begin.add!"years"(1)))
{
/++
Expands the interval forwards and/or backwards in time. Effectively,
it subtracts the given number of months/years from $(D begin).
Params:
years = The number of years to expand the interval by.
months = The number of months to expand the interval by.
allowOverflow = Whether the days should be allowed to overflow
on $(D begin), causing its month to increment.
Throws:
$(D DateTimeException) if this interval is empty or if the
resulting interval would be invalid.
Examples:
--------------------
auto interval1 = PosInfInterval!Date(Date(1996, 1, 2));
auto interval2 = PosInfInterval!Date(Date(1996, 1, 2));
interval1.expand(2);
assert(interval1 == PosInfInterval!Date(Date(1994, 1, 2)));
interval2.expand(-2);
assert(interval2 == PosInfInterval!Date(Date(1998, 1, 2)));
--------------------
+/
void expand(T)(T years, T months = 0, AllowDayOverflow allowOverflow = AllowDayOverflow.yes)
if(isIntegral!T)
{
auto begin = _begin;
begin.add!"years"(-years, allowOverflow);
begin.add!"months"(-months, allowOverflow);
_begin = begin;
return;
}
}
/++
Returns a range which iterates forward over the interval, starting
at $(D begin), using $(D_PARAM func) to generate each successive time
point.
The range's $(D front) is the interval's $(D begin). $(D_PARAM func) is
used to generate the next $(D front) when $(D popFront) is called. If
$(D_PARAM popFirst) is $(D PopFirst.yes), then $(D popFront) is called
before the range is returned (so that $(D front) is a time point which
$(D_PARAM func) would generate).
If $(D_PARAM func) ever generates a time point less than or equal to the
current $(D front) of the range, then a $(D DateTimeException) will be
thrown.
There are helper functions in this module which generate common
delegates to pass to $(D fwdRange). Their documentation starts with
"Range-generating function," so you can easily search for them.
Params:
func = The function used to generate the time points of the
range over the interval.
popFirst = Whether $(D popFront) should be called on the range
before returning it.
Throws:
$(D DateTimeException) if this interval is empty.
Warning:
$(D_PARAM func) must be logically pure. Ideally, $(D_PARAM func)
would be a function pointer to a pure function, but forcing
$(D_PARAM func) to be pure is far too restrictive to be useful, and
in order to have the ease of use of having functions which generate
functions to pass to $(D fwdRange), $(D_PARAM func) must be a
delegate.
If $(D_PARAM func) retains state which changes as it is called, then
some algorithms will not work correctly, because the range's
$(D save) will have failed to have really saved the range's state.
So, if you want to avoid such bugs, don't pass a delegate which is
not logically pure to $(D fwdRange). If $(D_PARAM func) is given the
same time point with two different calls, it must return the same
result both times.
Of course, none of the functions in this module have this problem,
so it's only relevant if you're creating your own delegate.
Examples:
--------------------
auto interval = PosInfInterval!Date(Date(2010, 9, 1));
auto func = (in Date date) //For iterating over even-numbered days.
{
if((date.day & 1) == 0)
return date + dur!"days"(2);
return date + dur!"days"(1);
};
auto range = interval.fwdRange(func);
//An odd day. Using PopFirst.yes would have made this Date(2010, 9, 2).
assert(range.front == Date(2010, 9, 1));
range.popFront();
assert(range.front == Date(2010, 9, 2));
range.popFront();
assert(range.front == Date(2010, 9, 4));
range.popFront();
assert(range.front == Date(2010, 9, 6));
range.popFront();
assert(range.front == Date(2010, 9, 8));
range.popFront();
assert(!range.empty);
--------------------
+/
PosInfIntervalRange!(TP) fwdRange(TP delegate(in TP) func, PopFirst popFirst = PopFirst.no) const
{
auto range = PosInfIntervalRange!(TP)(this, func);
if(popFirst == PopFirst.yes)
range.popFront();
return range;
}
/+
Converts this interval to a string.
+/
//Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
//have versions of toString() with extra modifiers, so we define one version
//with modifiers and one without.
string toString()
{
return _toStringImpl();
}
/++
Converts this interval to a string.
+/
//Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
//have versions of toString() with extra modifiers, so we define one version
//with modifiers and one without.
string toString() const nothrow
{
return _toStringImpl();
}
private:
/+
Since we have two versions of toString(), we have _toStringImpl()
so that they can share implementations.
+/
string _toStringImpl() const nothrow
{
try
return format("[%s - ∞)", _begin);
catch(Exception e)
assert(0, "format() threw.");
}
TP _begin;
}
//Test PosInfInterval's constructor.
unittest
{
version(testStdDateTime)
{
PosInfInterval!Date(Date.init);
PosInfInterval!TimeOfDay(TimeOfDay.init);
PosInfInterval!DateTime(DateTime.init);
PosInfInterval!SysTime(SysTime(0));
//Verify Examples.
auto interval = PosInfInterval!Date(Date(1996, 1, 2));
}
}
//Test PosInfInterval's begin.
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(PosInfInterval!Date(Date(1, 1, 1)).begin, Date(1, 1, 1));
_assertPred!"=="(PosInfInterval!Date(Date(2010, 1, 1)).begin, Date(2010, 1, 1));
_assertPred!"=="(PosInfInterval!Date(Date(1997, 12, 31)).begin, Date(1997, 12, 31));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
static assert(__traits(compiles, cPosInfInterval.begin));
static assert(__traits(compiles, iPosInfInterval.begin));
//Verify Examples.
assert(PosInfInterval!Date(Date(1996, 1, 2)).begin == Date(1996, 1, 2));
}
}
//Test PosInfInterval's empty.
unittest
{
version(testStdDateTime)
{
assert(!PosInfInterval!Date(Date(2010, 1, 1)).empty);
assert(!PosInfInterval!TimeOfDay(TimeOfDay(0, 30, 0)).empty);
assert(!PosInfInterval!DateTime(DateTime(2010, 1, 1, 0, 30, 0)).empty);
assert(!PosInfInterval!SysTime(SysTime(DateTime(2010, 1, 1, 0, 30, 0))).empty);
const cPosInfInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iPosInfInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
static assert(__traits(compiles, cPosInfInterval.empty));
static assert(__traits(compiles, iPosInfInterval.empty));
//Verify Examples.
assert(!PosInfInterval!Date(Date(1996, 1, 2)).empty);
}
}
//Test PosInfInterval's contains(time point).
unittest
{
version(testStdDateTime)
{
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
assert(!posInfInterval.contains(Date(2009, 7, 4)));
assert(!posInfInterval.contains(Date(2010, 7, 3)));
assert(posInfInterval.contains(Date(2010, 7, 4)));
assert(posInfInterval.contains(Date(2010, 7, 5)));
assert(posInfInterval.contains(Date(2011, 7, 1)));
assert(posInfInterval.contains(Date(2012, 1, 6)));
assert(posInfInterval.contains(Date(2012, 1, 7)));
assert(posInfInterval.contains(Date(2012, 1, 8)));
assert(posInfInterval.contains(Date(2013, 1, 7)));
const cdate = Date(2010, 7, 6);
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
static assert(__traits(compiles, posInfInterval.contains(cdate)));
static assert(__traits(compiles, cPosInfInterval.contains(cdate)));
static assert(__traits(compiles, iPosInfInterval.contains(cdate)));
//Verify Examples.
assert(!PosInfInterval!Date(Date(1996, 1, 2)).contains(Date(1994, 12, 24)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).contains(Date(2000, 1, 5)));
}
}
//Test PosInfInterval's contains(Interval).
unittest
{
version(testStdDateTime)
{
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
static void testInterval(in PosInfInterval!Date posInfInterval, in Interval!Date interval)
{
posInfInterval.contains(interval);
}
assertThrown!DateTimeException(testInterval(posInfInterval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assert(posInfInterval.contains(posInfInterval));
assert(!posInfInterval.contains(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
assert(!posInfInterval.contains(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))));
assert(!posInfInterval.contains(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))));
assert(!posInfInterval.contains(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))));
assert(!posInfInterval.contains(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))));
assert(!posInfInterval.contains(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))));
assert(posInfInterval.contains(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))));
assert(posInfInterval.contains(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))));
assert(posInfInterval.contains(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))));
assert(posInfInterval.contains(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))));
assert(posInfInterval.contains(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))));
assert(posInfInterval.contains(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
assert(!posInfInterval.contains(PosInfInterval!Date(Date(2010, 7, 3))));
assert(posInfInterval.contains(PosInfInterval!Date(Date(2010, 7, 4))));
assert(posInfInterval.contains(PosInfInterval!Date(Date(2010, 7, 5))));
assert(posInfInterval.contains(PosInfInterval!Date(Date(2012, 1, 6))));
assert(posInfInterval.contains(PosInfInterval!Date(Date(2012, 1, 7))));
assert(posInfInterval.contains(PosInfInterval!Date(Date(2012, 1, 8))));
assert(PosInfInterval!Date(Date(2010, 7, 3)).contains(posInfInterval));
assert(PosInfInterval!Date(Date(2010, 7, 4)).contains(posInfInterval));
assert(!PosInfInterval!Date(Date(2010, 7, 5)).contains(posInfInterval));
assert(!PosInfInterval!Date(Date(2012, 1, 6)).contains(posInfInterval));
assert(!PosInfInterval!Date(Date(2012, 1, 7)).contains(posInfInterval));
assert(!PosInfInterval!Date(Date(2012, 1, 8)).contains(posInfInterval));
assert(!posInfInterval.contains(NegInfInterval!Date(Date(2010, 7, 3))));
assert(!posInfInterval.contains(NegInfInterval!Date(Date(2010, 7, 4))));
assert(!posInfInterval.contains(NegInfInterval!Date(Date(2010, 7, 5))));
assert(!posInfInterval.contains(NegInfInterval!Date(Date(2012, 1, 6))));
assert(!posInfInterval.contains(NegInfInterval!Date(Date(2012, 1, 7))));
assert(!posInfInterval.contains(NegInfInterval!Date(Date(2012, 1, 8))));
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, posInfInterval.contains(interval)));
static assert(__traits(compiles, posInfInterval.contains(cInterval)));
static assert(__traits(compiles, posInfInterval.contains(iInterval)));
static assert(__traits(compiles, posInfInterval.contains(posInfInterval)));
static assert(__traits(compiles, posInfInterval.contains(cPosInfInterval)));
static assert(__traits(compiles, posInfInterval.contains(iPosInfInterval)));
static assert(__traits(compiles, posInfInterval.contains(negInfInterval)));
static assert(__traits(compiles, posInfInterval.contains(cNegInfInterval)));
static assert(__traits(compiles, posInfInterval.contains(iNegInfInterval)));
static assert(__traits(compiles, cPosInfInterval.contains(interval)));
static assert(__traits(compiles, cPosInfInterval.contains(cInterval)));
static assert(__traits(compiles, cPosInfInterval.contains(iInterval)));
static assert(__traits(compiles, cPosInfInterval.contains(posInfInterval)));
static assert(__traits(compiles, cPosInfInterval.contains(cPosInfInterval)));
static assert(__traits(compiles, cPosInfInterval.contains(iPosInfInterval)));
static assert(__traits(compiles, cPosInfInterval.contains(negInfInterval)));
static assert(__traits(compiles, cPosInfInterval.contains(cNegInfInterval)));
static assert(__traits(compiles, cPosInfInterval.contains(iNegInfInterval)));
static assert(__traits(compiles, iPosInfInterval.contains(interval)));
static assert(__traits(compiles, iPosInfInterval.contains(cInterval)));
static assert(__traits(compiles, iPosInfInterval.contains(iInterval)));
static assert(__traits(compiles, iPosInfInterval.contains(posInfInterval)));
static assert(__traits(compiles, iPosInfInterval.contains(cPosInfInterval)));
static assert(__traits(compiles, iPosInfInterval.contains(iPosInfInterval)));
static assert(__traits(compiles, iPosInfInterval.contains(negInfInterval)));
static assert(__traits(compiles, iPosInfInterval.contains(cNegInfInterval)));
static assert(__traits(compiles, iPosInfInterval.contains(iNegInfInterval)));
//Verify Examples.
assert(!PosInfInterval!Date(Date(1996, 1, 2)).contains(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(PosInfInterval!Date(Date(1996, 1, 2)).contains(Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(PosInfInterval!Date(Date(1996, 1, 2)).contains(Interval!Date(Date(1998, 2, 28), Date(2013, 5, 1))));
assert(PosInfInterval!Date(Date(1996, 1, 2)).contains(PosInfInterval!Date(Date(1999, 5, 4))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).contains(PosInfInterval!Date(Date(1995, 7, 2))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).contains(NegInfInterval!Date(Date(1996, 5, 4))));
}
}
//Test PosInfInterval's isBefore(time point).
unittest
{
version(testStdDateTime)
{
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
assert(!posInfInterval.isBefore(Date(2009, 7, 3)));
assert(!posInfInterval.isBefore(Date(2010, 7, 3)));
assert(!posInfInterval.isBefore(Date(2010, 7, 4)));
assert(!posInfInterval.isBefore(Date(2010, 7, 5)));
assert(!posInfInterval.isBefore(Date(2011, 7, 1)));
assert(!posInfInterval.isBefore(Date(2012, 1, 6)));
assert(!posInfInterval.isBefore(Date(2012, 1, 7)));
assert(!posInfInterval.isBefore(Date(2012, 1, 8)));
assert(!posInfInterval.isBefore(Date(2013, 1, 7)));
const cdate = Date(2010, 7, 6);
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
static assert(__traits(compiles, posInfInterval.isBefore(cdate)));
static assert(__traits(compiles, cPosInfInterval.isBefore(cdate)));
static assert(__traits(compiles, iPosInfInterval.isBefore(cdate)));
//Verify Examples.
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(Date(1994, 12, 24)));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(Date(2000, 1, 5)));
}
}
//Test PosInfInterval's isBefore(Interval).
unittest
{
version(testStdDateTime)
{
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
static void testInterval(in PosInfInterval!Date posInfInterval, in Interval!Date interval)
{
posInfInterval.isBefore(interval);
}
assertThrown!DateTimeException(testInterval(posInfInterval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assert(!posInfInterval.isBefore(posInfInterval));
assert(!posInfInterval.isBefore(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
assert(!posInfInterval.isBefore(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))));
assert(!posInfInterval.isBefore(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))));
assert(!posInfInterval.isBefore(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))));
assert(!posInfInterval.isBefore(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))));
assert(!posInfInterval.isBefore(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))));
assert(!posInfInterval.isBefore(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))));
assert(!posInfInterval.isBefore(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))));
assert(!posInfInterval.isBefore(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))));
assert(!posInfInterval.isBefore(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))));
assert(!posInfInterval.isBefore(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))));
assert(!posInfInterval.isBefore(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
assert(!posInfInterval.isBefore(PosInfInterval!Date(Date(2010, 7, 3))));
assert(!posInfInterval.isBefore(PosInfInterval!Date(Date(2010, 7, 4))));
assert(!posInfInterval.isBefore(PosInfInterval!Date(Date(2010, 7, 5))));
assert(!posInfInterval.isBefore(PosInfInterval!Date(Date(2012, 1, 6))));
assert(!posInfInterval.isBefore(PosInfInterval!Date(Date(2012, 1, 7))));
assert(!posInfInterval.isBefore(PosInfInterval!Date(Date(2012, 1, 8))));
assert(!PosInfInterval!Date(Date(2010, 7, 3)).isBefore(posInfInterval));
assert(!PosInfInterval!Date(Date(2010, 7, 4)).isBefore(posInfInterval));
assert(!PosInfInterval!Date(Date(2010, 7, 5)).isBefore(posInfInterval));
assert(!PosInfInterval!Date(Date(2012, 1, 6)).isBefore(posInfInterval));
assert(!PosInfInterval!Date(Date(2012, 1, 7)).isBefore(posInfInterval));
assert(!PosInfInterval!Date(Date(2012, 1, 8)).isBefore(posInfInterval));
assert(!posInfInterval.isBefore(NegInfInterval!Date(Date(2010, 7, 3))));
assert(!posInfInterval.isBefore(NegInfInterval!Date(Date(2010, 7, 4))));
assert(!posInfInterval.isBefore(NegInfInterval!Date(Date(2010, 7, 5))));
assert(!posInfInterval.isBefore(NegInfInterval!Date(Date(2012, 1, 6))));
assert(!posInfInterval.isBefore(NegInfInterval!Date(Date(2012, 1, 7))));
assert(!posInfInterval.isBefore(NegInfInterval!Date(Date(2012, 1, 8))));
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, posInfInterval.isBefore(interval)));
static assert(__traits(compiles, posInfInterval.isBefore(cInterval)));
static assert(__traits(compiles, posInfInterval.isBefore(iInterval)));
static assert(__traits(compiles, posInfInterval.isBefore(posInfInterval)));
static assert(__traits(compiles, posInfInterval.isBefore(cPosInfInterval)));
static assert(__traits(compiles, posInfInterval.isBefore(iPosInfInterval)));
static assert(__traits(compiles, posInfInterval.isBefore(negInfInterval)));
static assert(__traits(compiles, posInfInterval.isBefore(cNegInfInterval)));
static assert(__traits(compiles, posInfInterval.isBefore(iNegInfInterval)));
static assert(__traits(compiles, cPosInfInterval.isBefore(interval)));
static assert(__traits(compiles, cPosInfInterval.isBefore(cInterval)));
static assert(__traits(compiles, cPosInfInterval.isBefore(iInterval)));
static assert(__traits(compiles, cPosInfInterval.isBefore(posInfInterval)));
static assert(__traits(compiles, cPosInfInterval.isBefore(cPosInfInterval)));
static assert(__traits(compiles, cPosInfInterval.isBefore(iPosInfInterval)));
static assert(__traits(compiles, cPosInfInterval.isBefore(negInfInterval)));
static assert(__traits(compiles, cPosInfInterval.isBefore(cNegInfInterval)));
static assert(__traits(compiles, cPosInfInterval.isBefore(iNegInfInterval)));
static assert(__traits(compiles, iPosInfInterval.isBefore(interval)));
static assert(__traits(compiles, iPosInfInterval.isBefore(cInterval)));
static assert(__traits(compiles, iPosInfInterval.isBefore(iInterval)));
static assert(__traits(compiles, iPosInfInterval.isBefore(posInfInterval)));
static assert(__traits(compiles, iPosInfInterval.isBefore(cPosInfInterval)));
static assert(__traits(compiles, iPosInfInterval.isBefore(iPosInfInterval)));
static assert(__traits(compiles, iPosInfInterval.isBefore(negInfInterval)));
static assert(__traits(compiles, iPosInfInterval.isBefore(cNegInfInterval)));
static assert(__traits(compiles, iPosInfInterval.isBefore(iNegInfInterval)));
//Verify Examples.
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(PosInfInterval!Date(Date(1992, 5, 4))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(PosInfInterval!Date(Date(2013, 3, 7))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(NegInfInterval!Date(Date(1996, 5, 4))));
}
}
//Test PosInfInterval's isAfter(time point).
unittest
{
version(testStdDateTime)
{
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
assert(posInfInterval.isAfter(Date(2009, 7, 3)));
assert(posInfInterval.isAfter(Date(2010, 7, 3)));
assert(!posInfInterval.isAfter(Date(2010, 7, 4)));
assert(!posInfInterval.isAfter(Date(2010, 7, 5)));
assert(!posInfInterval.isAfter(Date(2011, 7, 1)));
assert(!posInfInterval.isAfter(Date(2012, 1, 6)));
assert(!posInfInterval.isAfter(Date(2012, 1, 7)));
assert(!posInfInterval.isAfter(Date(2012, 1, 8)));
assert(!posInfInterval.isAfter(Date(2013, 1, 7)));
const cdate = Date(2010, 7, 6);
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
static assert(__traits(compiles, posInfInterval.isAfter(cdate)));
static assert(__traits(compiles, cPosInfInterval.isAfter(cdate)));
static assert(__traits(compiles, iPosInfInterval.isAfter(cdate)));
//Verify Examples.
assert(PosInfInterval!Date(Date(1996, 1, 2)).isAfter(Date(1994, 12, 24)));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(Date(2000, 1, 5)));
}
}
//Test PosInfInterval's isAfter(Interval).
unittest
{
version(testStdDateTime)
{
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
static void testInterval(in PosInfInterval!Date posInfInterval, in Interval!Date interval)
{
posInfInterval.isAfter(interval);
}
assertThrown!DateTimeException(testInterval(posInfInterval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assert(!posInfInterval.isAfter(posInfInterval));
assert(posInfInterval.isAfter(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
assert(!posInfInterval.isAfter(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))));
assert(posInfInterval.isAfter(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))));
assert(!posInfInterval.isAfter(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))));
assert(!posInfInterval.isAfter(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))));
assert(!posInfInterval.isAfter(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))));
assert(!posInfInterval.isAfter(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))));
assert(!posInfInterval.isAfter(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))));
assert(!posInfInterval.isAfter(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))));
assert(!posInfInterval.isAfter(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))));
assert(!posInfInterval.isAfter(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))));
assert(!posInfInterval.isAfter(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
assert(!posInfInterval.isAfter(PosInfInterval!Date(Date(2010, 7, 3))));
assert(!posInfInterval.isAfter(PosInfInterval!Date(Date(2010, 7, 4))));
assert(!posInfInterval.isAfter(PosInfInterval!Date(Date(2010, 7, 5))));
assert(!posInfInterval.isAfter(PosInfInterval!Date(Date(2012, 1, 6))));
assert(!posInfInterval.isAfter(PosInfInterval!Date(Date(2012, 1, 7))));
assert(!posInfInterval.isAfter(PosInfInterval!Date(Date(2012, 1, 8))));
assert(!PosInfInterval!Date(Date(2010, 7, 3)).isAfter(posInfInterval));
assert(!PosInfInterval!Date(Date(2010, 7, 4)).isAfter(posInfInterval));
assert(!PosInfInterval!Date(Date(2010, 7, 5)).isAfter(posInfInterval));
assert(!PosInfInterval!Date(Date(2012, 1, 6)).isAfter(posInfInterval));
assert(!PosInfInterval!Date(Date(2012, 1, 7)).isAfter(posInfInterval));
assert(!PosInfInterval!Date(Date(2012, 1, 8)).isAfter(posInfInterval));
assert(posInfInterval.isAfter(NegInfInterval!Date(Date(2010, 7, 3))));
assert(posInfInterval.isAfter(NegInfInterval!Date(Date(2010, 7, 4))));
assert(!posInfInterval.isAfter(NegInfInterval!Date(Date(2010, 7, 5))));
assert(!posInfInterval.isAfter(NegInfInterval!Date(Date(2012, 1, 6))));
assert(!posInfInterval.isAfter(NegInfInterval!Date(Date(2012, 1, 7))));
assert(!posInfInterval.isAfter(NegInfInterval!Date(Date(2012, 1, 8))));
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, posInfInterval.isAfter(interval)));
static assert(__traits(compiles, posInfInterval.isAfter(cInterval)));
static assert(__traits(compiles, posInfInterval.isAfter(iInterval)));
static assert(__traits(compiles, posInfInterval.isAfter(posInfInterval)));
static assert(__traits(compiles, posInfInterval.isAfter(cPosInfInterval)));
static assert(__traits(compiles, posInfInterval.isAfter(iPosInfInterval)));
static assert(__traits(compiles, posInfInterval.isAfter(negInfInterval)));
static assert(__traits(compiles, posInfInterval.isAfter(cNegInfInterval)));
static assert(__traits(compiles, posInfInterval.isAfter(iNegInfInterval)));
static assert(__traits(compiles, cPosInfInterval.isAfter(interval)));
static assert(__traits(compiles, cPosInfInterval.isAfter(cInterval)));
static assert(__traits(compiles, cPosInfInterval.isAfter(iInterval)));
static assert(__traits(compiles, cPosInfInterval.isAfter(posInfInterval)));
static assert(__traits(compiles, cPosInfInterval.isAfter(cPosInfInterval)));
static assert(__traits(compiles, cPosInfInterval.isAfter(iPosInfInterval)));
static assert(__traits(compiles, cPosInfInterval.isAfter(negInfInterval)));
static assert(__traits(compiles, cPosInfInterval.isAfter(cNegInfInterval)));
static assert(__traits(compiles, cPosInfInterval.isAfter(iNegInfInterval)));
static assert(__traits(compiles, iPosInfInterval.isAfter(interval)));
static assert(__traits(compiles, iPosInfInterval.isAfter(cInterval)));
static assert(__traits(compiles, iPosInfInterval.isAfter(iInterval)));
static assert(__traits(compiles, iPosInfInterval.isAfter(posInfInterval)));
static assert(__traits(compiles, iPosInfInterval.isAfter(cPosInfInterval)));
static assert(__traits(compiles, iPosInfInterval.isAfter(iPosInfInterval)));
static assert(__traits(compiles, iPosInfInterval.isAfter(negInfInterval)));
static assert(__traits(compiles, iPosInfInterval.isAfter(cNegInfInterval)));
static assert(__traits(compiles, iPosInfInterval.isAfter(iNegInfInterval)));
//Verify Examples.
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(PosInfInterval!Date(Date(1996, 1, 2)).isAfter(Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(PosInfInterval!Date(Date(1990, 1, 7))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(PosInfInterval!Date(Date(1999, 5, 4))));
assert(PosInfInterval!Date(Date(1996, 1, 2)).isAfter(NegInfInterval!Date(Date(1996, 1, 2))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(NegInfInterval!Date(Date(2000, 7, 1))));
}
}
//Test PosInfInterval's intersects().
unittest
{
version(testStdDateTime)
{
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
static void testInterval(in PosInfInterval!Date posInfInterval, in Interval!Date interval)
{
posInfInterval.intersects(interval);
}
assertThrown!DateTimeException(testInterval(posInfInterval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assert(posInfInterval.intersects(posInfInterval));
assert(!posInfInterval.intersects(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
assert(posInfInterval.intersects(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))));
assert(!posInfInterval.intersects(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))));
assert(posInfInterval.intersects(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))));
assert(posInfInterval.intersects(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))));
assert(posInfInterval.intersects(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))));
assert(posInfInterval.intersects(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))));
assert(posInfInterval.intersects(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))));
assert(posInfInterval.intersects(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))));
assert(posInfInterval.intersects(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))));
assert(posInfInterval.intersects(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))));
assert(posInfInterval.intersects(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
assert(posInfInterval.intersects(PosInfInterval!Date(Date(2010, 7, 3))));
assert(posInfInterval.intersects(PosInfInterval!Date(Date(2010, 7, 4))));
assert(posInfInterval.intersects(PosInfInterval!Date(Date(2010, 7, 5))));
assert(posInfInterval.intersects(PosInfInterval!Date(Date(2012, 1, 6))));
assert(posInfInterval.intersects(PosInfInterval!Date(Date(2012, 1, 7))));
assert(posInfInterval.intersects(PosInfInterval!Date(Date(2012, 1, 8))));
assert(PosInfInterval!Date(Date(2010, 7, 3)).intersects(posInfInterval));
assert(PosInfInterval!Date(Date(2010, 7, 4)).intersects(posInfInterval));
assert(PosInfInterval!Date(Date(2010, 7, 5)).intersects(posInfInterval));
assert(PosInfInterval!Date(Date(2012, 1, 6)).intersects(posInfInterval));
assert(PosInfInterval!Date(Date(2012, 1, 7)).intersects(posInfInterval));
assert(PosInfInterval!Date(Date(2012, 1, 8)).intersects(posInfInterval));
assert(!posInfInterval.intersects(NegInfInterval!Date(Date(2010, 7, 3))));
assert(!posInfInterval.intersects(NegInfInterval!Date(Date(2010, 7, 4))));
assert(posInfInterval.intersects(NegInfInterval!Date(Date(2010, 7, 5))));
assert(posInfInterval.intersects(NegInfInterval!Date(Date(2012, 1, 6))));
assert(posInfInterval.intersects(NegInfInterval!Date(Date(2012, 1, 7))));
assert(posInfInterval.intersects(NegInfInterval!Date(Date(2012, 1, 8))));
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, posInfInterval.intersects(interval)));
static assert(__traits(compiles, posInfInterval.intersects(cInterval)));
static assert(__traits(compiles, posInfInterval.intersects(iInterval)));
static assert(__traits(compiles, posInfInterval.intersects(posInfInterval)));
static assert(__traits(compiles, posInfInterval.intersects(cPosInfInterval)));
static assert(__traits(compiles, posInfInterval.intersects(iPosInfInterval)));
static assert(__traits(compiles, posInfInterval.intersects(negInfInterval)));
static assert(__traits(compiles, posInfInterval.intersects(cNegInfInterval)));
static assert(__traits(compiles, posInfInterval.intersects(iNegInfInterval)));
static assert(__traits(compiles, cPosInfInterval.intersects(interval)));
static assert(__traits(compiles, cPosInfInterval.intersects(cInterval)));
static assert(__traits(compiles, cPosInfInterval.intersects(iInterval)));
static assert(__traits(compiles, cPosInfInterval.intersects(posInfInterval)));
static assert(__traits(compiles, cPosInfInterval.intersects(cPosInfInterval)));
static assert(__traits(compiles, cPosInfInterval.intersects(iPosInfInterval)));
static assert(__traits(compiles, cPosInfInterval.intersects(negInfInterval)));
static assert(__traits(compiles, cPosInfInterval.intersects(cNegInfInterval)));
static assert(__traits(compiles, cPosInfInterval.intersects(iNegInfInterval)));
static assert(__traits(compiles, iPosInfInterval.intersects(interval)));
static assert(__traits(compiles, iPosInfInterval.intersects(cInterval)));
static assert(__traits(compiles, iPosInfInterval.intersects(iInterval)));
static assert(__traits(compiles, iPosInfInterval.intersects(posInfInterval)));
static assert(__traits(compiles, iPosInfInterval.intersects(cPosInfInterval)));
static assert(__traits(compiles, iPosInfInterval.intersects(iPosInfInterval)));
static assert(__traits(compiles, iPosInfInterval.intersects(negInfInterval)));
static assert(__traits(compiles, iPosInfInterval.intersects(cNegInfInterval)));
static assert(__traits(compiles, iPosInfInterval.intersects(iNegInfInterval)));
//Verify Examples.
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects(Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).intersects(Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects(PosInfInterval!Date(Date(1990, 1, 7))));
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects(PosInfInterval!Date(Date(1999, 5, 4))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).intersects(NegInfInterval!Date(Date(1996, 1, 2))));
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects(NegInfInterval!Date(Date(2000, 7, 1))));
}
}
//Test PosInfInterval's intersection().
unittest
{
version(testStdDateTime)
{
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
static void testInterval(I, J)(in I interval1, in J interval2)
{
interval1.intersection(interval2);
}
assertThrown!DateTimeException(testInterval(posInfInterval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assertThrown!DateTimeException(testInterval(posInfInterval, Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
assertThrown!DateTimeException(testInterval(posInfInterval, Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))));
assertThrown!DateTimeException(testInterval(posInfInterval, NegInfInterval!Date(Date(2010, 7, 3))));
assertThrown!DateTimeException(testInterval(posInfInterval, NegInfInterval!Date(Date(2010, 7, 4))));
_assertPred!"=="(posInfInterval.intersection(posInfInterval),
posInfInterval);
_assertPred!"=="(posInfInterval.intersection(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))),
Interval!Date(Date(2010, 7, 4), Date(2013, 7, 3)));
_assertPred!"=="(posInfInterval.intersection(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))),
Interval!Date(Date(2010, 7, 4), Date(2010, 7, 5)));
_assertPred!"=="(posInfInterval.intersection(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(posInfInterval.intersection(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
_assertPred!"=="(posInfInterval.intersection(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))),
Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)));
_assertPred!"=="(posInfInterval.intersection(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))),
Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)));
_assertPred!"=="(posInfInterval.intersection(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))),
Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)));
_assertPred!"=="(posInfInterval.intersection(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))),
Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8)));
_assertPred!"=="(posInfInterval.intersection(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))),
Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8)));
_assertPred!"=="(posInfInterval.intersection(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))),
Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9)));
_assertPred!"=="(posInfInterval.intersection(PosInfInterval!Date(Date(2010, 7, 3))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.intersection(PosInfInterval!Date(Date(2010, 7, 4))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.intersection(PosInfInterval!Date(Date(2010, 7, 5))),
PosInfInterval!Date(Date(2010, 7, 5)));
_assertPred!"=="(posInfInterval.intersection(PosInfInterval!Date(Date(2012, 1, 6))),
PosInfInterval!Date(Date(2012, 1, 6)));
_assertPred!"=="(posInfInterval.intersection(PosInfInterval!Date(Date(2012, 1, 7))),
PosInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(posInfInterval.intersection(PosInfInterval!Date(Date(2012, 1, 8))),
PosInfInterval!Date(Date(2012, 1, 8)));
_assertPred!"=="(PosInfInterval!Date(Date(2010, 7, 3)).intersection(posInfInterval),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(PosInfInterval!Date(Date(2010, 7, 4)).intersection(posInfInterval),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(PosInfInterval!Date(Date(2010, 7, 5)).intersection(posInfInterval),
PosInfInterval!Date(Date(2010, 7, 5)));
_assertPred!"=="(PosInfInterval!Date(Date(2012, 1, 6)).intersection(posInfInterval),
PosInfInterval!Date(Date(2012, 1, 6)));
_assertPred!"=="(PosInfInterval!Date(Date(2012, 1, 7)).intersection(posInfInterval),
PosInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(PosInfInterval!Date(Date(2012, 1, 8)).intersection(posInfInterval),
PosInfInterval!Date(Date(2012, 1, 8)));
_assertPred!"=="(posInfInterval.intersection(NegInfInterval!Date(Date(2010, 7, 5))),
Interval!Date(Date(2010, 7, 4), Date(2010, 7, 5)));
_assertPred!"=="(posInfInterval.intersection(NegInfInterval!Date(Date(2012, 1, 6))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 6)));
_assertPred!"=="(posInfInterval.intersection(NegInfInterval!Date(Date(2012, 1, 7))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
_assertPred!"=="(posInfInterval.intersection(NegInfInterval!Date(Date(2012, 1, 8))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, posInfInterval.intersection(interval)));
static assert(__traits(compiles, posInfInterval.intersection(cInterval)));
static assert(__traits(compiles, posInfInterval.intersection(iInterval)));
static assert(__traits(compiles, posInfInterval.intersection(posInfInterval)));
static assert(__traits(compiles, posInfInterval.intersection(cPosInfInterval)));
static assert(__traits(compiles, posInfInterval.intersection(iPosInfInterval)));
static assert(__traits(compiles, posInfInterval.intersection(negInfInterval)));
static assert(__traits(compiles, posInfInterval.intersection(cNegInfInterval)));
static assert(__traits(compiles, posInfInterval.intersection(iNegInfInterval)));
static assert(__traits(compiles, cPosInfInterval.intersection(interval)));
static assert(__traits(compiles, cPosInfInterval.intersection(cInterval)));
static assert(__traits(compiles, cPosInfInterval.intersection(iInterval)));
static assert(__traits(compiles, cPosInfInterval.intersection(posInfInterval)));
static assert(__traits(compiles, cPosInfInterval.intersection(cPosInfInterval)));
static assert(__traits(compiles, cPosInfInterval.intersection(iPosInfInterval)));
static assert(__traits(compiles, cPosInfInterval.intersection(negInfInterval)));
static assert(__traits(compiles, cPosInfInterval.intersection(cNegInfInterval)));
static assert(__traits(compiles, cPosInfInterval.intersection(iNegInfInterval)));
static assert(__traits(compiles, iPosInfInterval.intersection(interval)));
static assert(__traits(compiles, iPosInfInterval.intersection(cInterval)));
static assert(__traits(compiles, iPosInfInterval.intersection(iInterval)));
static assert(__traits(compiles, iPosInfInterval.intersection(posInfInterval)));
static assert(__traits(compiles, iPosInfInterval.intersection(cPosInfInterval)));
static assert(__traits(compiles, iPosInfInterval.intersection(iPosInfInterval)));
static assert(__traits(compiles, iPosInfInterval.intersection(negInfInterval)));
static assert(__traits(compiles, iPosInfInterval.intersection(cNegInfInterval)));
static assert(__traits(compiles, iPosInfInterval.intersection(iNegInfInterval)));
//Verify Examples.
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) == Interval!Date(Date(1996, 1 , 2), Date(2000, 8, 2)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection(Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))) == Interval!Date(Date(1999, 1 , 12), Date(2011, 9, 17)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection(PosInfInterval!Date(Date(1990, 7, 6))) == PosInfInterval!Date(Date(1996, 1 , 2)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection(PosInfInterval!Date(Date(1999, 1, 12))) == PosInfInterval!Date(Date(1999, 1 , 12)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection(NegInfInterval!Date(Date(1999, 7, 6))) == Interval!Date(Date(1996, 1 , 2), Date(1999, 7, 6)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection(NegInfInterval!Date(Date(2013, 1, 12))) == Interval!Date(Date(1996, 1 , 2), Date(2013, 1, 12)));
}
}
//Test PosInfInterval's isAdjacent().
unittest
{
version(testStdDateTime)
{
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
static void testInterval(in PosInfInterval!Date posInfInterval, in Interval!Date interval)
{
posInfInterval.isAdjacent(interval);
}
assertThrown!DateTimeException(testInterval(posInfInterval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assert(!posInfInterval.isAdjacent(posInfInterval));
assert(!posInfInterval.isAdjacent(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
assert(!posInfInterval.isAdjacent(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))));
assert(posInfInterval.isAdjacent(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))));
assert(!posInfInterval.isAdjacent(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))));
assert(!posInfInterval.isAdjacent(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))));
assert(!posInfInterval.isAdjacent(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))));
assert(!posInfInterval.isAdjacent(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))));
assert(!posInfInterval.isAdjacent(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))));
assert(!posInfInterval.isAdjacent(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))));
assert(!posInfInterval.isAdjacent(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))));
assert(!posInfInterval.isAdjacent(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))));
assert(!posInfInterval.isAdjacent(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
assert(!posInfInterval.isAdjacent(PosInfInterval!Date(Date(2010, 7, 3))));
assert(!posInfInterval.isAdjacent(PosInfInterval!Date(Date(2010, 7, 4))));
assert(!posInfInterval.isAdjacent(PosInfInterval!Date(Date(2010, 7, 5))));
assert(!posInfInterval.isAdjacent(PosInfInterval!Date(Date(2012, 1, 6))));
assert(!posInfInterval.isAdjacent(PosInfInterval!Date(Date(2012, 1, 7))));
assert(!posInfInterval.isAdjacent(PosInfInterval!Date(Date(2012, 1, 8))));
assert(!PosInfInterval!Date(Date(2010, 7, 3)).isAdjacent(posInfInterval));
assert(!PosInfInterval!Date(Date(2010, 7, 4)).isAdjacent(posInfInterval));
assert(!PosInfInterval!Date(Date(2010, 7, 5)).isAdjacent(posInfInterval));
assert(!PosInfInterval!Date(Date(2012, 1, 6)).isAdjacent(posInfInterval));
assert(!PosInfInterval!Date(Date(2012, 1, 7)).isAdjacent(posInfInterval));
assert(!PosInfInterval!Date(Date(2012, 1, 8)).isAdjacent(posInfInterval));
assert(!posInfInterval.isAdjacent(NegInfInterval!Date(Date(2010, 7, 3))));
assert(posInfInterval.isAdjacent(NegInfInterval!Date(Date(2010, 7, 4))));
assert(!posInfInterval.isAdjacent(NegInfInterval!Date(Date(2010, 7, 5))));
assert(!posInfInterval.isAdjacent(NegInfInterval!Date(Date(2012, 1, 6))));
assert(!posInfInterval.isAdjacent(NegInfInterval!Date(Date(2012, 1, 7))));
assert(!posInfInterval.isAdjacent(NegInfInterval!Date(Date(2012, 1, 8))));
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, posInfInterval.isAdjacent(interval)));
static assert(__traits(compiles, posInfInterval.isAdjacent(cInterval)));
static assert(__traits(compiles, posInfInterval.isAdjacent(iInterval)));
static assert(__traits(compiles, posInfInterval.isAdjacent(posInfInterval)));
static assert(__traits(compiles, posInfInterval.isAdjacent(cPosInfInterval)));
static assert(__traits(compiles, posInfInterval.isAdjacent(iPosInfInterval)));
static assert(__traits(compiles, posInfInterval.isAdjacent(negInfInterval)));
static assert(__traits(compiles, posInfInterval.isAdjacent(cNegInfInterval)));
static assert(__traits(compiles, posInfInterval.isAdjacent(iNegInfInterval)));
static assert(__traits(compiles, cPosInfInterval.isAdjacent(interval)));
static assert(__traits(compiles, cPosInfInterval.isAdjacent(cInterval)));
static assert(__traits(compiles, cPosInfInterval.isAdjacent(iInterval)));
static assert(__traits(compiles, cPosInfInterval.isAdjacent(posInfInterval)));
static assert(__traits(compiles, cPosInfInterval.isAdjacent(cPosInfInterval)));
static assert(__traits(compiles, cPosInfInterval.isAdjacent(iPosInfInterval)));
static assert(__traits(compiles, cPosInfInterval.isAdjacent(negInfInterval)));
static assert(__traits(compiles, cPosInfInterval.isAdjacent(cNegInfInterval)));
static assert(__traits(compiles, cPosInfInterval.isAdjacent(iNegInfInterval)));
static assert(__traits(compiles, iPosInfInterval.isAdjacent(interval)));
static assert(__traits(compiles, iPosInfInterval.isAdjacent(cInterval)));
static assert(__traits(compiles, iPosInfInterval.isAdjacent(iInterval)));
static assert(__traits(compiles, iPosInfInterval.isAdjacent(posInfInterval)));
static assert(__traits(compiles, iPosInfInterval.isAdjacent(cPosInfInterval)));
static assert(__traits(compiles, iPosInfInterval.isAdjacent(iPosInfInterval)));
static assert(__traits(compiles, iPosInfInterval.isAdjacent(negInfInterval)));
static assert(__traits(compiles, iPosInfInterval.isAdjacent(cNegInfInterval)));
static assert(__traits(compiles, iPosInfInterval.isAdjacent(iNegInfInterval)));
//Verify Examples.
assert(PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent(Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));
assert(!PosInfInterval!Date(Date(1999, 1, 12)).isAdjacent(Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent(PosInfInterval!Date(Date(1990, 1, 7))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent(PosInfInterval!Date(Date(1996, 1, 2))));
assert(PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent(NegInfInterval!Date(Date(1996, 1, 2))));
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent(NegInfInterval!Date(Date(2000, 7, 1))));
}
}
//Test PosInfInterval's merge().
unittest
{
version(testStdDateTime)
{
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
static void testInterval(in PosInfInterval!Date posInfInterval, in Interval!Date interval)
{
posInfInterval.merge(interval);
}
assertThrown!DateTimeException(testInterval(posInfInterval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assertThrown!DateTimeException(testInterval(posInfInterval, Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
_assertPred!"=="(posInfInterval.merge(posInfInterval),
posInfInterval);
_assertPred!"=="(posInfInterval.merge(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))),
PosInfInterval!Date(Date(2010, 7, 1)));
_assertPred!"=="(posInfInterval.merge(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))),
PosInfInterval!Date(Date(2010, 7, 3)));
_assertPred!"=="(posInfInterval.merge(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))),
PosInfInterval!Date(Date(2010, 7, 3)));
_assertPred!"=="(posInfInterval.merge(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))),
PosInfInterval!Date(Date(2010, 7, 3)));
_assertPred!"=="(posInfInterval.merge(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))),
PosInfInterval!Date(Date(2010, 7, 3)));
_assertPred!"=="(posInfInterval.merge(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.merge(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.merge(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.merge(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.merge(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.merge(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.merge(PosInfInterval!Date(Date(2010, 7, 3))),
PosInfInterval!Date(Date(2010, 7, 3)));
_assertPred!"=="(posInfInterval.merge(PosInfInterval!Date(Date(2010, 7, 4))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.merge(PosInfInterval!Date(Date(2010, 7, 5))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.merge(PosInfInterval!Date(Date(2012, 1, 6))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.merge(PosInfInterval!Date(Date(2012, 1, 7))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.merge(PosInfInterval!Date(Date(2012, 1, 8))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(PosInfInterval!Date(Date(2010, 7, 3)).merge(posInfInterval),
PosInfInterval!Date(Date(2010, 7, 3)));
_assertPred!"=="(PosInfInterval!Date(Date(2010, 7, 4)).merge(posInfInterval),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(PosInfInterval!Date(Date(2010, 7, 5)).merge(posInfInterval),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(PosInfInterval!Date(Date(2012, 1, 6)).merge(posInfInterval),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(PosInfInterval!Date(Date(2012, 1, 7)).merge(posInfInterval),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(PosInfInterval!Date(Date(2012, 1, 8)).merge(posInfInterval),
PosInfInterval!Date(Date(2010, 7, 4)));
static assert(!__traits(compiles, posInfInterval.merge(NegInfInterval!Date(Date(2010, 7, 3)))));
static assert(!__traits(compiles, posInfInterval.merge(NegInfInterval!Date(Date(2010, 7, 4)))));
static assert(!__traits(compiles, posInfInterval.merge(NegInfInterval!Date(Date(2010, 7, 5)))));
static assert(!__traits(compiles, posInfInterval.merge(NegInfInterval!Date(Date(2012, 1, 6)))));
static assert(!__traits(compiles, posInfInterval.merge(NegInfInterval!Date(Date(2012, 1, 7)))));
static assert(!__traits(compiles, posInfInterval.merge(NegInfInterval!Date(Date(2012, 1, 8)))));
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, posInfInterval.merge(interval)));
static assert(__traits(compiles, posInfInterval.merge(cInterval)));
static assert(__traits(compiles, posInfInterval.merge(iInterval)));
static assert(__traits(compiles, posInfInterval.merge(posInfInterval)));
static assert(__traits(compiles, posInfInterval.merge(cPosInfInterval)));
static assert(__traits(compiles, posInfInterval.merge(iPosInfInterval)));
static assert(!__traits(compiles, posInfInterval.merge(negInfInterval)));
static assert(!__traits(compiles, posInfInterval.merge(cNegInfInterval)));
static assert(!__traits(compiles, posInfInterval.merge(iNegInfInterval)));
static assert(__traits(compiles, cPosInfInterval.merge(interval)));
static assert(__traits(compiles, cPosInfInterval.merge(cInterval)));
static assert(__traits(compiles, cPosInfInterval.merge(iInterval)));
static assert(__traits(compiles, cPosInfInterval.merge(posInfInterval)));
static assert(__traits(compiles, cPosInfInterval.merge(cPosInfInterval)));
static assert(__traits(compiles, cPosInfInterval.merge(iPosInfInterval)));
static assert(!__traits(compiles, cPosInfInterval.merge(negInfInterval)));
static assert(!__traits(compiles, cPosInfInterval.merge(cNegInfInterval)));
static assert(!__traits(compiles, cPosInfInterval.merge(iNegInfInterval)));
static assert(__traits(compiles, iPosInfInterval.merge(interval)));
static assert(__traits(compiles, iPosInfInterval.merge(cInterval)));
static assert(__traits(compiles, iPosInfInterval.merge(iInterval)));
static assert(__traits(compiles, iPosInfInterval.merge(posInfInterval)));
static assert(__traits(compiles, iPosInfInterval.merge(cPosInfInterval)));
static assert(__traits(compiles, iPosInfInterval.merge(iPosInfInterval)));
static assert(!__traits(compiles, iPosInfInterval.merge(negInfInterval)));
static assert(!__traits(compiles, iPosInfInterval.merge(cNegInfInterval)));
static assert(!__traits(compiles, iPosInfInterval.merge(iNegInfInterval)));
//Verify Examples.
assert(PosInfInterval!Date(Date(1996, 1, 2)).merge(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) == PosInfInterval!Date(Date(1990, 7 , 6)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).merge(Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))) == PosInfInterval!Date(Date(1996, 1 , 2)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).merge(PosInfInterval!Date(Date(1990, 7, 6))) == PosInfInterval!Date(Date(1990, 7 , 6)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).merge(PosInfInterval!Date(Date(1999, 1, 12))) == PosInfInterval!Date(Date(1996, 1 , 2)));
}
}
//Test PosInfInterval's span().
unittest
{
version(testStdDateTime)
{
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
static void testInterval(in PosInfInterval!Date posInfInterval, in Interval!Date interval)
{
posInfInterval.span(interval);
}
assertThrown!DateTimeException(testInterval(posInfInterval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
_assertPred!"=="(posInfInterval.span(posInfInterval),
posInfInterval);
_assertPred!"=="(posInfInterval.span(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))),
PosInfInterval!Date(Date(2010, 7, 1)));
_assertPred!"=="(posInfInterval.span(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))),
PosInfInterval!Date(Date(2010, 7, 1)));
_assertPred!"=="(posInfInterval.span(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))),
PosInfInterval!Date(Date(2010, 7, 3)));
_assertPred!"=="(posInfInterval.span(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))),
PosInfInterval!Date(Date(2010, 7, 3)));
_assertPred!"=="(posInfInterval.span(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))),
PosInfInterval!Date(Date(2010, 7, 3)));
_assertPred!"=="(posInfInterval.span(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))),
PosInfInterval!Date(Date(2010, 7, 3)));
_assertPred!"=="(posInfInterval.span(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.span(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.span(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.span(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.span(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.span(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.span(PosInfInterval!Date(Date(2010, 7, 3))),
PosInfInterval!Date(Date(2010, 7, 3)));
_assertPred!"=="(posInfInterval.span(PosInfInterval!Date(Date(2010, 7, 4))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.span(PosInfInterval!Date(Date(2010, 7, 5))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.span(PosInfInterval!Date(Date(2012, 1, 6))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.span(PosInfInterval!Date(Date(2012, 1, 7))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(posInfInterval.span(PosInfInterval!Date(Date(2012, 1, 8))),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(PosInfInterval!Date(Date(2010, 7, 3)).span(posInfInterval),
PosInfInterval!Date(Date(2010, 7, 3)));
_assertPred!"=="(PosInfInterval!Date(Date(2010, 7, 4)).span(posInfInterval),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(PosInfInterval!Date(Date(2010, 7, 5)).span(posInfInterval),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(PosInfInterval!Date(Date(2012, 1, 6)).span(posInfInterval),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(PosInfInterval!Date(Date(2012, 1, 7)).span(posInfInterval),
PosInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(PosInfInterval!Date(Date(2012, 1, 8)).span(posInfInterval),
PosInfInterval!Date(Date(2010, 7, 4)));
static assert(!__traits(compiles, posInfInterval.span(NegInfInterval!Date(Date(2010, 7, 3)))));
static assert(!__traits(compiles, posInfInterval.span(NegInfInterval!Date(Date(2010, 7, 4)))));
static assert(!__traits(compiles, posInfInterval.span(NegInfInterval!Date(Date(2010, 7, 5)))));
static assert(!__traits(compiles, posInfInterval.span(NegInfInterval!Date(Date(2012, 1, 6)))));
static assert(!__traits(compiles, posInfInterval.span(NegInfInterval!Date(Date(2012, 1, 7)))));
static assert(!__traits(compiles, posInfInterval.span(NegInfInterval!Date(Date(2012, 1, 8)))));
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, posInfInterval.span(interval)));
static assert(__traits(compiles, posInfInterval.span(cInterval)));
static assert(__traits(compiles, posInfInterval.span(iInterval)));
static assert(__traits(compiles, posInfInterval.span(posInfInterval)));
static assert(__traits(compiles, posInfInterval.span(cPosInfInterval)));
static assert(__traits(compiles, posInfInterval.span(iPosInfInterval)));
static assert(!__traits(compiles, posInfInterval.span(negInfInterval)));
static assert(!__traits(compiles, posInfInterval.span(cNegInfInterval)));
static assert(!__traits(compiles, posInfInterval.span(iNegInfInterval)));
static assert(__traits(compiles, cPosInfInterval.span(interval)));
static assert(__traits(compiles, cPosInfInterval.span(cInterval)));
static assert(__traits(compiles, cPosInfInterval.span(iInterval)));
static assert(__traits(compiles, cPosInfInterval.span(posInfInterval)));
static assert(__traits(compiles, cPosInfInterval.span(cPosInfInterval)));
static assert(__traits(compiles, cPosInfInterval.span(iPosInfInterval)));
static assert(!__traits(compiles, cPosInfInterval.span(negInfInterval)));
static assert(!__traits(compiles, cPosInfInterval.span(cNegInfInterval)));
static assert(!__traits(compiles, cPosInfInterval.span(iNegInfInterval)));
static assert(__traits(compiles, iPosInfInterval.span(interval)));
static assert(__traits(compiles, iPosInfInterval.span(cInterval)));
static assert(__traits(compiles, iPosInfInterval.span(iInterval)));
static assert(__traits(compiles, iPosInfInterval.span(posInfInterval)));
static assert(__traits(compiles, iPosInfInterval.span(cPosInfInterval)));
static assert(__traits(compiles, iPosInfInterval.span(iPosInfInterval)));
static assert(!__traits(compiles, iPosInfInterval.span(negInfInterval)));
static assert(!__traits(compiles, iPosInfInterval.span(cNegInfInterval)));
static assert(!__traits(compiles, iPosInfInterval.span(iNegInfInterval)));
//Verify Examples.
assert(PosInfInterval!Date(Date(1996, 1, 2)).span(Interval!Date(Date(500, 8, 9), Date(1602, 1, 31))) == PosInfInterval!Date(Date(500, 8, 9)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).span(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) == PosInfInterval!Date(Date(1990, 7 , 6)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).span(Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))) == PosInfInterval!Date(Date(1996, 1 , 2)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).span(PosInfInterval!Date(Date(1990, 7, 6))) == PosInfInterval!Date(Date(1990, 7 , 6)));
assert(PosInfInterval!Date(Date(1996, 1, 2)).span(PosInfInterval!Date(Date(1999, 1, 12))) == PosInfInterval!Date(Date(1996, 1 , 2)));
}
}
//Test PosInfInterval's shift().
unittest
{
version(testStdDateTime)
{
auto interval = PosInfInterval!Date(Date(2010, 7, 4));
static void testInterval(I)(I interval, in Duration duration, in I expected, size_t line = __LINE__)
{
interval.shift(duration);
_assertPred!"=="(interval, expected, "", __FILE__, line);
}
testInterval(interval, dur!"days"(22), PosInfInterval!Date(Date(2010, 7, 26)));
testInterval(interval, dur!"days"(-22), PosInfInterval!Date(Date(2010, 6, 12)));
const cInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iInterval = PosInfInterval!Date(Date(2010, 7, 4));
static assert(!__traits(compiles, cInterval.shift(dur!"days"(5))));
static assert(!__traits(compiles, iInterval.shift(dur!"days"(5))));
//Verify Examples.
auto interval1 = PosInfInterval!Date(Date(1996, 1, 2));
auto interval2 = PosInfInterval!Date(Date(1996, 1, 2));
interval1.shift(dur!"days"(50));
assert(interval1 == PosInfInterval!Date(Date(1996, 2, 21)));
interval2.shift(dur!"days"(-50));
assert(interval2 == PosInfInterval!Date(Date(1995, 11, 13)));
}
}
//Test PosInfInterval's shift(int, int, AllowDayOverflow).
unittest
{
version(testStdDateTime)
{
{
auto interval = PosInfInterval!Date(Date(2010, 7, 4));
static void testInterval(I)(I interval, int years, int months, AllowDayOverflow allow, in I expected, size_t line = __LINE__)
{
interval.shift(years, months, allow);
_assertPred!"=="(interval, expected, "", __FILE__, line);
}
testInterval(interval, 5, 0, AllowDayOverflow.yes, PosInfInterval!Date(Date(2015, 7, 4)));
testInterval(interval, -5, 0, AllowDayOverflow.yes, PosInfInterval!Date(Date(2005, 7, 4)));
auto interval2 = PosInfInterval!Date(Date(2000, 1, 29));
testInterval(interval2, 1, 1, AllowDayOverflow.yes, PosInfInterval!Date(Date(2001, 3, 1)));
testInterval(interval2, 1, -1, AllowDayOverflow.yes, PosInfInterval!Date(Date(2000, 12, 29)));
testInterval(interval2, -1, -1, AllowDayOverflow.yes, PosInfInterval!Date(Date(1998, 12, 29)));
testInterval(interval2, -1, 1, AllowDayOverflow.yes, PosInfInterval!Date(Date(1999, 3, 1)));
testInterval(interval2, 1, 1, AllowDayOverflow.no, PosInfInterval!Date(Date(2001, 2, 28)));
testInterval(interval2, 1, -1, AllowDayOverflow.no, PosInfInterval!Date(Date(2000, 12, 29)));
testInterval(interval2, -1, -1, AllowDayOverflow.no, PosInfInterval!Date(Date(1998, 12, 29)));
testInterval(interval2, -1, 1, AllowDayOverflow.no, PosInfInterval!Date(Date(1999, 2, 28)));
}
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
static assert(!__traits(compiles, cPosInfInterval.shift(1)));
static assert(!__traits(compiles, iPosInfInterval.shift(1)));
//Verify Examples.
auto interval1 = PosInfInterval!Date(Date(1996, 1, 2));
auto interval2 = PosInfInterval!Date(Date(1996, 1, 2));
interval1.shift(2);
assert(interval1 == PosInfInterval!Date(Date(1998, 1, 2)));
interval2.shift(-2);
assert(interval2 == PosInfInterval!Date(Date(1994, 1, 2)));
}
}
//Test PosInfInterval's expand().
unittest
{
version(testStdDateTime)
{
auto interval = PosInfInterval!Date(Date(2000, 7, 4));
static void testInterval(I)(I interval, in Duration duration, in I expected, size_t line = __LINE__)
{
interval.expand(duration);
_assertPred!"=="(interval, expected, "", __FILE__, line);
}
testInterval(interval, dur!"days"(22), PosInfInterval!Date(Date(2000, 6, 12)));
testInterval(interval, dur!"days"(-22), PosInfInterval!Date(Date(2000, 7, 26)));
const cInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iInterval = PosInfInterval!Date(Date(2010, 7, 4));
static assert(!__traits(compiles, cInterval.expand(dur!"days"(5))));
static assert(!__traits(compiles, iInterval.expand(dur!"days"(5))));
//Verify Examples.
auto interval1 = PosInfInterval!Date(Date(1996, 1, 2));
auto interval2 = PosInfInterval!Date(Date(1996, 1, 2));
interval1.expand(dur!"days"(2));
assert(interval1 == PosInfInterval!Date(Date(1995, 12, 31)));
interval2.expand(dur!"days"(-2));
assert(interval2 == PosInfInterval!Date(Date(1996, 1, 4)));
}
}
//Test PosInfInterval's expand(int, int, AllowDayOverflow).
unittest
{
version(testStdDateTime)
{
{
auto interval = PosInfInterval!Date(Date(2000, 7, 4));
static void testInterval(I)(I interval, int years, int months, AllowDayOverflow allow, in I expected, size_t line = __LINE__)
{
interval.expand(years, months, allow);
_assertPred!"=="(interval, expected, "", __FILE__, line);
}
testInterval(interval, 5, 0, AllowDayOverflow.yes, PosInfInterval!Date(Date(1995, 7, 4)));
testInterval(interval, -5, 0, AllowDayOverflow.yes, PosInfInterval!Date(Date(2005, 7, 4)));
auto interval2 = PosInfInterval!Date(Date(2000, 1, 29));
testInterval(interval2, 1, 1, AllowDayOverflow.yes, PosInfInterval!Date(Date(1998, 12, 29)));
testInterval(interval2, 1, -1, AllowDayOverflow.yes, PosInfInterval!Date(Date(1999, 3, 1)));
testInterval(interval2, -1, -1, AllowDayOverflow.yes, PosInfInterval!Date(Date(2001, 3, 1)));
testInterval(interval2, -1, 1, AllowDayOverflow.yes, PosInfInterval!Date(Date(2000, 12, 29)));
testInterval(interval2, 1, 1, AllowDayOverflow.no, PosInfInterval!Date(Date(1998, 12, 29)));
testInterval(interval2, 1, -1, AllowDayOverflow.no, PosInfInterval!Date(Date(1999, 2, 28)));
testInterval(interval2, -1, -1, AllowDayOverflow.no, PosInfInterval!Date(Date(2001, 2, 28)));
testInterval(interval2, -1, 1, AllowDayOverflow.no, PosInfInterval!Date(Date(2000, 12, 29)));
}
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
static assert(!__traits(compiles, cPosInfInterval.expand(1)));
static assert(!__traits(compiles, iPosInfInterval.expand(1)));
//Verify Examples.
auto interval1 = PosInfInterval!Date(Date(1996, 1, 2));
auto interval2 = PosInfInterval!Date(Date(1996, 1, 2));
interval1.expand(2);
assert(interval1 == PosInfInterval!Date(Date(1994, 1, 2)));
interval2.expand(-2);
assert(interval2 == PosInfInterval!Date(Date(1998, 1, 2)));
}
}
//Test PosInfInterval's fwdRange().
unittest
{
version(testStdDateTime)
{
auto posInfInterval = PosInfInterval!Date(Date(2010, 9, 19));
static void testInterval(PosInfInterval!Date posInfInterval)
{
posInfInterval.fwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri)).popFront();
}
assertThrown!DateTimeException(testInterval(posInfInterval));
_assertPred!"=="(PosInfInterval!Date(Date(2010, 9, 12)).fwdRange(everyDayOfWeek!Date(DayOfWeek.fri)).front,
Date(2010, 9, 12));
_assertPred!"=="(PosInfInterval!Date(Date(2010, 9, 12)).fwdRange(everyDayOfWeek!Date(DayOfWeek.fri), PopFirst.yes).front,
Date(2010, 9, 17));
//Verify Examples.
auto interval = PosInfInterval!Date(Date(2010, 9, 1));
auto func = (in Date date)
{
if((date.day & 1) == 0)
return date + dur!"days"(2);
return date + dur!"days"(1);
};
auto range = interval.fwdRange(func);
assert(range.front == Date(2010, 9, 1)); //An odd day. Using PopFirst.yes would have made this Date(2010, 9, 2).
range.popFront();
assert(range.front == Date(2010, 9, 2));
range.popFront();
assert(range.front == Date(2010, 9, 4));
range.popFront();
assert(range.front == Date(2010, 9, 6));
range.popFront();
assert(range.front == Date(2010, 9, 8));
range.popFront();
assert(!range.empty);
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
static assert(__traits(compiles, cPosInfInterval.fwdRange(everyDayOfWeek!Date(DayOfWeek.fri))));
static assert(__traits(compiles, iPosInfInterval.fwdRange(everyDayOfWeek!Date(DayOfWeek.fri))));
}
}
//Test PosInfInterval's toString().
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(PosInfInterval!Date(Date(2010, 7, 4)).toString(), "[2010-Jul-04 - ∞)");
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
static assert(__traits(compiles, cPosInfInterval.toString()));
static assert(__traits(compiles, iPosInfInterval.toString()));
}
}
/++
Represents an interval of time which has negative infinity as its starting
point.
Any ranges which iterate over a $(D NegInfInterval) are infinite. So, the
main purpose of using $(D NegInfInterval) is to create an infinite range
which starts at negative infinity and goes to a fixed end point. You would
then iterate over it in reverse.
+/
struct NegInfInterval(TP)
{
public:
/++
Params:
begin = The time point which begins the interval.
Examples:
--------------------
auto interval = PosInfInterval!Date(Date(1996, 1, 2));
--------------------
+/
this(in TP end) pure nothrow
{
_end = cast(TP)end;
}
/++
Params:
rhs = The $(D NegInfInterval) to assign to this one.
+/
/+ref+/ NegInfInterval opAssign(const ref NegInfInterval rhs) pure nothrow
{
_end = cast(TP)rhs._end;
return this;
}
/++
Params:
rhs = The $(D NegInfInterval) to assign to this one.
+/
/+ref+/ NegInfInterval opAssign(NegInfInterval rhs) pure nothrow
{
_end = cast(TP)rhs._end;
return this;
}
/++
The end point of the interval. It is excluded from the interval.
Examples:
--------------------
assert(NegInfInterval!Date(Date(2012, 3, 1)).end == Date(2012, 3, 1));
--------------------
+/
@property TP end() const pure nothrow
{
return cast(TP)_end;
}
/++
The end point of the interval. It is excluded from the interval.
Params:
timePoint = The time point to set end to.
+/
@property void end(TP timePoint) pure nothrow
{
_end = timePoint;
}
/++
Whether the interval's length is 0. Always returns false.
Examples:
--------------------
assert(!NegInfInterval!Date(Date(1996, 1, 2)).empty);
--------------------
+/
@property bool empty() const pure nothrow
{
return false;
}
/++
Whether the given time point is within this interval.
Params:
timePoint = The time point to check for inclusion in this interval.
Examples:
--------------------
assert(NegInfInterval!Date(Date(2012, 3, 1)).contains(Date(1994, 12, 24)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).contains(Date(2000, 1, 5)));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).contains(Date(2012, 3, 1)));
--------------------
+/
bool contains(TP timePoint) const pure nothrow
{
return timePoint < _end;
}
/++
Whether the given interval is completely within this interval.
Params:
interval = The interval to check for inclusion in this interval.
Throws:
$(D DateTimeException) if the given interval is empty.
Examples:
--------------------
assert(NegInfInterval!Date(Date(2012, 3, 1)).contains(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(NegInfInterval!Date(Date(2012, 3, 1)).contains(
Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).contains(
Interval!Date(Date(1998, 2, 28), Date(2013, 5, 1))));
--------------------
+/
bool contains(in Interval!TP interval) const pure
{
interval._enforceNotEmpty();
return interval._end <= _end;
}
/++
Whether the given interval is completely within this interval.
Always returns false because an interval beginning at negative
infinity can never contain an interval going to positive infinity.
Params:
interval = The interval to check for inclusion in this interval.
Examples:
--------------------
assert(!NegInfInterval!Date(Date(2012, 3, 1)).contains(
PosInfInterval!Date(Date(1999, 5, 4))));
--------------------
+/
bool contains(in PosInfInterval!TP interval) const pure nothrow
{
return false;
}
/++
Whether the given interval is completely within this interval.
Params:
interval = The interval to check for inclusion in this interval.
Examples:
--------------------
assert(NegInfInterval!Date(Date(2012, 3, 1)).contains(
NegInfInterval!Date(Date(1996, 5, 4))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).contains(
NegInfInterval!Date(Date(2013, 7, 9))));
--------------------
+/
bool contains(in NegInfInterval interval) const pure nothrow
{
return interval._end <= _end;
}
/++
Whether this interval is before the given time point.
Params:
timePoint = The time point to check whether this interval is
before it.
Examples:
--------------------
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(Date(1994, 12, 24)));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(Date(2000, 1, 5)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).isBefore(Date(2012, 3, 1)));
--------------------
+/
bool isBefore(in TP timePoint) const pure nothrow
{
return timePoint >= _end;
}
/++
Whether this interval is before the given interval and does not
intersect it.
Params:
interval = The interval to check for against this interval.
Throws:
$(D DateTimeException) if the given interval is empty
Examples:
--------------------
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(
Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(NegInfInterval!Date(Date(2012, 3, 1)).isBefore(
Interval!Date(Date(2022, 10, 19), Date(2027, 6, 3))));
--------------------
+/
bool isBefore(in Interval!TP interval) const pure
{
interval._enforceNotEmpty();
return _end <= interval._begin;
}
/++
Whether this interval is before the given interval and does not
intersect it.
Params:
interval = The interval to check for against this interval.
Examples:
--------------------
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(
PosInfInterval!Date(Date(1999, 5, 4))));
assert(NegInfInterval!Date(Date(2012, 3, 1)).isBefore(
PosInfInterval!Date(Date(2012, 3, 1))));
--------------------
+/
bool isBefore(in PosInfInterval!TP interval) const pure nothrow
{
return _end <= interval._begin;
}
/++
Whether this interval is before the given interval and does not
intersect it.
Always returns false because an interval beginning at negative
infinity can never be before another interval beginning at negative
infinity.
Params:
interval = The interval to check for against this interval.
Examples:
--------------------
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(
NegInfInterval!Date(Date(1996, 5, 4))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(
NegInfInterval!Date(Date(2013, 7, 9))));
--------------------
+/
bool isBefore(in NegInfInterval interval) const pure nothrow
{
return false;
}
/++
Whether this interval is after the given time point.
Always returns false because an interval beginning at negative infinity
can never be after any time point.
Params:
timePoint = The time point to check whether this interval is after
it.
Examples:
--------------------
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(Date(1994, 12, 24)));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(Date(2000, 1, 5)));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(Date(2012, 3, 1)));
--------------------
+/
bool isAfter(in TP timePoint) const pure nothrow
{
return false;
}
/++
Whether this interval is after the given interval and does not
intersect it.
Always returns false (unless the given interval is empty) because an
interval beginning at negative infinity can never be after any other
interval.
Params:
interval = The interval to check against this interval.
Throws:
$(D DateTimeException) if the given interval is empty.
Examples:
--------------------
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(
Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(
Interval!Date(Date(2022, 10, 19), Date(2027, 6, 3))));
--------------------
+/
bool isAfter(in Interval!TP interval) const pure
{
interval._enforceNotEmpty();
return false;
}
/++
Whether this interval is after the given interval and does not intersect
it.
Always returns false because an interval beginning at negative infinity
can never be after any other interval.
Params:
interval = The interval to check against this interval.
Examples:
--------------------
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(
PosInfInterval!Date(Date(1999, 5, 4))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(
PosInfInterval!Date(Date(2012, 3, 1))));
--------------------
+/
bool isAfter(in PosInfInterval!TP interval) const pure nothrow
{
return false;
}
/++
Whether this interval is after the given interval and does not intersect
it.
Always returns false because an interval beginning at negative infinity
can never be after any other interval.
Params:
interval = The interval to check against this interval.
Examples:
--------------------
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(
NegInfInterval!Date(Date(1996, 5, 4))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(
NegInfInterval!Date(Date(2013, 7, 9))));
--------------------
+/
bool isAfter(in NegInfInterval interval) const pure nothrow
{
return false;
}
/++
Whether the given interval overlaps this interval.
Params:
interval = The interval to check for intersection with this interval.
Throws:
$(D DateTimeException) if the given interval is empty.
Examples:
--------------------
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects(
Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).intersects(
Interval!Date(Date(2022, 10, 19), Date(2027, 6, 3))));
--------------------
+/
bool intersects(in Interval!TP interval) const pure
{
interval._enforceNotEmpty();
return interval._begin < _end;
}
/++
Whether the given interval overlaps this interval.
Params:
interval = The interval to check for intersection with this
interval.
Examples:
--------------------
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects(
PosInfInterval!Date(Date(1999, 5, 4))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).intersects(
PosInfInterval!Date(Date(2012, 3, 1))));
--------------------
+/
bool intersects(in PosInfInterval!TP interval) const pure nothrow
{
return interval._begin < _end;
}
/++
Whether the given interval overlaps this interval.
Always returns true because two intervals beginning at negative infinity
always overlap.
Params:
interval = The interval to check for intersection with this interval.
Examples:
--------------------
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects(
NegInfInterval!Date(Date(1996, 5, 4))));
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects(
NegInfInterval!Date(Date(2013, 7, 9))));
--------------------
+/
bool intersects(in NegInfInterval!TP interval) const pure nothrow
{
return true;
}
/++
Returns the intersection of two intervals
Params:
interval = The interval to intersect with this interval.
Throws:
$(D DateTimeException) if the two intervals do not intersect or if
the given interval is empty.
Examples:
--------------------
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) ==
Interval!Date(Date(1990, 7 , 6), Date(2000, 8, 2)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection(
Interval!Date(Date(1999, 1, 12), Date(2015, 9, 2))) ==
Interval!Date(Date(1999, 1 , 12), Date(2012, 3, 1)));
--------------------
+/
Interval!TP intersection(in Interval!TP interval) const
{
enforce(this.intersects(interval), new DateTimeException(format("%s and %s do not intersect.", this, interval)));
auto end = _end < interval._end ? _end : interval._end;
return Interval!TP(interval._begin, end);
}
/++
Returns the intersection of two intervals
Params:
interval = The interval to intersect with this interval.
Throws:
$(D DateTimeException) if the two intervals do not intersect.
Examples:
--------------------
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection(
PosInfInterval!Date(Date(1990, 7, 6))) ==
Interval!Date(Date(1990, 7 , 6), Date(2012, 3, 1)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection(
PosInfInterval!Date(Date(1999, 1, 12))) ==
Interval!Date(Date(1999, 1 , 12), Date(2012, 3, 1)));
--------------------
+/
Interval!TP intersection(in PosInfInterval!TP interval) const
{
enforce(this.intersects(interval), new DateTimeException(format("%s and %s do not intersect.", this, interval)));
return Interval!TP(interval._begin, _end);
}
/++
Returns the intersection of two intervals
Params:
interval = The interval to intersect with this interval.
Examples:
--------------------
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection(
NegInfInterval!Date(Date(1999, 7, 6))) ==
NegInfInterval!Date(Date(1999, 7 , 6)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection(
NegInfInterval!Date(Date(2013, 1, 12))) ==
NegInfInterval!Date(Date(2012, 3 , 1)));
--------------------
+/
NegInfInterval intersection(in NegInfInterval interval) const nothrow
{
return NegInfInterval(_end < interval._end ? _end : interval._end);
}
/++
Whether the given interval is adjacent to this interval.
Params:
interval = The interval to check whether its adjecent to this
interval.
Throws:
$(D DateTimeException) if the given interval is empty.
Examples:
--------------------
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(
Interval!Date(Date(1999, 1, 12), Date(2012, 3, 1))));
assert(NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(
Interval!Date(Date(2012, 3, 1), Date(2019, 2, 2))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(
Interval!Date(Date(2022, 10, 19), Date(2027, 6, 3))));
--------------------
+/
bool isAdjacent(in Interval!TP interval) const pure
{
interval._enforceNotEmpty();
return interval._begin == _end;
}
/++
Whether the given interval is adjacent to this interval.
Params:
interval = The interval to check whether its adjecent to this
interval.
Examples:
--------------------
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(
PosInfInterval!Date(Date(1999, 5, 4))));
assert(NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(
PosInfInterval!Date(Date(2012, 3, 1))));
--------------------
+/
bool isAdjacent(in PosInfInterval!TP interval) const pure nothrow
{
return interval._begin == _end;
}
/++
Whether the given interval is adjacent to this interval.
Always returns false because two intervals beginning at negative
infinity can never be adjacent to one another.
Params:
interval = The interval to check whether its adjecent to this
interval.
Examples:
--------------------
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(
NegInfInterval!Date(Date(1996, 5, 4))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(
NegInfInterval!Date(Date(2012, 3, 1))));
--------------------
+/
bool isAdjacent(in NegInfInterval interval) const pure nothrow
{
return false;
}
/++
Returns the union of two intervals
Params:
interval = The interval to merge with this interval.
Throws:
$(D DateTimeException) if the two intervals do not intersect and are
not adjacent or if the given interval is empty.
Note:
There is no overload for $(D merge) which takes a
$(D PosInfInterval). This is because you can't have an interval
which goes from negative infinity to positive infinity.
Examples:
--------------------
assert(NegInfInterval!Date(Date(2012, 3, 1)).merge(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) ==
NegInfInterval!Date(Date(2012, 3 , 1)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).merge(
Interval!Date(Date(1999, 1, 12), Date(2015, 9, 2))) ==
NegInfInterval!Date(Date(2015, 9 , 2)));
--------------------
+/
NegInfInterval merge(in Interval!TP interval) const
{
enforce(this.isAdjacent(interval) || this.intersects(interval),
new DateTimeException(format("%s and %s are not adjacent and do not intersect.", this, interval)));
return NegInfInterval(_end > interval._end ? _end : interval._end);
}
/++
Returns the union of two intervals
Params:
interval = The interval to merge with this interval.
Note:
There is no overload for $(D merge) which takes a
$(D PosInfInterval). This is because you can't have an interval
which goes from negative infinity to positive infinity.
Examples:
--------------------
assert(NegInfInterval!Date(Date(2012, 3, 1)).merge(
NegInfInterval!Date(Date(1999, 7, 6))) ==
NegInfInterval!Date(Date(2012, 3 , 1)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).merge(
NegInfInterval!Date(Date(2013, 1, 12))) ==
NegInfInterval!Date(Date(2013, 1 , 12)));
--------------------
+/
NegInfInterval merge(in NegInfInterval interval) const pure nothrow
{
return NegInfInterval(_end > interval._end ? _end : interval._end);
}
/++
Returns an interval that covers from the earliest time point of two
intervals up to (but not including) the latest time point of two
intervals.
Params:
interval = The interval to create a span together with this
interval.
Throws:
$(D DateTimeException) if the given interval is empty.
Note:
There is no overload for $(D span) which takes a
$(D PosInfInterval). This is because you can't have an interval
which goes from negative infinity to positive infinity.
Examples:
--------------------
assert(NegInfInterval!Date(Date(2012, 3, 1)).span(
Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) ==
NegInfInterval!Date(Date(2012, 3 , 1)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).span(
Interval!Date(Date(1999, 1, 12), Date(2015, 9, 2))) ==
NegInfInterval!Date(Date(2015, 9 , 2)));
assert(NegInfInterval!Date(Date(1600, 1, 7)).span(
Interval!Date(Date(2012, 3, 11), Date(2017, 7, 1))) ==
NegInfInterval!Date(Date(2017, 7 , 1)));
--------------------
+/
NegInfInterval span(in Interval!TP interval) const pure
{
interval._enforceNotEmpty();
return NegInfInterval(_end > interval._end ? _end : interval._end);
}
/++
Returns an interval that covers from the earliest time point of two
intervals up to (but not including) the latest time point of two
intervals.
Params:
interval = The interval to create a span together with this
interval.
Note:
There is no overload for $(D span) which takes a
$(D PosInfInterval). This is because you can't have an interval
which goes from negative infinity to positive infinity.
Examples:
--------------------
assert(NegInfInterval!Date(Date(2012, 3, 1)).span(
NegInfInterval!Date(Date(1999, 7, 6))) ==
NegInfInterval!Date(Date(2012, 3 , 1)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).span(
NegInfInterval!Date(Date(2013, 1, 12))) ==
NegInfInterval!Date(Date(2013, 1 , 12)));
--------------------
+/
NegInfInterval span(in NegInfInterval interval) const pure nothrow
{
return NegInfInterval(_end > interval._end ? _end : interval._end);
}
/++
Shifts the $(D end) of this interval forward or backwards in time by the
given duration (a positive duration shifts the interval forward; a
negative duration shifts it backward). Effectively, it does
$(D end += duration).
Params:
duration = The duration to shift the interval by.
Examples:
--------------------
auto interval1 = NegInfInterval!Date(Date(2012, 4, 5));
auto interval2 = NegInfInterval!Date(Date(2012, 4, 5));
interval1.shift(dur!"days"(50));
assert(interval1 == NegInfInterval!Date(Date(2012, 5, 25)));
interval2.shift(dur!"days"(-50));
assert(interval2 == NegInfInterval!Date( Date(2012, 2, 15)));
--------------------
+/
void shift(D)(D duration) pure nothrow
if(__traits(compiles, end + duration))
{
_end += duration;
}
static if(__traits(compiles, end.add!"months"(1)) &&
__traits(compiles, end.add!"years"(1)))
{
/++
Shifts the $(D end) of this interval forward or backwards in time by
the given number of years and/or months (a positive number of years
and months shifts the interval forward; a negative number shifts it
backward). It adds the years the given years and months to end. It
effectively calls $(D add!"years"()) and then $(D add!"months"())
on end with the given number of years and months.
Params:
years = The number of years to shift the interval by.
months = The number of months to shift the interval by.
allowOverflow = Whether the days should be allowed to overflow
on $(D end), causing its month to increment.
Throws:
$(D DateTimeException) if empty is true or if the resulting
interval would be invalid.
Examples:
--------------------
auto interval1 = NegInfInterval!Date(Date(2012, 3, 1));
auto interval2 = NegInfInterval!Date(Date(2012, 3, 1));
interval1.shift(2);
assert(interval1 == NegInfInterval!Date(Date(2014, 3, 1)));
interval2.shift(-2);
assert(interval2 == NegInfInterval!Date(Date(2010, 3, 1)));
--------------------
+/
void shift(T)(T years, T months = 0, AllowDayOverflow allowOverflow = AllowDayOverflow.yes)
if(isIntegral!T)
{
auto end = _end;
end.add!"years"(years, allowOverflow);
end.add!"months"(months, allowOverflow);
_end = end;
}
}
/++
Expands the interval forwards in time. Effectively, it does
$(D end += duration).
Params:
duration = The duration to expand the interval by.
dir = The direction in time to expand the interval.
Examples:
--------------------
auto interval1 = NegInfInterval!Date(Date(2012, 3, 1));
auto interval2 = NegInfInterval!Date(Date(2012, 3, 1));
interval1.expand(dur!"days"(2));
assert(interval1 == NegInfInterval!Date(Date(2012, 3, 3)));
interval2.expand(dur!"days"(-2));
assert(interval2 == NegInfInterval!Date(Date(2012, 2, 28)));
--------------------
+/
void expand(D)(D duration) pure nothrow
if(__traits(compiles, end + duration))
{
_end += duration;
}
static if(__traits(compiles, end.add!"months"(1)) &&
__traits(compiles, end.add!"years"(1)))
{
/++
Expands the interval forwards and/or backwards in time. Effectively,
it adds the given number of months/years to end.
Params:
years = The number of years to expand the interval by.
months = The number of months to expand the interval by.
allowOverflow = Whether the days should be allowed to overflow
on $(D end), causing their month to increment.
Throws:
$(D DateTimeException) if empty is true or if the resulting
interval would be invalid.
Examples:
--------------------
auto interval1 = NegInfInterval!Date(Date(2012, 3, 1));
auto interval2 = NegInfInterval!Date(Date(2012, 3, 1));
interval1.expand(2);
assert(interval1 == NegInfInterval!Date(Date(2014, 3, 1)));
interval2.expand(-2);
assert(interval2 == NegInfInterval!Date(Date(2010, 3, 1)));
--------------------
+/
void expand(T)(T years, T months = 0, AllowDayOverflow allowOverflow = AllowDayOverflow.yes)
if(isIntegral!T)
{
auto end = _end;
end.add!"years"(years, allowOverflow);
end.add!"months"(months, allowOverflow);
_end = end;
return;
}
}
/++
Returns a range which iterates backwards over the interval, starting
at $(D end), using $(D_PARAM func) to generate each successive time
point.
The range's $(D front) is the interval's $(D end). $(D_PARAM func) is
used to generate the next $(D front) when $(D popFront) is called. If
$(D_PARAM popFirst) is $(D PopFirst.yes), then $(D popFront) is called
before the range is returned (so that $(D front) is a time point which
$(D_PARAM func) would generate).
If $(D_PARAM func) ever generates a time point greater than or equal to
the current $(D front) of the range, then a $(D DateTimeException) will
be thrown.
There are helper functions in this module which generate common
delegates to pass to $(D bwdRange). Their documentation starts with
"Range-generating function," so you can easily search for them.
Params:
func = The function used to generate the time points of the
range over the interval.
popFirst = Whether $(D popFront) should be called on the range
before returning it.
Throws:
$(D DateTimeException) if this interval is empty.
Warning:
$(D_PARAM func) must be logically pure. Ideally, $(D_PARAM func)
would be a function pointer to a pure function, but forcing
$(D_PARAM func) to be pure is far too restrictive to be useful, and
in order to have the ease of use of having functions which generate
functions to pass to $(D fwdRange), $(D_PARAM func) must be a
delegate.
If $(D_PARAM func) retains state which changes as it is called, then
some algorithms will not work correctly, because the range's
$(D save) will have failed to have really saved the range's state.
So, if you want to avoid such bugs, don't pass a delegate which is
not logically pure to $(D fwdRange). If $(D_PARAM func) is given the
same time point with two different calls, it must return the same
result both times.
Of course, none of the functions in this module have this problem,
so it's only relevant if you're creating your own delegate.
Examples:
--------------------
auto interval = NegInfInterval!Date(Date(2010, 9, 9));
auto func = (in Date date) //For iterating over even-numbered days.
{
if((date.day & 1) == 0)
return date - dur!"days"(2);
return date - dur!"days"(1);
};
auto range = interval.bwdRange(func);
assert(range.front == Date(2010, 9, 9)); //An odd day. Using PopFirst.yes would have made this Date(2010, 9, 8).
range.popFront();
assert(range.front == Date(2010, 9, 8));
range.popFront();
assert(range.front == Date(2010, 9, 6));
range.popFront();
assert(range.front == Date(2010, 9, 4));
range.popFront();
assert(range.front == Date(2010, 9, 2));
range.popFront();
assert(!range.empty);
--------------------
+/
NegInfIntervalRange!(TP) bwdRange(TP delegate(in TP) func, PopFirst popFirst = PopFirst.no) const
{
auto range = NegInfIntervalRange!(TP)(this, func);
if(popFirst == PopFirst.yes)
range.popFront();
return range;
}
/+
Converts this interval to a string.
+/
//Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
//have versions of toString() with extra modifiers, so we define one version
//with modifiers and one without.
string toString()
{
return _toStringImpl();
}
/++
Converts this interval to a string.
+/
//Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
//have versions of toString() with extra modifiers, so we define one version
//with modifiers and one without.
string toString() const nothrow
{
return _toStringImpl();
}
private:
/+
Since we have two versions of toString(), we have _toStringImpl()
so that they can share implementations.
+/
string _toStringImpl() const nothrow
{
try
return format("[-∞ - %s)", _end);
catch(Exception e)
assert(0, "format() threw.");
}
TP _end;
}
//Test NegInfInterval's constructor.
unittest
{
version(testStdDateTime)
{
NegInfInterval!Date(Date.init);
NegInfInterval!TimeOfDay(TimeOfDay.init);
NegInfInterval!DateTime(DateTime.init);
NegInfInterval!SysTime(SysTime(0));
}
}
//Test NegInfInterval's end.
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(NegInfInterval!Date(Date(2010, 1, 1)).end, Date(2010, 1, 1));
_assertPred!"=="(NegInfInterval!Date(Date(2010, 1, 1)).end, Date(2010, 1, 1));
_assertPred!"=="(NegInfInterval!Date(Date(1998, 1, 1)).end, Date(1998, 1, 1));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, cNegInfInterval.end));
static assert(__traits(compiles, iNegInfInterval.end));
//Verify Examples.
assert(NegInfInterval!Date(Date(2012, 3, 1)).end == Date(2012, 3, 1));
}
}
//Test NegInfInterval's empty.
unittest
{
version(testStdDateTime)
{
assert(!NegInfInterval!Date(Date(2010, 1, 1)).empty);
assert(!NegInfInterval!TimeOfDay(TimeOfDay(0, 30, 0)).empty);
assert(!NegInfInterval!DateTime(DateTime(2010, 1, 1, 0, 30, 0)).empty);
assert(!NegInfInterval!SysTime(SysTime(DateTime(2010, 1, 1, 0, 30, 0))).empty);
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, cNegInfInterval.empty));
static assert(__traits(compiles, iNegInfInterval.empty));
//Verify Examples.
assert(!NegInfInterval!Date(Date(1996, 1, 2)).empty);
}
}
//Test NegInfInterval's contains(time point).
unittest
{
version(testStdDateTime)
{
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
assert(negInfInterval.contains(Date(2009, 7, 4)));
assert(negInfInterval.contains(Date(2010, 7, 3)));
assert(negInfInterval.contains(Date(2010, 7, 4)));
assert(negInfInterval.contains(Date(2010, 7, 5)));
assert(negInfInterval.contains(Date(2011, 7, 1)));
assert(negInfInterval.contains(Date(2012, 1, 6)));
assert(!negInfInterval.contains(Date(2012, 1, 7)));
assert(!negInfInterval.contains(Date(2012, 1, 8)));
assert(!negInfInterval.contains(Date(2013, 1, 7)));
const cdate = Date(2010, 7, 6);
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, negInfInterval.contains(cdate)));
static assert(__traits(compiles, cNegInfInterval.contains(cdate)));
static assert(__traits(compiles, iNegInfInterval.contains(cdate)));
//Verify Examples.
assert(NegInfInterval!Date(Date(2012, 3, 1)).contains(Date(1994, 12, 24)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).contains(Date(2000, 1, 5)));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).contains(Date(2012, 3, 1)));
}
}
//Test NegInfInterval's contains(Interval).
unittest
{
version(testStdDateTime)
{
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static void testInterval(in NegInfInterval!Date negInfInterval, in Interval!Date interval)
{
negInfInterval.contains(interval);
}
assertThrown!DateTimeException(testInterval(negInfInterval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assert(negInfInterval.contains(negInfInterval));
assert(negInfInterval.contains(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
assert(!negInfInterval.contains(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))));
assert(negInfInterval.contains(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))));
assert(negInfInterval.contains(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))));
assert(negInfInterval.contains(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))));
assert(!negInfInterval.contains(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))));
assert(negInfInterval.contains(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))));
assert(negInfInterval.contains(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))));
assert(negInfInterval.contains(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))));
assert(!negInfInterval.contains(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))));
assert(!negInfInterval.contains(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))));
assert(!negInfInterval.contains(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
assert(negInfInterval.contains(NegInfInterval!Date(Date(2010, 7, 3))));
assert(negInfInterval.contains(NegInfInterval!Date(Date(2010, 7, 4))));
assert(negInfInterval.contains(NegInfInterval!Date(Date(2010, 7, 5))));
assert(negInfInterval.contains(NegInfInterval!Date(Date(2012, 1, 6))));
assert(negInfInterval.contains(NegInfInterval!Date(Date(2012, 1, 7))));
assert(!negInfInterval.contains(NegInfInterval!Date(Date(2012, 1, 8))));
assert(!NegInfInterval!Date(Date(2010, 7, 3)).contains(negInfInterval));
assert(!NegInfInterval!Date(Date(2010, 7, 4)).contains(negInfInterval));
assert(!NegInfInterval!Date(Date(2010, 7, 5)).contains(negInfInterval));
assert(!NegInfInterval!Date(Date(2012, 1, 6)).contains(negInfInterval));
assert(NegInfInterval!Date(Date(2012, 1, 7)).contains(negInfInterval));
assert(NegInfInterval!Date(Date(2012, 1, 8)).contains(negInfInterval));
assert(!negInfInterval.contains(PosInfInterval!Date(Date(2010, 7, 3))));
assert(!negInfInterval.contains(PosInfInterval!Date(Date(2010, 7, 4))));
assert(!negInfInterval.contains(PosInfInterval!Date(Date(2010, 7, 5))));
assert(!negInfInterval.contains(PosInfInterval!Date(Date(2012, 1, 6))));
assert(!negInfInterval.contains(PosInfInterval!Date(Date(2012, 1, 7))));
assert(!negInfInterval.contains(PosInfInterval!Date(Date(2012, 1, 8))));
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, negInfInterval.contains(interval)));
static assert(__traits(compiles, negInfInterval.contains(cInterval)));
static assert(__traits(compiles, negInfInterval.contains(iInterval)));
static assert(__traits(compiles, negInfInterval.contains(posInfInterval)));
static assert(__traits(compiles, negInfInterval.contains(cPosInfInterval)));
static assert(__traits(compiles, negInfInterval.contains(iPosInfInterval)));
static assert(__traits(compiles, negInfInterval.contains(negInfInterval)));
static assert(__traits(compiles, negInfInterval.contains(cNegInfInterval)));
static assert(__traits(compiles, negInfInterval.contains(iNegInfInterval)));
static assert(__traits(compiles, cNegInfInterval.contains(interval)));
static assert(__traits(compiles, cNegInfInterval.contains(cInterval)));
static assert(__traits(compiles, cNegInfInterval.contains(iInterval)));
static assert(__traits(compiles, cNegInfInterval.contains(posInfInterval)));
static assert(__traits(compiles, cNegInfInterval.contains(cPosInfInterval)));
static assert(__traits(compiles, cNegInfInterval.contains(iPosInfInterval)));
static assert(__traits(compiles, cNegInfInterval.contains(negInfInterval)));
static assert(__traits(compiles, cNegInfInterval.contains(cNegInfInterval)));
static assert(__traits(compiles, cNegInfInterval.contains(iNegInfInterval)));
static assert(__traits(compiles, iNegInfInterval.contains(interval)));
static assert(__traits(compiles, iNegInfInterval.contains(cInterval)));
static assert(__traits(compiles, iNegInfInterval.contains(iInterval)));
static assert(__traits(compiles, iNegInfInterval.contains(posInfInterval)));
static assert(__traits(compiles, iNegInfInterval.contains(cPosInfInterval)));
static assert(__traits(compiles, iNegInfInterval.contains(iPosInfInterval)));
static assert(__traits(compiles, iNegInfInterval.contains(negInfInterval)));
static assert(__traits(compiles, iNegInfInterval.contains(cNegInfInterval)));
static assert(__traits(compiles, iNegInfInterval.contains(iNegInfInterval)));
//Verify Examples.
assert(NegInfInterval!Date(Date(2012, 3, 1)).contains(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(NegInfInterval!Date(Date(2012, 3, 1)).contains(Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).contains(Interval!Date(Date(1998, 2, 28), Date(2013, 5, 1))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).contains(PosInfInterval!Date(Date(1999, 5, 4))));
assert(NegInfInterval!Date(Date(2012, 3, 1)).contains(NegInfInterval!Date(Date(1996, 5, 4))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).contains(NegInfInterval!Date(Date(2013, 7, 9))));
}
}
//Test NegInfInterval's isBefore(time point).
unittest
{
version(testStdDateTime)
{
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
assert(!negInfInterval.isBefore(Date(2009, 7, 4)));
assert(!negInfInterval.isBefore(Date(2010, 7, 3)));
assert(!negInfInterval.isBefore(Date(2010, 7, 4)));
assert(!negInfInterval.isBefore(Date(2010, 7, 5)));
assert(!negInfInterval.isBefore(Date(2011, 7, 1)));
assert(!negInfInterval.isBefore(Date(2012, 1, 6)));
assert(negInfInterval.isBefore(Date(2012, 1, 7)));
assert(negInfInterval.isBefore(Date(2012, 1, 8)));
assert(negInfInterval.isBefore(Date(2013, 1, 7)));
const cdate = Date(2010, 7, 6);
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, negInfInterval.isBefore(cdate)));
static assert(__traits(compiles, cNegInfInterval.isBefore(cdate)));
static assert(__traits(compiles, iNegInfInterval.isBefore(cdate)));
//Verify Examples.
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(Date(1994, 12, 24)));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(Date(2000, 1, 5)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).isBefore(Date(2012, 3, 1)));
}
}
//Test NegInfInterval's isBefore(Interval).
unittest
{
version(testStdDateTime)
{
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static void testInterval(in NegInfInterval!Date negInfInterval, in Interval!Date interval)
{
negInfInterval.isBefore(interval);
}
assertThrown!DateTimeException(testInterval(negInfInterval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assert(!negInfInterval.isBefore(negInfInterval));
assert(!negInfInterval.isBefore(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
assert(!negInfInterval.isBefore(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))));
assert(!negInfInterval.isBefore(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))));
assert(!negInfInterval.isBefore(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))));
assert(!negInfInterval.isBefore(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))));
assert(!negInfInterval.isBefore(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))));
assert(!negInfInterval.isBefore(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))));
assert(!negInfInterval.isBefore(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))));
assert(!negInfInterval.isBefore(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))));
assert(!negInfInterval.isBefore(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))));
assert(negInfInterval.isBefore(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))));
assert(negInfInterval.isBefore(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
assert(!negInfInterval.isBefore(NegInfInterval!Date(Date(2010, 7, 3))));
assert(!negInfInterval.isBefore(NegInfInterval!Date(Date(2010, 7, 4))));
assert(!negInfInterval.isBefore(NegInfInterval!Date(Date(2010, 7, 5))));
assert(!negInfInterval.isBefore(NegInfInterval!Date(Date(2012, 1, 6))));
assert(!negInfInterval.isBefore(NegInfInterval!Date(Date(2012, 1, 7))));
assert(!negInfInterval.isBefore(NegInfInterval!Date(Date(2012, 1, 8))));
assert(!NegInfInterval!Date(Date(2010, 7, 3)).isBefore(negInfInterval));
assert(!NegInfInterval!Date(Date(2010, 7, 4)).isBefore(negInfInterval));
assert(!NegInfInterval!Date(Date(2010, 7, 5)).isBefore(negInfInterval));
assert(!NegInfInterval!Date(Date(2012, 1, 6)).isBefore(negInfInterval));
assert(!NegInfInterval!Date(Date(2012, 1, 7)).isBefore(negInfInterval));
assert(!NegInfInterval!Date(Date(2012, 1, 8)).isBefore(negInfInterval));
assert(!negInfInterval.isBefore(PosInfInterval!Date(Date(2010, 7, 3))));
assert(!negInfInterval.isBefore(PosInfInterval!Date(Date(2010, 7, 4))));
assert(!negInfInterval.isBefore(PosInfInterval!Date(Date(2010, 7, 5))));
assert(!negInfInterval.isBefore(PosInfInterval!Date(Date(2012, 1, 6))));
assert(negInfInterval.isBefore(PosInfInterval!Date(Date(2012, 1, 7))));
assert(negInfInterval.isBefore(PosInfInterval!Date(Date(2012, 1, 8))));
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, negInfInterval.isBefore(interval)));
static assert(__traits(compiles, negInfInterval.isBefore(cInterval)));
static assert(__traits(compiles, negInfInterval.isBefore(iInterval)));
static assert(__traits(compiles, negInfInterval.isBefore(posInfInterval)));
static assert(__traits(compiles, negInfInterval.isBefore(cPosInfInterval)));
static assert(__traits(compiles, negInfInterval.isBefore(iPosInfInterval)));
static assert(__traits(compiles, negInfInterval.isBefore(negInfInterval)));
static assert(__traits(compiles, negInfInterval.isBefore(cNegInfInterval)));
static assert(__traits(compiles, negInfInterval.isBefore(iNegInfInterval)));
static assert(__traits(compiles, cNegInfInterval.isBefore(interval)));
static assert(__traits(compiles, cNegInfInterval.isBefore(cInterval)));
static assert(__traits(compiles, cNegInfInterval.isBefore(iInterval)));
static assert(__traits(compiles, cNegInfInterval.isBefore(posInfInterval)));
static assert(__traits(compiles, cNegInfInterval.isBefore(cPosInfInterval)));
static assert(__traits(compiles, cNegInfInterval.isBefore(iPosInfInterval)));
static assert(__traits(compiles, cNegInfInterval.isBefore(negInfInterval)));
static assert(__traits(compiles, cNegInfInterval.isBefore(cNegInfInterval)));
static assert(__traits(compiles, cNegInfInterval.isBefore(iNegInfInterval)));
static assert(__traits(compiles, iNegInfInterval.isBefore(interval)));
static assert(__traits(compiles, iNegInfInterval.isBefore(cInterval)));
static assert(__traits(compiles, iNegInfInterval.isBefore(iInterval)));
static assert(__traits(compiles, iNegInfInterval.isBefore(posInfInterval)));
static assert(__traits(compiles, iNegInfInterval.isBefore(cPosInfInterval)));
static assert(__traits(compiles, iNegInfInterval.isBefore(iPosInfInterval)));
static assert(__traits(compiles, iNegInfInterval.isBefore(negInfInterval)));
static assert(__traits(compiles, iNegInfInterval.isBefore(cNegInfInterval)));
static assert(__traits(compiles, iNegInfInterval.isBefore(iNegInfInterval)));
//Verify Examples.
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(NegInfInterval!Date(Date(2012, 3, 1)).isBefore(Interval!Date(Date(2022, 10, 19), Date(2027, 6, 3))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(PosInfInterval!Date(Date(1999, 5, 4))));
assert(NegInfInterval!Date(Date(2012, 3, 1)).isBefore(PosInfInterval!Date(Date(2012, 3, 1))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(NegInfInterval!Date(Date(1996, 5, 4))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(NegInfInterval!Date(Date(2013, 7, 9))));
}
}
//Test NegInfInterval's isAfter(time point).
unittest
{
version(testStdDateTime)
{
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
assert(!negInfInterval.isAfter(Date(2009, 7, 4)));
assert(!negInfInterval.isAfter(Date(2010, 7, 3)));
assert(!negInfInterval.isAfter(Date(2010, 7, 4)));
assert(!negInfInterval.isAfter(Date(2010, 7, 5)));
assert(!negInfInterval.isAfter(Date(2011, 7, 1)));
assert(!negInfInterval.isAfter(Date(2012, 1, 6)));
assert(!negInfInterval.isAfter(Date(2012, 1, 7)));
assert(!negInfInterval.isAfter(Date(2012, 1, 8)));
assert(!negInfInterval.isAfter(Date(2013, 1, 7)));
const cdate = Date(2010, 7, 6);
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, negInfInterval.isAfter(cdate)));
static assert(__traits(compiles, cNegInfInterval.isAfter(cdate)));
static assert(__traits(compiles, iNegInfInterval.isAfter(cdate)));
}
}
//Test NegInfInterval's isAfter(Interval).
unittest
{
version(testStdDateTime)
{
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static void testInterval(in NegInfInterval!Date negInfInterval, in Interval!Date interval)
{
negInfInterval.isAfter(interval);
}
assertThrown!DateTimeException(testInterval(negInfInterval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assert(!negInfInterval.isAfter(negInfInterval));
assert(!negInfInterval.isAfter(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
assert(!negInfInterval.isAfter(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))));
assert(!negInfInterval.isAfter(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))));
assert(!negInfInterval.isAfter(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))));
assert(!negInfInterval.isAfter(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))));
assert(!negInfInterval.isAfter(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))));
assert(!negInfInterval.isAfter(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))));
assert(!negInfInterval.isAfter(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))));
assert(!negInfInterval.isAfter(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))));
assert(!negInfInterval.isAfter(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))));
assert(!negInfInterval.isAfter(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))));
assert(!negInfInterval.isAfter(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
assert(!negInfInterval.isAfter(NegInfInterval!Date(Date(2010, 7, 3))));
assert(!negInfInterval.isAfter(NegInfInterval!Date(Date(2010, 7, 4))));
assert(!negInfInterval.isAfter(NegInfInterval!Date(Date(2010, 7, 5))));
assert(!negInfInterval.isAfter(NegInfInterval!Date(Date(2012, 1, 6))));
assert(!negInfInterval.isAfter(NegInfInterval!Date(Date(2012, 1, 7))));
assert(!negInfInterval.isAfter(NegInfInterval!Date(Date(2012, 1, 8))));
assert(!NegInfInterval!Date(Date(2010, 7, 3)).isAfter(negInfInterval));
assert(!NegInfInterval!Date(Date(2010, 7, 4)).isAfter(negInfInterval));
assert(!NegInfInterval!Date(Date(2010, 7, 5)).isAfter(negInfInterval));
assert(!NegInfInterval!Date(Date(2012, 1, 6)).isAfter(negInfInterval));
assert(!NegInfInterval!Date(Date(2012, 1, 7)).isAfter(negInfInterval));
assert(!NegInfInterval!Date(Date(2012, 1, 8)).isAfter(negInfInterval));
assert(!negInfInterval.isAfter(PosInfInterval!Date(Date(2010, 7, 3))));
assert(!negInfInterval.isAfter(PosInfInterval!Date(Date(2010, 7, 4))));
assert(!negInfInterval.isAfter(PosInfInterval!Date(Date(2010, 7, 5))));
assert(!negInfInterval.isAfter(PosInfInterval!Date(Date(2012, 1, 6))));
assert(!negInfInterval.isAfter(PosInfInterval!Date(Date(2012, 1, 7))));
assert(!negInfInterval.isAfter(PosInfInterval!Date(Date(2012, 1, 8))));
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, negInfInterval.isAfter(interval)));
static assert(__traits(compiles, negInfInterval.isAfter(cInterval)));
static assert(__traits(compiles, negInfInterval.isAfter(iInterval)));
static assert(__traits(compiles, negInfInterval.isAfter(posInfInterval)));
static assert(__traits(compiles, negInfInterval.isAfter(cPosInfInterval)));
static assert(__traits(compiles, negInfInterval.isAfter(iPosInfInterval)));
static assert(__traits(compiles, negInfInterval.isAfter(negInfInterval)));
static assert(__traits(compiles, negInfInterval.isAfter(cNegInfInterval)));
static assert(__traits(compiles, negInfInterval.isAfter(iNegInfInterval)));
static assert(__traits(compiles, cNegInfInterval.isAfter(interval)));
static assert(__traits(compiles, cNegInfInterval.isAfter(cInterval)));
static assert(__traits(compiles, cNegInfInterval.isAfter(iInterval)));
static assert(__traits(compiles, cNegInfInterval.isAfter(posInfInterval)));
static assert(__traits(compiles, cNegInfInterval.isAfter(cPosInfInterval)));
static assert(__traits(compiles, cNegInfInterval.isAfter(iPosInfInterval)));
static assert(__traits(compiles, cNegInfInterval.isAfter(negInfInterval)));
static assert(__traits(compiles, cNegInfInterval.isAfter(cNegInfInterval)));
static assert(__traits(compiles, cNegInfInterval.isAfter(iNegInfInterval)));
static assert(__traits(compiles, iNegInfInterval.isAfter(interval)));
static assert(__traits(compiles, iNegInfInterval.isAfter(cInterval)));
static assert(__traits(compiles, iNegInfInterval.isAfter(iInterval)));
static assert(__traits(compiles, iNegInfInterval.isAfter(posInfInterval)));
static assert(__traits(compiles, iNegInfInterval.isAfter(cPosInfInterval)));
static assert(__traits(compiles, iNegInfInterval.isAfter(iPosInfInterval)));
static assert(__traits(compiles, iNegInfInterval.isAfter(negInfInterval)));
static assert(__traits(compiles, iNegInfInterval.isAfter(cNegInfInterval)));
static assert(__traits(compiles, iNegInfInterval.isAfter(iNegInfInterval)));
//Verify Examples.
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(Date(1994, 12, 24)));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(Date(2000, 1, 5)));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(Date(2012, 3, 1)));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(Interval!Date(Date(2022, 10, 19), Date(2027, 6, 3))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(PosInfInterval!Date(Date(1999, 5, 4))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(PosInfInterval!Date(Date(2012, 3, 1))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(NegInfInterval!Date(Date(1996, 5, 4))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(NegInfInterval!Date(Date(2013, 7, 9))));
}
}
//Test NegInfInterval's intersects().
unittest
{
version(testStdDateTime)
{
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static void testInterval(in NegInfInterval!Date negInfInterval, in Interval!Date interval)
{
negInfInterval.intersects(interval);
}
assertThrown!DateTimeException(testInterval(negInfInterval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assert(negInfInterval.intersects(negInfInterval));
assert(negInfInterval.intersects(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
assert(negInfInterval.intersects(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))));
assert(negInfInterval.intersects(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))));
assert(negInfInterval.intersects(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))));
assert(negInfInterval.intersects(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))));
assert(negInfInterval.intersects(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))));
assert(negInfInterval.intersects(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))));
assert(negInfInterval.intersects(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))));
assert(negInfInterval.intersects(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))));
assert(negInfInterval.intersects(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))));
assert(!negInfInterval.intersects(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))));
assert(!negInfInterval.intersects(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
assert(negInfInterval.intersects(NegInfInterval!Date(Date(2010, 7, 3))));
assert(negInfInterval.intersects(NegInfInterval!Date(Date(2010, 7, 4))));
assert(negInfInterval.intersects(NegInfInterval!Date(Date(2010, 7, 5))));
assert(negInfInterval.intersects(NegInfInterval!Date(Date(2012, 1, 6))));
assert(negInfInterval.intersects(NegInfInterval!Date(Date(2012, 1, 7))));
assert(negInfInterval.intersects(NegInfInterval!Date(Date(2012, 1, 8))));
assert(NegInfInterval!Date(Date(2010, 7, 3)).intersects(negInfInterval));
assert(NegInfInterval!Date(Date(2010, 7, 4)).intersects(negInfInterval));
assert(NegInfInterval!Date(Date(2010, 7, 5)).intersects(negInfInterval));
assert(NegInfInterval!Date(Date(2012, 1, 6)).intersects(negInfInterval));
assert(NegInfInterval!Date(Date(2012, 1, 7)).intersects(negInfInterval));
assert(NegInfInterval!Date(Date(2012, 1, 8)).intersects(negInfInterval));
assert(negInfInterval.intersects(PosInfInterval!Date(Date(2010, 7, 3))));
assert(negInfInterval.intersects(PosInfInterval!Date(Date(2010, 7, 4))));
assert(negInfInterval.intersects(PosInfInterval!Date(Date(2010, 7, 5))));
assert(negInfInterval.intersects(PosInfInterval!Date(Date(2012, 1, 6))));
assert(!negInfInterval.intersects(PosInfInterval!Date(Date(2012, 1, 7))));
assert(!negInfInterval.intersects(PosInfInterval!Date(Date(2012, 1, 8))));
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, negInfInterval.intersects(interval)));
static assert(__traits(compiles, negInfInterval.intersects(cInterval)));
static assert(__traits(compiles, negInfInterval.intersects(iInterval)));
static assert(__traits(compiles, negInfInterval.intersects(posInfInterval)));
static assert(__traits(compiles, negInfInterval.intersects(cPosInfInterval)));
static assert(__traits(compiles, negInfInterval.intersects(iPosInfInterval)));
static assert(__traits(compiles, negInfInterval.intersects(negInfInterval)));
static assert(__traits(compiles, negInfInterval.intersects(cNegInfInterval)));
static assert(__traits(compiles, negInfInterval.intersects(iNegInfInterval)));
static assert(__traits(compiles, cNegInfInterval.intersects(interval)));
static assert(__traits(compiles, cNegInfInterval.intersects(cInterval)));
static assert(__traits(compiles, cNegInfInterval.intersects(iInterval)));
static assert(__traits(compiles, cNegInfInterval.intersects(posInfInterval)));
static assert(__traits(compiles, cNegInfInterval.intersects(cPosInfInterval)));
static assert(__traits(compiles, cNegInfInterval.intersects(iPosInfInterval)));
static assert(__traits(compiles, cNegInfInterval.intersects(negInfInterval)));
static assert(__traits(compiles, cNegInfInterval.intersects(cNegInfInterval)));
static assert(__traits(compiles, cNegInfInterval.intersects(iNegInfInterval)));
static assert(__traits(compiles, iNegInfInterval.intersects(interval)));
static assert(__traits(compiles, iNegInfInterval.intersects(cInterval)));
static assert(__traits(compiles, iNegInfInterval.intersects(iInterval)));
static assert(__traits(compiles, iNegInfInterval.intersects(posInfInterval)));
static assert(__traits(compiles, iNegInfInterval.intersects(cPosInfInterval)));
static assert(__traits(compiles, iNegInfInterval.intersects(iPosInfInterval)));
static assert(__traits(compiles, iNegInfInterval.intersects(negInfInterval)));
static assert(__traits(compiles, iNegInfInterval.intersects(cNegInfInterval)));
static assert(__traits(compiles, iNegInfInterval.intersects(iNegInfInterval)));
//Verify Examples.
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects(Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).intersects(Interval!Date(Date(2022, 10, 19), Date(2027, 6, 3))));
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects(PosInfInterval!Date(Date(1999, 5, 4))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).intersects(PosInfInterval!Date(Date(2012, 3, 1))));
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects(NegInfInterval!Date(Date(1996, 5, 4))));
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects(NegInfInterval!Date(Date(2013, 7, 9))));
}
}
//Test NegInfInterval's intersection().
unittest
{
version(testStdDateTime)
{
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static void testInterval(I, J)(in I interval1, in J interval2)
{
interval1.intersection(interval2);
}
assertThrown!DateTimeException(testInterval(negInfInterval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assertThrown!DateTimeException(testInterval(negInfInterval, Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))));
assertThrown!DateTimeException(testInterval(negInfInterval, Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
assertThrown!DateTimeException(testInterval(negInfInterval, PosInfInterval!Date(Date(2012, 1, 7))));
assertThrown!DateTimeException(testInterval(negInfInterval, PosInfInterval!Date(Date(2012, 1, 8))));
_assertPred!"=="(negInfInterval.intersection(negInfInterval),
negInfInterval);
_assertPred!"=="(negInfInterval.intersection(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))),
Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3)));
_assertPred!"=="(negInfInterval.intersection(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))),
Interval!Date(Date(2010, 7, 1), Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.intersection(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))),
Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4)));
_assertPred!"=="(negInfInterval.intersection(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))),
Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5)));
_assertPred!"=="(negInfInterval.intersection(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))),
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.intersection(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))),
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.intersection(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))),
Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)));
_assertPred!"=="(negInfInterval.intersection(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))),
Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.intersection(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))),
Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.intersection(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))),
Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.intersection(NegInfInterval!Date(Date(2010, 7, 3))),
NegInfInterval!Date(Date(2010, 7, 3)));
_assertPred!"=="(negInfInterval.intersection(NegInfInterval!Date(Date(2010, 7, 4))),
NegInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(negInfInterval.intersection(NegInfInterval!Date(Date(2010, 7, 5))),
NegInfInterval!Date(Date(2010, 7, 5)));
_assertPred!"=="(negInfInterval.intersection(NegInfInterval!Date(Date(2012, 1, 6))),
NegInfInterval!Date(Date(2012, 1, 6)));
_assertPred!"=="(negInfInterval.intersection(NegInfInterval!Date(Date(2012, 1, 7))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.intersection(NegInfInterval!Date(Date(2012, 1, 8))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(NegInfInterval!Date(Date(2010, 7, 3)).intersection(negInfInterval),
NegInfInterval!Date(Date(2010, 7, 3)));
_assertPred!"=="(NegInfInterval!Date(Date(2010, 7, 4)).intersection(negInfInterval),
NegInfInterval!Date(Date(2010, 7, 4)));
_assertPred!"=="(NegInfInterval!Date(Date(2010, 7, 5)).intersection(negInfInterval),
NegInfInterval!Date(Date(2010, 7, 5)));
_assertPred!"=="(NegInfInterval!Date(Date(2012, 1, 6)).intersection(negInfInterval),
NegInfInterval!Date(Date(2012, 1, 6)));
_assertPred!"=="(NegInfInterval!Date(Date(2012, 1, 7)).intersection(negInfInterval),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(NegInfInterval!Date(Date(2012, 1, 8)).intersection(negInfInterval),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.intersection(PosInfInterval!Date(Date(2010, 7, 3))),
Interval!Date(Date(2010, 7, 3), Date(2012, 1 ,7)));
_assertPred!"=="(negInfInterval.intersection(PosInfInterval!Date(Date(2010, 7, 4))),
Interval!Date(Date(2010, 7, 4), Date(2012, 1 ,7)));
_assertPred!"=="(negInfInterval.intersection(PosInfInterval!Date(Date(2010, 7, 5))),
Interval!Date(Date(2010, 7, 5), Date(2012, 1 ,7)));
_assertPred!"=="(negInfInterval.intersection(PosInfInterval!Date(Date(2012, 1, 6))),
Interval!Date(Date(2012, 1, 6), Date(2012, 1 ,7)));
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, negInfInterval.intersection(interval)));
static assert(__traits(compiles, negInfInterval.intersection(cInterval)));
static assert(__traits(compiles, negInfInterval.intersection(iInterval)));
static assert(__traits(compiles, negInfInterval.intersection(posInfInterval)));
static assert(__traits(compiles, negInfInterval.intersection(cPosInfInterval)));
static assert(__traits(compiles, negInfInterval.intersection(iPosInfInterval)));
static assert(__traits(compiles, negInfInterval.intersection(negInfInterval)));
static assert(__traits(compiles, negInfInterval.intersection(cNegInfInterval)));
static assert(__traits(compiles, negInfInterval.intersection(iNegInfInterval)));
static assert(__traits(compiles, cNegInfInterval.intersection(interval)));
static assert(__traits(compiles, cNegInfInterval.intersection(cInterval)));
static assert(__traits(compiles, cNegInfInterval.intersection(iInterval)));
static assert(__traits(compiles, cNegInfInterval.intersection(posInfInterval)));
static assert(__traits(compiles, cNegInfInterval.intersection(cPosInfInterval)));
static assert(__traits(compiles, cNegInfInterval.intersection(iPosInfInterval)));
static assert(__traits(compiles, cNegInfInterval.intersection(negInfInterval)));
static assert(__traits(compiles, cNegInfInterval.intersection(cNegInfInterval)));
static assert(__traits(compiles, cNegInfInterval.intersection(iNegInfInterval)));
static assert(__traits(compiles, iNegInfInterval.intersection(interval)));
static assert(__traits(compiles, iNegInfInterval.intersection(cInterval)));
static assert(__traits(compiles, iNegInfInterval.intersection(iInterval)));
static assert(__traits(compiles, iNegInfInterval.intersection(posInfInterval)));
static assert(__traits(compiles, iNegInfInterval.intersection(cPosInfInterval)));
static assert(__traits(compiles, iNegInfInterval.intersection(iPosInfInterval)));
static assert(__traits(compiles, iNegInfInterval.intersection(negInfInterval)));
static assert(__traits(compiles, iNegInfInterval.intersection(cNegInfInterval)));
static assert(__traits(compiles, iNegInfInterval.intersection(iNegInfInterval)));
//Verify Examples.
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) == Interval!Date(Date(1990, 7 , 6), Date(2000, 8, 2)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection(Interval!Date(Date(1999, 1, 12), Date(2015, 9, 2))) == Interval!Date(Date(1999, 1 , 12), Date(2012, 3, 1)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection(PosInfInterval!Date(Date(1990, 7, 6))) == Interval!Date(Date(1990, 7 , 6), Date(2012, 3, 1)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection(PosInfInterval!Date(Date(1999, 1, 12))) == Interval!Date(Date(1999, 1 , 12), Date(2012, 3, 1)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection(NegInfInterval!Date(Date(1999, 7, 6))) == NegInfInterval!Date(Date(1999, 7 , 6)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection(NegInfInterval!Date(Date(2013, 1, 12))) == NegInfInterval!Date(Date(2012, 3 , 1)));
}
}
//Test NegInfInterval's isAdjacent().
unittest
{
version(testStdDateTime)
{
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static void testInterval(in NegInfInterval!Date negInfInterval, in Interval!Date interval)
{
negInfInterval.isAdjacent(interval);
}
assertThrown!DateTimeException(testInterval(negInfInterval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assert(!negInfInterval.isAdjacent(negInfInterval));
assert(!negInfInterval.isAdjacent(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))));
assert(!negInfInterval.isAdjacent(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))));
assert(!negInfInterval.isAdjacent(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))));
assert(!negInfInterval.isAdjacent(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))));
assert(!negInfInterval.isAdjacent(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))));
assert(!negInfInterval.isAdjacent(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))));
assert(!negInfInterval.isAdjacent(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))));
assert(!negInfInterval.isAdjacent(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))));
assert(!negInfInterval.isAdjacent(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))));
assert(!negInfInterval.isAdjacent(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))));
assert(negInfInterval.isAdjacent(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))));
assert(!negInfInterval.isAdjacent(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
assert(!negInfInterval.isAdjacent(NegInfInterval!Date(Date(2010, 7, 3))));
assert(!negInfInterval.isAdjacent(NegInfInterval!Date(Date(2010, 7, 4))));
assert(!negInfInterval.isAdjacent(NegInfInterval!Date(Date(2010, 7, 5))));
assert(!negInfInterval.isAdjacent(NegInfInterval!Date(Date(2012, 1, 6))));
assert(!negInfInterval.isAdjacent(NegInfInterval!Date(Date(2012, 1, 7))));
assert(!negInfInterval.isAdjacent(NegInfInterval!Date(Date(2012, 1, 8))));
assert(!NegInfInterval!Date(Date(2010, 7, 3)).isAdjacent(negInfInterval));
assert(!NegInfInterval!Date(Date(2010, 7, 4)).isAdjacent(negInfInterval));
assert(!NegInfInterval!Date(Date(2010, 7, 5)).isAdjacent(negInfInterval));
assert(!NegInfInterval!Date(Date(2012, 1, 6)).isAdjacent(negInfInterval));
assert(!NegInfInterval!Date(Date(2012, 1, 7)).isAdjacent(negInfInterval));
assert(!NegInfInterval!Date(Date(2012, 1, 8)).isAdjacent(negInfInterval));
assert(!negInfInterval.isAdjacent(PosInfInterval!Date(Date(2010, 7, 3))));
assert(!negInfInterval.isAdjacent(PosInfInterval!Date(Date(2010, 7, 4))));
assert(!negInfInterval.isAdjacent(PosInfInterval!Date(Date(2010, 7, 5))));
assert(!negInfInterval.isAdjacent(PosInfInterval!Date(Date(2012, 1, 6))));
assert(negInfInterval.isAdjacent(PosInfInterval!Date(Date(2012, 1, 7))));
assert(!negInfInterval.isAdjacent(PosInfInterval!Date(Date(2012, 1, 8))));
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, negInfInterval.isAdjacent(interval)));
static assert(__traits(compiles, negInfInterval.isAdjacent(cInterval)));
static assert(__traits(compiles, negInfInterval.isAdjacent(iInterval)));
static assert(__traits(compiles, negInfInterval.isAdjacent(posInfInterval)));
static assert(__traits(compiles, negInfInterval.isAdjacent(cPosInfInterval)));
static assert(__traits(compiles, negInfInterval.isAdjacent(iPosInfInterval)));
static assert(__traits(compiles, negInfInterval.isAdjacent(negInfInterval)));
static assert(__traits(compiles, negInfInterval.isAdjacent(cNegInfInterval)));
static assert(__traits(compiles, negInfInterval.isAdjacent(iNegInfInterval)));
static assert(__traits(compiles, cNegInfInterval.isAdjacent(interval)));
static assert(__traits(compiles, cNegInfInterval.isAdjacent(cInterval)));
static assert(__traits(compiles, cNegInfInterval.isAdjacent(iInterval)));
static assert(__traits(compiles, cNegInfInterval.isAdjacent(posInfInterval)));
static assert(__traits(compiles, cNegInfInterval.isAdjacent(cPosInfInterval)));
static assert(__traits(compiles, cNegInfInterval.isAdjacent(iPosInfInterval)));
static assert(__traits(compiles, cNegInfInterval.isAdjacent(negInfInterval)));
static assert(__traits(compiles, cNegInfInterval.isAdjacent(cNegInfInterval)));
static assert(__traits(compiles, cNegInfInterval.isAdjacent(iNegInfInterval)));
static assert(__traits(compiles, iNegInfInterval.isAdjacent(interval)));
static assert(__traits(compiles, iNegInfInterval.isAdjacent(cInterval)));
static assert(__traits(compiles, iNegInfInterval.isAdjacent(iInterval)));
static assert(__traits(compiles, iNegInfInterval.isAdjacent(posInfInterval)));
static assert(__traits(compiles, iNegInfInterval.isAdjacent(cPosInfInterval)));
static assert(__traits(compiles, iNegInfInterval.isAdjacent(iPosInfInterval)));
static assert(__traits(compiles, iNegInfInterval.isAdjacent(negInfInterval)));
static assert(__traits(compiles, iNegInfInterval.isAdjacent(cNegInfInterval)));
static assert(__traits(compiles, iNegInfInterval.isAdjacent(iNegInfInterval)));
//Verify Examples.
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(Interval!Date(Date(1999, 1, 12), Date(2012, 3, 1))));
assert(NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(Interval!Date(Date(2012, 3, 1), Date(2019, 2, 2))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(Interval!Date(Date(2022, 10, 19), Date(2027, 6, 3))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(PosInfInterval!Date(Date(1999, 5, 4))));
assert(NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(PosInfInterval!Date(Date(2012, 3, 1))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(NegInfInterval!Date(Date(1996, 5, 4))));
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(NegInfInterval!Date(Date(2012, 3, 1))));
}
}
//Test NegInfInterval's merge().
unittest
{
version(testStdDateTime)
{
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static void testInterval(I, J)(in I interval1, in J interval2)
{
interval1.merge(interval2);
}
assertThrown!DateTimeException(testInterval(negInfInterval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
assertThrown!DateTimeException(testInterval(negInfInterval, Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))));
_assertPred!"=="(negInfInterval.merge(negInfInterval),
negInfInterval);
_assertPred!"=="(negInfInterval.merge(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.merge(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))),
NegInfInterval!Date(Date(2013, 7, 3)));
_assertPred!"=="(negInfInterval.merge(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.merge(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.merge(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.merge(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))),
NegInfInterval!Date(Date(2012, 1, 8)));
_assertPred!"=="(negInfInterval.merge(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.merge(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.merge(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.merge(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))),
NegInfInterval!Date(Date(2012, 1, 8)));
_assertPred!"=="(negInfInterval.merge(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))),
NegInfInterval!Date(Date(2012, 1, 8)));
_assertPred!"=="(negInfInterval.merge(NegInfInterval!Date(Date(2010, 7, 3))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.merge(NegInfInterval!Date(Date(2010, 7, 4))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.merge(NegInfInterval!Date(Date(2010, 7, 5))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.merge(NegInfInterval!Date(Date(2012, 1, 6))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.merge(NegInfInterval!Date(Date(2012, 1, 7))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.merge(NegInfInterval!Date(Date(2012, 1, 8))),
NegInfInterval!Date(Date(2012, 1, 8)));
_assertPred!"=="(NegInfInterval!Date(Date(2010, 7, 3)).merge(negInfInterval),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(NegInfInterval!Date(Date(2010, 7, 4)).merge(negInfInterval),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(NegInfInterval!Date(Date(2010, 7, 5)).merge(negInfInterval),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(NegInfInterval!Date(Date(2012, 1, 6)).merge(negInfInterval),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(NegInfInterval!Date(Date(2012, 1, 7)).merge(negInfInterval),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(NegInfInterval!Date(Date(2012, 1, 8)).merge(negInfInterval),
NegInfInterval!Date(Date(2012, 1, 8)));
static assert(!__traits(compiles, negInfInterval.merge(PosInfInterval!Date(Date(2010, 7, 3)))));
static assert(!__traits(compiles, negInfInterval.merge(PosInfInterval!Date(Date(2010, 7, 4)))));
static assert(!__traits(compiles, negInfInterval.merge(PosInfInterval!Date(Date(2010, 7, 5)))));
static assert(!__traits(compiles, negInfInterval.merge(PosInfInterval!Date(Date(2012, 1, 6)))));
static assert(!__traits(compiles, negInfInterval.merge(PosInfInterval!Date(Date(2012, 1, 7)))));
static assert(!__traits(compiles, negInfInterval.merge(PosInfInterval!Date(Date(2012, 1, 8)))));
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, negInfInterval.merge(interval)));
static assert(__traits(compiles, negInfInterval.merge(cInterval)));
static assert(__traits(compiles, negInfInterval.merge(iInterval)));
static assert(!__traits(compiles, negInfInterval.merge(posInfInterval)));
static assert(!__traits(compiles, negInfInterval.merge(cPosInfInterval)));
static assert(!__traits(compiles, negInfInterval.merge(iPosInfInterval)));
static assert(__traits(compiles, negInfInterval.merge(negInfInterval)));
static assert(__traits(compiles, negInfInterval.merge(cNegInfInterval)));
static assert(__traits(compiles, negInfInterval.merge(iNegInfInterval)));
static assert(__traits(compiles, cNegInfInterval.merge(interval)));
static assert(__traits(compiles, cNegInfInterval.merge(cInterval)));
static assert(__traits(compiles, cNegInfInterval.merge(iInterval)));
static assert(!__traits(compiles, cNegInfInterval.merge(posInfInterval)));
static assert(!__traits(compiles, cNegInfInterval.merge(cPosInfInterval)));
static assert(!__traits(compiles, cNegInfInterval.merge(iPosInfInterval)));
static assert(__traits(compiles, cNegInfInterval.merge(negInfInterval)));
static assert(__traits(compiles, cNegInfInterval.merge(cNegInfInterval)));
static assert(__traits(compiles, cNegInfInterval.merge(iNegInfInterval)));
static assert(__traits(compiles, iNegInfInterval.merge(interval)));
static assert(__traits(compiles, iNegInfInterval.merge(cInterval)));
static assert(__traits(compiles, iNegInfInterval.merge(iInterval)));
static assert(!__traits(compiles, iNegInfInterval.merge(posInfInterval)));
static assert(!__traits(compiles, iNegInfInterval.merge(cPosInfInterval)));
static assert(!__traits(compiles, iNegInfInterval.merge(iPosInfInterval)));
static assert(__traits(compiles, iNegInfInterval.merge(negInfInterval)));
static assert(__traits(compiles, iNegInfInterval.merge(cNegInfInterval)));
static assert(__traits(compiles, iNegInfInterval.merge(iNegInfInterval)));
//Verify Examples.
assert(NegInfInterval!Date(Date(2012, 3, 1)).merge(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) == NegInfInterval!Date(Date(2012, 3 , 1)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).merge(Interval!Date(Date(1999, 1, 12), Date(2015, 9, 2))) == NegInfInterval!Date(Date(2015, 9 , 2)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).merge(NegInfInterval!Date(Date(1999, 7, 6))) == NegInfInterval!Date(Date(2012, 3 , 1)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).merge(NegInfInterval!Date(Date(2013, 1, 12))) == NegInfInterval!Date(Date(2013, 1 , 12)));
}
}
//Test NegInfInterval's span().
unittest
{
version(testStdDateTime)
{
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static void testInterval(I, J)(in I interval1, in J interval2)
{
interval1.span(interval2);
}
assertThrown!DateTimeException(testInterval(negInfInterval, Interval!Date(Date(2010, 7, 4), dur!"days"(0))));
_assertPred!"=="(negInfInterval.span(negInfInterval),
negInfInterval);
_assertPred!"=="(negInfInterval.span(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.span(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))),
NegInfInterval!Date(Date(2013, 7, 3)));
_assertPred!"=="(negInfInterval.span(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.span(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.span(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.span(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))),
NegInfInterval!Date(Date(2012, 1, 8)));
_assertPred!"=="(negInfInterval.span(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.span(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.span(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.span(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))),
NegInfInterval!Date(Date(2012, 1, 8)));
_assertPred!"=="(negInfInterval.span(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))),
NegInfInterval!Date(Date(2012, 1, 8)));
_assertPred!"=="(negInfInterval.span(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))),
NegInfInterval!Date(Date(2012, 1, 9)));
_assertPred!"=="(negInfInterval.span(NegInfInterval!Date(Date(2010, 7, 3))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.span(NegInfInterval!Date(Date(2010, 7, 4))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.span(NegInfInterval!Date(Date(2010, 7, 5))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.span(NegInfInterval!Date(Date(2012, 1, 6))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.span(NegInfInterval!Date(Date(2012, 1, 7))),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(negInfInterval.span(NegInfInterval!Date(Date(2012, 1, 8))),
NegInfInterval!Date(Date(2012, 1, 8)));
_assertPred!"=="(NegInfInterval!Date(Date(2010, 7, 3)).span(negInfInterval),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(NegInfInterval!Date(Date(2010, 7, 4)).span(negInfInterval),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(NegInfInterval!Date(Date(2010, 7, 5)).span(negInfInterval),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(NegInfInterval!Date(Date(2012, 1, 6)).span(negInfInterval),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(NegInfInterval!Date(Date(2012, 1, 7)).span(negInfInterval),
NegInfInterval!Date(Date(2012, 1, 7)));
_assertPred!"=="(NegInfInterval!Date(Date(2012, 1, 8)).span(negInfInterval),
NegInfInterval!Date(Date(2012, 1, 8)));
static assert(!__traits(compiles, negInfInterval.span(PosInfInterval!Date(Date(2010, 7, 3)))));
static assert(!__traits(compiles, negInfInterval.span(PosInfInterval!Date(Date(2010, 7, 4)))));
static assert(!__traits(compiles, negInfInterval.span(PosInfInterval!Date(Date(2010, 7, 5)))));
static assert(!__traits(compiles, negInfInterval.span(PosInfInterval!Date(Date(2012, 1, 6)))));
static assert(!__traits(compiles, negInfInterval.span(PosInfInterval!Date(Date(2012, 1, 7)))));
static assert(!__traits(compiles, negInfInterval.span(PosInfInterval!Date(Date(2012, 1, 8)))));
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
const cInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
immutable iInterval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
immutable iPosInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, negInfInterval.span(interval)));
static assert(__traits(compiles, negInfInterval.span(cInterval)));
static assert(__traits(compiles, negInfInterval.span(iInterval)));
static assert(!__traits(compiles, negInfInterval.span(posInfInterval)));
static assert(!__traits(compiles, negInfInterval.span(cPosInfInterval)));
static assert(!__traits(compiles, negInfInterval.span(iPosInfInterval)));
static assert(__traits(compiles, negInfInterval.span(negInfInterval)));
static assert(__traits(compiles, negInfInterval.span(cNegInfInterval)));
static assert(__traits(compiles, negInfInterval.span(iNegInfInterval)));
static assert(__traits(compiles, cNegInfInterval.span(interval)));
static assert(__traits(compiles, cNegInfInterval.span(cInterval)));
static assert(__traits(compiles, cNegInfInterval.span(iInterval)));
static assert(!__traits(compiles, cNegInfInterval.span(posInfInterval)));
static assert(!__traits(compiles, cNegInfInterval.span(cPosInfInterval)));
static assert(!__traits(compiles, cNegInfInterval.span(iPosInfInterval)));
static assert(__traits(compiles, cNegInfInterval.span(negInfInterval)));
static assert(__traits(compiles, cNegInfInterval.span(cNegInfInterval)));
static assert(__traits(compiles, cNegInfInterval.span(iNegInfInterval)));
static assert(__traits(compiles, iNegInfInterval.span(interval)));
static assert(__traits(compiles, iNegInfInterval.span(cInterval)));
static assert(__traits(compiles, iNegInfInterval.span(iInterval)));
static assert(!__traits(compiles, iNegInfInterval.span(posInfInterval)));
static assert(!__traits(compiles, iNegInfInterval.span(cPosInfInterval)));
static assert(!__traits(compiles, iNegInfInterval.span(iPosInfInterval)));
static assert(__traits(compiles, iNegInfInterval.span(negInfInterval)));
static assert(__traits(compiles, iNegInfInterval.span(cNegInfInterval)));
static assert(__traits(compiles, iNegInfInterval.span(iNegInfInterval)));
//Verify Examples.
assert(NegInfInterval!Date(Date(2012, 3, 1)).span(Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) == NegInfInterval!Date(Date(2012, 3 , 1)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).span(Interval!Date(Date(1999, 1, 12), Date(2015, 9, 2))) == NegInfInterval!Date(Date(2015, 9 , 2)));
assert(NegInfInterval!Date(Date(1600, 1, 7)).span(Interval!Date(Date(2012, 3, 11), Date(2017, 7, 1))) == NegInfInterval!Date(Date(2017, 7 , 1)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).span(NegInfInterval!Date(Date(1999, 7, 6))) == NegInfInterval!Date(Date(2012, 3 , 1)));
assert(NegInfInterval!Date(Date(2012, 3, 1)).span(NegInfInterval!Date(Date(2013, 1, 12))) == NegInfInterval!Date(Date(2013, 1 , 12)));
}
}
//Test NegInfInterval's shift().
unittest
{
version(testStdDateTime)
{
auto interval = NegInfInterval!Date(Date(2012, 1, 7));
static void testInterval(I)(I interval, in Duration duration, in I expected, size_t line = __LINE__)
{
interval.shift(duration);
_assertPred!"=="(interval, expected, "", __FILE__, line);
}
testInterval(interval, dur!"days"(22), NegInfInterval!Date(Date(2012, 1, 29)));
testInterval(interval, dur!"days"(-22), NegInfInterval!Date(Date(2011, 12, 16)));
const cInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(!__traits(compiles, cInterval.shift(dur!"days"(5))));
static assert(!__traits(compiles, iInterval.shift(dur!"days"(5))));
//Verify Examples.
auto interval1 = NegInfInterval!Date(Date(2012, 4, 5));
auto interval2 = NegInfInterval!Date(Date(2012, 4, 5));
interval1.shift(dur!"days"(50));
assert(interval1 == NegInfInterval!Date(Date(2012, 5, 25)));
interval2.shift(dur!"days"(-50));
assert(interval2 == NegInfInterval!Date( Date(2012, 2, 15)));
}
}
//Test NegInfInterval's shift(int, int, AllowDayOverflow).
unittest
{
version(testStdDateTime)
{
{
auto interval = NegInfInterval!Date(Date(2012, 1, 7));
static void testIntervalFail(I)(I interval, int years, int months)
{
interval.shift(years, months);
}
static void testInterval(I)(I interval, int years, int months, AllowDayOverflow allow, in I expected, size_t line = __LINE__)
{
interval.shift(years, months, allow);
_assertPred!"=="(interval, expected, "", __FILE__, line);
}
testInterval(interval, 5, 0, AllowDayOverflow.yes, NegInfInterval!Date(Date(2017, 1, 7)));
testInterval(interval, -5, 0, AllowDayOverflow.yes, NegInfInterval!Date(Date(2007, 1, 7)));
auto interval2 = NegInfInterval!Date(Date(2010, 5, 31));
testInterval(interval2, 1, 1, AllowDayOverflow.yes, NegInfInterval!Date(Date(2011, 7, 1)));
testInterval(interval2, 1, -1, AllowDayOverflow.yes, NegInfInterval!Date(Date(2011, 5, 1)));
testInterval(interval2, -1, -1, AllowDayOverflow.yes, NegInfInterval!Date(Date(2009, 5, 1)));
testInterval(interval2, -1, 1, AllowDayOverflow.yes, NegInfInterval!Date(Date(2009, 7, 1)));
testInterval(interval2, 1, 1, AllowDayOverflow.no, NegInfInterval!Date(Date(2011, 6, 30)));
testInterval(interval2, 1, -1, AllowDayOverflow.no, NegInfInterval!Date(Date(2011, 4, 30)));
testInterval(interval2, -1, -1, AllowDayOverflow.no, NegInfInterval!Date(Date(2009, 4, 30)));
testInterval(interval2, -1, 1, AllowDayOverflow.no, NegInfInterval!Date(Date(2009, 6, 30)));
}
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(!__traits(compiles, cNegInfInterval.shift(1)));
static assert(!__traits(compiles, iNegInfInterval.shift(1)));
//Verify Examples.
auto interval1 = NegInfInterval!Date(Date(2012, 3, 1));
auto interval2 = NegInfInterval!Date(Date(2012, 3, 1));
interval1.shift(2);
assert(interval1 == NegInfInterval!Date(Date(2014, 3, 1)));
interval2.shift(-2);
assert(interval2 == NegInfInterval!Date(Date(2010, 3, 1)));
}
}
//Test NegInfInterval's expand().
unittest
{
version(testStdDateTime)
{
auto interval = NegInfInterval!Date(Date(2012, 1, 7));
static void testInterval(I)(I interval, in Duration duration, in I expected, size_t line = __LINE__)
{
interval.expand(duration);
_assertPred!"=="(interval, expected, "", __FILE__, line);
}
testInterval(interval, dur!"days"(22), NegInfInterval!Date(Date(2012, 1, 29)));
testInterval(interval, dur!"days"(-22), NegInfInterval!Date(Date(2011, 12, 16)));
const cInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(!__traits(compiles, cInterval.expand(dur!"days"(5))));
static assert(!__traits(compiles, iInterval.expand(dur!"days"(5))));
//Verify Examples.
auto interval1 = NegInfInterval!Date(Date(2012, 3, 1));
auto interval2 = NegInfInterval!Date(Date(2012, 3, 1));
interval1.expand(dur!"days"(2));
assert(interval1 == NegInfInterval!Date(Date(2012, 3, 3)));
interval2.expand(dur!"days"(-2));
assert(interval2 == NegInfInterval!Date(Date(2012, 2, 28)));
}
}
//Test NegInfInterval's expand(int, int, AllowDayOverflow).
unittest
{
version(testStdDateTime)
{
{
auto interval = NegInfInterval!Date(Date(2012, 1, 7));
static void testInterval(I)(I interval, int years, int months, AllowDayOverflow allow, in I expected, size_t line = __LINE__)
{
interval.expand(years, months, allow);
_assertPred!"=="(interval, expected, "", __FILE__, line);
}
testInterval(interval, 5, 0, AllowDayOverflow.yes, NegInfInterval!Date(Date(2017, 1, 7)));
testInterval(interval, -5, 0, AllowDayOverflow.yes, NegInfInterval!Date(Date(2007, 1, 7)));
auto interval2 = NegInfInterval!Date(Date(2010, 5, 31));
testInterval(interval2, 1, 1, AllowDayOverflow.yes, NegInfInterval!Date(Date(2011, 7, 1)));
testInterval(interval2, 1, -1, AllowDayOverflow.yes, NegInfInterval!Date(Date(2011, 5, 1)));
testInterval(interval2, -1, -1, AllowDayOverflow.yes, NegInfInterval!Date(Date(2009, 5, 1)));
testInterval(interval2, -1, 1, AllowDayOverflow.yes, NegInfInterval!Date(Date(2009, 7, 1)));
testInterval(interval2, 1, 1, AllowDayOverflow.no, NegInfInterval!Date(Date(2011, 6, 30)));
testInterval(interval2, 1, -1, AllowDayOverflow.no, NegInfInterval!Date(Date(2011, 4, 30)));
testInterval(interval2, -1, -1, AllowDayOverflow.no, NegInfInterval!Date(Date(2009, 4, 30)));
testInterval(interval2, -1, 1, AllowDayOverflow.no, NegInfInterval!Date( Date(2009, 6, 30)));
}
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(!__traits(compiles, cNegInfInterval.expand(1)));
static assert(!__traits(compiles, iNegInfInterval.expand(1)));
//Verify Examples.
auto interval1 = NegInfInterval!Date(Date(2012, 3, 1));
auto interval2 = NegInfInterval!Date(Date(2012, 3, 1));
interval1.expand(2);
assert(interval1 == NegInfInterval!Date(Date(2014, 3, 1)));
interval2.expand(-2);
assert(interval2 == NegInfInterval!Date(Date(2010, 3, 1)));
}
}
//Test NegInfInterval's bwdRange().
unittest
{
version(testStdDateTime)
{
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static void testInterval(NegInfInterval!Date negInfInterval)
{
negInfInterval.bwdRange(everyDayOfWeek!(Date, Direction.fwd)(DayOfWeek.fri)).popFront();
}
assertThrown!DateTimeException(testInterval(negInfInterval));
_assertPred!"=="(NegInfInterval!Date(Date(2010, 10, 1)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri)).front,
Date(2010, 10, 1));
_assertPred!"=="(NegInfInterval!Date(Date(2010, 10, 1)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri), PopFirst.yes).front,
Date(2010, 9, 24));
//Verify Examples.
auto interval = NegInfInterval!Date(Date(2010, 9, 9));
auto func = (in Date date)
{
if((date.day & 1) == 0)
return date - dur!"days"(2);
return date - dur!"days"(1);
};
auto range = interval.bwdRange(func);
//An odd day. Using PopFirst.yes would have made this Date(2010, 9, 8).
assert(range.front == Date(2010, 9, 9));
range.popFront();
assert(range.front == Date(2010, 9, 8));
range.popFront();
assert(range.front == Date(2010, 9, 6));
range.popFront();
assert(range.front == Date(2010, 9, 4));
range.popFront();
assert(range.front == Date(2010, 9, 2));
range.popFront();
assert(!range.empty);
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, cNegInfInterval.bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri))));
static assert(__traits(compiles, iNegInfInterval.bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri))));
}
}
//Test NegInfInterval's toString().
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(NegInfInterval!Date(Date(2012, 1, 7)).toString(), "[-∞ - 2012-Jan-07)");
const cNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
immutable iNegInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
static assert(__traits(compiles, cNegInfInterval.toString()));
static assert(__traits(compiles, iNegInfInterval.toString()));
}
}
/++
Range-generating function.
Returns a delegate which returns the next time point with the given
$(D DayOfWeek) in a range.
Using this delegate allows you to iterate over successive time points which
are all the same day of the week. e.g. passing $(D DayOfWeek.mon) to
$(D everyDayOfWeek) would result in a delegate which could be used to
iterate over all of the Mondays in a range.
Params:
dir = The direction to iterate in. If passing the return value to
$(D fwdRange), use $(D Direction.fwd). If passing it to
$(D bwdRange), use $(D Direction.bwd).
dayOfWeek = The week that each time point in the range will be.
Examples:
--------------------
auto interval = Interval!Date(Date(2010, 9, 2), Date(2010, 9, 27));
auto func = everyDayOfWeek!Date(DayOfWeek.mon);
auto range = interval.fwdRange(func);
//A Thursday. Using PopFirst.yes would have made this Date(2010, 9, 6).
assert(range.front == Date(2010, 9, 2));
range.popFront();
assert(range.front == Date(2010, 9, 6));
range.popFront();
assert(range.front == Date(2010, 9, 13));
range.popFront();
assert(range.front == Date(2010, 9, 20));
range.popFront();
assert(range.empty);
--------------------
+/
static TP delegate(in TP) everyDayOfWeek(TP, Direction dir = Direction.fwd)(DayOfWeek dayOfWeek) nothrow
if(isTimePoint!TP &&
(dir == Direction.fwd || dir == Direction.bwd) &&
__traits(hasMember, TP, "dayOfWeek") &&
!__traits(isStaticFunction, TP.dayOfWeek) &&
is(ReturnType!(TP.dayOfWeek) == DayOfWeek) &&
(functionAttributes!(TP.dayOfWeek) & FunctionAttribute.property) &&
(functionAttributes!(TP.dayOfWeek) & FunctionAttribute.nothrow_))
{
TP func(in TP tp)
{
TP retval = cast(TP)tp;
immutable days = daysToDayOfWeek(retval.dayOfWeek, dayOfWeek);
static if(dir == Direction.fwd)
immutable adjustedDays = days == 0 ? 7 : days;
else
immutable adjustedDays = days == 0 ? -7 : days - 7;
return retval += dur!"days"(adjustedDays);
}
return &func;
}
unittest
{
version(testStdDateTime)
{
auto funcFwd = everyDayOfWeek!Date(DayOfWeek.mon);
auto funcBwd = everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.mon);
_assertPred!"=="(funcFwd(Date(2010, 8, 28)), Date(2010, 8, 30));
_assertPred!"=="(funcFwd(Date(2010, 8, 29)), Date(2010, 8, 30));
_assertPred!"=="(funcFwd(Date(2010, 8, 30)), Date(2010, 9, 6));
_assertPred!"=="(funcFwd(Date(2010, 8, 31)), Date(2010, 9, 6));
_assertPred!"=="(funcFwd(Date(2010, 9, 1)), Date(2010, 9, 6));
_assertPred!"=="(funcFwd(Date(2010, 9, 2)), Date(2010, 9, 6));
_assertPred!"=="(funcFwd(Date(2010, 9, 3)), Date(2010, 9, 6));
_assertPred!"=="(funcFwd(Date(2010, 9, 4)), Date(2010, 9, 6));
_assertPred!"=="(funcFwd(Date(2010, 9, 5)), Date(2010, 9, 6));
_assertPred!"=="(funcFwd(Date(2010, 9, 6)), Date(2010, 9, 13));
_assertPred!"=="(funcFwd(Date(2010, 9, 7)), Date(2010, 9, 13));
_assertPred!"=="(funcBwd(Date(2010, 8, 28)), Date(2010, 8, 23));
_assertPred!"=="(funcBwd(Date(2010, 8, 29)), Date(2010, 8, 23));
_assertPred!"=="(funcBwd(Date(2010, 8, 30)), Date(2010, 8, 23));
_assertPred!"=="(funcBwd(Date(2010, 8, 31)), Date(2010, 8, 30));
_assertPred!"=="(funcBwd(Date(2010, 9, 1)), Date(2010, 8, 30));
_assertPred!"=="(funcBwd(Date(2010, 9, 2)), Date(2010, 8, 30));
_assertPred!"=="(funcBwd(Date(2010, 9, 3)), Date(2010, 8, 30));
_assertPred!"=="(funcBwd(Date(2010, 9, 4)), Date(2010, 8, 30));
_assertPred!"=="(funcBwd(Date(2010, 9, 5)), Date(2010, 8, 30));
_assertPred!"=="(funcBwd(Date(2010, 9, 6)), Date(2010, 8, 30));
_assertPred!"=="(funcBwd(Date(2010, 9, 7)), Date(2010, 9, 6));
static assert(!__traits(compiles, everyDayOfWeek!(TimeOfDay)(DayOfWeek.mon)));
static assert(__traits(compiles, everyDayOfWeek!(DateTime)(DayOfWeek.mon)));
static assert(__traits(compiles, everyDayOfWeek!(SysTime)(DayOfWeek.mon)));
//Verify Examples.
auto interval = Interval!Date(Date(2010, 9, 2), Date(2010, 9, 27));
auto func = everyDayOfWeek!Date(DayOfWeek.mon);
auto range = interval.fwdRange(func);
//A Thursday. Using PopFirst.yes would have made this Date(2010, 9, 6).
assert(range.front == Date(2010, 9, 2));
range.popFront();
assert(range.front == Date(2010, 9, 6));
range.popFront();
assert(range.front == Date(2010, 9, 13));
range.popFront();
assert(range.front == Date(2010, 9, 20));
range.popFront();
assert(range.empty);
}
}
/++
Range-generating function.
Returns a delegate which returns the next time point with the given month
which would be reached by adding months to the given time point.
So, using this delegate allows you to iterate over successive time points
which are in the same month but different years. For example, you could
iterate over each successive December 25th in an interval by starting with a
date which had the 25th as its day and passed $(D Month.dec) to
$(D everyMonth) to create the delegate.
Since it wouldn't really make sense to be iterating over a specific month
and end up with some of the time points in the succeeding month or two years
after the previous time point, $(D AllowDayOverflow.no) is always used when
calculating the next time point.
Params:
dir = The direction to iterate in. If passing the return value to
$(D fwdRange), use $(D Direction.fwd). If passing it to
$(D bwdRange), use $(D Direction.bwd).
month = The month that each time point in the range will be in.
Examples:
--------------------
auto interval = Interval!Date(Date(2000, 1, 30), Date(2004, 8, 5));
auto func = everyMonth!(Date)(Month.feb);
auto range = interval.fwdRange(func);
//Using PopFirst.yes would have made this Date(2010, 2, 29).
assert(range.front == Date(2000, 1, 30));
range.popFront();
assert(range.front == Date(2000, 2, 29));
range.popFront();
assert(range.front == Date(2001, 2, 28));
range.popFront();
assert(range.front == Date(2002, 2, 28));
range.popFront();
assert(range.front == Date(2003, 2, 28));
range.popFront();
assert(range.front == Date(2004, 2, 28));
range.popFront();
assert(range.empty);
--------------------
+/
static TP delegate(in TP) everyMonth(TP, Direction dir = Direction.fwd)(int month)
if(isTimePoint!TP &&
(dir == Direction.fwd || dir == Direction.bwd) &&
__traits(hasMember, TP, "month") &&
!__traits(isStaticFunction, TP.month) &&
is(ReturnType!(TP.month) == Month) &&
(functionAttributes!(TP.month) & FunctionAttribute.property) &&
(functionAttributes!(TP.month) & FunctionAttribute.nothrow_))
{
enforceValid!"months"(month);
TP func(in TP tp)
{
TP retval = cast(TP)tp;
immutable months = monthsToMonth(retval.month, month);
static if(dir == Direction.fwd)
immutable adjustedMonths = months == 0 ? 12 : months;
else
immutable adjustedMonths = months == 0 ? -12 : months - 12;
retval.add!"months"(adjustedMonths, AllowDayOverflow.no);
if(retval.month != month)
{
retval.add!"months"(-1);
assert(retval.month == month);
}
return retval;
}
return &func;
}
unittest
{
version(testStdDateTime)
{
auto funcFwd = everyMonth!Date(Month.jun);
auto funcBwd = everyMonth!(Date, Direction.bwd)(Month.jun);
_assertPred!"=="(funcFwd(Date(2010, 5, 31)), Date(2010, 6, 30));
_assertPred!"=="(funcFwd(Date(2010, 6, 30)), Date(2011, 6, 30));
_assertPred!"=="(funcFwd(Date(2010, 7, 31)), Date(2011, 6, 30));
_assertPred!"=="(funcFwd(Date(2010, 8, 31)), Date(2011, 6, 30));
_assertPred!"=="(funcFwd(Date(2010, 9, 30)), Date(2011, 6, 30));
_assertPred!"=="(funcFwd(Date(2010, 10, 31)), Date(2011, 6, 30));
_assertPred!"=="(funcFwd(Date(2010, 11, 30)), Date(2011, 6, 30));
_assertPred!"=="(funcFwd(Date(2010, 12, 31)), Date(2011, 6, 30));
_assertPred!"=="(funcFwd(Date(2011, 1, 31)), Date(2011, 6, 30));
_assertPred!"=="(funcFwd(Date(2011, 2, 28)), Date(2011, 6, 28));
_assertPred!"=="(funcFwd(Date(2011, 3, 31)), Date(2011, 6, 30));
_assertPred!"=="(funcFwd(Date(2011, 4, 30)), Date(2011, 6, 30));
_assertPred!"=="(funcFwd(Date(2011, 5, 31)), Date(2011, 6, 30));
_assertPred!"=="(funcFwd(Date(2011, 6, 30)), Date(2012, 6, 30));
_assertPred!"=="(funcFwd(Date(2011, 7, 31)), Date(2012, 6, 30));
_assertPred!"=="(funcBwd(Date(2010, 5, 31)), Date(2009, 6, 30));
_assertPred!"=="(funcBwd(Date(2010, 6, 30)), Date(2009, 6, 30));
_assertPred!"=="(funcBwd(Date(2010, 7, 31)), Date(2010, 6, 30));
_assertPred!"=="(funcBwd(Date(2010, 8, 31)), Date(2010, 6, 30));
_assertPred!"=="(funcBwd(Date(2010, 9, 30)), Date(2010, 6, 30));
_assertPred!"=="(funcBwd(Date(2010, 10, 31)), Date(2010, 6, 30));
_assertPred!"=="(funcBwd(Date(2010, 11, 30)), Date(2010, 6, 30));
_assertPred!"=="(funcBwd(Date(2010, 12, 31)), Date(2010, 6, 30));
_assertPred!"=="(funcBwd(Date(2011, 1, 31)), Date(2010, 6, 30));
_assertPred!"=="(funcBwd(Date(2011, 2, 28)), Date(2010, 6, 28));
_assertPred!"=="(funcBwd(Date(2011, 3, 31)), Date(2010, 6, 30));
_assertPred!"=="(funcBwd(Date(2011, 4, 30)), Date(2010, 6, 30));
_assertPred!"=="(funcBwd(Date(2011, 5, 31)), Date(2010, 6, 30));
_assertPred!"=="(funcBwd(Date(2011, 6, 30)), Date(2010, 6, 30));
_assertPred!"=="(funcBwd(Date(2011, 7, 30)), Date(2011, 6, 30));
static assert(!__traits(compiles, everyMonth!(TimeOfDay)(Month.jan)));
static assert(__traits(compiles, everyMonth!(DateTime)(Month.jan)));
static assert(__traits(compiles, everyMonth!(SysTime)(Month.jan)));
//Verify Examples.
auto interval = Interval!Date(Date(2000, 1, 30), Date(2004, 8, 5));
auto func = everyMonth!(Date)(Month.feb);
auto range = interval.fwdRange(func);
//Using PopFirst.yes would have made this Date(2010, 2, 29).
assert(range.front == Date(2000, 1, 30));
range.popFront();
assert(range.front == Date(2000, 2, 29));
range.popFront();
assert(range.front == Date(2001, 2, 28));
range.popFront();
assert(range.front == Date(2002, 2, 28));
range.popFront();
assert(range.front == Date(2003, 2, 28));
range.popFront();
assert(range.front == Date(2004, 2, 28));
range.popFront();
assert(range.empty);
}
}
/++
Range-generating function.
Returns a delegate which returns the next time point which is the given
duration later.
Using this delegate allows you to iterate over successive time points which
are apart by the given duration e.g. passing $(D dur!"days"(3)) to
$(D everyDuration) would result in a delegate which could be used to iterate
over a range of days which are each 3 days apart.
Params:
dir = The direction to iterate in. If passing the return value to
$(D fwdRange), use $(D Direction.fwd). If passing it to
$(D bwdRange), use $(D Direction.bwd).
duration = The duration which separates each successive time point in
the range.
Examples:
--------------------
auto interval = Interval!Date(Date(2010, 9, 2), Date(2010, 9, 27));
auto func = everyDuration!Date(dur!"days"(8));
auto range = interval.fwdRange(func);
//Using PopFirst.yes would have made this Date(2010, 9, 10).
assert(range.front == Date(2010, 9, 2));
range.popFront();
assert(range.front == Date(2010, 9, 10));
range.popFront();
assert(range.front == Date(2010, 9, 18));
range.popFront();
assert(range.front == Date(2010, 9, 26));
range.popFront();
assert(range.empty);
--------------------
+/
static TP delegate(in TP) everyDuration(TP, Direction dir = Direction.fwd, D)
(D duration) nothrow
if(isTimePoint!TP &&
__traits(compiles, TP.init + duration) &&
(dir == Direction.fwd || dir == Direction.bwd))
{
TP func(in TP tp)
{
static if(dir == Direction.fwd)
return tp + duration;
else
return tp - duration;
}
return &func;
}
unittest
{
version(testStdDateTime)
{
auto funcFwd = everyDuration!Date(dur!"days"(27));
auto funcBwd = everyDuration!(Date, Direction.bwd)(dur!"days"(27));
_assertPred!"=="(funcFwd(Date(2009, 12, 25)), Date(2010, 1, 21));
_assertPred!"=="(funcFwd(Date(2009, 12, 26)), Date(2010, 1, 22));
_assertPred!"=="(funcFwd(Date(2009, 12, 27)), Date(2010, 1, 23));
_assertPred!"=="(funcFwd(Date(2009, 12, 28)), Date(2010, 1, 24));
_assertPred!"=="(funcBwd(Date(2010, 1, 21)), Date(2009, 12, 25));
_assertPred!"=="(funcBwd(Date(2010, 1, 22)), Date(2009, 12, 26));
_assertPred!"=="(funcBwd(Date(2010, 1, 23)), Date(2009, 12, 27));
_assertPred!"=="(funcBwd(Date(2010, 1, 24)), Date(2009, 12, 28));
static assert(__traits(compiles, everyDuration!Date(dur!"hnsecs"(1))));
static assert(__traits(compiles, everyDuration!TimeOfDay(dur!"hnsecs"(1))));
static assert(__traits(compiles, everyDuration!DateTime(dur!"hnsecs"(1))));
static assert(__traits(compiles, everyDuration!SysTime(dur!"hnsecs"(1))));
//Verify Examples.
auto interval = Interval!Date(Date(2010, 9, 2), Date(2010, 9, 27));
auto func = everyDuration!Date(dur!"days"(8));
auto range = interval.fwdRange(func);
//Using PopFirst.yes would have made this Date(2010, 9, 10).
assert(range.front == Date(2010, 9, 2));
range.popFront();
assert(range.front == Date(2010, 9, 10));
range.popFront();
assert(range.front == Date(2010, 9, 18));
range.popFront();
assert(range.front == Date(2010, 9, 26));
range.popFront();
assert(range.empty);
}
}
/++
Range-generating function.
Returns a delegate which returns the next time point which is the given
number of years, month, and duration later.
The difference between this version of $(D everyDuration) and the version
which just takes a $(D Duration) is that this one also takes the number of
years and months (along with an $(D AllowDayOverflow) to indicate whether
adding years and months should allow the days to overflow).
Note that if iterating forward, $(D add!"years"()) is called on the given
time point, then $(D add!"months"()), and finally the duration is added
to it. However, if iterating backwards, the duration is added first, then
$(D add!"months"()) is called, and finally $(D add!"years"()) is called.
That way, going backwards generates close to the same time points that
iterating forward does, but since adding years and months is not entirely
reversible (due to possible day overflow, regardless of whether
$(D AllowDayOverflow.yes) or $(D AllowDayOverflow.no) is used), it can't be
guaranteed that iterating backwards will give you the same time points as
iterating forward would have (even assuming that the end of the range is a
time point which would be returned by the delegate when iterating forward
from $(D begin)).
Params:
dir = The direction to iterate in. If passing the return
value to $(D fwdRange), use $(D Direction.fwd). If
passing it to $(D bwdRange), use $(D Direction.bwd).
years = The number of years to add to the time point passed to
the delegate.
months = The number of months to add to the time point passed to
the delegate.
allowOverflow = Whether the days should be allowed to overflow on
$(D begin) and $(D end), causing their month to
increment.
duration = The duration to add to the time point passed to the
delegate.
Examples:
--------------------
auto interval = Interval!Date(Date(2010, 9, 2), Date(2025, 9, 27));
auto func = everyDuration!Date(4, 1, AllowDayOverflow.yes, dur!"days"(2));
auto range = interval.fwdRange(func);
//Using PopFirst.yes would have made this Date(2014, 10, 12).
assert(range.front == Date(2010, 9, 2));
range.popFront();
assert(range.front == Date(2014, 10, 4));
range.popFront();
assert(range.front == Date(2018, 11, 6));
range.popFront();
assert(range.front == Date(2022, 12, 8));
range.popFront();
assert(range.empty);
--------------------
+/
static TP delegate(in TP) everyDuration(TP, Direction dir = Direction.fwd, D)
(int years,
int months = 0,
AllowDayOverflow allowOverflow = AllowDayOverflow.yes,
D duration = dur!"days"(0)) nothrow
if(isTimePoint!TP &&
__traits(compiles, TP.init + duration) &&
__traits(compiles, TP.init.add!"years"(years)) &&
__traits(compiles, TP.init.add!"months"(months)) &&
(dir == Direction.fwd || dir == Direction.bwd))
{
TP func(in TP tp)
{
static if(dir == Direction.fwd)
{
TP retval = cast(TP)tp;
retval.add!"years"(years, allowOverflow);
retval.add!"months"(months, allowOverflow);
return retval + duration;
}
else
{
TP retval = tp - duration;
retval.add!"months"(-months, allowOverflow);
retval.add!"years"(-years, allowOverflow);
return retval;
}
}
return &func;
}
unittest
{
version(testStdDateTime)
{
{
auto funcFwd = everyDuration!Date(1, 2, AllowDayOverflow.yes, dur!"days"(3));
auto funcBwd = everyDuration!(Date, Direction.bwd)(1, 2, AllowDayOverflow.yes, dur!"days"(3));
_assertPred!"=="(funcFwd(Date(2009, 12, 25)), Date(2011, 2, 28));
_assertPred!"=="(funcFwd(Date(2009, 12, 26)), Date(2011, 3, 1));
_assertPred!"=="(funcFwd(Date(2009, 12, 27)), Date(2011, 3, 2));
_assertPred!"=="(funcFwd(Date(2009, 12, 28)), Date(2011, 3, 3));
_assertPred!"=="(funcFwd(Date(2009, 12, 29)), Date(2011, 3, 4));
_assertPred!"=="(funcBwd(Date(2011, 2, 28)), Date(2009, 12, 25));
_assertPred!"=="(funcBwd(Date(2011, 3, 1)), Date(2009, 12, 26));
_assertPred!"=="(funcBwd(Date(2011, 3, 2)), Date(2009, 12, 27));
_assertPred!"=="(funcBwd(Date(2011, 3, 3)), Date(2009, 12, 28));
_assertPred!"=="(funcBwd(Date(2011, 3, 4)), Date(2010, 1, 1));
}
{
auto funcFwd = everyDuration!Date(1, 2, AllowDayOverflow.no, dur!"days"(3));
auto funcBwd = everyDuration!(Date, Direction.bwd)(1, 2, AllowDayOverflow.yes, dur!"days"(3));
_assertPred!"=="(funcFwd(Date(2009, 12, 25)), Date(2011, 2, 28));
_assertPred!"=="(funcFwd(Date(2009, 12, 26)), Date(2011, 3, 1));
_assertPred!"=="(funcFwd(Date(2009, 12, 27)), Date(2011, 3, 2));
_assertPred!"=="(funcFwd(Date(2009, 12, 28)), Date(2011, 3, 3));
_assertPred!"=="(funcFwd(Date(2009, 12, 29)), Date(2011, 3, 3));
_assertPred!"=="(funcBwd(Date(2011, 2, 28)), Date(2009, 12, 25));
_assertPred!"=="(funcBwd(Date(2011, 3, 1)), Date(2009, 12, 26));
_assertPred!"=="(funcBwd(Date(2011, 3, 2)), Date(2009, 12, 27));
_assertPred!"=="(funcBwd(Date(2011, 3, 3)), Date(2009, 12, 28));
_assertPred!"=="(funcBwd(Date(2011, 3, 4)), Date(2010, 1, 1));
}
static assert(__traits(compiles, everyDuration!Date(1, 2, AllowDayOverflow.yes, dur!"hnsecs"(1))));
static assert(!__traits(compiles, everyDuration!TimeOfDay(1, 2, AllowDayOverflow.yes, dur!"hnsecs"(1))));
static assert(__traits(compiles, everyDuration!DateTime(1, 2, AllowDayOverflow.yes, dur!"hnsecs"(1))));
static assert(__traits(compiles, everyDuration!SysTime(1, 2, AllowDayOverflow.yes, dur!"hnsecs"(1))));
//Verify Examples.
auto interval = Interval!Date(Date(2010, 9, 2), Date(2025, 9, 27));
auto func = everyDuration!Date(4, 1, AllowDayOverflow.yes, dur!"days"(2));
auto range = interval.fwdRange(func);
//Using PopFirst.yes would have made this Date(2014, 10, 12).
assert(range.front == Date(2010, 9, 2));
range.popFront();
assert(range.front == Date(2014, 10, 4));
range.popFront();
assert(range.front == Date(2018, 11, 6));
range.popFront();
assert(range.front == Date(2022, 12, 8));
range.popFront();
assert(range.empty);
}
}
//TODO Add function to create a range generating function based on a date recurrence pattern string.
// This may or may not involve creating a date recurrence pattern class of some sort - probably
// yes if we want to make it easy to build them. However, there is a standard recurrence
// pattern string format which we'd want to support with a range generator (though if we have
// the class/struct, we'd probably want a version of the range generating function which took
// that rather than a string).
//==============================================================================
// Section with ranges.
//==============================================================================
/++
A range over an $(D Interval).
$(D IntervalRange) is only ever constructed by $(D Interval). However, when
it is constructed, it is given a function, $(D func), which is used to
generate the time points which are iterated over. $(D func) takes a time
point and returns a time point of the same type. So, for instance, if you
had an $(D Interval!Date), and you wanted to iterate over all of the days in
that interval, you would pass a function to $(D Interval)'s $(D fwdRange)
where that function took a $(D Date) and returned a $(D Date) which was one
day later. That function would then be used by $(D IntervalRange)'s
$(D popFront) to iterate over the $(D Date)s in the interval.
If $(D dir == Direction.fwd), then a range iterates forward in time, whereas
if $(D dir == Direction.bwd), then it iterates backwards in time. So, if
$(D dir == Direction.fwd) then $(D front == interval.begin), whereas if
$(D dir == Direction.bwd) then $(D front == interval.end). $(D func) must
generate a time point going in the proper direction of iteration, or a
$(D DateTimeException) will be thrown. So, if you're iterating forward in
time, the time point that $(D func) generates must be later in time than the
one passed to it. If it's either identical or earlier in time, then a
$(D DateTimeException) will be thrown. If you're iterating backwards, then
the generated time point must be before the time point which was passed in.
If the generated time point is ever passed the edge of the range in the
proper direction, then the edge of that range will be used instead. So, if
iterating forward, and the generated time point is past the interval's
$(D end), then $(D front) becomes $(D end). If iterating backwards, and the
generated time point is before $(D begin), then $(D front) becomes
$(D begin). In either case, the range would then be empty.
Also note that while normally the $(D begin) of an interval is included in
it and its $(D end) is excluded from it, if $(D dir == Direction.bwd), then
$(D begin) is treated as excluded and $(D end) is treated as included. This
allows for the same behavior in both directions. This works because none of
$(D Interval)'s functions which care about whether $(D begin) or $(D end) is
included or excluded are ever called by $(D IntervalRange). $(D interval)
returns a normal interval, regardless of whether $(D dir == Direction.fwd)
or if $(D dir == Direction.bwd), so any $(D Interval) functions which are
called on it which care about whether $(D begin) or $(D end) are included or
excluded will treat $(D begin) as included and $(D end) as excluded.
+/
struct IntervalRange(TP, Direction dir)
if(isTimePoint!TP && dir != Direction.both)
{
public:
/++
Params:
rhs = The $(D IntervalRange) to assign to this one.
+/
/+ref+/ IntervalRange opAssign(ref IntervalRange rhs) pure nothrow
{
_interval = rhs._interval;
_func = rhs._func;
return this;
}
/++
Whether this $(D IntervalRange) is empty.
+/
@property bool empty() const pure nothrow
{
return _interval.empty;
}
/++
The first time point in the range.
Throws:
$(D DateTimeException) if the range is empty.
+/
@property TP front() const pure
{
_enforceNotEmpty();
static if(dir == Direction.fwd)
return _interval.begin;
else
return _interval.end;
}
/++
Pops $(D front) from the range, using $(D func) to generate the next
time point in the range. If the generated time point is beyond the edge
of the range, then $(D front) is set to that edge, and the range is then
empty. So, if iterating forwards, and the generated time point is
greater than the interval's $(D end), then $(D front) is set to
$(D end). If iterating backwards, and the generated time point is less
than the interval's $(D begin), then $(D front) is set to $(D begin).
Throws:
$(D DateTimeException) if the range is empty or if the generated
time point is in the wrong direction (i.e. if you're iterating
forward and the generated time point is before $(D front), or if
you're iterating backwards, and the generated time point is after
$(D front)).
+/
void popFront()
{
_enforceNotEmpty();
static if(dir == Direction.fwd)
{
auto begin = _func(_interval.begin);
if(begin > _interval.end)
begin = _interval.end;
_enforceCorrectDirection(begin);
_interval.begin = begin;
}
else
{
auto end = _func(_interval.end);
if(end < _interval.begin)
end = _interval.begin;
_enforceCorrectDirection(end);
_interval.end = end;
}
}
/++
Returns a copy of $(D this).
+/
@property IntervalRange save() pure nothrow
{
return this;
}
/++
The interval that this $(D IntervalRange) currently covers.
+/
@property Interval!TP interval() const pure nothrow
{
return cast(Interval!TP)_interval;
}
/++
The function used to generate the next time point in the range.
+/
TP delegate(in TP) func() pure nothrow @property
{
return _func;
}
/++
The $(D Direction) that this range iterates in.
+/
@property Direction direction() const pure nothrow
{
return dir;
}
private:
/+
Params:
interval = The interval that this range covers.
func = The function used to generate the time points which are
iterated over.
+/
this(in Interval!TP interval, TP delegate(in TP) func) pure nothrow
{
_func = func;
_interval = interval;
}
/+
Throws:
$(D DateTimeException) if this interval is empty.
+/
void _enforceNotEmpty(size_t line = __LINE__) const pure
{
if(empty)
throw new DateTimeException("Invalid operation for an empty IntervalRange.", __FILE__, line);
}
/+
Throws:
$(D DateTimeException) if $(D_PARAM newTP) is in the wrong
direction.
+/
void _enforceCorrectDirection(in TP newTP, size_t line = __LINE__) const
{
static if(dir == Direction.fwd)
{
enforce(newTP > _interval._begin,
new DateTimeException(format("Generated time point is before previous begin: prev [%s] new [%s]",
interval._begin,
newTP),
__FILE__,
line));
}
else
{
enforce(newTP < _interval._end,
new DateTimeException(format("Generated time point is after previous end: prev [%s] new [%s]",
interval._end,
newTP),
__FILE__,
line));
}
}
Interval!TP _interval;
TP delegate(in TP) _func;
}
//Test that IntervalRange satisfies the range predicates that it's supposed to satisfy.
unittest
{
version(testStdDateTime)
{
static assert(isInputRange!(IntervalRange!(Date, Direction.fwd)));
static assert(isForwardRange!(IntervalRange!(Date, Direction.fwd)));
//Commented out due to bug http://d.puremagic.com/issues/show_bug.cgi?id=4895
//static assert(!isOutputRange!(IntervalRange!(Date, Direction.fwd), Date));
static assert(!isBidirectionalRange!(IntervalRange!(Date, Direction.fwd)));
static assert(!isRandomAccessRange!(IntervalRange!(Date, Direction.fwd)));
static assert(!hasSwappableElements!(IntervalRange!(Date, Direction.fwd)));
static assert(!hasAssignableElements!(IntervalRange!(Date, Direction.fwd)));
static assert(!hasLength!(IntervalRange!(Date, Direction.fwd)));
static assert(!isInfinite!(IntervalRange!(Date, Direction.fwd)));
static assert(!hasSlicing!(IntervalRange!(Date, Direction.fwd)));
static assert(is(ElementType!(IntervalRange!(Date, Direction.fwd)) == Date));
static assert(is(ElementType!(IntervalRange!(TimeOfDay, Direction.fwd)) == TimeOfDay));
static assert(is(ElementType!(IntervalRange!(DateTime, Direction.fwd)) == DateTime));
static assert(is(ElementType!(IntervalRange!(SysTime, Direction.fwd)) == SysTime));
}
}
//Test construction of IntervalRange.
unittest
{
version(testStdDateTime)
{
{
Date dateFunc(in Date date)
{
return date;
}
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto ir = IntervalRange!(Date, Direction.fwd)(interval, &dateFunc);
}
{
TimeOfDay todFunc(in TimeOfDay tod)
{
return tod;
}
auto interval = Interval!TimeOfDay(TimeOfDay(12, 1, 7), TimeOfDay(14, 0, 0));
auto ir = IntervalRange!(TimeOfDay, Direction.fwd)(interval, &todFunc);
}
{
DateTime dtFunc(in DateTime dt)
{
return dt;
}
auto interval = Interval!DateTime(DateTime(2010, 7, 4, 12, 1, 7), DateTime(2012, 1, 7, 14, 0, 0));
auto ir = IntervalRange!(DateTime, Direction.fwd)(interval, &dtFunc);
}
{
SysTime stFunc(in SysTime st)
{
return cast(SysTime)st;
}
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);
}
}
}
//Test IntervalRange's empty().
unittest
{
version(testStdDateTime)
{
//fwd
{
auto range = Interval!Date(Date(2010, 9, 19), Date(2010, 9, 21)).fwdRange(everyDayOfWeek!Date(DayOfWeek.fri));
assert(!range.empty);
range.popFront();
assert(range.empty);
const cRange = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)).fwdRange(everyDayOfWeek!Date(DayOfWeek.fri));
static assert(__traits(compiles, cRange.empty));
//Apparently, creating an immutable IntervalRange!Date doesn't work, so we can't test if
//empty works with it. However, since an immutable range is pretty useless, it's no great loss.
}
//bwd
{
auto range = Interval!Date(Date(2010, 9, 19), Date(2010, 9, 21)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri));
assert(!range.empty);
range.popFront();
assert(range.empty);
const cRange = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri));
static assert(__traits(compiles, cRange.empty));
//Apparently, creating an immutable IntervalRange!Date doesn't work, so we can't test if
//empty works with it. However, since an immutable range is pretty useless, it's no great loss.
}
}
}
//Test IntervalRange's front.
unittest
{
version(testStdDateTime)
{
//fwd
{
auto emptyRange = Interval!Date(Date(2010, 9, 19), Date(2010, 9, 20)).fwdRange(everyDayOfWeek!Date(DayOfWeek.wed), PopFirst.yes);
assertThrown!DateTimeException((in IntervalRange!(Date, Direction.fwd) range){range.front;}(emptyRange));
auto range = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)).fwdRange(everyDayOfWeek!Date(DayOfWeek.wed));
_assertPred!"=="(range.front, Date(2010, 7, 4));
auto poppedRange = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)).fwdRange(everyDayOfWeek!Date(DayOfWeek.wed), PopFirst.yes);
_assertPred!"=="(poppedRange.front, Date(2010, 7, 7));
const cRange = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)).fwdRange(everyDayOfWeek!Date(DayOfWeek.fri));
static assert(__traits(compiles, cRange.front));
}
//bwd
{
auto emptyRange = Interval!Date(Date(2010, 9, 19), Date(2010, 9, 20)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.wed), PopFirst.yes);
assertThrown!DateTimeException((in IntervalRange!(Date, Direction.bwd) range){range.front;}(emptyRange));
auto range = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.wed));
_assertPred!"=="(range.front, Date(2012, 1, 7));
auto poppedRange = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.wed), PopFirst.yes);
_assertPred!"=="(poppedRange.front, Date(2012, 1, 4));
const cRange = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri));
static assert(__traits(compiles, cRange.front));
}
}
}
//Test IntervalRange's popFront().
unittest
{
version(testStdDateTime)
{
//fwd
{
auto emptyRange = Interval!Date(Date(2010, 9, 19), Date(2010, 9, 20)).fwdRange(everyDayOfWeek!Date(DayOfWeek.wed), PopFirst.yes);
assertThrown!DateTimeException((IntervalRange!(Date, Direction.fwd) range){range.popFront();}(emptyRange));
auto range = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)).fwdRange(everyDayOfWeek!Date(DayOfWeek.wed), PopFirst.yes);
auto expected = range.front;
foreach(date; range)
{
_assertPred!"=="(date, expected);
expected += dur!"days"(7);
}
_assertPred!"=="(walkLength(range), 79);
const cRange = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)).fwdRange(everyDayOfWeek!Date(DayOfWeek.fri));
static assert(__traits(compiles, cRange.front));
}
//bwd
{
auto emptyRange = Interval!Date(Date(2010, 9, 19), Date(2010, 9, 20)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.wed), PopFirst.yes);
assertThrown!DateTimeException((IntervalRange!(Date, Direction.bwd) range){range.popFront();}(emptyRange));
auto range = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.wed), PopFirst.yes);
auto expected = range.front;
foreach(date; range)
{
_assertPred!"=="(date, expected);
expected += dur!"days"(-7);
}
_assertPred!"=="(walkLength(range), 79);
const cRange = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri));
static assert(!__traits(compiles, cRange.popFront()));
}
}
}
//Test IntervalRange's save.
unittest
{
version(testStdDateTime)
{
//fwd
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto func = everyDayOfWeek!Date(DayOfWeek.fri);
auto range = interval.fwdRange(func);
assert(range.save == range);
}
//bwd
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto func = everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri);
auto range = interval.bwdRange(func);
assert(range.save == range);
}
}
}
//Test IntervalRange's interval.
unittest
{
version(testStdDateTime)
{
//fwd
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto func = everyDayOfWeek!Date(DayOfWeek.fri);
auto range = interval.fwdRange(func);
assert(range.interval == interval);
const cRange = range;
static assert(__traits(compiles, cRange.interval));
}
//bwd
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto func = everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri);
auto range = interval.bwdRange(func);
assert(range.interval == interval);
const cRange = range;
static assert(__traits(compiles, cRange.interval));
}
}
}
//Test IntervalRange's func.
unittest
{
version(testStdDateTime)
{
//fwd
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto func = everyDayOfWeek!Date(DayOfWeek.fri);
auto range = interval.fwdRange(func);
assert(range.func == func);
}
//bwd
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto func = everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri);
auto range = interval.bwdRange(func);
assert(range.func == func);
}
}
}
//Test IntervalRange's direction.
unittest
{
version(testStdDateTime)
{
//fwd
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto func = everyDayOfWeek!Date(DayOfWeek.fri);
auto range = interval.fwdRange(func);
assert(range.direction == Direction.fwd);
const cRange = range;
static assert(__traits(compiles, cRange.direction));
}
//bwd
{
auto interval = Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7));
auto func = everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri);
auto range = interval.bwdRange(func);
assert(range.direction == Direction.bwd);
const cRange = range;
static assert(__traits(compiles, cRange.direction));
}
}
}
/++
A range over a $(D PosInfInterval). It is an infinite range.
$(D PosInfIntervalRange) is only ever constructed by $(D PosInfInterval).
However, when it is constructed, it is given a function, $(D func), which
is used to generate the time points which are iterated over. $(D func)
takes a time point and returns a time point of the same type. So, for
instance, if you had a $(D PosInfInterval!Date), and you wanted to iterate
over all of the days in that interval, you would pass a function to
$(D PosInfInterval)'s $(D fwdRange) where that function took a $(D Date) and
returned a $(D Date) which was one day later. That function would then be
used by $(D PosInfIntervalRange)'s $(D popFront) to iterate over the
$(D Date)s in the interval - though obviously, since the range is infinite,
you would use a function such as $(D std.range.take) with it rather than
iterating over $(I all) of the dates.
As the interval goes to positive infinity, the range is always iterated over
forwards, never backwards. $(D func) must generate a time point going in
the proper direction of iteration, or a $(D DateTimeException) will be
thrown. So, the time points that $(D func) generates must be later in time
than the one passed to it. If it's either identical or earlier in time, then
a $(D DateTimeException) will be thrown.
+/
struct PosInfIntervalRange(TP)
if(isTimePoint!TP)
{
public:
/++
Params:
rhs = The $(D PosInfIntervalRange) to assign to this one.
+/
/+ref+/ PosInfIntervalRange opAssign(ref PosInfIntervalRange rhs) pure nothrow
{
_interval = rhs._interval;
_func = rhs._func;
return this;
}
/++
This is an infinite range, so it is never empty.
+/
enum bool empty = false;
/++
The first time point in the range.
+/
@property TP front() const pure nothrow
{
return _interval.begin;
}
/++
Pops $(D front) from the range, using $(D func) to generate the next
time point in the range.
Throws:
$(D DateTimeException) if the generated time point is less than
$(D front).
+/
void popFront()
{
auto begin = _func(_interval.begin);
_enforceCorrectDirection(begin);
_interval.begin = begin;
}
/++
Returns a copy of $(D this).
+/
@property PosInfIntervalRange save() pure nothrow
{
return this;
}
/++
The interval that this range currently covers.
+/
@property PosInfInterval!TP interval() const pure nothrow
{
return cast(PosInfInterval!TP)_interval;
}
/++
The function used to generate the next time point in the range.
+/
TP delegate(in TP) func() pure nothrow @property
{
return _func;
}
private:
/+
Params:
interval = The interval that this range covers.
func = The function used to generate the time points which are
iterated over.
+/
this(in PosInfInterval!TP interval, TP delegate(in TP) func) pure nothrow
{
_func = func;
_interval = interval;
}
/+
Throws:
$(D DateTimeException) if $(D_PARAME newTP) is in the wrong
direction.
+/
void _enforceCorrectDirection(in TP newTP, size_t line = __LINE__) const
{
enforce(newTP > _interval._begin,
new DateTimeException(format("Generated time point is before previous begin: prev [%s] new [%s]",
interval._begin,
newTP),
__FILE__,
line));
}
PosInfInterval!TP _interval;
TP delegate(in TP) _func;
}
//Test that PosInfIntervalRange satisfies the range predicates that it's supposed to satisfy.
unittest
{
version(testStdDateTime)
{
static assert(isInputRange!(PosInfIntervalRange!Date));
static assert(isForwardRange!(PosInfIntervalRange!Date));
static assert(isInfinite!(PosInfIntervalRange!Date));
//Commented out due to bug http://d.puremagic.com/issues/show_bug.cgi?id=4895
//static assert(!isOutputRange!(PosInfIntervalRange!Date, Date));
static assert(!isBidirectionalRange!(PosInfIntervalRange!Date));
static assert(!isRandomAccessRange!(PosInfIntervalRange!Date));
static assert(!hasSwappableElements!(PosInfIntervalRange!Date));
static assert(!hasAssignableElements!(PosInfIntervalRange!Date));
static assert(!hasLength!(PosInfIntervalRange!Date));
static assert(!hasSlicing!(PosInfIntervalRange!Date));
static assert(is(ElementType!(PosInfIntervalRange!Date) == Date));
static assert(is(ElementType!(PosInfIntervalRange!TimeOfDay) == TimeOfDay));
static assert(is(ElementType!(PosInfIntervalRange!DateTime) == DateTime));
static assert(is(ElementType!(PosInfIntervalRange!SysTime) == SysTime));
}
}
//Test construction of PosInfIntervalRange.
unittest
{
version(testStdDateTime)
{
{
Date dateFunc(in Date date)
{
return date;
}
auto posInfInterval = PosInfInterval!Date(Date(2010, 7, 4));
auto ir = PosInfIntervalRange!Date(posInfInterval, &dateFunc);
}
{
TimeOfDay todFunc(in TimeOfDay tod)
{
return tod;
}
auto posInfInterval = PosInfInterval!TimeOfDay(TimeOfDay(12, 1, 7));
auto ir = PosInfIntervalRange!(TimeOfDay)(posInfInterval, &todFunc);
}
{
DateTime dtFunc(in DateTime dt)
{
return dt;
}
auto posInfInterval = PosInfInterval!DateTime(DateTime(2010, 7, 4, 12, 1, 7));
auto ir = PosInfIntervalRange!(DateTime)(posInfInterval, &dtFunc);
}
{
SysTime stFunc(in SysTime st)
{
return cast(SysTime)st;
}
auto posInfInterval = PosInfInterval!SysTime(SysTime(DateTime(2010, 7, 4, 12, 1, 7)));
auto ir = PosInfIntervalRange!(SysTime)(posInfInterval, &stFunc);
}
}
}
//Test PosInfIntervalRange's front.
unittest
{
version(testStdDateTime)
{
auto range = PosInfInterval!Date(Date(2010, 7, 4)).fwdRange(everyDayOfWeek!Date(DayOfWeek.wed));
_assertPred!"=="(range.front, Date(2010, 7, 4));
auto poppedRange = PosInfInterval!Date(Date(2010, 7, 4)).fwdRange(everyDayOfWeek!Date(DayOfWeek.wed), PopFirst.yes);
_assertPred!"=="(poppedRange.front, Date(2010, 7, 7));
const cRange = PosInfInterval!Date(Date(2010, 7, 4)).fwdRange(everyDayOfWeek!Date(DayOfWeek.fri));
static assert(__traits(compiles, cRange.front));
}
}
//Test PosInfIntervalRange's popFront().
unittest
{
version(testStdDateTime)
{
auto range = PosInfInterval!Date(Date(2010, 7, 4)).fwdRange(everyDayOfWeek!Date(DayOfWeek.wed), PopFirst.yes);
auto expected = range.front;
foreach(date; take(range, 79))
{
_assertPred!"=="(date, expected);
expected += dur!"days"(7);
}
const cRange = PosInfInterval!Date(Date(2010, 7, 4)).fwdRange(everyDayOfWeek!Date(DayOfWeek.fri));
static assert(!__traits(compiles, cRange.popFront()));
}
}
//Test PosInfIntervalRange's save.
unittest
{
version(testStdDateTime)
{
auto interval = PosInfInterval!Date(Date(2010, 7, 4));
auto func = everyDayOfWeek!Date(DayOfWeek.fri);
auto range = interval.fwdRange(func);
assert(range.save == range);
}
}
//Test PosInfIntervalRange's interval.
unittest
{
version(testStdDateTime)
{
auto interval = PosInfInterval!Date(Date(2010, 7, 4));
auto func = everyDayOfWeek!Date(DayOfWeek.fri);
auto range = interval.fwdRange(func);
assert(range.interval == interval);
const cRange = range;
static assert(__traits(compiles, cRange.interval));
}
}
//Test PosInfIntervalRange's func.
unittest
{
version(testStdDateTime)
{
auto interval = PosInfInterval!Date(Date(2010, 7, 4));
auto func = everyDayOfWeek!Date(DayOfWeek.fri);
auto range = interval.fwdRange(func);
assert(range.func == func);
}
}
/++
A range over a $(D NegInfInterval). It is an infinite range.
$(D NegInfIntervalRange) is only ever constructed by $(D NegInfInterval).
However, when it is constructed, it is given a function, $(D func), which
is used to generate the time points which are iterated over. $(D func)
takes a time point and returns a time point of the same type. So, for
instance, if you had a $(D NegInfInterval!Date), and you wanted to iterate
over all of the days in that interval, you would pass a function to
$(D NegInfInterval)'s $(D bwdRange) where that function took a $(D Date) and
returned a $(D Date) which was one day earlier. That function would then be
used by $(D NegInfIntervalRange)'s $(D popFront) to iterate over the
$(D Date)s in the interval - though obviously, since the range is infinite,
you would use a function such as $(D std.range.take) with it rather than
iterating over $(I all) of the dates.
As the interval goes to negative infinity, the range is always iterated over
backwards, never forwards. $(D func) must generate a time point going in
the proper direction of iteration, or a $(D DateTimeException) will be
thrown. So, the time points that $(D func) generates must be earlier in time
than the one passed to it. If it's either identical or later in time, then a
$(D DateTimeException) will be thrown.
Also note that while normally the $(D end) of an interval is excluded from
it, $(D NegInfIntervalRange) treats it as if it were included. This allows
for the same behavior as you get with $(D PosInfIntervalRange). This works
because none of $(D NegInfInterval)'s functions which care about whether
$(D end) is included or excluded are ever called by
$(D NegInfIntervalRange). $(D interval) returns a normal interval, so any
$(D NegInfInterval) functions which are called on it which care about
whether $(D end) is included or excluded will treat $(D end) as excluded.
+/
struct NegInfIntervalRange(TP)
if(isTimePoint!TP)
{
public:
/++
Params:
rhs = The $(D NegInfIntervalRange) to assign to this one.
+/
/+ref+/ NegInfIntervalRange opAssign(ref NegInfIntervalRange rhs) pure nothrow
{
_interval = rhs._interval;
_func = rhs._func;
return this;
}
/++
This is an infinite range, so it is never empty.
+/
enum bool empty = false;
/++
The first time point in the range.
+/
@property TP front() const pure nothrow
{
return _interval.end;
}
/++
Pops $(D front) from the range, using $(D func) to generate the next
time point in the range.
Throws:
$(D DateTimeException) if the generated time point is greater than
$(D front).
+/
void popFront()
{
auto end = _func(_interval.end);
_enforceCorrectDirection(end);
_interval.end = end;
}
/++
Returns a copy of $(D this).
+/
@property NegInfIntervalRange save() pure nothrow
{
return this;
}
/++
The interval that this range currently covers.
+/
@property NegInfInterval!TP interval() const pure nothrow
{
return cast(NegInfInterval!TP)_interval;
}
/++
The function used to generate the next time point in the range.
+/
TP delegate(in TP) func() pure nothrow @property
{
return _func;
}
private:
/+
Params:
interval = The interval that this range covers.
func = The function used to generate the time points which are
iterated over.
+/
this(in NegInfInterval!TP interval, TP delegate(in TP) func) pure nothrow
{
_func = func;
_interval = interval;
}
/+
Throws:
$(D DateTimeException) if $(D_PARAM newTP) is in the wrong
direction.
+/
void _enforceCorrectDirection(in TP newTP, size_t line = __LINE__) const
{
enforce(newTP < _interval._end,
new DateTimeException(format("Generated time point is before previous end: prev [%s] new [%s]",
interval._end,
newTP),
__FILE__,
line));
}
NegInfInterval!TP _interval;
TP delegate(in TP) _func;
}
//Test that NegInfIntervalRange satisfies the range predicates that it's supposed to satisfy.
unittest
{
version(testStdDateTime)
{
static assert(isInputRange!(NegInfIntervalRange!Date));
static assert(isForwardRange!(NegInfIntervalRange!Date));
static assert(isInfinite!(NegInfIntervalRange!Date));
//Commented out due to bug http://d.puremagic.com/issues/show_bug.cgi?id=4895
//static assert(!isOutputRange!(NegInfIntervalRange!Date, Date));
static assert(!isBidirectionalRange!(NegInfIntervalRange!Date));
static assert(!isRandomAccessRange!(NegInfIntervalRange!Date));
static assert(!hasSwappableElements!(NegInfIntervalRange!Date));
static assert(!hasAssignableElements!(NegInfIntervalRange!Date));
static assert(!hasLength!(NegInfIntervalRange!Date));
static assert(!hasSlicing!(NegInfIntervalRange!Date));
static assert(is(ElementType!(NegInfIntervalRange!Date) == Date));
static assert(is(ElementType!(NegInfIntervalRange!TimeOfDay) == TimeOfDay));
static assert(is(ElementType!(NegInfIntervalRange!DateTime) == DateTime));
}
}
//Test construction of NegInfIntervalRange.
unittest
{
version(testStdDateTime)
{
{
Date dateFunc(in Date date)
{
return date;
}
auto negInfInterval = NegInfInterval!Date(Date(2012, 1, 7));
auto ir = NegInfIntervalRange!Date(negInfInterval, &dateFunc);
}
{
TimeOfDay todFunc(in TimeOfDay tod)
{
return tod;
}
auto negInfInterval = NegInfInterval!TimeOfDay(TimeOfDay(14, 0, 0));
auto ir = NegInfIntervalRange!(TimeOfDay)(negInfInterval, &todFunc);
}
{
DateTime dtFunc(in DateTime dt)
{
return dt;
}
auto negInfInterval = NegInfInterval!DateTime(DateTime(2012, 1, 7, 14, 0, 0));
auto ir = NegInfIntervalRange!(DateTime)(negInfInterval, &dtFunc);
}
{
SysTime stFunc(in SysTime st)
{
return cast(SysTime)(st);
}
auto negInfInterval = NegInfInterval!SysTime(SysTime(DateTime(2012, 1, 7, 14, 0, 0)));
auto ir = NegInfIntervalRange!(SysTime)(negInfInterval, &stFunc);
}
}
}
//Test NegInfIntervalRange's front.
unittest
{
version(testStdDateTime)
{
auto range = NegInfInterval!Date(Date(2012, 1, 7)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.wed));
_assertPred!"=="(range.front, Date(2012, 1, 7));
auto poppedRange = NegInfInterval!Date(Date(2012, 1, 7)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.wed), PopFirst.yes);
_assertPred!"=="(poppedRange.front, Date(2012, 1, 4));
const cRange = NegInfInterval!Date(Date(2012, 1, 7)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri));
static assert(__traits(compiles, cRange.front));
}
}
//Test NegInfIntervalRange's popFront().
unittest
{
version(testStdDateTime)
{
auto range = NegInfInterval!Date(Date(2012, 1, 7)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.wed), PopFirst.yes);
auto expected = range.front;
foreach(date; take(range, 79))
{
_assertPred!"=="(date, expected);
expected += dur!"days"(-7);
}
const cRange = NegInfInterval!Date(Date(2012, 1, 7)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri));
static assert(!__traits(compiles, cRange.popFront()));
}
}
//Test NegInfIntervalRange's save.
unittest
{
version(testStdDateTime)
{
auto interval = NegInfInterval!Date(Date(2012, 1, 7));
auto func = everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri);
auto range = interval.bwdRange(func);
assert(range.save == range);
}
}
//Test NegInfIntervalRange's interval.
unittest
{
version(testStdDateTime)
{
auto interval = NegInfInterval!Date(Date(2012, 1, 7));
auto func = everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri);
auto range = interval.bwdRange(func);
assert(range.interval == interval);
const cRange = range;
static assert(__traits(compiles, cRange.interval));
}
}
//Test NegInfIntervalRange's func.
unittest
{
version(testStdDateTime)
{
auto interval = NegInfInterval!Date(Date(2012, 1, 7));
auto func = everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri);
auto range = interval.bwdRange(func);
assert(range.func == func);
}
}
//==============================================================================
// Section with time zones.
//==============================================================================
/++
Represents a time zone. It is used with $(D SysTime) to indicate the time
zone of a $(D SysTime).
+/
abstract class TimeZone
{
public:
/++
The name of the time zone per the TZ Database. This is the name used to
get a $(D TimeZone) by name with $(D TimeZone.getTimeZone).
See_Also:
$(WEB en.wikipedia.org/wiki/Tz_database, Wikipedia entry on TZ
Database)
$(WEB en.wikipedia.org/wiki/List_of_tz_database_time_zones, List of
Time Zones)
+/
@property string name() const nothrow
{
return _name;
}
/++
Typically, the abbreviation (generally 3 or 4 letters) for the time zone
when DST is $(I not) in effect (e.g. PST). It is not necessarily unique.
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() const nothrow
{
return _stdName;
}
/++
Typically, the abbreviation (generally 3 or 4 letters) for the time zone
when DST $(I is) in effect (e.g. PDT). It is not necessarily unique.
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() const nothrow
{
return _dstName;
}
/++
Whether this time zone has Daylight Savings Time at any point in time.
Note that for some time zone types it may not have DST for current dates
but will still return true for $(D hasDST) because the time zone did at
some point have DST.
+/
@property abstract bool hasDST() const nothrow;
/++
Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D.
in UTC time (i.e. std time) and returns whether DST is effect in this
time zone at the given point in time.
Params:
stdTime = The UTC time that needs to be checked for DST in this time
zone.
+/
abstract bool dstInEffect(long stdTime) const nothrow;
/++
Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D.
in UTC time (i.e. std time) and converts it to this time zone's time.
Params:
stdTime = The UTC time that needs to be adjusted to this time zone's
time.
+/
abstract long utcToTZ(long stdTime) const nothrow;
/++
Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D.
in this time zone's time and converts it to UTC (i.e. std time).
Params:
adjTime = The time in this time zone that needs to be adjusted to
UTC time.
+/
abstract long tzToUTC(long adjTime) const nothrow;
/++
Returns a $(D TimeZone) with the give name per the TZ Database.
This returns a $(D PosixTimeZone) on Posix systems and a
$(D WindowsTimeZone) on Windows systems. If you want a
$(D PosixTimeZone) on Windows, then call $(D PosixTimeZone.getTimeZone)
directly and give it the location of the TZ Database time zone files on
disk.
On Windows, the given TZ Database name is converted to the corresponding
time zone name on Windows prior to calling
$(D WindowsTimeZone.getTimeZone). So, this function allows you to use
the same time zone names on both Windows and Posix systems.
See_Also:
$(WEB en.wikipedia.org/wiki/Tz_database, Wikipedia entry on TZ
Database)
$(WEB en.wikipedia.org/wiki/List_of_tz_database_time_zones, List of
Time Zones)
$(WEB unicode.org/repos/cldr-tmp/trunk/diff/supplemental/zone_tzid.html,
Windows <-> TZ Database Name Conversion Table)
Params:
name = The TZ Database name of the time zone that you're looking for.
Throws:
$(D DateTimeException) if the given time zone could not be found.
Examples:
--------------------
auto tz = TimeZone.getTimeZone("America/Los_Angeles");
--------------------
+/
static immutable(TimeZone) getTimeZone(string name)
{
version(Posix)
return PosixTimeZone.getTimeZone(name);
else version(Windows)
return WindowsTimeZone.getTimeZone(tzDatabaseNameToWindowsTZName(name));
}
//Since reading in the time zone files could be expensive, most unit tests
//are consolidated into this one unittest block which minimizes how often it
//reads a time zone file.
version(testStdDateTime) unittest
{
version(Posix) scope(exit) clearTZEnvVar();
static void testTZ(string tzName,
string stdName,
string dstName,
int utcOffset,
int dstOffset,
bool north = true)
{
scope(failure) writefln("Failed time zone: %s", tzName);
immutable tz = TimeZone.getTimeZone(tzName);
immutable hasDST = dstOffset != 0;
version(Posix)
_assertPred!"=="(tz.name, tzName);
else version(Windows)
_assertPred!"=="(tz.name, stdName);
_assertPred!"=="(tz.stdName, stdName);
_assertPred!"=="(tz.dstName, dstName);
_assertPred!"=="(tz.hasDST, hasDST);
immutable stdDate = DateTime(2010, north ? 1 : 7, 1, 6, 0, 0);
immutable dstDate = DateTime(2010, north ? 7 : 1, 1, 6, 0, 0);
auto std = SysTime(stdDate, tz);
auto dst = SysTime(dstDate, tz);
auto stdUTC = SysTime(stdDate - dur!"minutes"(utcOffset), UTC());
auto dstUTC = SysTime(stdDate - dur!"minutes"(utcOffset + dstOffset), UTC());
assert(!std.dstInEffect);
_assertPred!"=="(dst.dstInEffect, hasDST);
_assertPred!"=="(cast(DateTime)std, stdDate);
_assertPred!"=="(cast(DateTime)dst, dstDate);
_assertPred!"=="(std, stdUTC);
version(Posix)
{
setTZEnvVar(tzName);
static void testTM(in SysTime st)
{
time_t unixTime = st.toUnixTime();
tm* osTimeInfo = localtime(&unixTime);
tm ourTimeInfo = st.toTM();
_assertPred!"=="(ourTimeInfo.tm_sec, osTimeInfo.tm_sec);
_assertPred!"=="(ourTimeInfo.tm_min, osTimeInfo.tm_min);
_assertPred!"=="(ourTimeInfo.tm_hour, osTimeInfo.tm_hour);
_assertPred!"=="(ourTimeInfo.tm_min, osTimeInfo.tm_min);
_assertPred!"=="(ourTimeInfo.tm_mday, osTimeInfo.tm_mday);
_assertPred!"=="(ourTimeInfo.tm_mon, osTimeInfo.tm_mon);
_assertPred!"=="(ourTimeInfo.tm_year, osTimeInfo.tm_year);
_assertPred!"=="(ourTimeInfo.tm_wday, osTimeInfo.tm_wday);
_assertPred!"=="(ourTimeInfo.tm_yday, osTimeInfo.tm_yday);
_assertPred!"=="(ourTimeInfo.tm_isdst, osTimeInfo.tm_isdst);
_assertPred!"=="(ourTimeInfo.tm_gmtoff, osTimeInfo.tm_gmtoff);
_assertPred!"=="(to!string(ourTimeInfo.tm_zone),
to!string(osTimeInfo.tm_zone));
}
testTM(std);
testTM(dst);
//Apparently, right/ does not exist on Mac OS X. I don't know
//whether or not it exists on FreeBSD. It's rather pointless
//normally, since the Posix standard requires that leap seconds
//be ignored, so it does make some sense that right/ wouldn't
//be there, but since PosixTimeZone _does_ use leap seconds if
//the time zone file does, we'll test that functionality if the
//appropriate files exist.
if((PosixTimeZone.defaultTZDatabaseDir ~ "right/" ~ tzName).exists())
{
auto leapTZ = PosixTimeZone.getTimeZone("right/" ~ tzName);
assert(leapTZ.name == "right/" ~ tzName);
assert(leapTZ.stdName == stdName);
assert(leapTZ.dstName == dstName);
assert(leapTZ.hasDST == hasDST);
auto leapSTD = SysTime(std.stdTime, leapTZ);
auto leapDST = SysTime(dst.stdTime, leapTZ);
assert(!leapSTD.dstInEffect);
assert(leapDST.dstInEffect == hasDST);
_assertPred!"=="(leapSTD.stdTime, std.stdTime);
_assertPred!"=="(leapDST.stdTime, dst.stdTime);
//Whenever a leap second is added/removed,
//this will have to be adjusted.
enum leapDiff = convert!("seconds", "hnsecs")(24);
_assertPred!"=="(leapSTD.adjTime - leapDiff, std.adjTime);
_assertPred!"=="(leapDST.adjTime - leapDiff, dst.adjTime);
}
}
}
version(Posix)
{
version(FreeBSD) enum utcZone = "Etc/UTC";
version(linux) enum utcZone = "UTC";
version(OSX) enum utcZone = "UTC";
testTZ("America/Los_Angeles", "PST", "PDT", -8 * 60, 60);
testTZ("America/New_York", "EST", "EDT", -5 * 60, 60);
testTZ(utcZone, "UTC", "UTC", 0, 0);
testTZ("Europe/Paris", "CET", "CEST", 60, 60);
testTZ("Australia/Adelaide", "CST", "CST", 9 * 60 + 30, 60, false);
assertThrown!DateTimeException(PosixTimeZone.getTimeZone("hello_world"));
}
version(Windows)
{
testTZ("America/Los_Angeles", "Pacific Standard Time",
"Pacific Daylight Time", -8 * 60, 60);
testTZ("America/New_York", "Eastern Standard Time",
"Eastern Daylight Time", -5 * 60, 60);
testTZ("Atlantic/Reykjavik", "Greenwich Standard Time",
"Greenwich Daylight Time", 0, 0);
testTZ("Europe/Paris", "Romance Standard Time",
"Romance Daylight Time", 60, 60);
testTZ("Australia/Adelaide", "Cen. Australia Standard Time",
"Cen. Australia Daylight Time", 9 * 60 + 30, 60, false);
assertThrown!DateTimeException(WindowsTimeZone.getTimeZone("hello_world"));
}
}
/++
Returns a list of the names of the time zones installed on the system.
You can provide a sub-name to narrow down the list of time zones (which
will likely be in the thousands if you get them all). For example,
if you pass in "America" as the sub-name, then only the time zones which
begin with "America" will be returned.
On Windows, this function will convert the Windows time zone names to
the corresponding TZ Database names with
$(D windowsTZNameToTZDatabaseName). If you want the actual Windows time
zone names, use $(D WindowsTimeZone.getInstalledTZNames) directly.
Params:
subName = The first part of the time zones that you want.
Throws:
$(D FileException) on Posix systems if it fails to read from disk.
$(D DateTimeException) on Windows systems if it fails to read the
registry.
+/
static string[] getInstalledTZNames(string subName = "")
{
version(Posix)
return PosixTimeZone.getInstalledTZNames(subName);
else version(Windows)
{
auto windowsNames = WindowsTimeZone.getInstalledTZNames();
auto retval = appender!(string[])();
foreach(winName; windowsNames)
{
auto tzName = windowsTZNameToTZDatabaseName(winName);
if(tzName.startsWith(subName))
retval.put(tzName);
}
sort(retval.data);
return retval.data;
}
}
unittest
{
version(testStdDateTime)
{
static void testPZSuccess(string tzName)
{
scope(failure) writefln("TZName which threw: %s", tzName);
TimeZone.getTimeZone(tzName);
}
auto tzNames = getInstalledTZNames();
foreach(tzName; tzNames)
assertNotThrown!DateTimeException(testPZSuccess(tzName));
}
}
private:
/+
Params:
name = The TZ Database name for the time zone.
stdName = The abbreviation for the time zone during std time.
dstName = The abbreviation for the time zone during DST.
+/
this(string name, string stdName, string dstName) immutable pure
{
_name = name;
_stdName = stdName;
_dstName = dstName;
}
immutable string _name;
immutable string _stdName;
immutable string _dstName;
}
/++
A TimeZone which represents the current local time zone on
the system running your program.
This uses the underlying C calls to adjust the time rather than using
specific D code based off of system settings to calculate the time such as
$(D PosixTimeZone) and $(D WindowsTimeZone) do. That also means that it will
use whatever the current time zone is on the system, even if the system's
time zone changes while the program is running.
+/
final class LocalTime : TimeZone
{
public:
/++
$(D LocalTime) is a singleton class. $(D LocalTime) returns its only
instance.
+/
static immutable(LocalTime) opCall() pure nothrow
{
return _localTime;
}
version(StdDdoc)
{
/++
The name of the time zone per the TZ Database. This is the name used to
get a $(D TimeZone) by name with $(D TimeZone.getTimeZone).
Note that this always returns the empty string. This is because time
zones cannot be uniquely identified by the attributes given by the
OS (such as the $(D stdName) and $(D dstName)), and neither Posix
systems nor Windows systems provide an easy way to get the TZ
Database name of the local time zone.
See_Also:
$(WEB en.wikipedia.org/wiki/Tz_database, Wikipedia entry on TZ
Database)
$(WEB en.wikipedia.org/wiki/List_of_tz_database_time_zones, List
of Time Zones)
+/
@property override string name() const nothrow;
}
/++
Typically, the abbreviation (generally 3 or 4 letters) for the time zone
when DST is $(I not) in effect (e.g. PST). It is not necessarily unique.
However, on Windows, it may be the unabbreviated name (e.g. Pacific
Standard Time). Regardless, it is not the same as name.
This property is overridden because the local time of the system could
change while the program is running and we need to determine it
dynamically rather than it being fixed like it would be with most time
zones.
+/
@property override string stdName() const nothrow
{
version(Posix)
{
try
return to!string(tzname[0]);
catch(Exception e)
assert(0, "to!string(tzname[0]) failed.");
}
else version(Windows)
{
try
{
TIME_ZONE_INFORMATION tzInfo;
GetTimeZoneInformation(&tzInfo);
//Cannot use to!string() like this should, probably due to bug http://d.puremagic.com/issues/show_bug.cgi?id=5016
//return to!string(tzInfo.StandardName);
wchar[32] str;
foreach(i, ref wchar c; str)
c = tzInfo.StandardName[i];
string retval;
foreach(dchar c; str)
{
if(c == '\0')
break;
retval ~= c;
}
return retval;
}
catch(Exception e)
assert(0, "GetTimeZoneInformation() threw.");
}
}
unittest
{
version(testStdDateTime)
{
assert(LocalTime().stdName !is null);
version(Posix)
{
scope(exit) clearTZEnvVar();
setTZEnvVar("America/Los_Angeles");
_assertPred!"=="(LocalTime().stdName, "PST");
setTZEnvVar("America/New_York");
_assertPred!"=="(LocalTime().stdName, "EST");
}
}
}
/++
Typically, the abbreviation (generally 3 or 4 letters) for the time zone
when DST $(I is) in effect (e.g. PDT). It is not necessarily unique.
However, on Windows, it may be the unabbreviated name (e.g. Pacific
Daylight Time). Regardless, it is not the same as name.
This property is overridden because the local time of the system could
change while the program is running and we need to determine it
dynamically rather than it being fixed like it would be with most time
zones.
+/
@property override string dstName() const nothrow
{
version(Posix)
{
try
return to!string(tzname[1]);
catch(Exception e)
assert(0, "to!string(tzname[1]) failed.");
}
else version(Windows)
{
try
{
TIME_ZONE_INFORMATION tzInfo;
GetTimeZoneInformation(&tzInfo);
//Cannot use to!string() like this should, probably due to bug http://d.puremagic.com/issues/show_bug.cgi?id=5016
//return to!string(tzInfo.DaylightName);
wchar[32] str;
foreach(i, ref wchar c; str)
c = tzInfo.DaylightName[i];
string retval;
foreach(dchar c; str)
{
if(c == '\0')
break;
retval ~= c;
}
return retval;
}
catch(Exception e)
assert(0, "GetTimeZoneInformation() threw.");
}
}
unittest
{
version(testStdDateTime)
{
assert(LocalTime().dstName !is null);
version(Posix)
{
scope(exit) clearTZEnvVar();
setTZEnvVar("America/Los_Angeles");
_assertPred!"=="(LocalTime().dstName, "PDT");
setTZEnvVar("America/New_York");
_assertPred!"=="(LocalTime().dstName, "EDT");
}
}
}
/++
Whether this time zone has Daylight Savings Time at any point in time.
Note that for some time zone types it may not have DST for current
dates but will still return true for $(D hasDST) because the time zone
did at some point have DST.
+/
@property override bool hasDST() const nothrow
{
version(Posix)
{
static if(is(typeof(daylight)))
return cast(bool)(daylight);
else
{
try
{
auto currYear = (cast(Date)Clock.currTime()).year;
auto janOffset = SysTime(Date(currYear, 1, 4), this).stdTime -
SysTime(Date(currYear, 1, 4), UTC()).stdTime;
auto julyOffset = SysTime(Date(currYear, 7, 4), this).stdTime -
SysTime(Date(currYear, 7, 4), UTC()).stdTime;
return janOffset != julyOffset;
}
catch(Exception e)
assert(0, "Clock.currTime() threw.");
}
}
else version(Windows)
{
try
{
TIME_ZONE_INFORMATION tzInfo;
GetTimeZoneInformation(&tzInfo);
return tzInfo.DaylightDate.wMonth != 0;
}
catch(Exception e)
assert(0, "GetTimeZoneInformation() threw.");
}
}
unittest
{
version(testStdDateTime)
{
LocalTime().hasDST;
version(Posix)
{
scope(exit) clearTZEnvVar();
setTZEnvVar("America/Los_Angeles");
assert(LocalTime().hasDST);
setTZEnvVar("America/New_York");
assert(LocalTime().hasDST);
setTZEnvVar("UTC");
assert(!LocalTime().hasDST);
}
}
}
/++
Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D.
in UTC time (i.e. std time) and returns whether DST is in effect in this
time zone at the given point in time.
Params:
stdTime = The UTC time that needs to be checked for DST in this time
zone.
+/
override bool dstInEffect(long stdTime) const nothrow
{
time_t unixTime = stdTimeToUnixTime(stdTime);
version(Posix)
{
tm* timeInfo = localtime(&unixTime);
return cast(bool)(timeInfo.tm_isdst);
}
else version(Windows)
{
//Apparently Windows isn't smart enough to deal with negative time_t.
if(unixTime >= 0)
{
tm* timeInfo = localtime(&unixTime);
if(timeInfo)
return cast(bool)(timeInfo.tm_isdst);
}
TIME_ZONE_INFORMATION tzInfo;
try
GetTimeZoneInformation(&tzInfo);
catch(Exception e)
assert(0, "The impossible happened. GetTimeZoneInformation() threw.");
return WindowsTimeZone._dstInEffect(&tzInfo, stdTime);
}
}
unittest
{
version(testStdDateTime)
{
auto currTime = Clock.currStdTime;
LocalTime().dstInEffect(currTime);
version(Posix)
{
scope(exit) clearTZEnvVar();
auto std = SysTime(DateTime(2010, 1, 1, 12, 0, 0), LocalTime());
auto dst = SysTime(DateTime(2010, 7, 1, 12, 0, 0), LocalTime());
setTZEnvVar("America/Los_Angeles");
assert(!LocalTime().dstInEffect(std.stdTime));
assert(LocalTime().dstInEffect(dst.stdTime));
assert(!std.dstInEffect);
assert(dst.dstInEffect);
setTZEnvVar("America/New_York");
assert(!LocalTime().dstInEffect(std.stdTime));
assert(LocalTime().dstInEffect(dst.stdTime));
assert(!std.dstInEffect);
assert(dst.dstInEffect);
}
}
}
/++
Returns hnsecs in the local time zone using the standard C function
calls on Posix systems and the standard Windows system calls on Windows
systems to adjust the time to the appropriate time zone from std time.
Params:
stdTime = The UTC time that needs to be adjusted to this time zone's
time.
See_Also:
$(D TimeZone.utcToTZ)
+/
override long utcToTZ(long stdTime) const nothrow
{
version(Posix)
{
time_t unixTime = stdTimeToUnixTime(stdTime);
tm* timeInfo = localtime(&unixTime);
return stdTime + convert!("seconds", "hnsecs")(timeInfo.tm_gmtoff);
}
else version(Windows)
{
TIME_ZONE_INFORMATION tzInfo;
try
GetTimeZoneInformation(&tzInfo);
catch(Exception e)
assert(0, "GetTimeZoneInformation() threw.");
return WindowsTimeZone._utcToTZ(&tzInfo, stdTime, hasDST);
}
}
unittest
{
version(testStdDateTime)
{
LocalTime().utcToTZ(0);
version(Posix)
{
scope(exit) clearTZEnvVar();
{
setTZEnvVar("America/Los_Angeles");
auto std = SysTime(Date(2010, 1, 1));
auto dst = SysTime(Date(2010, 7, 1));
_assertPred!"=="(LocalTime().utcToTZ(std.stdTime), SysTime(DateTime(2009, 12, 31, 16, 0, 0)).stdTime);
_assertPred!"=="(LocalTime().utcToTZ(dst.stdTime), SysTime(DateTime(2010, 6, 30, 17, 0, 0)).stdTime);
}
{
setTZEnvVar("America/New_York");
auto std = SysTime(Date(2010, 1, 1));
auto dst = SysTime(Date(2010, 7, 1));
_assertPred!"=="(LocalTime().utcToTZ(std.stdTime), SysTime(DateTime(2009, 12, 31, 19, 0, 0)).stdTime);
_assertPred!"=="(LocalTime().utcToTZ(dst.stdTime), SysTime(DateTime(2010, 6, 30, 20, 0, 0)).stdTime);
}
}
}
}
/++
Returns std time using the standard C function calls on Posix systems
and the standard Windows system calls on Windows systems to adjust the
time to UTC from the appropriate time zone.
See_Also:
$(D TimeZone.tzToUTC)
Params:
adjTime = The time in this time zone that needs to be adjusted to
UTC time.
+/
override long tzToUTC(long adjTime) const nothrow
{
version(Posix)
{
time_t unixTime = stdTimeToUnixTime(adjTime);
tm* timeInfo = localtime(&unixTime);
return adjTime - convert!("seconds", "hnsecs")(timeInfo.tm_gmtoff);
}
else version(Windows)
{
TIME_ZONE_INFORMATION tzInfo;
try
GetTimeZoneInformation(&tzInfo);
catch(Exception e)
assert(0, "GetTimeZoneInformation() threw.");
return WindowsTimeZone._tzToUTC(&tzInfo, adjTime, hasDST);
}
}
unittest
{
version(testStdDateTime)
{
LocalTime().tzToUTC(0);
_assertPred!"=="(LocalTime().tzToUTC(LocalTime().utcToTZ(0)), 0);
_assertPred!"=="(LocalTime().utcToTZ(LocalTime().tzToUTC(0)), 0);
version(Posix)
{
scope(exit) clearTZEnvVar();
{
setTZEnvVar("America/Los_Angeles");
auto std = SysTime(DateTime(2009, 12, 31, 16, 0, 0));
auto dst = SysTime(DateTime(2010, 6, 30, 17, 0, 0));
_assertPred!"=="(LocalTime().tzToUTC(std.stdTime), SysTime(Date(2010, 1, 1)).stdTime);
_assertPred!"=="(LocalTime().tzToUTC(dst.stdTime), SysTime(Date(2010, 7, 1)).stdTime);
}
{
setTZEnvVar("America/New_York");
auto std = SysTime(DateTime(2009, 12, 31, 19, 0, 0));
auto dst = SysTime(DateTime(2010, 6, 30, 20, 0, 0));
_assertPred!"=="(LocalTime().tzToUTC(std.stdTime), SysTime(Date(2010, 1, 1)).stdTime);
_assertPred!"=="(LocalTime().tzToUTC(dst.stdTime), SysTime(Date(2010, 7, 1)).stdTime);
}
}
}
}
private:
this() immutable pure
{
super("", "", "");
}
static immutable LocalTime _localTime;
shared static this()
{
tzset();
_localTime = new immutable(LocalTime)();
}
}
/++
A $(D TimeZone) which represents UTC.
+/
final class UTC : TimeZone
{
public:
/++
$(D UTC) is a singleton class. $(D UTC) returns its only instance.
+/
static immutable(UTC) opCall() pure nothrow
{
return _utc;
}
/++
Always returns false.
+/
@property override bool hasDST() const nothrow
{
return false;
}
/++
Always returns false.
+/
override bool dstInEffect(long stdTime) const nothrow
{
return false;
}
/++
Returns the given hnsecs without changing them at all.
Params:
stdTime = The UTC time that needs to be adjusted to this time zone's
time.
See_Also:
$(D TimeZone.utcToTZ)
+/
override long utcToTZ(long stdTime) const nothrow
{
return stdTime;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(UTC().utcToTZ(0), 0);
version(Posix)
{
scope(exit) clearTZEnvVar();
setTZEnvVar("UTC");
auto std = SysTime(Date(2010, 1, 1));
auto dst = SysTime(Date(2010, 7, 1));
_assertPred!"=="(UTC().utcToTZ(std.stdTime), std.stdTime);
_assertPred!"=="(UTC().utcToTZ(dst.stdTime), dst.stdTime);
}
}
}
/++
Returns the given hnsecs without changing them at all.
See_Also:
$(D TimeZone.tzToUTC)
Params:
adjTime = The time in this time zone that needs to be adjusted to
UTC time.
+/
override long tzToUTC(long adjTime) const nothrow
{
return adjTime;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(UTC().tzToUTC(0), 0);
version(Posix)
{
scope(exit) clearTZEnvVar();
setTZEnvVar("UTC");
auto std = SysTime(Date(2010, 1, 1));
auto dst = SysTime(Date(2010, 7, 1));
_assertPred!"=="(UTC().tzToUTC(std.stdTime), std.stdTime);
_assertPred!"=="(UTC().tzToUTC(dst.stdTime), dst.stdTime);
}
}
}
private:
this() immutable pure
{
super("UTC", "UTC", "UTC");
}
static immutable UTC _utc;
shared static this()
{
_utc = new immutable(UTC)();
}
}
/++
Represents a time zone with an offset (in minutes, west is negative) from
UTC but no DST.
It's primarily used as the time zone in the result of $(D SysTime)'s
$(D fromISOString), $(D fromISOExtString), and $(D fromSimpleString).
$(D name) and $(D dstName) are always the empty string since this time zone
has no DST, and while it may be meant to represent a time zone which is in
the TZ Database, obviously it's not likely to be following the exact rules
of any of the time zones in the TZ Database, so it makes no sense to set it.
+/
final class SimpleTimeZone : TimeZone
{
public:
/++
Always returns false.
+/
@property override bool hasDST() const nothrow
{
return false;
}
/++
Always returns false.
+/
override bool dstInEffect(long stdTime) const nothrow
{
return false;
}
/++
Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D.
in UTC time (i.e. std time) and converts it to this time zone's time.
Params:
stdTime = The UTC time that needs to be adjusted to this time zone's
time.
+/
override long utcToTZ(long stdTime) const nothrow
{
return stdTime + convert!("minutes", "hnsecs")(utcOffset);
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="((new SimpleTimeZone(-8 * 60)).utcToTZ(0), -288_000_000_000L);
_assertPred!"=="((new SimpleTimeZone(8 * 60)).utcToTZ(0), 288_000_000_000L);
_assertPred!"=="((new SimpleTimeZone(-8 * 60)).utcToTZ(54_321_234_567_890L), 54_033_234_567_890L);
auto stz = new SimpleTimeZone(-8 * 60);
const cstz = new SimpleTimeZone(-8 * 60);
static assert(__traits(compiles, stz.utcToTZ(50002)));
static assert(__traits(compiles, cstz.utcToTZ(50002)));
}
}
/++
Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D.
in this time zone's time and converts it to UTC (i.e. std time).
Params:
adjTime = The time in this time zone that needs to be adjusted to
UTC time.
+/
override long tzToUTC(long adjTime) const nothrow
{
return adjTime - convert!("minutes", "hnsecs")(utcOffset);
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="((new SimpleTimeZone(-8 * 60)).tzToUTC(-288_000_000_000L), 0);
_assertPred!"=="((new SimpleTimeZone(8 * 60)).tzToUTC(288_000_000_000L), 0);
_assertPred!"=="((new SimpleTimeZone(-8 * 60)).tzToUTC(54_033_234_567_890L), 54_321_234_567_890L);
auto stz = new SimpleTimeZone(-8 * 60);
const cstz = new SimpleTimeZone(-8 * 60);
static assert(__traits(compiles, stz.tzToUTC(20005)));
static assert(__traits(compiles, cstz.tzToUTC(20005)));
}
}
/++
Params:
utcOffset = This time zone's offset from UTC in minutes with west of
UTC being negative (it is added to UTC to get the
adjusted time).
stdName = The $(D stdName) for this time zone.
+/
this(int utcOffset, string stdName = "") immutable
{
//FIXME This probably needs to be changed to something like (-12 - 13).
enforce(std.math.abs(utcOffset) < 1440, new DateTimeException("Offset from UTC must be within range (-24:00 - 24:00)."));
super("", stdName, "");
this.utcOffset = utcOffset;
}
unittest
{
version(testStdDateTime)
{
auto stz = new SimpleTimeZone(-8 * 60, "PST");
_assertPred!"=="(stz.name, "");
_assertPred!"=="(stz.stdName, "PST");
_assertPred!"=="(stz.dstName, "");
_assertPred!"=="(stz.utcOffset, -8 * 60);
}
}
/++
The number of minutes the offset from UTC is (negative is west of UTC,
positive is east).
+/
immutable int utcOffset;
private:
/+
Returns a time zone as a string with an offset from UTC.
Time zone offsets will be in the form +HH:MM or -HH:MM.
Params:
utcOffset = The number of minutes offset from UTC (negative means
west).
+/
static string toISOString(int utcOffset)
{
immutable absOffset = std.math.abs(utcOffset);
enforce(absOffset < 1440, new DateTimeException("Offset from UTC must be within range (-24:00 - 24:00)."));
immutable hours = convert!("minutes", "hours")(absOffset);
immutable minutes = absOffset - convert!("hours", "minutes")(hours);
if(utcOffset < 0)
return format("-%02d:%02d", hours, minutes);
return format("+%02d:%02d", hours, minutes);
}
unittest
{
version(testStdDateTime)
{
static string testSTZInvalid(int offset)
{
return SimpleTimeZone.toISOString(offset);
}
assertThrown!DateTimeException(testSTZInvalid(1440));
assertThrown!DateTimeException(testSTZInvalid(-1440));
_assertPred!"=="(toISOString(0), "+00:00");
_assertPred!"=="(toISOString(1), "+00:01");
_assertPred!"=="(toISOString(10), "+00:10");
_assertPred!"=="(toISOString(59), "+00:59");
_assertPred!"=="(toISOString(60), "+01:00");
_assertPred!"=="(toISOString(90), "+01:30");
_assertPred!"=="(toISOString(120), "+02:00");
_assertPred!"=="(toISOString(480), "+08:00");
_assertPred!"=="(toISOString(1439), "+23:59");
_assertPred!"=="(toISOString(-1), "-00:01");
_assertPred!"=="(toISOString(-10), "-00:10");
_assertPred!"=="(toISOString(-59), "-00:59");
_assertPred!"=="(toISOString(-60), "-01:00");
_assertPred!"=="(toISOString(-90), "-01:30");
_assertPred!"=="(toISOString(-120), "-02:00");
_assertPred!"=="(toISOString(-480), "-08:00");
_assertPred!"=="(toISOString(-1439), "-23:59");
}
}
/+
Takes a time zone as a string with an offset from UTC and returns a
$(D SimpleTimeZone) which matches.
The accepted formats for time zone offsets
are +H, -H, +HH, -HH, +H:MM, -H:MM, +HH:MM, and -HH:MM.
Params:
isoString = A string which represents a time zone in the ISO format.
+/
static immutable(SimpleTimeZone) fromISOString(S)(S isoString)
if(isSomeString!(S))
{
auto dstr = to!dstring(strip(isoString));
enforce(dstr.startsWith("-") || dstr.startsWith("+"), new DateTimeException("Invalid ISO String"));
auto sign = dstr.startsWith("-") ? -1 : 1;
dstr.popFront();
enforce(!dstr.empty, new DateTimeException("Invalid ISO String"));
immutable colon = dstr.stds_indexOf(":");
dstring hoursStr;
dstring minutesStr;
if(colon != -1)
{
hoursStr = dstr[0 .. colon];
minutesStr = dstr[colon + 1 .. $];
enforce(minutesStr.length == 2, new DateTimeException(format("Invalid ISO String: %s", dstr)));
}
else
hoursStr = dstr;
enforce(!canFind!(not!isDigit)(hoursStr), new DateTimeException(format("Invalid ISO String: %s", dstr)));
enforce(!canFind!(not!isDigit)(minutesStr), new DateTimeException(format("Invalid ISO String: %s", dstr)));
immutable hours = to!int(hoursStr);
immutable minutes = minutesStr.empty ? 0 : to!int(minutesStr);
return new SimpleTimeZone(sign * cast(int)(convert!("hours", "minutes")(hours) + minutes));
}
unittest
{
version(testStdDateTime)
{
assertThrown!DateTimeException(SimpleTimeZone.fromISOString(""));
assertThrown!DateTimeException(SimpleTimeZone.fromISOString("Z"));
assertThrown!DateTimeException(SimpleTimeZone.fromISOString("-"));
assertThrown!DateTimeException(SimpleTimeZone.fromISOString("+"));
assertThrown!DateTimeException(SimpleTimeZone.fromISOString("-:"));
assertThrown!DateTimeException(SimpleTimeZone.fromISOString("+:"));
assertThrown!DateTimeException(SimpleTimeZone.fromISOString("-1:"));
assertThrown!DateTimeException(SimpleTimeZone.fromISOString("+1:"));
assertThrown!DateTimeException(SimpleTimeZone.fromISOString("1"));
assertThrown!DateTimeException(SimpleTimeZone.fromISOString("-24:00"));
assertThrown!DateTimeException(SimpleTimeZone.fromISOString("+24:00"));
assertThrown!DateTimeException(SimpleTimeZone.fromISOString("+1:0"));
_assertPred!"=="(SimpleTimeZone.fromISOString("+00:00").utcOffset, (new SimpleTimeZone(0)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+00:01").utcOffset, (new SimpleTimeZone(1)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+00:10").utcOffset, (new SimpleTimeZone(10)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+00:59").utcOffset, (new SimpleTimeZone(59)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+01:00").utcOffset, (new SimpleTimeZone(60)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+01:30").utcOffset, (new SimpleTimeZone(90)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+02:00").utcOffset, (new SimpleTimeZone(120)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+08:00").utcOffset, (new SimpleTimeZone(480)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+23:59").utcOffset, (new SimpleTimeZone(1439)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("-00:01").utcOffset, (new SimpleTimeZone(-1)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("-00:10").utcOffset, (new SimpleTimeZone(-10)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("-00:59").utcOffset, (new SimpleTimeZone(-59)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("-01:00").utcOffset, (new SimpleTimeZone(-60)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("-01:30").utcOffset, (new SimpleTimeZone(-90)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("-02:00").utcOffset, (new SimpleTimeZone(-120)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("-08:00").utcOffset, (new SimpleTimeZone(-480)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("-23:59").utcOffset, (new SimpleTimeZone(-1439)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+0").utcOffset, (new SimpleTimeZone(0)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+1").utcOffset, (new SimpleTimeZone(60)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+2").utcOffset, (new SimpleTimeZone(120)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+23").utcOffset, (new SimpleTimeZone(1380)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+2").utcOffset, (new SimpleTimeZone(120)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+0").utcOffset, (new SimpleTimeZone(0)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+1").utcOffset, (new SimpleTimeZone(60)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+2").utcOffset, (new SimpleTimeZone(120)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+23").utcOffset, (new SimpleTimeZone(1380)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+1:00").utcOffset, (new SimpleTimeZone(60)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("+1:01").utcOffset, (new SimpleTimeZone(61)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("-0").utcOffset, (new SimpleTimeZone(0)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("-1").utcOffset, (new SimpleTimeZone(-60)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("-2").utcOffset, (new SimpleTimeZone(-120)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("-23").utcOffset, (new SimpleTimeZone(-1380)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("-1:00").utcOffset, (new SimpleTimeZone(-60)).utcOffset);
_assertPred!"=="(SimpleTimeZone.fromISOString("-1:01").utcOffset, (new SimpleTimeZone(-61)).utcOffset);
}
}
//Test that converting from an ISO string to a SimpleTimeZone to an ISO String works properly.
unittest
{
version(testStdDateTime)
{
static void testSTZ(in string isoString, int expectedOffset, size_t line = __LINE__)
{
auto stz = SimpleTimeZone.fromISOString(isoString);
_assertPred!"=="(stz.utcOffset, expectedOffset, "", __FILE__, line);
auto result = SimpleTimeZone.toISOString(stz.utcOffset);
_assertPred!"=="(result, isoString, "", __FILE__, line);
}
testSTZ("+00:00", 0);
testSTZ("+00:01", 1);
testSTZ("+00:10", 10);
testSTZ("+00:59", 59);
testSTZ("+01:00", 60);
testSTZ("+01:30", 90);
testSTZ("+02:00", 120);
testSTZ("+08:00", 480);
testSTZ("+08:00", 480);
testSTZ("+23:59", 1439);
testSTZ("-00:01", -1);
testSTZ("-00:10", -10);
testSTZ("-00:59", -59);
testSTZ("-01:00", -60);
testSTZ("-01:30", -90);
testSTZ("-02:00", -120);
testSTZ("-08:00", -480);
testSTZ("-08:00", -480);
testSTZ("-23:59", -1439);
}
}
}
/++
Represents a time zone from a TZ Database time zone file. Files from the TZ
database are how Posix systems hold their time zone information.
Unfortunately, Windows does not use the TZ Database. You can, however, use
$(D PosixTimeZone) (which reads its information from the TZ Database files
on disk) on Windows if you provide the TZ Database files
( $(WEB elsie.nci.nih.gov/pub/, Repository with the TZ Database files (tzdata)) )
yourself and tell $(D PosixTimeZone.getTimeZone) where the directory holding
them is.
To get a $(D PosixTimeZone), either call $(D PosixTimeZone.getTimeZone)
(which will allow you to specify the location the time zone files) or call
$(D TimeZone.getTimeZone) (which will give you a $(D PosixTimeZone) on Posix
systems and a $(D WindowsTimeZone) on Windows systems).
Note:
Unless your system's local time zone deals with leap seconds (which is
highly unlikely), then only way that you will get a time zone which
takes leap seconds into account is if you use $(D PosixTimeZone) with a
time zone whose name starts with "right/". Those time zone files do
include leap seconds, and $(D PosixTimeZone) will take them into account
(though posix systems which use a "right/" time zone as their local time
zone will $(I not) take leap seconds into account even though they're
in the file).
See_Also:
$(WEB en.wikipedia.org/wiki/Tz_database, Wikipedia entry on TZ Database)
$(WEB en.wikipedia.org/wiki/List_of_tz_database_time_zones, List of Time
Zones)
+/
final class PosixTimeZone : TimeZone
{
public:
/++
Whether this time zone has Daylight Savings Time at any point in time.
Note that for some time zone types it may not have DST for current
dates but will still return true for $(D hasDST) because the time zone
did at some point have DST.
+/
@property override bool hasDST() const nothrow
{
return _hasDST;
}
/++
Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D.
in UTC time (i.e. std time) and returns whether DST is in effect in this
time zone at the given point in time.
Params:
stdTime = The UTC time that needs to be checked for DST in this time
zone.
+/
override bool dstInEffect(long stdTime) const nothrow
{
assert(!_transitions.empty);
try
{
immutable unixTime = stdTimeToUnixTime(stdTime);
if(_transitions.front.timeT >= unixTime)
return _transitions.front.ttInfo.isDST;
auto found = std.algorithm.countUntil!"b < a.timeT"(cast(Transition[])_transitions, unixTime);
if(found == -1)
return _transitions.back.ttInfo.isDST;
auto transition = found == 0 ? _transitions[0] : _transitions[found - 1];
return transition.ttInfo.isDST;
}
catch(Exception e)
assert(0, format("Nothing in calculateLeapSeconds() should be throwing. Caught Exception: %s", e));
}
/++
Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D.
in UTC time (i.e. std time) and converts it to this time zone's time.
Params:
stdTime = The UTC time that needs to be adjusted to this time zone's
time.
+/
override long utcToTZ(long stdTime) const nothrow
{
assert(!_transitions.empty);
try
{
immutable leapSecs = calculateLeapSeconds(stdTime);
immutable unixTime = stdTimeToUnixTime(stdTime);
if(_transitions.front.timeT >= unixTime)
return stdTime + convert!("seconds", "hnsecs")(_transitions.front.ttInfo.utcOffset + leapSecs);
auto found = std.algorithm.countUntil!"b < a.timeT"(cast(Transition[])_transitions, unixTime);
if(found == -1)
return stdTime + convert!("seconds", "hnsecs")(_transitions.back.ttInfo.utcOffset + leapSecs);
auto transition = found == 0 ? _transitions[0] : _transitions[found - 1];
return stdTime + convert!("seconds", "hnsecs")(transition.ttInfo.utcOffset + leapSecs);
}
catch(Exception e)
assert(0, format("Nothing in calculateLeapSeconds() should be throwing. Caught Exception: %s", e));
}
/++
Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D.
in this time zone's time and converts it to UTC (i.e. std time).
Params:
adjTime = The time in this time zone that needs to be adjusted to
UTC time.
+/
override long tzToUTC(long adjTime) const nothrow
{
assert(!_transitions.empty);
try
{
immutable leapSecs = calculateLeapSeconds(adjTime);
immutable unixTime = stdTimeToUnixTime(adjTime);
if(_transitions.front.timeT >= unixTime)
return adjTime - convert!("seconds", "hnsecs")(_transitions.front.ttInfo.utcOffset + leapSecs);
//Okay, casting is a hack, but countUntil shouldn't be changing it,
//and it would be too inefficient to have to keep duping it every
//time we have to calculate the time. Hopefully, countUntil will
//properly support immutable ranges at some point.
auto found = std.algorithm.countUntil!"b < a.timeT"(cast(Transition[])_transitions, unixTime);
if(found == -1)
return adjTime - convert!("seconds", "hnsecs")(_transitions.back.ttInfo.utcOffset + leapSecs);
auto transition = found == 0 ? _transitions[0] : _transitions[found - 1];
return adjTime - convert!("seconds", "hnsecs")(transition.ttInfo.utcOffset + leapSecs);
}
catch(Exception e)
assert(0, format("Nothing in calculateLeapSeconds() should be throwing. Caught Exception: %s", e));
}
version(Posix)
{
/++
The default directory where the TZ Database files are. It's empty
for Windows, since Windows doesn't have them.
+/
enum defaultTZDatabaseDir = "/usr/share/zoneinfo/";
}
else version(Windows)
{
/++ The default directory where the TZ Database files are. It's empty
for Windows, since Windows doesn't have them.
+/
enum defaultTZDatabaseDir = "";
}
/++
Returns a $(D TimeZone) with the give name per the TZ Database. The time
zone information is fetched from the TZ Database time zone files in the
given directory.
See_Also:
$(WEB en.wikipedia.org/wiki/Tz_database, Wikipedia entry on TZ
Database)
$(WEB en.wikipedia.org/wiki/List_of_tz_database_time_zones, List of
Time Zones)
Params:
name = The TZ Database name of the time zone that you're
looking for.
tzDatabaseDir = The directory where the TZ Database files are
located. Because these files are not located on
Windows systems, you will need to provide them
yourself and give their location here if you wish to
use $(D PosixTimeZone)s.
Throws:
$(D DateTimeException) if the given time zone could not be found or
$(D FileException) if the TZ Database file could not be opened.
Examples:
--------------------
auto tz = PosixTimeZone.getTimeZone("America/Los_Angeles");
assert(tz.name == "America/Los_Angeles");
assert(tz.stdName == "PST");
assert(tz.dstName == "PDT");
--------------------
+/
//TODO make it possible for tzDatabaseDir to be gzipped tar file rather than an uncompressed
// directory.
static immutable(PosixTimeZone) getTimeZone(string name, string tzDatabaseDir = defaultTZDatabaseDir)
{
name = strip(name);
enforce(tzDatabaseDir.exists, new DateTimeException(format("Directory %s does not exist.", tzDatabaseDir)));
enforce(tzDatabaseDir.isDir, new DateTimeException(format("%s is not a directory.", tzDatabaseDir)));
version(Posix)
auto file = tzDatabaseDir ~ name;
else version(Windows)
auto file = tzDatabaseDir ~ replace(strip(name), "/", sep);
enforce(file.exists, new DateTimeException(format("File %s does not exist.", file)));
enforce(file.isFile, new DateTimeException(format("%s is not a file.", file)));
auto tzFile = File(file);
immutable gmtZone = file.canFind("GMT");
try
{
_enforceValidTZFile(readVal!(char[])(tzFile, 4) == "TZif");
immutable char tzFileVersion = readVal!char(tzFile);
_enforceValidTZFile(tzFileVersion == '\0' || tzFileVersion == '2');
{
auto zeroBlock = readVal!(ubyte[])(tzFile, 15);
bool allZeroes = true;
foreach(val; zeroBlock)
{
if(val != 0)
{
allZeroes = false;
break;
}
}
_enforceValidTZFile(allZeroes);
}
//The number of UTC/local indicators stored in the file.
auto tzh_ttisgmtcnt = readVal!int(tzFile);
//The number of standard/wall indicators stored in the file.
auto tzh_ttisstdcnt = readVal!int(tzFile);
//The number of leap seconds for which data is stored in the file.
auto tzh_leapcnt = readVal!int(tzFile);
//The number of "transition times" for which data is stored in the file.
auto tzh_timecnt = readVal!int(tzFile);
//The number of "local time types" for which data is stored in the file (must not be zero).
auto tzh_typecnt = readVal!int(tzFile);
_enforceValidTZFile(tzh_typecnt != 0);
//The number of characters of "timezone abbreviation strings" stored in the file.
auto tzh_charcnt = readVal!int(tzFile);
//time_ts where DST transitions occur.
auto transitionTimeTs = new long[](tzh_timecnt);
foreach(ref transition; transitionTimeTs)
transition = readVal!int(tzFile);
//Indices into ttinfo structs indicating the changes
//to be made at the corresponding DST transition.
auto ttInfoIndices = new ubyte[](tzh_timecnt);
foreach(ref ttInfoIndex; ttInfoIndices)
ttInfoIndex = readVal!ubyte(tzFile);
//ttinfos which give info on DST transitions.
auto tempTTInfos = new TempTTInfo[](tzh_typecnt);
foreach(ref ttInfo; tempTTInfos)
ttInfo = readVal!TempTTInfo(tzFile);
//The array of time zone abbreviation characters.
auto tzAbbrevChars = readVal!(char[])(tzFile, tzh_charcnt);
auto leapSeconds = new LeapSecond[](tzh_leapcnt);
foreach(ref leapSecond; leapSeconds)
{
//The time_t when the leap second occurs.
auto timeT = readVal!int(tzFile);
//The total number of leap seconds to be applied after
//the corresponding leap second.
auto total = readVal!int(tzFile);
leapSecond = LeapSecond(timeT, total);
}
//Indicate whether each corresponding DST transition were specified
//in standard time or wall clock time.
auto transitionIsStd = new bool[](tzh_ttisstdcnt);
foreach(ref isStd; transitionIsStd)
isStd = readVal!bool(tzFile);
//Indicate whether each corresponding DST transition associated with
//local time types are specified in UTC or local time.
auto transitionInUTC = new bool[](tzh_ttisgmtcnt);
foreach(ref inUTC; transitionInUTC)
inUTC = readVal!bool(tzFile);
_enforceValidTZFile(!tzFile.eof());
//If version 2, the information is duplicated in 64-bit.
if(tzFileVersion == '2')
{
_enforceValidTZFile(readVal!(char[])(tzFile, 4) == "TZif");
_enforceValidTZFile(readVal!(char)(tzFile) == '2');
{
auto zeroBlock = readVal!(ubyte[])(tzFile, 15);
bool allZeroes = true;
foreach(val; zeroBlock)
{
if(val != 0)
{
allZeroes = false;
break;
}
}
_enforceValidTZFile(allZeroes);
}
//The number of UTC/local indicators stored in the file.
tzh_ttisgmtcnt = readVal!int(tzFile);
//The number of standard/wall indicators stored in the file.
tzh_ttisstdcnt = readVal!int(tzFile);
//The number of leap seconds for which data is stored in the file.
tzh_leapcnt = readVal!int(tzFile);
//The number of "transition times" for which data is stored in the file.
tzh_timecnt = readVal!int(tzFile);
//The number of "local time types" for which data is stored in the file (must not be zero).
tzh_typecnt = readVal!int(tzFile);
_enforceValidTZFile(tzh_typecnt != 0);
//The number of characters of "timezone abbreviation strings" stored in the file.
tzh_charcnt = readVal!int(tzFile);
//time_ts where DST transitions occur.
transitionTimeTs = new long[](tzh_timecnt);
foreach(ref transition; transitionTimeTs)
transition = readVal!long(tzFile);
//Indices into ttinfo structs indicating the changes
//to be made at the corresponding DST transition.
ttInfoIndices = new ubyte[](tzh_timecnt);
foreach(ref ttInfoIndex; ttInfoIndices)
ttInfoIndex = readVal!ubyte(tzFile);
//ttinfos which give info on DST transitions.
tempTTInfos = new TempTTInfo[](tzh_typecnt);
foreach(ref ttInfo; tempTTInfos)
ttInfo = readVal!TempTTInfo(tzFile);
//The array of time zone abbreviation characters.
tzAbbrevChars = readVal!(char[])(tzFile, tzh_charcnt);
leapSeconds = new LeapSecond[](tzh_leapcnt);
foreach(ref leapSecond; leapSeconds)
{
//The time_t when the leap second occurs.
auto timeT = readVal!long(tzFile);
//The total number of leap seconds to be applied after
//the corresponding leap second.
auto total = readVal!int(tzFile);
leapSecond = LeapSecond(timeT, total);
}
//Indicate whether each corresponding DST transition were specified
//in standard time or wall clock time.
transitionIsStd = new bool[](tzh_ttisstdcnt);
foreach(ref isStd; transitionIsStd)
isStd = readVal!bool(tzFile);
//Indicate whether each corresponding DST transition associated with
//local time types are specified in UTC or local time.
transitionInUTC = new bool[](tzh_ttisgmtcnt);
foreach(ref inUTC; transitionInUTC)
inUTC = readVal!bool(tzFile);
}
_enforceValidTZFile(tzFile.readln().strip().empty());
auto posixEnvStr = tzFile.readln().strip();
_enforceValidTZFile(tzFile.readln().strip().empty());
_enforceValidTZFile(tzFile.eof());
auto transitionTypes = new TransitionType*[](tempTTInfos.length);
foreach(i, ref ttype; transitionTypes)
{
bool isStd = false;
if(i < transitionIsStd.length && !transitionIsStd.empty)
isStd = transitionIsStd[i];
bool inUTC = false;
if(i < transitionInUTC.length && !transitionInUTC.empty)
inUTC = transitionInUTC[i];
ttype = new TransitionType(isStd, inUTC);
}
auto ttInfos = new immutable(TTInfo)*[](tempTTInfos.length);
foreach(i, ref ttInfo; ttInfos)
{
auto tempTTInfo = tempTTInfos[i];
if(gmtZone)
tempTTInfo.tt_gmtoff = -tempTTInfo.tt_gmtoff;
auto abbrevChars = tzAbbrevChars[tempTTInfo.tt_abbrind .. $];
string abbrev = abbrevChars[0 .. abbrevChars.stds_indexOf("\0")].idup;
ttInfo = new immutable(TTInfo)(tempTTInfos[i], abbrev);
}
auto tempTransitions = new TempTransition[](transitionTimeTs.length);
foreach(i, ref tempTransition; tempTransitions)
{
immutable ttiIndex = ttInfoIndices[i];
auto transitionTimeT = transitionTimeTs[i];
auto ttype = transitionTypes[ttiIndex];
auto ttInfo = ttInfos[ttiIndex];
tempTransition = TempTransition(transitionTimeT, ttInfo, ttype);
}
if(tempTransitions.empty)
{
_enforceValidTZFile(ttInfos.length == 1 && transitionTypes.length == 1);
tempTransitions ~= TempTransition(0, ttInfos[0], transitionTypes[0]);
}
sort!"a.timeT < b.timeT"(tempTransitions);
sort!"a.timeT < b.timeT"(leapSeconds);
auto transitions = new Transition[](tempTransitions.length);
foreach(i, ref transition; transitions)
{
auto tempTransition = tempTransitions[i];
auto transitionTimeT = tempTransition.timeT;
auto ttInfo = tempTransition.ttInfo;
auto ttype = tempTransition.ttype;
_enforceValidTZFile(i == 0 || transitionTimeT > tempTransitions[i - 1].timeT);
transition = Transition(transitionTimeT, ttInfo);
}
string stdName;
string dstName;
bool hasDST = false;
foreach(transition; retro(transitions))
{
auto ttInfo = transition.ttInfo;
if(ttInfo.isDST)
{
if(dstName.empty)
dstName = ttInfo.abbrev;
hasDST = true;
}
else
{
if(stdName.empty)
stdName = ttInfo.abbrev;
}
if(!stdName.empty && !dstName.empty)
break;
}
return new PosixTimeZone(transitions.idup, leapSeconds.idup, name, stdName, dstName, hasDST);
}
catch(DateTimeException dte)
throw dte;
catch(Exception e)
throw new DateTimeException("Not a valid TZ data file", __FILE__, __LINE__, e);
}
/++
Returns a list of the names of the time zones installed on the system.
You can provide a sub-name to narrow down the list of time zones (which
will likely be in the thousands if you get them all). For example,
if you pass in "America" as the sub-name, then only the time zones which
begin with "America" will be returned.
Params:
subName = The first part of the time zones that you want.
Throws:
$(D FileException) if it fails to read from disk.
+/
static string[] getInstalledTZNames(string subName = "", string tzDatabaseDir = defaultTZDatabaseDir)
{
version(Posix)
subName = strip(subName);
else version(Windows)
subName = replace(strip(subName), "/", sep);
if(!tzDatabaseDir.endsWith(sep))
tzDatabaseDir ~= sep;
enforce(tzDatabaseDir.exists, new DateTimeException(format("Directory %s does not exist.", tzDatabaseDir)));
enforce(tzDatabaseDir.isDir, new DateTimeException(format("%s is not a directory.", tzDatabaseDir)));
auto timezones = appender!(string[])();
foreach(DirEntry dentry; dirEntries(tzDatabaseDir, SpanMode.depth))
{
if(dentry.isFile)
{
auto tzName = dentry.name[tzDatabaseDir.length .. $];
if(!tzName.extension().empty() ||
!tzName.startsWith(subName) ||
tzName == "+VERSION")
{
continue;
}
timezones.put(tzName);
}
}
sort(timezones.data);
return timezones.data;
}
unittest
{
version(testStdDateTime)
{
version(Posix)
{
static void testPTZSuccess(string tzName)
{
scope(failure) writefln("TZName which threw: %s", tzName);
PosixTimeZone.getTimeZone(tzName);
}
static void testPTZFailure(string tzName)
{
scope(success) writefln("TZName which was supposed to throw: %s", tzName);
PosixTimeZone.getTimeZone(tzName);
}
auto tzNames = getInstalledTZNames();
foreach(tzName; tzNames)
assertNotThrown!DateTimeException(testPTZSuccess(tzName));
foreach(DirEntry dentry; dirEntries(defaultTZDatabaseDir, SpanMode.depth))
{
if(dentry.isFile)
{
auto tzName = dentry.name[defaultTZDatabaseDir.length .. $];
if(!canFind(tzNames, tzName))
assertThrown!DateTimeException(testPTZFailure(tzName));
}
}
}
}
}
private:
/+
Holds information on when a time transition occures (usually a
transition to or from DST) as well as a pointer to the $(D TTInfo) which
holds information on the utc offset passed the transition.
+/
struct Transition
{
this(long timeT, immutable (TTInfo)* ttInfo)
{
this.timeT = timeT;
this.ttInfo = ttInfo;
}
long timeT;
immutable (TTInfo)* ttInfo;
}
/+
Holds information on when a leap second occurs.
+/
struct LeapSecond
{
this(long timeT, int total)
{
this.timeT = timeT;
this.total = total;
}
long timeT;
int total;
}
/+
Holds information on the utc offset after a transition as well as
whether DST is in effect after that transition.
+/
struct TTInfo
{
this(in TempTTInfo tempTTInfo, string abbrev) immutable
{
utcOffset = tempTTInfo.tt_gmtoff;
isDST = tempTTInfo.tt_isdst;
this.abbrev = abbrev;
}
immutable int utcOffset; /// Offset from UTC.
immutable bool isDST; /// Whether DST is in effect.
immutable string abbrev; /// The current abbreviation for the time zone.
}
/+
Struct used to hold information relating to $(D TTInfo) while organizing
the time zone information prior to putting it in its final form.
+/
struct TempTTInfo
{
this(int gmtOff, bool isDST, ubyte abbrInd)
{
tt_gmtoff = gmtOff;
tt_isdst = isDST;
tt_abbrind = abbrInd;
}
int tt_gmtoff;
bool tt_isdst;
ubyte tt_abbrind;
}
/+
Struct used to hold information relating to $(D Transition) while
organizing the time zone information prior to putting it in its final
form.
+/
struct TempTransition
{
this(long timeT, immutable (TTInfo)* ttInfo, TransitionType* ttype)
{
this.timeT = timeT;
this.ttInfo = ttInfo;
this.ttype = ttype;
}
long timeT;
immutable (TTInfo)* ttInfo;
TransitionType* ttype;
}
/+
Struct used to hold information relating to $(D Transition) and
$(D TTInfo) while organizing the time zone information prior to putting
it in its final form.
+/
struct TransitionType
{
this(bool isStd, bool inUTC)
{
this.isStd = isStd;
this.inUTC = inUTC;
}
/// Whether the transition is in std time (as opposed to wall clock time).
bool isStd;
/// Whether the transition is in UTC (as opposed to local time).
bool inUTC;
}
/+
Reads an int from a TZ file.
+/
static T readVal(T)(ref File tzFile)
if((isIntegral!T || isSomeChar!T) || is(Unqual!T == bool))
{
import std.bitmanip;
T[1] buff;
_enforceValidTZFile(!tzFile.eof());
tzFile.rawRead(buff);
// @@@BUG@@@ 4414 forces us to save the result rather than use it directly.
auto bigEndian = cast(ubyte[T.sizeof])buff;
return bigEndianToNative!T(bigEndian);
}
/+
Reads an array of values from a TZ file.
+/
static T readVal(T)(ref File tzFile, size_t length)
if(isArray!T)
{
auto buff = new T(length);
_enforceValidTZFile(!tzFile.eof());
tzFile.rawRead(buff);
return buff;
}
/+
Reads a $(D TempTTInfo) from a TZ file.
+/
static T readVal(T)(ref File tzFile)
if(is(T == TempTTInfo))
{
return TempTTInfo(readVal!int(tzFile),
readVal!bool(tzFile),
readVal!ubyte(tzFile));
}
/+
Throws:
$(D DateTimeException) if $(D result) is false.
+/
static void _enforceValidTZFile(bool result, size_t line = __LINE__)
{
if(!result)
throw new DateTimeException("Not a valid tzdata file.", __FILE__, line);
}
int calculateLeapSeconds(long stdTime) const nothrow
{
try
{
if(_leapSeconds.empty)
return 0;
immutable unixTime = stdTimeToUnixTime(stdTime);
if(_leapSeconds.front.timeT >= unixTime)
return 0;
//Okay, casting is a hack, but countUntil shouldn't be changing it,
//and it would be too inefficient to have to keep duping it every
//time we have to calculate the time. Hopefully, countUntil will
//properly support immutable ranges at some point.
auto found = std.algorithm.countUntil!"b < a.timeT"(cast(LeapSecond[])_leapSeconds, unixTime);
if(found == -1)
return _leapSeconds.back.total;
auto leapSecond = found == 0 ? _leapSeconds[0] : _leapSeconds[found - 1];
return leapSecond.total;
}
catch(Exception e)
assert(0, format("Nothing in calculateLeapSeconds() should be throwing. Caught Exception: %s", e));
}
this(immutable Transition[] transitions,
immutable LeapSecond[] leapSeconds,
string name,
string stdName,
string dstName,
bool hasDST) immutable
{
if(dstName.empty && !stdName.empty)
dstName = stdName;
else if(stdName.empty && !dstName.empty)
stdName = dstName;
super(name, stdName, dstName);
if(!transitions.empty)
{
foreach(i, transition; transitions[0 .. $-1])
_enforceValidTZFile(transition.timeT < transitions[i + 1].timeT);
}
foreach(i, leapSecond; leapSeconds)
_enforceValidTZFile(i == leapSeconds.length - 1 || leapSecond.timeT < leapSeconds[i + 1].timeT);
_transitions = transitions;
_leapSeconds = leapSeconds;
_hasDST = hasDST;
}
/// List of times when the utc offset changes.
immutable Transition[] _transitions;
/// List of leap second occurrences.
immutable LeapSecond[] _leapSeconds;
/// Whether DST is in effect for this time zone at any point in time.
immutable bool _hasDST;
}
version(StdDdoc)
{
/++
$(BLUE This class is Windows-Only.)
Represents a time zone from the Windows registry. Unfortunately, Windows
does not use the TZ Database. You can, however, use $(D PosixTimeZone)
(which reads its information from the TZ Database files on disk) on
Windows if you provide the TZ Database files
( $(WEB ftp://elsie.nci.nih.gov/pub/,
Repository with the TZ Database files (tzdata)) )
yourself and tell $(D PosixTimeZone.getTimeZone) where the directory
holding them is.
The TZ Dabatase files and Windows are not likely to always match,
particularly for historical dates, so if you want complete consistency
between Posix and Windows, then you should provide the appropriate
TZ Database files on Windows and use $(D PosixTimeZone). But as
$(D WindowsTimeZone) uses the Windows functions, $(D WindowsTimeZone)
is more likely to match the behavior of other Windows programs.
$(D WindowsTimeZone) should be fine for most programs.
$(D WindowsTimeZone) does not exist on Posix systems.
To get a $(D WindowsTimeZone), either call
$(D WindowsTimeZone.getTimeZone) or call $(D TimeZone.getTimeZone)
(which will give you a $(D PosixTimeZone) on Posix systems and a
$(D WindowsTimeZone) on Windows systems).
+/
final class WindowsTimeZone : TimeZone
{
public:
/++
Whether this time zone has Daylight Savings Time at any point in
time. Note that for some time zone types it may not have DST for
current dates but will still return true for $(D hasDST) because the
time zone did at some point have DST.
+/
@property override bool hasDST() const nothrow;
/++
Takes the number of hnsecs (100 ns) since midnight, January 1st,
1 A.D. in UTC time (i.e. std time) and returns whether DST is in
effect in this time zone at the given point in time.
Params:
stdTime = The UTC time that needs to be checked for DST in this
time zone.
+/
override bool dstInEffect(long stdTime) const nothrow;
/++
Takes the number of hnsecs (100 ns) since midnight, January 1st,
1 A.D. in UTC time (i.e. std time) and converts it to this time
zone's time.
Params:
stdTime = The UTC time that needs to be adjusted to this time
zone's time.
+/
override long utcToTZ(long stdTime) const nothrow;
/++
Takes the number of hnsecs (100 ns) since midnight, January 1st,
1 A.D. in this time zone's time and converts it to UTC (i.e. std
time).
Params:
adjTime = The time in this time zone that needs to be adjusted
to UTC time.
+/
override long tzToUTC(long adjTime) const nothrow;
/++
Returns a $(D TimeZone) with the given name per the Windows time
zone names. The time zone information is fetched from the Windows
registry.
See_Also:
$(WEB en.wikipedia.org/wiki/Tz_database, Wikipedia entry on TZ
Database)
$(WEB en.wikipedia.org/wiki/List_of_tz_database_time_zones, List
of Time Zones)
Params:
name = The TZ Database name of the time zone that you're looking
for.
Throws:
$(D DateTimeException) if the given time zone could not be
found.
Examples:
--------------------
auto tz = TimeZone.getTimeZone("America/Los_Angeles");
--------------------
+/
static immutable(WindowsTimeZone) getTimeZone(string name);
/++
Returns a list of the names of the time zones installed on the
system.
+/
static string[] getInstalledTZNames();
private:
version(Windows) {}
else
alias void* TIME_ZONE_INFORMATION;
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;
this() immutable pure
{
super("", "", "");
}
}
}
else version(Windows)
{
//Should be in core.sys.windows.windows, but for some reason it isn't.
extern(Windows)
{
export LONG RegQueryValueExA(HKEY hKey, LPCSTR name, LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count);
struct REG_TZI_FORMAT
{
LONG Bias;
LONG StandardBias;
LONG DaylightBias;
SYSTEMTIME StandardDate;
SYSTEMTIME DaylightDate;
}
}
final class WindowsTimeZone : TimeZone
{
public:
@property override bool hasDST() const nothrow
{
return _tzInfo.DaylightDate.wMonth != 0;
}
override bool dstInEffect(long stdTime) const nothrow
{
return _dstInEffect(&_tzInfo, stdTime);
}
override long utcToTZ(long stdTime) const nothrow
{
return _utcToTZ(&_tzInfo, stdTime, hasDST);
}
override long tzToUTC(long adjTime) const nothrow
{
return _tzToUTC(&_tzInfo, adjTime, hasDST);
}
static immutable(WindowsTimeZone) getTimeZone(string name)
{
auto keyStr = "Software\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones\0";
HKEY baseKey;
{
auto result = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keyStr.ptr, 0, KEY_READ, &baseKey);
if(result != ERROR_SUCCESS)
throw new DateTimeException(format("Failed to open registry. Error: %s", result));
}
scope(exit) RegCloseKey(baseKey);
char[1024] keyName;
auto nameLen = to!DWORD(keyName.length);
int result;
for(DWORD index = 0;
(result = RegEnumKeyExA(baseKey, index, keyName.ptr, &nameLen, null, null, null, null)) != ERROR_NO_MORE_ITEMS;
++index, nameLen = keyName.length)
{
if(result == ERROR_SUCCESS)
{
HKEY tzKey;
if(RegOpenKeyExA(baseKey, keyName.ptr, 0, KEY_READ, &tzKey) == ERROR_SUCCESS)
{
scope(exit) RegCloseKey(tzKey);
char[1024] strVal;
auto strValLen = to!DWORD(strVal.length);
bool queryStringValue(string name, size_t lineNum = __LINE__)
{
strValLen = strVal.length;
return RegQueryValueExA(tzKey, name.ptr, null, null, cast(ubyte*)strVal.ptr, &strValLen) == ERROR_SUCCESS;
}
if(to!string(keyName.ptr) == name)
{
if(queryStringValue("Std\0"))
{
//Cannot use to!wstring(char*), probably due to bug http://d.puremagic.com/issues/show_bug.cgi?id=5016
static wstring conv(char* cstr, size_t strValLen)
{
cstr[strValLen - 1] = '\0';
string retval;
for(;; ++cstr)
{
if(*cstr == '\0')
break;
retval ~= *cstr;
}
return to!wstring(retval);
}
//auto stdName = to!wstring(strVal.ptr);
auto stdName = conv(strVal.ptr, strValLen);
if(queryStringValue("Dlt\0"))
{
//auto dstName = to!wstring(strVal.ptr);
auto dstName = conv(strVal.ptr, strValLen);
enum tzi = "TZI\0";
REG_TZI_FORMAT binVal;
auto binValLen = to!DWORD(REG_TZI_FORMAT.sizeof);
if(RegQueryValueExA(tzKey, tzi.ptr, null, null, cast(ubyte*)&binVal, &binValLen) == ERROR_SUCCESS)
{
TIME_ZONE_INFORMATION tzInfo;
auto stdNameLen = stdName.length > 32 ? 32 : stdName.length;
auto dstNameLen = dstName.length > 32 ? 32 : dstName.length;
tzInfo.Bias = binVal.Bias;
tzInfo.StandardName[0 .. stdNameLen] = stdName[0 .. stdNameLen];
tzInfo.StandardName[stdNameLen .. $] = '\0';
tzInfo.StandardDate = binVal.StandardDate;
tzInfo.StandardBias = binVal.StandardBias;
tzInfo.DaylightName[0 .. dstNameLen] = dstName[0 .. dstNameLen];
tzInfo.DaylightName[dstNameLen .. $] = '\0';
tzInfo.DaylightDate = binVal.DaylightDate;
tzInfo.DaylightBias = binVal.DaylightBias;
return new WindowsTimeZone(name, tzInfo);
}
}
}
}
}
}
}
throw new DateTimeException(format("Failed to find time zone: %s", name));
}
static string[] getInstalledTZNames()
{
auto timezones = appender!(string[])();
auto keyStr = "Software\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones";
HKEY baseKey;
{
auto result = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keyStr.ptr, 0, KEY_READ, &baseKey);
if(result != ERROR_SUCCESS)
throw new DateTimeException(format("Failed to open registry. Error: %s", result));
}
scope(exit) RegCloseKey(baseKey);
char[1024] keyName;
auto nameLen = to!DWORD(keyName.length);
int result;
for(DWORD index = 0;
(result = RegEnumKeyExA(baseKey, index, keyName.ptr, &nameLen, null, null, null, null)) != ERROR_NO_MORE_ITEMS;
++index, nameLen = keyName.length)
{
if(result == ERROR_SUCCESS)
timezones.put(to!string(keyName.ptr));
}
sort(timezones.data);
return timezones.data;
}
unittest
{
version(testStdDateTime)
{
static void testWTZSuccess(string tzName)
{
scope(failure) writefln("TZName which threw: %s", tzName);
WindowsTimeZone.getTimeZone(tzName);
}
auto tzNames = getInstalledTZNames();
foreach(tzName; tzNames)
assertNotThrown!DateTimeException(testWTZSuccess(tzName));
}
}
private:
static bool _dstInEffect(const TIME_ZONE_INFORMATION* tzInfo, long stdTime) nothrow
{
try
{
if(tzInfo.DaylightDate.wMonth == 0)
return false;
auto utcDateTime = cast(DateTime)SysTime(stdTime, UTC());
//The limits of what SystemTimeToTZSpecificLocalTime will accept.
if(utcDateTime.year < 1601)
{
if(utcDateTime.month == Month.feb && utcDateTime.day == 29)
utcDateTime.day = 28;
utcDateTime.year = 1601;
}
else if(utcDateTime.year > 30_827)
{
if(utcDateTime.month == Month.feb && utcDateTime.day == 29)
utcDateTime.day = 28;
utcDateTime.year = 30_827;
}
//SystemTimeToTZSpecificLocalTime doesn't act correctly at the
//beginning or end of the year (bleh). Unless some bizarre time
//zone changes DST on January 1st or December 31st, this should
//fix the problem.
if(utcDateTime.month == Month.jan)
{
if(utcDateTime.day == 1)
utcDateTime.day = 2;
}
else if(utcDateTime.month == Month.dec && utcDateTime.day == 31)
utcDateTime.day = 30;
SYSTEMTIME utcTime = void;
SYSTEMTIME otherTime = void;
utcTime.wYear = utcDateTime.year;
utcTime.wMonth = utcDateTime.month;
utcTime.wDay = utcDateTime.day;
utcTime.wHour = utcDateTime.hour;
utcTime.wMinute = utcDateTime.minute;
utcTime.wSecond = utcDateTime.second;
utcTime.wMilliseconds = 0;
immutable result = SystemTimeToTzSpecificLocalTime(cast(TIME_ZONE_INFORMATION*)tzInfo,
&utcTime,
&otherTime);
assert(result);
immutable otherDateTime = DateTime(otherTime.wYear,
otherTime.wMonth,
otherTime.wDay,
otherTime.wHour,
otherTime.wMinute,
otherTime.wSecond);
immutable diff = utcDateTime - otherDateTime;
immutable minutes = diff.total!"minutes"() - tzInfo.Bias;
if(minutes == tzInfo.DaylightBias)
return true;
assert(minutes == tzInfo.StandardBias);
return false;
}
catch(Exception e)
assert(0, "DateTime's constructor threw.");
}
version(testStdDateTime) unittest
{
TIME_ZONE_INFORMATION tzInfo;
GetTimeZoneInformation(&tzInfo);
foreach(year; [1600, 1601, 30_827, 30_828])
WindowsTimeZone._dstInEffect(&tzInfo, SysTime(DateTime(year, 1, 1)).stdTime);
}
static long _utcToTZ(const TIME_ZONE_INFORMATION* tzInfo, long stdTime, bool hasDST) nothrow
{
if(hasDST && WindowsTimeZone._dstInEffect(tzInfo, stdTime))
return stdTime - convert!("minutes", "hnsecs")(tzInfo.Bias + tzInfo.DaylightBias);
return stdTime - convert!("minutes", "hnsecs")(tzInfo.Bias + tzInfo.StandardBias);
}
static long _tzToUTC(const TIME_ZONE_INFORMATION* tzInfo, long adjTime, bool hasDST) nothrow
{
if(hasDST)
{
try
{
bool dstInEffectForLocalDateTime(DateTime localDateTime)
{
//The limits of what SystemTimeToTZSpecificLocalTime will accept.
if(localDateTime.year < 1601)
{
if(localDateTime.month == Month.feb && localDateTime.day == 29)
localDateTime.day = 28;
localDateTime.year = 1601;
}
else if(localDateTime.year > 30_827)
{
if(localDateTime.month == Month.feb && localDateTime.day == 29)
localDateTime.day = 28;
localDateTime.year = 30_827;
}
//SystemTimeToTZSpecificLocalTime doesn't act correctly at the
//beginning or end of the year (bleh). Unless some bizarre time
//zone changes DST on January 1st or December 31st, this should
//fix the problem.
if(localDateTime.month == Month.jan)
{
if(localDateTime.day == 1)
localDateTime.day = 2;
}
else if(localDateTime.month == Month.dec && localDateTime.day == 31)
localDateTime.day = 30;
SYSTEMTIME utcTime = void;
SYSTEMTIME localTime = void;
localTime.wYear = localDateTime.year;
localTime.wMonth = localDateTime.month;
localTime.wDay = localDateTime.day;
localTime.wHour = localDateTime.hour;
localTime.wMinute = localDateTime.minute;
localTime.wSecond = localDateTime.second;
localTime.wMilliseconds = 0;
immutable result = SystemTimeToTzSpecificLocalTime(cast(TIME_ZONE_INFORMATION*)tzInfo,
&localTime,
&utcTime);
assert(result);
immutable utcDateTime = DateTime(utcTime.wYear,
utcTime.wMonth,
utcTime.wDay,
utcTime.wHour,
utcTime.wMinute,
utcTime.wSecond);
immutable diff = localDateTime - utcDateTime;
immutable minutes = diff.total!"minutes"() - tzInfo.Bias;
if(minutes == tzInfo.DaylightBias)
return true;
assert(minutes == tzInfo.StandardBias);
return false;
}
auto localDateTime = cast(DateTime)SysTime(adjTime, UTC());
auto localDateTimeBefore = localDateTime - dur!"hours"(1);
auto localDateTimeAfter = localDateTime + dur!"hours"(1);
auto dstInEffectNow = dstInEffectForLocalDateTime(localDateTime);
auto dstInEffectBefore = dstInEffectForLocalDateTime(localDateTimeBefore);
auto dstInEffectAfter = dstInEffectForLocalDateTime(localDateTimeAfter);
bool isDST;
if(dstInEffectBefore && dstInEffectNow && dstInEffectAfter)
isDST = true;
else if(!dstInEffectBefore && !dstInEffectNow && !dstInEffectAfter)
isDST = false;
else if((!dstInEffectBefore && dstInEffectAfter) ||
(dstInEffectBefore && !dstInEffectAfter))
{
isDST = dstInEffectNow;
}
else
assert(0, "Bad Logic.");
if(isDST)
return adjTime + convert!("minutes", "hnsecs")(tzInfo.Bias + tzInfo.DaylightBias);
}
catch(Exception e)
assert(0, "SysTime's constructor threw.");
}
return adjTime + convert!("minutes", "hnsecs")(tzInfo.Bias + tzInfo.StandardBias);
}
this(string name, TIME_ZONE_INFORMATION tzInfo) immutable
{
//Cannot use to!string(wchar*), probably due to bug http://d.puremagic.com/issues/show_bug.cgi?id=5016
static string conv(wchar* wcstr)
{
wcstr[31] = '\0';
wstring retval;
for(;; ++wcstr)
{
if(*wcstr == '\0')
break;
retval ~= *wcstr;
}
return to!string(retval);
}
//super(name, to!string(tzInfo.StandardName.ptr), to!string(tzInfo.DaylightName.ptr));
super(name, conv(tzInfo.StandardName.ptr), conv(tzInfo.DaylightName.ptr));
_tzInfo = tzInfo;
}
TIME_ZONE_INFORMATION _tzInfo;
}
}
version(StdDdoc)
{
/++
$(BLUE This function is Posix-Only.)
Allows you to set the local time zone on Posix systems with the TZ
database name by setting the TZ environment variable.
Unfortunately, there is no way to do it on Windows using the TZ
database name, so this function only exists on Posix systems.
+/
void setTZEnvVar(string tzDatabaseName);
/++
$(BLUE This function is Posix-Only.)
Clears the TZ environment variable.
+/
void clearTZEnvVar();
}
else version(Posix)
{
void setTZEnvVar(string tzDatabaseName) nothrow
{
try
{
auto value = PosixTimeZone.defaultTZDatabaseDir ~ tzDatabaseName ~ "\0";
setenv("TZ", value.ptr, 1);
tzset();
}
catch(Exception e)
assert(0, "The impossible happened. setenv or tzset threw.");
}
void clearTZEnvVar() nothrow
{
try
{
unsetenv("TZ");
tzset();
}
catch(Exception e)
assert(0, "The impossible happened. unsetenv or tzset threw.");
}
}
/++
Converts the given TZ Database name to the corresponding Windows time zone
name.
Note that in a few cases, a TZ Dabatase name corresponds to two different
Windows time zone names. So, while in most cases converting from one to the
other and back again will result in the same time zone name that you started
with, in a few cases, you will get a different name.
Also, there are far more TZ Database names than Windows time zones, so some
of the more exotic TZ Database names don't have corresponding Windows time
zone names.
See_Also:
$(WEB unicode.org/repos/cldr-tmp/trunk/diff/supplemental/zone_tzid.html,
Windows <-> TZ Database Name Conversion Table)
Params:
tzName = The TZ Database name to convert.
Throws:
$(D DateTimeException) if the given $(D_PARAM tzName) cannot be
converted.
+/
string tzDatabaseNameToWindowsTZName(string tzName)
{
switch(tzName)
{
case "Africa/Cairo": return "Egypt Standard Time";
case "Africa/Casablanca": return "Morocco Standard Time";
case "Africa/Johannesburg": return "South Africa Standard Time";
case "Africa/Lagos": return "W. Central Africa Standard Time";
case "Africa/Nairobi": return "E. Africa Standard Time";
case "Africa/Windhoek": return "Namibia Standard Time";
case "America/Anchorage": return "Alaskan Standard Time";
case "America/Asuncion": return "Paraguay Standard Time";
case "America/Bogota": return "SA Pacific Standard Time";
case "America/Buenos_Aires": return "Argentina Standard Time";
case "America/Caracas": return "Venezuela Standard Time";
case "America/Cayenne": return "SA Eastern Standard Time";
case "America/Chicago": return "Central Standard Time";
case "America/Chihuahua": return "Mountain Standard Time (Mexico)";
case "America/Cuiaba": return "Central Brazilian Standard Time";
case "America/Denver": return "Mountain Standard Time";
case "America/Godthab": return "Greenland Standard Time";
case "America/Guatemala": return "Central America Standard Time";
case "America/Halifax": return "Atlantic Standard Time";
case "America/La_Paz": return "SA Western Standard Time";
case "America/Los_Angeles": return "Pacific Standard Time";
case "America/Mexico_City": return "Central Standard Time (Mexico)";
case "America/Montevideo": return "Montevideo Standard Time";
case "America/New_York": return "Eastern Standard Time";
case "America/Phoenix": return "US Mountain Standard Time";
case "America/Regina": return "Canada Central Standard Time";
case "America/Santa_Isabel": return "Pacific Standard Time (Mexico)";
case "America/Santiago": return "Pacific SA Standard Time";
case "America/Sao_Paulo": return "E. South America Standard Time";
case "America/St_Johns": return "Newfoundland Standard Time";
case "Asia/Almaty": return "Central Asia Standard Time";
case "Asia/Amman": return "Jordan Standard Time";
case "Asia/Baghdad": return "Arabic Standard Time";
case "Asia/Baku": return "Azerbaijan Standard Time";
case "Asia/Bangkok": return "SE Asia Standard Time";
case "Asia/Beirut": return "Middle East Standard Time";
case "Asia/Calcutta": return "India Standard Time";
case "Asia/Colombo": return "Sri Lanka Standard Time";
case "Asia/Damascus": return "Syria Standard Time";
case "Asia/Dhaka": return "Bangladesh Standard Time";
case "Asia/Dubai": return "Arabian Standard Time";
case "Asia/Irkutsk": return "North Asia East Standard Time";
case "Asia/Jerusalem": return "Israel Standard Time";
case "Asia/Kabul": return "Afghanistan Standard Time";
case "Asia/Kamchatka": return "Kamchatka Standard Time";
case "Asia/Karachi": return "Pakistan Standard Time";
case "Asia/Katmandu": return "Nepal Standard Time";
case "Asia/Krasnoyarsk": return "North Asia Standard Time";
case "Asia/Magadan": return "Magadan Standard Time";
case "Asia/Novosibirsk": return "N. Central Asia Standard Time";
case "Asia/Rangoon": return "Myanmar Standard Time";
case "Asia/Riyadh": return "Arab Standard Time";
case "Asia/Seoul": return "Korea Standard Time";
case "Asia/Shanghai": return "China Standard Time";
case "Asia/Singapore": return "Singapore Standard Time";
case "Asia/Taipei": return "Taipei Standard Time";
case "Asia/Tashkent": return "West Asia Standard Time";
case "Asia/Tbilisi": return "Georgian Standard Time";
case "Asia/Tehran": return "Iran Standard Time";
case "Asia/Tokyo": return "Tokyo Standard Time";
case "Asia/Ulaanbaatar": return "Ulaanbaatar Standard Time";
case "Asia/Vladivostok": return "Vladivostok Standard Time";
case "Asia/Yakutsk": return "Yakutsk Standard Time";
case "Asia/Yekaterinburg": return "Ekaterinburg Standard Time";
case "Asia/Yerevan": return "Caucasus Standard Time";
case "Atlantic/Azores": return "Azores Standard Time";
case "Atlantic/Cape_Verde": return "Cape Verde Standard Time";
case "Atlantic/Reykjavik": return "Greenwich Standard Time";
case "Australia/Adelaide": return "Cen. Australia Standard Time";
case "Australia/Brisbane": return "E. Australia Standard Time";
case "Australia/Darwin": return "AUS Central Standard Time";
case "Australia/Hobart": return "Tasmania Standard Time";
case "Australia/Perth": return "W. Australia Standard Time";
case "Australia/Sydney": return "AUS Eastern Standard Time";
case "Etc/GMT-12": return "UTC+12";
case "Etc/GMT": return "UTC";
case "Etc/GMT+11": return "UTC-11";
case "Etc/GMT+12": return "Dateline Standard Time";
case "Etc/GMT+2": return "Mid-Atlantic Standard Time";
case "Etc/GMT+5": return "US Eastern Standard Time";
case "Europe/Berlin": return "W. Europe Standard Time";
case "Europe/Budapest": return "Central Europe Standard Time";
case "Europe/Istanbul": return "GTB Standard Time";
case "Europe/Kiev": return "FLE Standard Time";
case "Europe/London": return "GMT Standard Time";
case "Europe/Minsk": return "E. Europe Standard Time";
case "Europe/Moscow": return "Russian Standard Time";
case "Europe/Paris": return "Romance Standard Time";
case "Europe/Warsaw": return "Central European Standard Time";
case "Indian/Mauritius": return "Mauritius Standard Time";
case "Pacific/Apia": return "Samoa Standard Time";
case "Pacific/Auckland": return "New Zealand Standard Time";
case "Pacific/Fiji": return "Fiji Standard Time";
case "Pacific/Guadalcanal": return "Central Pacific Standard Time";
case "Pacific/Honolulu": return "Hawaiian Standard Time";
case "Pacific/Port_Moresby": return "West Pacific Standard Time";
case "Pacific/Tongatapu": return "Tonga Standard Time";
default:
throw new DateTimeException(format("Could not find Windows time zone name for: %s.", tzName));
}
}
unittest
{
version(testStdDateTime)
{
version(Windows)
{
static void testTZSuccess(string tzName)
{
scope(failure) writefln("TZName which threw: %s", tzName);
tzDatabaseNameToWindowsTZName(tzName);
}
auto timeZones = TimeZone.getInstalledTZNames();
foreach(tzname; timeZones)
assertNotThrown!DateTimeException(testTZSuccess(tzname));
}
}
}
/++
Converts the given Windows time zone name to a corresponding TZ Database
name.
See_Also:
$(WEB unicode.org/repos/cldr-tmp/trunk/diff/supplemental/zone_tzid.html,
Windows <-> TZ Database Name Conversion Table)
Params:
tzName = The TZ Database name to convert.
Throws:
$(D DateTimeException) if the given $(D_PARAM tzName) cannot be
converted.
+/
string windowsTZNameToTZDatabaseName(string tzName)
{
switch(tzName)
{
case "AUS Central Standard Time": return "Australia/Darwin";
case "AUS Eastern Standard Time": return "Australia/Sydney";
case "Afghanistan Standard Time": return "Asia/Kabul";
case "Alaskan Standard Time": return "America/Anchorage";
case "Arab Standard Time": return "Asia/Riyadh";
case "Arabian Standard Time": return "Asia/Dubai";
case "Arabic Standard Time": return "Asia/Baghdad";
case "Argentina Standard Time": return "America/Buenos_Aires";
case "Armenian Standard Time": return "Asia/Yerevan";
case "Atlantic Standard Time": return "America/Halifax";
case "Azerbaijan Standard Time": return "Asia/Baku";
case "Azores Standard Time": return "Atlantic/Azores";
case "Bangladesh Standard Time": return "Asia/Dhaka";
case "Canada Central Standard Time": return "America/Regina";
case "Cape Verde Standard Time": return "Atlantic/Cape_Verde";
case "Caucasus Standard Time": return "Asia/Yerevan";
case "Cen. Australia Standard Time": return "Australia/Adelaide";
case "Central America Standard Time": return "America/Guatemala";
case "Central Asia Standard Time": return "Asia/Almaty";
case "Central Brazilian Standard Time": return "America/Cuiaba";
case "Central Europe Standard Time": return "Europe/Budapest";
case "Central European Standard Time": return "Europe/Warsaw";
case "Central Pacific Standard Time": return "Pacific/Guadalcanal";
case "Central Standard Time": return "America/Chicago";
case "Central Standard Time (Mexico)": return "America/Mexico_City";
case "China Standard Time": return "Asia/Shanghai";
case "Dateline Standard Time": return "Etc/GMT+12";
case "E. Africa Standard Time": return "Africa/Nairobi";
case "E. Australia Standard Time": return "Australia/Brisbane";
case "E. Europe Standard Time": return "Europe/Minsk";
case "E. South America Standard Time": return "America/Sao_Paulo";
case "Eastern Standard Time": return "America/New_York";
case "Egypt Standard Time": return "Africa/Cairo";
case "Ekaterinburg Standard Time": return "Asia/Yekaterinburg";
case "FLE Standard Time": return "Europe/Kiev";
case "Fiji Standard Time": return "Pacific/Fiji";
case "GMT Standard Time": return "Europe/London";
case "GTB Standard Time": return "Europe/Istanbul";
case "Georgian Standard Time": return "Asia/Tbilisi";
case "Greenland Standard Time": return "America/Godthab";
case "Greenwich Standard Time": return "Atlantic/Reykjavik";
case "Hawaiian Standard Time": return "Pacific/Honolulu";
case "India Standard Time": return "Asia/Calcutta";
case "Iran Standard Time": return "Asia/Tehran";
case "Israel Standard Time": return "Asia/Jerusalem";
case "Jordan Standard Time": return "Asia/Amman";
case "Kamchatka Standard Time": return "Asia/Kamchatka";
case "Korea Standard Time": return "Asia/Seoul";
case "Magadan Standard Time": return "Asia/Magadan";
case "Mauritius Standard Time": return "Indian/Mauritius";
case "Mexico Standard Time": return "America/Mexico_City";
case "Mexico Standard Time 2": return "America/Chihuahua";
case "Mid-Atlantic Standard Time": return "Etc/GMT+2";
case "Middle East Standard Time": return "Asia/Beirut";
case "Montevideo Standard Time": return "America/Montevideo";
case "Morocco Standard Time": return "Africa/Casablanca";
case "Mountain Standard Time": return "America/Denver";
case "Mountain Standard Time (Mexico)": return "America/Chihuahua";
case "Myanmar Standard Time": return "Asia/Rangoon";
case "N. Central Asia Standard Time": return "Asia/Novosibirsk";
case "Namibia Standard Time": return "Africa/Windhoek";
case "Nepal Standard Time": return "Asia/Katmandu";
case "New Zealand Standard Time": return "Pacific/Auckland";
case "Newfoundland Standard Time": return "America/St_Johns";
case "North Asia East Standard Time": return "Asia/Irkutsk";
case "North Asia Standard Time": return "Asia/Krasnoyarsk";
case "Pacific SA Standard Time": return "America/Santiago";
case "Pacific Standard Time": return "America/Los_Angeles";
case "Pacific Standard Time (Mexico)": return "America/Santa_Isabel";
case "Pakistan Standard Time": return "Asia/Karachi";
case "Paraguay Standard Time": return "America/Asuncion";
case "Romance Standard Time": return "Europe/Paris";
case "Russian Standard Time": return "Europe/Moscow";
case "SA Eastern Standard Time": return "America/Cayenne";
case "SA Pacific Standard Time": return "America/Bogota";
case "SA Western Standard Time": return "America/La_Paz";
case "SE Asia Standard Time": return "Asia/Bangkok";
case "Samoa Standard Time": return "Pacific/Apia";
case "Singapore Standard Time": return "Asia/Singapore";
case "South Africa Standard Time": return "Africa/Johannesburg";
case "Sri Lanka Standard Time": return "Asia/Colombo";
case "Syria Standard Time": return "Asia/Damascus";
case "Taipei Standard Time": return "Asia/Taipei";
case "Tasmania Standard Time": return "Australia/Hobart";
case "Tokyo Standard Time": return "Asia/Tokyo";
case "Tonga Standard Time": return "Pacific/Tongatapu";
case "US Eastern Standard Time": return "Etc/GMT+5";
case "US Mountain Standard Time": return "America/Phoenix";
case "UTC": return "Etc/GMT";
case "UTC+12": return "Etc/GMT-12";
case "UTC-02": return "Etc/GMT+2";
case "UTC-11": return "Etc/GMT+11";
case "Ulaanbaatar Standard Time": return "Asia/Ulaanbaatar";
case "Venezuela Standard Time": return "America/Caracas";
case "Vladivostok Standard Time": return "Asia/Vladivostok";
case "W. Australia Standard Time": return "Australia/Perth";
case "W. Central Africa Standard Time": return "Africa/Lagos";
case "W. Europe Standard Time": return "Europe/Berlin";
case "West Asia Standard Time": return "Asia/Tashkent";
case "West Pacific Standard Time": return "Pacific/Port_Moresby";
case "Yakutsk Standard Time": return "Asia/Yakutsk";
default:
throw new DateTimeException(format("Could not find TZ Database name for: %s.", tzName));
}
}
unittest
{
version(testStdDateTime)
{
version(Windows)
{
static void testTZSuccess(string tzName)
{
scope(failure) writefln("TZName which threw: %s", tzName);
windowsTZNameToTZDatabaseName(tzName);
}
auto timeZones = WindowsTimeZone.getInstalledTZNames();
foreach(tzname; timeZones)
assertNotThrown!DateTimeException(testTZSuccess(tzname));
}
}
}
//==============================================================================
// Section with StopWatch and Benchmark Code.
//==============================================================================
/++
$(D StopWatch) measures time as precisely as possible.
This class uses a high-performance counter. On Windows systems, it uses
$(D QueryPerformanceCounter), and on Posix systems, it uses
$(D clock_gettime) if available, and $(D gettimeofday) otherwise.
But the precision of $(D StopWatch) differs from system to system. It is
impossible to for it to be the same from system to system since the precision
of the system clock varies from system to system, and other system-dependent
and situation-dependent stuff (such as the overhead of a context switch
between threads) can also affect $(D StopWatch)'s accuracy.
Examples:
--------------------
void foo()
{
StopWatch sw;
enum n = 100;
TickDuration[n] times;
TickDuration last = TickDuration.from!"seconds"(0);
foreach(i; 0..n)
{
sw.start(); //start/resume mesuring.
foreach(unused; 0..1_000_000)
bar();
sw.stop(); //stop/pause measuring.
//Return value of peek() after having stopped are the always same.
writeln((i + 1) * 1_000_000, " times done, lap time: ",
sw.peek().msecs, "[ms]");
times[i] = sw.peek() - last;
last = sw.peek();
}
real sum = 0;
// When you want to know the number of seconds,
// you can use properties of TickDuration.
// (seconds, mseconds, useconds, hnsecs)
foreach(t; times)
sum += t.hnsecs;
writeln("Average time: ", sum/n, " hnsecs");
}
--------------------
+/
@safe struct StopWatch
{
public:
//Verify Example
@safe unittest
{
void writeln(S...)(S args){}
static void bar() {}
StopWatch sw;
enum n = 100;
TickDuration[n] times;
TickDuration last = TickDuration.from!"seconds"(0);
foreach(i; 0..n)
{
sw.start(); //start/resume mesuring.
foreach(unused; 0..1_000_000)
bar();
sw.stop(); //stop/pause measuring.
//Return value of peek() after having stopped are the always same.
writeln((i + 1) * 1_000_000, " times done, lap time: ",
sw.peek().msecs, "[ms]");
times[i] = sw.peek() - last;
last = sw.peek();
}
real sum = 0;
// When you want to know the number of seconds,
// you can use properties of TickDuration.
// (seconds, mseconds, useconds, hnsecs)
foreach(t; times)
sum += t.hnsecs;
writeln("Average time: ", sum/n, " hnsecs");
}
/++
Auto start with constructor.
+/
this(AutoStart autostart)
{
if(autostart)
start();
}
version(testStdDateTime) @safe unittest
{
auto sw = StopWatch(AutoStart.yes);
sw.stop();
}
///
bool opEquals(const ref StopWatch rhs) const pure nothrow
{
return _timeStart == rhs._timeStart &&
_timeMeasured == rhs._timeMeasured;
}
/++
Resets the stop watch.
+/
void reset()
{
if(_flagStarted)
{
// Set current system time if StopWatch is measuring.
_timeStart = Clock.currSystemTick;
}
else
{
// Set zero if StopWatch is not measuring.
_timeStart.length = 0;
}
_timeMeasured.length = 0;
}
version(testStdDateTime) @safe unittest
{
StopWatch sw;
sw.start();
sw.stop();
sw.reset();
assert(sw.peek().to!("seconds", real) == 0);
}
/++
Starts the stop watch.
+/
void start()
{
assert(!_flagStarted);
StopWatch sw;
_flagStarted = true;
_timeStart = Clock.currSystemTick;
}
version(testStdDateTime) @trusted unittest
{
StopWatch sw;
sw.start();
auto t1 = sw.peek();
bool doublestart = true;
try
sw.start();
catch(AssertError e)
doublestart = false;
assert(!doublestart);
sw.stop();
assert((t1 - sw.peek()).to!("seconds", real) <= 0);
}
/++
Stops the stop watch.
+/
void stop()
{
assert(_flagStarted);
_flagStarted = false;
_timeMeasured += Clock.currSystemTick - _timeStart;
}
version(testStdDateTime) @trusted unittest
{
StopWatch sw;
sw.start();
sw.stop();
auto t1 = sw.peek();
bool doublestop = true;
try
sw.stop();
catch(AssertError e)
doublestop = false;
assert(!doublestop);
assert((t1 - sw.peek()).to!("seconds", real) == 0);
}
/++
Peek at the amount of time which has passed since the stop watch was
started.
+/
TickDuration peek() const
{
if(_flagStarted)
return Clock.currSystemTick - _timeStart + _timeMeasured;
return _timeMeasured;
}
version(testStdDateTime) @safe unittest
{
StopWatch sw;
sw.start();
auto t1 = sw.peek();
sw.stop();
auto t2 = sw.peek();
auto t3 = sw.peek();
assert(t1 <= t2);
assert(t2 == t3);
}
private:
// true if observing.
bool _flagStarted = false;
// TickDuration at the time of StopWatch starting measurement.
TickDuration _timeStart;
// Total time that StopWatch ran.
TickDuration _timeMeasured;
}
// workaround for bug4886
@safe size_t lengthof(aliases...)() pure nothrow
{
return aliases.length;
}
/++
Benchmarks code for speed assessment and comparison.
Params:
fun = aliases of callable objects (e.g. function names). Each should
take no arguments.
n = The number of times each function is to be executed.
Returns:
The amount of time (as a $(CXREF time, TickDuration)) that it took to
call each function $(D n) times. The first value is the length of time
that it took to call $(D fun[0]) $(D n) times. The second value is the
length of time it took to call $(D fun[1]) $(D n) times. Etc.
Examples:
--------------------
int a;
void f0() {}
void f1() {auto b = a;}
void f2() {auto b = to!(string)(a);}
auto r = benchmark!(f0, f1, f2)(10_000_000);
writefln("Milliseconds to call fun[0] n times: %s", r[0].to!("msecs", int));
--------------------
+/
@safe TickDuration[lengthof!(fun)()] benchmark(fun...)(uint n)
if(areAllSafe!fun)
{
TickDuration[lengthof!(fun)()] result;
StopWatch sw;
sw.start();
foreach(i, unused; fun)
{
sw.reset();
foreach(j; 0 .. n)
fun[i]();
result[i] = sw.peek();
}
return result;
}
/++ Ditto +/
TickDuration[lengthof!(fun)()] benchmark(fun...)(uint times)
if(!areAllSafe!fun)
{
TickDuration[lengthof!(fun)()] result;
StopWatch sw;
sw.start();
foreach(i, unused; fun)
{
sw.reset();
foreach(j; 0 .. times)
fun[i]();
result[i] = sw.peek();
}
return result;
}
//Verify Examples.
version(testStdDateTime) unittest
{
void writefln(S...)(S args){}
int a;
void f0() {}
void f1() {auto b = a;}
void f2() {auto b = to!(string)(a);}
auto r = benchmark!(f0, f1, f2)(10_000_000);
writefln("Milliseconds to call fun[0] n times: %s", r[0].to!("msecs", int));
}
version(testStdDateTime) @safe unittest
{
int a;
void f0() {}
//void f1() {auto b = to!(string)(a);}
void f2() {auto b = (a);}
auto r = benchmark!(f0, f2)(100);
}
/++
Return value of benchmark with two functions comparing.
+/
@safe struct ComparingBenchmarkResult
{
/++
Evaluation value
This returns the evaluation value of performance as the ratio of
baseFunc's time over targetFunc's time. If performance is high, this
returns a high value.
+/
@property real point() const pure nothrow
{
return _baseTime.length / cast(const real)_targetTime.length;
}
/++
The time required of the base function
+/
@property public TickDuration baseTime() const pure nothrow
{
return _baseTime;
}
/++
The time required of the target function
+/
@property public TickDuration targetTime() const pure nothrow
{
return _targetTime;
}
private:
this(TickDuration baseTime, TickDuration targetTime) pure nothrow
{
_baseTime = baseTime;
_targetTime = targetTime;
}
TickDuration _baseTime;
TickDuration _targetTime;
}
/++
Benchmark with two functions comparing.
Params:
baseFunc = The function to become the base of the speed.
targetFunc = The function that wants to measure speed.
times = The number of times each function is to be executed.
Examples:
--------------------
void f1() {
// ...
}
void f2() {
// ...
}
void main() {
auto b = comparingBenchmark!(f1, f2, 0x80);
writeln(b.point);
}
--------------------
+/
@safe ComparingBenchmarkResult comparingBenchmark(alias baseFunc,
alias targetFunc,
int times = 0xfff)()
if(isSafe!baseFunc && isSafe!targetFunc)
{
auto t = benchmark!(baseFunc, targetFunc)(times);
return ComparingBenchmarkResult(t[0], t[1]);
}
/++ Ditto +/
ComparingBenchmarkResult comparingBenchmark(alias baseFunc,
alias targetFunc,
int times = 0xfff)()
if(!isSafe!baseFunc || !isSafe!targetFunc)
{
auto t = benchmark!(baseFunc, targetFunc)(times);
return ComparingBenchmarkResult(t[0], t[1]);
}
version(testStdDateTime) @safe unittest
{
void f1x() {}
void f2x() {}
@safe void f1o() {}
@safe void f2o() {}
auto b1 = comparingBenchmark!(f1o, f2o, 1); // OK
//static auto b2 = comparingBenchmark!(f1x, f2x, 1); // NG
}
version(testStdDateTime) unittest
{
void f1x() {}
void f2x() {}
@safe void f1o() {}
@safe void f2o() {}
auto b1 = comparingBenchmark!(f1o, f2o, 1); // OK
auto b2 = comparingBenchmark!(f1x, f2x, 1); // OK
}
//==============================================================================
// Section with public helper functions and templates.
//==============================================================================
/++
$(RED Deprecated. It will be removed in February 2012. This is only here to
help transition code which uses std.date to using std.datetime.)
Returns a $(D d_time) for the given $(D SysTime).
+/
deprecated long sysTimeToDTime(in SysTime sysTime)
{
return convert!("hnsecs", "msecs")(sysTime.stdTime - 621355968000000000L);
}
version(testStdDateTime) unittest
{
_assertPred!"=="(sysTimeToDTime(SysTime(DateTime(1970, 1, 1), UTC())),
0);
_assertPred!"=="(sysTimeToDTime(SysTime(DateTime(1970, 1, 1), FracSec.from!"msecs"(1), UTC())),
1);
_assertPred!"=="(sysTimeToDTime(SysTime(DateTime(1969, 12, 31, 23, 59, 59), FracSec.from!"msecs"(999), UTC())),
-1);
_assertPred!"=="(sysTimeToDTime(SysTime(DateTime(1970, 1, 2), UTC())),
86_400_000);
_assertPred!"=="(sysTimeToDTime(SysTime(DateTime(1969, 12, 31), UTC())),
-86_400_000);
}
/++
$(RED Deprecated. It will be removed in February 2012. This is only here to
help transition code which uses std.date to using std.datetime.)
Returns a $(D SysTime) for the given $(D d_time).
+/
deprecated SysTime dTimeToSysTime(long dTime, immutable TimeZone tz = null)
{
immutable hnsecs = convert!("msecs", "hnsecs")(dTime) + 621355968000000000L;
return SysTime(hnsecs, tz);
}
version(testStdDateTime) unittest
{
_assertPred!"=="(dTimeToSysTime(0),
SysTime(DateTime(1970, 1, 1), UTC()));
_assertPred!"=="(dTimeToSysTime(1),
SysTime(DateTime(1970, 1, 1), FracSec.from!"msecs"(1), UTC()));
_assertPred!"=="(dTimeToSysTime(-1),
SysTime(DateTime(1969, 12, 31, 23, 59, 59), FracSec.from!"msecs"(999), UTC()));
_assertPred!"=="(dTimeToSysTime(86_400_000),
SysTime(DateTime(1970, 1, 2), UTC()));
_assertPred!"=="(dTimeToSysTime(-86_400_000),
SysTime(DateTime(1969, 12, 31), UTC()));
}
/++
Returns the absolute value of a duration.
+/
D abs(D)(D duration)
if(is(Unqual!D == Duration) ||
is(Unqual!D == TickDuration))
{
static if(is(Unqual!D == Duration))
return dur!"hnsecs"(std.math.abs(duration.total!"hnsecs"()));
else static if(is(Unqual!D == TickDuration))
return TickDuration(std.math.abs(duration.length));
else
static assert(0);
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(abs(dur!"msecs"(5)), dur!"msecs"(5));
_assertPred!"=="(abs(dur!"msecs"(-5)), dur!"msecs"(5));
_assertPred!"=="(abs(TickDuration(17)), TickDuration(17));
_assertPred!"=="(abs(TickDuration(-17)), TickDuration(17));
}
}
/++
Whether the given type defines all of the necessary functions for it to
function as a time point.
+/
template isTimePoint(T)
{
enum isTimePoint = hasMin!T &&
hasMax!T &&
hasOverloadedOpBinaryWithDuration!T &&
hasOverloadedOpAssignWithDuration!T &&
hasOverloadedOpBinaryWithSelf!T;
}
unittest
{
version(testStdDateTime)
{
static assert(isTimePoint!(Date));
static assert(isTimePoint!(DateTime));
static assert(isTimePoint!(TimeOfDay));
static assert(isTimePoint!(SysTime));
static assert(isTimePoint!(const Date));
static assert(isTimePoint!(const DateTime));
static assert(isTimePoint!(const TimeOfDay));
static assert(isTimePoint!(const SysTime));
static assert(isTimePoint!(immutable Date));
static assert(isTimePoint!(immutable DateTime));
static assert(isTimePoint!(immutable TimeOfDay));
static assert(isTimePoint!(immutable SysTime));
}
}
/++
Whether the given Gregorian Year is a leap year.
Params:
year = The year to to be tested.
+/
static bool yearIsLeapYear(int year) pure nothrow
{
if(year % 400 == 0)
return true;
if(year % 100 == 0)
return false;
return year % 4 == 0;
}
version(testStdDateTime) unittest
{
foreach(year; [1, 2, 3, 5, 6, 7, 100, 200, 300, 500, 600, 700, 1998, 1999,
2001, 2002, 2003, 2005, 2006, 2007, 2009, 2010, 2011])
{
assert(!yearIsLeapYear(year), format("year: %s.", year));
assert(!yearIsLeapYear(-year), format("year: %s.", year));
}
foreach(year; [0, 4, 8, 400, 800, 1600, 1996, 2000, 2004, 2008, 2012])
{
assert(yearIsLeapYear(year), format("year: %s.", year));
assert(yearIsLeapYear(-year), format("year: %s.", year));
}
}
/++
Converts a $(D time_t) (which uses midnight, January 1st, 1970 UTC as its
epoch and seconds as its units) to std time (which uses midnight,
January 1st, 1 A.D. UTC and hnsecs as its units).
Params:
unixTime = The $(D time_t) to convert.
+/
long unixTimeToStdTime(time_t unixTime) pure nothrow
{
return 621_355_968_000_000_000L + convert!("seconds", "hnsecs")(unixTime);
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(unixTimeToStdTime(0), 621_355_968_000_000_000L); //Midnight, January 1st, 1970
_assertPred!"=="(unixTimeToStdTime(86_400), 621_355_968_000_000_000L + 864_000_000_000L); //Midnight, January 2nd, 1970
_assertPred!"=="(unixTimeToStdTime(-86_400), 621_355_968_000_000_000L - 864_000_000_000L); //Midnight, December 31st, 1969
_assertPred!"=="(unixTimeToStdTime(0), (Date(1970, 1, 1) - Date(1, 1, 1)).total!"hnsecs");
_assertPred!"=="(unixTimeToStdTime(0), (DateTime(1970, 1, 1) - DateTime(1, 1, 1)).total!"hnsecs");
}
}
/++
Converts std time (which uses midnight, January 1st, 1 A.D. UTC as its epoch
and hnsecs as its units) to $(D time_t) (which uses midnight, January 1st,
1970 UTC as its epoch and seconds as its units). If $(D time_t) is 32 bits,
rather than 64, and the result can't fit in a 32-bit value, then the closest
value that can be held in 32 bits will be used (so $(D time_t.max) if it
goes over and $(D time_t.min) if it goes under).
Note:
While Windows systems require that $(D time_t) be non-negative (in spite
of $(D time_t) being signed), this function still returns negative
numbers on Windows, since it's more flexible to allow negative time_t
for those who need it. So, if you're on Windows and are using the
standard C functions or Win32 API functions which take a $(D time_t),
you may want to check whether the return value of
$(D stdTimeToUnixTime) is non-negative.
Params:
stdTime = The std time to convert.
+/
time_t stdTimeToUnixTime(long stdTime) pure nothrow
{
immutable unixTime = convert!("hnsecs", "seconds")(stdTime - 621_355_968_000_000_000L);
static if(time_t.sizeof >= long.sizeof)
return cast(time_t)unixTime;
else
{
if(unixTime > 0)
{
if(unixTime > time_t.max)
return time_t.max;
return cast(time_t)unixTime;
}
if(unixTime < time_t.min)
return time_t.min;
return cast(time_t)unixTime;
}
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(stdTimeToUnixTime(621_355_968_000_000_000L), 0); //Midnight, January 1st, 1970
_assertPred!"=="(stdTimeToUnixTime(621_355_968_000_000_000L + 864_000_000_000L), 86_400); //Midnight, January 2nd, 1970
_assertPred!"=="(stdTimeToUnixTime(621_355_968_000_000_000L - 864_000_000_000L), -86_400); //Midnight, December 31st, 1969
_assertPred!"=="(stdTimeToUnixTime((Date(1970, 1, 1) - Date(1, 1, 1)).total!"hnsecs"), 0);
_assertPred!"=="(stdTimeToUnixTime((DateTime(1970, 1, 1) - DateTime(1, 1, 1)).total!"hnsecs"), 0);
}
}
version(StdDdoc)
{
version(Windows) {}
else
{
alias void* SYSTEMTIME;
alias void* FILETIME;
}
/++
$(BLUE This function is Windows-Only.)
Converts a $(D SYSTEMTIME) struct to a $(D SysTime).
Params:
st = The $(D SYSTEMTIME) struct to convert.
tz = The time zone that the time in the $(D SYSTEMTIME) struct is
assumed to be (if the $(D SYSTEMTIME) was supplied by a Windows
system call, the $(D SYSTEMTIME) will either be in local time
or UTC, depending on the call).
Throws:
$(D DateTimeException) if the given $(D SYSTEMTIME) will not fit in
a $(D SysTime), which is highly unlikely to happen given that
$(D SysTime.max) is in 29,228 A.D. and the maximum $(D SYSTEMTIME)
is in 30,827 A.D.
+/
SysTime SYSTEMTIMEToSysTime(const SYSTEMTIME* st, immutable TimeZone tz = LocalTime());
/++
$(BLUE This function is Windows-Only.)
Converts a $(D SysTime) to a $(D SYSTEMTIME) struct.
The $(D SYSTEMTIME) which is returned will be set using the given
$(D SysTime)'s time zone, so if you want the $(D SYSTEMTIME) to be in
UTC, set the $(D SysTime)'s time zone to UTC.
Params:
sysTime = The $(D SysTime) to convert.
Throws:
$(D DateTimeException) if the given $(D SysTime) will not fit in a
$(D SYSTEMTIME). This will only happen if the $(D SysTime)'s date is
prior to 1601 A.D.
+/
SYSTEMTIME SysTimeToSYSTEMTIME(in SysTime sysTime);
/++
$(BLUE This function is Windows-Only.)
Converts a $(D FILETIME) struct to a $(D SysTime).
Params:
ft = The $(D FILETIME) struct to convert.
tz = The time zone that the $(D SysTime) will be in ($(D FILETIME)s
are in UTC).
Throws:
$(D DateTimeException) if the given $(D FILETIME) will not fit in a
$(D SysTime) or if the $(D FILETIME) cannot be converted to a
$(D SYSTEMTIME).
+/
SysTime FILETIMEToSysTime(const FILETIME* ft, immutable TimeZone tz = LocalTime());
/++
$(BLUE This function is Windows-Only.)
Converts a $(D SysTime) to a $(D FILETIME) struct.
$(D FILETIME)s are always in UTC.
Params:
sysTime = The $(D SysTime) to convert.
Throws:
$(D DateTimeException) if the given $(D SysTime) will not fit in a
$(D FILETIME).
+/
FILETIME SysTimeToFILETIME(SysTime sysTime);
}
else version(Windows)
{
SysTime SYSTEMTIMEToSysTime(const SYSTEMTIME* st, immutable TimeZone tz = LocalTime())
{
const max = SysTime.max;
static void throwLaterThanMax()
{
throw new DateTimeException("The given SYSTEMTIME is for a date greater than SysTime.max.");
}
if(st.wYear > max.year)
throwLaterThanMax();
else if(st.wYear == max.year)
{
if(st.wMonth > max.month)
throwLaterThanMax();
else if(st.wMonth == max.month)
{
if(st.wDay > max.day)
throwLaterThanMax();
else if(st.wDay == max.day)
{
if(st.wHour > max.hour)
throwLaterThanMax();
else if(st.wHour == max.hour)
{
if(st.wMinute > max.minute)
throwLaterThanMax();
else if(st.wMinute == max.minute)
{
if(st.wSecond > max.second)
throwLaterThanMax();
else if(st.wSecond == max.second)
{
if(st.wMilliseconds > max.fracSec.msecs)
throwLaterThanMax();
}
}
}
}
}
}
auto dt = DateTime(st.wYear, st.wMonth, st.wDay,
st.wHour, st.wMinute, st.wSecond);
return SysTime(dt, FracSec.from!"msecs"(st.wMilliseconds), tz);
}
unittest
{
version(testStdDateTime)
{
auto sysTime = Clock.currTime(UTC());
SYSTEMTIME st = void;
GetSystemTime(&st);
auto converted = SYSTEMTIMEToSysTime(&st, UTC());
_assertPred!"<="(abs((converted - sysTime)),
dur!"seconds"(2));
}
}
SYSTEMTIME SysTimeToSYSTEMTIME(in SysTime sysTime)
{
immutable dt = cast(DateTime)sysTime;
if(dt.year < 1601)
throw new DateTimeException("SYSTEMTIME cannot hold dates prior to the year 1601.");
SYSTEMTIME st;
st.wYear = dt.year;
st.wMonth = dt.month;
st.wDayOfWeek = dt.dayOfWeek;
st.wDay = dt.day;
st.wHour = dt.hour;
st.wMinute = dt.minute;
st.wSecond = dt.second;
st.wMilliseconds = cast(ushort)sysTime.fracSec.msecs;
return st;
}
unittest
{
version(testStdDateTime)
{
SYSTEMTIME st = void;
GetSystemTime(&st);
auto sysTime = SYSTEMTIMEToSysTime(&st, UTC());
SYSTEMTIME result = SysTimeToSYSTEMTIME(sysTime);
_assertPred!"=="(st.wYear, result.wYear);
_assertPred!"=="(st.wMonth, result.wMonth);
_assertPred!"=="(st.wDayOfWeek, result.wDayOfWeek);
_assertPred!"=="(st.wDay, result.wDay);
_assertPred!"=="(st.wHour, result.wHour);
_assertPred!"=="(st.wMinute, result.wMinute);
_assertPred!"=="(st.wSecond, result.wSecond);
_assertPred!"=="(st.wMilliseconds, result.wMilliseconds);
}
}
SysTime FILETIMEToSysTime(const FILETIME* ft, immutable TimeZone tz = LocalTime())
{
SYSTEMTIME st = void;
if(!FileTimeToSystemTime(ft, &st))
throw new DateTimeException("FileTimeToSystemTime() failed.");
auto sysTime = SYSTEMTIMEToSysTime(&st, UTC());
sysTime.timezone = tz;
return sysTime;
}
unittest
{
version(testStdDateTime)
{
auto sysTime = Clock.currTime(UTC());
SYSTEMTIME st = void;
GetSystemTime(&st);
FILETIME ft = void;
SystemTimeToFileTime(&st, &ft);
auto converted = FILETIMEToSysTime(&ft);
_assertPred!"<="(abs((converted - sysTime)),
dur!"seconds"(2));
}
}
FILETIME SysTimeToFILETIME(SysTime sysTime)
{
SYSTEMTIME st = SysTimeToSYSTEMTIME(sysTime.toUTC());
FILETIME ft = void;
SystemTimeToFileTime(&st, &ft);
return ft;
}
unittest
{
version(testStdDateTime)
{
SYSTEMTIME st = void;
GetSystemTime(&st);
FILETIME ft = void;
SystemTimeToFileTime(&st, &ft);
auto sysTime = FILETIMEToSysTime(&ft, UTC());
FILETIME result = SysTimeToFILETIME(sysTime);
_assertPred!"=="(ft.dwLowDateTime, result.dwLowDateTime);
_assertPred!"=="(ft.dwHighDateTime, result.dwHighDateTime);
}
}
}
/++
Type representing the DOS file date/time format.
+/
typedef uint DosFileTime;
/++
Converts from DOS file date/time to $(D SysTime).
Params:
dft = The DOS file time to convert.
tz = The time zone which the DOS file time is assumed to be in.
Throws:
$(D DateTimeException) if the $(D DosFileTime) is invalid.
+/
SysTime DosFileTimeToSysTime(DosFileTime dft, immutable TimeZone tz = LocalTime())
{
uint dt = cast(uint)dft;
if(dt == 0)
throw new DateTimeException("Invalid DosFileTime.");
int year = ((dt >> 25) & 0x7F) + 1980;
int month = ((dt >> 21) & 0x0F); // 1..12
int dayOfMonth = ((dt >> 16) & 0x1F); // 1..31
int hour = (dt >> 11) & 0x1F; // 0..23
int minute = (dt >> 5) & 0x3F; // 0..59
int second = (dt << 1) & 0x3E; // 0..58 (in 2 second increments)
SysTime sysTime = void;
try
return SysTime(DateTime(year, month, dayOfMonth, hour, minute, second), tz);
catch(DateTimeException dte)
throw new DateTimeException("Invalid DosFileTime", __FILE__, __LINE__, dte);
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(DosFileTimeToSysTime(0b00000000001000010000000000000000),
SysTime(DateTime(1980, 1, 1, 0, 0, 0)));
_assertPred!"=="(DosFileTimeToSysTime(0b11111111100111111011111101111101),
SysTime(DateTime(2107, 12, 31, 23, 59, 58)));
_assertPred!"=="(DosFileTimeToSysTime(0x3E3F8456),
SysTime(DateTime(2011, 1, 31, 16, 34, 44)));
}
}
/++
Converts from $(D SysTime) to DOS file date/time.
Params:
sysTime = The $(D SysTime) to convert.
Throws:
$(D DateTimeException) if the given $(D SysTime) cannot be converted to
a $(D DosFileTime).
+/
DosFileTime SysTimeToDosFileTime(SysTime sysTime)
{
auto dateTime = cast(DateTime)sysTime;
if(dateTime.year < 1980)
throw new DateTimeException("DOS File Times cannot hold dates prior to 1980.");
if(dateTime.year > 2107)
throw new DateTimeException("DOS File Times cannot hold dates passed 2107.");
uint retval = 0;
retval = (dateTime.year - 1980) << 25;
retval |= (dateTime.month & 0x0F) << 21;
retval |= (dateTime.day & 0x1F) << 16;
retval |= (dateTime.hour & 0x1F) << 11;
retval |= (dateTime.minute & 0x3F) << 5;
retval |= (dateTime.second >> 1) & 0x1F;
return cast(DosFileTime)retval;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(SysTimeToDosFileTime(SysTime(DateTime(1980, 1, 1, 0, 0, 0))),
0b00000000001000010000000000000000);
_assertPred!"=="(SysTimeToDosFileTime(SysTime(DateTime(2107, 12, 31, 23, 59, 58))),
0b11111111100111111011111101111101);
_assertPred!"=="(SysTimeToDosFileTime(SysTime(DateTime(2011, 1, 31, 16, 34, 44))),
0x3E3F8456);
}
}
/++
Whether all of the given strings are valid units of time.
$(D "nsecs") is not considered a valid unit of time. Nothing in std.datetime
can handle precision greater than hnsecs, and the few functions in core.time
which deal with "nsecs" deal with it explicitly.
+/
bool validTimeUnits(string[] units...)
{
foreach(str; units)
{
if(!canFind(timeStrings.dup, str))
return false;
}
return true;
}
/++
Compares two time unit strings. $(D "years") are the largest units and
$(D "hnsecs") are the smallest.
Returns:
$(BOOKTABLE,
$(TR $(TD this < rhs) $(TD < 0))
$(TR $(TD this == rhs) $(TD 0))
$(TR $(TD this > rhs) $(TD > 0))
)
Throws:
$(D DateTimeException) if either of the given strings is not a valid
time unit string.
+/
int cmpTimeUnits(string lhs, string rhs)
{
auto tstrings = timeStrings.dup;
immutable indexOfLHS = std.algorithm.countUntil(tstrings, lhs);
immutable indexOfRHS = std.algorithm.countUntil(tstrings, rhs);
enforce(indexOfLHS != -1, format("%s is not a valid TimeString", lhs));
enforce(indexOfRHS != -1, format("%s is not a valid TimeString", rhs));
if(indexOfLHS < indexOfRHS)
return -1;
if(indexOfLHS > indexOfRHS)
return 1;
return 0;
}
unittest
{
version(testStdDateTime)
{
foreach(i, outerUnits; timeStrings)
{
_assertPred!"=="(cmpTimeUnits(outerUnits, outerUnits), 0);
//For some reason, $ won't compile.
foreach(innerUnits; timeStrings[i+1 .. timeStrings.length])
_assertPred!"=="(cmpTimeUnits(outerUnits, innerUnits), -1);
}
foreach(i, outerUnits; timeStrings)
{
foreach(innerUnits; timeStrings[0 .. i])
_assertPred!"=="(cmpTimeUnits(outerUnits, innerUnits), 1);
}
}
}
/++
Compares two time unit strings at compile time. $(D "years") are the largest
units and $(D "hnsecs") are the smallest.
This template is used instead of $(D cmpTimeUnits) because exceptions
can't be thrown at compile time and $(D cmpTimeUnits) must enforce that
the strings it's given are valid time unit strings. This template uses a
template constraint instead.
Returns:
$(BOOKTABLE,
$(TR $(TD this < rhs) $(TD < 0))
$(TR $(TD this == rhs) $(TD 0))
$(TR $(TD this > rhs) $(TD > 0))
)
+/
template CmpTimeUnits(string lhs, string rhs)
if(validTimeUnits(lhs, rhs))
{
enum CmpTimeUnits = cmpTimeUnitsCTFE(lhs, rhs);
}
/+
Helper function for $(D CmpTimeUnits).
+/
private int cmpTimeUnitsCTFE(string lhs, string rhs)
{
auto tstrings = timeStrings.dup;
immutable indexOfLHS = std.algorithm.countUntil(tstrings, lhs);
immutable indexOfRHS = std.algorithm.countUntil(tstrings, rhs);
if(indexOfLHS < indexOfRHS)
return -1;
if(indexOfLHS > indexOfRHS)
return 1;
return 0;
}
unittest
{
version(testStdDateTime)
{
static string genTest(size_t index)
{
auto currUnits = timeStrings[index];
auto test = `_assertPred!"=="(CmpTimeUnits!("` ~ currUnits ~ `", "` ~ currUnits ~ `"), 0); `;
//For some reason, $ won't compile.
foreach(units; timeStrings[index + 1 .. timeStrings.length])
test ~= `_assertPred!"=="(CmpTimeUnits!("` ~ currUnits ~ `", "` ~ units ~ `"), -1); `;
foreach(units; timeStrings[0 .. index])
test ~= `_assertPred!"=="(CmpTimeUnits!("` ~ currUnits ~ `", "` ~ units ~ `"), 1); `;
return test;
}
mixin(genTest(0));
mixin(genTest(1));
mixin(genTest(2));
mixin(genTest(3));
mixin(genTest(4));
mixin(genTest(5));
mixin(genTest(6));
mixin(genTest(7));
mixin(genTest(8));
mixin(genTest(9));
}
}
/++
Returns whether the given value is valid for the given unit type when in a
time point. Naturally, a duration is not held to a particular range, but
the values in a time point are (e.g. a month must be in the range of
1 - 12 inclusive).
Params:
units = The units of time to validate.
value = The number to validate.
Examples:
--------------------
assert(valid!"hours"(12));
assert(!valid!"hours"(32));
assert(valid!"months"(12));
assert(!valid!"months"(13));
--------------------
+/
bool valid(string units)(int value) pure nothrow
if(units == "months" ||
units == "hours" ||
units == "minutes" ||
units == "seconds")
{
static if(units == "months")
return value >= Month.jan && value <= Month.dec;
else static if(units == "hours")
return value >= 0 && value <= TimeOfDay.maxHour;
else static if(units == "minutes")
return value >= 0 && value <= TimeOfDay.maxMinute;
else static if(units == "seconds")
return value >= 0 && value <= TimeOfDay.maxSecond;
}
unittest
{
version(testStdDateTime)
{
//Verify Examples.
assert(valid!"hours"(12));
assert(!valid!"hours"(32));
assert(valid!"months"(12));
assert(!valid!"months"(13));
}
}
/++
Returns whether the given day is valid for the given year and month.
Params:
units = The units of time to validate.
year = The year of the day to validate.
month = The month of the day to validate.
day = The day to validate.
+/
bool valid(string units)(int year, int month, int day) pure nothrow
if(units == "days")
{
return day > 0 && day <= maxDay(year, month);
}
/++
Params:
units = The units of time to validate.
value = The number to validate.
file = The file that the $(D DateTimeException) will list if thrown.
line = The line number that the $(D DateTimeException) will list if
thrown.
Throws:
$(D DateTimeException) if $(D valid!units(value)) is false.
+/
void enforceValid(string units)(int value, string file = __FILE__, size_t line = __LINE__) pure
if(units == "months" ||
units == "hours" ||
units == "minutes" ||
units == "seconds")
{
static if(units == "months")
{
if(!valid!units(value))
throw new DateTimeException(numToString(value) ~ " is not a valid month of the year.", file, line);
}
else static if(units == "hours")
{
if(!valid!units(value))
throw new DateTimeException(numToString(value) ~ " is not a valid hour of the day.", file, line);
}
else static if(units == "minutes")
{
if(!valid!units(value))
throw new DateTimeException(numToString(value) ~ " is not a valid minute of an hour.", file, line);
}
else static if(units == "seconds")
{
if(!valid!units(value))
throw new DateTimeException(numToString(value) ~ " is not a valid second of a minute.", file, line);
}
}
/++
Params:
units = The units of time to validate.
year = The year of the day to validate.
month = The month of the day to validate.
day = The day to validate.
file = The file that the $(D DateTimeException) will list if thrown.
line = The line number that the $(D DateTimeException) will list if
thrown.
Throws:
$(D DateTimeException) if $(D valid!"days"(year, month, day)) is false.
+/
void enforceValid(string units)(int year, Month month, int day, string file = __FILE__, size_t line = __LINE__) pure
if(units == "days")
{
if(!valid!"days"(year, month, day))
{
throw new DateTimeException(numToString(day) ~
" is not a valid day in " ~
monthToString(month) ~
" in " ~
numToString(year), file, line);
}
}
/++
Returns the number of months from the current months of the year to the
given month of the year. If they are the same, then the result is 0.
Params:
currMonth = The current month of the year.
month = The month of the year to get the number of months to.
+/
static int monthsToMonth(int currMonth, int month) pure
{
enforceValid!"months"(currMonth);
enforceValid!"months"(month);
if(currMonth == month)
return 0;
if(currMonth < month)
return month - currMonth;
return (Month.dec - currMonth) + month;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(monthsToMonth(Month.jan, Month.jan), 0);
_assertPred!"=="(monthsToMonth(Month.jan, Month.feb), 1);
_assertPred!"=="(monthsToMonth(Month.jan, Month.mar), 2);
_assertPred!"=="(monthsToMonth(Month.jan, Month.apr), 3);
_assertPred!"=="(monthsToMonth(Month.jan, Month.may), 4);
_assertPred!"=="(monthsToMonth(Month.jan, Month.jun), 5);
_assertPred!"=="(monthsToMonth(Month.jan, Month.jul), 6);
_assertPred!"=="(monthsToMonth(Month.jan, Month.aug), 7);
_assertPred!"=="(monthsToMonth(Month.jan, Month.sep), 8);
_assertPred!"=="(monthsToMonth(Month.jan, Month.oct), 9);
_assertPred!"=="(monthsToMonth(Month.jan, Month.nov), 10);
_assertPred!"=="(monthsToMonth(Month.jan, Month.dec), 11);
_assertPred!"=="(monthsToMonth(Month.may, Month.jan), 8);
_assertPred!"=="(monthsToMonth(Month.may, Month.feb), 9);
_assertPred!"=="(monthsToMonth(Month.may, Month.mar), 10);
_assertPred!"=="(monthsToMonth(Month.may, Month.apr), 11);
_assertPred!"=="(monthsToMonth(Month.may, Month.may), 0);
_assertPred!"=="(monthsToMonth(Month.may, Month.jun), 1);
_assertPred!"=="(monthsToMonth(Month.may, Month.jul), 2);
_assertPred!"=="(monthsToMonth(Month.may, Month.aug), 3);
_assertPred!"=="(monthsToMonth(Month.may, Month.sep), 4);
_assertPred!"=="(monthsToMonth(Month.may, Month.oct), 5);
_assertPred!"=="(monthsToMonth(Month.may, Month.nov), 6);
_assertPred!"=="(monthsToMonth(Month.may, Month.dec), 7);
_assertPred!"=="(monthsToMonth(Month.oct, Month.jan), 3);
_assertPred!"=="(monthsToMonth(Month.oct, Month.feb), 4);
_assertPred!"=="(monthsToMonth(Month.oct, Month.mar), 5);
_assertPred!"=="(monthsToMonth(Month.oct, Month.apr), 6);
_assertPred!"=="(monthsToMonth(Month.oct, Month.may), 7);
_assertPred!"=="(monthsToMonth(Month.oct, Month.jun), 8);
_assertPred!"=="(monthsToMonth(Month.oct, Month.jul), 9);
_assertPred!"=="(monthsToMonth(Month.oct, Month.aug), 10);
_assertPred!"=="(monthsToMonth(Month.oct, Month.sep), 11);
_assertPred!"=="(monthsToMonth(Month.oct, Month.oct), 0);
_assertPred!"=="(monthsToMonth(Month.oct, Month.nov), 1);
_assertPred!"=="(monthsToMonth(Month.oct, Month.dec), 2);
_assertPred!"=="(monthsToMonth(Month.dec, Month.jan), 1);
_assertPred!"=="(monthsToMonth(Month.dec, Month.feb), 2);
_assertPred!"=="(monthsToMonth(Month.dec, Month.mar), 3);
_assertPred!"=="(monthsToMonth(Month.dec, Month.apr), 4);
_assertPred!"=="(monthsToMonth(Month.dec, Month.may), 5);
_assertPred!"=="(monthsToMonth(Month.dec, Month.jun), 6);
_assertPred!"=="(monthsToMonth(Month.dec, Month.jul), 7);
_assertPred!"=="(monthsToMonth(Month.dec, Month.aug), 8);
_assertPred!"=="(monthsToMonth(Month.dec, Month.sep), 9);
_assertPred!"=="(monthsToMonth(Month.dec, Month.oct), 10);
_assertPred!"=="(monthsToMonth(Month.dec, Month.nov), 11);
_assertPred!"=="(monthsToMonth(Month.dec, Month.dec), 0);
}
}
/++
Returns the number of days from the current day of the week to the given
day of the week. If they are the same, then the result is 0.
Params:
currDoW = The current day of the week.
dow = The day of the week to get the number of days to.
+/
static int daysToDayOfWeek(DayOfWeek currDoW, DayOfWeek dow) pure nothrow
{
if(currDoW == dow)
return 0;
if(currDoW < dow)
return dow - currDoW;
return (DayOfWeek.sat - currDoW) + dow + 1;
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.sun, DayOfWeek.sun), 0);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.sun, DayOfWeek.mon), 1);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.sun, DayOfWeek.tue), 2);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.sun, DayOfWeek.wed), 3);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.sun, DayOfWeek.thu), 4);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.sun, DayOfWeek.fri), 5);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.sun, DayOfWeek.sat), 6);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.mon, DayOfWeek.sun), 6);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.mon, DayOfWeek.mon), 0);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.mon, DayOfWeek.tue), 1);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.mon, DayOfWeek.wed), 2);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.mon, DayOfWeek.thu), 3);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.mon, DayOfWeek.fri), 4);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.mon, DayOfWeek.sat), 5);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.tue, DayOfWeek.sun), 5);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.tue, DayOfWeek.mon), 6);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.tue, DayOfWeek.tue), 0);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.tue, DayOfWeek.wed), 1);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.tue, DayOfWeek.thu), 2);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.tue, DayOfWeek.fri), 3);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.tue, DayOfWeek.sat), 4);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.wed, DayOfWeek.sun), 4);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.wed, DayOfWeek.mon), 5);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.wed, DayOfWeek.tue), 6);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.wed, DayOfWeek.wed), 0);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.wed, DayOfWeek.thu), 1);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.wed, DayOfWeek.fri), 2);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.wed, DayOfWeek.sat), 3);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.thu, DayOfWeek.sun), 3);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.thu, DayOfWeek.mon), 4);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.thu, DayOfWeek.tue), 5);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.thu, DayOfWeek.wed), 6);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.thu, DayOfWeek.thu), 0);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.thu, DayOfWeek.fri), 1);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.thu, DayOfWeek.sat), 2);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.fri, DayOfWeek.sun), 2);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.fri, DayOfWeek.mon), 3);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.fri, DayOfWeek.tue), 4);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.fri, DayOfWeek.wed), 5);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.fri, DayOfWeek.thu), 6);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.fri, DayOfWeek.fri), 0);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.fri, DayOfWeek.sat), 1);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.sat, DayOfWeek.sun), 1);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.sat, DayOfWeek.mon), 2);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.sat, DayOfWeek.tue), 3);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.sat, DayOfWeek.wed), 4);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.sat, DayOfWeek.thu), 5);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.sat, DayOfWeek.fri), 6);
_assertPred!"=="(daysToDayOfWeek(DayOfWeek.sat, DayOfWeek.sat), 0);
}
}
version(StdDdoc)
{
/++
Function for starting to a stop watch time when the function is called
and stopping it when its return value goes out of scope and is destroyed.
When the value that is returned by this function is destroyed,
$(D func) will run. $(D func) is a unary function that takes a
$(CXREF TickDuration).
Examples:
--------------------
writeln("benchmark start!");
{
auto mt = measureTime!((a){assert(a.seconds);});
doSomething();
}
writeln("benchmark end!");
--------------------
+/
auto measureTime(alias func)();
}
else
{
@safe auto measureTime(alias func)()
if(isSafe!func)
{
struct Result
{
private StopWatch _sw = void;
this(AutoStart as)
{
_sw = StopWatch(as);
}
~this()
{
unaryFun!(func)(_sw.peek());
}
}
return Result(AutoStart.yes);
}
auto measureTime(alias func)()
if(!isSafe!func)
{
struct Result
{
private StopWatch _sw = void;
this(AutoStart as)
{
_sw = StopWatch(as);
}
~this()
{
unaryFun!(func)(_sw.peek());
}
}
return Result(AutoStart.yes);
}
}
version(testStdDateTime) @safe unittest
{
@safe static void func(TickDuration td)
{
assert(td.to!("seconds", real) <>= 0);
}
auto mt = measureTime!(func)();
/+
with (measureTime!((a){assert(a.seconds);}))
{
// doSomething();
// @@@BUG@@@ doesn't work yet.
}
+/
}
version(testStdDateTime) unittest
{
static void func(TickDuration td)
{
assert(td.to!("seconds", real) <>= 0);
}
auto mt = measureTime!(func)();
/+
with (measureTime!((a){assert(a.seconds);}))
{
// doSomething();
// @@@BUG@@@ doesn't work yet.
}
+/
}
//==============================================================================
// Private Section.
//==============================================================================
private:
//==============================================================================
// Section with private enums and constants.
//==============================================================================
enum daysInYear = 365; /// The number of days in a non-leap year.
enum daysInLeapYear = 366; /// The numbef or days in a leap year.
enum daysIn4Years = daysInYear * 3 + daysInLeapYear; /// Number of days in 4 years.
enum daysIn100Years = daysIn4Years * 25 - 1; /// The number of days in 100 years.
enum daysIn400Years = daysIn100Years * 4 + 1; /// The number of days in 400 years.
//==============================================================================
// Section with private helper functions and templates.
//==============================================================================
/+
Template to help with converting between time units.
+/
template hnsecsPer(string units)
if(CmpTimeUnits!(units, "months") < 0)
{
static if(units == "hnsecs")
enum hnsecsPer = 1L;
else static if(units == "usecs")
enum hnsecsPer = 10L;
else static if(units == "msecs")
enum hnsecsPer = 1000 * hnsecsPer!"usecs";
else static if(units == "seconds")
enum hnsecsPer = 1000 * hnsecsPer!"msecs";
else static if(units == "minutes")
enum hnsecsPer = 60 * hnsecsPer!"seconds";
else static if(units == "hours")
enum hnsecsPer = 60 * hnsecsPer!"minutes";
else static if(units == "days")
enum hnsecsPer = 24 * hnsecsPer!"hours";
else static if(units == "weeks")
enum hnsecsPer = 7 * hnsecsPer!"days";
}
/+
Splits out a particular unit from hnsecs and gives you the value for that
unit and the remaining hnsecs. It really shouldn't be used unless unless
all units larger than the given units have already been split out.
Params:
units = The units to split out.
hnsecs = The current total hnsecs. Upon returning, it is the hnsecs left
after splitting out the given units.
Returns:
The number of the given units from converting hnsecs to those units.
Examples:
--------------------
auto hnsecs = 2595000000007L;
immutable days = splitUnitsFromHNSecs!"days"(hnsecs);
assert(days == 3);
assert(hnsecs == 3000000007);
immutable minutes = splitUnitsFromHNSecs!"minutes"(hnsecs);
assert(minutes == 5);
assert(hnsecs == 7);
--------------------
+/
long splitUnitsFromHNSecs(string units)(ref long hnsecs) pure nothrow
if(validTimeUnits(units) &&
CmpTimeUnits!(units, "months") < 0)
{
immutable value = convert!("hnsecs", units)(hnsecs);
hnsecs -= convert!(units, "hnsecs")(value);
return value;
}
unittest
{
version(testStdDateTime)
{
//Verify Example.
auto hnsecs = 2595000000007L;
immutable days = splitUnitsFromHNSecs!"days"(hnsecs);
assert(days == 3);
assert(hnsecs == 3000000007);
immutable minutes = splitUnitsFromHNSecs!"minutes"(hnsecs);
assert(minutes == 5);
assert(hnsecs == 7);
}
}
/+
This function is used to split out the units without getting the remaining
hnsecs.
See_Also:
splitUnitsFromHNSecs()
Params:
units = The units to split out.
hnsecs = The current total hnsecs.
Returns:
The split out value.
Examples:
--------------------
auto hnsecs = 2595000000007L;
immutable days = getUnitsFromHNSecs!"days"(hnsecs);
assert(days == 3);
assert(hnsecs == 2595000000007L);
--------------------
+/
long getUnitsFromHNSecs(string units)(long hnsecs) pure nothrow
if(validTimeUnits(units) &&
CmpTimeUnits!(units, "months") < 0)
{
return convert!("hnsecs", units)(hnsecs);
}
unittest
{
version(testStdDateTime)
{
//Verify Example.
auto hnsecs = 2595000000007L;
immutable days = getUnitsFromHNSecs!"days"(hnsecs);
assert(days == 3);
assert(hnsecs == 2595000000007L);
}
}
/+
This function is used to split out the units without getting the units but
just the remaining hnsecs.
See_Also:
splitUnitsFromHNSecs()
Params:
units = The units to split out.
hnsecs = The current total hnsecs.
Returns:
The remaining hnsecs.
Examples:
--------------------
auto hnsecs = 2595000000007L;
auto returned = removeUnitsFromHNSecs!"days"(hnsecs);
assert(returned == 3000000007);
assert(hnsecs == 2595000000007L);
--------------------
+/
long removeUnitsFromHNSecs(string units)(long hnsecs) pure nothrow
if(validTimeUnits(units) &&
CmpTimeUnits!(units, "months") < 0)
{
immutable value = convert!("hnsecs", units)(hnsecs);
return hnsecs - convert!(units, "hnsecs")(value);
}
unittest
{
version(testStdDateTime)
{
//Verify Example.
auto hnsecs = 2595000000007L;
auto returned = removeUnitsFromHNSecs!"days"(hnsecs);
assert(returned == 3000000007);
assert(hnsecs == 2595000000007L);
}
}
/+
The maximum valid Day in the given month in the given year.
Params:
year = The year to get the day for.
month = The month of the Gregorian Calendar to get the day for.
+/
static ubyte maxDay(int year, int month) pure nothrow
in
{
assert(valid!"months"(month));
}
body
{
switch(month)
{
case Month.jan, Month.mar, Month.may, Month.jul, Month.aug, Month.oct, Month.dec:
return 31;
case Month.feb:
return yearIsLeapYear(year) ? 29 : 28;
case Month.apr, Month.jun, Month.sep, Month.nov:
return 30;
default:
assert(0, "Invalid month.");
}
}
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(maxDay(1999, 1), 31);
_assertPred!"=="(maxDay(1999, 2), 28);
_assertPred!"=="(maxDay(1999, 3), 31);
_assertPred!"=="(maxDay(1999, 4), 30);
_assertPred!"=="(maxDay(1999, 5), 31);
_assertPred!"=="(maxDay(1999, 6), 30);
_assertPred!"=="(maxDay(1999, 7), 31);
_assertPred!"=="(maxDay(1999, 8), 31);
_assertPred!"=="(maxDay(1999, 9), 30);
_assertPred!"=="(maxDay(1999, 10), 31);
_assertPred!"=="(maxDay(1999, 11), 30);
_assertPred!"=="(maxDay(1999, 12), 31);
_assertPred!"=="(maxDay(2000, 1), 31);
_assertPred!"=="(maxDay(2000, 2), 29);
_assertPred!"=="(maxDay(2000, 3), 31);
_assertPred!"=="(maxDay(2000, 4), 30);
_assertPred!"=="(maxDay(2000, 5), 31);
_assertPred!"=="(maxDay(2000, 6), 30);
_assertPred!"=="(maxDay(2000, 7), 31);
_assertPred!"=="(maxDay(2000, 8), 31);
_assertPred!"=="(maxDay(2000, 9), 30);
_assertPred!"=="(maxDay(2000, 10), 31);
_assertPred!"=="(maxDay(2000, 11), 30);
_assertPred!"=="(maxDay(2000, 12), 31);
//Test B.C.
_assertPred!"=="(maxDay(-1999, 1), 31);
_assertPred!"=="(maxDay(-1999, 2), 28);
_assertPred!"=="(maxDay(-1999, 3), 31);
_assertPred!"=="(maxDay(-1999, 4), 30);
_assertPred!"=="(maxDay(-1999, 5), 31);
_assertPred!"=="(maxDay(-1999, 6), 30);
_assertPred!"=="(maxDay(-1999, 7), 31);
_assertPred!"=="(maxDay(-1999, 8), 31);
_assertPred!"=="(maxDay(-1999, 9), 30);
_assertPred!"=="(maxDay(-1999, 10), 31);
_assertPred!"=="(maxDay(-1999, 11), 30);
_assertPred!"=="(maxDay(-1999, 12), 31);
_assertPred!"=="(maxDay(-2000, 1), 31);
_assertPred!"=="(maxDay(-2000, 2), 29);
_assertPred!"=="(maxDay(-2000, 3), 31);
_assertPred!"=="(maxDay(-2000, 4), 30);
_assertPred!"=="(maxDay(-2000, 5), 31);
_assertPred!"=="(maxDay(-2000, 6), 30);
_assertPred!"=="(maxDay(-2000, 7), 31);
_assertPred!"=="(maxDay(-2000, 8), 31);
_assertPred!"=="(maxDay(-2000, 9), 30);
_assertPred!"=="(maxDay(-2000, 10), 31);
_assertPred!"=="(maxDay(-2000, 11), 30);
_assertPred!"=="(maxDay(-2000, 12), 31);
}
}
/+
Returns the day of the week for the given day of the Gregorian Calendar.
Params:
day = The day of the Gregorian Calendar for which to get the day of
the week.
+/
DayOfWeek getDayOfWeek(int day) pure nothrow
{
//January 1st, 1 A.D. was a Monday
if(day >= 0)
return cast(DayOfWeek)(day % 7);
else
{
immutable dow = cast(DayOfWeek)((day % 7) + 7);
if(dow == 7)
return DayOfWeek.sun;
else
return dow;
}
}
unittest
{
version(testStdDateTime)
{
//Test A.D.
_assertPred!"=="(getDayOfWeek(SysTime(Date(1, 1, 1)).dayOfGregorianCal), DayOfWeek.mon);
_assertPred!"=="(getDayOfWeek(SysTime(Date(1, 1, 2)).dayOfGregorianCal), DayOfWeek.tue);
_assertPred!"=="(getDayOfWeek(SysTime(Date(1, 1, 3)).dayOfGregorianCal), DayOfWeek.wed);
_assertPred!"=="(getDayOfWeek(SysTime(Date(1, 1, 4)).dayOfGregorianCal), DayOfWeek.thu);
_assertPred!"=="(getDayOfWeek(SysTime(Date(1, 1, 5)).dayOfGregorianCal), DayOfWeek.fri);
_assertPred!"=="(getDayOfWeek(SysTime(Date(1, 1, 6)).dayOfGregorianCal), DayOfWeek.sat);
_assertPred!"=="(getDayOfWeek(SysTime(Date(1, 1, 7)).dayOfGregorianCal), DayOfWeek.sun);
_assertPred!"=="(getDayOfWeek(SysTime(Date(1, 1, 8)).dayOfGregorianCal), DayOfWeek.mon);
_assertPred!"=="(getDayOfWeek(SysTime(Date(1, 1, 9)).dayOfGregorianCal), DayOfWeek.tue);
_assertPred!"=="(getDayOfWeek(SysTime(Date(2, 1, 1)).dayOfGregorianCal), DayOfWeek.tue);
_assertPred!"=="(getDayOfWeek(SysTime(Date(3, 1, 1)).dayOfGregorianCal), DayOfWeek.wed);
_assertPred!"=="(getDayOfWeek(SysTime(Date(4, 1, 1)).dayOfGregorianCal), DayOfWeek.thu);
_assertPred!"=="(getDayOfWeek(SysTime(Date(5, 1, 1)).dayOfGregorianCal), DayOfWeek.sat);
_assertPred!"=="(getDayOfWeek(SysTime(Date(2000, 1, 1)).dayOfGregorianCal), DayOfWeek.sat);
_assertPred!"=="(getDayOfWeek(SysTime(Date(2010, 8, 22)).dayOfGregorianCal), DayOfWeek.sun);
_assertPred!"=="(getDayOfWeek(SysTime(Date(2010, 8, 23)).dayOfGregorianCal), DayOfWeek.mon);
_assertPred!"=="(getDayOfWeek(SysTime(Date(2010, 8, 24)).dayOfGregorianCal), DayOfWeek.tue);
_assertPred!"=="(getDayOfWeek(SysTime(Date(2010, 8, 25)).dayOfGregorianCal), DayOfWeek.wed);
_assertPred!"=="(getDayOfWeek(SysTime(Date(2010, 8, 26)).dayOfGregorianCal), DayOfWeek.thu);
_assertPred!"=="(getDayOfWeek(SysTime(Date(2010, 8, 27)).dayOfGregorianCal), DayOfWeek.fri);
_assertPred!"=="(getDayOfWeek(SysTime(Date(2010, 8, 28)).dayOfGregorianCal), DayOfWeek.sat);
_assertPred!"=="(getDayOfWeek(SysTime(Date(2010, 8, 29)).dayOfGregorianCal), DayOfWeek.sun);
//Test B.C.
_assertPred!"=="(getDayOfWeek(SysTime(Date(0, 12, 31)).dayOfGregorianCal), DayOfWeek.sun);
_assertPred!"=="(getDayOfWeek(SysTime(Date(0, 12, 30)).dayOfGregorianCal), DayOfWeek.sat);
_assertPred!"=="(getDayOfWeek(SysTime(Date(0, 12, 29)).dayOfGregorianCal), DayOfWeek.fri);
_assertPred!"=="(getDayOfWeek(SysTime(Date(0, 12, 28)).dayOfGregorianCal), DayOfWeek.thu);
_assertPred!"=="(getDayOfWeek(SysTime(Date(0, 12, 27)).dayOfGregorianCal), DayOfWeek.wed);
_assertPred!"=="(getDayOfWeek(SysTime(Date(0, 12, 26)).dayOfGregorianCal), DayOfWeek.tue);
_assertPred!"=="(getDayOfWeek(SysTime(Date(0, 12, 25)).dayOfGregorianCal), DayOfWeek.mon);
_assertPred!"=="(getDayOfWeek(SysTime(Date(0, 12, 24)).dayOfGregorianCal), DayOfWeek.sun);
_assertPred!"=="(getDayOfWeek(SysTime(Date(0, 12, 23)).dayOfGregorianCal), DayOfWeek.sat);
}
}
/+
Returns the string representation of the given month.
Params:
useLongName = Whether the long or short version of the month name should
be used.
plural = Whether the string should be plural or not.
Throws:
$(D DateTimeException) if the given month is not a valid month.
+/
string monthToString(Month month, bool useLongName = true) pure
{
if(useLongName == true)
{
switch(month)
{
case Month.jan:
return "January";
case Month.feb:
return "February";
case Month.mar:
return "March";
case Month.apr:
return "April";
case Month.may:
return "May";
case Month.jun:
return "June";
case Month.jul:
return "July";
case Month.aug:
return "August";
case Month.sep:
return "September";
case Month.oct:
return "October";
case Month.nov:
return "November";
case Month.dec:
return "December";
default:
throw new DateTimeException("Invalid month: " ~ numToString(month));
}
}
else
{
switch(month)
{
case Month.jan:
return "Jan";
case Month.feb:
return "Feb";
case Month.mar:
return "Mar";
case Month.apr:
return "Apr";
case Month.may:
return "May";
case Month.jun:
return "Jun";
case Month.jul:
return "Jul";
case Month.aug:
return "Aug";
case Month.sep:
return "Sep";
case Month.oct:
return "Oct";
case Month.nov:
return "Nov";
case Month.dec:
return "Dec";
default:
throw new DateTimeException("Invalid month: " ~ numToString(month));
}
}
}
unittest
{
version(testStdDateTime)
{
static void testMTSInvalid(Month month, bool useLongName)
{
monthToString(month, useLongName);
}
assertThrown!DateTimeException(testMTSInvalid(cast(Month)0, true));
assertThrown!DateTimeException(testMTSInvalid(cast(Month)0, false));
assertThrown!DateTimeException(testMTSInvalid(cast(Month)13, true));
assertThrown!DateTimeException(testMTSInvalid(cast(Month)13, false));
_assertPred!"=="(monthToString(Month.jan), "January");
_assertPred!"=="(monthToString(Month.feb), "February");
_assertPred!"=="(monthToString(Month.mar), "March");
_assertPred!"=="(monthToString(Month.apr), "April");
_assertPred!"=="(monthToString(Month.may), "May");
_assertPred!"=="(monthToString(Month.jun), "June");
_assertPred!"=="(monthToString(Month.jul), "July");
_assertPred!"=="(monthToString(Month.aug), "August");
_assertPred!"=="(monthToString(Month.sep), "September");
_assertPred!"=="(monthToString(Month.oct), "October");
_assertPred!"=="(monthToString(Month.nov), "November");
_assertPred!"=="(monthToString(Month.dec), "December");
_assertPred!"=="(monthToString(Month.jan, false), "Jan");
_assertPred!"=="(monthToString(Month.feb, false), "Feb");
_assertPred!"=="(monthToString(Month.mar, false), "Mar");
_assertPred!"=="(monthToString(Month.apr, false), "Apr");
_assertPred!"=="(monthToString(Month.may, false), "May");
_assertPred!"=="(monthToString(Month.jun, false), "Jun");
_assertPred!"=="(monthToString(Month.jul, false), "Jul");
_assertPred!"=="(monthToString(Month.aug, false), "Aug");
_assertPred!"=="(monthToString(Month.sep, false), "Sep");
_assertPred!"=="(monthToString(Month.oct, false), "Oct");
_assertPred!"=="(monthToString(Month.nov, false), "Nov");
_assertPred!"=="(monthToString(Month.dec, false), "Dec");
}
}
/+
Returns the Month corresponding to the given string. Casing is ignored.
Params:
monthStr = The string representation of the month to get the Month for.
Throws:
$(D DateTimeException) if the given month is not a valid month string.
+/
Month monthFromString(string monthStr)
{
switch(toLower(monthStr))
{
case "january":
case "jan":
return Month.jan;
case "february":
case "feb":
return Month.feb;
case "march":
case "mar":
return Month.mar;
case "april":
case "apr":
return Month.apr;
case "may":
return Month.may;
case "june":
case "jun":
return Month.jun;
case "july":
case "jul":
return Month.jul;
case "august":
case "aug":
return Month.aug;
case "september":
case "sep":
return Month.sep;
case "october":
case "oct":
return Month.oct;
case "november":
case "nov":
return Month.nov;
case "december":
case "dec":
return Month.dec;
default:
throw new DateTimeException(format("Invalid month %s", monthStr));
}
}
unittest
{
version(testStdDateTime)
{
static void testMFSInvalid(string monthStr)
{
monthFromString(monthStr);
}
assertThrown!DateTimeException(testMFSInvalid("Ja"));
assertThrown!DateTimeException(testMFSInvalid("Janu"));
assertThrown!DateTimeException(testMFSInvalid("Januar"));
assertThrown!DateTimeException(testMFSInvalid("Januarys"));
assertThrown!DateTimeException(testMFSInvalid("JJanuary"));
_assertPred!"=="(monthFromString(monthToString(Month.jan)), Month.jan);
_assertPred!"=="(monthFromString(monthToString(Month.feb)), Month.feb);
_assertPred!"=="(monthFromString(monthToString(Month.mar)), Month.mar);
_assertPred!"=="(monthFromString(monthToString(Month.apr)), Month.apr);
_assertPred!"=="(monthFromString(monthToString(Month.may)), Month.may);
_assertPred!"=="(monthFromString(monthToString(Month.jun)), Month.jun);
_assertPred!"=="(monthFromString(monthToString(Month.jul)), Month.jul);
_assertPred!"=="(monthFromString(monthToString(Month.aug)), Month.aug);
_assertPred!"=="(monthFromString(monthToString(Month.sep)), Month.sep);
_assertPred!"=="(monthFromString(monthToString(Month.oct)), Month.oct);
_assertPred!"=="(monthFromString(monthToString(Month.nov)), Month.nov);
_assertPred!"=="(monthFromString(monthToString(Month.dec)), Month.dec);
_assertPred!"=="(monthFromString(monthToString(Month.jan, false)), Month.jan);
_assertPred!"=="(monthFromString(monthToString(Month.feb, false)), Month.feb);
_assertPred!"=="(monthFromString(monthToString(Month.mar, false)), Month.mar);
_assertPred!"=="(monthFromString(monthToString(Month.apr, false)), Month.apr);
_assertPred!"=="(monthFromString(monthToString(Month.may, false)), Month.may);
_assertPred!"=="(monthFromString(monthToString(Month.jun, false)), Month.jun);
_assertPred!"=="(monthFromString(monthToString(Month.jul, false)), Month.jul);
_assertPred!"=="(monthFromString(monthToString(Month.aug, false)), Month.aug);
_assertPred!"=="(monthFromString(monthToString(Month.sep, false)), Month.sep);
_assertPred!"=="(monthFromString(monthToString(Month.oct, false)), Month.oct);
_assertPred!"=="(monthFromString(monthToString(Month.nov, false)), Month.nov);
_assertPred!"=="(monthFromString(monthToString(Month.dec, false)), Month.dec);
_assertPred!"=="(monthFromString("JANUARY"), Month.jan);
_assertPred!"=="(monthFromString("JAN"), Month.jan);
_assertPred!"=="(monthFromString("january"), Month.jan);
_assertPred!"=="(monthFromString("jan"), Month.jan);
_assertPred!"=="(monthFromString("jaNuary"), Month.jan);
_assertPred!"=="(monthFromString("jaN"), Month.jan);
_assertPred!"=="(monthFromString("jaNuaRy"), Month.jan);
_assertPred!"=="(monthFromString("jAn"), Month.jan);
}
}
/+
The time units which are one step smaller than the given units.
Examples:
--------------------
assert(nextSmallerTimeUnits!"years" == "months");
assert(nextSmallerTimeUnits!"usecs" == "hnsecs");
--------------------
+/
template nextSmallerTimeUnits(string units)
if(validTimeUnits(units) &&
timeStrings.front != units)
{
enum nextSmallerTimeUnits = timeStrings[std.algorithm.countUntil(timeStrings.dup, units) - 1];
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(nextSmallerTimeUnits!"months", "weeks");
_assertPred!"=="(nextSmallerTimeUnits!"weeks", "days");
_assertPred!"=="(nextSmallerTimeUnits!"days", "hours");
_assertPred!"=="(nextSmallerTimeUnits!"hours", "minutes");
_assertPred!"=="(nextSmallerTimeUnits!"minutes", "seconds");
_assertPred!"=="(nextSmallerTimeUnits!"seconds", "msecs");
_assertPred!"=="(nextSmallerTimeUnits!"msecs", "usecs");
static assert(!__traits(compiles, nextSmallerTimeUnits!"hnsecs"));
//Verify Examples.
assert(nextSmallerTimeUnits!"years" == "months");
assert(nextSmallerTimeUnits!"usecs" == "hnsecs");
}
}
/+
The time units which are one step larger than the given units.
Examples:
--------------------
assert(nextLargerTimeUnits!"months" == "years");
assert(nextLargerTimeUnits!"hnsecs" == "usecs");
--------------------
+/
template nextLargerTimeUnits(string units)
if(validTimeUnits(units) &&
timeStrings.back != units)
{
enum nextLargerTimeUnits = timeStrings[std.algorithm.countUntil(timeStrings.dup, units) + 1];
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(nextLargerTimeUnits!"usecs", "msecs");
_assertPred!"=="(nextLargerTimeUnits!"msecs", "seconds");
_assertPred!"=="(nextLargerTimeUnits!"seconds", "minutes");
_assertPred!"=="(nextLargerTimeUnits!"minutes", "hours");
_assertPred!"=="(nextLargerTimeUnits!"hours", "days");
_assertPred!"=="(nextLargerTimeUnits!"days", "weeks");
_assertPred!"=="(nextLargerTimeUnits!"weeks", "months");
static assert(!__traits(compiles, nextLargerTimeUnits!"years"));
//Verify Examples.
assert(nextLargerTimeUnits!"months" == "years");
assert(nextLargerTimeUnits!"hnsecs" == "usecs");
}
}
/+
Returns the given hnsecs as an ISO string of fractional seconds.
+/
static string fracSecToISOString(int hnsecs) nothrow
in
{
assert(hnsecs >= 0);
}
body
{
try
{
string isoString = format(".%07d", hnsecs);
while(isoString.endsWith("0"))
isoString.popBack();
if(isoString.length == 1)
return "";
return isoString;
}
catch(Exception e)
assert(0, "format() threw.");
}
unittest
{
version(testStdDateTime)
{
_assertPred!"=="(fracSecToISOString(0), "");
_assertPred!"=="(fracSecToISOString(1), ".0000001");
_assertPred!"=="(fracSecToISOString(10), ".000001");
_assertPred!"=="(fracSecToISOString(100), ".00001");
_assertPred!"=="(fracSecToISOString(1000), ".0001");
_assertPred!"=="(fracSecToISOString(10_000), ".001");
_assertPred!"=="(fracSecToISOString(100_000), ".01");
_assertPred!"=="(fracSecToISOString(1_000_000), ".1");
_assertPred!"=="(fracSecToISOString(1_000_001), ".1000001");
_assertPred!"=="(fracSecToISOString(1_001_001), ".1001001");
_assertPred!"=="(fracSecToISOString(1_071_601), ".1071601");
_assertPred!"=="(fracSecToISOString(1_271_641), ".1271641");
_assertPred!"=="(fracSecToISOString(9_999_999), ".9999999");
_assertPred!"=="(fracSecToISOString(9_999_990), ".999999");
_assertPred!"=="(fracSecToISOString(9_999_900), ".99999");
_assertPred!"=="(fracSecToISOString(9_999_000), ".9999");
_assertPred!"=="(fracSecToISOString(9_990_000), ".999");
_assertPred!"=="(fracSecToISOString(9_900_000), ".99");
_assertPred!"=="(fracSecToISOString(9_000_000), ".9");
_assertPred!"=="(fracSecToISOString(999), ".0000999");
_assertPred!"=="(fracSecToISOString(9990), ".000999");
_assertPred!"=="(fracSecToISOString(99_900), ".00999");
_assertPred!"=="(fracSecToISOString(999_000), ".0999");
}
}
/+
Returns a FracSec corresponding to to the given ISO string of
fractional seconds.
+/
static FracSec fracSecFromISOString(S)(in S isoString)
if(isSomeString!S)
{
if(isoString.empty)
return FracSec.from!"hnsecs"(0);
auto dstr = to!dstring(isoString);
enforce(dstr.startsWith("."), new DateTimeException("Invalid ISO String"));
dstr.popFront();
enforce(!dstr.empty && dstr.length <= 7, new DateTimeException("Invalid ISO String"));
enforce(!canFind!(not!isDigit)(dstr), new DateTimeException("Invalid ISO String"));
dchar[7] fullISOString;
foreach(i, ref dchar c; fullISOString)
{
if(i < dstr.length)
c = dstr[i];
else
c = '0';
}
return FracSec.from!"hnsecs"(to!int(fullISOString[]));
}
unittest
{
version(testStdDateTime)
{
static void testFSInvalid(string isoString)
{
fracSecFromISOString(isoString);
}
assertThrown!DateTimeException(testFSInvalid("."));
assertThrown!DateTimeException(testFSInvalid("0."));
assertThrown!DateTimeException(testFSInvalid("0"));
assertThrown!DateTimeException(testFSInvalid("0000000"));
assertThrown!DateTimeException(testFSInvalid(".00000000"));
assertThrown!DateTimeException(testFSInvalid(".00000001"));
assertThrown!DateTimeException(testFSInvalid("T"));
assertThrown!DateTimeException(testFSInvalid("T."));
assertThrown!DateTimeException(testFSInvalid(".T"));
_assertPred!"=="(fracSecFromISOString(""), FracSec.from!"hnsecs"(0));
_assertPred!"=="(fracSecFromISOString(".0000001"), FracSec.from!"hnsecs"(1));
_assertPred!"=="(fracSecFromISOString(".000001"), FracSec.from!"hnsecs"(10));
_assertPred!"=="(fracSecFromISOString(".00001"), FracSec.from!"hnsecs"(100));
_assertPred!"=="(fracSecFromISOString(".0001"), FracSec.from!"hnsecs"(1000));
_assertPred!"=="(fracSecFromISOString(".001"), FracSec.from!"hnsecs"(10_000));
_assertPred!"=="(fracSecFromISOString(".01"), FracSec.from!"hnsecs"(100_000));
_assertPred!"=="(fracSecFromISOString(".1"), FracSec.from!"hnsecs"(1_000_000));
_assertPred!"=="(fracSecFromISOString(".1000001"), FracSec.from!"hnsecs"(1_000_001));
_assertPred!"=="(fracSecFromISOString(".1001001"), FracSec.from!"hnsecs"(1_001_001));
_assertPred!"=="(fracSecFromISOString(".1071601"), FracSec.from!"hnsecs"(1_071_601));
_assertPred!"=="(fracSecFromISOString(".1271641"), FracSec.from!"hnsecs"(1_271_641));
_assertPred!"=="(fracSecFromISOString(".9999999"), FracSec.from!"hnsecs"(9_999_999));
_assertPred!"=="(fracSecFromISOString(".9999990"), FracSec.from!"hnsecs"(9_999_990));
_assertPred!"=="(fracSecFromISOString(".999999"), FracSec.from!"hnsecs"(9_999_990));
_assertPred!"=="(fracSecFromISOString(".9999900"), FracSec.from!"hnsecs"(9_999_900));
_assertPred!"=="(fracSecFromISOString(".99999"), FracSec.from!"hnsecs"(9_999_900));
_assertPred!"=="(fracSecFromISOString(".9999000"), FracSec.from!"hnsecs"(9_999_000));
_assertPred!"=="(fracSecFromISOString(".9999"), FracSec.from!"hnsecs"(9_999_000));
_assertPred!"=="(fracSecFromISOString(".9990000"), FracSec.from!"hnsecs"(9_990_000));
_assertPred!"=="(fracSecFromISOString(".999"), FracSec.from!"hnsecs"(9_990_000));
_assertPred!"=="(fracSecFromISOString(".9900000"), FracSec.from!"hnsecs"(9_900_000));
_assertPred!"=="(fracSecFromISOString(".9900"), FracSec.from!"hnsecs"(9_900_000));
_assertPred!"=="(fracSecFromISOString(".99"), FracSec.from!"hnsecs"(9_900_000));
_assertPred!"=="(fracSecFromISOString(".9000000"), FracSec.from!"hnsecs"(9_000_000));
_assertPred!"=="(fracSecFromISOString(".9"), FracSec.from!"hnsecs"(9_000_000));
_assertPred!"=="(fracSecFromISOString(".0000999"), FracSec.from!"hnsecs"(999));
_assertPred!"=="(fracSecFromISOString(".0009990"), FracSec.from!"hnsecs"(9990));
_assertPred!"=="(fracSecFromISOString(".000999"), FracSec.from!"hnsecs"(9990));
_assertPred!"=="(fracSecFromISOString(".0099900"), FracSec.from!"hnsecs"(99_900));
_assertPred!"=="(fracSecFromISOString(".00999"), FracSec.from!"hnsecs"(99_900));
_assertPred!"=="(fracSecFromISOString(".0999000"), FracSec.from!"hnsecs"(999_000));
_assertPred!"=="(fracSecFromISOString(".0999"), FracSec.from!"hnsecs"(999_000));
}
}
/+
Whether the given type defines the static property min which returns the
minimum value for the type.
+/
template hasMin(T)
{
enum hasMin = __traits(hasMember, T, "min") &&
__traits(isStaticFunction, T.min) &&
is(ReturnType!(T.min) == Unqual!T) &&
(functionAttributes!(T.min) & FunctionAttribute.property) &&
(functionAttributes!(T.min) & FunctionAttribute.nothrow_);
//(functionAttributes!(T.min) & FunctionAttribute.pure_); //Ideally this would be the case, but SysTime's min() can't currently be pure.
}
unittest
{
version(testStdDateTime)
{
static assert(hasMin!(Date));
static assert(hasMin!(TimeOfDay));
static assert(hasMin!(DateTime));
static assert(hasMin!(SysTime));
static assert(hasMin!(const Date));
static assert(hasMin!(const TimeOfDay));
static assert(hasMin!(const DateTime));
static assert(hasMin!(const SysTime));
static assert(hasMin!(immutable Date));
static assert(hasMin!(immutable TimeOfDay));
static assert(hasMin!(immutable SysTime));
}
}
/+
Whether the given type defines the static property max which returns the
maximum value for the type.
+/
template hasMax(T)
{
enum hasMax = __traits(hasMember, T, "max") &&
__traits(isStaticFunction, T.max) &&
is(ReturnType!(T.max) == Unqual!T) &&
(functionAttributes!(T.max) & FunctionAttribute.property) &&
(functionAttributes!(T.max) & FunctionAttribute.nothrow_);
//(functionAttributes!(T.max) & FunctionAttribute.pure_); //Ideally this would be the case, but SysTime's max() can't currently be pure.
}
unittest
{
version(testStdDateTime)
{
static assert(hasMax!(Date));
static assert(hasMax!(TimeOfDay));
static assert(hasMax!(DateTime));
static assert(hasMax!(SysTime));
static assert(hasMax!(const Date));
static assert(hasMax!(const TimeOfDay));
static assert(hasMax!(const DateTime));
static assert(hasMax!(const SysTime));
static assert(hasMax!(immutable Date));
static assert(hasMax!(immutable TimeOfDay));
static assert(hasMax!(immutable DateTime));
static assert(hasMax!(immutable SysTime));
}
}
/+
Whether the given type defines the overloaded opBinary operators that a time
point is supposed to define which work with time durations. Namely:
$(BOOKTABLE,
$(TR $(TD TimePoint opBinary"+"(duration)))
$(TR $(TD TimePoint opBinary"-"(duration)))
)
+/
template hasOverloadedOpBinaryWithDuration(T)
{
enum hasOverloadedOpBinaryWithDuration = __traits(compiles, T.init + dur!"days"(5)) &&
is(typeof(T.init + dur!"days"(5)) == Unqual!T) &&
__traits(compiles, T.init - dur!"days"(5)) &&
is(typeof(T.init - dur!"days"(5)) == Unqual!T) &&
__traits(compiles, T.init + TickDuration.from!"hnsecs"(5)) &&
is(typeof(T.init + TickDuration.from!"hnsecs"(5)) == Unqual!T) &&
__traits(compiles, T.init - TickDuration.from!"hnsecs"(5)) &&
is(typeof(T.init - TickDuration.from!"hnsecs"(5)) == Unqual!T);
}
unittest
{
version(testStdDateTime)
{
static assert(hasOverloadedOpBinaryWithDuration!(Date));
static assert(hasOverloadedOpBinaryWithDuration!(TimeOfDay));
static assert(hasOverloadedOpBinaryWithDuration!(DateTime));
static assert(hasOverloadedOpBinaryWithDuration!(SysTime));
static assert(hasOverloadedOpBinaryWithDuration!(const Date));
static assert(hasOverloadedOpBinaryWithDuration!(const TimeOfDay));
static assert(hasOverloadedOpBinaryWithDuration!(const DateTime));
static assert(hasOverloadedOpBinaryWithDuration!(const SysTime));
static assert(hasOverloadedOpBinaryWithDuration!(immutable Date));
static assert(hasOverloadedOpBinaryWithDuration!(immutable TimeOfDay));
static assert(hasOverloadedOpBinaryWithDuration!(immutable DateTime));
static assert(hasOverloadedOpBinaryWithDuration!(immutable SysTime));
}
}
/+
Whether the given type defines the overloaded opOpAssign operators that a time point is supposed
to define. Namely:
$(BOOKTABLE,
$(TR $(TD TimePoint opOpAssign"+"(duration)))
$(TR $(TD TimePoint opOpAssign"-"(duration)))
)
+/
template hasOverloadedOpAssignWithDuration(T)
{
enum hasOverloadedOpAssignWithDuration = __traits(compiles, T.init += dur!"days"(5)) &&
is(typeof(T.init += dur!"days"(5)) == Unqual!T) &&
__traits(compiles, T.init -= dur!"days"(5)) &&
is(typeof(T.init -= dur!"days"(5)) == Unqual!T) &&
__traits(compiles, T.init += TickDuration.from!"hnsecs"(5)) &&
is(typeof(T.init += TickDuration.from!"hnsecs"(5)) == Unqual!T) &&
__traits(compiles, T.init -= TickDuration.from!"hnsecs"(5)) &&
is(typeof(T.init -= TickDuration.from!"hnsecs"(5)) == Unqual!T);
}
unittest
{
version(testStdDateTime)
{
static assert(hasOverloadedOpAssignWithDuration!(Date));
static assert(hasOverloadedOpAssignWithDuration!(TimeOfDay));
static assert(hasOverloadedOpAssignWithDuration!(DateTime));
static assert(hasOverloadedOpAssignWithDuration!(SysTime));
static assert(hasOverloadedOpAssignWithDuration!(const Date));
static assert(hasOverloadedOpAssignWithDuration!(const TimeOfDay));
static assert(hasOverloadedOpAssignWithDuration!(const DateTime));
static assert(hasOverloadedOpAssignWithDuration!(const SysTime));
static assert(hasOverloadedOpAssignWithDuration!(immutable Date));
static assert(hasOverloadedOpAssignWithDuration!(immutable TimeOfDay));
static assert(hasOverloadedOpAssignWithDuration!(immutable DateTime));
static assert(hasOverloadedOpAssignWithDuration!(immutable SysTime));
}
}
/+
Whether the given type defines the overloaded opBinary operator that a time point is supposed
to define which works with itself. Namely:
$(BOOKTABLE,
$(TR $(TD duration opBinary"-"(Date)))
)
+/
template hasOverloadedOpBinaryWithSelf(T)
{
enum hasOverloadedOpBinaryWithSelf = __traits(compiles, T.init - T.init) &&
is(Unqual!(typeof(T.init - T.init)) == Duration);
}
unittest
{
version(testStdDateTime)
{
static assert(hasOverloadedOpBinaryWithSelf!(Date));
static assert(hasOverloadedOpBinaryWithSelf!(TimeOfDay));
static assert(hasOverloadedOpBinaryWithSelf!(DateTime));
static assert(hasOverloadedOpBinaryWithSelf!(SysTime));
static assert(hasOverloadedOpBinaryWithSelf!(const Date));
static assert(hasOverloadedOpBinaryWithSelf!(const TimeOfDay));
static assert(hasOverloadedOpBinaryWithSelf!(const DateTime));
static assert(hasOverloadedOpBinaryWithSelf!(const SysTime));
static assert(hasOverloadedOpBinaryWithSelf!(immutable Date));
static assert(hasOverloadedOpBinaryWithSelf!(immutable TimeOfDay));
static assert(hasOverloadedOpBinaryWithSelf!(immutable DateTime));
static assert(hasOverloadedOpBinaryWithSelf!(immutable SysTime));
}
}
/+
Unfortunately, to!string() is not pure, so here's a way to convert
a number to a string which is. Once to!string() is properly pure
(like it hopefully will be at some point), this function should
be removed in favor of using to!string().
+/
string numToString(long value) pure nothrow
{
try
{
immutable negative = value < 0;
char[25] str;
size_t i = str.length;
if(negative)
value = -value;
while(1)
{
char digit = cast(char)('0' + value % 10);
value /= 10;
str[--i] = digit;
assert(i > 0);
if(value == 0)
break;
}
if(negative)
return "-" ~ str[i .. $].idup;
else
return str[i .. $].idup;
}
catch(Exception e)
assert(0, "Something threw when nothing can throw.");
}
version(unittest)
{
//Variables to help in testing.
Duration currLocalDiffFromUTC;
immutable (TimeZone)[] testTZs;
//All of these helper arrays are sorted in ascending order.
auto testYearsBC = [-1999, -1200, -600, -4, -1, 0];
auto testYearsAD = [1, 4, 1000, 1999, 2000, 2012];
//I'd use a Tuple, but I get forward reference errors if I try.
struct MonthDay
{
Month month;
short day;
this(int m, short d)
{
month = cast(Month)m;
day = d;
}
}
MonthDay[] testMonthDays = [MonthDay(1, 1),
MonthDay(1, 2),
MonthDay(3, 17),
MonthDay(7, 4),
MonthDay(10, 27),
MonthDay(12, 30),
MonthDay(12, 31)];
auto testDays = [1, 2, 9, 10, 16, 20, 25, 28, 29, 30, 31];
auto testTODs = [TimeOfDay(0, 0, 0),
TimeOfDay(0, 0, 1),
TimeOfDay(0, 1, 0),
TimeOfDay(1, 0, 0),
TimeOfDay(13, 13, 13),
TimeOfDay(23, 59, 59)];
auto testHours = [0, 1, 12, 22, 23];
auto testMinSecs = [0, 1, 30, 58, 59];
//Throwing exceptions is incredibly expensive, so we want to use a smaller
//set of values for tests using assertThrown.
auto testTODsThrown = [TimeOfDay(0, 0, 0),
TimeOfDay(13, 13, 13),
TimeOfDay(23, 59, 59)];
Date[] testDatesBC;
Date[] testDatesAD;
DateTime[] testDateTimesBC;
DateTime[] testDateTimesAD;
FracSec[] testFracSecs;
SysTime[] testSysTimesBC;
SysTime[] testSysTimesAD;
//I'd use a Tuple, but I get forward reference errors if I try.
struct GregDay { int day; Date date; }
auto testGregDaysBC = [GregDay(-1_373_427, Date(-3760, 9, 7)), //Start of the Hebrew Calendar
GregDay(-735_233, Date(-2012, 1, 1)),
GregDay(-735_202, Date(-2012, 2, 1)),
GregDay(-735_175, Date(-2012, 2, 28)),
GregDay(-735_174, Date(-2012, 2, 29)),
GregDay(-735_173, Date(-2012, 3, 1)),
GregDay(-734_502, Date(-2010, 1, 1)),
GregDay(-734_472, Date(-2010, 1, 31)),
GregDay(-734_471, Date(-2010, 2, 1)),
GregDay(-734_444, Date(-2010, 2, 28)),
GregDay(-734_443, Date(-2010, 3, 1)),
GregDay(-734_413, Date(-2010, 3, 31)),
GregDay(-734_412, Date(-2010, 4, 1)),
GregDay(-734_383, Date(-2010, 4, 30)),
GregDay(-734_382, Date(-2010, 5, 1)),
GregDay(-734_352, Date(-2010, 5, 31)),
GregDay(-734_351, Date(-2010, 6, 1)),
GregDay(-734_322, Date(-2010, 6, 30)),
GregDay(-734_321, Date(-2010, 7, 1)),
GregDay(-734_291, Date(-2010, 7, 31)),
GregDay(-734_290, Date(-2010, 8, 1)),
GregDay(-734_260, Date(-2010, 8, 31)),
GregDay(-734_259, Date(-2010, 9, 1)),
GregDay(-734_230, Date(-2010, 9, 30)),
GregDay(-734_229, Date(-2010, 10, 1)),
GregDay(-734_199, Date(-2010, 10, 31)),
GregDay(-734_198, Date(-2010, 11, 1)),
GregDay(-734_169, Date(-2010, 11, 30)),
GregDay(-734_168, Date(-2010, 12, 1)),
GregDay(-734_139, Date(-2010, 12, 30)),
GregDay(-734_138, Date(-2010, 12, 31)),
GregDay(-731_215, Date(-2001, 1, 1)),
GregDay(-730_850, Date(-2000, 1, 1)),
GregDay(-730_849, Date(-2000, 1, 2)),
GregDay(-730_486, Date(-2000, 12, 30)),
GregDay(-730_485, Date(-2000, 12, 31)),
GregDay(-730_484, Date(-1999, 1, 1)),
GregDay(-694_690, Date(-1901, 1, 1)),
GregDay(-694_325, Date(-1900, 1, 1)),
GregDay(-585_118, Date(-1601, 1, 1)),
GregDay(-584_753, Date(-1600, 1, 1)),
GregDay(-584_388, Date(-1600, 12, 31)),
GregDay(-584_387, Date(-1599, 1, 1)),
GregDay(-365_972, Date(-1001, 1, 1)),
GregDay(-365_607, Date(-1000, 1, 1)),
GregDay(-183_351, Date(-501, 1, 1)),
GregDay(-182_986, Date(-500, 1, 1)),
GregDay(-182_621, Date(-499, 1, 1)),
GregDay(-146_827, Date(-401, 1, 1)),
GregDay(-146_462, Date(-400, 1, 1)),
GregDay(-146_097, Date(-400, 12, 31)),
GregDay(-110_302, Date(-301, 1, 1)),
GregDay(-109_937, Date(-300, 1, 1)),
GregDay(-73_778, Date(-201, 1, 1)),
GregDay(-73_413, Date(-200, 1, 1)),
GregDay(-38_715, Date(-105, 1, 1)),
GregDay(-37_254, Date(-101, 1, 1)),
GregDay(-36_889, Date(-100, 1, 1)),
GregDay(-36_524, Date(-99, 1, 1)),
GregDay(-36_160, Date(-99, 12, 31)),
GregDay(-35_794, Date(-97, 1, 1)),
GregDay(-18_627, Date(-50, 1, 1)),
GregDay(-18_262, Date(-49, 1, 1)),
GregDay(-3652, Date(-9, 1, 1)),
GregDay(-2191, Date(-5, 1, 1)),
GregDay(-1827, Date(-5, 12, 31)),
GregDay(-1826, Date(-4, 1, 1)),
GregDay(-1825, Date(-4, 1, 2)),
GregDay(-1462, Date(-4, 12, 30)),
GregDay(-1461, Date(-4, 12, 31)),
GregDay(-1460, Date(-3, 1, 1)),
GregDay(-1096, Date(-3, 12, 31)),
GregDay(-1095, Date(-2, 1, 1)),
GregDay(-731, Date(-2, 12, 31)),
GregDay(-730, Date(-1, 1, 1)),
GregDay(-367, Date(-1, 12, 30)),
GregDay(-366, Date(-1, 12, 31)),
GregDay(-365, Date(0, 1, 1)),
GregDay(-31, Date(0, 11, 30)),
GregDay(-30, Date(0, 12, 1)),
GregDay(-1, Date(0, 12, 30)),
GregDay(0, Date(0, 12, 31))];
auto testGregDaysAD = [GregDay(1, Date(1, 1, 1)),
GregDay(2, Date(1, 1, 2)),
GregDay(32, Date(1, 2, 1)),
GregDay(365, Date(1, 12, 31)),
GregDay(366, Date(2, 1, 1)),
GregDay(731, Date(3, 1, 1)),
GregDay(1096, Date(4, 1, 1)),
GregDay(1097, Date(4, 1, 2)),
GregDay(1460, Date(4, 12, 30)),
GregDay(1461, Date(4, 12, 31)),
GregDay(1462, Date(5, 1, 1)),
GregDay(17_898, Date(50, 1, 1)),
GregDay(35_065, Date(97, 1, 1)),
GregDay(36_160, Date(100, 1, 1)),
GregDay(36_525, Date(101, 1, 1)),
GregDay(37_986, Date(105, 1, 1)),
GregDay(72_684, Date(200, 1, 1)),
GregDay(73_049, Date(201, 1, 1)),
GregDay(109_208, Date(300, 1, 1)),
GregDay(109_573, Date(301, 1, 1)),
GregDay(145_732, Date(400, 1, 1)),
GregDay(146_098, Date(401, 1, 1)),
GregDay(182_257, Date(500, 1, 1)),
GregDay(182_622, Date(501, 1, 1)),
GregDay(364_878, Date(1000, 1, 1)),
GregDay(365_243, Date(1001, 1, 1)),
GregDay(584_023, Date(1600, 1, 1)),
GregDay(584_389, Date(1601, 1, 1)),
GregDay(693_596, Date(1900, 1, 1)),
GregDay(693_961, Date(1901, 1, 1)),
GregDay(729_755, Date(1999, 1, 1)),
GregDay(730_120, Date(2000, 1, 1)),
GregDay(730_121, Date(2000, 1, 2)),
GregDay(730_484, Date(2000, 12, 30)),
GregDay(730_485, Date(2000, 12, 31)),
GregDay(730_486, Date(2001, 1, 1)),
GregDay(733_773, Date(2010, 1, 1)),
GregDay(733_774, Date(2010, 1, 2)),
GregDay(733_803, Date(2010, 1, 31)),
GregDay(733_804, Date(2010, 2, 1)),
GregDay(733_831, Date(2010, 2, 28)),
GregDay(733_832, Date(2010, 3, 1)),
GregDay(733_862, Date(2010, 3, 31)),
GregDay(733_863, Date(2010, 4, 1)),
GregDay(733_892, Date(2010, 4, 30)),
GregDay(733_893, Date(2010, 5, 1)),
GregDay(733_923, Date(2010, 5, 31)),
GregDay(733_924, Date(2010, 6, 1)),
GregDay(733_953, Date(2010, 6, 30)),
GregDay(733_954, Date(2010, 7, 1)),
GregDay(733_984, Date(2010, 7, 31)),
GregDay(733_985, Date(2010, 8, 1)),
GregDay(734_015, Date(2010, 8, 31)),
GregDay(734_016, Date(2010, 9, 1)),
GregDay(734_045, Date(2010, 9, 30)),
GregDay(734_046, Date(2010, 10, 1)),
GregDay(734_076, Date(2010, 10, 31)),
GregDay(734_077, Date(2010, 11, 1)),
GregDay(734_106, Date(2010, 11, 30)),
GregDay(734_107, Date(2010, 12, 1)),
GregDay(734_136, Date(2010, 12, 30)),
GregDay(734_137, Date(2010, 12, 31)),
GregDay(734_503, Date(2012, 1, 1)),
GregDay(734_534, Date(2012, 2, 1)),
GregDay(734_561, Date(2012, 2, 28)),
GregDay(734_562, Date(2012, 2, 29)),
GregDay(734_563, Date(2012, 3, 1)),
GregDay(734_858, Date(2012, 12, 21))];
//I'd use a Tuple, but I get forward reference errors if I try.
struct DayOfYear { int day; MonthDay md; }
auto testDaysOfYear = [DayOfYear(1, MonthDay(1, 1)),
DayOfYear(2, MonthDay(1, 2)),
DayOfYear(3, MonthDay(1, 3)),
DayOfYear(31, MonthDay(1, 31)),
DayOfYear(32, MonthDay(2, 1)),
DayOfYear(59, MonthDay(2, 28)),
DayOfYear(60, MonthDay(3, 1)),
DayOfYear(90, MonthDay(3, 31)),
DayOfYear(91, MonthDay(4, 1)),
DayOfYear(120, MonthDay(4, 30)),
DayOfYear(121, MonthDay(5, 1)),
DayOfYear(151, MonthDay(5, 31)),
DayOfYear(152, MonthDay(6, 1)),
DayOfYear(181, MonthDay(6, 30)),
DayOfYear(182, MonthDay(7, 1)),
DayOfYear(212, MonthDay(7, 31)),
DayOfYear(213, MonthDay(8, 1)),
DayOfYear(243, MonthDay(8, 31)),
DayOfYear(244, MonthDay(9, 1)),
DayOfYear(273, MonthDay(9, 30)),
DayOfYear(274, MonthDay(10, 1)),
DayOfYear(304, MonthDay(10, 31)),
DayOfYear(305, MonthDay(11, 1)),
DayOfYear(334, MonthDay(11, 30)),
DayOfYear(335, MonthDay(12, 1)),
DayOfYear(363, MonthDay(12, 29)),
DayOfYear(364, MonthDay(12, 30)),
DayOfYear(365, MonthDay(12, 31))];
auto testDaysOfLeapYear = [DayOfYear(1, MonthDay(1, 1)),
DayOfYear(2, MonthDay(1, 2)),
DayOfYear(3, MonthDay(1, 3)),
DayOfYear(31, MonthDay(1, 31)),
DayOfYear(32, MonthDay(2, 1)),
DayOfYear(59, MonthDay(2, 28)),
DayOfYear(60, MonthDay(2, 29)),
DayOfYear(61, MonthDay(3, 1)),
DayOfYear(91, MonthDay(3, 31)),
DayOfYear(92, MonthDay(4, 1)),
DayOfYear(121, MonthDay(4, 30)),
DayOfYear(122, MonthDay(5, 1)),
DayOfYear(152, MonthDay(5, 31)),
DayOfYear(153, MonthDay(6, 1)),
DayOfYear(182, MonthDay(6, 30)),
DayOfYear(183, MonthDay(7, 1)),
DayOfYear(213, MonthDay(7, 31)),
DayOfYear(214, MonthDay(8, 1)),
DayOfYear(244, MonthDay(8, 31)),
DayOfYear(245, MonthDay(9, 1)),
DayOfYear(274, MonthDay(9, 30)),
DayOfYear(275, MonthDay(10, 1)),
DayOfYear(305, MonthDay(10, 31)),
DayOfYear(306, MonthDay(11, 1)),
DayOfYear(335, MonthDay(11, 30)),
DayOfYear(336, MonthDay(12, 1)),
DayOfYear(364, MonthDay(12, 29)),
DayOfYear(365, MonthDay(12, 30)),
DayOfYear(366, MonthDay(12, 31))];
static this()
{
currLocalDiffFromUTC = Clock.currTime(UTC()) -
Clock.currTime(LocalTime());
immutable simpleTZ = new SimpleTimeZone(cast(int)
(currLocalDiffFromUTC + dur!"hours"(2)).total!"minutes"());
immutable lt = LocalTime().utcToTZ(0);
immutable st = simpleTZ.utcToTZ(0);
auto diffs = [0, lt, st];
auto diffAA = [0 : cast(immutable TimeZone)UTC(),
lt : cast(immutable TimeZone)LocalTime(),
st : cast(immutable TimeZone)simpleTZ];
sort(diffs);
testTZs = [diffAA[diffs[0]], diffAA[diffs[1]], diffAA[diffs[2]]];
testFracSecs = [FracSec.from!"hnsecs"(0),
FracSec.from!"hnsecs"(1),
FracSec.from!"hnsecs"(5007),
FracSec.from!"hnsecs"(9999999)];
foreach(year; testYearsBC)
{
foreach(md; testMonthDays)
testDatesBC ~= Date(year, md.month, md.day);
}
foreach(year; testYearsAD)
{
foreach(md; testMonthDays)
testDatesAD ~= Date(year, md.month, md.day);
}
foreach(dt; testDatesBC)
{
foreach(tod; testTODs)
testDateTimesBC ~= DateTime(dt, tod);
}
foreach(dt; testDatesAD)
{
foreach(tod; testTODs)
testDateTimesAD ~= DateTime(dt, tod);
}
foreach(dt; testDateTimesBC)
{
foreach(tz; testTZs)
{
foreach(fs; testFracSecs)
testSysTimesBC ~= SysTime(dt, fs, tz);
}
}
foreach(dt; testDateTimesAD)
{
foreach(tz; testTZs)
{
foreach(fs; testFracSecs)
testSysTimesAD ~= SysTime(dt, fs, tz);
}
}
}
}
//==============================================================================
// Unit testing functions.
//==============================================================================
void _assertPred(string op, L, R)
(L lhs, R rhs, lazy string msg = null, string file = __FILE__, size_t line = __LINE__)
if((op == "<" ||
op == "<=" ||
op == "==" ||
op == "!=" ||
op == ">=" ||
op == ">") &&
__traits(compiles, mixin("lhs " ~ op ~ " rhs")) &&
_isPrintable!L &&
_isPrintable!R)
{
immutable result = mixin("lhs " ~ op ~ " rhs");
if(!result)
{
if(msg.empty)
throw new AssertError(format(`_assertPred!"%s" failed: [%s] is not %s [%s].`, op, lhs, op, rhs), file, line);
else
throw new AssertError(format(`_assertPred!"%s" failed: [%s] is not %s [%s]: %s`, op, lhs, op, rhs, msg), file, line);
}
}
unittest
{
version(testStdDateTime)
{
struct IntWrapper
{
int value;
this(int value)
{
this.value = value;
}
string toString()
{
return to!string(value);
}
}
//Test ==.
assertNotThrown!AssertError(_assertPred!"=="(6, 6));
assertNotThrown!AssertError(_assertPred!"=="(6, 6.0));
assertNotThrown!AssertError(_assertPred!"=="(IntWrapper(6), IntWrapper(6)));
assertThrown!AssertError(_assertPred!"=="(6, 7));
assertThrown!AssertError(_assertPred!"=="(6, 6.1));
assertThrown!AssertError(_assertPred!"=="(IntWrapper(6), IntWrapper(7)));
assertThrown!AssertError(_assertPred!"=="(IntWrapper(7), IntWrapper(6)));
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"=="(6, 7)),
`_assertPred!"==" failed: [6] is not == [7].`);
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"=="(6, 7, "It failed!")),
`_assertPred!"==" failed: [6] is not == [7]: It failed!`);
//Test !=.
assertNotThrown!AssertError(_assertPred!"!="(6, 7));
assertNotThrown!AssertError(_assertPred!"!="(6, 6.1));
assertNotThrown!AssertError(_assertPred!"!="(IntWrapper(6), IntWrapper(7)));
assertNotThrown!AssertError(_assertPred!"!="(IntWrapper(7), IntWrapper(6)));
assertThrown!AssertError(_assertPred!"!="(6, 6));
assertThrown!AssertError(_assertPred!"!="(6, 6.0));
assertThrown!AssertError(_assertPred!"!="(IntWrapper(6), IntWrapper(6)));
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"!="(6, 6)),
`_assertPred!"!=" failed: [6] is not != [6].`);
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"!="(6, 6, "It failed!")),
`_assertPred!"!=" failed: [6] is not != [6]: It failed!`);
//Test <, <=, >=, >.
assertNotThrown!AssertError(_assertPred!"<"(5, 7));
assertNotThrown!AssertError(_assertPred!"<="(5, 7));
assertNotThrown!AssertError(_assertPred!"<="(5, 5));
assertNotThrown!AssertError(_assertPred!">="(7, 7));
assertNotThrown!AssertError(_assertPred!">="(7, 5));
assertNotThrown!AssertError(_assertPred!">"(7, 5));
assertThrown!AssertError(_assertPred!"<"(7, 5));
assertThrown!AssertError(_assertPred!"<="(7, 5));
assertThrown!AssertError(_assertPred!">="(5, 7));
assertThrown!AssertError(_assertPred!">"(5, 7));
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"<"(7, 5)),
`_assertPred!"<" failed: [7] is not < [5].`);
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"<"(7, 5, "It failed!")),
`_assertPred!"<" failed: [7] is not < [5]: It failed!`);
//Verify Examples.
//Equivalent to assert(5 / 2 + 4 < 27);
_assertPred!"<"(5 / 2 + 4, 27);
//Equivalent to assert(4 <= 5);
_assertPred!"<="(4, 5);
//Equivalent to assert(1 * 2.1 == 2.1);
_assertPred!"=="(1 * 2.1, 2.1);
//Equivalent to assert("hello " ~ "world" != "goodbye world");
_assertPred!"!="("hello " ~ "world", "goodbye world");
//Equivalent to assert(14.2 >= 14);
_assertPred!">="(14.2, 14);
//Equivalent to assert(15 > 2 + 1);
_assertPred!">"(15, 2 + 1);
assert(collectExceptionMsg!AssertError(_assertPred!"=="("hello", "goodbye")) ==
`_assertPred!"==" failed: [hello] is not == [goodbye].`);
assert(collectExceptionMsg!AssertError(_assertPred!"<"(5, 2, "My test failed!")) ==
`_assertPred!"<" failed: [5] is not < [2]: My test failed!`);
}
}
void _assertPred(string func, string expected, L, R)
(L lhs, R rhs, lazy string msg = null, string file = __FILE__, size_t line = __LINE__)
if(func == "opCmp" &&
(expected == "<" ||
expected == "==" ||
expected == ">") &&
__traits(compiles, lhs.opCmp(rhs)) &&
_isPrintable!L &&
_isPrintable!R)
{
immutable result = lhs.opCmp(rhs);
static if(expected == "<")
{
if(result < 0)
return;
if(result == 0)
{
if(msg.empty)
throw new AssertError(format(`_assertPred!("opCmp", "<") failed: [%s] == [%s].`, lhs, rhs), file, line);
else
throw new AssertError(format(`_assertPred!("opCmp", "<") failed: [%s] == [%s]: %s`, lhs, rhs, msg), file, line);
}
else
{
if(msg.empty)
throw new AssertError(format(`_assertPred!("opCmp", "<") failed: [%s] > [%s].`, lhs, rhs), file, line);
else
throw new AssertError(format(`_assertPred!("opCmp", "<") failed: [%s] > [%s]: %s`, lhs, rhs, msg), file, line);
}
}
else static if(expected == "==")
{
if(result == 0)
return;
if(result < 0)
{
if(msg.empty)
throw new AssertError(format(`_assertPred!("opCmp", "==") failed: [%s] < [%s].`, lhs, rhs), file, line);
else
throw new AssertError(format(`_assertPred!("opCmp", "==") failed: [%s] < [%s]: %s`, lhs, rhs, msg), file, line);
}
else
{
if(msg.empty)
throw new AssertError(format(`_assertPred!("opCmp", "==") failed: [%s] > [%s].`, lhs, rhs), file, line);
else
throw new AssertError(format(`_assertPred!("opCmp", "==") failed: [%s] > [%s]: %s`, lhs, rhs, msg), file, line);
}
}
else static if(expected == ">")
{
if(result > 0)
return;
if(result < 0)
{
if(msg.empty)
throw new AssertError(format(`_assertPred!("opCmp", ">") failed: [%s] < [%s].`, lhs, rhs), file, line);
else
throw new AssertError(format(`_assertPred!("opCmp", ">") failed: [%s] < [%s]: %s`, lhs, rhs, msg), file, line);
}
else
{
if(msg.empty)
throw new AssertError(format(`_assertPred!("opCmp", ">") failed: [%s] == [%s].`, lhs, rhs), file, line);
else
throw new AssertError(format(`_assertPred!("opCmp", ">") failed: [%s] == [%s]: %s`, lhs, rhs, msg), file, line);
}
}
else
static assert(0);
}
void _assertPred(string op, L, R, E)
(L lhs, R rhs, E expected, lazy string msg = null, string file = __FILE__, size_t line = __LINE__)
if((op == "+=" ||
op == "-=" ||
op == "*=" ||
op == "/=" ||
op == "%=" ||
op == "^^=" ||
op == "&=" ||
op == "|=" ||
op == "^=" ||
op == "<<=" ||
op == ">>=" ||
op == ">>>=" ||
op == "~=") &&
__traits(compiles, mixin("lhs " ~ op ~ " rhs")) &&
__traits(compiles, mixin("(lhs " ~ op ~ " rhs) == expected")) &&
_isPrintable!L &&
_isPrintable!R)
{
immutable origLHSStr = to!string(lhs);
const result = mixin("lhs " ~ op ~ " rhs");
if(lhs != expected)
{
if(msg.empty)
{
throw new AssertError(format(`_assertPred!"%s" failed: After [%s] %s [%s], lhs was assigned to [%s] instead of [%s].`,
op,
origLHSStr,
op,
rhs,
lhs,
expected),
file,
line);
}
else
{
throw new AssertError(format(`_assertPred!"%s" failed: After [%s] %s [%s], lhs was assigned to [%s] instead of [%s]: %s`,
op,
origLHSStr,
op,
rhs,
lhs,
expected,
msg),
file,
line);
}
}
if(result != expected)
{
if(msg.empty)
{
throw new AssertError(format(`_assertPred!"%s" failed: Return value of [%s] %s [%s] was [%s] instead of [%s].`,
op,
origLHSStr,
op,
rhs,
result,
expected),
file,
line);
}
else
{
throw new AssertError(format(`_assertPred!"%s" failed: Return value of [%s] %s [%s] was [%s] instead of [%s]: %s`,
op,
origLHSStr,
op,
rhs,
result,
expected,
msg),
file,
line);
}
}
}
unittest
{
version(testStdDateTime)
{
assertNotThrown!AssertError(_assertPred!"+="(7, 5, 12));
assertNotThrown!AssertError(_assertPred!"-="(7, 5, 2));
assertNotThrown!AssertError(_assertPred!"*="(7, 5, 35));
assertNotThrown!AssertError(_assertPred!"/="(7, 5, 1));
assertNotThrown!AssertError(_assertPred!"%="(7, 5, 2));
assertNotThrown!AssertError(_assertPred!"^^="(7, 5, 16_807));
assertNotThrown!AssertError(_assertPred!"&="(7, 5, 5));
assertNotThrown!AssertError(_assertPred!"|="(7, 5, 7));
assertNotThrown!AssertError(_assertPred!"^="(7, 5, 2));
assertNotThrown!AssertError(_assertPred!"<<="(7, 1, 14));
assertNotThrown!AssertError(_assertPred!">>="(7, 1, 3));
assertNotThrown!AssertError(_assertPred!">>>="(-7, 1, 2_147_483_644));
assertNotThrown!AssertError(_assertPred!"~="("hello ", "world", "hello world"));
assertThrown!AssertError(_assertPred!"+="(7, 5, 0));
assertThrown!AssertError(_assertPred!"-="(7, 5, 0));
assertThrown!AssertError(_assertPred!"*="(7, 5, 0));
assertThrown!AssertError(_assertPred!"/="(7, 5, 0));
assertThrown!AssertError(_assertPred!"%="(7, 5, 0));
assertThrown!AssertError(_assertPred!"^^="(7, 5, 0));
assertThrown!AssertError(_assertPred!"&="(7, 5, 0));
assertThrown!AssertError(_assertPred!"|="(7, 5, 0));
assertThrown!AssertError(_assertPred!"^="(7, 5, 0));
assertThrown!AssertError(_assertPred!"<<="(7, 1, 0));
assertThrown!AssertError(_assertPred!">>="(7, 1, 0));
assertThrown!AssertError(_assertPred!">>>="(-7, 1, 0));
assertThrown!AssertError(_assertPred!"~="("hello ", "world", "goodbye world"));
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"+="(7, 5, 11)),
`_assertPred!"+=" failed: After [7] += [5], lhs was assigned to [12] instead of [11].`);
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"+="(7, 5, 11, "It failed!")),
`_assertPred!"+=" failed: After [7] += [5], lhs was assigned to [12] instead of [11]: It failed!`);
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"^^="(7, 5, 42)),
`_assertPred!"^^=" failed: After [7] ^^= [5], lhs was assigned to [16807] instead of [42].`);
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"^^="(7, 5, 42, "It failed!")),
`_assertPred!"^^=" failed: After [7] ^^= [5], lhs was assigned to [16807] instead of [42]: It failed!`);
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"~="("hello ", "world", "goodbye world")),
`_assertPred!"~=" failed: After [hello ] ~= [world], lhs was assigned to [hello world] instead of [goodbye world].`);
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"~="("hello ", "world", "goodbye world", "It failed!")),
`_assertPred!"~=" failed: After [hello ] ~= [world], lhs was assigned to [hello world] instead of [goodbye world]: It failed!`);
struct IntWrapper
{
int value;
this(int value)
{
this.value = value;
}
IntWrapper opOpAssign(string op)(IntWrapper rhs)
{
mixin("this.value " ~ op ~ "= rhs.value;");
return this;
}
string toString()
{
return to!string(value);
}
}
struct IntWrapper_BadAssign
{
int value;
this(int value)
{
this.value = value;
}
IntWrapper_BadAssign opOpAssign(string op)(IntWrapper_BadAssign rhs)
{
auto old = this.value;
mixin("this.value " ~ op ~ "= -rhs.value;");
return IntWrapper_BadAssign(mixin("old " ~ op ~ " rhs.value"));
}
string toString()
{
return to!string(value);
}
}
struct IntWrapper_BadReturn
{
int value;
this(int value)
{
this.value = value;
}
IntWrapper_BadReturn opOpAssign(string op)(IntWrapper_BadReturn rhs)
{
mixin("this.value " ~ op ~ "= rhs.value;");
return IntWrapper_BadReturn(rhs.value);
}
string toString()
{
return to!string(value);
}
}
assertNotThrown!AssertError(_assertPred!"+="(IntWrapper(5), IntWrapper(2), IntWrapper(7)));
assertNotThrown!AssertError(_assertPred!"*="(IntWrapper(5), IntWrapper(2), IntWrapper(10)));
assertThrown!AssertError(_assertPred!"+="(IntWrapper_BadAssign(5), IntWrapper_BadAssign(2), IntWrapper_BadAssign(7)));
assertThrown!AssertError(_assertPred!"+="(IntWrapper_BadReturn(5), IntWrapper_BadReturn(2), IntWrapper_BadReturn(7)));
assertThrown!AssertError(_assertPred!"*="(IntWrapper_BadAssign(5), IntWrapper_BadAssign(2), IntWrapper_BadAssign(10)));
assertThrown!AssertError(_assertPred!"*="(IntWrapper_BadReturn(5), IntWrapper_BadReturn(2), IntWrapper_BadReturn(10)));
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"+="(IntWrapper_BadAssign(5), IntWrapper_BadAssign(2), IntWrapper_BadAssign(7))),
`_assertPred!"+=" failed: After [5] += [2], lhs was assigned to [3] instead of [7].`);
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"+="(IntWrapper_BadAssign(5), IntWrapper_BadAssign(2), IntWrapper_BadAssign(7), "It failed!")),
`_assertPred!"+=" failed: After [5] += [2], lhs was assigned to [3] instead of [7]: It failed!`);
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"+="(IntWrapper_BadReturn(5), IntWrapper_BadReturn(2), IntWrapper_BadReturn(7))),
`_assertPred!"+=" failed: Return value of [5] += [2] was [2] instead of [7].`);
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"+="(IntWrapper_BadReturn(5), IntWrapper_BadReturn(2), IntWrapper_BadReturn(7), "It failed!")),
`_assertPred!"+=" failed: Return value of [5] += [2] was [2] instead of [7]: It failed!`);
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"*="(IntWrapper_BadAssign(5), IntWrapper_BadAssign(2), IntWrapper_BadAssign(10))),
`_assertPred!"*=" failed: After [5] *= [2], lhs was assigned to [-10] instead of [10].`);
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"*="(IntWrapper_BadAssign(5), IntWrapper_BadAssign(2), IntWrapper_BadAssign(10), "It failed!")),
`_assertPred!"*=" failed: After [5] *= [2], lhs was assigned to [-10] instead of [10]: It failed!`);
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"*="(IntWrapper_BadReturn(5), IntWrapper_BadReturn(2), IntWrapper_BadReturn(10))),
`_assertPred!"*=" failed: Return value of [5] *= [2] was [2] instead of [10].`);
_assertPred!"=="(collectExceptionMsg!AssertError(_assertPred!"*="(IntWrapper_BadReturn(5), IntWrapper_BadReturn(2), IntWrapper_BadReturn(10), "It failed!")),
`_assertPred!"*=" failed: Return value of [5] *= [2] was [2] instead of [10]: It failed!`);
}
}
template _isPrintable(T...)
{
static if(T.length == 0)
enum _isPrintable = true;
else static if(T.length == 1)
{
enum _isPrintable = (!isArray!(T[0]) && __traits(compiles, to!string(T[0].init))) ||
(isArray!(T[0]) && __traits(compiles, to!string(T[0].init[0])));
}
else
{
enum _isPrintable = _isPrintable!(T[0]) && _isPrintable!(T[1 .. $]);
}
}
template softDeprec(string vers, string date, string oldFunc, string newFunc)
{
enum softDeprec = Format!("Notice: As of Phobos %s, std.datetime.%s has been scheduled " ~
"for deprecation in %s. Please use std.datetime.%s instead.",
vers, oldFunc, date, newFunc);
}
|
D
|
/Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/SQL.build/SQLSelectExpression.swift.o : /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLBind.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLJoinMethod.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLTable.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLCreateTable.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDropTable.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLAlterTable.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLSerializable.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDataType.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLUpdate.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDelete.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLLiteral.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLBoolLiteral.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDefaultLiteral.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLTableConstraintAlgorithm.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLColumnConstraintAlgorithm.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLJoin.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLExpression.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLSelectExpression.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLCollation.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLForeignKeyAction.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLConnection.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDirection.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLFunction.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLColumnDefinition.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLCreateTableBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDropTableBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLAlterTableBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLPredicateBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLUpdateBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDeleteBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLColumnBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLPredicateGroupBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLSelectBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLInsertBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLRawBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLCreateIndexBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLQueryBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLQueryEncoder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLQueryFetcher.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLIndexModifier.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLIdentifier.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLTableIdentifier.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLColumnIdentifier.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLError.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLBinaryOperator.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/Exports.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLSelect.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDistinct.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLFunctionArgument.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLTableConstraint.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLColumnConstraint.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLInsert.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLCreateIndex.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDropIndex.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLGroupBy.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLOrderBy.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLForeignKey.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLPrimaryKey.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLQuery.swift /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/XPC.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/ObjectiveC.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/Dispatch.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/Darwin.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/Foundation.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/CoreFoundation.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/CoreGraphics.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/Swift.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/IOKit.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/SwiftOnoneSupport.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Combine.framework/Modules/Combine.swiftmodule/x86_64-apple-macos.swiftinterface /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/Async.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/Service.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/Core.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/Debugging.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/COperatingSystem.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/Bits.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/DatabaseKit.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/swift-nio-zlib-support/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/SQL.build/SQLSelectExpression~partial.swiftmodule : /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLBind.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLJoinMethod.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLTable.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLCreateTable.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDropTable.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLAlterTable.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLSerializable.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDataType.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLUpdate.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDelete.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLLiteral.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLBoolLiteral.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDefaultLiteral.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLTableConstraintAlgorithm.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLColumnConstraintAlgorithm.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLJoin.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLExpression.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLSelectExpression.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLCollation.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLForeignKeyAction.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLConnection.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDirection.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLFunction.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLColumnDefinition.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLCreateTableBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDropTableBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLAlterTableBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLPredicateBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLUpdateBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDeleteBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLColumnBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLPredicateGroupBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLSelectBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLInsertBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLRawBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLCreateIndexBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLQueryBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLQueryEncoder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLQueryFetcher.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLIndexModifier.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLIdentifier.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLTableIdentifier.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLColumnIdentifier.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLError.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLBinaryOperator.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/Exports.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLSelect.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDistinct.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLFunctionArgument.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLTableConstraint.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLColumnConstraint.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLInsert.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLCreateIndex.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDropIndex.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLGroupBy.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLOrderBy.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLForeignKey.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLPrimaryKey.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLQuery.swift /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/XPC.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/ObjectiveC.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/Dispatch.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/Darwin.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/Foundation.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/CoreFoundation.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/CoreGraphics.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/Swift.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/IOKit.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/SwiftOnoneSupport.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Combine.framework/Modules/Combine.swiftmodule/x86_64-apple-macos.swiftinterface /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/Async.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/Service.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/Core.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/Debugging.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/COperatingSystem.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/Bits.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/DatabaseKit.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/swift-nio-zlib-support/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/SQL.build/SQLSelectExpression~partial.swiftdoc : /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLBind.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLJoinMethod.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLTable.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLCreateTable.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDropTable.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLAlterTable.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLSerializable.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDataType.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLUpdate.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDelete.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLLiteral.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLBoolLiteral.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDefaultLiteral.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLTableConstraintAlgorithm.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLColumnConstraintAlgorithm.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLJoin.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLExpression.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLSelectExpression.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLCollation.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLForeignKeyAction.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLConnection.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDirection.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLFunction.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLColumnDefinition.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLCreateTableBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDropTableBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLAlterTableBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLPredicateBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLUpdateBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDeleteBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLColumnBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLPredicateGroupBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLSelectBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLInsertBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLRawBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLCreateIndexBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLQueryBuilder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLQueryEncoder.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLQueryFetcher.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLIndexModifier.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLIdentifier.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLTableIdentifier.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLColumnIdentifier.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLError.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLBinaryOperator.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/Exports.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLSelect.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDistinct.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLFunctionArgument.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLTableConstraint.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLColumnConstraint.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLInsert.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLCreateIndex.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLDropIndex.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLGroupBy.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLOrderBy.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLForeignKey.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLPrimaryKey.swift /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/sql/Sources/SQL/SQLQuery.swift /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/XPC.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/ObjectiveC.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/Dispatch.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/Darwin.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/Foundation.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/CoreFoundation.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/CoreGraphics.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/Swift.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/IOKit.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/SwiftOnoneSupport.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Combine.framework/Modules/Combine.swiftmodule/x86_64-apple-macos.swiftinterface /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/Async.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/Service.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/Core.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/Debugging.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/COperatingSystem.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/Bits.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/DatabaseKit.swiftmodule /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/weirujian/Desktop/WeiRuJian/Vapor/AuthServer/.build/checkouts/swift-nio-zlib-support/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
|
D
|
/*********************************************************
Copyright: (C) 2008-2010 by Steven Schveighoffer.
All rights reserved
License: Boost Software License version 1.0
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer, must
be included in all copies of the Software, in whole or in part, and all
derivative works of the Software, unless such copies or derivative works are
solely in the form of machine-executable object code generated by a source
language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
**********************************************************/
module dcollections.model.List;
public import dcollections.model.Addable;
private import std.range;
/**
* A List is a collection whose elements are in the order added. These are
* useful when you need something that keeps track of not only values, but the
* order added.
*/
interface List(V) : Addable!V, Iterator!V, Purgeable!V
{
/**
* Concatenate two lists together. The resulting list type is of the type
* of the left hand side. The returned list is a new object, different
* from this and rhs.
*/
List concat(List rhs);
/**
* Concatenate this list and an array together.
*
* The resulting list is the same type as this list.
*/
List concat(V[] array);
/**
* Concatenate an array and this list together.
*
* The resulting list is the same type as this list.
*/
List concat_r(V[] array);
version(testcompiler)
{
/**
* operator overload for concatenation.
*/
auto opBinary(string op, T)(T rhs) if (op == "~" && (is(T == V[]) || is(T : List)))
{
return concat(rhs);
}
/**
* operator overload for concatenation of an array with this object.
*/
auto opBinaryRight(string op, T)(T lhs) if (op == "~" && is(T == V[]))
{
return concat_r(lhs);
}
/**
* Append the given elements in the range to the end of the list. Returns
* 'this'
*/
auto opOpAssign(string op, R)(R range) if (op == "~=" && !(is(R == V[])) && isInputRange!R && is(ElementType!R : V))
{
addRange(range);
return this;
}
/**
* Append the given item to the
*/
auto opOpAssign(string op, T)(T other) if (op == "~=" && (is(T == V[]) || is(T : Iterator!V) || is(T : V)))
{
return add(other);
}
}
else
{
// workaround for compiler deficiencies. Note you MUST repeat this in
// derived classes to achieve covariance (see bug 4182).
alias concat opCat;
alias concat_r opCat_r;
alias add opCatAssign;
}
/**
* clear all elements from the list. (Part of the collection
* pseudo-interface)
*/
List clear();
/**
* Create a clone of this list. (Part of the collection pseudo-interface)
*/
List dup();
/**
* Covariant add (from Addable)
*/
List add(V[] elems...);
/**
* Covariant add (from Addable)
*/
List add(Iterator!(V) it);
/**
* sort this list according to the default compare routine for V. Returns
* a reference to the list after it is sorted. O(NlgN) runtime or better.
*/
List sort();
/**
* sort this list according to the comparison routine given. Returns a
* reference to the list after it is sorted. O(NlgN) runtime or better.
*/
List sort(scope bool delegate(ref V v1, ref V v2) comp);
/**
* sort this list according to the comparison routine given. Returns a
* reference to the list after it is sorted. O(NlgN) runtime or better.
*/
List sort(bool function(ref V v1, ref V v2) comp);
/**
* compare this list to another list. Returns true if they have the same
* number of elements and all the elements are equal.
*
* If o is not a list, then 0 is returned.
*/
bool opEquals(Object o);
/**
* compare this list to an array. Returns true if they have the same
* number of elements and all the elements are equal.
*/
bool opEquals(V[] arr);
/**
* Returns the element at the front of the list, or the oldest element
* added. If the list is empty, calling front is undefined.
*
* TODO: should be inout
*/
V front();
/**
* Returns the element at the end of the list, or the most recent element
* added. If the list is empty, calling back is undefined.
*
* TODO: should be inout
*/
V back();
/**
* Takes the element at the end of the list, and return its value. This
* operation is guaranteed to be O(lgN) or better. It should always be
* implementable as O(lgN) because it is O(lgN) to add an element to the
* end.
*/
V take();
}
|
D
|
# FIXED
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/packages/ti/drivers/lcd/LCDDogm1286.c
Drivers/LCD/LCDDogm1286.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/string.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/linkage.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/std.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/stdarg.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/stddef.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/targets/arm/elf/std.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/targets/arm/elf/M3.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/targets/std.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/stdint.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/xdc.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types__prologue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/package.defs.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types__epilogue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error__prologue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Main.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IHeap.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Memory.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IHeap.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/Memory_HeapProxy.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IHeap.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IGateProvider.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/Main_Module_GateProxy.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IGateProvider.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error__epilogue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert__prologue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Main.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags__prologue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Main.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags__epilogue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert__epilogue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log__prologue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Main.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Text.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log__epilogue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/System.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/ISystemSupport.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IGateProvider.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/System_SupportProxy.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/ISystemSupport.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/System_Module_GateProxy.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IGateProvider.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/System_SupportProxy.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/System_Module_GateProxy.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/BIOS.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/BIOS__prologue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/package/package.defs.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IGateProvider.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/package/BIOS_RtsGateProxy.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IGateProvider.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/BIOS__epilogue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/package/BIOS_RtsGateProxy.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/m3/Hwi.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/m3/Hwi__prologue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/m3/package/package.defs.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/BIOS.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/IHwi.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/package/package.defs.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/m3/Hwi__epilogue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Semaphore.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/package/package.defs.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Task.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Task__prologue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IHeap.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/ITaskSupport.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/ITimer.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Swi.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/package/Clock_TimerProxy.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/ITimer.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/package/Task_SupportProxy.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/ITaskSupport.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Task__epilogue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Event.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Event__prologue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Task.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Event__epilogue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Task.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/package/Task_SupportProxy.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/package/Clock_TimerProxy.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/packages/ti/drivers/SPI.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/stdbool.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/yvals.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/stdarg.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/_lock.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/stddef.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/packages/ti/drivers/spi/SPICC26XXDMA.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/packages/ti/drivers/pin/PINCC26XX.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/packages/ti/drivers/PIN.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/stddef.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/inc/hw_types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/inc/hw_chip_def.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/driverlib/ioc.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/inc/hw_memmap.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/inc/hw_ioc.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/inc/hw_ints.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/driverlib/interrupt.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/inc/hw_nvic.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/driverlib/debug.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/driverlib/cpu.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/driverlib/rom.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/driverlib/gpio.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/inc/hw_gpio.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/m3/Hwi.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/stddef.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/packages/ti/drivers/dma/UDMACC26XX.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/driverlib/udma.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/inc/hw_udma.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/cc26xx/Power.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/cc26xx/package/package.defs.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/IPower.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/cc26xx/PowerCC2650.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/cc26xx/Power.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Semaphore.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/m3/Hwi.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/packages/ti/drivers/lcd/LCDDogm1286.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/m3/Hwi.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Semaphore.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/packages/ti/drivers/lcd/LCDDogm1286_util.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/driverlib/ssi.h
Drivers/LCD/LCDDogm1286.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/inc/hw_ssi.h
C:/ti/tirtos_simplelink_2_13_00_06/packages/ti/drivers/lcd/LCDDogm1286.c:
C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/string.h:
C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/linkage.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/std.h:
C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/stdarg.h:
C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/stddef.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/targets/arm/elf/std.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/targets/arm/elf/M3.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/targets/std.h:
C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/stdint.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/xdc.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types__prologue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/package.defs.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types__epilogue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error__prologue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Main.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IHeap.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Memory.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IHeap.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/Memory_HeapProxy.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IHeap.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IGateProvider.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/Main_Module_GateProxy.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IGateProvider.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error__epilogue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert__prologue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Main.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags__prologue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Main.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags__epilogue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert__epilogue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log__prologue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Main.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Text.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log__epilogue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/System.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/ISystemSupport.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IGateProvider.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/System_SupportProxy.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/ISystemSupport.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/System_Module_GateProxy.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IGateProvider.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/System_SupportProxy.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/System_Module_GateProxy.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/BIOS.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/BIOS__prologue.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/package/package.defs.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IGateProvider.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/package/BIOS_RtsGateProxy.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IGateProvider.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/BIOS__epilogue.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/package/BIOS_RtsGateProxy.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/m3/Hwi.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/m3/Hwi__prologue.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/m3/package/package.defs.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/BIOS.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/IHwi.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/package/package.defs.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/m3/Hwi__epilogue.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Semaphore.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/package/package.defs.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Task.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Task__prologue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IHeap.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/ITaskSupport.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/ITimer.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Swi.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/package/Clock_TimerProxy.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/ITimer.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/package/Task_SupportProxy.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/ITaskSupport.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Task__epilogue.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Event.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Event__prologue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Task.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Event__epilogue.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Task.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/package/Task_SupportProxy.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/package/Clock_TimerProxy.h:
C:/ti/tirtos_simplelink_2_13_00_06/packages/ti/drivers/SPI.h:
C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/stdbool.h:
C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/yvals.h:
C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/stdarg.h:
C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/_lock.h:
C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/stddef.h:
C:/ti/tirtos_simplelink_2_13_00_06/packages/ti/drivers/spi/SPICC26XXDMA.h:
C:/ti/tirtos_simplelink_2_13_00_06/packages/ti/drivers/pin/PINCC26XX.h:
C:/ti/tirtos_simplelink_2_13_00_06/packages/ti/drivers/PIN.h:
C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/stddef.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/inc/hw_types.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/inc/hw_chip_def.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/driverlib/ioc.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/inc/hw_memmap.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/inc/hw_ioc.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/inc/hw_ints.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/driverlib/interrupt.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/inc/hw_nvic.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/driverlib/debug.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/driverlib/cpu.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/driverlib/rom.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/driverlib/gpio.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/inc/hw_gpio.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/m3/Hwi.h:
C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include/stddef.h:
C:/ti/tirtos_simplelink_2_13_00_06/packages/ti/drivers/dma/UDMACC26XX.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/driverlib/udma.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/inc/hw_udma.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/cc26xx/Power.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/cc26xx/package/package.defs.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/IPower.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/cc26xx/PowerCC2650.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/cc26xx/Power.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Semaphore.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/m3/Hwi.h:
C:/ti/tirtos_simplelink_2_13_00_06/packages/ti/drivers/lcd/LCDDogm1286.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/family/arm/m3/Hwi.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Semaphore.h:
C:/ti/tirtos_simplelink_2_13_00_06/packages/ti/drivers/lcd/LCDDogm1286_util.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/driverlib/ssi.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/cc26xxware_2_21_01_15600/inc/hw_ssi.h:
|
D
|
/Users/ryoto/Work/CITest/DerivedData/CITest/Build/Intermediates/CITest.build/Debug-iphonesimulator/CITest.build/Objects-normal/x86_64/AppDelegate.o : /Users/ryoto/Work/CITest/CITest/ViewController.swift /Users/ryoto/Work/CITest/CITest/AppDelegate.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Security.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/CoreImage.swiftmodule
/Users/ryoto/Work/CITest/DerivedData/CITest/Build/Intermediates/CITest.build/Debug-iphonesimulator/CITest.build/Objects-normal/x86_64/AppDelegate~partial.swiftmodule : /Users/ryoto/Work/CITest/CITest/ViewController.swift /Users/ryoto/Work/CITest/CITest/AppDelegate.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Security.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/CoreImage.swiftmodule
/Users/ryoto/Work/CITest/DerivedData/CITest/Build/Intermediates/CITest.build/Debug-iphonesimulator/CITest.build/Objects-normal/x86_64/AppDelegate~partial.swiftdoc : /Users/ryoto/Work/CITest/CITest/ViewController.swift /Users/ryoto/Work/CITest/CITest/AppDelegate.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Security.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/CoreImage.swiftmodule
|
D
|
//
//----------------------------------------------------------------------
// Copyright 2007-2011 Mentor Graphics Corporation
// Copyright 2007-2010 Cadence Design Systems, Inc.
// Copyright 2010 Synopsys, Inc.
// Copyright 2014 Coverify Systems Technology
// All Rights Reserved Worldwide
//
// Licensed under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of
// the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in
// writing, software distributed under the License is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See
// the License for the specific language governing
// permissions and limitations under the License.
//----------------------------------------------------------------------
// Title: UVM Run-Time Phases
//
// The run-time schedule is the pre-defined phase schedule
// which runs concurrently to the <uvm_run_phase> global run phase.
// By default, all <uvm_component>s using the run-time schedule
// are synchronized with respect to the pre-defined phases in the schedule.
// It is possible for components to belong to different domains
// in which case their schedules can be unsynchronized.
//
// The run-time phases are executed in the sequence they are specified below.
//
//
// Class: uvm_pre_reset_phase
//
// Before reset is asserted.
//
// <uvm_task_phase> that calls the
// <uvm_component::pre_reset_phase> method. This phase starts at the
// same time as the <uvm_run_phase> unless a user defined phase is inserted
// in front of this phase.
//
// Upon Entry:
// - Indicates that power has been applied but not necessarily valid or stable.
// - There should not have been any active clock edges
// before entry into this phase.
//
// Typical Uses:
// - Wait for power good.
// - Components connected to interfaces should initialize
// their output to X's or Z's.
// - Initialize the clock signals to a valid value
// - Assign reset signals to X (power-on reset).
// - Wait for reset signal to be asserted
// if not driven by the verification environment.
//
// Exit Criteria:
// - Reset signal, if driven by the verification environment,
// is ready to be asserted.
// - Reset signal, if not driven by the verification environment, is asserted.
//
module uvm.base.uvm_runtime_phases;
import uvm.base.uvm_task_phase;
import uvm.base.uvm_phase;
import uvm.base.uvm_component;
import uvm.meta.misc;
class uvm_pre_reset_phase: uvm_task_phase
{
static class uvm_once
{
uvm_pre_reset_phase _m_inst;
uvm_pre_reset_phase m_inst() {
synchronized(this) {
if(_m_inst is null) {
_m_inst = new uvm_pre_reset_phase();
}
return _m_inst;
}
}
}
mixin uvm_once_sync;
// task
final override public void exec_task(uvm_component comp, uvm_phase phase) {
comp.pre_reset_phase(phase);
}
enum string type_name = "uvm_pre_reset_phase";
static public uvm_pre_reset_phase get() {
return m_inst;
}
protected this(string name="pre_reset") {
super(name);
}
final override public string get_type_name() {
return type_name;
}
}
//
// Class: uvm_reset_phase
//
// Reset is asserted.
//
// <uvm_task_phase> that calls the
// <uvm_component::reset_phase> method.
//
// Upon Entry:
// - Indicates that the hardware reset signal is ready to be asserted.
//
// Typical Uses:
// - Assert reset signals.
// - Components connected to interfaces should drive their output
// to their specified reset or idle value.
// - Components and environments should initialize their state variables.
// - Clock generators start generating active edges.
// - De-assert the reset signal(s) just before exit.
// - Wait for the reset signal(s) to be de-asserted.
//
// Exit Criteria:
// - Reset signal has just been de-asserted.
// - Main or base clock is working and stable.
// - At least one active clock edge has occurred.
// - Output signals and state variables have been initialized.
//
class uvm_reset_phase: uvm_task_phase
{
static class uvm_once
{
uvm_reset_phase _m_inst;
uvm_reset_phase m_inst() {
synchronized(this) {
if(_m_inst is null) {
_m_inst = new uvm_reset_phase();
}
return _m_inst;
}
}
}
mixin uvm_once_sync;
// task
final override public void exec_task(uvm_component comp, uvm_phase phase) {
comp.reset_phase(phase);
}
enum string type_name = "uvm_reset_phase";
static public uvm_reset_phase get() {
return m_inst;
}
protected this(string name="reset") {
super(name);
}
final override public string get_type_name() {
return type_name;
}
}
// Class: uvm_post_reset_phase
//
// After reset is de-asserted.
//
// <uvm_task_phase> that calls the
// <uvm_component::post_reset_phase> method.
//
// Upon Entry:
// - Indicates that the DUT reset signal has been de-asserted.
//
// Typical Uses:
// - Components should start behavior appropriate for reset being inactive.
// For example, components may start to transmit idle transactions
// or interface training and rate negotiation.
// This behavior typically continues beyond the end of this phase.
//
// Exit Criteria:
// - The testbench and the DUT are in a known, active state.
//
class uvm_post_reset_phase: uvm_task_phase
{
static class uvm_once
{
uvm_post_reset_phase _m_inst;
uvm_post_reset_phase m_inst() {
synchronized(this) {
if(_m_inst is null) {
_m_inst = new uvm_post_reset_phase();
}
return _m_inst;
}
}
}
mixin uvm_once_sync;
// task
final override public void exec_task(uvm_component comp, uvm_phase phase) {
comp.post_reset_phase(phase);
}
enum string type_name = "uvm_post_reset_phase";
static public uvm_post_reset_phase get() {
return m_inst;
}
protected this(string name="post_reset") {
super(name);
}
final override public string get_type_name() {
return type_name;
}
}
// Class: uvm_pre_configure_phase
//
// Before the DUT is configured by the SW.
//
// <uvm_task_phase> that calls the
// <uvm_component::pre_configure_phase> method.
//
// Upon Entry:
// - Indicates that the DUT has been completed reset
// and is ready to be configured.
//
// Typical Uses:
// - Procedurally modify the DUT configuration information as described
// in the environment (and that will be eventually uploaded into the DUT).
// - Wait for components required for DUT configuration to complete
// training and rate negotiation.
//
// Exit Criteria:
// - DUT configuration information is defined.
//
class uvm_pre_configure_phase: uvm_task_phase
{
static class uvm_once
{
uvm_pre_configure_phase _m_inst;
uvm_pre_configure_phase m_inst() {
synchronized(this) {
if(_m_inst is null) {
_m_inst = new uvm_pre_configure_phase();
}
return _m_inst;
}
}
}
mixin uvm_once_sync;
// task
final override public void exec_task(uvm_component comp, uvm_phase phase) {
comp.pre_configure_phase(phase);
}
enum string type_name = "uvm_pre_configure_phase";
static public uvm_pre_configure_phase get() {
return m_inst;
}
protected this(string name="pre_configure") {
super(name);
}
final override public string get_type_name() {
return type_name;
}
}
// Class: uvm_configure_phase
//
// The SW configures the DUT.
//
// <uvm_task_phase> that calls the
// <uvm_component::configure_phase> method.
//
// Upon Entry:
// - Indicates that the DUT is ready to be configured.
//
// Typical Uses:
// - Components required for DUT configuration execute transactions normally.
// - Set signals and program the DUT and memories
// (e.g. read/write operations and sequences)
// to match the desired configuration for the test and environment.
//
// Exit Criteria:
// - The DUT has been configured and is ready to operate normally.
//
class uvm_configure_phase: uvm_task_phase
{
static class uvm_once
{
uvm_configure_phase _m_inst;
uvm_configure_phase m_inst() {
synchronized(this) {
if(_m_inst is null) {
_m_inst = new uvm_configure_phase();
}
return _m_inst;
}
}
}
mixin uvm_once_sync;
// task
final override public void exec_task(uvm_component comp, uvm_phase phase) {
comp.configure_phase(phase);
}
enum string type_name = "uvm_configure_phase";
static public uvm_configure_phase get() {
return m_inst;
}
protected this(string name="configure") {
super(name);
}
final override public string get_type_name() {
return type_name;
}
}
// Class: uvm_post_configure_phase
//
// After the SW has configured the DUT.
//
// <uvm_task_phase> that calls the
// <uvm_component::post_configure_phase> method.
//
// Upon Entry:
// - Indicates that the configuration information has been fully uploaded.
//
// Typical Uses:
// - Wait for configuration information to fully propagate and take effect.
// - Wait for components to complete training and rate negotiation.
// - Enable the DUT.
// - Sample DUT configuration coverage.
//
// Exit Criteria:
// - The DUT has been fully configured and enabled
// and is ready to start operating normally.
//
class uvm_post_configure_phase: uvm_task_phase
{
static class uvm_once
{
uvm_post_configure_phase _m_inst;
uvm_post_configure_phase m_inst() {
synchronized(this) {
if(_m_inst is null) {
_m_inst = new uvm_post_configure_phase();
}
return _m_inst;
}
}
}
mixin uvm_once_sync;
// task
final override public void exec_task(uvm_component comp, uvm_phase phase) {
comp.post_configure_phase(phase);
}
enum string type_name = "uvm_post_configure_phase";
static public uvm_post_configure_phase get() {
return m_inst;
}
protected this(string name="post_configure") {
super(name);
}
final override public string get_type_name() {
return type_name;
}
}
// Class: uvm_pre_main_phase
//
// Before the primary test stimulus starts.
//
// <uvm_task_phase> that calls the
// <uvm_component::pre_main_phase> method.
//
// Upon Entry:
// - Indicates that the DUT has been fully configured.
//
// Typical Uses:
// - Wait for components to complete training and rate negotiation.
//
// Exit Criteria:
// - All components have completed training and rate negotiation.
// - All components are ready to generate and/or observe normal stimulus.
//
class uvm_pre_main_phase: uvm_task_phase
{
static class uvm_once
{
uvm_pre_main_phase _m_inst;
uvm_pre_main_phase m_inst() {
synchronized(this) {
if(_m_inst is null) {
_m_inst = new uvm_pre_main_phase();
}
return _m_inst;
}
}
}
mixin uvm_once_sync;
// task
final override public void exec_task(uvm_component comp, uvm_phase phase) {
comp.pre_main_phase(phase);
}
enum string type_name = "uvm_pre_main_phase";
static public uvm_pre_main_phase get() {
return m_inst;
}
protected this(string name="pre_main") {
super(name);
}
final override public string get_type_name() {
return type_name;
}
}
// Class: uvm_main_phase
//
// Primary test stimulus.
//
// <uvm_task_phase> that calls the
// <uvm_component::main_phase> method.
//
// Upon Entry:
// - The stimulus associated with the test objectives is ready to be applied.
//
// Typical Uses:
// - Components execute transactions normally.
// - Data stimulus sequences are started.
// - Wait for a time-out or certain amount of time,
// or completion of stimulus sequences.
//
// Exit Criteria:
// - Enough stimulus has been applied to meet the primary
// stimulus objective of the test.
//
class uvm_main_phase: uvm_task_phase
{
static class uvm_once
{
uvm_main_phase _m_inst;
uvm_main_phase m_inst() {
synchronized(this) {
if(_m_inst is null) {
_m_inst = new uvm_main_phase();
}
return _m_inst;
}
}
}
mixin uvm_once_sync;
// task
final override public void exec_task(uvm_component comp, uvm_phase phase) {
comp.main_phase(phase);
}
enum string type_name = "uvm_main_phase";
static public uvm_main_phase get() {
return m_inst;
}
protected this(string name="main") {
super(name);
}
final override public string get_type_name() {
return type_name;
}
}
// Class: uvm_post_main_phase
//
// After enough of the primary test stimulus.
//
// <uvm_task_phase> that calls the
// <uvm_component::post_main_phase> method.
//
// Upon Entry:
// - The primary stimulus objective of the test has been met.
//
// Typical Uses:
// - Included for symmetry.
//
// Exit Criteria:
// - None.
//
class uvm_post_main_phase: uvm_task_phase
{
static class uvm_once
{
uvm_post_main_phase _m_inst;
uvm_post_main_phase m_inst() {
synchronized(this) {
if(_m_inst is null) {
_m_inst = new uvm_post_main_phase();
}
return _m_inst;
}
}
}
mixin uvm_once_sync;
// task
final override public void exec_task(uvm_component comp, uvm_phase phase) {
comp.post_main_phase(phase);
}
enum string type_name = "uvm_post_main_phase";
static public uvm_post_main_phase get() {
return m_inst;
}
protected this(string name="post_main") {
super(name);
}
final override public string get_type_name() {
return type_name;
}
}
// Class: uvm_pre_shutdown_phase
//
// Before things settle down.
//
// <uvm_task_phase> that calls the
// <uvm_component::pre_shutdown_phase> method.
//
// Upon Entry:
// - None.
//
// Typical Uses:
// - Included for symmetry.
//
// Exit Criteria:
// - None.
//
class uvm_pre_shutdown_phase: uvm_task_phase
{
static class uvm_once
{
uvm_pre_shutdown_phase _m_inst;
uvm_pre_shutdown_phase m_inst() {
synchronized(this) {
if(_m_inst is null) {
_m_inst = new uvm_pre_shutdown_phase();
}
return _m_inst;
}
}
}
mixin uvm_once_sync;
// task
final override public void exec_task(uvm_component comp, uvm_phase phase) {
comp.pre_shutdown_phase(phase);
}
enum string type_name = "uvm_pre_shutdown_phase";
static public uvm_pre_shutdown_phase get() {
return m_inst;
}
protected this(string name="pre_shutdown") {
super(name);
}
final override public string get_type_name() {
return type_name;
}
}
// Class: uvm_shutdown_phase
//
// Letting things settle down.
//
// <uvm_task_phase> that calls the
// <uvm_component::shutdown_phase> method.
//
// Upon Entry:
// - None.
//
// Typical Uses:
// - Wait for all data to be drained out of the DUT.
// - Extract data still buffered in the DUT,
// usually through read/write operations or sequences.
//
// Exit Criteria:
// - All data has been drained or extracted from the DUT.
// - All interfaces are idle.
//
class uvm_shutdown_phase: uvm_task_phase
{
static class uvm_once
{
uvm_shutdown_phase _m_inst;
uvm_shutdown_phase m_inst() {
synchronized(this) {
if(_m_inst is null) {
_m_inst = new uvm_shutdown_phase();
}
return _m_inst;
}
}
}
mixin uvm_once_sync;
// task
final override public void exec_task(uvm_component comp, uvm_phase phase) {
comp.shutdown_phase(phase);
}
enum string type_name = "uvm_shutdown_phase";
static public uvm_shutdown_phase get() {
return m_inst;
}
protected this(string name="shutdown") {
super(name);
}
final override public string get_type_name() {
return type_name;
}
}
// Class: uvm_post_shutdown_phase
//
// After things have settled down.
//
// <uvm_task_phase> that calls the
// <uvm_component::post_shutdown_phase> method. The end of this phase is
// synchronized to the end of the <uvm_run_phase> phase unless a user defined
// phase is added after this phase.
//
// Upon Entry:
// - No more "data" stimulus is applied to the DUT.
//
// Typical Uses:
// - Perform final checks that require run-time access to the DUT
// (e.g. read accounting registers or dump the content of memories).
//
// Exit Criteria:
// - All run-time checks have been satisfied.
// - The <uvm_run_phase> phase is ready to end.
//
class uvm_post_shutdown_phase: uvm_task_phase
{
static class uvm_once
{
uvm_post_shutdown_phase _m_inst;
uvm_post_shutdown_phase m_inst() {
synchronized(this) {
if(_m_inst is null) {
_m_inst = new uvm_post_shutdown_phase();
}
return _m_inst;
}
}
}
mixin uvm_once_sync;
// task
final override public void exec_task(uvm_component comp, uvm_phase phase) {
comp.post_shutdown_phase(phase);
}
enum string type_name = "uvm_post_shutdown_phase";
static public uvm_post_shutdown_phase get() {
return m_inst;
}
protected this(string name="post_shutdown") {
super(name);
}
final override public string get_type_name() {
return type_name;
}
}
|
D
|
<?xml version="1.0" encoding="UTF-8"?>
<di:SashWindowsMngr xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi">
<pageList>
<availablePage>
<emfPageIdentifier href="FileControl.notation#_3WlFUOVZEeKaPs8U9gcP2w"/>
</availablePage>
<availablePage>
<emfPageIdentifier href="FileControl.notation#_NdnL4OVwEeKaPs8U9gcP2w"/>
</availablePage>
</pageList>
<sashModel currentSelection="//@sashModel/@windows.0/@children.0">
<windows>
<children xsi:type="di:TabFolder">
<children>
<emfPageIdentifier href="FileControl.notation#_3WlFUOVZEeKaPs8U9gcP2w"/>
</children>
<children>
<emfPageIdentifier href="FileControl.notation#_NdnL4OVwEeKaPs8U9gcP2w"/>
</children>
</children>
</windows>
</sashModel>
</di:SashWindowsMngr>
|
D
|
a small piece of paper that is supposed to be removed when a hole is punched in a card or paper tape
a lake in north central Africa
a landlocked desert republic in north-central Africa
a family of Afroasiatic tonal languages (mostly two tones) spoken in the regions west and south of Lake Chad in north central Africa
|
D
|
// Copyright Ferdinand Majerech 2013-2014.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
module tharsis.entity.prototypemanager;
import core.sync.rwmutex;
import std.algorithm;
import std.typecons;
import tharsis.entity.componenttypeinfo;
import tharsis.entity.componenttypemanager;
import tharsis.entity.entitymanager;
import tharsis.entity.entityprototype;
import tharsis.entity.resourcemanager;
import tharsis.util.interfaces;
import tharsis.util.mallocarray;
import tharsis.util.pagedarray;
import tharsis.util.qualifierhacks;
import tharsis.util.typecons;
// TODO: Add a method to specify resources to preload at start instead of always
// loading on demand. Try to find a generic way to do this for all or most
// (e.g. only with StringDescriptors-files) resources/resourcemanagers.
// TODO: Try creating an universal Prototype resource and turning
// BasePrototypeManager into PrototypeManager.
// TODO: Add an error log with info for every failed load on why it failed.
/// Base class for resource managers managing entity prototypes.
///
/// There may be various entity prototype resource types (e.g. defined in a file
/// or directly in a Source); these should be managed by separate resource
/// managers derived from BasePrototypeManager templated with the resource type.
///
/// The Resource type should define following members in addition to the
/// Descriptor type required by ResourceManager:
///
/// // Constructor from descriptor.
/// this(ref Descriptor);
/// // The prototype stored by the resource (once loaded)
/// EntityPrototype prototype;
/// // Descriptor describing this resource.
/// Descriptor descriptor;
/// // The current resource state.
/// ResourceState state;
///
/// For an example Resource type, see
/// tharsis.entity.entityprototype.EntityPrototypeResource .
class BasePrototypeManager(Resource) : ResourceManager!Resource
{
/// Loads a resource, setting its state to Loaded on success or LoadFailed
/// on failure.
///
/// Using a delegate allows loadResource_ to be defined in a templated
/// constructor without templating the class with extra template parameters
/// (avoiding e.g. templating the prototype manager with Source).
void delegate(ref Resource) @safe nothrow loadResource_;
/// Entity prototype resources are stored here.
///
/// When a resource handle corresponding to a descriptor is first requested,
/// an empty resource with that descriptor is added to resourcesToAdd_.
/// Between game updates, those resources are moved to resources_. This
/// allows us to avoid locking on every read from resources_, instead only
/// locking resourcesToAdd_ when read/written.
/// The state of newly added resources is ResourceState.New . Once in
/// resources_, a resource can be modified and loaded (even asynchronously)
/// by the prototype manager. After loading, the resource state is changed
/// to ResourceState.Loaded if loaded successfully or
/// ResourceState.LoadFailed if the loading failed. Once loaded, a resource
/// is immutable and may not be modified, allowing lock-less reading from
/// multiple threads.
PagedArray!Resource resources_;
/// Resources are staged here after initial creation in a handle() call with
/// a new descriptor and until the game update ends. Then they are moved to
/// resources_. Shared; may be written to and/or read by multiple threads.
/// A class wrapper is used since destructors can't destroy shared struct
/// members as of DMD 2.054.
///
/// See_Also: resources_
shared(Class!(MallocArray!Resource)) resourcesToAdd_;
/// Mutex used to lock resourcesToAdd_.
ReadWriteMutex resourcesToAddMutex_;
/// Indices of prototypes requested to be loaded by the user.
///
/// May contain duplicates or indices of already loaded prototypes; these
/// will be ignored. Shared; may be written to or read by multiple threads.
/// A class wrapper is used since destructors can't destroy shared struct
/// members as of DMD 2.054.
shared(Class!(MallocArray!uint)) indicesToLoad_;
/// Mutex used to lock indicesToLoad_.
ReadWriteMutex indicesToLoadMutex_;
/// Memory used by loaded (immutable) entity prototypes in resources_ to
/// store components.
PartiallyMutablePagedBuffer prototypeData_;
public:
/// BasePrototypeManager constructor.
///
/// Params: Source = Type of source to load prototypes from
/// (e.g. YAMLSource).
/// Policy = Policy used with the entity manager,
/// specifying compile-time tweakables.
/// componentTypeManager = Component type manager where all used
/// component types are registered.
/// entityManager = The entity manager.
/// getPrototypeSource = A delegate that takes a resource
/// descriptor (of Descriptor type defined by
/// the Resource type that is a template
/// parameter of the prototype manager) and
/// returns a Source storing an entity
/// prototype. The returned source may be
/// null (Source.isNull == true) if the
/// source could not be loaded.
this(Source, Policy)
(ComponentTypeManager!(Source, Policy) componentTypeManager,
EntityManager!Policy entityManager,
Source delegate(ref Descriptor) nothrow getPrototypeSource)
{
resourcesToAdd_ = new shared(Class!(MallocArray!Resource))();
indicesToLoad_ = new shared(Class!(MallocArray!uint))();
// Write access should be very rare, but if it happens, give it a
// priority to ensure it ends ASAP
resourcesToAddMutex_ =
new ReadWriteMutex(ReadWriteMutex.Policy.PREFER_WRITERS);
indicesToLoadMutex_ =
new ReadWriteMutex(ReadWriteMutex.Policy.PREFER_WRITERS);
/// Load a component of type componentType from componentSource to
/// prototype.
///
/// Params: componentType = Type of the component to load.
/// componentSource = Source to load the component from.
/// prototype = Prototype to load the component into.
/// Must not be locked yet.
///
/// Returns: true if the component was successfully loaded,
/// false otherwise.
bool loadComponent(ref const(ComponentTypeInfo) componentType,
ref Source componentSource,
ref EntityPrototype prototype) nothrow
{
ubyte[] storage = prototype.allocateComponent(componentType);
if(!componentType.loadComponent(storage, componentSource,
&entityManager.rawResourceHandle))
{
// Failed to load the component.
return false;
}
return true;
}
/// Load components of a multicomponent type componentType from
/// sequence to prototype.
///
/// Params: componentType = Type of components to load. Must be a
/// MultiComponent type.
/// sequence = Source storing a sequence of components.
/// prototype = Prototype to load the components into.
/// Must not be locked yet.
///
/// Returns: true if the components successfully loaded,
/// false if either a) there are zero components (sequence is
/// empty, b) one or more components could not be loaded, or
/// c) there are more components than the maximum number of
/// components of type componentType in a single entity (this
/// limit is specified in a MultiComponent type definition).
bool loadMultiComponent(ref const(ComponentTypeInfo) componentType,
ref Source sequence,
ref EntityPrototype prototype) nothrow
{
size_t count = 0;
Source componentSource;
while(sequence.getSequenceValue(count, componentSource))
{
if(!loadComponent(componentType, componentSource, prototype))
{
return false;
}
++count;
if(count > componentType.maxPerEntity)
{
// Too many components of this type.
return false;
}
}
// Zero components of this type (or a non-sequence Source): loading
// failed.
if(count == 0)
{
return false;
}
return true;
}
/// Load an entity prototype resource.
///
/// Params: resource = The resource to load. State of the resource will
/// be set to Loaded if loaded successfully,
/// LoadFailed otherwise.
void loadResource(ref Resource resource) @trusted nothrow
{
auto typeMgr = componentTypeManager;
// Get the source (e.g. YAML) storing the prototype. May fail e.g if
// getPrototypeSource looks for the source in a nonexistent file.
Source source = getPrototypeSource(resource.descriptor);
if(source.isNull)
{
resource.state = ResourceState.LoadFailed;
return;
}
// A shortcut pointer for less typing.
EntityPrototype* prototype = &resource.prototype;
// Provide memory to the prototype.
ubyte[] storage =
prototypeData_.getBytes(prototype.maxPrototypeBytes(typeMgr));
prototype.useMemory(storage);
const ComponentTypeInfo[] typeInfo = typeMgr.componentTypeInfo[];
scope(exit)
{
assert([ResourceState.Loaded, ResourceState.LoadFailed]
.canFind(resource.state),
"Unexpected prototype resource state after loading");
const loaded = resource.state == ResourceState.Loaded;
// The prototype should return any memory it does not use.
prototypeData_.lockBytes(loaded
? prototype.lockAndTrimMemory(typeInfo)
: storage[0 .. 0]);
}
// Load components of the entity.
// Look for components of all component types.
foreach(ref type; typeInfo) if(!type.isNull)
{
Source compSrc;
// No component of this type in the source.
if(!source.getMappingValue(type.sourceName, compSrc))
{
continue;
}
if(type.isMulti ? !loadMultiComponent(type, compSrc, *prototype)
: !loadComponent(type, compSrc, *prototype))
{
resource.state = ResourceState.LoadFailed;
return;
}
}
resource.state = ResourceState.Loaded;
return;
}
loadResource_ = &loadResource;
// 4 kiB won't kill us and it's likely that we won't load this many
// new prototypes during one game update. No locking because the
// PrototypeManager is constructed before process threads run.
indicesToLoad_.assumeUnshared.reserve(1024);
}
/// Deallocate all resource arrays.
override void clear() @trusted
{
// These are class objects, so they need to be destroyed manually.
destroy(resourcesToAdd_.assumeUnshared.self_);
destroy(indicesToLoad_.assumeUnshared.self_);
destroy(resources_);
destroy(prototypeData_);
}
// Lock-free unless requesting a handle to an unknown resource (the first
// time a handle is requested for any given descriptor), or requesting a
// handle to a resource that became known only during the current game
// update.
//
// May be used outside of a Process, e.g. by the user when loading the first
// entity prototype at the beginning of a game.
override Handle handle(ref Descriptor descriptor) @trusted nothrow
{
// If the resource already exists, return a handle to it.
foreach(idx; 0 .. resources_.length)
{
if(resources_.atConst(idx).descriptor.mapsToSameHandle(descriptor))
{
return Handle(cast(RawResourceHandle)idx);
}
}
// Hack to make nothrow work with synchronized.
static Handle synced(ref Descriptor descriptor,
BasePrototypeManager self)
{
auto resourcesToAdd = self.resourcesToAdd_.assumeUnshared;
auto mutex = self.resourcesToAddMutex_;
// The descriptor may have been used to create a new resource
// earlier during this game update. This should happen very rarely.
synchronized(mutex.reader) foreach(idx; 0 .. resourcesToAdd.length)
{
if(resourcesToAdd[idx].descriptor.mapsToSameHandle(descriptor))
{
return Handle(cast(RawResourceHandle)
(self.resources_.length + idx));
}
}
// New resource is being added. This should happen rarely (relative
// to the total number of handle() calls).
synchronized(mutex.writer)
{
resourcesToAdd ~= Resource(descriptor);
// Will be at this index once contents of resourcesToAdd_ are
// appended to resources_ when the next game update starts.
return Handle(cast(RawResourceHandle)(self.resourceCount - 1));
}
}
alias Handle function(ref Descriptor, BasePrototypeManager) nothrow
Synced;
return (cast(Synced)&synced)(descriptor, this);
}
// Always lock-free in the release build. Locks in the debug build to run
// an assertion.
final override ResourceState state(const Handle handle)
@trusted pure nothrow
{
// Usually the handle points to a resource created before the current
// game update.
if(handle.rawHandle < resources_.length)
{
return resources_.atConst(handle.rawHandle).state;
}
// This can only happen with a newly added resource that's still in
// resourcesToAdd_, meaning it's New at least until the next game update
// starts.
//
// Hack to make nothrow work with synchronized.
static void synced(Handle handle, BasePrototypeManager self) @trusted
{
debug synchronized(self.resourcesToAddMutex_.reader)
{
assert(handle.rawHandle < self.resourceCount,
"Resource handle out of range");
}
}
alias void function(Handle, BasePrototypeManager) pure nothrow Synced;
(cast(Synced)&synced)(handle, this);
return ResourceState.New;
}
// Lock-free if the resource is already loaded. Locks otherwise.
override void requestLoad(const Handle handle) @trusted nothrow
{
// If resource already loaded, loading or failed to load, do nothing.
if(handle.rawHandle < resources_.length &&
resources_.atConst(handle.rawHandle).state != ResourceState.New)
{
return;
}
// May or may not be loaded. Assume not loaded.
static void synced(Handle handle, BasePrototypeManager self) @trusted
{
synchronized(self.indicesToLoadMutex_.writer)
{
self.indicesToLoad_.assumeUnshared ~= handle.rawHandle;
}
}
alias void function(Handle, BasePrototypeManager) nothrow Synced;
(cast(Synced)&synced)(handle, this);
}
// Lock-free.
final override ref immutable(Resource) resource(const Handle handle)
@trusted pure nothrow
{
// A resource only becomes immutable once it is loaded successfully.
assert(state(handle) == ResourceState.Loaded,
"Can't directly access a resource that is not loaded");
// If loaded, a resource is in resources_.
// (Only New resources can be in resourcesToAdd_.)
return resources_.atImmutable(handle.rawHandle);
}
override Foreachable!(const(Descriptor)) loadFailedDescriptors()
{
class FailedDescriptors: Foreachable!(const(Descriptor))
{
private:
BasePrototypeManager prototypeManager_;
public:
this(BasePrototypeManager prototypeManager)
{
prototypeManager_ = prototypeManager;
}
// Iterates over all resources in resources_ (which are immutable)
// filtering down to descriptors of resources that failed to load.
int opApply(int delegate(ref const(Descriptor)) dg)
{
int result = 0;
foreach(r; 0 .. prototypeManager_.resources_.length)
{
auto resource = &resources_.atConst(r);
if(resource.state != ResourceState.LoadFailed) { continue; }
result = dg(resource.descriptor);
if(result) { break; }
}
return result;
}
}
return new FailedDescriptors(this);
}
protected:
override void update_() @trusted nothrow
{
// No need for synchronization here; this runs between game updates when
// process threads don't run.
// Need to add resources repeatedly; newly loaded resources (prototypes)
// may contain handles adding new resources to resourcesToAdd_.
//
// Even if there are no newly added resources, there may be resources
// requested to be loaded (indicesToLoad_).
while(!resourcesToAdd_.assumeUnshared.empty ||
!indicesToLoad_.assumeUnshared.empty)
{
// DMD (as of DMD 2.053) breaks the release build if we don't
// iterate by reference here.
// foreach(index; indicesToLoad_)
foreach(ref resource; resourcesToAdd_.assumeUnshared)
{
resources_ ~= resource;
}
// We've loaded these now, so clear them.
resourcesToAdd_.assumeUnshared.clear();
// Load prototypes at indices from indicesToLoad_ (if not loaded
// already). May add new resources to resourcesToAdd_.
foreach(ref index; indicesToLoad_.assumeUnshared)
{
const resource = &resources_.atConst(index);
if(resource.state != ResourceState.New) { continue; }
auto resourceMutable = &resources_.atMutable(index);
resourceMutable.state = ResourceState.Loading;
loadResource(*resourceMutable);
if(resourceMutable.state == ResourceState.Loaded)
{
resources_.markImmutable(index);
}
}
indicesToLoad_.assumeUnshared.clear();
}
}
private:
/// Load specified resource.
void loadResource(ref Resource resource) @safe nothrow
{
loadResource_(resource);
}
/// Get the total number of resources, loaded or not.
///
/// Note: Reads resourcesToAdd_ which may be read/modified by multiple
/// threads. Any use of this method should be synchronized.
size_t resourceCount() @trusted pure nothrow const
{
return resources_.length + resourcesToAdd_.assumeUnshared.length;
}
}
/// Manages entity prototypes defined in files, with filename descriptors.
class PrototypeManager: BasePrototypeManager!EntityPrototypeResource
{
public:
/// Construct a PrototypeManager.
///
/// Params: Source = Type of source to load prototypes from
/// (e.g. YAMLSource)
/// Policy = Policy used with the entity manager,
/// specifying compile-time tweakables.
/// componentTypeManager = Component type manager where all used
/// component types are registered.
/// entityManager = The entity manager.
this(Source, Policy)
(ComponentTypeManager!(Source, Policy) componentTypeManager,
EntityManager!Policy entityManager)
{
// An EntityPrototypeResource descriptor contains the file name where
// the prototype is defined. The prototype manager gets the prototype
// source by loading source from that file.
super(componentTypeManager, entityManager,
(ref Descriptor d)
=> componentTypeManager.loadSource(d.fileName));
}
}
unittest
{
PagedArray!EntityPrototypeResource testPrototypes;
}
|
D
|
/**
Provides vibe based applications with a central program entry point.
This module is included automatically through the import 'vibe.d'. It will provide a default
application entry point which parses command line arguments, reads the global vibe configuration
file, and starts the event loop.
The application itself then just has to initialize itself from within a 'static this' module
constructor and perform the appropriate calls to listen for connections or other operations.
If you want to provide your own main function, you have to import vibe.vibe instead of
vibe.d and define a -version=VibeCustomMain. Be sure to call vibe.core.core.runEventLoop
at the end of your main function in this case. Also beware that you have to make appropriate
calls to vibe.core.args.finalizeCommandLineOptions and vibe.core.core.lowerPrivileges to get the
same behavior.
Copyright: © 2012 RejectedSoftware e.K.
License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file.
Authors: Sönke Ludwig
*/
module vibe.appmain;
import vibe.core.args : finalizeCommandLineOptions;
import vibe.core.core : runEventLoop, lowerPrivileges;
import vibe.core.log;
import std.encoding : sanitize;
// only include main if VibeCustomMain is not set
version(VibeCustomMain) {} else:
/**
The predefined vibe.d application entry point.
This function will automatically be executed if you import the module vibe.d in your code. It
will perform default command line parsing and starts the event loop.
*/
int main()
{
version(unittest){
logInfo("All unit tests were successful.");
return 0;
} else {
try if (!finalizeCommandLineOptions()) return 0;
catch (Exception e) {
logDiagnostic("Error processing command line: %s", e.msg);
return 1;
}
lowerPrivileges();
logDiagnostic("Running event loop...");
int status;
debug {
status = runEventLoop();
} else {
try {
status = runEventLoop();
} catch( Throwable th ){
logError("Unhandled exception in event loop: %s", th.msg);
logDiagnostic("Full exception: %s", th.toString().sanitize());
return 1;
}
}
logDiagnostic("Event loop exited with status %d.", status);
return status;
}
}
|
D
|
import std.stdio;
import std.typecons; // Nullable
import std.c.stdlib; // exit()
import std.path;
import std.process;
import std.getopt;
import std.file;
import std.format;
import std.string;
import config;
import dirconfig;
import dini;
import log;
import builder;
import impl;
struct ElixirBuildOptions {
string repo;
string tag;
string id;
string configname;
}
// executables to symlink to after a build is complete
string[] bins = [
"bin/elixir",
"bin/elixirc",
"bin/iex",
"bin/mix"
];
class ExtractImpl : Impl {
string extractsectionname; // [Extract] or [Extract3] in the extract_config file
this() {
IdKey = "Elixirs";
name = "extract";
commands = ["elixir", "elixirc", "iex", "mix"];
installbasedir = getConfigSubdir("elixirs");
repodir = getConfigSubdir("elixir_repos");
appConfigName = "extract_config";
extractsectionname = "Extract";
}
override string[] getBins() {
return bins;
}
override void initOnce() {
log_debug("extract init once");
if(exists(buildNormalizedPath(getConfigDir(), appConfigName))) {
log_debug("extract has already been initialized");
return;
}
mkdirSafe(getConfigDir());
mkdirSafe(buildNormalizedPath(getConfigDir(), "elixirs"));
mkdirSafe(buildNormalizedPath(getConfigDir(), "elixir_repos"));
// create ~/.erln8.d/extract_config file
File config = File(buildNormalizedPath(getConfigDir(), "extract_config"), "w");
// "none" must be left in, otherwise the section will be empty
config.writeln(q"EOS
[Extract]
default_config=default
system_default=
color=true
[Repos]
default=https://github.com/elixir-lang/elixir.git
[Elixirs]
none =
[Configs]
EOS"
);
config.close();
setupBins();
//Ini cfg = getAppConfig();
//doClone(cfg, "default");
}
override void processArgs(string[] args, bool showHelp) {
CommandLineOptions opts;
try {
auto rslt = getopt(
args,
std.getopt.config.passThrough,
"use", "Setup the current directory to use a specific verion of Elixir", &opts.opt_use,
"list", "List installed versions of Elixir", &opts.opt_list,
"remote", "add/delete/show remotes", &opts.opt_remote,
"clone", "Clone a Elixir source repository", &opts.opt_clone,
"fetch", "Update source repos", &opts.opt_fetch,
"build", "Build a specific version of Elixir from source", &opts.opt_build,
"build-latest", "Build the latest tagged version of Elixir from source", &opts.opt_build_latest,
"with-erlang", "Build with a configured version of Erlang", &opts.opt_with_erlang,
"repo", "Specifies repo name to build from", &opts.opt_repo,
"id", "A user assigned name for a version of Elixir", &opts.opt_id,
"config", "Build configuration", &opts.opt_config,
"show", "Show the configured version of Elixir in the current working directory", &opts.opt_show,
"prompt", "Same as above without a newline, suitable to use in a prompt", &opts.opt_prompt,
"configs", "List build configs", &opts.opt_configs,
"repos", "List build repos", &opts.opt_repos,
"force", "Overwrite an erln8.config in the current directory", &opts.opt_force,
"buildable", "List tags to build from configured source repos", &opts.opt_buildable,
"version", "Show the installed version of extract", &opts.opt_version,
"setup-bins", "Regenerate erln8-managed OTP application links", &opts.opt_setup_bins,
"debug", "Show debug output", &opts.opt_debug
);
if(showHelp && rslt.helpWanted) {
// it's an Arrested Development joke
auto bannerMichael = "Usage: " ~ name ~ " [--use <id> --force] [--list] [--remote add|delete|show]\n";
bannerMichael ~= " [--clone <remotename>] [--fetch <remotename>] [--show] [--prompt]\n";
bannerMichael ~= " [--build --id <someid> --repo <remotename> --config <configname>]\n";
bannerMichael ~= " [--buildable] [--configs] \n";
defaultGetoptPrinter(bannerMichael.color(fg.yellow), rslt.options);
exit(0);
}
log_debug(opts);
opts.allargs = args;
currentOpts = opts;
} catch (Exception e) {
writeln(e.msg);
exit(-1);
}
}
override string[] getSymlinkedExecutables() {
string[] all = [];
foreach(bin;bins) {
all = all ~ baseName(bin);
}
return all;
}
void doShow(Ini cfg) {
DirconfigResult dcr = getConfigFromCWD("Elixir");
auto dirini = dcr.ini;
if(dirini.isNull) {
log_fatal("Can't find a configured version of Elixir");
exit(-1);
}
log_debug("Elixir id:", dirini["Config"].getKey("Elixir"));
string elixirid = dirini["Config"].getKey("Elixir");
if(!isValidElixir(cfg, elixirid)) {
log_fatal("Unknown Elixir id: ", elixirid);
exit(-1);
}
if(currentOpts.opt_show) {
auto path = cfg["Elixirs"].getKey(elixirid);
writeln(elixirid, " @ ", path);
} else {
write(elixirid);
}
}
void doUse(Ini cfg) {
auto keys = cfg[IdKey].keys();
log_debug("Trying to use ", currentOpts.opt_use);
string elixirId = currentOpts.opt_use;
if(!(elixirId in keys)) {
writeln(elixirId, " is not a configured version of Elixir");
exit(-1);
}
string fileName = "erln8.config";
if(exists(fileName)) {
if(!currentOpts.opt_force) {
writeln("Config already exists in this directory. Override with --force.");
exit(-1);
}
}
if(currentOpts.opt_force) {
// update the existing file
DirconfigResult dcr = getConfigFromCWD();
auto dircfg = dcr.ini;
IniSection inicfg = dircfg.get().getSection("Config");
inicfg.setKey("Elixir", elixirId);
saveDirConfig(dcr.path, dcr.ini);
} else {
// write a new file
File file = File("erln8.config", "w");
file.writeln("[Config]");
file.writeln("Elixir=", elixirId);
}
}
bool isValidElixir(Ini ini, string id) {
return ini[IdKey].hasKey(id);
}
ElixirBuildOptions getBuildOptions(string repo, string tag, string id, string configname) {
ElixirBuildOptions opts;
opts.repo = (repo == null ? "default" : repo);
opts.tag = tag;
if(opts.id == null) {
opts.id = tag;
} else {
opts.id = id;
}
// TODO: use Elixir.default_config value here
//opts.configname = (configname == null ? "default_config" : configname);
opts.configname = configname;
return opts;
}
void verifyInputs(Ini cfg, ElixirBuildOptions build_options) {
auto elixirs = cfg[IdKey].keys();
if(build_options.id in elixirs) {
writeln("A version of Elixir already exists with the id ", build_options.id);
exit(-1);
}
auto repos = cfg["Repos"].keys();
if(!(build_options.repo in repos)) {
writeln("Unconfigured repo: ", build_options.repo);
exit(-1);
}
string repoURL = cfg["Repos"].getKey(build_options.repo);
string repoPath = buildNormalizedPath(getConfigSubdir(repodir),build_options.repo);
if(!exists(repoPath)) {
writeln("Missing repo for " ~ currentOpts.opt_fetch
~ ", which should be in " ~ repoPath ~ ". Maybe you forgot to extract --clone <repo_name>");
exit(-1);
}
// TODO
//auto configs = cfg["Configs"].keys();
//if(!(build_options.configname in configs)) {
// writeln("Unknown build config: ", build_options.configname);
// exit(-1);
// }
}
void checkObject(ElixirBuildOptions opts, string sourcePath) {
string checkObj = "cd " ~ sourcePath ~ " && git show-ref " ~ opts.tag ~ " > /dev/null";
log_debug(checkObj);
auto shell = executeShell(checkObj);
if(shell.status != 0) {
writeln("branch or tag " ~ opts.tag ~ " does not exist in " ~ opts.repo ~ " Git repo");
log_debug("Git object missing");
exit(-1);
} else {
log_debug("Git object exists");
}
}
// TODO: NEEDS A SYSTEM DEFAULT IF ONE ISN'T SET
override void doBuild(Ini cfg, string tag) {
ElixirBuildOptions opts = getBuildOptions(currentOpts.opt_repo,
tag,
currentOpts.opt_id,
currentOpts.opt_config);
string withErlang = currentOpts.opt_with_erlang;
verifyInputs(cfg, opts);
string outputRoot = buildNormalizedPath(getConfigSubdir(installbasedir),opts.id);
string outputPath = buildNormalizedPath(outputRoot, "dist");
string sourcePath = buildNormalizedPath(getConfigSubdir(repodir), opts.repo);
checkObject(opts, sourcePath);
//if(withErlang != null) {
// auto keys = cfg[IdKey].keys();
// log_debug("Trying to use ", withErlang);
// if(!(withErlang in keys)) {
// writeln(withErlang , " is not a configured version of Erlang");
// exit(-1);
// }
//}
string makeBin = getMakeBin();
// TODO: build config _env
string env = "";
log_debug("Output root = ", outputRoot);
log_debug("Output path = ", outputPath);
log_debug("Source path = ", sourcePath);
string tmp = buildNormalizedPath(tempDir(), getTimestampedFilename());
log_debug("tmp dir = ", tmp);
string logFile = buildNormalizedPath(tmp, "build_log");
log_debug("log = ", tmp);
mkdirRecurse(tmp);
mkdirRecurse(outputPath);
string cmd0 = format("%s cd %s && git archive %s | (cd %s; tar -f - -x)",
env, sourcePath, opts.tag, tmp);
string cmd1;
if(withErlang) {
cmd1 = format("cd %s && echo '[Config]\nErlang=%s\n' > erln8.config", tmp, withErlang);
} else {
cmd1 = format("echo 'Using Erlang system default'");
}
string cmd2 = format("cd %s && perl -p -i -e \"s/PREFIX :=/PREFIX ?=/\" Makefile", tmp);
string cmd3 = format("%s cd %s && make > ./build_log 2>&1",
env, tmp);
string cmd4 = format("%s cd %s && PREFIX=%s make install > ./build_log 2>&1",
env, tmp, outputPath);
Builder b = new Builder();
b.addCommand("Copy source ", cmd0);
b.addCommand("Setup Erlang ", cmd1);
b.addCommand("Patch Makefile ", cmd2);
b.addCommand("Build ", cmd3);
b.addCommand("Install ", cmd4);
if(!b.run()) {
writeln("*** Build failed ***");
writeln("Here are the last 10 lines of " ~ logFile);
auto pid = spawnShell("tail -10 " ~ logFile);
wait(pid);
return;
}
log_debug("Adding Elixir id to ~/.erln8/extract_config");
cfg[IdKey].setKey(opts.id, outputPath);
setupLinks(outputRoot);
saveAppConfig(cfg);
setSystemDefaultIfFirst("Extract", opts.id);
writeln("Done!");
}
override void runConfig() {
Ini cfg = getAppConfig();
if(currentOpts.opt_buildable) {
doBuildable(cfg);
} else if(currentOpts.opt_list) {
doList(cfg);
} else if(currentOpts.opt_repos) {
doRepos(cfg);
} else if(currentOpts.opt_show || currentOpts.opt_prompt) {
doShow(cfg);
} else if(currentOpts.opt_configs) {
doConfigs(cfg);
} else if(currentOpts.opt_use) {
doUse(cfg);
} else if(currentOpts.opt_clone) {
doClone(cfg);
} else if(currentOpts.opt_fetch) {
doFetch(cfg);
} else if(currentOpts.opt_build) {
foreach(b;currentOpts.opt_build) {
doBuild(cfg, b);
}
} else if(currentOpts.opt_build_latest) {
doBuildLatest(cfg);
} else if(currentOpts.opt_version) {
writeln(name, " ", erln8_version);
} else if(currentOpts.opt_setup_bins) {
doSetupBins(cfg);
} else {
log_debug("Nothing to do");
}
}
override void runCommand(string[] cmdline) {
Ini cfg = getAppConfig();
log_debug("Config:", cfg);
log_debug("Running: ", cmdline);
string bin = baseName(cmdline[0]);
DirconfigResult dcr = getConfigFromCWD();
auto dirini = dcr.ini;
string elixirId;
if(dirini.isNull) {
IniSection e8cfg = cfg.getSection(extractsectionname);
if(e8cfg.hasKey("system_default") && e8cfg.getKey("system_default") != null ) {
log_debug("Using system_default ", e8cfg.getKey("system_default"));
elixirId = e8cfg.getKey("system_default");
} else {
log_fatal("Can't find a configured version of Elixir");
exit(-1);
}
} else {
elixirId = dirini["Config"].getKey("Elixir");
log_debug("Elixir id:", dirini["Config"].getKey("Elixir"));
}
if(!isValidElixir(cfg, elixirId)) {
log_fatal("Unknown Elixir id: ", elixirId);
exit(-1);
}
log_debug("installbasedir = ", installbasedir);
log_debug("repodir = ", repodir);
string binFullPath = buildNormalizedPath(installbasedir, elixirId, bin);
log_debug("mapped cmd to execute = ", binFullPath);
auto argsPassthrough = [bin] ~ cmdline[1 .. $];
log_debug("Args = ", argsPassthrough);
execv(binFullPath, argsPassthrough);
}
}
|
D
|
instance Bau_900_Onar(Npc_Default)
{
name[0] = "Онар";
guild = GIL_BAU;
id = 900;
voice = 14;
flags = 0;
npcType = npctype_main;
B_SetAttributesToChapter(self,4);
level = 1;
aivar[93] = TRUE;
fight_tactic = FAI_HUMAN_STRONG;
EquipItem(self,ItMw_1h_Bau_Mace);
B_CreateAmbientInv(self);
B_SetNpcVisual(self,MALE,"Hum_Head_FatBald",Face_N_OldBald_Jeremiah,BodyTex_N,ITAR_Vlk_H);
Mdl_SetModelFatness(self,2);
Mdl_ApplyOverlayMds(self,"Humans_Arrogance.mds");
B_GiveNpcTalents(self);
B_SetFightSkills(self,70);
daily_routine = Rtn_Start_900;
};
func void Rtn_Start_900()
{
TA_Sit_Throne(9,0,21,0,"NW_BIGFARM_HOUSE_ONAR_SIT");
TA_Sleep(21,0,9,0,"NW_BIGFARM_HOUSE_UP1_04");
};
func void rtn_startpass_900()
{
TA_Sit_Throne(9,0,11,45,"NW_BIGFARM_HOUSE_ONAR_SIT");
TA_Stand_Guarding(11,45,13,0,"NW_CRYPT_02");
TA_Stand_Guarding(13,0,13,30,"NW_CRYPT_03");
TA_Stand_Guarding(13,30,14,0,"NW_CRYPT_05");
TA_Sit_Throne(14,0,21,0,"NW_BIGFARM_HOUSE_ONAR_SIT");
TA_Sleep(21,0,9,0,"NW_BIGFARM_HOUSE_UP1_04");
};
func void rtn_comedeath_900()
{
TA_Stand_Guarding(9,0,21,0,"NW_BIGFARM_PATH_04");
TA_Stand_Guarding(21,0,9,0,"NW_BIGFARM_PATH_04");
};
|
D
|
instance DIA_BAU_1_EXIT(C_Info)
{
nr = 999;
condition = DIA_BAU_1_EXIT_Condition;
information = DIA_BAU_1_EXIT_Info;
permanent = TRUE;
description = Dialog_Ende;
};
func int DIA_BAU_1_EXIT_Condition()
{
return TRUE;
};
func void DIA_BAU_1_EXIT_Info()
{
AI_StopProcessInfos(self);
};
instance DIA_BAU_1_HowAU(C_Info)
{
nr = 101;
condition = DIA_BAU_1_HowAU_Condition;
information = DIA_BAU_1_HowAU_Info;
permanent = TRUE;
description = "Как дела?";
};
func int DIA_BAU_1_HowAU_Condition()
{
return TRUE;
};
func void DIA_BAU_1_HowAU_Info()
{
if (hero.voice == 3) {
AI_Output(other,self,"DIA_BAU_HowAU_03_00"); //Как дела?
} else if (hero.voice == 7) {
AI_Output(other,self,"DIA_BAU_HowAU_07_00"); //Как дела?
} else if (hero.voice == 10) {
AI_Output(other,self,"DIA_BAU_HowAU_10_00"); //Как дела?
} else if (hero.voice == 14) {
AI_Output(other,self,"DIA_BAU_HowAU_14_00"); //Как дела?
} else {
AI_Output(other,self,"DIA_BAU_HowAU_16_00"); //Как дела?
};
var int rnd; rnd = Hlp_Random(3);
if (rnd == 0) {
AI_Output(self,other,"DIA_BAU_HowAU_01_01"); //Грех жаловаться. Урожай в этом году хороший.
} else if (rnd == 1) {
AI_Output(self,other,"DIA_BAU_HowAU_01_02"); //Урожай собран, можно ненадолго расслабиться.
} else {
AI_Output(self,other,"DIA_BAU_HowAU_01_03"); //Спина ноет, а так, все, слава Инносу, в порядке.
};
};
instance DIA_BAU_1_News(C_Info)
{
nr = 102;
condition = DIA_BAU_1_News_Condition;
information = DIA_BAU_1_News_Info;
permanent = TRUE;
description = "Что нового?";
};
func int DIA_BAU_1_News_Condition()
{
return TRUE;
};
func void DIA_BAU_1_News_Info()
{
if (hero.voice == 3) {
AI_Output(other,self,"DIA_BAU_News_03_00"); //Что нового?
} else if (hero.voice == 7) {
AI_Output(other,self,"DIA_BAU_News_07_00"); //Что нового?
} else if (hero.voice == 10) {
AI_Output(other,self,"DIA_BAU_News_10_00"); //Что нового?
} else if (hero.voice == 14) {
AI_Output(other,self,"DIA_BAU_News_14_00"); //Что нового?
} else {
AI_Output(other,self,"DIA_BAU_News_16_00"); //Что нового?
};
var int rnd; rnd = Hlp_Random(2);
if (rnd == 0) {
AI_Output(self,other,"DIA_BAU_News_01_01"); //Да ничего...
} else {
AI_Output(self,other,"DIA_BAU_News_01_02"); //Все как обычно.
};
};
func void B_AssignAmbientInfos_BAU_1(var C_Npc slf)
{
dia_BAU_1_exit.npc = Hlp_GetInstanceID(slf);
dia_BAU_1_howau.npc = Hlp_GetInstanceID(slf);
dia_BAU_1_news.npc = Hlp_GetInstanceID(slf);
};
|
D
|
/*******************************************************************************
Copyright: Copyright (C) 2008 Kris Bell. все rights reserved.
License: BSD стиль: $(LICENSE)
version: Initial release: March 2008
Authors: Kris
*******************************************************************************/
module text.xml.DocPrinter;
private import io.model;
private import text.xml.Document;
/*******************************************************************************
Simple Документ printer, with support for serialization caching
where the latter avoопрs having в_ generate unchanged подст-trees
*******************************************************************************/
class ДокПринтер(T)
{
public alias Документ!(T) Док; /// the typed document
public alias Док.Узел Узел; /// генерный document узел
private бул быстро = да;
private бцел indentation = 2;
version (Win32)
private const T[] Кс = "\r\n";
else
private const T[] Кс = "\n";
/***********************************************************************
Sets the число of пробелы использован when increasing indentation
levels. Use a значение of zero в_ disable явный formatting
***********************************************************************/
final ДокПринтер indent (бцел indentation);
/***********************************************************************
Enable or disable use of cached document snИПpets. These
represent document branches that remain unaltered, и
can be излейted verbatim instead of traversing the дерево
***********************************************************************/
final ДокПринтер кэш (бул да);
/***********************************************************************
Generate a текст representation of the document дерево
***********************************************************************/
final T[] выведи (Док doc, T[] контент=пусто)
{
if(контент !is пусто)
выведи (doc.дерево, (T[][] s...)
{
т_мера i=0;
foreach(t; s)
{
if(i+t.length >= контент.length)
throw new ИсклРЯР ("Буфер is в_ small");
контент[i..t.length] = t;
i+=t.length;
}
контент.length = i;
});
else
выведи (doc.дерево, (T[][] s...)
{
foreach(t; s) контент ~= t;
});
return контент;
}
/***********************************************************************
Generate a текст representation of the document дерево
***********************************************************************/
final проц выведи (Док doc, ИПотокВывода поток);
/***********************************************************************
Generate a representation of the given узел-subtree
***********************************************************************/
final проц выведи (Узел корень, проц delegate(T[][]...) излей);
}
debug import text.xml.Document;
debug import util.log.Trace;
unittest
{
ткст document = "<blah><xml>foo</xml></blah>";
auto doc = new Документ!(сим);
doc.разбор (document);
auto p = new ДокПринтер!(сим);
сим[1024] буф;
auto newbuf = p.выведи (doc, буф);
assert(document == newbuf);
assert(буф.ptr == newbuf.ptr);
assert(document == p.выведи(doc));
}
|
D
|
INSTANCE Mod_7738_BDT_Bandit_EIS (Npc_Default)
{
// ------ NSC ------
name = "Bandit";
guild = GIL_STRF;
id = 7738;
voice = 03;
flags = 0;
npctype = NPCTYPE_nw_bandit;
// ------ Attribute ------
B_SetAttributesToChapter (self, 3);
// ------ Kampf-Taktik ------
fight_tactic = FAI_HUMAN_strong;
// ------ Equippte Waffen ------
EquipItem (self, ItMw_Banditenschwert);
// ------ Inventory ------
B_CreateAmbientInv (self);
// ------ visuals ------
B_SetNpcVisual (self, MALE, "Hum_Head_Bald", Face_N_Normal08, BodyTex_N, ITAR_bdt_m_01);
Mdl_SetModelFatness (self, 0);
Mdl_ApplyOverlayMds (self, "Humans_Relaxed.mds");
// ------ NSC-relevante Talente vergeben ------
B_GiveNpcTalents (self);
// ------ Kampf-Talente ------
B_SetFightSkills (self, 45);
// ------ TA anmelden ------
daily_routine = Rtn_Start_7738;
};
FUNC VOID Rtn_Start_7738 ()
{
TA_Cook_Stove (08,00,20,00,"NORDOSTENLOCH_3");
TA_Cook_Stove (20,00,08,00,"NORDOSTENLOCH_3");
};
|
D
|
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
int[3][2] BS;
int[2][3] CS;
int[2] solve(int t, int[3][3] bd)
{
if (t == 9) {
int b, c;
foreach (int ij; 0..9) {
int i = ij/3;
int j = ij%3;
if (i+1 < 3) {
if(bd[i][j] == bd[i+1][j]) {
b += BS[i][j];
} else {
c += BS[i][j];
}
}
if (j+1 < 3) {
if (bd[i][j] == bd[i][j+1]) {
b += CS[i][j];
} else {
c += CS[i][j];
}
}
}
return [b, c];
} else {
auto m = t%2+1;
int max_b = -1, max_c = -1;
foreach (int ij; 0..9) {
auto i = ij/3;
auto j = ij%3;
if (bd[i][j]) continue;
bd[i][j] = m;
auto r = solve(t+1, bd);
if ((m == 1 && r[0] > max_b) || (m == 2 && r[1] > max_c)) {
max_b = r[0];
max_c = r[1];
}
bd[i][j] = 0;
}
return [max_b, max_c];
}
}
void main()
{
foreach (i, b; readln.split.to!(int[])) BS[0][i] = b;
foreach (i, b; readln.split.to!(int[])) BS[1][i] = b;
foreach (i, c; readln.split.to!(int[])) CS[0][i] = c;
foreach (i, c; readln.split.to!(int[])) CS[1][i] = c;
foreach (i, c; readln.split.to!(int[])) CS[2][i] = c;
auto r = solve(0, [[0, 0, 0], [0, 0, 0], [0, 0, 0]]);
writeln(r[0]);
writeln(r[1]);
}
|
D
|
instance DIA_Sonja_EXIT(C_Info)
{
npc = VLK_436_Sonja;
nr = 999;
condition = DIA_Sonja_EXIT_Condition;
information = DIA_Sonja_EXIT_Info;
permanent = TRUE;
description = Dialog_Ende;
};
func int DIA_Sonja_EXIT_Condition()
{
return TRUE;
};
func void DIA_Sonja_EXIT_Info()
{
AI_StopProcessInfos(self);
};
instance DIA_Sonja_PICKPOCKET(C_Info)
{
npc = VLK_436_Sonja;
nr = 900;
condition = DIA_Sonja_PICKPOCKET_Condition;
information = DIA_Sonja_PICKPOCKET_Info;
permanent = TRUE;
description = Pickpocket_60_Female;
};
func int DIA_Sonja_PICKPOCKET_Condition()
{
return C_Beklauen(58,70);
};
func void DIA_Sonja_PICKPOCKET_Info()
{
Info_ClearChoices(DIA_Sonja_PICKPOCKET);
Info_AddChoice(DIA_Sonja_PICKPOCKET,Dialog_Back,DIA_Sonja_PICKPOCKET_BACK);
Info_AddChoice(DIA_Sonja_PICKPOCKET,DIALOG_PICKPOCKET,DIA_Sonja_PICKPOCKET_DoIt);
};
func void DIA_Sonja_PICKPOCKET_DoIt()
{
B_Beklauen();
Info_ClearChoices(DIA_Sonja_PICKPOCKET);
};
func void DIA_Sonja_PICKPOCKET_BACK()
{
Info_ClearChoices(DIA_Sonja_PICKPOCKET);
};
instance DIA_Sonja_STANDARD(C_Info)
{
npc = VLK_436_Sonja;
condition = DIA_Sonja_STANDARD_Condition;
information = DIA_Sonja_STANDARD_Info;
important = TRUE;
permanent = TRUE;
};
func int DIA_Sonja_STANDARD_Condition()
{
if(Npc_IsInState(self,ZS_Talk) && (MIS_Andre_REDLIGHT != LOG_Running))
{
return TRUE;
};
};
func void DIA_Sonja_STANDARD_Info()
{
if(self.aivar[AIV_TalkedToPlayer] == FALSE)
{
AI_Output(self,other,"DIA_Sonja_STANDARD_16_00"); //Если хочешь развлечься, поговори с Бромором.
}
else if((other.guild == GIL_DJG) && (Sonja_Says == FALSE))
{
AI_Output(self,other,"DIA_Sonja_STANDARD_16_01"); //У таких парней как ты одна проблема - вас больше интересуют орки, чем мы.
Sonja_Says = TRUE;
}
else
{
AI_Output(self,other,"DIA_Sonja_STANDARD_16_02"); //Если ты хочешь поговорить, иди, найди себе женщину, и женись на ней.
};
AI_StopProcessInfos(self);
};
|
D
|
/*******************************************************************************
* Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Port to the D programming language:
* Frank Benoit <benoit@tionex.de>
*******************************************************************************/
module dwt.events.MouseTrackAdapter;
import dwt.dwthelper.utils;
import dwt.events.MouseEvent;
import dwt.events.MouseTrackListener;
/**
* This adapter class provides default implementations for the
* methods described by the <code>MouseTrackListener</code> interface.
* <p>
* Classes that wish to deal with <code>MouseEvent</code>s which
* occur as the mouse pointer passes (or hovers) over controls can
* extend this class and override only the methods which they are
* interested in.
* </p>
*
* @see MouseTrackListener
* @see MouseEvent
* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
*/
public abstract class MouseTrackAdapter : MouseTrackListener {
/**
* Sent when the mouse pointer passes into the area of
* the screen covered by a control.
* The default behavior is to do nothing.
*
* @param e an event containing information about the mouse enter
*/
public void mouseEnter(MouseEvent e) {
}
/**
* Sent when the mouse pointer passes out of the area of
* the screen covered by a control.
* The default behavior is to do nothing.
*
* @param e an event containing information about the mouse exit
*/
public void mouseExit(MouseEvent e) {
}
/**
* Sent when the mouse pointer hovers (that is, stops moving
* for an (operating system specified) period of time) over
* a control.
* The default behavior is to do nothing.
*
* @param e an event containing information about the hover
*/
public void mouseHover(MouseEvent e) {
}
}
|
D
|
// **************************************************
// EXIT
// **************************************************
INSTANCE DIA_RBL_2605_GARRY_Exit (C_INFO)
{
npc = RBL_2605_GARRY;
nr = 999;
condition = DIA_RBL_2605_GARRY_Exit_Condition;
information = DIA_RBL_2605_GARRY_Exit_Info;
permanent = 1;
description = DIALOG_ENDE;
};
FUNC INT DIA_RBL_2605_GARRY_Exit_Condition()
{
return 1;
};
FUNC VOID DIA_RBL_2605_GARRY_Exit_Info()
{
B_StopProcessInfos ( self );
};
// **************************************************
// hello
// **************************************************
INSTANCE DIA_RBL_2605_GARRY_Hello (C_INFO)
{
npc = RBL_2605_GARRY;
nr = 1;
condition = DIA_RBL_2605_GARRY_Hello_Condition;
information = DIA_RBL_2605_GARRY_Hello_Info;
permanent = 0;
important = 0;
description = "Ciężko pracujesz.";
};
FUNC INT DIA_RBL_2605_GARRY_Hello_Condition()
{
return 1;
};
FUNC VOID DIA_RBL_2605_GARRY_Hello_Info()
{
AI_Output (other, self, "DIA_RBL_2605_GARRY_Hello_15_01"); //Ciężko pracujesz.
AI_Output (self, other, "DIA_RBL_2605_GARRY_Hello_11_02"); //Praca to mój żywioł, a kowalstwo sprawia, że znowu chcę żyć.
AI_Output (self, other, "DIA_RBL_2605_GARRY_Hello_11_03"); //Nie sądziłem, że to taka radocha. Mogę teraz tworzyć wspaniałą broń!
AI_Output (self, other, "DIA_RBL_2605_GARRY_Hello_11_04"); //Mogę pieścić każde ostrze po wykuciu. Nie ma to jak syk stali w wodzie o poranku...
AI_Output (other, self, "DIA_RBL_2605_GARRY_Hello_15_05"); //Skoro tak twierdzisz.
};
var int garry_fight;
INSTANCE DIA_RBL_2605_GARRY_GoBring (C_INFO)
{
npc = RBL_2605_GARRY;
nr = 2;
condition = DIA_RBL_2605_GARRY_GoBring_Condition;
information = DIA_RBL_2605_GARRY_GoBring_Info;
permanent = 0;
important = 0;
description = "Mam dla Ciebie propozycję nie do odrzucenia.";
};
FUNC INT DIA_RBL_2605_GARRY_GoBring_Condition()
{
if (Npc_KnowsInfo (hero, DIA_RBL_2605_GARRY_Hello))&&(Npc_KnowsInfo (hero, DIA_HUN_859_AIDAN_GoBring))
{
return 1;
};
};
FUNC VOID DIA_RBL_2605_GARRY_GoBring_Info()
{
Npc_SetAivar(self,AIV_WASDEFEATEDBYSC, FALSE); Npc_SetAivar(self,AIV_HASDEFEATEDSC, FALSE);
AI_Output (other, self, "DIA_RBL_2605_GARRY_GoBring_15_01"); //Mam dla Ciebie propozycję nie do odrzucenia.
AI_Output (self, other, "DIA_RBL_2605_GARRY_GoBring_11_02"); //To znaczy?
AI_Output (other, self, "DIA_RBL_2605_GARRY_GoBring_15_03"); //Przestań pastwić się nad kowadłem Aidana!
AI_Output (self, other, "DIA_RBL_2605_GARRY_GoBring_11_04"); //Nic z tego. Jestem świetnym kowalem, a Ty wtrącasz się w nie swoje sprawy.
AI_Output (self, other, "DIA_RBL_2605_GARRY_GoBring_11_05"); //Zejdź mi z oczu.
AI_Output (other, self, "DIA_RBL_2605_GARRY_GoBring_15_06"); //Powiem inaczej.
AI_Output (other, self, "DIA_RBL_2605_GARRY_GoBring_15_07"); //Masz do wyboru dwie opcje.
AI_Output (other, self, "DIA_RBL_2605_GARRY_GoBring_15_08"); //Opcja A. Odkładasz młotek z własnej woli i nie wracasz tu psuć kowadła.
AI_Output (other, self, "DIA_RBL_2605_GARRY_GoBring_15_09"); //Opcja B. To dużo mniej przyjemna wersja opcji A z łamaniem kończyn i obcinaniem palców włącznie.
AI_Output (other, self, "DIA_RBL_2605_GARRY_GoBring_15_10"); //Więc jak będzie? Którą opcję wybierasz?
var C_NPC Quentin; Quentin = Hlp_GetNpc(HUN_858_Quentin);
if (Npc_KnowsInfo (hero, DIA_HUN_858_Quentin_Hello))&&(Npc_GetAivar(Quentin,AIV_WASDEFEATEDBYSC) == TRUE)
{
garry_out = TRUE;
AI_Output (self, other, "DIA_RBL_2605_GARRY_GoBring_11_11"); //Widziałem, jak walczyłeś z Quentinem i raczej nie skorzystam z opcji B.
AI_Output (self, other, "DIA_RBL_2605_GARRY_GoBring_11_12"); //Wiedz jednak, że złamałeś mi serce i zadałeś straszliwy ból mojej duszy artysty...
AI_Output (self, other, "DIA_RBL_2605_GARRY_GoBring_11_13"); //Przez Twoje barbarzyństwo straci też sztuka kowalstwa!
AI_Output (self, other, "DIA_RBL_2605_GARRY_GoBring_11_14"); //Idę się schlać...
B_GiveXP(250);
B_LogEntry (CH1_Rbl_AidanHelp, "Garry widział jak załatwiłem Quentina i zdaje się, że to zaważyło na jego decyzji. Powiedział, że idzie się schlać.");
Npc_ExchangeRoutine (self,"GarryTavern");
B_StopProcessInfos (self);
}
else
{
garry_fight = TRUE;
AI_Output (self, other, "DIA_RBL_2605_GARRY_GoBring_11_15"); //A kim Ty jesteś, żeby mówić mi co mam robić?
AI_Output (self, other, "DIA_RBL_2605_GARRY_GoBring_11_16"); //Niech będzie opcja B, gnojku!
B_LogEntry (CH1_Rbl_AidanHelp, "Garry nie rzuci kowalstwa po dobroci. No nic czas skopać mu rzyć...");
B_SetTimedATT(self,30*events_per_sec,-180,-180,-95);
B_StopProcessInfos (self);
B_StartAfterDialogFight(self,other,false);
};
};
INSTANCE DIA_RBL_2605_GARRY_After (C_INFO)
{
npc = RBL_2605_GARRY;
nr = 3;
condition = DIA_RBL_2605_GARRY_After_Condition;
information = DIA_RBL_2605_GARRY_After_Info;
permanent = 0;
important = 0;
description = "Idziemy!";
};
FUNC INT DIA_RBL_2605_GARRY_After_Condition()
{
if (garry_fight == TRUE)&&(Npc_GetAivar(self,AIV_WASDEFEATEDBYSC) == TRUE)
{
return 1;
};
};
FUNC VOID DIA_RBL_2605_GARRY_After_Info()
{
garry_out = TRUE;
AI_Output (other, self, "DIA_RBL_2605_GARRY_After_15_01"); //Idziemy!
AI_Output (self, other, "DIA_RBL_2605_GARRY_After_11_02"); //Uspokój się. Złamałeś nie tylko mego ducha, ale i serce.
AI_Output (self, other, "DIA_RBL_2605_GARRY_After_11_03"); //Przez twoje barbarzyństwo straci też sztuka kowalstwa!
AI_Output (self, other, "DIA_RBL_2605_GARRY_After_11_04"); //Idę się schlać...
B_GiveXP(150);
B_LogEntry (CH1_Rbl_AidanHelp, "Solidne lanie pomogło Garremu podjąć decyzję. Już nie wróci do Aidana i poszedł się schlać.");
Npc_ExchangeRoutine (self,"GarryTavern");
B_StopProcessInfos (self);
};
INSTANCE DIA_RBL_2605_GARRY_After1 (C_INFO)
{
npc = RBL_2605_GARRY;
nr = 4;
condition = DIA_RBL_2605_GARRY_After1_Condition;
information = DIA_RBL_2605_GARRY_After1_Info;
permanent = 0;
important = 0;
description = "Topisz żale w winie?";
};
FUNC INT DIA_RBL_2605_GARRY_After1_Condition()
{
if (garry_out == TRUE)&&(Npc_GetDistToWP (self,"GARRY") < 1000 ) //wp w którym siedzi w tawernie
{
return 1;
};
};
FUNC VOID DIA_RBL_2605_GARRY_After1_Info()
{
AI_Output (other, self, "DIA_RBL_2605_GARRY_After1_15_01"); //Topisz żale w winie?
AI_Output (self, other, "DIA_RBL_2605_GARRY_After1_11_02"); //A co Cię to obchodzi?
AI_Output (self, other, "DIA_RBL_2605_GARRY_After1_11_03"); //Przez Ciebie nie mam teraz co robić.
AI_Output (self, other, "DIA_RBL_2605_GARRY_After1_11_04"); //Do cholery, nie mam nawet za co chlać...
};
INSTANCE DIA_RBL_2605_GARRY_After2 (C_INFO)
{
npc = RBL_2605_GARRY;
nr = 5;
condition = DIA_RBL_2605_GARRY_After2_Condition;
information = DIA_RBL_2605_GARRY_After2_Info;
permanent = 0;
important = 0;
description = "Może to cię zainteresuje...";
};
FUNC INT DIA_RBL_2605_GARRY_After2_Condition()
{
if (Npc_KnowsInfo (hero, DIA_RBL_2605_GARRY_After1))&&(Npc_KnowsInfo (hero, DIA_RBL_2613_VAM_GoBring))
{
return 1;
};
};
FUNC VOID DIA_RBL_2605_GARRY_After2_Info()
{
AI_Output (other, self, "DIA_RBL_2605_GARRY_After2_15_01"); //Może to Cię zainteresuje...
AI_Output (self, other, "DIA_RBL_2605_GARRY_After2_11_02"); //Co takiego?
AI_Output (other, self, "DIA_RBL_2605_GARRY_After2_11_03"); //Drwal Vam szuka pomocnika.
AI_Output (self, other, "DIA_RBL_2605_GARRY_After2_11_04"); //Hmm. Drwal powiadasz?
AI_Output (self, other, "DIA_RBL_2605_GARRY_After2_11_05"); //Ścinanie drzew, obcowanie z matką naturą, heblowanie desek, gładzenie delikatnej powierzchni drewna...
AI_Output (self, other, "DIA_RBL_2605_GARRY_After2_11_06"); //To coś dokładnie dla mnie!
if (C_BodystateContains(self, BS_SIT) )
{
AI_StandUp (self);
AI_TurnToNpc (self, other);
};
AI_Output (self, other, "DIA_RBL_2605_GARRY_After2_11_07"); //Prowadź!
Party_AddNpc(self);
Npc_ExchangeRoutine (self,"FOLLOW");
B_StopProcessInfos (self);
};
INSTANCE DIA_RBL_2605_GARRY_After3 (C_INFO)
{
npc = RBL_2605_GARRY;
nr = 6;
condition = DIA_RBL_2605_GARRY_After3_Condition;
information = DIA_RBL_2605_GARRY_After3_Info;
permanent = 0;
important = 1;
description = "...";
};
FUNC INT DIA_RBL_2605_GARRY_After3_Condition()
{
if (Npc_KnowsInfo (hero, RBL_2613_Vam_Ok))
{
return 1;
};
};
FUNC VOID DIA_RBL_2605_GARRY_After3_Info()
{
AI_TurnToNpc (self, other);
AI_Output (self, other, "DIA_RBL_2605_GARRY_After3_11_01"); //W sumie może i dobrze się stało.
AI_Output (self, other, "DIA_RBL_2605_GARRY_After3_11_02"); //Praca przy drewnie jest spokojniejsza i bardziej... uduchowiona.
AI_Output (other, self, "DIA_RBL_2605_GARRY_After3_15_03"); //Skoro tak twierdzisz. Miłego obcowania z duchami!
B_StopProcessInfos ( self );
};
INSTANCE DIA_Garry_Stew (C_INFO)
{
npc = RBL_2605_GARRY;
nr = 12;
condition = DIA_Garry_Stew_Condition;
information = DIA_Garry_Stew_Info;
permanent = 0;
important = 0;
description = "Mam gulasz Snafa.";
};
FUNC INT DIA_Garry_Stew_Condition()
{
if (Npc_KnowsInfo (hero, DIA_Fox_Camp))&&(NPC_HasItems(other,ItFo_Stew)>=1)
{
return 1;
};
};
FUNC VOID DIA_Garry_Stew_Info()
{
fox_stew = fox_stew + 1;
AI_Output (other, self, "DIA_Garry_Stew_15_01"); //Mam gulasz Snafa.
AI_Output (self, other, "DIA_Garry_Stew_11_02"); //A ja mam wrzody i co z tego?
AI_Output (other, self, "DIA_Garry_Stew_15_03"); //Bierzesz czy nie?
AI_Output (self, other, "DIA_Garry_Stew_11_04"); //Pewnie, dawaj.
B_GiveInvItems (other, self, ItFo_Stew, 1);
B_LogEntry (CH2_Rbl_Food, "Przyda się Garremu ciepła strawa na nowej posadce.");
};
|
D
|
<!DOCTYPE html>
<html>
<!-- Mirrored from www.cognitiveclouds.com/img/c/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/safari-pinned-tab.svg by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 04 Aug 2017 17:04:12 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="">
<meta name="keywords" content="design driven development"/>
<meta name="description" content="At CognitiveClouds we build world class applications for mobile, web and cloud. We collaborate with well known brands and promising startups architecting, developing, designing and shipping smart software products" />
<meta name="google-site-verification" content="JdlkgSU9kQfKat08YgfmdLFMOyYpA2ROG9rt9FCglGM" />
<!--facebook-->
<meta property="og:url" content="../../../../../../../../../../../../../../../../../../../../../../../index.html" />
<meta property="og:type" content="article" />
<meta property="og:title" content="We Create Transformative Software Products." />
<meta property="og:description" content="Startups and enterprises partner with us to research, design and develop elegant digital products for consumers, businesses and industries." />
<meta property="og:image" content="https://storage.googleapis.com/ccwebsite-assets/img/about-us/aboutus.jpg" />
<title>Page not found</title>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="/js/html5shiv-8b3747c5.js"></script>
<script src="/js/respond/respond.min-88c91176.js"></script>
<![endif]-->
<!-- Main CSS -->
<link href="../../../../../../../../../../../../../../../../../../../../../../../css/main-b0cae359.css" rel="stylesheet">
<link href="../../../../../../../../../../../../../../../../../../../../../../../css/nprogress.css" rel="stylesheet">
<link href="../../../../../../../../../../../../../../../../../../../../../../../css/workshop.css" rel="stylesheet">
<link href="../../../../../../../../../../../../../../../../../../../../../../../css/rangepicker.css" rel="stylesheet">
<link href="../../../../../../../../../../../../../../../../../../../../../../../css/resources.css" rel="stylesheet">
<link rel="apple-touch-icon" sizes="57x57" href="apple-touch-icon-57x57-20">
<link rel="apple-touch-icon" sizes="60x60" href="apple-touch-icon-60x60-20">
<link rel="apple-touch-icon" sizes="72x72" href="apple-touch-icon-72x72-20">
<link rel="apple-touch-icon" sizes="76x76" href="apple-touch-icon-76x76-20">
<link rel="apple-touch-icon" sizes="114x114" href="apple-touch-icon-114x11-20">
<link rel="apple-touch-icon" sizes="120x120" href="apple-touch-icon-120x12-20">
<link rel="apple-touch-icon" sizes="144x144" href="apple-touch-icon-144x14-20">
<link rel="icon" type="image/png" href="../../../../../../../../../../../../../../../../../../../../../../../favicons/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="../../../../../../../../../../../../../../../../../../../../../../../favicons/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="../../../../../../../../../../../../../../../../../../../../../../../favicons/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="../favico/manifest.bad.delaye">
<link rel="mask-icon" href="safari-pinned-tab.bae.d" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-TileImage" content="../../../../../../../../../../../../../../../../../../../../../../../mstile-144x144.html">
<meta name="theme-color" content="#ffffff">
</head>
<body>
<!-- Page hiding snippet (recommended) -->
<style>.async-hide { opacity: 0 !important} </style>
<script>
(function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;
h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')};
(a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);
})(window,document.documentElement,'async-hide','dataLayer',4000,{'GTM-5F86N3V':true});
</script>
<!--Ends Page hiding snippet -->
<!--Google Analytics Tracking code-->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-37831194-1', 'auto');
ga('require', 'GTM-5F86N3V');
ga('send', 'pageview');
</script>
<!--End Google Analytics Tracking code-->
<!-- Google Tag Manager -->
<noscript><iframe src="http://www.googletagmanager.com/ns.html?id=GTM-KPF6BB"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'http://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-KPF6BB');</script>
<!-- End Google Tag Manager -->
<div id="page-wrap" class="">
<nav class="navbar navbar-fixed-top navbar-static">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse" aria-expanded="false">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand text-hide" href="../../../../../../../../../../../../../../../../../../../../../../../index.html"></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="../../../../../../../../../../../../../../../../../../../../../../../custom-software-development-company.html" class="">About</a>
<li><a href="../../../../../../../../../../../../../../../../../../../../../../../custom-software-development-services.html" class="">Services</a>
<!-- <li><a href="services">Services</a> -->
<li><a href="../../../../../../../../../../../../../../../../../../../../../../../software-product-development-portfolio.html" class="">Portfolio</a></li>
<!--<li><a href="/resources" class="">Resources</a></li>-->
<li><a href="../../../../../../../../../../../../../../../../../../../../../../../insights/index.html" class="">Insights</a></li>
<li><a href="../../../../../../../../../../../../../../../../../../../../../../../jobs.html" class="">We're Hiring</a></li>
<li><a href="../../../../../../../../../../../../../../../../../../../../../../../contact.html" class="">Contact</a></li>
<li>
<div class="scrollTop">
<a type="submit" class="btn-green" href="#page-content">Free consultation</a>
</div>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<!--content starts here-->
<div id="page-content" class="home page-not-found">
<section>
<div>
<h1>Oops!</h1>
<h5>We can't seem to find the page you're looking for.</h5>
<p>Error code: 404</p>
</div>
</section>
</div><!--/home-->
<style>
.page-not-found p{}
.page-not-found {
text-align: center;
padding-left: 20px;
padding-right: 20px;
color: #567387;
background: #fff;
font-family: "Graphik-Regular", "Helvetica", Arial, sans-serif;
}
.page-not-found h5{
line-height: 87px;
color: #567387;
font-family: "Graphik-Regular", "Helvetica", Arial, sans-serif;
font-size: 30px;
max-width: 1000px;
margin: 0 auto;
}
.page-not-found h1{
font-family: "FoundersGrotesk-Bold", serif;
font-size: 87px;
color: #567387;
}
.page-not-found p{
font-size: 20px;
color: #567387;
}
#page-wrap{
min-height: 0% !important;
}
@media(max-width: 767px){
.page-not-found h1{
font-size: 40px;
}
.page-not-found h5 {
line-height: 30px;
font-size: 20px;
}
}
</style>
<!--content end-->
</div>
<footer>
<div class="container">
<div class="row">
<div class="col-lg-4">
<div class="email contact_us">
<h3>Contact</h3>
<h4>For new business:</h4>
<a href="../../../../../../../../../../../../../../../../../../../../../../../contact.html" class="btn btn-primary">Contact Us</a>
<h4>For new career opportunities: </h4>
<a href="../../../../../../../../../../../../../../../../../../../../../../../jobs.html">jobs@cognitiveclouds.com</a>
</div>
</div>
<div class="col-lg-8">
<div class="contact-information">
<div id="aclock-usa">
<div class="division">
<div class="div"></div>
<div class="div"></div>
<div class="mask"></div>
<div class="div"></div>
<div class="mask"></div>
<div id="period-usa"></div>
</div>
<div id="hour-hand-usa" class="hours arrow"></div>
<div id="minute-hand-usa" class="minutes arrow"></div>
<div class="point"></div>
<div id="second-hand-usa" class="second-hand arrow" ></div>
</div>
<div class="address">
<h3>United States</h3>
<span>5433 Ontario Common </span> <span>Fremont CA 94555</span> <span>USA </span>
<a href="tel:+1.415.234.3611" class="tel">+1.415.234.3611</a>
</div>
</div>
<div class="contact-information">
<div id="aclock-sp">
<div class="division">
<div class="div"></div>
<div class="div"></div>
<div class="mask"></div>
<div class="div"></div>
<div class="mask"></div>
<div id="period-sp"></div>
</div>
<div id="hour-hand-sp" class="hours arrow"></div>
<div id="minute-hand-sp" class="minutes arrow"></div>
<div class="point"></div>
<div id="second-hand-sp" class="second-hand arrow" ></div>
</div>
<div class="address">
<h3>Singapore</h3>
<span>20 Cecil street #14-01 </span> <span>Equity plaza</span> <span>Singapore - 049705</span>
<a href="tel:+65.31587850" class="tel">+65.31587850</a>
</div>
</div>
<div class="contact-information">
<div id="aclock">
<div class="division">
<div class="div"></div>
<div class="div"></div>
<div class="mask"></div>
<div class="div"></div>
<div class="mask"></div>
<div id="period"></div>
</div>
<div id="hourhand" class="hours arrow"></div>
<div id="minutehand" class="minutes arrow"></div>
<div class="point"></div>
<div id="secondhand" class="second-hand arrow" ></div>
</div>
<div class="address">
<h3>India</h3>
<span>#2 4th Cross KSRTC Layout</span> <span>Chikkalsandra </span> <span>Bangalore - 560061 </span>
<a href="tel:+91.80.41707002" class="tel">+91.80.41707002</a>
</div>
</div>
</div>
</div>
</div>
<div class="container copyright-content">
<div class="row">
<div class="col-span-4">
<img src="../../../../../../../../../../../../../../../../../../../../../../h/logo.png" alt="Cognitive Clouds Logo">
<p>since 2012.</p>
<p> © 2017 CognitiveClouds</p>
</div>
<div class="col-span-8">
<ul class="list-inline">
<li>
<a href="https://twitter.com/cognitiveclouds" class="social-twitter" target="_blank">
<svg width="36px" height="36px" viewBox="0 0 36 36" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
<!-- Generator: Sketch 3.3.3 (12072) - http://www.bohemiancoding.com/sketch -->
<title>social-twitter</title><desc>Created with Sketch.</desc><defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
<g id="social-twitter" sketch:type="MSArtboardGroup" fill="#0093FF">
<path d="M27.9554745,11.8870673 C27.2212409,12.207139 26.4322628,12.4235336 25.6040146,12.5207534 C26.4493431,12.0227444 27.0985401,11.2340807 27.4041606,10.2943139 C26.6131387,10.7555157 25.7369343,11.0904395 24.8043796,11.2708879 C24.0575182,10.4887534 22.9935036,10 21.8159854,10 C19.5548905,10 17.7218248,11.8019013 17.7218248,14.0242511 C17.7218248,14.3397309 17.7580292,14.6468161 17.8278102,14.941417 C14.4252555,14.7735964 11.4084672,13.1714439 9.38919708,10.7366457 C9.03678832,11.3310135 8.8349635,12.0223139 8.8349635,12.7598206 C8.8349635,14.1559821 9.55773723,15.3877668 10.6562774,16.1094888 C9.98510949,16.0886099 9.35386861,15.9075157 8.80182482,15.6060987 C8.80153285,15.6229596 8.80153285,15.6397489 8.80153285,15.6566816 C8.80153285,17.6066009 10.2127007,19.2330762 12.0856934,19.6027982 C11.7421168,19.6947085 11.380438,19.7439283 11.0070073,19.7439283 C10.7432117,19.7439283 10.4867153,19.7186726 10.2367883,19.6717489 C10.7577372,21.2705291 12.269708,22.4340807 14.0612409,22.466583 C12.660073,23.5459013 10.8947445,24.1892735 8.97664234,24.1892735 C8.64620438,24.1892735 8.32029197,24.1701883 8,24.1330224 C9.81182482,25.2748341 11.9638686,25.9410942 14.2759124,25.9410942 C21.8064964,25.9410942 25.9243796,19.8089327 25.9243796,14.4909058 C25.9243796,14.3164843 25.920438,14.1429238 25.9125547,13.970296 C26.7124088,13.4029058 27.4065693,12.6940987 27.9554745,11.8870673" id="Imported-Layers" sketch:type="MSShapeGroup"></path>
</g>
</g>
</svg>
</a>
</li>
<li>
<!-- <a href="https://www.facebook.com/sharer/sharer.php?u=cognitiveclouds.com" class="social-facebook" target="_blank"> -->
<a href="https://www.facebook.com/CognitiveClouds-558720034161747/" class="social-facebook" target="_blank">
<svg width="36px" height="36px" viewBox="0 0 36 36" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
<!-- Generator: Sketch 3.3.3 (12072) - http://www.bohemiancoding.com/sketch -->
<title>social-facebook</title><desc>Created with Sketch.</desc><defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
<g id="social-facebook" sketch:type="MSArtboardGroup" fill="#0093FF">
<path d="M19.7763361,26.9688458 L19.7763361,19.2285286 L22.4001765,19.2285286 L22.793,16.2119648 L19.7763361,16.2119648 L19.7763361,14.2860969 C19.7763361,13.4126564 20.0213025,12.8175066 21.2861429,12.8175066 L22.8992605,12.8167577 L22.8992605,10.1188502 C22.6201849,10.0820793 21.6626303,10 20.5485966,10 C18.2228151,10 16.6304958,11.4057577 16.6304958,13.9873612 L16.6304958,16.2119648 L14,16.2119648 L14,19.2285286 L16.6304958,19.2285286 L16.6304958,26.9688458 L19.7763361,26.9688458" id="Imported-Layers" sketch:type="MSShapeGroup"></path>
</g>
</g>
</svg>
</a>
</li>
<li>
<a href="https://www.linkedin.com/company/cognitiveclouds" class="social-ln" target="_blank">
<svg width="36px" height="36px" viewBox="0 0 36 36" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
<!-- Generator: Sketch 3.3.3 (12072) - http://www.bohemiancoding.com/sketch -->
<title>social-linkedin</title><desc>Created with Sketch.</desc><defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
<g id="social-linkedin" sketch:type="MSArtboardGroup" fill="#0093FF">
<g id="Imported-Layers" sketch:type="MSLayerGroup" transform="translate(9.000000, 9.000000)">
<path d="M16.5888,0.000124137931 L1.35508966,0.000124137931 C0.627144828,0.000124137931 0.0356275862,0.577117241 0.0356275862,1.28817931 L0.0356275862,16.5861931 C0.0356275862,17.2981241 0.627144828,17.8759862 1.35508966,17.8759862 L16.5888,17.8759862 C17.3179862,17.8759862 17.9119862,17.2981241 17.9119862,16.5861931 L17.9119862,1.28817931 C17.9119862,0.577117241 17.3179862,0.000124137931 16.5888,0.000124137931 Z M2.68609655,6.70171034 L5.33755862,6.70171034 L5.33755862,15.2327172 L2.68609655,15.2327172 L2.68609655,6.70171034 Z M4.01238621,2.46115862 C4.86,2.46115862 5.54884138,3.15012414 5.54884138,3.99798621 C5.54884138,4.84671724 4.86,5.53555862 4.01238621,5.53555862 C3.16266207,5.53555862 2.47481379,4.84671724 2.47481379,3.99798621 C2.47481379,3.15012414 3.16266207,2.46115862 4.01238621,2.46115862 Z M7.00063448,6.70171034 L9.5436,6.70171034 L9.5436,7.86748966 L9.57910345,7.86748966 C9.93314483,7.19677241 10.7978897,6.48968276 12.0878069,6.48968276 C14.7726621,6.48968276 15.2683448,8.25666207 15.2683448,10.5534621 L15.2683448,15.2327172 L12.6187448,15.2327172 L12.6187448,11.0840276 C12.6187448,10.0947724 12.6006207,8.82223448 11.2410621,8.82223448 C9.86151724,8.82223448 9.64961379,9.89987586 9.64961379,11.0125241 L9.64961379,15.2327172 L7.00063448,15.2327172 L7.00063448,6.70171034 Z" id="Fill-1" sketch:type="MSShapeGroup"></path>
</g>
</g>
</g>
</svg>
</a>
</li>
</ul>
<div class="privacyPolicy">
<a href="../../../../../../../../../../../../../../../../../../../../../../../privacy.html">Privacy Policy</a>
</div>
</div>
</div>
</div>
</footer>
<script src="../../../../../../../../../../../../../../../../../../../../../../../js/jQuery-1.11.3.js"></script>
<script src="../../../../../../../../../../../../../../../../../../../../../../../js/bootstrap.js"></script>
<script src="../../../../../../../../../../../../../../../../../../../../../../../js/moment.js"></script>
<script src="../../../../../../../../../../../../../../../../../../../../../../../js/custom.js"></script>
<script src="../../../../../../../../../../../../../../../../../../../../../../../js/rangepicker.js"></script>
<script src="../../../../../../../../../../../../../../../../../../../../../../../js/nprogress.js"></script>
<script src="https://js.stripe.com/v3/"></script>
<!-- <script src="/js/one.min.js"></script>-->
<!--intercom js-->
<script>
window.intercomSettings = {
app_id: "x3h0no0f"
};
</script>
<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/x3h0no0f';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>
<!--ends intercom js-->
</body>
<!-- Mirrored from www.cognitiveclouds.com/img/c/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/favicons/safari-pinned-tab.svg by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 04 Aug 2017 17:04:12 GMT -->
</html>
|
D
|
/Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Service.build/Utilities/Extendable.swift.o : /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/ServiceID.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Utilities/Deprecated.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/Service.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/ServiceCache.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Utilities/Extendable.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/ServiceType.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Config/Config.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Provider/Provider.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Container/Container.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Container/SubContainer.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Container/BasicSubContainer.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Container/BasicContainer.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Utilities/ServiceError.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Container/ContainerAlias.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/Services.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Utilities/Exports.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Environment/Environment.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/ServiceFactory.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/BasicServiceFactory.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/TypeServiceFactory.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/COperatingSystem.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOFoundationCompat.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /Users/work/Projects/Hello/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
/Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Service.build/Extendable~partial.swiftmodule : /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/ServiceID.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Utilities/Deprecated.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/Service.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/ServiceCache.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Utilities/Extendable.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/ServiceType.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Config/Config.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Provider/Provider.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Container/Container.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Container/SubContainer.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Container/BasicSubContainer.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Container/BasicContainer.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Utilities/ServiceError.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Container/ContainerAlias.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/Services.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Utilities/Exports.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Environment/Environment.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/ServiceFactory.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/BasicServiceFactory.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/TypeServiceFactory.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/COperatingSystem.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOFoundationCompat.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /Users/work/Projects/Hello/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
/Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Service.build/Extendable~partial.swiftdoc : /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/ServiceID.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Utilities/Deprecated.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/Service.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/ServiceCache.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Utilities/Extendable.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/ServiceType.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Config/Config.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Provider/Provider.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Container/Container.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Container/SubContainer.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Container/BasicSubContainer.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Container/BasicContainer.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Utilities/ServiceError.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Container/ContainerAlias.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/Services.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Utilities/Exports.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Environment/Environment.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/ServiceFactory.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/BasicServiceFactory.swift /Users/work/Projects/Hello/.build/checkouts/service.git--3029908809087319447/Sources/Service/Services/TypeServiceFactory.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/COperatingSystem.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOFoundationCompat.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /Users/work/Projects/Hello/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
|
D
|
/Users/liujianhao/code/rust/simple_web_app/simple_web_app/target/rls/debug/deps/tokio_executor-b079f515d0aceafe.rmeta: /Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/lib.rs /Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/enter.rs /Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/error.rs /Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/executor.rs /Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/global.rs /Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/park.rs /Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/typed.rs
/Users/liujianhao/code/rust/simple_web_app/simple_web_app/target/rls/debug/deps/tokio_executor-b079f515d0aceafe.d: /Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/lib.rs /Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/enter.rs /Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/error.rs /Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/executor.rs /Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/global.rs /Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/park.rs /Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/typed.rs
/Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/lib.rs:
/Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/enter.rs:
/Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/error.rs:
/Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/executor.rs:
/Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/global.rs:
/Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/park.rs:
/Users/liujianhao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tokio-executor-0.1.10/src/typed.rs:
|
D
|
/Users/jpc-mac/Documents/NYTimesDemo/Build/Build/Intermediates.noindex/NYTimesDemo.build/Debug-iphonesimulator/NYTimesDemo.build/Objects-normal/x86_64/DataStore.o : /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/Model/Article.swift /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/Model/DataStore.swift /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/AppDelegate.swift /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/Controller/ArticleCell.swift /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/Controller/ViewController.swift /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/Controller/ArticleDetailsViewController.swift /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/APIClientNetworking/APIClient.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
/Users/jpc-mac/Documents/NYTimesDemo/Build/Build/Intermediates.noindex/NYTimesDemo.build/Debug-iphonesimulator/NYTimesDemo.build/Objects-normal/x86_64/DataStore~partial.swiftmodule : /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/Model/Article.swift /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/Model/DataStore.swift /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/AppDelegate.swift /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/Controller/ArticleCell.swift /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/Controller/ViewController.swift /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/Controller/ArticleDetailsViewController.swift /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/APIClientNetworking/APIClient.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
/Users/jpc-mac/Documents/NYTimesDemo/Build/Build/Intermediates.noindex/NYTimesDemo.build/Debug-iphonesimulator/NYTimesDemo.build/Objects-normal/x86_64/DataStore~partial.swiftdoc : /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/Model/Article.swift /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/Model/DataStore.swift /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/AppDelegate.swift /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/Controller/ArticleCell.swift /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/Controller/ViewController.swift /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/Controller/ArticleDetailsViewController.swift /Users/jpc-mac/Documents/NYTimesDemo/NYTimesDemo/APIClientNetworking/APIClient.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
|
D
|
/***********************************************************************\
* setupapi.d *
* *
* Windows API header module *
* *
* Translated from MinGW Windows headers *
* by Vladimir Vlasov *
* *
* Placed into public domain *
\***********************************************************************/
module os.win32.setupapi;
pragma(lib, "setupapi.lib");
private import os.win32.basetyps, os.win32.commctrl, os.win32.prsht, os.win32.w32api,
os.win32.winreg, os.win32.windef;
private import os.win32.winbase; // for SYSTEMTIME
/*static if(_WIN32_WINNT < _WIN32_WINDOWS) {
const UINT _SETUPAPI_VER = _WIN32_WINNT; // SetupAPI version follows Windows NT version
} else static if(_WIN32_WINDOWS) {
static if(_WIN32_WINDOWS >= 0x0490) {
const UINT _SETUPAPI_VER = 0x0500; // WinME uses same version of SetupAPI as Win2k
} else static if(_WIN32_WINDOWS >= 0x0410) {
const UINT _SETUPAPI_VER = 0x0410; // Indicates version of SetupAPI shipped with Win98
} else {
const UINT _SETUPAPI_VER = 0x0400; // Earliest SetupAPI version
}
} else {
const UINT _SETUPAPI_VER = 0x0501;
}
version (WindowsNTonly) {
static if (_WIN32_WINNT >= 0x500) {
const UINT USE_SP_DRVINFO_DATA_V1 = 0;
} else {
const UINT USE_SP_DRVINFO_DATA_V1 = 1;
}
} else {
const UINT USE_SP_DRVINFO_DATA_V1 = 1;
}*/
/+
const UINT _SETUPAPI_VER = 0x0400; // Earliest SetupAPI version
const UINT USE_SP_DRVINFO_DATA_V1 = 1;
+/
const UINT _SETUPAPI_VER = WINVER;
const bool USE_SP_DRVINFO_DATA_V1 = !_WIN32_WINNT_ONLY || _WIN32_WINNT < 0x500;
enum : uint {
LINE_LEN = 256,
MAX_INF_STRING_LENGTH = 4096,
MAX_TITLE_LEN = 60,
MAX_INSTRUCTION_LEN = 256,
MAX_LABEL_LEN = 30,
MAX_SERVICE_NAME_LEN = 256,
MAX_SUBTITLE_LEN = 256,
SP_MAX_MACHINENAME_LENGTH = MAX_PATH + 3
}
enum : DWORD {
COPYFLG_WARN_IF_SKIP = 0x00000001,
COPYFLG_NOSKIP = 0x00000002,
COPYFLG_NOVERSIONCHECK = 0x00000004,
COPYFLG_FORCE_FILE_IN_USE = 0x00000008,
COPYFLG_NO_OVERWRITE = 0x00000010,
COPYFLG_NO_VERSION_DIALOG = 0x00000020,
COPYFLG_OVERWRITE_OLDER_ONLY = 0x00000040,
COPYFLG_REPLACEONLY = 0x00000400,
COPYFLG_NODECOMP = 0x00000800,
COPYFLG_REPLACE_BOOT_FILE = 0x00001000,
COPYFLG_NOPRUNE = 0x00002000
}
enum : DWORD {
DELFLG_IN_USE = 0x00000001,
DELFLG_IN_USE1 = 0x00010000
}
enum : DWORD {
DI_REMOVEDEVICE_GLOBAL = 0x00000001,
DI_REMOVEDEVICE_CONFIGSPECIFIC = 0x00000002,
DI_UNREMOVEDEVICE_CONFIGSPECIFIC = 0x00000002,
DI_SHOWOEM = 0x00000001,
DI_SHOWCOMPAT = 0x00000002,
DI_SHOWCLASS = 0x00000004,
DI_SHOWALL = 0x00000007,
DI_NOVCP = 0x00000008,
DI_DIDCOMPAT = 0x00000010,
DI_DIDCLASS = 0x00000020,
DI_AUTOASSIGNRES = 0x00000040,
DI_NEEDRESTART = 0x00000080,
DI_NEEDREBOOT = 0x00000100,
DI_NOBROWSE = 0x00000200,
DI_MULTMFGS = 0x00000400,
DI_DISABLED = 0x00000800,
DI_GENERALPAGE_ADDED = 0x00001000,
DI_RESOURCEPAGE_ADDED = 0x00002000,
DI_PROPERTIES_CHANGE = 0x00004000,
DI_INF_IS_SORTED = 0x00008000,
DI_ENUMSINGLEINF = 0x00010000,
DI_DONOTCALLCONFIGMG = 0x00020000,
DI_INSTALLDISABLED = 0x00040000,
DI_COMPAT_FROM_CLASS = 0x00080000,
DI_CLASSINSTALLPARAMS = 0x00100000,
DI_NODI_DEFAULTACTION = 0x00200000,
DI_QUIETINSTALL = 0x00800000,
DI_NOFILECOPY = 0x01000000,
DI_FORCECOPY = 0x02000000,
DI_DRIVERPAGE_ADDED = 0x04000000,
DI_USECI_SELECTSTRINGS = 0x08000000,
DI_OVERRIDE_INFFLAGS = 0x10000000,
DI_PROPS_NOCHANGEUSAGE = 0x20000000,
DI_NOSELECTICONS = 0x40000000,
DI_NOWRITE_IDS = 0x80000000,
DI_FLAGSEX_USEOLDINFSEARCH = 0x00000001,
DI_FLAGSEX_AUTOSELECTRANK0 = 0x00000002,
DI_FLAGSEX_CI_FAILED = 0x00000004,
DI_FLAGSEX_DIDINFOLIST = 0x00000010,
DI_FLAGSEX_DIDCOMPATINFO = 0x00000020,
DI_FLAGSEX_FILTERCLASSES = 0x00000040,
DI_FLAGSEX_SETFAILEDINSTALL = 0x00000080,
DI_FLAGSEX_DEVICECHANGE = 0x00000100,
DI_FLAGSEX_ALWAYSWRITEIDS = 0x00000200,
DI_FLAGSEX_PROPCHANGE_PENDING = 0x00000400,
DI_FLAGSEX_ALLOWEXCLUDEDDRVS = 0x00000800,
DI_FLAGSEX_NOUIONQUERYREMOVE = 0x00001000,
DI_FLAGSEX_USECLASSFORCOMPAT = 0x00002000,
DI_FLAGSEX_OLDINF_IN_CLASSLIST = 0x00004000,
DI_FLAGSEX_NO_DRVREG_MODIFY = 0x00008000,
DI_FLAGSEX_IN_SYSTEM_SETUP = 0x00010000,
DI_FLAGSEX_INET_DRIVER = 0x00020000,
DI_FLAGSEX_APPENDDRIVERLIST = 0x00040000,
DI_FLAGSEX_PREINSTALLBACKUP = 0x00080000,
DI_FLAGSEX_BACKUPONREPLACE = 0x00100000,
DI_FLAGSEX_DRIVERLIST_FROM_URL = 0x00200000,
DI_FLAGSEX_RESERVED1 = 0x00400000,
DI_FLAGSEX_EXCLUDE_OLD_INET_DRIVERS = 0x00800000,
DI_FLAGSEX_POWERPAGE_ADDED = 0x01000000
}
enum : DWORD {
DIBCI_NOINSTALLCLASS = 0x00000001,
DIBCI_NODISPLAYCLASS = 0x00000002
}
enum : DWORD {
DICD_GENERATE_ID = 0x00000001,
DICD_INHERIT_CLASSDRVS = 0x00000002
}
enum : DWORD {
DICS_ENABLE = 1,
DICS_DISABLE,
DICS_PROPCHANGE,
DICS_START,
DICS_STOP // = 5
}
enum : DWORD {
DICS_FLAG_GLOBAL = 1,
DICS_FLAG_CONFIGSPECIFIC = 2,
DICS_FLAG_CONFIGGENERAL = 4
}
alias UINT DI_FUNCTION;
enum : DI_FUNCTION {
DIF_SELECTDEVICE = 1,
DIF_INSTALLDEVICE,
DIF_ASSIGNRESOURCES,
DIF_PROPERTIES,
DIF_REMOVE,
DIF_FIRSTTIMESETUP,
DIF_FOUNDDEVICE,
DIF_SELECTCLASSDRIVERS,
DIF_VALIDATECLASSDRIVERS,
DIF_INSTALLCLASSDRIVERS,
DIF_CALCDISKSPACE,
DIF_DESTROYPRIVATEDATA,
DIF_VALIDATEDRIVER,
DIF_MOVEDEVICE,
DIF_DETECT,
DIF_INSTALLWIZARD,
DIF_DESTROYWIZARDDATA,
DIF_PROPERTYCHANGE,
DIF_ENABLECLASS,
DIF_DETECTVERIFY,
DIF_INSTALLDEVICEFILES,
DIF_UNREMOVE,
DIF_SELECTBESTCOMPATDRV,
DIF_ALLOW_INSTALL,
DIF_REGISTERDEVICE,
DIF_NEWDEVICEWIZARD_PRESELECT,
DIF_NEWDEVICEWIZARD_SELECT,
DIF_NEWDEVICEWIZARD_PREANALYZE,
DIF_NEWDEVICEWIZARD_POSTANALYZE,
DIF_NEWDEVICEWIZARD_FINISHINSTALL,
DIF_UNUSED1,
DIF_INSTALLINTERFACES,
DIF_DETECTCANCEL,
DIF_REGISTER_COINSTALLERS,
DIF_ADDPROPERTYPAGE_ADVANCED,
DIF_ADDPROPERTYPAGE_BASIC,
DIF_RESERVED1,
DIF_TROUBLESHOOTER,
DIF_POWERMESSAGEWAKE // = 39
}
enum : DWORD {
DIGCF_DEFAULT = 0x00000001,
DIGCF_PRESENT = 0x00000002,
DIGCF_ALLCLASSES = 0x00000004,
DIGCF_PROFILE = 0x00000008,
DIGCF_DEVICEINTERFACE = 0x00000010
}
deprecated enum : DWORD {
DIGCF_INTERFACEDEVICE = DIGCF_DEVICEINTERFACE
}
enum : DWORD {
DIGCDP_FLAG_BASIC = 0x00000001,
DIGCDP_FLAG_ADVANCED = 0x00000002
}
enum : DWORD {
DIOCR_INSTALLER = 0x00000001,
DIOCR_INTERFACE = 0x00000002
}
enum : DWORD {
DIODI_NO_ADD = 0x00000001
}
enum : DWORD {
DIOD_INHERIT_CLASSDRVS = 0x00000002,
DIOD_CANCEL_REMOVE = 0x00000004
}
enum : DWORD {
DIREG_DEV = 0x00000001,
DIREG_DRV = 0x00000002,
DIREG_BOTH = 0x00000004
}
enum : int {
DIRID_ABSOLUTE = -1,
DIRID_NULL = 0,
DIRID_SRCPATH = 1,
DIRID_WINDOWS = 10,
DIRID_SYSTEM = 11,
DIRID_DRIVERS = 12,
DIRID_IOSUBSYS = DIRID_DRIVERS,
DIRID_INF = 17,
DIRID_HELP = 18,
DIRID_FONTS = 20,
DIRID_VIEWERS = 21,
DIRID_COLOR = 23,
DIRID_APPS = 24,
DIRID_SHARED = 25,
DIRID_BOOT = 30,
DIRID_SYSTEM16 = 50,
DIRID_SPOOL = 51,
DIRID_SPOOLDRIVERS = 52,
DIRID_USERPROFILE = 53,
DIRID_LOADER = 54,
DIRID_PRINTPROCESSOR = 55,
DIRID_DEFAULT = DIRID_SYSTEM
}
enum : int {
DIRID_COMMON_STARTMENU = 16406,
DIRID_COMMON_PROGRAMS = 16407,
DIRID_COMMON_STARTUP = 16408,
DIRID_COMMON_DESKTOPDIRECTORY = 16409,
DIRID_COMMON_FAVORITES = 16415,
DIRID_COMMON_APPDATA = 16419,
DIRID_PROGRAM_FILES = 16422,
DIRID_SYSTEM_X86 = 16425,
DIRID_PROGRAM_FILES_X86 = 16426,
DIRID_PROGRAM_FILES_COMMON = 16427,
DIRID_PROGRAM_FILES_COMMONX86 = 16428,
DIRID_COMMON_TEMPLATES = 16429,
DIRID_COMMON_DOCUMENTS = 16430,
DIRID_USER = 0x8000,
DIRID_ABSOLUTE_16BIT = 0xffff
}
enum : DWORD {
DMI_MASK = 0x00000001,
DMI_BKCOLOR = 0x00000002,
DMI_USERECT = 0x00000004
}
enum : DWORD {
DNF_DUPDESC = 0x00000001,
DNF_OLDDRIVER = 0x00000002,
DNF_EXCLUDEFROMLIST = 0x00000004,
DNF_NODRIVER = 0x00000008,
DNF_LEGACYINF = 0x00000010,
DNF_CLASS_DRIVER = 0x00000020,
DNF_COMPATIBLE_DRIVER = 0x00000040,
DNF_INET_DRIVER = 0x00000080,
DNF_UNUSED1 = 0x00000100,
DNF_INDEXED_DRIVER = 0x00000200,
DNF_OLD_INET_DRIVER = 0x00000400,
DNF_BAD_DRIVER = 0x00000800,
DNF_DUPPROVIDER = 0x00001000
}
enum : UINT {
DPROMPT_SUCCESS,
DPROMPT_CANCEL,
DPROMPT_SKIPFILE,
DPROMPT_BUFFERTOOSMALL,
DPROMPT_OUTOFMEMORY // = 4
}
enum : DWORD {
DRIVER_HARDWAREID_RANK = 0x00000FFF,
DRIVER_COMPATID_RANK = 0x00003FFF,
DRIVER_UNTRUSTED_RANK = 0x00008000,
DRIVER_UNTRUSTED_HARDWAREID_RANK = 0x00008FFF,
DRIVER_UNTRUSTED_COMPATID_RANK = 0x0000BFFF,
DRIVER_W9X_SUSPECT_RANK = 0x0000C000,
DRIVER_W9X_SUSPECT_HARDWAREID_RANK = 0x0000CFFF,
DRIVER_W9X_SUSPECT_COMPATID_RANK = 0x0000FFFF
}
enum : DWORD {
DYNAWIZ_FLAG_PAGESADDED = 0x00000001,
DYNAWIZ_FLAG_INSTALLDET_NEXT = 0x00000002,
DYNAWIZ_FLAG_INSTALLDET_PREV = 0x00000004,
DYNAWIZ_FLAG_ANALYZE_HANDLECONFLICT = 0x00000008
}
enum : WORD {
ENABLECLASS_QUERY,
ENABLECLASS_SUCCESS,
ENABLECLASS_FAILURE // = 2
}
enum : DWORD {
ERROR_EXPECTED_SECTION_NAME = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0,
ERROR_BAD_SECTION_NAME_LINE = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 1,
ERROR_SECTION_NAME_TOO_LONG = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 2,
ERROR_GENERAL_SYNTAX = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 3,
ERROR_WRONG_INF_STYLE = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x100,
ERROR_NOT_INSTALLED = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x1000,
ERROR_SECTION_NOT_FOUND = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x101,
ERROR_LINE_NOT_FOUND = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x102,
ERROR_NO_BACKUP = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x103,
ERROR_NO_ASSOCIATED_CLASS = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x200,
ERROR_CLASS_MISMATCH = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x201,
ERROR_DUPLICATE_FOUND = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x202,
ERROR_NO_DRIVER_SELECTED = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x203,
ERROR_KEY_DOES_NOT_EXIST = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x204,
ERROR_INVALID_DEVINST_NAME = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x205,
ERROR_INVALID_CLASS = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x206,
ERROR_DEVINST_ALREADY_EXISTS = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x207,
ERROR_DEVINFO_NOT_REGISTERED = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x208,
ERROR_INVALID_REG_PROPERTY = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x209,
ERROR_NO_INF = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x20A,
ERROR_NO_SUCH_DEVINST = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x20B,
ERROR_CANT_LOAD_CLASS_ICON = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x20C,
ERROR_INVALID_CLASS_INSTALLER = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x20D,
ERROR_DI_DO_DEFAULT = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x20E,
ERROR_DI_NOFILECOPY = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x20F,
ERROR_INVALID_HWPROFILE = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x210,
ERROR_NO_DEVICE_SELECTED = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x211,
ERROR_DEVINFO_LIST_LOCKED = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x212,
ERROR_DEVINFO_DATA_LOCKED = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x213,
ERROR_DI_BAD_PATH = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x214,
ERROR_NO_CLASSINSTALL_PARAMS = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x215,
ERROR_FILEQUEUE_LOCKED = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x216,
ERROR_BAD_SERVICE_INSTALLSECT = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x217,
ERROR_NO_CLASS_DRIVER_LIST = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x218,
ERROR_NO_ASSOCIATED_SERVICE = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x219,
ERROR_NO_DEFAULT_DEVICE_INTERFACE = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x21A,
ERROR_DEVICE_INTERFACE_ACTIVE = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x21B,
ERROR_DEVICE_INTERFACE_REMOVED = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x21C,
ERROR_BAD_INTERFACE_INSTALLSECT = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x21D,
ERROR_NO_SUCH_INTERFACE_CLASS = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x21E,
ERROR_INVALID_REFERENCE_STRING = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x21F,
ERROR_INVALID_MACHINENAME = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x220,
ERROR_REMOTE_COMM_FAILURE = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x221,
ERROR_MACHINE_UNAVAILABLE = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x222,
ERROR_NO_CONFIGMGR_SERVICES = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x223,
ERROR_INVALID_PROPPAGE_PROVIDER = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x224,
ERROR_NO_SUCH_DEVICE_INTERFACE = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x225,
ERROR_DI_POSTPROCESSING_REQUIRED = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x226,
ERROR_INVALID_COINSTALLER = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x227,
ERROR_NO_COMPAT_DRIVERS = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x228,
ERROR_NO_DEVICE_ICON = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x229,
ERROR_INVALID_INF_LOGCONFIG = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x22A,
ERROR_DI_DONT_INSTALL = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x22B,
ERROR_INVALID_FILTER_DRIVER = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x22C,
ERROR_NON_WINDOWS_NT_DRIVER = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x22D,
ERROR_NON_WINDOWS_DRIVER = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x22E,
ERROR_NO_CATALOG_FOR_OEM_INF = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x22F,
ERROR_DEVINSTALL_QUEUE_NONNATIVE = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x230,
ERROR_NOT_DISABLEABLE = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x231,
ERROR_CANT_REMOVE_DEVINST = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x232
}
deprecated enum : DWORD {
ERROR_NO_DEFAULT_INTERFACE_DEVICE = ERROR_NO_DEFAULT_DEVICE_INTERFACE,
ERROR_INTERFACE_DEVICE_ACTIVE = ERROR_DEVICE_INTERFACE_ACTIVE,
ERROR_INTERFACE_DEVICE_REMOVED = ERROR_DEVICE_INTERFACE_REMOVED,
ERROR_NO_SUCH_INTERFACE_DEVICE = ERROR_NO_SUCH_DEVICE_INTERFACE,
}
enum : UINT {
FILEOP_COPY,
FILEOP_RENAME,
FILEOP_DELETE,
FILEOP_BACKUP,
FILEOP_NEWPATH, // = 4
FILEOP_ABORT = 0,
FILEOP_DOIT,
FILEOP_SKIP, // = 2
FILEOP_RETRY = FILEOP_DOIT
}
enum : UINT {
FILE_COMPRESSION_NONE,
FILE_COMPRESSION_WINLZA,
FILE_COMPRESSION_MSZIP,
FILE_COMPRESSION_NTCAB // = 3
}
enum : DWORD {
FLG_ADDREG_TYPE_SZ = 0x00000000,
FLG_ADDREG_BINVALUETYPE = 0x00000001,
FLG_ADDREG_NOCLOBBER = 0x00000002,
FLG_ADDREG_DELVAL = 0x00000004,
FLG_ADDREG_APPEND = 0x00000008,
FLG_ADDREG_KEYONLY = 0x00000010,
FLG_ADDREG_OVERWRITEONLY = 0x00000020,
FLG_ADDREG_TYPE_MULTI_SZ = 0x00010000,
FLG_ADDREG_TYPE_EXPAND_SZ = 0x00020000,
FLG_ADDREG_TYPE_BINARY = 0x00000000 | FLG_ADDREG_BINVALUETYPE,
FLG_ADDREG_TYPE_DWORD = 0x00010000 | FLG_ADDREG_BINVALUETYPE,
FLG_ADDREG_TYPE_NONE = 0x00020000 | FLG_ADDREG_BINVALUETYPE,
FLG_ADDREG_TYPE_MASK = 0xFFFF0000 | FLG_ADDREG_BINVALUETYPE
}
static if(_SETUPAPI_VER >= 0x0501) {
enum : DWORD {
FLG_ADDREG_64BITKEY = 0x00001000,
FLG_ADDREG_KEYONLY_COMMON = 0x00002000,
FLG_ADDREG_32BITKEY = 0x00004000,
FLG_ADDREG_DELREG_BIT = 0x00008000
}
}
enum : DWORD {
FLG_DELREG_VALUE = 0x00000000
}
static if(_SETUPAPI_VER >= 0x0501) {
enum : DWORD {
FLG_DELREG_TYPE_MASK = FLG_ADDREG_TYPE_MASK,
FLG_DELREG_TYPE_SZ = FLG_ADDREG_TYPE_SZ,
FLG_DELREG_TYPE_MULTI_SZ = FLG_ADDREG_TYPE_MULTI_SZ,
FLG_DELREG_TYPE_EXPAND_SZ = FLG_ADDREG_TYPE_EXPAND_SZ,
FLG_DELREG_TYPE_BINARY = FLG_ADDREG_TYPE_BINARY,
FLG_DELREG_TYPE_DWORD = FLG_ADDREG_TYPE_DWORD,
FLG_DELREG_TYPE_NONE = FLG_ADDREG_TYPE_NONE,
FLG_DELREG_64BITKEY = FLG_ADDREG_64BITKEY,
FLG_DELREG_KEYONLY_COMMON = FLG_ADDREG_KEYONLY_COMMON,
FLG_DELREG_32BITKEY = FLG_ADDREG_32BITKEY,
FLG_DELREG_OPERATION_MASK = 0x000000FE,
FLG_DELREG_MULTI_SZ_DELSTRING = 0x00000002 | FLG_DELREG_TYPE_MULTI_SZ | FLG_ADDREG_DELREG_BIT
}
}
enum : DWORD {
FLG_BITREG_CLEARBITS = 0x00000000,
FLG_BITREG_SETBITS = 0x00000001
}
static if(_SETUPAPI_VER >= 0x0501) {
enum : DWORD {
FLG_BITREG_64BITKEY = 0x00001000,
FLG_BITREG_32BITKEY = 0x00004000
}
}
enum : DWORD {
FLG_PROFITEM_CURRENTUSER = 0x00000001,
FLG_PROFITEM_DELETE = 0x00000002,
FLG_PROFITEM_GROUP = 0x00000004,
FLG_PROFITEM_CSIDL = 0x00000008
}
enum : DWORD {
FLG_REGSVR_DLLREGISTER = 0x00000001,
FLG_REGSVR_DLLINSTALL = 0x00000002
}
enum {
IDD_DYNAWIZ_FIRSTPAGE = 10000,
IDD_DYNAWIZ_SELECT_PREVPAGE,
IDD_DYNAWIZ_SELECT_NEXTPAGE,
IDD_DYNAWIZ_ANALYZE_PREVPAGE,
IDD_DYNAWIZ_ANALYZE_NEXTPAGE, // = 1004
IDD_DYNAWIZ_INSTALLDETECTED_PREVPAGE = 10006,
IDD_DYNAWIZ_INSTALLDETECTED_NEXTPAGE,
IDD_DYNAWIZ_INSTALLDETECTED_NODEVS,
IDD_DYNAWIZ_SELECTDEV_PAGE,
IDD_DYNAWIZ_ANALYZEDEV_PAGE,
IDD_DYNAWIZ_INSTALLDETECTEDDEVS_PAGE,
IDD_DYNAWIZ_SELECTCLASS_PAGE, // = 10012
MIN_IDD_DYNAWIZ_RESOURCE_ID = 10000,
MAX_IDD_DYNAWIZ_RESOURCE_ID = 11000
}
enum : DWORD {
IDF_NOBROWSE = 0x00000001,
IDF_NOSKIP = 0x00000002,
IDF_NODETAILS = 0x00000004,
IDF_NOCOMPRESSED = 0x00000008,
IDF_CHECKFIRST = 0x00000100,
IDF_NOBEEP = 0x00000200,
IDF_NOFOREGROUND = 0x00000400,
IDF_WARNIFSKIP = 0x00000800
}
static if(_SETUPAPI_VER >= 0x0501) {
enum : DWORD {
IDF_NOREMOVABLEMEDIAPROMPT = 0x00001000,
IDF_USEDISKNAMEASPROMPT = 0x00002000,
IDF_OEMDISK = 0x80000000
}
}
enum {
IDI_RESOURCEFIRST = 159,
IDI_RESOURCE = 159,
IDI_RESOURCELAST = 161,
IDI_RESOURCEOVERLAYFIRST = 161,
IDI_RESOURCEOVERLAYLAST = 161,
IDI_CONFLICT = 161,
IDI_PROBLEM_OVL = 500,
IDI_DISABLED_OVL = 501,
IDI_FORCED_OVL = 502,
IDI_CLASSICON_OVERLAYFIRST = 500,
IDI_CLASSICON_OVERLAYLAST = 502
}
enum : DWORD {
INF_STYLE_NONE = 0x00000000,
INF_STYLE_OLDNT = 0x00000001,
INF_STYLE_WIN4 = 0x00000002,
INF_STYLE_CACHE_ENABLE = 0x00000010,
INF_STYLE_CACHE_DISABLE = 0x00000020
}
enum : DWORD {
INFINFO_INF_SPEC_IS_HINF = 1,
INFINFO_INF_NAME_IS_ABSOLUTE,
INFINFO_DEFAULT_SEARCH,
INFINFO_REVERSE_DEFAULT_SEARCH,
INFINFO_INF_PATH_LIST_SEARCH // = 5
}
alias DWORD LogSeverity;
enum : LogSeverity {
LogSevInformation,
LogSevWarning,
LogSevError,
LogSevFatalError,
LogSevMaximum // = 4
}
const MAX_INSTALLWIZARD_DYNAPAGES = 20;
enum : DWORD {
NDW_INSTALLFLAG_DIDFACTDEFS = 0x00000001,
NDW_INSTALLFLAG_HARDWAREALLREADYIN = 0x00000002,
NDW_INSTALLFLAG_NEEDSHUTDOWN = 0x00000200,
NDW_INSTALLFLAG_EXPRESSINTRO = 0x00000400,
NDW_INSTALLFLAG_SKIPISDEVINSTALLED = 0x00000800,
NDW_INSTALLFLAG_NODETECTEDDEVS = 0x00001000,
NDW_INSTALLFLAG_INSTALLSPECIFIC = 0x00002000,
NDW_INSTALLFLAG_SKIPCLASSLIST = 0x00004000,
NDW_INSTALLFLAG_CI_PICKED_OEM = 0x00008000,
NDW_INSTALLFLAG_PCMCIAMODE = 0x00010000,
NDW_INSTALLFLAG_PCMCIADEVICE = 0x00020000,
NDW_INSTALLFLAG_USERCANCEL = 0x00040000,
NDW_INSTALLFLAG_KNOWNCLASS = 0x00080000,
NDW_INSTALLFLAG_NEEDRESTART = 0x00000080,
NDW_INSTALLFLAG_NEEDREBOOT = 0x00000100
}
enum : DWORD {
SETDIRID_NOT_FULL_PATH = 0x00000001
}
enum : DWORD {
SP_COPY_DELETESOURCE = 0x0000001,
SP_COPY_REPLACEONLY = 0x0000002,
SP_COPY_NEWER = 0x0000004,
SP_COPY_NEWER_OR_SAME = 0x0000004,
SP_COPY_NOOVERWRITE = 0x0000008,
SP_COPY_NODECOMP = 0x0000010,
SP_COPY_LANGUAGEAWARE = 0x0000020,
SP_COPY_SOURCE_ABSOLUTE = 0x0000040,
SP_COPY_SOURCEPATH_ABSOLUTE = 0x0000080,
SP_COPY_IN_USE_NEEDS_REBOOT = 0x0000100,
SP_COPY_FORCE_IN_USE = 0x0000200,
SP_COPY_NOSKIP = 0x0000400,
SP_FLAG_CABINETCONTINUATION = 0x0000800,
SP_COPY_FORCE_NOOVERWRITE = 0x0001000,
SP_COPY_FORCE_NEWER = 0x0002000,
SP_COPY_WARNIFSKIP = 0x0004000,
SP_COPY_NOBROWSE = 0x0008000,
SP_COPY_NEWER_ONLY = 0x0010000,
SP_COPY_SOURCE_SIS_MASTER = 0x0020000,
SP_COPY_OEMINF_CATALOG_ONLY = 0x0040000,
SP_COPY_REPLACE_BOOT_FILE = 0x0080000,
SP_COPY_NOPRUNE = 0x0100000
}
static if(_SETUPAPI_VER >= 0x0501) {
enum : DWORD {
SP_COPY_OEM_F6_INF = 0x0200000
}
}
enum : DWORD {
SPCRP_SECURITY = 23,
SPCRP_SECURITY_SDS,
SPCRP_DEVTYPE,
SPCRP_EXCLUSIVE,
SPCRP_CHARACTERISTICS,
SPCRP_MAXIMUM_PROPERTY // = 28
}
enum : DWORD {
SPDIT_NODRIVER,
SPDIT_CLASSDRIVER,
SPDIT_COMPATDRIVER // = 2
}
enum : DWORD {
SPDRP_DEVICEDESC,
SPDRP_HARDWAREID,
SPDRP_COMPATIBLEIDS,
SPDRP_UNUSED0,
SPDRP_SERVICE,
SPDRP_UNUSED1,
SPDRP_UNUSED2,
SPDRP_CLASS,
SPDRP_CLASSGUID,
SPDRP_DRIVER,
SPDRP_CONFIGFLAGS,
SPDRP_MFG,
SPDRP_FRIENDLYNAME,
SPDRP_LOCATION_INFORMATION,
SPDRP_PHYSICAL_DEVICE_OBJECT_NAME,
SPDRP_CAPABILITIES,
SPDRP_UI_NUMBER,
SPDRP_UPPERFILTERS,
SPDRP_LOWERFILTERS,
SPDRP_BUSTYPEGUID,
SPDRP_LEGACYBUSTYPE,
SPDRP_BUSNUMBER,
SPDRP_ENUMERATOR_NAME,
SPDRP_SECURITY,
SPDRP_SECURITY_SDS,
SPDRP_DEVTYPE,
SPDRP_EXCLUSIVE,
SPDRP_CHARACTERISTICS,
SPDRP_ADDRESS, // = 28
SPDRP_UI_NUMBER_DESC_FORMAT = 30,
SPDRP_MAXIMUM_PROPERTY = 31
}
enum : UINT {
SPDSL_IGNORE_DISK = 1,
SPDSL_DISALLOW_NEGATIVE_ADJUST
}
enum : UINT {
SPFILENOTIFY_STARTQUEUE = 1,
SPFILENOTIFY_ENDQUEUE,
SPFILENOTIFY_STARTSUBQUEUE,
SPFILENOTIFY_ENDSUBQUEUE,
SPFILENOTIFY_STARTDELETE,
SPFILENOTIFY_ENDDELETE,
SPFILENOTIFY_DELETEERROR,
SPFILENOTIFY_STARTRENAME,
SPFILENOTIFY_ENDRENAME,
SPFILENOTIFY_RENAMEERROR,
SPFILENOTIFY_STARTCOPY,
SPFILENOTIFY_ENDCOPY,
SPFILENOTIFY_COPYERROR,
SPFILENOTIFY_NEEDMEDIA,
SPFILENOTIFY_QUEUESCAN,
SPFILENOTIFY_CABINETINFO,
SPFILENOTIFY_FILEINCABINET,
SPFILENOTIFY_NEEDNEWCABINET,
SPFILENOTIFY_FILEEXTRACTED,
SPFILENOTIFY_FILEOPDELAYED,
SPFILENOTIFY_STARTBACKUP,
SPFILENOTIFY_BACKUPERROR,
SPFILENOTIFY_ENDBACKUP,
SPFILENOTIFY_QUEUESCAN_EX,
SPFILENOTIFY_STARTREGISTRATION, // = 25
SPFILENOTIFY_ENDREGISTRATION = 32,
SPFILENOTIFY_LANGMISMATCH = 0x00010000,
SPFILENOTIFY_TARGETEXISTS = 0x00020000,
SPFILENOTIFY_TARGETNEWER = 0x00040000
}
static if(_SETUPAPI_VER >= 0x0501) {
enum : UINT {
SPFILENOTIFY_QUEUESCAN_SIGNERINFO = 0x00000040
}
}
enum : DWORD {
SPFILELOG_SYSTEMLOG = 0x00000001,
SPFILELOG_OEMFILE = 0x00000001,
SPFILELOG_FORCENEW = 0x00000002,
SPFILELOG_QUERYONLY = 0x00000004
}
enum : INT {
SPFILEQ_FILE_IN_USE = 0x00000001,
SPFILEQ_REBOOT_RECOMMENDED = 0x00000002,
SPFILEQ_REBOOT_IN_PROGRESS = 0x00000004
}
enum : DWORD {
SPINT_ACTIVE = 0x00000001,
SPINT_DEFAULT = 0x00000002,
SPINT_REMOVED = 0x00000004
}
deprecated enum : DWORD {
SPID_ACTIVE = SPINT_ACTIVE,
SPID_DEFAULT = SPINT_DEFAULT,
SPID_REMOVED = SPINT_REMOVED
}
enum : UINT {
SPINST_LOGCONFIG = 0x00000001,
SPINST_INIFILES = 0x00000002,
SPINST_REGISTRY = 0x00000004,
SPINST_INI2REG = 0x00000008,
SPINST_FILES = 0x00000010,
SPINST_BITREG = 0x00000020,
SPINST_REGSVR = 0x00000040,
SPINST_UNREGSVR = 0x00000080,
SPINST_PROFILEITEMS = 0x00000100,
SPINST_SINGLESECTION = 0x00010000,
SPINST_LOGCONFIG_IS_FORCED = 0x00020000,
SPINST_LOGCONFIGS_ARE_OVERRIDES = 0x00040000
}
static if(_SETUPAPI_VER >= 0x0501) {
enum : UINT {
SPINST_COPYINF = 0x00000200,
SPINST_ALL = 0x000003ff,
SPINST_REGISTERCALLBACKAWARE = 0x00080000
}
} else {
enum : UINT {
SPINST_ALL = 0x000001ff
}
}
enum : DWORD {
SPOST_NONE,
SPOST_PATH,
SPOST_URL,
SPOST_MAX // = 3
}
enum : DWORD {
SPPSR_SELECT_DEVICE_RESOURCES = 1,
SPPSR_ENUM_BASIC_DEVICE_PROPERTIES,
SPPSR_ENUM_ADV_DEVICE_PROPERTIES
}
enum : DWORD {
SPQ_SCAN_FILE_PRESENCE = 0x00000001,
SPQ_SCAN_FILE_VALIDITY = 0x00000002,
SPQ_SCAN_USE_CALLBACK = 0x00000004,
SPQ_SCAN_USE_CALLBACKEX = 0x00000008,
SPQ_SCAN_INFORM_USER = 0x00000010,
SPQ_SCAN_PRUNE_COPY_QUEUE = 0x00000020
}
static if(_SETUPAPI_VER >= 0x0501) {
enum : DWORD {
SPQ_SCAN_USE_CALLBACK_SIGNERINFO = 0x00000040,
SPQ_SCAN_PRUNE_DELREN = 0x00000080
}
}
enum : UINT_PTR {
SPQ_DELAYED_COPY = 0x00000001
}
enum : DWORD {
SPRDI_FIND_DUPS = 0x00000001,
}
enum : DWORD {
SPSVCINST_TAGTOFRONT = 0x00000001,
SPSVCINST_ASSOCSERVICE = 0x00000002,
SPSVCINST_DELETEEVENTLOGENTRY = 0x00000004,
SPSVCINST_NOCLOBBER_DISPLAYNAME = 0x00000008,
SPSVCINST_NOCLOBBER_STARTTYPE = 0x00000010,
SPSVCINST_NOCLOBBER_ERRORCONTROL = 0x00000020,
SPSVCINST_NOCLOBBER_LOADORDERGROUP = 0x00000040,
SPSVCINST_NOCLOBBER_DEPENDENCIES = 0x00000080,
SPSVCINST_NOCLOBBER_DESCRIPTION = 0x00000100,
SPSVCINST_STOPSERVICE = 0x00000200
}
static if(_SETUPAPI_VER >= 0x0501) {
enum : DWORD {
SPSVCINST_CLOBBER_SECURITY = 0x00000400
}
}
enum : DWORD {
SPWPT_SELECTDEVICE = 0x00000001
}
enum : DWORD {
SPWP_USE_DEVINFO_DATA = 0x00000001
}
enum : UINT {
SRCINFO_PATH = 1,
SRCINFO_TAGFILE,
SRCINFO_DESCRIPTION,
SRCINFO_FLAGS // = 4
}
enum : DWORD {
SRCLIST_TEMPORARY = 0x00000001,
SRCLIST_NOBROWSE = 0x00000002,
SRCLIST_SYSTEM = 0x00000010,
SRCLIST_USER = 0x00000020,
SRCLIST_SYSIFADMIN = 0x00000040,
SRCLIST_SUBDIRS = 0x00000100,
SRCLIST_APPEND = 0x00000200,
SRCLIST_NOSTRIPPLATFORM = 0x00000400
}
alias PVOID HINF;
alias PVOID HDSKSPC;
alias HANDLE HDEVINFO;
alias PVOID HSPFILEQ;
alias PVOID HSPFILELOG;
enum SetupFileLogInfo {
SetupFileLogSourceFilename,
SetupFileLogChecksum,
SetupFileLogDiskTagfile,
SetupFileLogDiskDescription,
SetupFileLogOtherInfo,
SetupFileLogMax
}
align(1):
struct INFCONTEXT {
PVOID Inf;
PVOID CurrentInf;
UINT Section;
UINT Line;
}
alias INFCONTEXT* PINFCONTEXT;
struct SP_INF_INFORMATION {
DWORD InfStyle;
DWORD InfCount;
BYTE _VersionData[1];
BYTE* VersionData() { return _VersionData.ptr; }
}
alias SP_INF_INFORMATION* PSP_INF_INFORMATION;
struct SP_ALTPLATFORM_INFO {
DWORD cbSize = SP_ALTPLATFORM_INFO.sizeof;
DWORD Platform;
DWORD MajorVersion;
DWORD MinorVersion;
WORD ProcessorArchitecture;
WORD Reserved;
}
alias SP_ALTPLATFORM_INFO* PSP_ALTPLATFORM_INFO;
struct SP_ORIGINAL_FILE_INFO_A {
DWORD cbSize = SP_ORIGINAL_FILE_INFO_A.sizeof;
CHAR OriginalInfName[MAX_PATH];
CHAR OriginalCatalogName[MAX_PATH];
}
alias SP_ORIGINAL_FILE_INFO_A* PSP_ORIGINAL_FILE_INFO_A;
struct SP_ORIGINAL_FILE_INFO_W {
DWORD cbSize = SP_ORIGINAL_FILE_INFO_W.sizeof;
WCHAR OriginalInfName[MAX_PATH];
WCHAR OriginalCatalogName[MAX_PATH];
}
alias SP_ORIGINAL_FILE_INFO_W* PSP_ORIGINAL_FILE_INFO_W;
struct FILEPATHS_A {
PCSTR Target;
PCSTR Source;
UINT Win32Error;
DWORD Flags;
}
alias FILEPATHS_A* PFILEPATHS_A;
struct FILEPATHS_W {
PCWSTR Target;
PCWSTR Source;
UINT Win32Error;
DWORD Flags;
}
alias FILEPATHS_W* PFILEPATHS_W;
struct SOURCE_MEDIA_A {
PCSTR Reserved;
PCSTR Tagfile;
PCSTR Description;
PCSTR SourcePath;
PCSTR SourceFile;
DWORD Flags;
}
alias SOURCE_MEDIA_A* PSOURCE_MEDIA_A;
struct SOURCE_MEDIA_W {
PCWSTR Reserved;
PCWSTR Tagfile;
PCWSTR Description;
PCWSTR SourcePath;
PCWSTR SourceFile;
DWORD Flags;
}
alias SOURCE_MEDIA_W* PSOURCE_MEDIA_W;
struct CABINET_INFO_A {
PCSTR CabinetPath;
PCSTR CabinetFile;
PCSTR DiskName;
USHORT SetId;
USHORT CabinetNumber;
}
alias CABINET_INFO_A* PCABINET_INFO_A;
struct CABINET_INFO_W {
PCWSTR CabinetPath;
PCWSTR CabinetFile;
PCWSTR DiskName;
USHORT SetId;
USHORT CabinetNumber;
}
alias CABINET_INFO_W* PCABINET_INFO_W;
struct FILE_IN_CABINET_INFO_A {
PCSTR NameInCabinet;
DWORD FileSize;
DWORD Win32Error;
WORD DosDate;
WORD DosTime;
WORD DosAttribs;
CHAR FullTargetName[MAX_PATH];
}
alias FILE_IN_CABINET_INFO_A* PFILE_IN_CABINET_INFO_A;
struct FILE_IN_CABINET_INFO_W {
PCWSTR NameInCabinet;
DWORD FileSize;
DWORD Win32Error;
WORD DosDate;
WORD DosTime;
WORD DosAttribs;
WCHAR FullTargetName[MAX_PATH];
}
alias FILE_IN_CABINET_INFO_W* PFILE_IN_CABINET_INFO_W;
struct SP_FILE_COPY_PARAMS_A {
DWORD cbSize = SP_FILE_COPY_PARAMS_A.sizeof;
HSPFILEQ QueueHandle;
PCSTR SourceRootPath;
PCSTR SourcePath;
PCSTR SourceFilename;
PCSTR SourceDescription;
PCSTR SourceTagfile;
PCSTR TargetDirectory;
PCSTR TargetFilename;
DWORD CopyStyle;
HINF LayoutInf;
PCSTR SecurityDescriptor;
}
alias SP_FILE_COPY_PARAMS_A* PSP_FILE_COPY_PARAMS_A;
struct SP_FILE_COPY_PARAMS_W {
DWORD cbSize = SP_FILE_COPY_PARAMS_W.sizeof;
HSPFILEQ QueueHandle;
PCWSTR SourceRootPath;
PCWSTR SourcePath;
PCWSTR SourceFilename;
PCWSTR SourceDescription;
PCWSTR SourceTagfile;
PCWSTR TargetDirectory;
PCWSTR TargetFilename;
DWORD CopyStyle;
HINF LayoutInf;
PCWSTR SecurityDescriptor;
}
alias SP_FILE_COPY_PARAMS_W* PSP_FILE_COPY_PARAMS_W;
struct SP_DEVINFO_DATA {
DWORD cbSize = SP_DEVINFO_DATA.sizeof;
GUID ClassGuid;
DWORD DevInst;
ULONG_PTR Reserved;
}
alias SP_DEVINFO_DATA* PSP_DEVINFO_DATA;
struct SP_DEVICE_INTERFACE_DATA {
DWORD cbSize = SP_DEVICE_INTERFACE_DATA.sizeof;
GUID InterfaceClassGuid;
DWORD Flags;
ULONG_PTR Reserved;
}
alias SP_DEVICE_INTERFACE_DATA* PSP_DEVICE_INTERFACE_DATA;
deprecated alias SP_DEVICE_INTERFACE_DATA SP_INTERFACE_DEVICE_DATA;
deprecated alias SP_DEVICE_INTERFACE_DATA* PSP_INTERFACE_DEVICE_DATA;
struct SP_DEVICE_INTERFACE_DETAIL_DATA_A {
DWORD cbSize = SP_DEVICE_INTERFACE_DETAIL_DATA_A.sizeof;
CHAR _DevicePath[1];
CHAR* DevicePath() { return _DevicePath.ptr; }
}
alias SP_DEVICE_INTERFACE_DETAIL_DATA_A* PSP_DEVICE_INTERFACE_DETAIL_DATA_A;
struct SP_DEVICE_INTERFACE_DETAIL_DATA_W {
DWORD cbSize = SP_DEVICE_INTERFACE_DETAIL_DATA_W.sizeof;
WCHAR _DevicePath[1];
WCHAR* DevicePath() { return _DevicePath.ptr; }
}
alias SP_DEVICE_INTERFACE_DETAIL_DATA_W* PSP_DEVICE_INTERFACE_DETAIL_DATA_W;
deprecated alias SP_DEVICE_INTERFACE_DETAIL_DATA_A SP_INTERFACE_DEVICE_DETAIL_DATA_A;
deprecated alias SP_DEVICE_INTERFACE_DETAIL_DATA_A* PSP_INTERFACE_DEVICE_DETAIL_DATA_A;
deprecated alias SP_DEVICE_INTERFACE_DETAIL_DATA_W SP_INTERFACE_DEVICE_DETAIL_DATA_W;
deprecated alias SP_DEVICE_INTERFACE_DETAIL_DATA_W* PSP_INTERFACE_DEVICE_DETAIL_DATA_W;
struct SP_DEVINFO_LIST_DETAIL_DATA_A {
DWORD cbSize = SP_DEVINFO_LIST_DETAIL_DATA_A.sizeof;
GUID ClassGuid;
HANDLE RemoteMachineHandle;
CHAR RemoteMachineName[SP_MAX_MACHINENAME_LENGTH];
}
alias SP_DEVINFO_LIST_DETAIL_DATA_A* PSP_DEVINFO_LIST_DETAIL_DATA_A;
struct SP_DEVINFO_LIST_DETAIL_DATA_W {
DWORD cbSize = SP_DEVINFO_LIST_DETAIL_DATA_W.sizeof;
GUID ClassGuid;
HANDLE RemoteMachineHandle;
WCHAR RemoteMachineName[SP_MAX_MACHINENAME_LENGTH];
}
alias SP_DEVINFO_LIST_DETAIL_DATA_W* PSP_DEVINFO_LIST_DETAIL_DATA_W;
extern(Windows) alias UINT function(PVOID,UINT,UINT_PTR,UINT_PTR) PSP_FILE_CALLBACK_A;
extern(Windows) alias UINT function(PVOID,UINT,UINT_PTR,UINT_PTR) PSP_FILE_CALLBACK_W;
struct SP_DEVINSTALL_PARAMS_A {
DWORD cbSize = SP_DEVINSTALL_PARAMS_A.sizeof;
DWORD Flags;
DWORD FlagsEx;
HWND hwndParent;
PSP_FILE_CALLBACK_A InstallMsgHandler;
PVOID InstallMsgHandlerContext;
HSPFILEQ FileQueue;
ULONG_PTR ClassInstallReserved;
DWORD Reserved;
CHAR DriverPath[MAX_PATH];
}
alias SP_DEVINSTALL_PARAMS_A* PSP_DEVINSTALL_PARAMS_A;
struct SP_DEVINSTALL_PARAMS_W {
DWORD cbSize = SP_DEVINSTALL_PARAMS_W.sizeof;
DWORD Flags;
DWORD FlagsEx;
HWND hwndParent;
PSP_FILE_CALLBACK_W InstallMsgHandler;
PVOID InstallMsgHandlerContext;
HSPFILEQ FileQueue;
ULONG_PTR ClassInstallReserved;
DWORD Reserved;
WCHAR DriverPath[MAX_PATH];
}
alias SP_DEVINSTALL_PARAMS_W* PSP_DEVINSTALL_PARAMS_W;
struct SP_CLASSINSTALL_HEADER {
DWORD cbSize = SP_CLASSINSTALL_HEADER.sizeof;
DI_FUNCTION InstallFunction;
}
alias SP_CLASSINSTALL_HEADER* PSP_CLASSINSTALL_HEADER;
struct SP_ENABLECLASS_PARAMS {
SP_CLASSINSTALL_HEADER ClassInstallHeader;
GUID ClassGuid;
DWORD EnableMessage;
}
alias SP_ENABLECLASS_PARAMS* PSP_ENABLECLASS_PARAMS;
struct SP_MOVEDEV_PARAMS {
SP_CLASSINSTALL_HEADER ClassInstallHeader;
SP_DEVINFO_DATA SourceDeviceInfoData;
}
alias SP_MOVEDEV_PARAMS* PSP_MOVEDEV_PARAMS;
struct SP_PROPCHANGE_PARAMS {
SP_CLASSINSTALL_HEADER ClassInstallHeader;
DWORD StateChange;
DWORD Scope;
DWORD HwProfile;
}
alias SP_PROPCHANGE_PARAMS* PSP_PROPCHANGE_PARAMS;
struct SP_REMOVEDEVICE_PARAMS {
SP_CLASSINSTALL_HEADER ClassInstallHeader;
DWORD Scope;
DWORD HwProfile;
}
alias SP_REMOVEDEVICE_PARAMS* PSP_REMOVEDEVICE_PARAMS;
struct SP_UNREMOVEDEVICE_PARAMS {
SP_CLASSINSTALL_HEADER ClassInstallHeader;
DWORD Scope;
DWORD HwProfile;
}
alias SP_UNREMOVEDEVICE_PARAMS* PSP_UNREMOVEDEVICE_PARAMS;
struct SP_SELECTDEVICE_PARAMS_A {
SP_CLASSINSTALL_HEADER ClassInstallHeader;
CHAR Title[MAX_TITLE_LEN];
CHAR Instructions[MAX_INSTRUCTION_LEN];
CHAR ListLabel[MAX_LABEL_LEN];
CHAR SubTitle[MAX_SUBTITLE_LEN];
BYTE Reserved[2];
}
alias SP_SELECTDEVICE_PARAMS_A* PSP_SELECTDEVICE_PARAMS_A;
struct SP_SELECTDEVICE_PARAMS_W {
SP_CLASSINSTALL_HEADER ClassInstallHeader;
WCHAR Title[MAX_TITLE_LEN];
WCHAR Instructions[MAX_INSTRUCTION_LEN];
WCHAR ListLabel[MAX_LABEL_LEN];
WCHAR SubTitle[MAX_SUBTITLE_LEN];
}
alias SP_SELECTDEVICE_PARAMS_W* PSP_SELECTDEVICE_PARAMS_W;
extern(Windows) alias BOOL function(PVOID,DWORD) PDETECT_PROGRESS_NOTIFY;
struct SP_DETECTDEVICE_PARAMS {
SP_CLASSINSTALL_HEADER ClassInstallHeader;
PDETECT_PROGRESS_NOTIFY DetectProgressNotify;
PVOID ProgressNotifyParam;
}
alias SP_DETECTDEVICE_PARAMS* PSP_DETECTDEVICE_PARAMS;
struct SP_INSTALLWIZARD_DATA {
SP_CLASSINSTALL_HEADER ClassInstallHeader;
DWORD Flags;
HPROPSHEETPAGE DynamicPages[MAX_INSTALLWIZARD_DYNAPAGES];
DWORD NumDynamicPages;
DWORD DynamicPageFlags;
DWORD PrivateFlags;
LPARAM PrivateData;
HWND hwndWizardDlg;
}
alias SP_INSTALLWIZARD_DATA* PSP_INSTALLWIZARD_DATA;
struct SP_NEWDEVICEWIZARD_DATA {
SP_CLASSINSTALL_HEADER ClassInstallHeader;
DWORD Flags;
HPROPSHEETPAGE DynamicPages[MAX_INSTALLWIZARD_DYNAPAGES];
DWORD NumDynamicPages;
HWND hwndWizardDlg;
}
alias SP_NEWDEVICEWIZARD_DATA* PSP_NEWDEVICEWIZARD_DATA;
alias SP_NEWDEVICEWIZARD_DATA SP_ADDPROPERTYPAGE_DATA;
alias SP_NEWDEVICEWIZARD_DATA* PSP_ADDPROPERTYPAGE_DATA;
struct SP_TROUBLESHOOTER_PARAMS_A {
SP_CLASSINSTALL_HEADER ClassInstallHeader;
CHAR ChmFile[MAX_PATH];
CHAR HtmlTroubleShooter[MAX_PATH];
}
alias SP_TROUBLESHOOTER_PARAMS_A* PSP_TROUBLESHOOTER_PARAMS_A;
struct SP_TROUBLESHOOTER_PARAMS_W {
SP_CLASSINSTALL_HEADER ClassInstallHeader;
WCHAR ChmFile[MAX_PATH];
WCHAR HtmlTroubleShooter[MAX_PATH];
}
alias SP_TROUBLESHOOTER_PARAMS_W* PSP_TROUBLESHOOTER_PARAMS_W;
struct SP_POWERMESSAGEWAKE_PARAMS_A {
SP_CLASSINSTALL_HEADER ClassInstallHeader;
CHAR PowerMessageWake[LINE_LEN*2];
}
alias SP_POWERMESSAGEWAKE_PARAMS_A* PSP_POWERMESSAGEWAKE_PARAMS_A;
struct SP_POWERMESSAGEWAKE_PARAMS_W {
SP_CLASSINSTALL_HEADER ClassInstallHeader;
WCHAR PowerMessageWake[LINE_LEN*2];
}
alias SP_POWERMESSAGEWAKE_PARAMS_W* PSP_POWERMESSAGEWAKE_PARAMS_W;
struct SP_DRVINFO_DATA_V2_A {
DWORD cbSize = SP_DRVINFO_DATA_V2_A.sizeof;
DWORD DriverType;
ULONG_PTR Reserved;
CHAR Description[LINE_LEN];
CHAR MfgName[LINE_LEN];
CHAR ProviderName[LINE_LEN];
FILETIME DriverDate;
DWORDLONG DriverVersion;
}
alias SP_DRVINFO_DATA_V2_A* PSP_DRVINFO_DATA_V2_A;
struct SP_DRVINFO_DATA_V2_W {
DWORD cbSize = SP_DRVINFO_DATA_V2_A.sizeof;
DWORD DriverType;
ULONG_PTR Reserved;
WCHAR Description[LINE_LEN];
WCHAR MfgName[LINE_LEN];
WCHAR ProviderName[LINE_LEN];
FILETIME DriverDate;
DWORDLONG DriverVersion;
}
alias SP_DRVINFO_DATA_V2_W* PSP_DRVINFO_DATA_V2_W;
struct SP_DRVINFO_DATA_V1_A {
DWORD cbSize = SP_DRVINFO_DATA_V1_A.sizeof;
DWORD DriverType;
ULONG_PTR Reserved;
CHAR Description[LINE_LEN];
CHAR MfgName[LINE_LEN];
CHAR ProviderName[LINE_LEN];
}
alias SP_DRVINFO_DATA_V1_A* PSP_DRVINFO_DATA_V1_A;
struct SP_DRVINFO_DATA_V1_W {
DWORD cbSize = SP_DRVINFO_DATA_V1_W.sizeof;
DWORD DriverType;
ULONG_PTR Reserved;
WCHAR Description[LINE_LEN];
WCHAR MfgName[LINE_LEN];
WCHAR ProviderName[LINE_LEN];
}
alias SP_DRVINFO_DATA_V1_W* PSP_DRVINFO_DATA_V1_W;
version (Unicode) {
alias SP_DRVINFO_DATA_V1_W SP_DRVINFO_DATA_V1;
alias SP_DRVINFO_DATA_V2_W SP_DRVINFO_DATA_V2;
} else {
alias SP_DRVINFO_DATA_V1_A SP_DRVINFO_DATA_V1;
alias SP_DRVINFO_DATA_V2_A SP_DRVINFO_DATA_V2;
}
alias SP_DRVINFO_DATA_V1* PSP_DRVINFO_DATA_V1;
alias SP_DRVINFO_DATA_V2* PSP_DRVINFO_DATA_V2;
static if(USE_SP_DRVINFO_DATA_V1) {
alias SP_DRVINFO_DATA_V1_A SP_DRVINFO_DATA_A;
alias SP_DRVINFO_DATA_V1_A* PSP_DRVINFO_DATA_A;
alias SP_DRVINFO_DATA_V1_W SP_DRVINFO_DATA_W;
alias SP_DRVINFO_DATA_V1_W* PSP_DRVINFO_DATA_W;
alias SP_DRVINFO_DATA_V1 SP_DRVINFO_DATA;
alias SP_DRVINFO_DATA_V1* PSP_DRVINFO_DATA;
} else {
alias SP_DRVINFO_DATA_V2_A SP_DRVINFO_DATA_A;
alias SP_DRVINFO_DATA_V2_A* PSP_DRVINFO_DATA_A;
alias SP_DRVINFO_DATA_V2_W SP_DRVINFO_DATA_W;
alias SP_DRVINFO_DATA_V2_W* PSP_DRVINFO_DATA_W;
alias SP_DRVINFO_DATA_V2 SP_DRVINFO_DATA;
alias SP_DRVINFO_DATA_V2* PSP_DRVINFO_DATA;
}
extern(Windows) alias DWORD function(HDEVINFO,PSP_DEVINFO_DATA,PSP_DEVINFO_DATA,PVOID) PSP_DETSIG_CMPPROC;
struct SP_DRVINFO_DETAIL_DATA_A {
DWORD cbSize = SP_DRVINFO_DETAIL_DATA_A.sizeof;
FILETIME InfDate;
DWORD CompatIDsOffset;
DWORD CompatIDsLength;
ULONG_PTR Reserved;
CHAR SectionName[LINE_LEN];
CHAR InfFileName[MAX_PATH];
CHAR DrvDescription[LINE_LEN];
CHAR _HardwareID[1];
CHAR* HardwareID() { return _HardwareID.ptr; }
}
alias SP_DRVINFO_DETAIL_DATA_A* PSP_DRVINFO_DETAIL_DATA_A;
struct SP_DRVINFO_DETAIL_DATA_W {
DWORD cbSize = SP_DRVINFO_DETAIL_DATA_W.sizeof;
FILETIME InfDate;
DWORD CompatIDsOffset;
DWORD CompatIDsLength;
ULONG_PTR Reserved;
WCHAR SectionName[LINE_LEN];
WCHAR InfFileName[MAX_PATH];
WCHAR DrvDescription[LINE_LEN];
WCHAR _HardwareID[1];
WCHAR* HardwareID() { return _HardwareID.ptr; }
}
alias SP_DRVINFO_DETAIL_DATA_W* PSP_DRVINFO_DETAIL_DATA_W;
struct SP_DRVINSTALL_PARAMS {
DWORD cbSize = SP_DRVINSTALL_PARAMS.sizeof;
DWORD Rank;
DWORD Flags;
DWORD_PTR PrivateData;
DWORD Reserved;
}
alias SP_DRVINSTALL_PARAMS* PSP_DRVINSTALL_PARAMS;
struct COINSTALLER_CONTEXT_DATA {
BOOL PostProcessing;
DWORD InstallResult;
PVOID PrivateData;
}
alias COINSTALLER_CONTEXT_DATA* PCOINSTALLER_CONTEXT_DATA;
struct SP_CLASSIMAGELIST_DATA {
DWORD cbSize = SP_CLASSIMAGELIST_DATA.sizeof;
HIMAGELIST ImageList;
ULONG_PTR Reserved;
}
alias SP_CLASSIMAGELIST_DATA* PSP_CLASSIMAGELIST_DATA;
struct SP_PROPSHEETPAGE_REQUEST {
DWORD cbSize = SP_PROPSHEETPAGE_REQUEST.sizeof;
DWORD PageRequested;
HDEVINFO DeviceInfoSet;
PSP_DEVINFO_DATA DeviceInfoData;
}
alias SP_PROPSHEETPAGE_REQUEST* PSP_PROPSHEETPAGE_REQUEST;
struct SP_BACKUP_QUEUE_PARAMS_A {
DWORD cbSize = SP_BACKUP_QUEUE_PARAMS_A.sizeof;
CHAR FullInfPath[MAX_PATH];
INT FilenameOffset;
}
alias SP_BACKUP_QUEUE_PARAMS_A* PSP_BACKUP_QUEUE_PARAMS_A;
struct SP_BACKUP_QUEUE_PARAMS_W {
DWORD cbSize = SP_BACKUP_QUEUE_PARAMS_W.sizeof;
WCHAR FullInfPath[MAX_PATH];
INT FilenameOffset;
}
alias SP_BACKUP_QUEUE_PARAMS_W* PSP_BACKUP_QUEUE_PARAMS_W;
version (Unicode) {
alias SP_ORIGINAL_FILE_INFO_W SP_ORIGINAL_FILE_INFO;
alias SP_ORIGINAL_FILE_INFO_W* PSP_ORIGINAL_FILE_INFO;
alias FILEPATHS_W FILEPATHS;
alias FILEPATHS_W* PFILEPATHS;
alias SOURCE_MEDIA_W SOURCE_MEDIA;
alias SOURCE_MEDIA_W* PSOURCE_MEDIA;
alias CABINET_INFO_W CABINET_INFO;
alias CABINET_INFO_W* PCABINET_INFO;
alias FILE_IN_CABINET_INFO_W FILE_IN_CABINET_INFO;
alias FILE_IN_CABINET_INFO_W* PFILE_IN_CABINET_INFO;
alias SP_FILE_COPY_PARAMS_W SP_FILE_COPY_PARAMS;
alias SP_FILE_COPY_PARAMS_W* PSP_FILE_COPY_PARAMS;
alias SP_DEVICE_INTERFACE_DETAIL_DATA_W SP_DEVICE_INTERFACE_DETAIL_DATA;
alias SP_DEVICE_INTERFACE_DETAIL_DATA_W* PSP_DEVICE_INTERFACE_DETAIL_DATA;
deprecated {
alias SP_DEVICE_INTERFACE_DETAIL_DATA_W SP_INTERFACE_DEVICE_DETAIL_DATA;
alias SP_DEVICE_INTERFACE_DETAIL_DATA_W* PSP_INTERFACE_DEVICE_DETAIL_DATA;
}
alias SP_DEVINFO_LIST_DETAIL_DATA_W SP_DEVINFO_LIST_DETAIL_DATA;
alias SP_DEVINFO_LIST_DETAIL_DATA_W *PSP_DEVINFO_LIST_DETAIL_DATA;
alias SP_DEVINSTALL_PARAMS_W SP_DEVINSTALL_PARAMS;
alias SP_DEVINSTALL_PARAMS_W* PSP_DEVINSTALL_PARAMS;
alias SP_SELECTDEVICE_PARAMS_W SP_SELECTDEVICE_PARAMS;
alias SP_SELECTDEVICE_PARAMS_W* PSP_SELECTDEVICE_PARAMS;
alias SP_TROUBLESHOOTER_PARAMS_W SP_TROUBLESHOOTER_PARAMS;
alias SP_TROUBLESHOOTER_PARAMS_W* PSP_TROUBLESHOOTER_PARAMS;
alias SP_POWERMESSAGEWAKE_PARAMS_W SP_POWERMESSAGEWAKE_PARAMS;
alias SP_POWERMESSAGEWAKE_PARAMS_W* PSP_POWERMESSAGEWAKE_PARAMS;
alias SP_DRVINFO_DETAIL_DATA_W SP_DRVINFO_DETAIL_DATA;
alias SP_DRVINFO_DETAIL_DATA_W* PSP_DRVINFO_DETAIL_DATA;
alias SP_BACKUP_QUEUE_PARAMS_W SP_BACKUP_QUEUE_PARAMS;
alias SP_BACKUP_QUEUE_PARAMS_W* PSP_BACKUP_QUEUE_PARAMS;
} else {
alias SP_ORIGINAL_FILE_INFO_A SP_ORIGINAL_FILE_INFO;
alias SP_ORIGINAL_FILE_INFO_A* PSP_ORIGINAL_FILE_INFO;
alias FILEPATHS_A FILEPATHS;
alias FILEPATHS_A* PFILEPATHS;
alias SOURCE_MEDIA_A SOURCE_MEDIA;
alias SOURCE_MEDIA_A* PSOURCE_MEDIA;
alias CABINET_INFO_A CABINET_INFO;
alias CABINET_INFO_A* PCABINET_INFO;
alias FILE_IN_CABINET_INFO_A FILE_IN_CABINET_INFO;
alias FILE_IN_CABINET_INFO_A* PFILE_IN_CABINET_INFO;
alias SP_FILE_COPY_PARAMS_A SP_FILE_COPY_PARAMS;
alias SP_FILE_COPY_PARAMS_A* PSP_FILE_COPY_PARAMS;
alias SP_DEVICE_INTERFACE_DETAIL_DATA_A SP_DEVICE_INTERFACE_DETAIL_DATA;
alias SP_DEVICE_INTERFACE_DETAIL_DATA_A* PSP_DEVICE_INTERFACE_DETAIL_DATA;
deprecated {
alias SP_DEVICE_INTERFACE_DETAIL_DATA_A SP_INTERFACE_DEVICE_DETAIL_DATA;
alias SP_DEVICE_INTERFACE_DETAIL_DATA_A* PSP_INTERFACE_DEVICE_DETAIL_DATA;
}
alias SP_DEVINFO_LIST_DETAIL_DATA_A SP_DEVINFO_LIST_DETAIL_DATA;
alias SP_DEVINFO_LIST_DETAIL_DATA_A* PSP_DEVINFO_LIST_DETAIL_DATA;
alias SP_DEVINSTALL_PARAMS_A SP_DEVINSTALL_PARAMS;
alias SP_DEVINSTALL_PARAMS_A* PSP_DEVINSTALL_PARAMS;
alias SP_SELECTDEVICE_PARAMS_A SP_SELECTDEVICE_PARAMS;
alias SP_SELECTDEVICE_PARAMS_A* PSP_SELECTDEVICE_PARAMS;
alias SP_TROUBLESHOOTER_PARAMS_A SP_TROUBLESHOOTER_PARAMS;
alias SP_TROUBLESHOOTER_PARAMS_A* PSP_TROUBLESHOOTER_PARAMS;
alias SP_POWERMESSAGEWAKE_PARAMS_A SP_POWERMESSAGEWAKE_PARAMS;
alias SP_POWERMESSAGEWAKE_PARAMS_A* PSP_POWERMESSAGEWAKE_PARAMS;
alias SP_DRVINFO_DETAIL_DATA_A SP_DRVINFO_DETAIL_DATA;
alias SP_DRVINFO_DETAIL_DATA_A* PSP_DRVINFO_DETAIL_DATA;
alias SP_BACKUP_QUEUE_PARAMS_A SP_BACKUP_QUEUE_PARAMS;
alias SP_BACKUP_QUEUE_PARAMS_A* PSP_BACKUP_QUEUE_PARAMS;
}
extern (Windows) {
BOOL SetupAddInstallSectionToDiskSpaceListA(HDSKSPC,HINF,HINF,PCSTR,PVOID,UINT);
BOOL SetupAddInstallSectionToDiskSpaceListW(HDSKSPC,HINF,HINF,PCWSTR,PVOID,UINT);
BOOL SetupAddSectionToDiskSpaceListA(HDSKSPC,HINF,HINF,PCSTR,UINT,PVOID,UINT);
BOOL SetupAddSectionToDiskSpaceListW(HDSKSPC,HINF,HINF,PCWSTR,UINT,PVOID,UINT);
BOOL SetupAddToDiskSpaceListA(HDSKSPC,PCSTR,LONGLONG,UINT,PVOID,UINT);
BOOL SetupAddToDiskSpaceListW(HDSKSPC,PCWSTR,LONGLONG,UINT,PVOID,UINT);
BOOL SetupAddToSourceListA(DWORD,PCSTR);
BOOL SetupAddToSourceListW(DWORD,PCWSTR);
BOOL SetupQuerySourceListA(DWORD,PCSTR**List,PUINT);
BOOL SetupQuerySourceListW(DWORD,PCWSTR**List,PUINT);
BOOL SetupFreeSourceListA(PCSTR**List,UINT);
BOOL SetupFreeSourceListW(PCWSTR**List,UINT);
BOOL SetupAdjustDiskSpaceListA(HDSKSPC,LPCSTR,LONGLONG,PVOID,UINT);
BOOL SetupAdjustDiskSpaceListW(HDSKSPC,LPCWSTR,LONGLONG,PVOID,UINT);
UINT SetupBackupErrorA(HWND,PCSTR,PCSTR,PCSTR,UINT,DWORD);
UINT SetupBackupErrorW(HWND,PCWSTR,PCWSTR,PCWSTR,UINT,DWORD);
BOOL SetupCancelTemporary();
BOOL SetupCloseFileQueue(HSPFILEQ);
VOID SetupCloseInfFile(HINF);
VOID SetupCloseLog();
BOOL SetupCommitFileQueueA(HWND,HSPFILEQ,PSP_FILE_CALLBACK_A,PVOID);
BOOL SetupCommitFileQueueW(HWND,HSPFILEQ,PSP_FILE_CALLBACK_W,PVOID);
UINT SetupCopyErrorA(HWND,PCSTR,PCSTR,PCSTR,PCSTR,PCSTR,UINT,DWORD,PSTR,DWORD,PDWORD);
UINT SetupCopyErrorW(HWND,PCWSTR,PCWSTR,PCWSTR,PCWSTR,PCWSTR,UINT,DWORD,PWSTR,DWORD,PDWORD);
BOOL SetupCopyOEMInfA(PCSTR,PCSTR,DWORD,DWORD,PSTR,DWORD,PDWORD,PSTR*);
BOOL SetupCopyOEMInfW(PCWSTR,PCWSTR,DWORD,DWORD,PWSTR,DWORD,PDWORD,PWSTR*);
HDSKSPC SetupCreateDiskSpaceListA(PVOID,DWORD,UINT);
HDSKSPC SetupCreateDiskSpaceListW(PVOID,DWORD,UINT);
DWORD SetupDecompressOrCopyFileA(PCSTR,PCSTR,PUINT);
DWORD SetupDecompressOrCopyFileW(PCWSTR,PCWSTR,PUINT);
UINT SetupDefaultQueueCallbackA(PVOID,UINT,UINT_PTR,UINT_PTR);
UINT SetupDefaultQueueCallbackW(PVOID,UINT,UINT_PTR,UINT_PTR);
UINT SetupDeleteErrorA(HWND,PCSTR,PCSTR,UINT,DWORD);
UINT SetupDeleteErrorW(HWND,PCWSTR,PCWSTR,UINT,DWORD);
BOOL SetupDestroyDiskSpaceList(HDSKSPC);
BOOL SetupDiAskForOEMDisk(HDEVINFO,PSP_DEVINFO_DATA);
BOOL SetupDiBuildClassInfoList(DWORD,LPGUID,DWORD,PDWORD);
BOOL SetupDiBuildClassInfoListExA(DWORD,LPGUID,DWORD,PDWORD,PCSTR,PVOID);
BOOL SetupDiBuildClassInfoListExW(DWORD,LPGUID,DWORD,PDWORD,PCWSTR,PVOID);
BOOL SetupDiBuildDriverInfoList(HDEVINFO,PSP_DEVINFO_DATA,DWORD);
BOOL SetupDiCallClassInstaller(DI_FUNCTION,HDEVINFO,PSP_DEVINFO_DATA);
BOOL SetupDiCancelDriverInfoSearch(HDEVINFO);
BOOL SetupDiChangeState(HDEVINFO,PSP_DEVINFO_DATA);
BOOL SetupDiClassGuidsFromNameA(PCSTR,LPGUID,DWORD,PDWORD);
BOOL SetupDiClassGuidsFromNameW(PCWSTR,LPGUID,DWORD,PDWORD);
BOOL SetupDiClassGuidsFromNameExA(PCSTR,LPGUID,DWORD,PDWORD,PCSTR,PVOID);
BOOL SetupDiClassGuidsFromNameExW(PCWSTR,LPGUID,DWORD,PDWORD,PCWSTR,PVOID);
BOOL SetupDiClassNameFromGuidA(GUID*,PSTR,DWORD,PDWORD);
BOOL SetupDiClassNameFromGuidW(GUID*,PWSTR,DWORD,PDWORD);
BOOL SetupDiClassNameFromGuidExA(GUID*,PSTR,DWORD,PDWORD,PCSTR,PVOID);
BOOL SetupDiClassNameFromGuidExW(GUID*,PWSTR,DWORD,PDWORD,PCWSTR,PVOID);
BOOL SetupDiCreateDeviceInfoA(HDEVINFO,PCSTR,GUID*,PCSTR,HWND,DWORD,PSP_DEVINFO_DATA);
BOOL SetupDiCreateDeviceInfoW(HDEVINFO,PCWSTR,GUID*,PCWSTR,HWND,DWORD,PSP_DEVINFO_DATA);
HDEVINFO SetupDiCreateDeviceInfoList(GUID*,HWND);
HDEVINFO SetupDiCreateDeviceInfoListExA(GUID*,HWND,PCSTR,PVOID);
HDEVINFO SetupDiCreateDeviceInfoListExW(GUID*,HWND,PCWSTR,PVOID);
BOOL SetupDiCreateDeviceInterfaceA(HDEVINFO,PSP_DEVINFO_DATA,GUID*,PCSTR,DWORD,PSP_DEVICE_INTERFACE_DATA);
BOOL SetupDiCreateDeviceInterfaceW(HDEVINFO,PSP_DEVINFO_DATA,GUID*,PCWSTR,DWORD,PSP_DEVICE_INTERFACE_DATA);
HKEY SetupDiCreateDeviceInterfaceRegKeyA(HDEVINFO,PSP_DEVICE_INTERFACE_DATA,DWORD,REGSAM,HINF,PCSTR);
HKEY SetupDiCreateDeviceInterfaceRegKeyW(HDEVINFO,PSP_DEVICE_INTERFACE_DATA,DWORD,REGSAM,HINF,PCWSTR);
HKEY SetupDiCreateDevRegKeyA(HDEVINFO,PSP_DEVINFO_DATA,DWORD,DWORD,DWORD,HINF,PCSTR);
HKEY SetupDiCreateDevRegKeyW(HDEVINFO,PSP_DEVINFO_DATA,DWORD,DWORD,DWORD,HINF,PCWSTR);
BOOL SetupDiDeleteDeviceInfo(HDEVINFO,PSP_DEVINFO_DATA);
BOOL SetupDiDeleteDeviceInterfaceData(HDEVINFO,PSP_DEVICE_INTERFACE_DATA);
BOOL SetupDiDeleteDeviceInterfaceRegKey(HDEVINFO,PSP_DEVICE_INTERFACE_DATA,DWORD);
BOOL SetupDiDeleteDevRegKey(HDEVINFO,PSP_DEVINFO_DATA,DWORD,DWORD,DWORD);
BOOL SetupDiDestroyClassImageList(PSP_CLASSIMAGELIST_DATA);
BOOL SetupDiDestroyDeviceInfoList(HDEVINFO);
BOOL SetupDiDestroyDriverInfoList(HDEVINFO,PSP_DEVINFO_DATA,DWORD);
INT SetupDiDrawMiniIcon(HDC,RECT,INT,DWORD);
BOOL SetupDiEnumDeviceInfo(HDEVINFO,DWORD,PSP_DEVINFO_DATA);
BOOL SetupDiEnumDeviceInterfaces(HDEVINFO,PSP_DEVINFO_DATA,GUID*,DWORD,PSP_DEVICE_INTERFACE_DATA);
BOOL SetupDiEnumDriverInfoA(HDEVINFO,PSP_DEVINFO_DATA,DWORD,DWORD,PSP_DRVINFO_DATA_A);
BOOL SetupDiEnumDriverInfoW(HDEVINFO,PSP_DEVINFO_DATA,DWORD,DWORD,PSP_DRVINFO_DATA_W);
BOOL SetupDiGetActualSectionToInstallA(HINF,PCSTR,PSTR,DWORD,PDWORD,PSTR*);
BOOL SetupDiGetActualSectionToInstallW(HINF,PCWSTR,PWSTR,DWORD,PDWORD,PWSTR*);
BOOL SetupDiGetClassBitmapIndex(GUID*,PINT);
BOOL SetupDiGetClassDescriptionA(GUID*,PSTR,DWORD,PDWORD);
BOOL SetupDiGetClassDescriptionW(GUID*,PWSTR,DWORD,PDWORD);
BOOL SetupDiGetClassDescriptionExA(GUID*,PSTR,DWORD,PDWORD,PCSTR,PVOID);
BOOL SetupDiGetClassDescriptionExW(GUID*,PWSTR,DWORD,PDWORD,PCWSTR,PVOID);
BOOL SetupDiGetClassDevPropertySheetsA(HDEVINFO,PSP_DEVINFO_DATA,LPPROPSHEETHEADERA,DWORD,PDWORD,DWORD);
BOOL SetupDiGetClassDevPropertySheetsW(HDEVINFO,PSP_DEVINFO_DATA,LPPROPSHEETHEADERW,DWORD,PDWORD,DWORD);
HDEVINFO SetupDiGetClassDevsA(GUID*,PCSTR,HWND,DWORD);
HDEVINFO SetupDiGetClassDevsW(GUID*,PCWSTR,HWND,DWORD);
HDEVINFO SetupDiGetClassDevsExA(GUID*,PCSTR,HWND,DWORD,HDEVINFO,PCSTR,PVOID);
HDEVINFO SetupDiGetClassDevsExW(GUID*,PCWSTR,HWND,DWORD,HDEVINFO,PCWSTR,PVOID);
BOOL SetupDiGetClassImageIndex(PSP_CLASSIMAGELIST_DATA,GUID*,PINT);
BOOL SetupDiGetClassImageList(PSP_CLASSIMAGELIST_DATA);
BOOL SetupDiGetClassImageListExA(PSP_CLASSIMAGELIST_DATA,PCSTR,PVOID);
BOOL SetupDiGetClassImageListExW(PSP_CLASSIMAGELIST_DATA,PCWSTR,PVOID);
BOOL SetupDiGetClassInstallParamsA(HDEVINFO,PSP_DEVINFO_DATA,PSP_CLASSINSTALL_HEADER,DWORD,PDWORD);
BOOL SetupDiGetClassInstallParamsW(HDEVINFO,PSP_DEVINFO_DATA,PSP_CLASSINSTALL_HEADER,DWORD,PDWORD);
BOOL SetupDiGetClassRegistryPropertyA(LPGUID,DWORD,PDWORD,PBYTE,DWORD,PDWORD,PCSTR,PVOID);
BOOL SetupDiGetClassRegistryPropertyW(LPGUID,DWORD,PDWORD,PBYTE,DWORD,PDWORD,PCWSTR,PVOID);
BOOL SetupDiGetDeviceInfoListClass(HDEVINFO,LPGUID);
BOOL SetupDiGetDeviceInfoListDetailA(HDEVINFO,PSP_DEVINFO_LIST_DETAIL_DATA_A);
BOOL SetupDiGetDeviceInfoListDetailW(HDEVINFO,PSP_DEVINFO_LIST_DETAIL_DATA_W);
BOOL SetupDiGetDeviceInstallParamsA(HDEVINFO,PSP_DEVINFO_DATA,PSP_DEVINSTALL_PARAMS_A);
BOOL SetupDiGetDeviceInstallParamsW(HDEVINFO,PSP_DEVINFO_DATA,PSP_DEVINSTALL_PARAMS_W);
BOOL SetupDiGetDeviceInstanceIdA(HDEVINFO,PSP_DEVINFO_DATA,PSTR,DWORD,PDWORD);
BOOL SetupDiGetDeviceInstanceIdW(HDEVINFO,PSP_DEVINFO_DATA,PWSTR,DWORD,PDWORD);
BOOL SetupDiGetDeviceInterfaceAlias(HDEVINFO,PSP_DEVICE_INTERFACE_DATA,GUID*,PSP_DEVICE_INTERFACE_DATA);
BOOL SetupDiGetDeviceInterfaceDetailA(HDEVINFO,PSP_DEVICE_INTERFACE_DATA,PSP_DEVICE_INTERFACE_DETAIL_DATA_A,DWORD,PDWORD,PSP_DEVINFO_DATA);
BOOL SetupDiGetDeviceInterfaceDetailW(HDEVINFO,PSP_DEVICE_INTERFACE_DATA,PSP_DEVICE_INTERFACE_DETAIL_DATA_W,DWORD,PDWORD,PSP_DEVINFO_DATA);
BOOL SetupDiGetDeviceRegistryPropertyA(HDEVINFO,PSP_DEVINFO_DATA,DWORD,PDWORD,PBYTE,DWORD,PDWORD);
BOOL SetupDiGetDeviceRegistryPropertyW(HDEVINFO,PSP_DEVINFO_DATA,DWORD,PDWORD,PBYTE,DWORD,PDWORD);
BOOL SetupDiGetDriverInfoDetailA(HDEVINFO,PSP_DEVINFO_DATA,PSP_DRVINFO_DATA_A,PSP_DRVINFO_DETAIL_DATA_A,DWORD,PDWORD);
BOOL SetupDiGetDriverInfoDetailW(HDEVINFO,PSP_DEVINFO_DATA,PSP_DRVINFO_DATA_W,PSP_DRVINFO_DETAIL_DATA_W,DWORD,PDWORD);
BOOL SetupDiGetDriverInstallParamsA(HDEVINFO,PSP_DEVINFO_DATA,PSP_DRVINFO_DATA_A,PSP_DRVINSTALL_PARAMS);
BOOL SetupDiGetDriverInstallParamsW(HDEVINFO,PSP_DEVINFO_DATA,PSP_DRVINFO_DATA_W,PSP_DRVINSTALL_PARAMS);
BOOL SetupDiGetHwProfileFriendlyNameA(DWORD,PSTR,DWORD,PDWORD);
BOOL SetupDiGetHwProfileFriendlyNameExA(DWORD,PSTR,DWORD,PDWORD,PCSTR,PVOID);
BOOL SetupDiGetHwProfileFriendlyNameExW(DWORD,PWSTR,DWORD,PDWORD,PCWSTR,PVOID);
BOOL SetupDiGetHwProfileFriendlyNameW(DWORD,PWSTR,DWORD,PDWORD);
BOOL SetupDiGetHwProfileList(PDWORD,DWORD,PDWORD,PDWORD);
BOOL SetupDiGetHwProfileListExA(PDWORD,DWORD,PDWORD,PDWORD,PCSTR,PVOID);
BOOL SetupDiGetHwProfileListExW(PDWORD,DWORD,PDWORD,PDWORD,PCWSTR,PVOID);
BOOL SetupDiGetINFClassA(PCSTR,LPGUID,PSTR,DWORD,PDWORD);
BOOL SetupDiGetINFClassW(PCWSTR,LPGUID,PWSTR,DWORD,PDWORD);
BOOL SetupDiGetSelectedDevice(HDEVINFO,PSP_DEVINFO_DATA);
BOOL SetupDiGetSelectedDriverA(HDEVINFO,PSP_DEVINFO_DATA,PSP_DRVINFO_DATA_A);
BOOL SetupDiGetSelectedDriverW(HDEVINFO,PSP_DEVINFO_DATA,PSP_DRVINFO_DATA_W);
HPROPSHEETPAGE SetupDiGetWizardage(HDEVINFO,PSP_DEVINFO_DATA,PSP_INSTALLWIZARD_DATA,DWORD,DWORD);
BOOL SetupDiInstallClassA(HWND,PCSTR,DWORD,HSPFILEQ);
BOOL SetupDiInstallClassW(HWND,PCWSTR,DWORD,HSPFILEQ);
BOOL SetupDiInstallClassExA(HWND,PCSTR,DWORD,HSPFILEQ,GUID*,PVOID,PVOID);
BOOL SetupDiInstallClassExW(HWND,PCWSTR,DWORD,HSPFILEQ,GUID*,PVOID,PVOID);
BOOL SetupDiInstallDevice(HDEVINFO,PSP_DEVINFO_DATA);
BOOL SetupDiInstallDeviceInterfaces(HDEVINFO,PSP_DEVINFO_DATA);
BOOL SetupDiInstallDriverFiles(HDEVINFO,PSP_DEVINFO_DATA);
BOOL SetupDiLoadClassIcon(GUID*,HICON*,PINT);
BOOL SetupDiMoveDuplicateDevice(HDEVINFO,PSP_DEVINFO_DATA);
HKEY SetupDiOpenClassRegKey(GUID*,REGSAM);
HKEY SetupDiOpenClassRegKeyExA(GUID*,REGSAM,DWORD,PCSTR,PVOID);
HKEY SetupDiOpenClassRegKeyExW(GUID*,REGSAM,DWORD,PCWSTR,PVOID);
BOOL SetupDiOpenDeviceInfoA(HDEVINFO,PCSTR,HWND,DWORD,PSP_DEVINFO_DATA);
BOOL SetupDiOpenDeviceInfoW(HDEVINFO,PCWSTR,HWND,DWORD,PSP_DEVINFO_DATA);
BOOL SetupDiOpenDeviceInterfaceA(HDEVINFO,PCSTR,DWORD,PSP_DEVICE_INTERFACE_DATA);
BOOL SetupDiOpenDeviceInterfaceW(HDEVINFO,PCWSTR,DWORD,PSP_DEVICE_INTERFACE_DATA);
HKEY SetupDiOpenDeviceInterfaceRegKey(HDEVINFO,PSP_DEVICE_INTERFACE_DATA,DWORD,REGSAM);
HKEY SetupDiOpenDevRegKey(HDEVINFO,PSP_DEVINFO_DATA,DWORD,DWORD,DWORD,REGSAM);
BOOL SetupDiRegisterCoDeviceInstallers(HDEVINFO,PSP_DEVINFO_DATA);
BOOL SetupDiRegisterDeviceInfo(HDEVINFO,PSP_DEVINFO_DATA,DWORD,PSP_DETSIG_CMPPROC,PVOID,PSP_DEVINFO_DATA);
BOOL SetupDiRemoveDevice(HDEVINFO,PSP_DEVINFO_DATA);
BOOL SetupDiRemoveDeviceInterface(HDEVINFO,PSP_DEVICE_INTERFACE_DATA);
BOOL SetupDiSelectBestCompatDrv(HDEVINFO,PSP_DEVINFO_DATA);
BOOL SetupDiSelectDevice(HDEVINFO,PSP_DEVINFO_DATA);
BOOL SetupDiSelectOEMDrv(HWND,HDEVINFO,PSP_DEVINFO_DATA);
BOOL SetupDiSetClassInstallParamsA(HDEVINFO,PSP_DEVINFO_DATA,PSP_CLASSINSTALL_HEADER,DWORD);
BOOL SetupDiSetClassInstallParamsW(HDEVINFO,PSP_DEVINFO_DATA,PSP_CLASSINSTALL_HEADER,DWORD);
BOOL SetupDiSetClassRegistryPropertyA(LPGUID,DWORD,BYTE*,DWORD,PCSTR,PVOID);
BOOL SetupDiSetClassRegistryPropertyW(LPGUID,DWORD,BYTE*,DWORD,PCWSTR,PVOID);
BOOL SetupDiSetDeviceInstallParamsA(HDEVINFO,PSP_DEVINFO_DATA,PSP_DEVINSTALL_PARAMS_A);
BOOL SetupDiSetDeviceInstallParamsW(HDEVINFO,PSP_DEVINFO_DATA,PSP_DEVINSTALL_PARAMS_W);
BOOL SetupDiSetDeviceRegistryPropertyA(HDEVINFO,PSP_DEVINFO_DATA,DWORD,BYTE*,DWORD);
BOOL SetupDiSetDeviceRegistryPropertyW(HDEVINFO,PSP_DEVINFO_DATA,DWORD,BYTE*,DWORD);
BOOL SetupDiSetDriverInstallParamsA(HDEVINFO,PSP_DEVINFO_DATA,PSP_DRVINFO_DATA_A,PSP_DRVINSTALL_PARAMS);
BOOL SetupDiSetDriverInstallParamsW(HDEVINFO,PSP_DEVINFO_DATA,PSP_DRVINFO_DATA_W,PSP_DRVINSTALL_PARAMS);
BOOL SetupDiSetSelectedDevice(HDEVINFO,PSP_DEVINFO_DATA);
BOOL SetupDiSetSelectedDriverA(HDEVINFO,PSP_DEVINFO_DATA,PSP_DRVINFO_DATA_A);
BOOL SetupDiSetSelectedDriverW(HDEVINFO,PSP_DEVINFO_DATA,PSP_DRVINFO_DATA_W);
BOOL SetupDiUnremoveDevice(HDEVINFO,PSP_DEVINFO_DATA);
HDSKSPC SetupDuplicateDiskSpaceListA(HDSKSPC,PVOID,DWORD,UINT);
HDSKSPC SetupDuplicateDiskSpaceListW(HDSKSPC,PVOID,DWORD,UINT);
BOOL SetupFindFirstLineA(HINF,PCSTR,PCSTR,PINFCONTEXT);
BOOL SetupFindFirstLineW(HINF,PCWSTR,PCWSTR,PINFCONTEXT);
BOOL SetupFindNextLine(PINFCONTEXT,PINFCONTEXT);
BOOL SetupFindNextMatchLineA(PINFCONTEXT,PCSTR,PINFCONTEXT);
BOOL SetupFindNextMatchLineW(PINFCONTEXT,PCWSTR,PINFCONTEXT);
BOOL SetupFreeA(PCSTR**,UINT);
BOOL SetupFreeW(PCWSTR**,UINT);
BOOL SetupGetBackupInformationA(HSPFILEQ,PSP_BACKUP_QUEUE_PARAMS_A);
BOOL SetupGetBackupInformationW(HSPFILEQ,PSP_BACKUP_QUEUE_PARAMS_W);
BOOL SetupGetBinaryField(PINFCONTEXT,DWORD,PBYTE,DWORD,LPDWORD);
DWORD SetupGetFieldCount(PINFCONTEXT);
DWORD SetupGetFileCompressionInfoA(PCSTR,PSTR*,PDWORD,PDWORD,PUINT);
DWORD SetupGetFileCompressionInfoW(PCWSTR,PWSTR*,PDWORD,PDWORD,PUINT);
BOOL SetupGetInfFileListA(PCSTR,DWORD,PSTR,DWORD,PDWORD);
BOOL SetupGetInfFileListW(PCWSTR,DWORD,PWSTR,DWORD,PDWORD);
BOOL SetupGetInfInformationA(LPCVOID,DWORD,PSP_INF_INFORMATION,DWORD,PDWORD);
BOOL SetupGetInfInformationW(LPCVOID,DWORD,PSP_INF_INFORMATION,DWORD,PDWORD);
BOOL SetupGetIntField(PINFCONTEXT,DWORD,PINT);
BOOL SetupGetLineByIndexA(HINF,PCSTR,DWORD,PINFCONTEXT);
BOOL SetupGetLineByIndexW(HINF,PCWSTR,DWORD,PINFCONTEXT);
LONG SetupGetLineCountA(HINF,PCSTR);
LONG SetupGetLineCountW(HINF,PCWSTR);
BOOL SetupGetLineTextA(PINFCONTEXT,HINF,PCSTR,PCSTR,PSTR,DWORD,PDWORD);
BOOL SetupGetLineTextW(PINFCONTEXT,HINF,PCWSTR,PCWSTR,PWSTR,DWORD,PDWORD);
BOOL SetupGetMultiSzFieldA(PINFCONTEXT,DWORD,PSTR,DWORD,LPDWORD);
BOOL SetupGetMultiSzFieldW(PINFCONTEXT,DWORD,PWSTR,DWORD,LPDWORD);
BOOL SetupGetSourceFileLocationA(HINF,PINFCONTEXT,PCSTR,PUINT,PSTR,DWORD,PDWORD);
BOOL SetupGetSourceFileLocationW(HINF,PINFCONTEXT,PCWSTR,PUINT,PWSTR,DWORD,PDWORD);
BOOL SetupGetSourceFileSizeA(HINF,PINFCONTEXT,PCSTR,PCSTR,PDWORD,UINT);
BOOL SetupGetSourceFileSizeW(HINF,PINFCONTEXT,PCWSTR,PCWSTR,PDWORD,UINT);
BOOL SetupGetSourceInfoA(HINF,UINT,UINT,PSTR,DWORD,PDWORD);
BOOL SetupGetSourceInfoW(HINF,UINT,UINT,PWSTR,DWORD,PDWORD);
BOOL SetupGetStringFieldA(PINFCONTEXT,DWORD,PSTR,DWORD,PDWORD);
BOOL SetupGetStringFieldW(PINFCONTEXT,DWORD,PWSTR,DWORD,PDWORD);
BOOL SetupGetTargetPathA(HINF,PINFCONTEXT,PCSTR,PSTR,DWORD,PDWORD);
BOOL SetupGetTargetPathW(HINF,PINFCONTEXT,PCWSTR,PWSTR,DWORD,PDWORD);
PVOID SetupInitDefaultQueueCallback(HWND);
PVOID SetupInitDefaultQueueCallbackEx(HWND,HWND,UINT,DWORD,PVOID);
HSPFILELOG SetupInitializeFileLogA(PCSTR,DWORD);
HSPFILELOG SetupInitializeFileLogW(PCWSTR,DWORD);
BOOL SetupInstallFileA(HINF,PINFCONTEXT,PCSTR,PCSTR,PCSTR,DWORD,PSP_FILE_CALLBACK_A,PVOID);
BOOL SetupInstallFileW(HINF,PINFCONTEXT,PCWSTR,PCWSTR,PCWSTR,DWORD,PSP_FILE_CALLBACK_W,PVOID);
BOOL SetupInstallFileExA(HINF,PINFCONTEXT,PCSTR,PCSTR,PCSTR,DWORD,PSP_FILE_CALLBACK_A,PVOID,PBOOL);
BOOL SetupInstallFileExW(HINF,PINFCONTEXT,PCWSTR,PCWSTR,PCWSTR,DWORD,PSP_FILE_CALLBACK_W,PVOID,PBOOL);
BOOL SetupInstallFilesFromInfSectionA(HINF,HINF,HSPFILEQ,PCSTR,PCSTR,UINT);
BOOL SetupInstallFilesFromInfSectionW(HINF,HINF,HSPFILEQ,PCWSTR,PCWSTR,UINT);
BOOL SetupInstallFromInfSectionA(HWND,HINF,PCSTR,UINT,HKEY,PCSTR,UINT,PSP_FILE_CALLBACK_A,PVOID,HDEVINFO,PSP_DEVINFO_DATA);
BOOL SetupInstallFromInfSectionW(HWND,HINF,PCWSTR,UINT,HKEY,PCWSTR,UINT,PSP_FILE_CALLBACK_W,PVOID,HDEVINFO,PSP_DEVINFO_DATA);
BOOL SetupInstallServicesFromInfSectionA(HINF,PCSTR,DWORD);
BOOL SetupInstallServicesFromInfSectionW(HINF,PCWSTR,DWORD);
BOOL SetupInstallServicesFromInfSectionExA(HINF,PCSTR,DWORD,HDEVINFO,PSP_DEVINFO_DATA,PVOID,PVOID);
BOOL SetupInstallServicesFromInfSectionExW(HINF,PCWSTR,DWORD,HDEVINFO,PSP_DEVINFO_DATA,PVOID,PVOID);
BOOL SetupIterateCabinetA(PCSTR,DWORD,PSP_FILE_CALLBACK_A,PVOID);
BOOL SetupIterateCabinetW(PCWSTR,DWORD,PSP_FILE_CALLBACK_W,PVOID);
BOOL SetupLogErrorA(LPCSTR,LogSeverity);
BOOL SetupLogErrorW(LPCWSTR,LogSeverity);
BOOL SetupLogFileA(HSPFILELOG,PCSTR,PCSTR,PCSTR,DWORD,PCSTR,PCSTR,PCSTR,DWORD);
BOOL SetupLogFileW(HSPFILELOG,PCWSTR,PCWSTR,PCWSTR,DWORD,PCWSTR,PCWSTR,PCWSTR,DWORD);
BOOL SetupOpenAppendInfFileA(PCSTR,HINF,PUINT);
BOOL SetupOpenAppendInfFileW(PCWSTR,HINF,PUINT);
HSPFILEQ SetupOpenFileQueue();
HINF SetupOpenInfFileA(PCSTR,PCSTR,DWORD,PUINT);
HINF SetupOpenInfFileW(PCWSTR,PCWSTR,DWORD,PUINT);
BOOL SetupOpenLog(BOOL);
HINF SetupOpenMasterInf();
UINT SetupPromptForDiskA(HWND,PCSTR,PCSTR,PCSTR,PCSTR,PCSTR,DWORD,PSTR,DWORD,PDWORD);
UINT SetupPromptForDiskW(HWND,PCWSTR,PCWSTR,PCWSTR,PCWSTR,PCWSTR,DWORD,PWSTR,DWORD,PDWORD);
INT SetupPromptReboot(HSPFILEQ,HWND,BOOL);
BOOL SetupQueryA(DWORD,PCSTR**,PUINT);
BOOL SetupQueryW(DWORD,PCWSTR**,PUINT);
BOOL SetupQueryDrivesInDiskSpaceListA(HDSKSPC,PSTR,DWORD,PDWORD);
BOOL SetupQueryDrivesInDiskSpaceListW(HDSKSPC,PWSTR,DWORD,PDWORD);
BOOL SetupQueryFileLogA(HSPFILELOG,PCSTR,PCSTR,SetupFileLogInfo,PSTR,DWORD,PDWORD);
BOOL SetupQueryFileLogW(HSPFILELOG,PCWSTR,PCWSTR,SetupFileLogInfo,PWSTR,DWORD,PDWORD);
BOOL SetupQueryInfFileInformationA(PSP_INF_INFORMATION,UINT,PSTR,DWORD,PDWORD);
BOOL SetupQueryInfFileInformationW(PSP_INF_INFORMATION,UINT,PWSTR,DWORD,PDWORD);
BOOL SetupQueryInfOriginalFileInformationA(PSP_INF_INFORMATION,UINT,PSP_ALTPLATFORM_INFO,PSP_ORIGINAL_FILE_INFO_A);
BOOL SetupQueryInfOriginalFileInformationW(PSP_INF_INFORMATION,UINT,PSP_ALTPLATFORM_INFO,PSP_ORIGINAL_FILE_INFO_W);
BOOL SetupQueryInfVersionInformationA(PSP_INF_INFORMATION,UINT,PSTR,PSTR,DWORD,PDWORD);
BOOL SetupQueryInfVersionInformationW(PSP_INF_INFORMATION,UINT,PCWSTR,PWSTR,DWORD,PDWORD);
BOOL SetupQuerySpaceRequiredOnDriveA(HDSKSPC,PCSTR,LONGLONG*,PVOID,UINT);
BOOL SetupQuerySpaceRequiredOnDriveW(HDSKSPC,PCWSTR,LONGLONG*,PVOID,UINT);
BOOL SetupQueueCopyA(HSPFILEQ,PCSTR,PCSTR,PCSTR,PCSTR,PCSTR,PCSTR,PCSTR,DWORD);
BOOL SetupQueueCopyW(HSPFILEQ,PCWSTR,PCWSTR,PCWSTR,PCWSTR,PCWSTR,PCWSTR,PCWSTR,DWORD);
BOOL SetupQueueCopyIndirectA(PSP_FILE_COPY_PARAMS_A);
BOOL SetupQueueCopyIndirectW(PSP_FILE_COPY_PARAMS_W);
BOOL SetupQueueCopySectionA(HSPFILEQ,PCSTR,HINF,HINF,PCSTR,DWORD);
BOOL SetupQueueCopySectionW(HSPFILEQ,PCWSTR,HINF,HINF,PCWSTR,DWORD);
BOOL SetupQueueDefaultCopyA(HSPFILEQ,HINF,PCSTR,PCSTR,PCSTR,DWORD);
BOOL SetupQueueDefaultCopyW(HSPFILEQ,HINF,PCWSTR,PCWSTR,PCWSTR,DWORD);
BOOL SetupQueueDeleteA(HSPFILEQ,PCSTR,PCSTR);
BOOL SetupQueueDeleteW(HSPFILEQ,PCWSTR,PCWSTR);
BOOL SetupQueueDeleteSectionA(HSPFILEQ,HINF,HINF,PCSTR);
BOOL SetupQueueDeleteSectionW(HSPFILEQ,HINF,HINF,PCWSTR);
BOOL SetupQueueRenameA(HSPFILEQ,PCSTR,PCSTR,PCSTR,PCSTR);
BOOL SetupQueueRenameW(HSPFILEQ,PCWSTR,PCWSTR,PCWSTR,PCWSTR);
BOOL SetupQueueRenameSectionA(HSPFILEQ,HINF,HINF,PCSTR);
BOOL SetupQueueRenameSectionW(HSPFILEQ,HINF,HINF,PCWSTR);
BOOL SetupRemoveFileLogEntryA(HSPFILELOG,PCSTR,PCSTR);
BOOL SetupRemoveFileLogEntryW(HSPFILELOG,PCWSTR,PCWSTR);
BOOL SetupRemoveFromDiskSpaceListA(HDSKSPC,PCSTR,UINT,PVOID,UINT);
BOOL SetupRemoveFromDiskSpaceListW(HDSKSPC,PCWSTR,UINT,PVOID,UINT);
BOOL SetupRemoveFromSourceListA(DWORD,PCSTR);
BOOL SetupRemoveFromSourceListW(DWORD,PCWSTR);
BOOL SetupRemoveInstallSectionFromDiskSpaceListA(HDSKSPC,HINF,HINF,PCSTR,PVOID,UINT);
BOOL SetupRemoveInstallSectionFromDiskSpaceListW(HDSKSPC,HINF,HINF,PCWSTR,PVOID,UINT);
BOOL SetupRemoveSectionFromDiskSpaceListA(HDSKSPC,HINF,HINF,PCSTR,UINT,PVOID,UINT);
BOOL SetupRemoveSectionFromDiskSpaceListW(HDSKSPC,HINF,HINF,PCWSTR,UINT,PVOID,UINT);
UINT SetupRenameErrorA(HWND,PCSTR,PCSTR,PCSTR,UINT,DWORD);
UINT SetupRenameErrorW(HWND,PCWSTR,PCWSTR,PCWSTR,UINT,DWORD);
BOOL SetupScanFileQueueA(HSPFILEQ,DWORD,HWND,PSP_FILE_CALLBACK_A,PVOID,PDWORD);
BOOL SetupScanFileQueueW(HSPFILEQ,DWORD,HWND,PSP_FILE_CALLBACK_W,PVOID,PDWORD);
BOOL SetupSetDirectoryIdA(HINF,DWORD,PCSTR);
BOOL SetupSetDirectoryIdW(HINF,DWORD,PCWSTR);
BOOL SetupSetDirectoryIdExA(HINF,DWORD,PCSTR,DWORD,DWORD,PVOID);
BOOL SetupSetDirectoryIdExW(HINF,DWORD,PCWSTR,DWORD,DWORD,PVOID);
BOOL SetupSetFileQueueAlternatePlatformA(HSPFILEQ,PSP_ALTPLATFORM_INFO,PCSTR);
BOOL SetupSetFileQueueAlternatePlatformW(HSPFILEQ,PSP_ALTPLATFORM_INFO,PCWSTR);
BOOL SetupSetPlatformPathOverrideA(PCSTR);
BOOL SetupSetPlatformPathOverrideW(PCWSTR);
BOOL SetupSetSourceListA(DWORD,PCSTR*,UINT);
BOOL SetupSetSourceListW(DWORD,PCWSTR*,UINT);
VOID SetupTermDefaultQueueCallback(PVOID);
BOOL SetupTerminateFileLog(HSPFILELOG);
}
deprecated {
alias SetupDiCreateDeviceInterfaceW SetupDiCreateInterfaceDeviceW;
alias SetupDiCreateDeviceInterfaceRegKeyW SetupDiCreateInterfaceDeviceRegKeyW;
alias SetupDiOpenDeviceInterfaceW SetupDiOpenInterfaceDeviceW;
alias SetupDiGetDeviceInterfaceDetailW SetupDiGetInterfaceDeviceDetailW;
alias SetupDiCreateDeviceInterfaceA SetupDiCreateInterfaceDeviceA;
alias SetupDiCreateDeviceInterfaceRegKeyA SetupDiCreateInterfaceDeviceRegKeyA;
alias SetupDiOpenDeviceInterfaceA SetupDiOpenInterfaceDeviceA;
alias SetupDiGetDeviceInterfaceDetailA SetupDiGetInterfaceDeviceDetailA;
}
version (Unicode) {
alias PSP_FILE_CALLBACK_W PSP_FILE_CALLBACK;
alias SetupAddInstallSectionToDiskSpaceListW SetupAddInstallSectionToDiskSpaceList;
alias SetupAddSectionToDiskSpaceListW SetupAddSectionToDiskSpaceList;
alias SetupAddToDiskSpaceListW SetupAddToDiskSpaceList;
alias SetupAddToSourceListW SetupAddToSourceList;
alias SetupAdjustDiskSpaceListW SetupAdjustDiskSpaceList;
alias SetupBackupErrorW SetupBackupError;
alias SetupCommitFileQueueW SetupCommitFileQueue;
alias SetupCopyErrorW SetupCopyError;
alias SetupCopyOEMInfW SetupCopyOEMInf;
alias SetupCreateDiskSpaceListW SetupCreateDiskSpaceList;
alias SetupDecompressOrCopyFileW SetupDecompressOrCopyFile;
alias SetupDefaultQueueCallbackW SetupDefaultQueueCallback;
alias SetupDeleteErrorW SetupDeleteError;
alias SetupDiBuildClassInfoListExW SetupDiBuildClassInfoListEx;
alias SetupDiClassGuidsFromNameExW SetupDiClassGuidsFromNameEx;
alias SetupDiClassGuidsFromNameW SetupDiClassGuidsFromName;
alias SetupDiClassNameFromGuidExW SetupDiClassNameFromGuidEx;
alias SetupDiClassNameFromGuidW SetupDiClassNameFromGuid;
alias SetupDiCreateDeviceInfoListExW SetupDiCreateDeviceInfoListEx;
alias SetupDiCreateDeviceInfoW SetupDiCreateDeviceInfo;
alias SetupDiCreateDeviceInterfaceRegKeyW SetupDiCreateDeviceInterfaceRegKey;
deprecated alias SetupDiCreateDeviceInterfaceRegKeyW SetupDiCreateInterfaceDeviceRegKey;
alias SetupDiCreateDeviceInterfaceW SetupDiCreateDeviceInterface;
deprecated alias SetupDiCreateDeviceInterfaceW SetupDiCreateInterfaceDevice;
alias SetupDiCreateDevRegKeyW SetupDiCreateDevRegKey;
alias SetupDiEnumDriverInfoW SetupDiEnumDriverInfo;
alias SetupDiGetActualSectionToInstallW SetupDiGetActualSectionToInstall;
alias SetupDiGetClassDescriptionExW SetupDiGetClassDescriptionEx;
alias SetupDiGetClassDescriptionW SetupDiGetClassDescription;
alias SetupDiGetClassDevPropertySheetsW SetupDiGetClassDevPropertySheets;
alias SetupDiGetClassDevsExW SetupDiGetClassDevsEx;
alias SetupDiGetClassDevsW SetupDiGetClassDevs;
alias SetupDiGetClassImageListExW SetupDiGetClassImageListEx;
alias SetupDiGetClassInstallParamsW SetupDiGetClassInstallParams;
alias SetupDiGetClassRegistryPropertyW SetupDiGetClassRegistryProperty;
alias SetupDiGetDeviceInfoListDetailW SetupDiGetDeviceInfoListDetail;
alias SetupDiGetDeviceInstallParamsW SetupDiGetDeviceInstallParams;
alias SetupDiGetDeviceInstanceIdW SetupDiGetDeviceInstanceId;
alias SetupDiGetDeviceInterfaceDetailW SetupDiGetDeviceInterfaceDetail;
deprecated alias SetupDiGetDeviceInterfaceDetailW SetupDiGetInterfaceDeviceDetail;
alias SetupDiGetDeviceRegistryPropertyW SetupDiGetDeviceRegistryProperty;
alias SetupDiGetDriverInfoDetailW SetupDiGetDriverInfoDetail;
alias SetupDiGetDriverInstallParamsW SetupDiGetDriverInstallParams;
alias SetupDiGetHwProfileFriendlyNameExW SetupDiGetHwProfileFriendlyNameEx;
alias SetupDiGetHwProfileFriendlyNameW SetupDiGetHwProfileFriendlyName;
alias SetupDiGetHwProfileListExW SetupDiGetHwProfileListEx;
alias SetupDiGetINFClassW SetupDiGetINFClass;
alias SetupDiGetSelectedDriverW SetupDiGetSelectedDriver;
alias SetupDiInstallClassExW SetupDiInstallClassEx;
alias SetupDiInstallClassW SetupDiInstallClass;
alias SetupDiOpenClassRegKeyExW SetupDiOpenClassRegKeyEx;
alias SetupDiOpenDeviceInfoW SetupDiOpenDeviceInfo;
alias SetupDiOpenDeviceInterfaceW SetupDiOpenDeviceInterface;
deprecated alias SetupDiOpenDeviceInterfaceW SetupDiOpenInterfaceDevice;
alias SetupDiSetClassInstallParamsW SetupDiSetClassInstallParams;
alias SetupDiSetClassRegistryPropertyW SetupDiSetClassRegistryProperty;
alias SetupDiSetDeviceInstallParamsW SetupDiSetDeviceInstallParams;
alias SetupDiSetDeviceRegistryPropertyW SetupDiSetDeviceRegistryProperty;
alias SetupDiSetDriverInstallParamsW SetupDiSetDriverInstallParams;
alias SetupDiSetSelectedDriverW SetupDiSetSelectedDriver;
alias SetupDuplicateDiskSpaceListW SetupDuplicateDiskSpaceList;
alias SetupFindFirstLineW SetupFindFirstLine;
alias SetupFindNextMatchLineW SetupFindNextMatchLine;
alias SetupFreeSourceListW SetupFreeSourceList;
alias SetupGetBackupInformationW SetupGetBackupInformation;
alias SetupGetFileCompressionInfoW SetupGetFileCompressionInfo;
alias SetupGetInfFileListW SetupGetInfFileList;
alias SetupGetInfInformationW SetupGetInfInformation;
alias SetupGetLineByIndexW SetupGetLineByIndex;
alias SetupGetLineCountW SetupGetLineCount;
alias SetupGetLineTextW SetupGetLineText;
alias SetupGetMultiSzFieldW SetupGetMultiSzField;
alias SetupGetSourceFileLocationW SetupGetSourceFileLocation;
alias SetupGetSourceFileSizeW SetupGetSourceFileSize;
alias SetupGetSourceInfoW SetupGetSourceInfo;
alias SetupGetStringFieldW SetupGetStringField;
alias SetupGetTargetPathW SetupGetTargetPath;
alias SetupInitializeFileLogW SetupInitializeFileLog;
alias SetupInstallFileExW SetupInstallFileEx;
alias SetupInstallFilesFromInfSectionW SetupInstallFilesFromInfSection;
alias SetupInstallFileW SetupInstallFile;
alias SetupInstallFromInfSectionW SetupInstallFromInfSection;
alias SetupInstallServicesFromInfSectionExW SetupInstallServicesFromInfSectionEx;
alias SetupInstallServicesFromInfSectionW SetupInstallServicesFromInfSection;
alias SetupIterateCabinetW SetupIterateCabinet;
alias SetupLogErrorW SetupLogError;
alias SetupLogFileW SetupLogFile;
alias SetupOpenAppendInfFileW SetupOpenAppendInfFile;
alias SetupOpenInfFileW SetupOpenInfFile;
alias SetupPromptForDiskW SetupPromptForDisk;
alias SetupQueryDrivesInDiskSpaceListW SetupQueryDrivesInDiskSpaceList;
alias SetupQueryFileLogW SetupQueryFileLog;
alias SetupQueryInfFileInformationW SetupQueryInfFileInformation;
alias SetupQueryInfOriginalFileInformationW SetupQueryInfOriginalFileInformation;
alias SetupQueryInfVersionInformationW SetupQueryInfVersionInformation;
alias SetupQuerySourceListW SetupQuerySourceList;
alias SetupQuerySpaceRequiredOnDriveW SetupQuerySpaceRequiredOnDrive;
alias SetupQueueCopyIndirectW SetupQueueCopyIndirect;
alias SetupQueueCopySectionW SetupQueueCopySection;
alias SetupQueueCopyW SetupQueueCopy;
alias SetupQueueDefaultCopyW SetupQueueDefaultCopy;
alias SetupQueueDeleteSectionW SetupQueueDeleteSection;
alias SetupQueueDeleteW SetupQueueDelete;
alias SetupQueueRenameSectionW SetupQueueRenameSection;
alias SetupQueueRenameW SetupQueueRename;
alias SetupRemoveFileLogEntryW SetupRemoveFileLogEntry;
alias SetupRemoveFromDiskSpaceListW SetupRemoveFromDiskSpaceList;
alias SetupRemoveFromSourceListW SetupRemoveFromSourceList;
alias SetupRemoveInstallSectionFromDiskSpaceListW SetupRemoveInstallSectionFromDiskSpaceList;
alias SetupRemoveSectionFromDiskSpaceListW SetupRemoveSectionFromDiskSpaceList;
alias SetupRenameErrorW SetupRenameError;
alias SetupScanFileQueueW SetupScanFileQueue;
alias SetupSetDirectoryIdExW SetupSetDirectoryIdEx;
alias SetupSetDirectoryIdW SetupSetDirectoryId;
alias SetupSetFileQueueAlternatePlatformW SetupSetFileQueueAlternatePlatform;
alias SetupSetPlatformPathOverrideW SetupSetPlatformPathOverride;
alias SetupSetSourceListW SetupSetSourceList;
} else {
alias PSP_FILE_CALLBACK_A PSP_FILE_CALLBACK;
alias SetupAddInstallSectionToDiskSpaceListA SetupAddInstallSectionToDiskSpaceList;
alias SetupAddSectionToDiskSpaceListA SetupAddSectionToDiskSpaceList;
alias SetupAddToDiskSpaceListA SetupAddToDiskSpaceList;
alias SetupAddToSourceListA SetupAddToSourceList;
alias SetupAdjustDiskSpaceListA SetupAdjustDiskSpaceList;
alias SetupBackupErrorA SetupBackupError;
alias SetupCommitFileQueueA SetupCommitFileQueue;
alias SetupCopyErrorA SetupCopyError;
alias SetupCopyOEMInfA SetupCopyOEMInf;
alias SetupCreateDiskSpaceListA SetupCreateDiskSpaceList;
alias SetupDecompressOrCopyFileA SetupDecompressOrCopyFile;
alias SetupDefaultQueueCallbackA SetupDefaultQueueCallback;
alias SetupDeleteErrorA SetupDeleteError;
alias SetupDiBuildClassInfoListExA SetupDiBuildClassInfoListEx;
alias SetupDiClassGuidsFromNameA SetupDiClassGuidsFromName;
alias SetupDiClassGuidsFromNameExA SetupDiClassGuidsFromNameEx;
alias SetupDiClassNameFromGuidA SetupDiClassNameFromGuid;
alias SetupDiClassNameFromGuidExA SetupDiClassNameFromGuidEx;
alias SetupDiCreateDeviceInfoA SetupDiCreateDeviceInfo;
alias SetupDiCreateDeviceInfoListExA SetupDiCreateDeviceInfoListEx;
alias SetupDiCreateDeviceInterfaceA SetupDiCreateDeviceInterface;
deprecated alias SetupDiCreateDeviceInterfaceA SetupDiCreateInterfaceDevice;
alias SetupDiCreateDeviceInterfaceRegKeyA SetupDiCreateDeviceInterfaceRegKey;
deprecated alias SetupDiCreateDeviceInterfaceRegKeyA SetupDiCreateInterfaceDeviceRegKey;
alias SetupDiCreateDevRegKeyA SetupDiCreateDevRegKey;
alias SetupDiDeleteDeviceInterfaceData SetupDiDeleteInterfaceDeviceData;
alias SetupDiEnumDriverInfoA SetupDiEnumDriverInfo;
alias SetupDiGetActualSectionToInstallA SetupDiGetActualSectionToInstall;
alias SetupDiGetClassDescriptionA SetupDiGetClassDescription;
alias SetupDiGetClassDescriptionExA SetupDiGetClassDescriptionEx;
alias SetupDiGetClassDevPropertySheetsA SetupDiGetClassDevPropertySheets;
alias SetupDiGetClassDevsA SetupDiGetClassDevs;
alias SetupDiGetClassDevsExA SetupDiGetClassDevsEx;
alias SetupDiGetClassImageListExA SetupDiGetClassImageListEx;
alias SetupDiGetClassInstallParamsA SetupDiGetClassInstallParams;
alias SetupDiGetClassRegistryPropertyA SetupDiGetClassRegistryProperty;
alias SetupDiGetDeviceInfoListDetailA SetupDiGetDeviceInfoListDetail;
alias SetupDiGetDeviceInstallParamsA SetupDiGetDeviceInstallParams;
alias SetupDiGetDeviceInstanceIdA SetupDiGetDeviceInstanceId;
alias SetupDiGetDeviceInterfaceDetailA SetupDiGetDeviceInterfaceDetail;
deprecated alias SetupDiGetDeviceInterfaceDetailA SetupDiGetInterfaceDeviceDetail;
alias SetupDiGetDeviceRegistryPropertyA SetupDiGetDeviceRegistryProperty;
alias SetupDiGetDriverInfoDetailA SetupDiGetDriverInfoDetail;
alias SetupDiGetDriverInstallParamsA SetupDiGetDriverInstallParams;
alias SetupDiGetHwProfileFriendlyNameA SetupDiGetHwProfileFriendlyName;
alias SetupDiGetHwProfileFriendlyNameExA SetupDiGetHwProfileFriendlyNameEx;
alias SetupDiGetHwProfileListExA SetupDiGetHwProfileListEx;
alias SetupDiGetINFClassA SetupDiGetINFClass;
alias SetupDiGetSelectedDriverA SetupDiGetSelectedDriver;
alias SetupDiInstallClassA SetupDiInstallClass;
alias SetupDiInstallClassExA SetupDiInstallClassEx;
alias SetupDiOpenClassRegKeyExA SetupDiOpenClassRegKeyEx;
alias SetupDiOpenDeviceInfoA SetupDiOpenDeviceInfo;
alias SetupDiOpenDeviceInterfaceA SetupDiOpenDeviceInterface;
deprecated alias SetupDiOpenDeviceInterfaceA SetupDiOpenInterfaceDevice;
alias SetupDiSetClassInstallParamsA SetupDiSetClassInstallParams;
alias SetupDiSetClassRegistryPropertyA SetupDiSetClassRegistryProperty;
alias SetupDiSetDeviceInstallParamsA SetupDiSetDeviceInstallParams;
alias SetupDiSetDeviceRegistryPropertyA SetupDiSetDeviceRegistryProperty;
alias SetupDiSetDriverInstallParamsA SetupDiSetDriverInstallParams;
alias SetupDiSetSelectedDriverA SetupDiSetSelectedDriver;
alias SetupDuplicateDiskSpaceListA SetupDuplicateDiskSpaceList;
alias SetupFindFirstLineA SetupFindFirstLine;
alias SetupFindNextMatchLineA SetupFindNextMatchLine;
alias SetupFreeSourceListA SetupFreeSourceList;
alias SetupGetBackupInformationA SetupGetBackupInformation;
alias SetupGetFileCompressionInfoA SetupGetFileCompressionInfo;
alias SetupGetInfFileListA SetupGetInfFileList;
alias SetupGetInfInformationA SetupGetInfInformation;
alias SetupGetLineByIndexA SetupGetLineByIndex;
alias SetupGetLineCountA SetupGetLineCount;
alias SetupGetLineTextA SetupGetLineText;
alias SetupGetMultiSzFieldA SetupGetMultiSzField;
alias SetupGetSourceFileLocationA SetupGetSourceFileLocation;
alias SetupGetSourceFileSizeA SetupGetSourceFileSize;
alias SetupGetSourceInfoA SetupGetSourceInfo;
alias SetupGetStringFieldA SetupGetStringField;
alias SetupGetTargetPathA SetupGetTargetPath;
alias SetupInitializeFileLogA SetupInitializeFileLog;
alias SetupInstallFileA SetupInstallFile;
alias SetupInstallFileExA SetupInstallFileEx;
alias SetupInstallFilesFromInfSectionA SetupInstallFilesFromInfSection;
alias SetupInstallFromInfSectionA SetupInstallFromInfSection;
alias SetupInstallServicesFromInfSectionA SetupInstallServicesFromInfSection;
alias SetupInstallServicesFromInfSectionExA SetupInstallServicesFromInfSectionEx;
alias SetupIterateCabinetA SetupIterateCabinet;
alias SetupLogErrorA SetupLogError;
alias SetupLogFileA SetupLogFile;
alias SetupOpenAppendInfFileA SetupOpenAppendInfFile;
alias SetupOpenInfFileA SetupOpenInfFile;
alias SetupPromptForDiskA SetupPromptForDisk;
alias SetupQueryDrivesInDiskSpaceListA SetupQueryDrivesInDiskSpaceList;
alias SetupQueryFileLogA SetupQueryFileLog;
alias SetupQueryInfFileInformationA SetupQueryInfFileInformation;
alias SetupQueryInfOriginalFileInformationA SetupQueryInfOriginalFileInformation;
alias SetupQueryInfVersionInformationA SetupQueryInfVersionInformation;
alias SetupQuerySourceListA SetupQuerySourceList;
alias SetupQuerySpaceRequiredOnDriveA SetupQuerySpaceRequiredOnDrive;
alias SetupQueueCopyA SetupQueueCopy;
alias SetupQueueCopyIndirectA SetupQueueCopyIndirect;
alias SetupQueueCopySectionA SetupQueueCopySection;
alias SetupQueueDefaultCopyA SetupQueueDefaultCopy;
alias SetupQueueDeleteA SetupQueueDelete;
alias SetupQueueDeleteSectionA SetupQueueDeleteSection;
alias SetupQueueRenameA SetupQueueRename;
alias SetupQueueRenameSectionA SetupQueueRenameSection;
alias SetupRemoveFileLogEntryA SetupRemoveFileLogEntry;
alias SetupRemoveFromDiskSpaceListA SetupRemoveFromDiskSpaceList;
alias SetupRemoveFromSourceListA SetupRemoveFromSourceList;
alias SetupRemoveInstallSectionFromDiskSpaceListA SetupRemoveInstallSectionFromDiskSpaceList;
alias SetupRemoveSectionFromDiskSpaceListA SetupRemoveSectionFromDiskSpaceList;
alias SetupRenameErrorA SetupRenameError;
alias SetupScanFileQueueA SetupScanFileQueue;
alias SetupSetDirectoryIdA SetupSetDirectoryId;
alias SetupSetDirectoryIdExA SetupSetDirectoryIdEx;
alias SetupSetFileQueueAlternatePlatformA SetupSetFileQueueAlternatePlatform;
alias SetupSetPlatformPathOverrideA SetupSetPlatformPathOverride;
alias SetupSetSourceListA SetupSetSourceList;
}
|
D
|
/*******************************************************************************
copyright: Copyright (c) 2008 Jeff Davey. All rights reserved
license: BSD style: $(LICENSE)
author: Jeff Davey <j@submersion.com>
*******************************************************************************/
module tango.net.util.c.OpenSSL;
private import tango.sys.SharedLib;
private import tango.sys.Environment;
private import rt.core.stdc.stdio;
private import rt.core.stdc.stringz;
private import rt.core.stdc.config: c_long,c_ulong;
private import tango.io.FilePath;
private import tango.core.Thread;
private import tango.core.sync.Mutex;
private import tango.core.sync.ReadWriteMutex;
private import tango.text.convert.Format;
private import Integer = tango.text.convert.Integer;
/*******************************************************************************
This module contains all of the dynamic bindings needed to the
OpenSSL libraries (libssl.so/libssl32.dll and libcrypto.so/libeay32.dll)
*******************************************************************************/
/*
XXX TODO XXX
A lot of unsigned longs and longs were converted to uint and int
These will need to be reversed to support 64bit tango
(should use c_long and c_ulong from rt.core.stdc.config)
XXX TODO XXX
*/
version(linux)
{
version(build)
{
pragma(link, "dl");
}
}
const uint BYTES_ENTROPY = 2048; // default bytes of entropy to load on startup.
private CRYPTO_dynlock_value *last = null;
Mutex _dynLocksMutex = null;
extern (C)
{
const int NID_sha1 = 64;
const int NID_md5 = 4;
const int RSA_PKCS1_OAEP_PADDING = 4;
const int RSA_PKCS1_PADDING = 1;
const int BIO_C_SET_NBIO = 102;
const int SHA_DIGEST_LENGTH = 20;
const int SSL_CTRL_SET_SESS_CACHE_MODE = 44;
const int MBSTRING_FLAG = 0x1000;
const int MBSTRING_ASC = MBSTRING_FLAG | 1;
const int EVP_PKEY_RSA = 6;
const int RSA_F4 = 0x1001;
const int SSL_SENT_SHUTDOWN = 1;
const int SSL_RECEIVED_SHUTDOWN = 2;
const int BIO_C_GET_SSL = 110;
const int BIO_CTRL_RESET = 1;
const int BIO_CTRL_INFO = 3;
const int BIO_FLAGS_READ = 0x01;
const int BIO_FLAGS_WRITE = 0x02;
const int BIO_FLAGS_IO_SPECIAL = 0x04;
const int BIO_FLAGS_SHOULD_RETRY = 0x08;
const int BIO_CLOSE = 0x00;
const int BIO_NOCLOSE = 0x01;
const int ASN1_STRFLGS_ESC_CTRL = 2;
const int ASN1_STRFLGS_ESC_MSB = 4;
const int XN_FLAG_SEP_MULTILINE = (4 << 16);
const int XN_FLAG_SPC_EQ = (1 << 23);
const int XN_FLAG_FN_LN = (1 << 21);
const int XN_FLAG_FN_ALIGN = (1 << 25);
const int XN_FLAG_MULTILINE = ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB | XN_FLAG_SEP_MULTILINE | XN_FLAG_SPC_EQ | XN_FLAG_FN_LN | XN_FLAG_FN_ALIGN;
const char* PEM_STRING_EVP_PKEY = "ANY PRIVATE KEY";
const char* PEM_STRING_X509 = "CERTIFICATE";
const char* PEM_STRING_RSA_PUBLIC = "RSA PUBLIC KEY";
const int SSL_CTRL_OPTIONS = 32;
const int SSL_OP_ALL = 0x00000FFFL;
const int SSL_OP_NO_SSLv2 = 0x01000000L;
const int CRYPTO_LOCK = 1;
const int CRYPTO_UNLOCK = 2;
const int CRYPTO_READ = 4;
const int CRYPTO_WRITE = 8;
const int ERR_TXT_STRING = 0x02;
const int MD5_CBLOCK = 64;
const int MD5_LBLOCK = MD5_CBLOCK / 4;
const int MD5_DIGEST_LENGTH = 16;
const int EVP_MAX_BLOCK_LENGTH = 32;
const int EVP_MAX_IV_LENGTH = 16;
struct MD5_CTX
{
uint A;
uint B;
uint C;
uint D;
uint Nl;
uint Nh;
uint[MD5_LBLOCK] data;
uint num;
};
struct EVP_CIPHER_CTX
{
void *cipher;
void *engine;
int encrypt;
int buf_len;
ubyte[EVP_MAX_IV_LENGTH] oiv;
ubyte[EVP_MAX_IV_LENGTH] iv;
ubyte buf[EVP_MAX_BLOCK_LENGTH];
int num;
void *ap_data;
int key_len;
c_ulong flags;
void *cipher_data;
int final_used;
int block_mask;
ubyte[EVP_MAX_BLOCK_LENGTH] finalv;
};
// fallback for OpenSSL 0.9.7l 28 Sep 2006 that defines only macros
int EVP_CIPHER_CTX_block_size_097l(EVP_CIPHER_CTX *e){
return *((cast(int*)e.cipher)+1);
}
struct BIO
{
BIO_METHOD *method;
int function(BIO *b, int a, char *c, int d, int e, int f) callback;
char *cb_arg;
int init;
int shutdown;
int flags;
// yadda yadda
};
typedef BIO* function(int sock, int close_flag) tBIO_new_socket;
typedef BIO* function(SSL_CTX *ctx, int client) tBIO_new_ssl;
typedef void function(BIO *bio) tBIO_free_all;
typedef BIO* function(BIO *b, BIO *append) tBIO_push;
struct SSL_CTX {};
struct SSL {};
struct SSL_METHOD {};
struct EVP_PKEY
{
int type;
int save_type;
int references;
void *pkey;
// yadda yadda ...
};
struct X509_STORE_CTX {};
struct EVP_CIPHER {};
struct X509_ALGOR {};
struct ASN1_INTEGER {};
struct EVP_MD {};
struct ASN1_STRING
{
int length;
int type;
char *data;
int flags;
}
typedef ASN1_STRING ASN1_GENERALIZEDTIME;
typedef ASN1_STRING ASN1_TIME;
struct X509_STORE {};
struct X509_VAL
{
ASN1_TIME *notBefore;
ASN1_TIME *notAfter;
}
struct X509_CINF // being lazy here, only doing the first peices up to what I need
{
ASN1_INTEGER *vers;
ASN1_INTEGER *serialNumber;
X509_ALGOR *signature;
X509_NAME *issuer;
X509_VAL *validity;
// yadda yadda
}
struct X509 // ditto X509_CINF
{
X509_CINF *cert_info;
// yadda yadda
};
struct X509_NAME {};
struct RSA {};
struct BIO_METHOD {};
typedef int function(char *buf, int size, int rwflag, void *userdata) pem_password_cb;
typedef char *function() d2i_of_void;
typedef int function() i2d_of_void;
typedef SSL_CTX* function(SSL_METHOD *meth) tSSL_CTX_new;
typedef SSL_METHOD* function() tSSLv23_method;
typedef EVP_PKEY* function(int type, EVP_PKEY **a, ubyte **pp, int length) td2i_PrivateKey;
typedef int function(SSL_CTX *ctx, EVP_PKEY *pkey) tSSL_CTX_use_PrivateKey;
typedef void function(SSL_CTX *ctx, int mode, int function(int, X509_STORE_CTX *) callback) tSSL_CTX_set_verify;
typedef void function(EVP_PKEY *pkey) tEVP_PKEY_free;
typedef int function(SSL_CTX *ctx, int cmd, int larg, void *parg) tSSL_CTX_ctrl;
typedef int function(SSL_CTX *ctx, char *str) tSSL_CTX_set_cipher_list;
typedef void function(SSL_CTX *) tSSL_CTX_free;
typedef void function() tSSL_load_error_strings;
typedef void function() tSSL_library_init;
typedef void function() tOpenSSL_add_all_digests;
typedef int function(char *file, int max_bytes) tRAND_load_file;
typedef int function() tCRYPTO_num_locks;
typedef void function(uint function() cb) tCRYPTO_set_id_callback;
typedef void function(void function(int mode, int type, char *file, int line) cb) tCRYPTO_set_locking_callback;
typedef void function(CRYPTO_dynlock_value *function(char *file, int line) cb) tCRYPTO_set_dynlock_create_callback;
typedef void function(void function(int mode, CRYPTO_dynlock_value *lock, char *file, int lineNo) cb) tCRYPTO_set_dynlock_lock_callback;
typedef void function(void function(CRYPTO_dynlock_value *lock, char *file, int line) cb) tCRYPTO_set_dynlock_destroy_callback;
typedef uint function(char **file, int *line, char **data, int *flags) tERR_get_error_line_data;
typedef void function(uint pid) tERR_remove_state;
typedef void function() tRAND_cleanup;
typedef void function() tERR_free_strings;
typedef void function() tEVP_cleanup;
typedef void function() tOBJ_cleanup;
typedef void function() tX509V3_EXT_cleanup;
typedef void function() tCRYPTO_cleanup_all_ex_data;
typedef int function(BIO *b, void *data, int len) tBIO_write;
typedef int function(BIO *b, void *data, int len) tBIO_read;
typedef int function(SSL_CTX *ctx) tSSL_CTX_check_private_key;
typedef EVP_PKEY* function(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u) tPEM_read_bio_PrivateKey;
typedef BIO* function(char *filename, char *mode) tBIO_new_file;
typedef int function() tERR_peek_error;
typedef int function(BIO *b, int flags) tBIO_test_flags;
typedef int function(BIO *b, int cmd, int larg, void *parg) tBIO_ctrl;
typedef void function(SSL *ssl, int mode) tSSL_set_shutdown;
typedef int function(SSL *ssl) tSSL_get_shutdown;
typedef int function(SSL_CTX *ctx, X509 *x) tSSL_CTX_use_certificate;
typedef void function(SSL_CTX *CTX, X509_STORE *store) tSSL_CTX_set_cert_store;
typedef int function(SSL_CTX *ctx, char *CAfile, char *CApath) tSSL_CTX_load_verify_locations;
typedef X509* function(X509_STORE_CTX *ctx) tX509_STORE_CTX_get_current_cert;
typedef int function(X509_STORE_CTX *ctx) tX509_STORE_CTX_get_error;
typedef int function(X509_STORE_CTX *ctx) tX509_STORE_CTX_get_error_depth;
typedef X509_STORE* function() tX509_STORE_new;
typedef void function(X509_STORE *v) tX509_STORE_free;
typedef int function(X509_STORE *store, X509 *x) tX509_STORE_add_cert;
// typedef int function(X509_STORE *store, int depth) tX509_STORE_set_depth;
typedef BIO* function(void *buff, int len) tBIO_new_mem_buf;
typedef RSA* function(int bits, uint e, void function(int a, int b, void *c) callback, void *cb_arg) tRSA_generate_key;
typedef EVP_PKEY* function() tEVP_PKEY_new;
typedef int function(EVP_PKEY *pkey, int type, char *key) tEVP_PKEY_assign;
typedef void function(RSA *r) tRSA_free;
typedef BIO* function(BIO_METHOD *type) tBIO_new;
typedef BIO_METHOD* function() tBIO_s_mem;
typedef int function(BIO *bp, EVP_PKEY *x, EVP_CIPHER *cipher, char *kstr, int klen, pem_password_cb, void *) tPEM_write_bio_PKCS8PrivateKey;
typedef EVP_CIPHER* function() tEVP_aes_256_cbc;
typedef void* function(d2i_of_void d2i, char *name, BIO *bp, void **x, pem_password_cb cb, void *u) tPEM_ASN1_read_bio;
typedef X509* function() tX509_new;
typedef void function(X509 *x) tX509_free;
typedef int function(X509 *x, int ver) tX509_set_version;
typedef int function(ASN1_INTEGER *a, int v) tASN1_INTEGER_set;
typedef ASN1_INTEGER* function(X509 *x) tX509_get_serialNumber;
typedef int function(ASN1_INTEGER *a) tASN1_INTEGER_get;
typedef ASN1_TIME* function(ASN1_TIME *s, int adj) tX509_gmtime_adj;
typedef int function(X509 *x, EVP_PKEY *pkey) tX509_set_pubkey;
typedef X509_NAME* function(X509 *x) tX509_get_subject_name;
typedef int function(BIO *b, X509_NAME *nm, int indent, uint flags) tX509_NAME_print_ex;
typedef int function(X509 *x, X509_NAME *name) tX509_set_issuer_name;
typedef int function(X509 *x, EVP_PKEY *pkey, EVP_MD *md) tX509_sign;
typedef EVP_MD* function() tEVP_sha1;
typedef X509_STORE_CTX* function() tX509_STORE_CTX_new;
typedef int function(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509, void *shizzle) tX509_STORE_CTX_init;
typedef int function(X509_STORE_CTX *ctx) tX509_verify_cert;
typedef void function(X509_STORE_CTX *ctx) tX509_STORE_CTX_free;
typedef int function(i2d_of_void i2d, char *name, BIO *bp, char *x, EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb cb, void *u) tPEM_ASN1_write_bio;
typedef int function(X509_NAME *name, char* field, int type, char *bytes, int len, int loc, int set) tX509_NAME_add_entry_by_txt;
typedef int function(SSL_CTX *ctx, ubyte *id, uint len) tSSL_CTX_set_session_id_context;
typedef int function(EVP_PKEY *a, EVP_PKEY *b) tEVP_PKEY_cmp_parameters;
typedef int function(X509 *a, X509 *b) tX509_cmp;
typedef void function() tOPENSSL_add_all_algorithms_noconf;
typedef ASN1_GENERALIZEDTIME *function(ASN1_TIME *t, ASN1_GENERALIZEDTIME **outTime) tASN1_TIME_to_generalizedtime;
typedef void function(ASN1_STRING *a) tASN1_STRING_free;
typedef int function() tRAND_poll;
typedef int function(RSA *rsa) tRSA_size;
typedef int function(int flen, ubyte *from, ubyte *to, RSA *rsa, int padding) tRSA_public_encrypt;
typedef int function(int flen, ubyte *from, ubyte *to, RSA *rsa, int padding) tRSA_private_decrypt;
typedef int function(int flen, ubyte *from, ubyte *to, RSA *rsa, int padding) tRSA_private_encrypt;
typedef int function(int flen, ubyte *from, ubyte *to, RSA *rsa, int padding) tRSA_public_decrypt;
typedef int function(int type, ubyte *m, uint m_length, ubyte *sigret, uint *siglen, RSA *rsa) tRSA_sign;
typedef int function(int type, ubyte *m, uint m_length, ubyte *sigbuf, uint siglen, RSA *rsa) tRSA_verify;
typedef void function(MD5_CTX *c) tMD5_Init;
typedef void function(MD5_CTX *c, void *data, size_t len) tMD5_Update;
typedef void function(ubyte *md, MD5_CTX *c) tMD5_Final;
typedef int function(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, void *impl, ubyte *key, ubyte *iv) tEVP_EncryptInit_ex;
typedef int function(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, void *impl, ubyte *key, ubyte*iv) tEVP_DecryptInit_ex;
typedef int function(EVP_CIPHER_CTX *ctx, ubyte *outv, int *outl, ubyte *inv, int inl) tEVP_EncryptUpdate;
typedef int function(EVP_CIPHER_CTX *ctx, ubyte *outv, int *outl, ubyte *inv, int inl) tEVP_DecryptUpdate;
typedef int function(EVP_CIPHER_CTX *ctx, ubyte *outv, int *outl) tEVP_EncryptFinal_ex;
typedef int function(EVP_CIPHER_CTX *ctx, ubyte *outv, int *outl) tEVP_DecryptFinal_ex;
typedef int function(EVP_CIPHER_CTX *ctx) tEVP_CIPHER_CTX_block_size;
typedef EVP_CIPHER *function() tEVP_aes_128_cbc;
typedef int function(EVP_CIPHER_CTX *ctx) tEVP_CIPHER_CTX_cleanup;
struct CRYPTO_dynlock_value
{
ReadWriteMutex lock;
CRYPTO_dynlock_value *next;
CRYPTO_dynlock_value *prev;
}
uint sslThreadId()
{
return cast(uint)cast(void*)Thread.getThis;
}
void sslStaticLock(int mode, int index, char *sourceFile, int lineNo)
{
if (_locks)
{
if (mode & CRYPTO_LOCK)
{
if (mode & CRYPTO_READ)
_locks[index].reader.lock();
else
_locks[index].writer.lock();
}
else
{
if (mode & CRYPTO_READ)
_locks[index].reader.unlock();
else
_locks[index].writer.unlock();
}
}
}
uint ablah = 0;
CRYPTO_dynlock_value *sslDynamicLockCreate(char *sourceFile, int lineNo)
{
auto rtn = new CRYPTO_dynlock_value;
rtn.lock = new ReadWriteMutex;
synchronized
{
if (last is null)
last = rtn;
else
{
rtn.prev = last;
last.next = rtn;
last = rtn;
}
}
return rtn;
}
void sslDynamicLockLock(int mode, CRYPTO_dynlock_value *lock, char *sourceFile, int lineNo)
{
if (lock && lock.lock)
{
if (mode & CRYPTO_LOCK)
{
if (mode & CRYPTO_READ)
lock.lock.reader.lock();
else
lock.lock.writer.lock();
}
else
{
if (mode & CRYPTO_READ)
lock.lock.reader.unlock();
else
lock.lock.writer.unlock();
}
}
}
void sslDynamicLockDestroy(CRYPTO_dynlock_value *lock, char *sourceFile, int lineNo)
{
synchronized
{
if (lock.prev)
lock.prev.next = lock.next;
if (lock.next)
lock.next.prev = lock.prev;
if (lock is last)
last = lock.prev;
lock = lock.next = lock.prev = null;
}
}
}
private bool _bioTestFlags = true;
tBIO_test_flags BIO_test_flags;
tBIO_new_socket BIO_new_socket;
tBIO_new_ssl BIO_new_ssl;
tBIO_free_all BIO_free_all;
tBIO_push BIO_push;
tBIO_read BIO_read;
tBIO_write BIO_write;
tSSL_CTX_new SSL_CTX_new;
tSSLv23_method SSLv23_method;
td2i_PrivateKey d2i_PrivateKey;
tSSL_CTX_use_PrivateKey SSL_CTX_use_PrivateKey;
tSSL_CTX_set_verify SSL_CTX_set_verify;
tEVP_PKEY_free EVP_PKEY_free;
tSSL_CTX_ctrl SSL_CTX_ctrl;
tSSL_CTX_set_cipher_list SSL_CTX_set_cipher_list;
tSSL_CTX_free SSL_CTX_free;
tSSL_load_error_strings SSL_load_error_strings;
tSSL_library_init SSL_library_init;
tRAND_load_file RAND_load_file;
tCRYPTO_num_locks CRYPTO_num_locks;
tCRYPTO_set_id_callback CRYPTO_set_id_callback;
tCRYPTO_set_locking_callback CRYPTO_set_locking_callback;
tCRYPTO_set_dynlock_create_callback CRYPTO_set_dynlock_create_callback;
tCRYPTO_set_dynlock_lock_callback CRYPTO_set_dynlock_lock_callback;
tCRYPTO_set_dynlock_destroy_callback CRYPTO_set_dynlock_destroy_callback;
tERR_get_error_line_data ERR_get_error_line_data;
tERR_remove_state ERR_remove_state;
tRAND_cleanup RAND_cleanup;
tERR_free_strings ERR_free_strings;
tEVP_cleanup EVP_cleanup;
tOBJ_cleanup OBJ_cleanup;
tX509V3_EXT_cleanup X509V3_EXT_cleanup;
tCRYPTO_cleanup_all_ex_data CRYPTO_cleanup_all_ex_data;
tSSL_CTX_check_private_key SSL_CTX_check_private_key;
tPEM_read_bio_PrivateKey PEM_read_bio_PrivateKey;
tBIO_new_file BIO_new_file;
tERR_peek_error ERR_peek_error;
tBIO_ctrl BIO_ctrl;
tSSL_get_shutdown SSL_get_shutdown;
tSSL_set_shutdown SSL_set_shutdown;
tSSL_CTX_use_certificate SSL_CTX_use_certificate;
tSSL_CTX_set_cert_store SSL_CTX_set_cert_store;
tSSL_CTX_load_verify_locations SSL_CTX_load_verify_locations;
tX509_STORE_CTX_get_current_cert X509_STORE_CTX_get_current_cert;
tX509_STORE_CTX_get_error_depth X509_STORE_CTX_get_error_depth;
tX509_STORE_CTX_get_error X509_STORE_CTX_get_error;
tX509_STORE_new X509_STORE_new;
tX509_STORE_free X509_STORE_free;
tX509_STORE_add_cert X509_STORE_add_cert;
//tX509_STORE_set_depth X509_STORE_set_depth;
tBIO_new_mem_buf BIO_new_mem_buf;
tRSA_generate_key RSA_generate_key;
tEVP_PKEY_new EVP_PKEY_new;
tEVP_PKEY_assign EVP_PKEY_assign;
tRSA_free RSA_free;
tBIO_new BIO_new;
tBIO_s_mem BIO_s_mem;
tPEM_write_bio_PKCS8PrivateKey PEM_write_bio_PKCS8PrivateKey;
tEVP_aes_256_cbc EVP_aes_256_cbc;
tPEM_ASN1_read_bio PEM_ASN1_read_bio;
d2i_of_void d2i_X509;
d2i_of_void d2i_RSAPublicKey;
tX509_new X509_new;
tX509_free X509_free;
tX509_set_version X509_set_version;
tASN1_INTEGER_set ASN1_INTEGER_set;
tX509_get_serialNumber X509_get_serialNumber;
tASN1_INTEGER_get ASN1_INTEGER_get;
tX509_gmtime_adj X509_gmtime_adj;
tX509_set_pubkey X509_set_pubkey;
tX509_get_subject_name X509_get_subject_name;
tX509_NAME_print_ex X509_NAME_print_ex;
tX509_set_issuer_name X509_set_issuer_name;
tX509_sign X509_sign;
tEVP_sha1 EVP_sha1;
tX509_STORE_CTX_new X509_STORE_CTX_new;
tX509_STORE_CTX_init X509_STORE_CTX_init;
tX509_verify_cert X509_verify_cert;
tX509_STORE_CTX_free X509_STORE_CTX_free;
tPEM_ASN1_write_bio PEM_ASN1_write_bio;
i2d_of_void i2d_X509;
i2d_of_void i2d_RSAPublicKey;
tX509_NAME_add_entry_by_txt X509_NAME_add_entry_by_txt;
tSSL_CTX_set_session_id_context SSL_CTX_set_session_id_context;
tEVP_PKEY_cmp_parameters EVP_PKEY_cmp_parameters;
tX509_cmp X509_cmp;
tOPENSSL_add_all_algorithms_noconf OPENSSL_add_all_algorithms_noconf;
tASN1_TIME_to_generalizedtime ASN1_TIME_to_generalizedtime;
tASN1_STRING_free ASN1_STRING_free;
tRAND_poll RAND_poll;
tRSA_size RSA_size;
tRSA_public_encrypt RSA_public_encrypt;
tRSA_private_decrypt RSA_private_decrypt;
tRSA_private_encrypt RSA_private_encrypt;
tRSA_public_decrypt RSA_public_decrypt;
tRSA_sign RSA_sign;
tRSA_verify RSA_verify;
tMD5_Init MD5_Init;
tMD5_Update MD5_Update;
tMD5_Final MD5_Final;
tEVP_EncryptInit_ex EVP_EncryptInit_ex;
tEVP_DecryptInit_ex EVP_DecryptInit_ex;
tEVP_EncryptUpdate EVP_EncryptUpdate;
tEVP_DecryptUpdate EVP_DecryptUpdate;
tEVP_EncryptFinal_ex EVP_EncryptFinal_ex;
tEVP_DecryptFinal_ex EVP_DecryptFinal_ex;
tEVP_aes_128_cbc EVP_aes_128_cbc;
tEVP_CIPHER_CTX_block_size EVP_CIPHER_CTX_block_size;
tEVP_CIPHER_CTX_cleanup EVP_CIPHER_CTX_cleanup;
int PEM_write_bio_RSAPublicKey(BIO *bp, RSA *x)
{
return PEM_ASN1_write_bio(i2d_RSAPublicKey, PEM_STRING_RSA_PUBLIC, bp, cast(char*)x, null, null, 0, null, null);
}
RSA *PEM_read_bio_RSAPublicKey(BIO *bp, RSA **x, pem_password_cb cb, void *u)
{
return cast(RSA *)PEM_ASN1_read_bio(d2i_RSAPublicKey, PEM_STRING_RSA_PUBLIC, bp, cast(void **)x, cb, u);
}
int PEM_write_bio_X509(BIO *b, X509 *x)
{
return PEM_ASN1_write_bio(i2d_X509, PEM_STRING_X509, b,cast(char *)x, null, null, 0, null, null);
}
ASN1_TIME *X509_get_notBefore(X509 *x)
{
return x.cert_info.validity.notBefore;
}
ASN1_TIME *X509_get_notAfter(X509 *x)
{
return x.cert_info.validity.notAfter;
}
int EVP_PKEY_assign_RSA(EVP_PKEY *key, RSA *rsa)
{
return EVP_PKEY_assign(key, EVP_PKEY_RSA, cast(char*)rsa);
}
int BIO_get_mem_data(BIO *b, char **data)
{
return BIO_ctrl(b, BIO_CTRL_INFO, 0, data);
}
void BIO_get_ssl(BIO *b, SSL **obj)
{
BIO_ctrl(b, BIO_C_GET_SSL, 0, obj);
}
int SSL_CTX_set_options(SSL_CTX *ctx, int larg)
{
return SSL_CTX_ctrl(ctx, SSL_CTRL_OPTIONS, larg, null);
}
int SSL_CTX_set_session_cache_mode(SSL_CTX *ctx, int mode)
{
return SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SESS_CACHE_MODE, mode, null);
}
int BIO_reset(BIO *b)
{
return BIO_ctrl(b, BIO_CTRL_RESET, 0, null);
}
bool BIO_should_retry(BIO *b)
{
if (_bioTestFlags)
return cast(bool)BIO_test_flags(b, BIO_FLAGS_SHOULD_RETRY);
return cast(bool)(b.flags & BIO_FLAGS_SHOULD_RETRY);
}
bool BIO_should_io_special(BIO *b)
{
if (_bioTestFlags)
return cast(bool)BIO_test_flags(b, BIO_FLAGS_IO_SPECIAL);
return cast(bool)(b.flags & BIO_FLAGS_IO_SPECIAL);
}
bool BIO_should_read(BIO *b)
{
if (_bioTestFlags)
return cast(bool)BIO_test_flags(b, BIO_FLAGS_READ);
return cast(bool)(b.flags & BIO_FLAGS_READ);
}
bool BIO_should_write(BIO *b)
{
if (_bioTestFlags)
return cast(bool)BIO_test_flags(b, BIO_FLAGS_WRITE);
return cast(bool)(b.flags & BIO_FLAGS_WRITE);
}
X509* PEM_read_bio_X509(BIO *b, X509 **x, pem_password_cb cb, void *u)
{
return cast(X509 *)PEM_ASN1_read_bio(d2i_X509, PEM_STRING_X509, b, cast(void**)x, cb, u);
}
private void bindFunc(T)(ref T func, char[] funcName, SharedLib lib)
in
{
assert(funcName);
assert(lib);
}
body
{
void *funcPtr = lib.getSymbol(toStringz(funcName));
if (funcPtr)
{
void **point = cast(void **)&func;
*point = funcPtr;
}
else
throw new Exception("Could not load symbol: " ~ funcName);
}
static SharedLib ssllib = null;
version(Win32)
{
static SharedLib eaylib = null;
}
version(darwin){
static SharedLib cryptolib = null;
}
static ReadWriteMutex[] _locks = null;
void throwOpenSSLError()
{
if (ERR_peek_error())
{
char[] exceptionString;
int flags, line;
char *data;
char *file;
uint code;
code = ERR_get_error_line_data(&file, &line, &data, &flags);
while (code != 0)
{
if (data && (flags & ERR_TXT_STRING))
exceptionString ~= Format.convert("ssl error code: {} {}:{} - {}\r\n", code, fromStringz(file), line, fromStringz(data));
else
exceptionString ~= Format.convert("ssl error code: {} {}:{}\r\n", code, fromStringz(file), line);
code = ERR_get_error_line_data(&file, &line, &data, &flags);
}
throw new Exception(exceptionString);
}
else
throw new Exception("Unknown OpenSSL error.");
}
void _initOpenSSL()
{
SSL_load_error_strings();
SSL_library_init();
OPENSSL_add_all_algorithms_noconf();
version(Posix)
RAND_load_file("/dev/urandom", BYTES_ENTROPY);
version(Win32)
{
RAND_poll();
}
uint numLocks = CRYPTO_num_locks();
if ((_locks = new ReadWriteMutex[numLocks]) !is null)
{
uint i = 0;
for (; i < numLocks; i++)
{
if((_locks[i] = new ReadWriteMutex()) is null)
break;
}
if (i == numLocks)
{
CRYPTO_set_id_callback(&sslThreadId);
CRYPTO_set_locking_callback(&sslStaticLock);
CRYPTO_set_dynlock_create_callback(&sslDynamicLockCreate);
CRYPTO_set_dynlock_lock_callback(&sslDynamicLockLock);
CRYPTO_set_dynlock_destroy_callback(&sslDynamicLockDestroy);
}
}
}
static this()
{
version(Win32)
loadEAY32();
loadOpenSSL();
}
// Though it would be nice to do this, it can't be closed until all the sockets and etc have been collected.. not sure how to do that.
/*static ~this()
{
closeOpenSSL();
}*/
SharedLib loadLib(char[][] loadPath)
{
SharedLib rtn;
foreach(path; loadPath)
{
try
rtn = SharedLib.load(path);
catch (SharedLibException ex)
{
scope fp = new FilePath(path);
try
rtn = SharedLib.load(fp.absolute(Environment.cwd()).toString);
catch (SharedLibException ex)
{}
}
}
return rtn;
}
version (Win32)
{
void loadEAY32()
{
char[][] loadPath = [ "libeay32.dll" ];
if ((eaylib = loadLib(loadPath)) !is null)
{
bindCrypto(eaylib);
}
}
}
void bindCrypto(SharedLib ssllib)
{
if (ssllib)
{
bindFunc(X509_cmp, "X509_cmp", ssllib);
bindFunc(OPENSSL_add_all_algorithms_noconf, "OPENSSL_add_all_algorithms_noconf", ssllib);
bindFunc(ASN1_TIME_to_generalizedtime, "ASN1_TIME_to_generalizedtime", ssllib);
bindFunc(ASN1_STRING_free, "ASN1_STRING_free", ssllib);
bindFunc(EVP_PKEY_cmp_parameters, "EVP_PKEY_cmp_parameters", ssllib);
bindFunc(X509_STORE_CTX_get_current_cert, "X509_STORE_CTX_get_current_cert", ssllib);
bindFunc(X509_STORE_CTX_get_error_depth, "X509_STORE_CTX_get_error_depth", ssllib);
bindFunc(X509_STORE_CTX_get_error, "X509_STORE_CTX_get_error", ssllib);
bindFunc(X509_STORE_new, "X509_STORE_new", ssllib);
bindFunc(X509_STORE_free, "X509_STORE_free", ssllib);
bindFunc(X509_STORE_add_cert, "X509_STORE_add_cert", ssllib);
// bindFunc(X509_STORE_set_depth, "X509_STORE_set_depth", ssllib);
bindFunc(BIO_new_mem_buf, "BIO_new_mem_buf", ssllib);
bindFunc(RSA_generate_key, "RSA_generate_key", ssllib);
bindFunc(EVP_PKEY_new, "EVP_PKEY_new", ssllib);
bindFunc(EVP_PKEY_assign, "EVP_PKEY_assign", ssllib);
bindFunc(RSA_free, "RSA_free", ssllib);
bindFunc(BIO_new, "BIO_new", ssllib);
bindFunc(BIO_s_mem, "BIO_s_mem", ssllib);
bindFunc(PEM_write_bio_PKCS8PrivateKey, "PEM_write_bio_PKCS8PrivateKey", ssllib);
bindFunc(EVP_aes_256_cbc, "EVP_aes_256_cbc", ssllib);
bindFunc(PEM_ASN1_read_bio, "PEM_ASN1_read_bio", ssllib);
bindFunc(d2i_X509, "d2i_X509", ssllib);
bindFunc(d2i_RSAPublicKey, "d2i_RSAPublicKey", ssllib);
bindFunc(X509_new, "X509_new", ssllib);
bindFunc(X509_free, "X509_free", ssllib);
bindFunc(X509_set_version, "X509_set_version", ssllib);
bindFunc(ASN1_INTEGER_set, "ASN1_INTEGER_set", ssllib);
bindFunc(X509_get_serialNumber, "X509_get_serialNumber", ssllib);
bindFunc(ASN1_INTEGER_get, "ASN1_INTEGER_get", ssllib);
bindFunc(X509_gmtime_adj, "X509_gmtime_adj", ssllib);
bindFunc(X509_set_pubkey, "X509_set_pubkey", ssllib);
bindFunc(X509_get_subject_name, "X509_get_subject_name", ssllib);
bindFunc(X509_NAME_print_ex, "X509_NAME_print_ex", ssllib);
bindFunc(X509_set_issuer_name, "X509_set_issuer_name", ssllib);
bindFunc(X509_sign, "X509_sign", ssllib);
bindFunc(EVP_sha1, "EVP_sha1", ssllib);
bindFunc(X509_STORE_CTX_new, "X509_STORE_CTX_new", ssllib);
bindFunc(X509_STORE_CTX_init, "X509_STORE_CTX_init", ssllib);
bindFunc(X509_verify_cert, "X509_verify_cert", ssllib);
bindFunc(X509_STORE_CTX_free, "X509_STORE_CTX_free", ssllib);
bindFunc(PEM_ASN1_write_bio, "PEM_ASN1_write_bio", ssllib);
bindFunc(i2d_X509, "i2d_X509", ssllib);
bindFunc(i2d_RSAPublicKey, "i2d_RSAPublicKey", ssllib);
bindFunc(X509_NAME_add_entry_by_txt, "X509_NAME_add_entry_by_txt", ssllib);
bindFunc(PEM_read_bio_PrivateKey, "PEM_read_bio_PrivateKey", ssllib);
bindFunc(BIO_new_file, "BIO_new_file", ssllib);
bindFunc(ERR_peek_error, "ERR_peek_error", ssllib);
try
bindFunc(BIO_test_flags, "BIO_test_flags", ssllib); // 0.9.7 doesn't have this function, it access the struct directly
catch (Exception ex)
_bioTestFlags = false;
bindFunc(BIO_ctrl, "BIO_ctrl", ssllib);
bindFunc(RAND_load_file, "RAND_load_file", ssllib);
bindFunc(CRYPTO_num_locks, "CRYPTO_num_locks", ssllib);
bindFunc(CRYPTO_set_id_callback, "CRYPTO_set_id_callback", ssllib);
bindFunc(CRYPTO_set_locking_callback, "CRYPTO_set_locking_callback", ssllib);
bindFunc(CRYPTO_set_dynlock_create_callback, "CRYPTO_set_dynlock_create_callback", ssllib);
bindFunc(CRYPTO_set_dynlock_lock_callback, "CRYPTO_set_dynlock_lock_callback", ssllib);
bindFunc(CRYPTO_set_dynlock_lock_callback, "CRYPTO_set_dynlock_lock_callback", ssllib);
bindFunc(CRYPTO_set_dynlock_destroy_callback, "CRYPTO_set_dynlock_destroy_callback", ssllib);
bindFunc(ERR_get_error_line_data, "ERR_get_error_line_data", ssllib);
bindFunc(ERR_remove_state, "ERR_remove_state", ssllib);
bindFunc(RAND_cleanup, "RAND_cleanup", ssllib);
bindFunc(ERR_free_strings, "ERR_free_strings", ssllib);
bindFunc(EVP_cleanup, "EVP_cleanup", ssllib);
bindFunc(OBJ_cleanup, "OBJ_cleanup", ssllib);
bindFunc(X509V3_EXT_cleanup, "X509V3_EXT_cleanup", ssllib);
bindFunc(CRYPTO_cleanup_all_ex_data, "CRYPTO_cleanup_all_ex_data", ssllib);
bindFunc(BIO_read, "BIO_read", ssllib);
bindFunc(BIO_write, "BIO_write", ssllib);
bindFunc(EVP_PKEY_free, "EVP_PKEY_free", ssllib);
bindFunc(d2i_PrivateKey, "d2i_PrivateKey", ssllib);
bindFunc(BIO_free_all, "BIO_free_all", ssllib);
bindFunc(BIO_push, "BIO_push", ssllib);
bindFunc(BIO_new_socket, "BIO_new_socket", ssllib);
bindFunc(RAND_poll, "RAND_poll", ssllib);
bindFunc(RSA_size, "RSA_size", ssllib);
bindFunc(RSA_public_encrypt, "RSA_public_encrypt", ssllib);
bindFunc(RSA_private_decrypt, "RSA_private_decrypt", ssllib);
bindFunc(RSA_private_encrypt, "RSA_private_encrypt", ssllib);
bindFunc(RSA_public_decrypt, "RSA_public_decrypt", ssllib);
bindFunc(RSA_sign, "RSA_sign", ssllib);
bindFunc(RSA_verify, "RSA_verify", ssllib);
bindFunc(MD5_Init, "MD5_Init", ssllib);
bindFunc(MD5_Update, "MD5_Update", ssllib);
bindFunc(MD5_Final, "MD5_Final", ssllib);
bindFunc(EVP_EncryptInit_ex, "EVP_EncryptInit_ex", ssllib);
bindFunc(EVP_DecryptInit_ex, "EVP_DecryptInit_ex", ssllib);
bindFunc(EVP_EncryptUpdate, "EVP_EncryptUpdate", ssllib);
bindFunc(EVP_DecryptUpdate, "EVP_DecryptUpdate", ssllib);
bindFunc(EVP_EncryptFinal_ex, "EVP_EncryptFinal_ex", ssllib);
bindFunc(EVP_DecryptFinal_ex, "EVP_DecryptFinal_ex", ssllib);
bindFunc(EVP_aes_128_cbc, "EVP_aes_128_cbc", ssllib);
try {
bindFunc(EVP_CIPHER_CTX_block_size, "EVP_CIPHER_CTX_block_size", ssllib);
} catch (Exception e){
// openSSL 0.9.7l defines only macros, not the function
EVP_CIPHER_CTX_block_size=&EVP_CIPHER_CTX_block_size_097l;
}
bindFunc(EVP_CIPHER_CTX_cleanup, "EVP_CIPHER_CTX_cleanup", ssllib);
}
}
void loadOpenSSL()
{
version (linux)
{
char[][] loadPath = [ "libssl.so.0.9.8", "libssl.so" ];
}
version (Win32)
{
char[][] loadPath = [ "libssl32.dll" ];
}
version (darwin)
{
char[][] loadPath = [ "/usr/lib/libssl.dylib", "libssl.dylib" ];
}
version (freebsd)
{
char[][] loadPath = [ "libssl.so.5", "libssl.so" ];
}
version (solaris)
{
char[][] loadPath = [ "libssl.so.0.9.8", "libssl.so" ];
}
if ((ssllib = loadLib(loadPath)) !is null)
{
bindFunc(BIO_new_ssl, "BIO_new_ssl", ssllib);
bindFunc(SSL_CTX_free, "SSL_CTX_free", ssllib);
bindFunc(SSL_CTX_new, "SSL_CTX_new", ssllib);
bindFunc(SSLv23_method, "SSLv23_method", ssllib);
bindFunc(SSL_CTX_use_PrivateKey, "SSL_CTX_use_PrivateKey", ssllib);
bindFunc(SSL_CTX_set_verify, "SSL_CTX_set_verify", ssllib);
bindFunc(SSL_CTX_ctrl, "SSL_CTX_ctrl", ssllib);
bindFunc(SSL_CTX_set_cipher_list, "SSL_CTX_set_cipher_list", ssllib);
bindFunc(SSL_load_error_strings, "SSL_load_error_strings", ssllib);
bindFunc(SSL_library_init, "SSL_library_init", ssllib);
bindFunc(SSL_CTX_check_private_key, "SSL_CTX_check_private_key", ssllib);
bindFunc(SSL_get_shutdown, "SSL_get_shutdown", ssllib);
bindFunc(SSL_set_shutdown, "SSL_set_shutdown", ssllib);
bindFunc(SSL_CTX_use_certificate, "SSL_CTX_use_certificate", ssllib);
bindFunc(SSL_CTX_set_cert_store, "SSL_CTX_set_cert_store", ssllib);
bindFunc(SSL_CTX_load_verify_locations, "SSL_CTX_load_verify_locations", ssllib);
bindFunc(SSL_CTX_set_session_id_context, "SSL_CTX_set_session_id_context", ssllib);
version(Posix)
{
version(darwin){
char[][] loadPathCrypto = [ "/usr/lib/libcrypto.dylib", "libcrypto.dylib" ];
cryptolib = loadLib(loadPathCrypto);
if (cryptolib !is null) bindCrypto(cryptolib);
} else {
bindCrypto(ssllib);
}
}
_initOpenSSL();
}
else
throw new Exception("Could not load OpenSSL library.");
}
void closeOpenSSL()
{
CRYPTO_set_id_callback(null);
CRYPTO_set_locking_callback(null);
CRYPTO_set_dynlock_create_callback(null);
CRYPTO_set_dynlock_lock_callback(null);
CRYPTO_set_dynlock_destroy_callback(null);
ERR_remove_state(0);
RAND_cleanup();
ERR_free_strings();
EVP_cleanup();
OBJ_cleanup();
X509V3_EXT_cleanup();
CRYPTO_cleanup_all_ex_data();
if (ssllib)
ssllib.unload();
version(darwin){
if (cryptolib)
cryptolib.unload();
}
version(Win32)
{
if (eaylib)
eaylib.unload();
}
}
|
D
|
/Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Crypto.build/RSA/RSAPadding.swift.o : /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/RSA/RSA.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/MAC/HMAC.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Utilities/Deprecated.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/RSA/RSAPadding.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Cipher/CipherAlgorithm.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Digest/DigestAlgorithm.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Random/CryptoRandom.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Cipher/Cipher.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Utilities/CryptoError.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Utilities/Exports.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Digest/Digest.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/BCrypt/BCryptDigest.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/RSA/RSAKey.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIOOpenSSL.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIOTLS.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/COperatingSystem.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Random.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIOFoundationCompat.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /usr/local/Cellar/libressl/2.7.4/include/openssl/asn1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/tls1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/dtls1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pkcs12.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl2.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pem2.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl23.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl3.h /usr/local/Cellar/libressl/2.7.4/include/openssl/x509v3.h /usr/local/Cellar/libressl/2.7.4/include/openssl/md5.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pkcs7.h /usr/local/Cellar/libressl/2.7.4/include/openssl/x509.h /usr/local/Cellar/libressl/2.7.4/include/openssl/sha.h /usr/local/Cellar/libressl/2.7.4/include/openssl/dsa.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ecdsa.h /usr/local/Cellar/libressl/2.7.4/include/openssl/rsa.h /usr/local/Cellar/libressl/2.7.4/include/openssl/obj_mac.h /usr/local/Cellar/libressl/2.7.4/include/openssl/hmac.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ec.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /usr/local/Cellar/libressl/2.7.4/include/openssl/rand.h /usr/local/Cellar/libressl/2.7.4/include/openssl/conf.h /usr/local/Cellar/libressl/2.7.4/include/openssl/opensslconf.h /usr/local/Cellar/libressl/2.7.4/include/openssl/dh.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ecdh.h /usr/local/Cellar/libressl/2.7.4/include/openssl/lhash.h /usr/local/Cellar/libressl/2.7.4/include/openssl/stack.h /usr/local/Cellar/libressl/2.7.4/include/openssl/safestack.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/CNIOOpenSSL/include/c_nio_openssl.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pem.h /usr/local/Cellar/libressl/2.7.4/include/openssl/bn.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /usr/local/Cellar/libressl/2.7.4/include/openssl/bio.h /usr/local/Cellar/libressl/2.7.4/include/openssl/crypto.h /usr/local/Cellar/libressl/2.7.4/include/openssl/srtp.h /usr/local/Cellar/libressl/2.7.4/include/openssl/evp.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/2.7.4/include/openssl/buffer.h /usr/local/Cellar/libressl/2.7.4/include/openssl/err.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /usr/local/Cellar/libressl/2.7.4/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/2.7.4/include/openssl/objects.h /usr/local/Cellar/libressl/2.7.4/include/openssl/opensslv.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /usr/local/Cellar/libressl/2.7.4/include/openssl/x509_vfy.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio-ssl-support.git--2359138821295600615/module.modulemap /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/libbcrypt/include/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
/Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Crypto.build/RSAPadding~partial.swiftmodule : /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/RSA/RSA.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/MAC/HMAC.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Utilities/Deprecated.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/RSA/RSAPadding.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Cipher/CipherAlgorithm.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Digest/DigestAlgorithm.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Random/CryptoRandom.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Cipher/Cipher.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Utilities/CryptoError.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Utilities/Exports.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Digest/Digest.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/BCrypt/BCryptDigest.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/RSA/RSAKey.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIOOpenSSL.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIOTLS.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/COperatingSystem.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Random.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIOFoundationCompat.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /usr/local/Cellar/libressl/2.7.4/include/openssl/asn1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/tls1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/dtls1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pkcs12.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl2.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pem2.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl23.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl3.h /usr/local/Cellar/libressl/2.7.4/include/openssl/x509v3.h /usr/local/Cellar/libressl/2.7.4/include/openssl/md5.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pkcs7.h /usr/local/Cellar/libressl/2.7.4/include/openssl/x509.h /usr/local/Cellar/libressl/2.7.4/include/openssl/sha.h /usr/local/Cellar/libressl/2.7.4/include/openssl/dsa.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ecdsa.h /usr/local/Cellar/libressl/2.7.4/include/openssl/rsa.h /usr/local/Cellar/libressl/2.7.4/include/openssl/obj_mac.h /usr/local/Cellar/libressl/2.7.4/include/openssl/hmac.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ec.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /usr/local/Cellar/libressl/2.7.4/include/openssl/rand.h /usr/local/Cellar/libressl/2.7.4/include/openssl/conf.h /usr/local/Cellar/libressl/2.7.4/include/openssl/opensslconf.h /usr/local/Cellar/libressl/2.7.4/include/openssl/dh.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ecdh.h /usr/local/Cellar/libressl/2.7.4/include/openssl/lhash.h /usr/local/Cellar/libressl/2.7.4/include/openssl/stack.h /usr/local/Cellar/libressl/2.7.4/include/openssl/safestack.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/CNIOOpenSSL/include/c_nio_openssl.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pem.h /usr/local/Cellar/libressl/2.7.4/include/openssl/bn.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /usr/local/Cellar/libressl/2.7.4/include/openssl/bio.h /usr/local/Cellar/libressl/2.7.4/include/openssl/crypto.h /usr/local/Cellar/libressl/2.7.4/include/openssl/srtp.h /usr/local/Cellar/libressl/2.7.4/include/openssl/evp.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/2.7.4/include/openssl/buffer.h /usr/local/Cellar/libressl/2.7.4/include/openssl/err.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /usr/local/Cellar/libressl/2.7.4/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/2.7.4/include/openssl/objects.h /usr/local/Cellar/libressl/2.7.4/include/openssl/opensslv.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /usr/local/Cellar/libressl/2.7.4/include/openssl/x509_vfy.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio-ssl-support.git--2359138821295600615/module.modulemap /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/libbcrypt/include/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
/Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Crypto.build/RSAPadding~partial.swiftdoc : /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/RSA/RSA.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/MAC/HMAC.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Utilities/Deprecated.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/RSA/RSAPadding.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Cipher/CipherAlgorithm.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Digest/DigestAlgorithm.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Random/CryptoRandom.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Cipher/Cipher.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Utilities/CryptoError.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Utilities/Exports.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Digest/Digest.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/BCrypt/BCryptDigest.swift /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/RSA/RSAKey.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIOOpenSSL.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIOTLS.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/COperatingSystem.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Random.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIOFoundationCompat.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /usr/local/Cellar/libressl/2.7.4/include/openssl/asn1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/tls1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/dtls1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pkcs12.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl2.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pem2.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl23.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl3.h /usr/local/Cellar/libressl/2.7.4/include/openssl/x509v3.h /usr/local/Cellar/libressl/2.7.4/include/openssl/md5.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pkcs7.h /usr/local/Cellar/libressl/2.7.4/include/openssl/x509.h /usr/local/Cellar/libressl/2.7.4/include/openssl/sha.h /usr/local/Cellar/libressl/2.7.4/include/openssl/dsa.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ecdsa.h /usr/local/Cellar/libressl/2.7.4/include/openssl/rsa.h /usr/local/Cellar/libressl/2.7.4/include/openssl/obj_mac.h /usr/local/Cellar/libressl/2.7.4/include/openssl/hmac.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ec.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /usr/local/Cellar/libressl/2.7.4/include/openssl/rand.h /usr/local/Cellar/libressl/2.7.4/include/openssl/conf.h /usr/local/Cellar/libressl/2.7.4/include/openssl/opensslconf.h /usr/local/Cellar/libressl/2.7.4/include/openssl/dh.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ecdh.h /usr/local/Cellar/libressl/2.7.4/include/openssl/lhash.h /usr/local/Cellar/libressl/2.7.4/include/openssl/stack.h /usr/local/Cellar/libressl/2.7.4/include/openssl/safestack.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/CNIOOpenSSL/include/c_nio_openssl.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pem.h /usr/local/Cellar/libressl/2.7.4/include/openssl/bn.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /usr/local/Cellar/libressl/2.7.4/include/openssl/bio.h /usr/local/Cellar/libressl/2.7.4/include/openssl/crypto.h /usr/local/Cellar/libressl/2.7.4/include/openssl/srtp.h /usr/local/Cellar/libressl/2.7.4/include/openssl/evp.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/2.7.4/include/openssl/buffer.h /usr/local/Cellar/libressl/2.7.4/include/openssl/err.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /usr/local/Cellar/libressl/2.7.4/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/2.7.4/include/openssl/objects.h /usr/local/Cellar/libressl/2.7.4/include/openssl/opensslv.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /usr/local/Cellar/libressl/2.7.4/include/openssl/x509_vfy.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio-ssl-support.git--2359138821295600615/module.modulemap /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/checkouts/crypto.git-7980259129511365902/Sources/libbcrypt/include/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
|
D
|
# FIXED
driverlib/usb.obj: C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/driverlib/usb.c
driverlib/usb.obj: C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.0.LTS/include/stdbool.h
driverlib/usb.obj: C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.0.LTS/include/stdint.h
driverlib/usb.obj: C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/inc/hw_ints.h
driverlib/usb.obj: C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/inc/hw_memmap.h
driverlib/usb.obj: C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/inc/hw_types.h
driverlib/usb.obj: C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/inc/hw_sysctl.h
driverlib/usb.obj: C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/inc/hw_usb.h
driverlib/usb.obj: C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/driverlib/debug.h
driverlib/usb.obj: C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/driverlib/interrupt.h
driverlib/usb.obj: C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/driverlib/sysctl.h
driverlib/usb.obj: C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/driverlib/udma.h
driverlib/usb.obj: C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/driverlib/usb.h
C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/driverlib/usb.c:
C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.0.LTS/include/stdbool.h:
C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.0.LTS/include/stdint.h:
C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/inc/hw_ints.h:
C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/inc/hw_memmap.h:
C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/inc/hw_types.h:
C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/inc/hw_sysctl.h:
C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/inc/hw_usb.h:
C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/driverlib/debug.h:
C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/driverlib/interrupt.h:
C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/driverlib/sysctl.h:
C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/driverlib/udma.h:
C:/Users/Max/Desktop/TivaWare_C_Series-2.1.3.156/driverlib/usb.h:
|
D
|
/home/f/Desktop/rust-projects/guessing_game/target/rls/debug/build/libc-3160b678f2fa33c1/build_script_build-3160b678f2fa33c1: /home/f/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.62/build.rs
/home/f/Desktop/rust-projects/guessing_game/target/rls/debug/build/libc-3160b678f2fa33c1/build_script_build-3160b678f2fa33c1.d: /home/f/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.62/build.rs
/home/f/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.62/build.rs:
|
D
|
/home/git/for_nep141/nep141transfer/contract/target/debug/build/libc-aa9cacf7625af113/build_script_build-aa9cacf7625af113: /root/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.73/build.rs
/home/git/for_nep141/nep141transfer/contract/target/debug/build/libc-aa9cacf7625af113/build_script_build-aa9cacf7625af113.d: /root/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.73/build.rs
/root/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.73/build.rs:
|
D
|
(art) the branch of philosophy dealing with beauty and taste (emphasizing the evaluative criteria that are applied to art
(philosophy) a philosophical theory as to what is beautiful
|
D
|
module senderoxc.data.object.HABTM;
|
D
|
/**
A HTTP 1.1/1.0 server implementation.
Copyright: © 2012-2013 RejectedSoftware e.K.
License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file.
Authors: Sönke Ludwig, Jan Krüger, Ilya Shipunov
*/
module vibe.http.server;
public import vibe.core.net;
public import vibe.http.common;
public import vibe.http.session;
import vibe.core.file;
import vibe.core.log;
import vibe.data.json;
import vibe.http.dist;
import vibe.http.log;
import vibe.inet.message;
import vibe.inet.url;
import vibe.inet.webform;
import vibe.stream.counting;
import vibe.stream.operations;
import vibe.stream.tls;
import vibe.stream.wrapper : ConnectionProxyStream;
import vibe.stream.zlib;
import vibe.textfilter.urlencode;
import vibe.utils.array;
import vibe.utils.memory;
import vibe.utils.string;
import core.atomic;
import core.vararg;
import std.array;
import std.conv;
import std.datetime;
import std.encoding : sanitize;
import std.exception;
import std.format;
import std.functional;
import std.string;
import std.typecons;
import std.uri;
/**************************************************************************************************/
/* Public functions */
/**************************************************************************************************/
/**
Starts a HTTP server listening on the specified port.
request_handler will be called for each HTTP request that is made. The
res parameter of the callback then has to be filled with the response
data.
request_handler can be either HTTPServerRequestDelegate/HTTPServerRequestFunction
or a class/struct with a member function 'handleRequest' that has the same
signature.
Note that if the application has been started with the --disthost command line
switch, listenHTTP() will automatically listen on the specified VibeDist host
instead of locally. This allows for a seamless switch from single-host to
multi-host scenarios without changing the code. If you need to listen locally,
use listenHTTPPlain() instead.
Params:
settings = Customizes the HTTP servers functionality.
request_handler = This callback is invoked for each incoming request and is responsible
for generating the response.
Returns:
A handle is returned that can be used to stop listening for further HTTP
requests with the supplied settings. Another call to `listenHTTP` can be
used afterwards to start listening again.
*/
HTTPListener listenHTTP(HTTPServerSettings settings, HTTPServerRequestDelegate request_handler)
{
enforce(settings.bindAddresses.length, "Must provide at least one bind address for a HTTP server.");
HTTPServerContext ctx;
ctx.id = atomicOp!"+="(g_contextIDCounter, 1);
ctx.settings = settings;
ctx.requestHandler = request_handler;
if (settings.accessLogToConsole)
ctx.loggers ~= new HTTPConsoleLogger(settings, settings.accessLogFormat);
if (settings.accessLogFile.length)
ctx.loggers ~= new HTTPFileLogger(settings, settings.accessLogFormat, settings.accessLogFile);
synchronized (g_listenersMutex)
addContext(ctx);
// if a VibeDist host was specified on the command line, register there instead of listening
// directly.
if (s_distHost.length && !settings.disableDistHost) {
listenHTTPDist(settings, request_handler, s_distHost, s_distPort);
} else {
listenHTTPPlain(settings);
}
return HTTPListener(ctx.id);
}
/// ditto
HTTPListener listenHTTP(HTTPServerSettings settings, HTTPServerRequestFunction request_handler)
{
return listenHTTP(settings, toDelegate(request_handler));
}
/// ditto
HTTPListener listenHTTP(HTTPServerSettings settings, HTTPServerRequestHandler request_handler)
{
return listenHTTP(settings, &request_handler.handleRequest);
}
/// ditto
HTTPListener listenHTTP(HTTPServerSettings settings, HTTPServerRequestDelegateS request_handler)
{
return listenHTTP(settings, cast(HTTPServerRequestDelegate)request_handler);
}
/// ditto
HTTPListener listenHTTP(HTTPServerSettings settings, HTTPServerRequestFunctionS request_handler)
{
return listenHTTP(settings, toDelegate(request_handler));
}
/// ditto
HTTPListener listenHTTP(HTTPServerSettings settings, HTTPServerRequestHandlerS request_handler)
{
return listenHTTP(settings, &request_handler.handleRequest);
}
/**
Provides a HTTP request handler that responds with a static Diet template.
*/
@property HTTPServerRequestDelegateS staticTemplate(string template_file)()
{
import vibe.templ.diet;
return (scope HTTPServerRequest req, scope HTTPServerResponse res){
res.render!(template_file, req);
};
}
/**
Provides a HTTP request handler that responds with a static redirection to the specified URL.
Params:
url = The URL to redirect to
status = Redirection status to use $(LPAREN)by default this is $(D HTTPStatus.found)$(RPAREN).
Returns:
Returns a $(D HTTPServerRequestDelegate) that performs the redirect
*/
HTTPServerRequestDelegate staticRedirect(string url, HTTPStatus status = HTTPStatus.found)
{
return (HTTPServerRequest req, HTTPServerResponse res){
res.redirect(url, status);
};
}
/// ditto
HTTPServerRequestDelegate staticRedirect(URL url, HTTPStatus status = HTTPStatus.found)
{
return (HTTPServerRequest req, HTTPServerResponse res){
res.redirect(url, status);
};
}
///
unittest {
import vibe.http.router;
void test()
{
auto router = new URLRouter;
router.get("/old_url", staticRedirect("http://example.org/new_url", HTTPStatus.movedPermanently));
listenHTTP(new HTTPServerSettings, router);
}
}
/**
Sets a VibeDist host to register with.
*/
void setVibeDistHost(string host, ushort port)
{
s_distHost = host;
s_distPort = port;
}
/**
Renders the given template and makes all ALIASES available to the template.
This currently suffers from multiple DMD bugs - use renderCompat() instead for the time being.
You can call this function as a member of HTTPServerResponse using D's uniform function
call syntax.
Examples:
---
string title = "Hello, World!";
int pageNumber = 1;
res.render!("mytemplate.jd", title, pageNumber);
---
*/
@property void render(string template_file, ALIASES...)(HTTPServerResponse res)
{
import vibe.templ.diet;
res.headers["Content-Type"] = "text/html; charset=UTF-8";
parseDietFile!(template_file, ALIASES)(res.bodyWriter);
}
/**
Creates a HTTPServerRequest suitable for writing unit tests.
*/
HTTPServerRequest createTestHTTPServerRequest(URL url, HTTPMethod method = HTTPMethod.GET, InputStream data = null)
{
InetHeaderMap headers;
return createTestHTTPServerRequest(url, method, headers, data);
}
/// ditto
HTTPServerRequest createTestHTTPServerRequest(URL url, HTTPMethod method, InetHeaderMap headers, InputStream data = null)
{
auto tls = url.schema == "https";
auto ret = new HTTPServerRequest(Clock.currTime(UTC()), url.port ? url.port : tls ? 443 : 80);
ret.path = url.pathString;
ret.queryString = url.queryString;
ret.username = url.username;
ret.password = url.password;
ret.requestURL = url.localURI;
ret.method = method;
ret.tls = tls;
ret.headers = headers;
ret.bodyReader = data;
return ret;
}
/**
Creates a HTTPServerResponse suitable for writing unit tests.
*/
HTTPServerResponse createTestHTTPServerResponse(OutputStream data_sink = null, SessionStore session_store = null)
{
import vibe.stream.wrapper;
HTTPServerSettings settings;
if (session_store) {
settings = new HTTPServerSettings;
settings.sessionStore = session_store;
}
if (!data_sink) data_sink = new NullOutputStream;
auto stream = new ProxyStream(null, data_sink);
auto ret = new HTTPServerResponse(stream, null, settings, defaultAllocator());
return ret;
}
/**************************************************************************************************/
/* Public types */
/**************************************************************************************************/
/// Delegate based request handler
alias HTTPServerRequestDelegate = void delegate(HTTPServerRequest req, HTTPServerResponse res);
/// Static function based request handler
alias HTTPServerRequestFunction = void function(HTTPServerRequest req, HTTPServerResponse res);
/// Interface for class based request handlers
interface HTTPServerRequestHandler {
/// Handles incoming HTTP requests
void handleRequest(HTTPServerRequest req, HTTPServerResponse res);
}
/// Delegate based request handler with scoped parameters
alias HTTPServerRequestDelegateS = void delegate(scope HTTPServerRequest req, scope HTTPServerResponse res);
/// Static function based request handler with scoped parameters
alias HTTPServerRequestFunctionS = void function(scope HTTPServerRequest req, scope HTTPServerResponse res);
/// Interface for class based request handlers with scoped parameters
interface HTTPServerRequestHandlerS {
/// Handles incoming HTTP requests
void handleRequest(scope HTTPServerRequest req, scope HTTPServerResponse res);
}
unittest {
static assert(is(HTTPServerRequestDelegateS : HTTPServerRequestDelegate));
static assert(is(HTTPServerRequestFunctionS : HTTPServerRequestFunction));
}
/// Aggregates all information about an HTTP error status.
final class HTTPServerErrorInfo {
/// The HTTP status code
int code;
/// The error message
string message;
/// Extended error message with debug information such as a stack trace
string debugMessage;
/// The error exception, if any
Throwable exception;
}
/// Delegate type used for user defined error page generator callbacks.
alias HTTPServerErrorPageHandler = void delegate(HTTPServerRequest req, HTTPServerResponse res, HTTPServerErrorInfo error);
/**
Specifies optional features of the HTTP server.
Disabling unneeded features can speed up the server or reduce its memory usage.
Note that the options parseFormBody, parseJsonBody and parseMultiPartBody
will also drain the HTTPServerRequest.bodyReader stream whenever a request
body with form or JSON data is encountered.
*/
enum HTTPServerOption {
none = 0,
/// Fills the .path, .queryString fields in the request
parseURL = 1<<0,
/// Fills the .query field in the request
parseQueryString = 1<<1 | parseURL,
/// Fills the .form field in the request
parseFormBody = 1<<2,
/// Fills the .json field in the request
parseJsonBody = 1<<3,
/// Enables use of the .nextPart() method in the request
parseMultiPartBody = 1<<4, // todo
/// Fills the .cookies field in the request
parseCookies = 1<<5,
/// Distributes request processing among worker threads
distribute = 1<<6,
/** Enables stack traces (HTTPServerErrorInfo.debugMessage).
Note that generating the stack traces are generally a costly
operation that should usually be avoided in production
environments. It can also reveal internal information about
the application, such as function addresses, which can
help an attacker to abuse possible security holes.
*/
errorStackTraces = 1<<7,
/** The default set of options.
Includes all options, except for distribute.
*/
defaults =
parseURL |
parseQueryString |
parseFormBody |
parseJsonBody |
parseMultiPartBody |
parseCookies |
errorStackTraces,
/// deprecated
None = none,
/// deprecated
ParseURL = parseURL,
/// deprecated
ParseQueryString = parseQueryString,
/// deprecated
ParseFormBody = parseFormBody,
/// deprecated
ParseJsonBody = parseJsonBody,
/// deprecated
ParseMultiPartBody = parseMultiPartBody,
/// deprecated
ParseCookies = parseCookies
}
/**
Contains all settings for configuring a basic HTTP server.
The defaults are sufficient for most normal uses.
*/
final class HTTPServerSettings {
/** The port on which the HTTP server is listening.
The default value is 80. If you are running a TLS enabled server you may want to set this
to 443 instead.
*/
ushort port = 80;
/** The interfaces on which the HTTP server is listening.
By default, the server will listen on all IPv4 and IPv6 interfaces.
*/
string[] bindAddresses = ["::", "0.0.0.0"];
/** Determines the server host name.
If multiple servers are listening on the same port, the host name will determine which one
gets a request.
*/
string hostName;
/** Configures optional features of the HTTP server
Disabling unneeded features can improve performance or reduce the server
load in case of invalid or unwanted requests (DoS). By default,
HTTPServerOption.defaults is used.
*/
HTTPServerOption options = HTTPServerOption.defaults;
/** Time of a request after which the connection is closed with an error; not supported yet
The default limit of 0 means that the request time is not limited.
*/
Duration maxRequestTime;// = dur!"seconds"(0);
/** Maximum time between two request on a keep-alive connection
The default value is 10 seconds.
*/
Duration keepAliveTimeout;// = dur!"seconds"(10);
/// Maximum number of transferred bytes per request after which the connection is closed with
/// an error; not supported yet
ulong maxRequestSize = 2097152;
/// Maximum number of transferred bytes for the request header. This includes the request line
/// the url and all headers.
ulong maxRequestHeaderSize = 8192;
/// Sets a custom handler for displaying error pages for HTTP errors
HTTPServerErrorPageHandler errorPageHandler = null;
/// If set, a HTTPS server will be started instead of plain HTTP.
TLSContext tlsContext;
/// Compatibility alias - use `tlsContext` instead.
alias sslContext = tlsContext;
/// Session management is enabled if a session store instance is provided
SessionStore sessionStore;
string sessionIdCookie = "vibe.session_id";
///
import vibe.core.core : vibeVersionString;
string serverString = "vibe.d/" ~ vibeVersionString;
/** Specifies the format used for the access log.
The log format is given using the Apache server syntax. By default NCSA combined is used.
---
"%h - %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\""
---
*/
string accessLogFormat = "%h - %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\"";
/// Spefifies the name of a file to which access log messages are appended.
string accessLogFile = "";
/// If set, access log entries will be output to the console.
bool accessLogToConsole = false;
/// Returns a duplicate of the settings object.
@property HTTPServerSettings dup()
{
auto ret = new HTTPServerSettings;
foreach (mem; __traits(allMembers, HTTPServerSettings)) {
static if (mem == "bindAddresses") ret.bindAddresses = bindAddresses.dup;
else static if (__traits(compiles, __traits(getMember, ret, mem) = __traits(getMember, this, mem)))
__traits(getMember, ret, mem) = __traits(getMember, this, mem);
}
return ret;
}
/// Disable support for VibeDist and instead start listening immediately.
bool disableDistHost = false;
/** Responds to "Accept-Encoding" by using compression if possible.
Compression can also be manually enabled by setting the
"Content-Encoding" header of the HTTP response appropriately before
sending the response body.
This setting is disabled by default. Also note that there are still some
known issues with the GZIP compression code.
*/
bool useCompressionIfPossible = false;
/** Interval between WebSocket ping frames.
The default value is 60 seconds; set to Duration.zero to disable pings.
*/
Duration webSocketPingInterval;// = dur!"seconds"(60);
this()
{
// need to use the contructor because the Ubuntu 13.10 GDC cannot CTFE dur()
maxRequestTime = 0.seconds;
keepAliveTimeout = 10.seconds;
webSocketPingInterval = 60.seconds;
}
}
/**
Options altering how sessions are created.
Multiple values can be or'ed together.
See_Also: HTTPServerResponse.startSession
*/
enum SessionOption {
/// No options.
none = 0,
/** Instructs the browser to disallow accessing the session ID from JavaScript.
See_Also: Cookie.httpOnly
*/
httpOnly = 1<<0,
/** Instructs the browser to disallow sending the session ID over
unencrypted connections.
By default, the type of the connection on which the session is started
will be used to determine if secure or noSecure is used.
See_Also: noSecure, Cookie.secure
*/
secure = 1<<1,
/** Instructs the browser to allow sending the session ID over unencrypted
connections.
By default, the type of the connection on which the session is started
will be used to determine if secure or noSecure is used.
See_Also: secure, Cookie.secure
*/
noSecure = 1<<2
}
/**
Represents a HTTP request as received by the server side.
*/
final class HTTPServerRequest : HTTPRequest {
private {
SysTime m_timeCreated;
FixedAppender!(string, 31) m_dateAppender;
HTTPServerSettings m_settings;
ushort m_port;
}
public {
/// The IP address of the client
string peer;
/// ditto
NetworkAddress clientAddress;
/// Determines if the request was issued over an TLS encrypted channel.
bool tls;
/// Compatibility alias - use `tls` instead.
alias ssl = tls;
/** Information about the TLS certificate provided by the client.
Remarks: This field is only set if `tls` is true, and the peer
presented a client certificate.
*/
TLSCertificateInformation clientCertificate;
/** The _path part of the URL.
Remarks: This field is only set if HTTPServerOption.parseURL is set.
*/
string path;
/** The user name part of the URL, if present.
Remarks: This field is only set if HTTPServerOption.parseURL is set.
*/
string username;
/** The _password part of the URL, if present.
Remarks: This field is only set if HTTPServerOption.parseURL is set.
*/
string password;
/** The _query string part of the URL.
Remarks: This field is only set if HTTPServerOption.parseURL is set.
*/
string queryString;
/** Contains the list of _cookies that are stored on the client.
Note that the a single cookie name may occur multiple times if multiple
cookies have that name but different paths or domains that all match
the request URI. By default, the first cookie will be returned, which is
the or one of the cookies with the closest path match.
Remarks: This field is only set if HTTPServerOption.parseCookies is set.
*/
CookieValueMap cookies;
/** Contains all _form fields supplied using the _query string.
The fields are stored in the same order as they are received.
Remarks: This field is only set if HTTPServerOption.parseQueryString is set.
*/
FormFields query;
/** A map of general parameters for the request.
This map is supposed to be used by middleware functionality to store
information for later stages. For example vibe.http.router.URLRouter uses this map
to store the value of any named placeholders.
*/
string[string] params;
/** Supplies the request body as a stream.
Note that when certain server options are set (such as
HTTPServerOption.parseJsonBody) and a matching request was sent,
the returned stream will be empty. If needed, remove those
options and do your own processing of the body when launching
the server. HTTPServerOption has a list of all options that affect
the request body.
*/
InputStream bodyReader;
/** Contains the parsed Json for a JSON request.
Remarks:
This field is only set if HTTPServerOption.parseJsonBody is set.
A JSON request must have the Content-Type "application/json".
*/
Json json;
/** Contains the parsed parameters of a HTML POST _form request.
The fields are stored in the same order as they are received.
Remarks:
This field is only set if HTTPServerOption.parseFormBody is set.
A form request must either have the Content-Type
"application/x-www-form-urlencoded" or "multipart/form-data".
*/
FormFields form;
/** Contains information about any uploaded file for a HTML _form request.
Remarks:
This field is only set if HTTPServerOption.parseFormBody is set
and if the Content-Type is "multipart/form-data".
*/
FilePartFormFields files;
/** The current Session object.
This field is set if HTTPServerResponse.startSession() has been called
on a previous response and if the client has sent back the matching
cookie.
Remarks: Requires the HTTPServerOption.parseCookies option.
*/
Session session;
}
package {
/** The settings of the server serving this request.
*/
@property const(HTTPServerSettings) serverSettings() const
{
return m_settings;
}
}
this(SysTime time, ushort port)
{
m_timeCreated = time.toUTC();
m_port = port;
writeRFC822DateTimeString(m_dateAppender, time);
this.headers["Date"] = m_dateAppender.data();
}
/** Time when this request started processing.
*/
@property inout(SysTime) timeCreated() inout { return m_timeCreated; }
/** The full URL that corresponds to this request.
The host URL includes the protocol, host and optionally the user
and password that was used for this request. This field is useful to
construct self referencing URLs.
Note that the port is currently not set, so that this only works if
the standard port is used.
*/
@property URL fullURL()
const {
URL url;
auto fh = this.headers.get("X-Forwarded-Host", "");
if (!fh.empty) {
url.schema = this.headers.get("X-Forwarded-Proto", "http");
url.host = fh;
} else {
if (!this.host.empty) url.host = this.host;
else if (!m_settings.hostName.empty) url.host = m_settings.hostName;
else url.host = m_settings.bindAddresses[0];
if (this.tls) {
url.schema = "https";
if (m_port != 443) url.port = m_port;
} else {
url.schema = "http";
if (m_port != 80) url.port = m_port;
}
}
url.host = url.host.split(":")[0];
url.username = this.username;
url.password = this.password;
url.path = Path(path);
url.queryString = queryString;
return url;
}
/** The relative path the the root folder.
Using this function instead of absolute URLs for embedded links can be
useful to avoid dead link when the site is piped through a
reverse-proxy.
The returned string always ends with a slash.
*/
@property string rootDir() const {
if (path.length == 0) return "./";
auto depth = count(path[1 .. $], '/');
return depth == 0 ? "./" : replicate("../", depth);
}
}
/**
Represents a HTTP response as sent from the server side.
*/
final class HTTPServerResponse : HTTPResponse {
private {
Stream m_conn;
ConnectionStream m_rawConnection;
OutputStream m_bodyWriter;
Allocator m_requestAlloc;
FreeListRef!ChunkedOutputStream m_chunkedBodyWriter;
FreeListRef!CountingOutputStream m_countingWriter;
FreeListRef!GzipOutputStream m_gzipOutputStream;
FreeListRef!DeflateOutputStream m_deflateOutputStream;
HTTPServerSettings m_settings;
Session m_session;
bool m_headerWritten = false;
bool m_isHeadResponse = false;
bool m_tls;
SysTime m_timeFinalized;
}
this(Stream conn, ConnectionStream raw_connection, HTTPServerSettings settings, Allocator req_alloc)
{
m_conn = conn;
m_rawConnection = raw_connection;
m_countingWriter = FreeListRef!CountingOutputStream(conn);
m_settings = settings;
m_requestAlloc = req_alloc;
}
@property SysTime timeFinalized() { return m_timeFinalized; }
/** Determines if the HTTP header has already been written.
*/
@property bool headerWritten() const { return m_headerWritten; }
/** Determines if the response does not need a body.
*/
bool isHeadResponse() const { return m_isHeadResponse; }
/** Determines if the response is sent over an encrypted connection.
*/
bool tls() const { return m_tls; }
/// Compatibility alias - use `tls` instead.
alias ssl = tls;
/// Writes the entire response body at once.
void writeBody(in ubyte[] data, string content_type = null)
{
if (content_type != "") headers["Content-Type"] = content_type;
headers["Content-Length"] = formatAlloc(m_requestAlloc, "%d", data.length);
bodyWriter.write(data);
}
/// ditto
void writeBody(string data, string content_type = "text/plain; charset=UTF-8")
{
writeBody(cast(ubyte[])data, content_type);
}
/// ditto
void writeBody(in ubyte[] data, int status, string content_type = null)
{
statusCode = status;
writeBody(data, content_type);
}
/// ditto
void writeBody(string data, int status, string content_type = "text/plain; charset=UTF-8")
{
statusCode = status;
writeBody(data, content_type);
}
/// ditto
void writeBody(scope InputStream data, string content_type = null)
{
if (content_type != "") headers["Content-Type"] = content_type;
bodyWriter.write(data);
}
/** Writes the whole response body at once, without doing any further encoding.
The caller has to make sure that the appropriate headers are set correctly
(i.e. Content-Type and Content-Encoding).
Note that the version taking a RandomAccessStream may perform additional
optimizations such as sending a file directly from the disk to the
network card using a DMA transfer.
*/
void writeRawBody(RandomAccessStream stream)
{
assert(!m_headerWritten, "A body was already written!");
writeHeader();
if (m_isHeadResponse) return;
auto bytes = stream.size - stream.tell();
m_conn.write(stream);
m_countingWriter.increment(bytes);
}
/// ditto
void writeRawBody(InputStream stream, size_t num_bytes = 0)
{
assert(!m_headerWritten, "A body was already written!");
writeHeader();
if (m_isHeadResponse) return;
if (num_bytes > 0) {
m_conn.write(stream, num_bytes);
m_countingWriter.increment(num_bytes);
} else m_countingWriter.write(stream, num_bytes);
}
/// ditto
void writeRawBody(RandomAccessStream stream, int status)
{
statusCode = status;
writeRawBody(stream);
}
/// ditto
void writeRawBody(InputStream stream, int status, size_t num_bytes = 0)
{
statusCode = status;
writeRawBody(stream, num_bytes);
}
/// Writes a JSON message with the specified status
void writeJsonBody(T)(T data, int status = HTTPStatus.OK, string content_type = "application/json; charset=UTF-8", bool allow_chunked = false)
{
import std.traits;
import vibe.stream.wrapper;
static if (is(typeof(data.data())) && isArray!(typeof(data.data()))) {
static assert(!is(T == Appender!(typeof(data.data()))), "Passed an Appender!T to writeJsonBody - this is most probably not doing what's indended.");
}
statusCode = status;
headers["Content-Type"] = content_type;
// set an explicit content-length field if chunked encoding is not allowed
if (!allow_chunked) {
import vibe.internal.rangeutil;
long length = 0;
auto counter = RangeCounter(&length);
serializeToJson(counter, data);
headers["Content-Length"] = formatAlloc(m_requestAlloc, "%d", length);
}
auto rng = StreamOutputRange(bodyWriter);
serializeToJson(&rng, data);
}
/**
* Writes the response with no body.
*
* This method should be used in situations where no body is
* requested, such as a HEAD request. For an empty body, just use writeBody,
* as this method causes problems with some keep-alive connections.
*/
void writeVoidBody()
{
if (!m_isHeadResponse) {
assert("Content-Length" !in headers);
assert("Transfer-Encoding" !in headers);
}
assert(!headerWritten);
writeHeader();
}
/** A stream for writing the body of the HTTP response.
Note that after 'bodyWriter' has been accessed for the first time, it
is not allowed to change any header or the status code of the response.
*/
@property OutputStream bodyWriter()
{
assert(m_conn !is null);
if (m_bodyWriter) return m_bodyWriter;
assert(!m_headerWritten, "A void body was already written!");
if (m_isHeadResponse) {
// for HEAD requests, we define a NullOutputWriter for convenience
// - no body will be written. However, the request handler should call writeVoidBody()
// and skip writing of the body in this case.
if ("Content-Length" !in headers)
headers["Transfer-Encoding"] = "chunked";
writeHeader();
m_bodyWriter = new NullOutputStream;
return m_bodyWriter;
}
if ("Content-Encoding" in headers && "Content-Length" in headers) {
// we do not known how large the compressed body will be in advance
// so remove the content-length and use chunked transfer
headers.remove("Content-Length");
}
if ("Content-Length" in headers) {
writeHeader();
m_bodyWriter = m_countingWriter; // TODO: LimitedOutputStream(m_conn, content_length)
} else {
headers["Transfer-Encoding"] = "chunked";
writeHeader();
m_chunkedBodyWriter = FreeListRef!ChunkedOutputStream(m_countingWriter);
m_bodyWriter = m_chunkedBodyWriter;
}
if (auto pce = "Content-Encoding" in headers) {
if (icmp2(*pce, "gzip") == 0) {
m_gzipOutputStream = FreeListRef!GzipOutputStream(m_bodyWriter);
m_bodyWriter = m_gzipOutputStream;
} else if (icmp2(*pce, "deflate") == 0) {
m_deflateOutputStream = FreeListRef!DeflateOutputStream(m_bodyWriter);
m_bodyWriter = m_deflateOutputStream;
} else {
logWarn("Unsupported Content-Encoding set in response: '"~*pce~"'");
}
}
return m_bodyWriter;
}
/** Sends a redirect request to the client.
Params:
url = The URL to redirect to
status = The HTTP redirect status (3xx) to send - by default this is $D(D HTTPStatus.found)
*/
void redirect(string url, int status = HTTPStatus.Found)
{
statusCode = status;
headers["Location"] = url;
headers["Content-Length"] = "14";
bodyWriter.write("redirecting...");
}
/// ditto
void redirect(URL url, int status = HTTPStatus.Found)
{
redirect(url.toString(), status);
}
///
unittest {
import vibe.http.router;
void request_handler(HTTPServerRequest req, HTTPServerResponse res)
{
res.redirect("http://example.org/some_other_url");
}
void test()
{
auto router = new URLRouter;
router.get("/old_url", &request_handler);
listenHTTP(new HTTPServerSettings, router);
}
}
/** Special method sending a SWITCHING_PROTOCOLS response to the client.
*/
ConnectionStream switchProtocol(string protocol)
{
statusCode = HTTPStatus.SwitchingProtocols;
headers["Upgrade"] = protocol;
writeVoidBody();
return new ConnectionProxyStream(m_conn, m_rawConnection);
}
/** Sets the specified cookie value.
Params:
name = Name of the cookie
value = New cookie value - pass null to clear the cookie
path = Path (as seen by the client) of the directory tree in which the cookie is visible
*/
Cookie setCookie(string name, string value, string path = "/")
{
auto cookie = new Cookie();
cookie.path = path;
cookie.value = value;
if (value is null) {
cookie.maxAge = 0;
cookie.expires = "Thu, 01 Jan 1970 00:00:00 GMT";
}
cookies[name] = cookie;
return cookie;
}
/**
Initiates a new session.
The session is stored in the SessionStore that was specified when
creating the server. Depending on this, the session can be persistent
or temporary and specific to this server instance.
*/
Session startSession(string path = "/", SessionOption options = SessionOption.httpOnly)
{
assert(m_settings.sessionStore, "no session store set");
assert(!m_session, "Try to start a session, but already started one.");
bool secure;
if (options & SessionOption.secure) secure = true;
else if (options & SessionOption.noSecure) secure = false;
else secure = this.tls;
m_session = m_settings.sessionStore.create();
m_session.set("$sessionCookiePath", path);
m_session.set("$sessionCookieSecure", secure);
auto cookie = setCookie(m_settings.sessionIdCookie, m_session.id, path);
cookie.secure = secure;
cookie.httpOnly = (options & SessionOption.httpOnly) != 0;
return m_session;
}
/**
Terminates the current session (if any).
*/
void terminateSession()
{
assert(m_session, "Try to terminate a session, but none is started.");
auto cookie = setCookie(m_settings.sessionIdCookie, null, m_session.get!string("$sessionCookiePath"));
cookie.secure = m_session.get!bool("$sessionCookieSecure");
m_session.destroy();
m_session = Session.init;
}
@property ulong bytesWritten() { return m_countingWriter.bytesWritten; }
/**
Scheduled for deprecation - use `render` instead.
This version of render() works around an old compiler bug in DMD < 2.064 (Issue 2962).
The first template argument is the name of the template file. All following arguments
must be pairs of a type and a string, each specifying one parameter. Parameter values
can be passed either as a value of the same type as specified by the template
arguments, or as a Variant which has the same type stored.
Note that the variables are copied and not referenced inside of the template - any
modification you do on them from within the template will get lost.
Examples:
---
string title = "Hello, World!";
int pageNumber = 1;
res.renderCompat!("mytemplate.jd",
string, "title",
int, "pageNumber")
(title, pageNumber);
---
*/
void renderCompat(string template_file, TYPES_AND_NAMES...)(...)
{
import vibe.templ.diet;
headers["Content-Type"] = "text/html; charset=UTF-8";
compileDietFileCompatV!(template_file, TYPES_AND_NAMES)(bodyWriter, _argptr, _arguments);
}
/**
Waits until either the connection closes or until the given timeout is
reached.
Returns:
$(D true) if the connection was closed and $(D false) when the
timeout was reached.
*/
bool waitForConnectionClose(Duration timeout = Duration.max)
{
if (!m_rawConnection || !m_rawConnection.connected) return true;
m_rawConnection.waitForData(timeout);
return !m_rawConnection.connected;
}
// Finalizes the response. This is called automatically by the server.
private void finalize()
{
if (m_gzipOutputStream) {
m_gzipOutputStream.finalize();
m_gzipOutputStream.destroy();
}
if (m_deflateOutputStream) {
m_deflateOutputStream.finalize();
m_deflateOutputStream.destroy();
}
if (m_chunkedBodyWriter) {
m_chunkedBodyWriter.finalize();
m_chunkedBodyWriter.destroy();
}
// ignore exceptions caused by an already closed connection - the client
// may have closed the connection already and this doesn't usually indicate
// a problem.
if (m_rawConnection && m_rawConnection.connected) {
try if (m_conn) m_conn.flush();
catch (Exception e) logDebug("Failed to flush connection after finishing HTTP response: %s", e.msg);
if (!isHeadResponse && bytesWritten < headers.get("Content-Length", "0").to!long) {
logDebug("HTTP response only written partially before finalization. Terminating connection.");
m_rawConnection.close();
}
}
m_timeFinalized = Clock.currTime(UTC());
m_conn = null;
m_rawConnection = null;
}
private void writeHeader()
{
import vibe.stream.wrapper;
assert(!m_bodyWriter && !m_headerWritten, "Try to write header after body has already begun.");
m_headerWritten = true;
auto dst = StreamOutputRange(m_conn);
void writeLine(T...)(string fmt, T args)
{
formattedWrite(&dst, fmt, args);
dst.put("\r\n");
logTrace(fmt, args);
}
logTrace("---------------------");
logTrace("HTTP server response:");
logTrace("---------------------");
// write the status line
writeLine("%s %d %s",
getHTTPVersionString(this.httpVersion),
this.statusCode,
this.statusPhrase.length ? this.statusPhrase : httpStatusText(this.statusCode));
// write all normal headers
foreach (k, v; this.headers)
writeLine("%s: %s", k, v);
logTrace("---------------------");
// write cookies
foreach (n, cookie; this.cookies) {
dst.put("Set-Cookie: ");
cookie.writeString(&dst, n);
dst.put("\r\n");
}
// finalize response header
dst.put("\r\n");
dst.flush();
m_conn.flush();
}
}
/**
Represents the request listener for a specific `listenHTTP` call.
This struct can be used to stop listening for HTTP requests at runtime.
*/
struct HTTPListener {
private {
size_t m_contextID;
}
private this(size_t id) { m_contextID = id; }
/** Stops handling HTTP requests and closes the TCP listening port if
possible.
*/
void stopListening()
{
import std.algorithm : countUntil;
synchronized (g_listenersMutex) {
auto contexts = getContexts();
auto idx = contexts.countUntil!(c => c.id == m_contextID);
if (idx < 0) return;
// remove context entry
auto ctx = getContexts()[idx];
removeContext(idx);
// stop listening on all unused TCP ports
auto port = ctx.settings.port;
foreach (addr; ctx.settings.bindAddresses) {
// any other context still occupying the same addr/port?
if (getContexts().canFind!(c => c.settings.port == port && c.settings.bindAddresses.canFind(addr)))
continue;
auto lidx = g_listeners.countUntil!(l => l.bindAddress == addr && l.bindPort == port);
if (lidx >= 0) {
g_listeners[lidx].listener.stopListening();
logInfo("Stopped to listen for HTTP%s requests on %s:%s", ctx.settings.tlsContext ? "S": "", addr, port);
g_listeners = g_listeners[0 .. lidx] ~ g_listeners[lidx+1 .. $];
}
}
}
}
}
/**************************************************************************************************/
/* Private types */
/**************************************************************************************************/
private struct HTTPServerContext {
HTTPServerRequestDelegate requestHandler;
HTTPServerSettings settings;
HTTPLogger[] loggers;
size_t id;
}
private struct HTTPListenInfo {
TCPListener listener;
string bindAddress;
ushort bindPort;
TLSContext tlsContext;
}
private enum MaxHTTPHeaderLineLength = 4096;
private final class LimitedHTTPInputStream : LimitedInputStream {
this(InputStream stream, ulong byte_limit, bool silent_limit = false) {
super(stream, byte_limit, silent_limit);
}
override void onSizeLimitReached() {
throw new HTTPStatusException(HTTPStatus.requestEntityTooLarge);
}
}
private final class TimeoutHTTPInputStream : InputStream {
private {
long m_timeref;
long m_timeleft;
InputStream m_in;
}
this(InputStream stream, Duration timeleft, SysTime reftime)
{
enforce(timeleft > dur!"seconds"(0), "Timeout required");
m_in = stream;
m_timeleft = timeleft.total!"hnsecs"();
m_timeref = reftime.stdTime();
}
@property bool empty() { enforce(m_in !is null, "InputStream missing"); return m_in.empty(); }
@property ulong leastSize() { enforce(m_in !is null, "InputStream missing"); return m_in.leastSize(); }
@property bool dataAvailableForRead() { enforce(m_in !is null, "InputStream missing"); return m_in.dataAvailableForRead; }
const(ubyte)[] peek() { return m_in.peek(); }
void read(ubyte[] dst)
{
enforce(m_in !is null, "InputStream missing");
checkTimeout();
m_in.read(dst);
}
private void checkTimeout()
{
auto curr = Clock.currStdTime();
auto diff = curr - m_timeref;
if (diff > m_timeleft) throw new HTTPStatusException(HTTPStatus.RequestTimeout);
m_timeleft -= diff;
m_timeref = curr;
}
}
/**************************************************************************************************/
/* Private functions */
/**************************************************************************************************/
private {
import core.sync.mutex;
shared string s_distHost;
shared ushort s_distPort = 11000;
shared size_t g_contextIDCounter = 1;
// protects g_listeners and *write* accesses to g_contexts
__gshared Mutex g_listenersMutex;
__gshared HTTPListenInfo[] g_listeners;
// accessed for every request, needs to be kept thread-safe by only atomically assigning new
// arrays (COW). shared immutable(HTTPServerContext)[] would be the right candidate here, but
// is impractical due to type system limitations.
shared HTTPServerContext[] g_contexts;
HTTPServerContext[] getContexts()
{
static if (__VERSION__ >= 2067) {
version (Win64) return cast(HTTPServerContext[])g_contexts;
else return cast(HTTPServerContext[])atomicLoad(g_contexts);
}
else
return cast(HTTPServerContext[])g_contexts;
}
void addContext(HTTPServerContext ctx)
{
synchronized (g_listenersMutex) {
static if (__VERSION__ >= 2067)
atomicStore(g_contexts, g_contexts ~ cast(shared)ctx);
else
g_contexts = g_contexts ~ cast(shared)ctx;
}
}
void removeContext(size_t idx)
{
// write a new complete array reference to avoid race conditions during removal
auto contexts = g_contexts;
auto newarr = contexts[0 .. idx] ~ contexts[idx+1 .. $];
static if (__VERSION__ >= 2067)
atomicStore(g_contexts, newarr);
else
g_contexts = newarr;
}
}
/**
[private] Starts a HTTP server listening on the specified port.
This is the same as listenHTTP() except that it does not use a VibeDist host for
remote listening, even if specified on the command line.
*/
private void listenHTTPPlain(HTTPServerSettings settings)
{
import std.algorithm : canFind;
static TCPListener doListen(HTTPListenInfo listen_info, bool dist)
{
try {
auto ret = listenTCP(listen_info.bindPort, (TCPConnection conn) {
handleHTTPConnection(conn, listen_info);
}, listen_info.bindAddress, dist ? TCPListenOptions.distribute : TCPListenOptions.defaults);
logInfo("Listening for HTTP%s requests on %s:%s", listen_info.tlsContext ? "S" : "", listen_info.bindAddress, listen_info.bindPort);
return ret;
} catch( Exception e ) {
logWarn("Failed to listen on %s:%s", listen_info.bindAddress, listen_info.bindPort);
return null;
}
}
void addVHost(ref HTTPListenInfo lst)
{
auto contexts = getContexts();
TLSContext onSNI(string servername)
{
foreach (ctx; contexts)
if (ctx.settings.bindAddresses.canFind(lst.bindAddress)
&& ctx.settings.port == lst.bindPort
&& ctx.settings.hostName.icmp(servername) == 0)
{
logDebug("Found context for SNI host '%s'.", servername);
return ctx.settings.tlsContext;
}
logDebug("No context found for SNI host '%s'.", servername);
return null;
}
if (settings.tlsContext !is lst.tlsContext && lst.tlsContext.kind != TLSContextKind.serverSNI) {
logDebug("Create SNI TLS context for %s, port %s", lst.bindAddress, lst.bindPort);
lst.tlsContext = createTLSContext(TLSContextKind.serverSNI);
lst.tlsContext.sniCallback = &onSNI;
}
foreach (ctx; contexts) {
if (ctx.settings.port != settings.port) continue;
if (!ctx.settings.bindAddresses.canFind(lst.bindAddress)) continue;
/*enforce(ctx.settings.hostName != settings.hostName,
"A server with the host name '"~settings.hostName~"' is already "
"listening on "~addr~":"~to!string(settings.port)~".");*/
}
}
bool any_successful = false;
synchronized (g_listenersMutex) {
// Check for every bind address/port, if a new listening socket needs to be created and
// check for conflicting servers
foreach (addr; settings.bindAddresses) {
bool found_listener = false;
foreach (i, ref lst; g_listeners) {
if (lst.bindAddress == addr && lst.bindPort == settings.port) {
addVHost(lst);
assert(!settings.tlsContext || settings.tlsContext is lst.tlsContext
|| lst.tlsContext.kind == TLSContextKind.serverSNI,
format("Got multiple overlapping TLS bind addresses (port %s), but no SNI TLS context!?", settings.port));
found_listener = true;
any_successful = true;
break;
}
}
if (!found_listener) {
auto linfo = HTTPListenInfo(null, addr, settings.port, settings.tlsContext);
if (auto tcp_lst = doListen(linfo, (settings.options & HTTPServerOption.distribute) != 0)) // DMD BUG 2043
{
linfo.listener = tcp_lst;
found_listener = true;
any_successful = true;
g_listeners ~= linfo;
}
}
}
}
enforce(any_successful, "Failed to listen for incoming HTTP connections on any of the supplied interfaces.");
}
private void handleHTTPConnection(TCPConnection connection, HTTPListenInfo listen_info)
{
Stream http_stream = connection;
version(VibeNoSSL) {} else {
import std.traits : ReturnType;
ReturnType!createTLSStreamFL tls_stream;
}
if (!connection.waitForData(10.seconds())) {
logDebug("Client didn't send the initial request in a timely manner. Closing connection.");
return;
}
// If this is a HTTPS server, initiate TLS
if (listen_info.tlsContext) {
version (VibeNoSSL) assert(false, "No TLS support compiled in (VibeNoSSL)");
else {
logDebug("Accept TLS connection: %s", listen_info.tlsContext.kind);
// TODO: reverse DNS lookup for peer_name of the incoming connection for TLS client certificate verification purposes
tls_stream = createTLSStreamFL(http_stream, listen_info.tlsContext, TLSStreamState.accepting, null, connection.remoteAddress);
http_stream = tls_stream;
}
}
do {
HTTPServerSettings settings;
bool keep_alive;
handleRequest(http_stream, connection, listen_info, settings, keep_alive);
if (!keep_alive) { logTrace("No keep-alive - disconnecting client."); break; }
logTrace("Waiting for next request...");
// wait for another possible request on a keep-alive connection
if (!connection.waitForData(settings.keepAliveTimeout)) {
if (!connection.connected) logTrace("Client disconnected.");
else logDebug("Keep-alive connection timed out!");
break;
}
} while(!connection.empty);
logTrace("Done handling connection.");
}
private bool handleRequest(Stream http_stream, TCPConnection tcp_connection, HTTPListenInfo listen_info, ref HTTPServerSettings settings, ref bool keep_alive)
{
import std.algorithm : canFind;
SysTime reqtime = Clock.currTime(UTC());
//auto request_allocator = scoped!(PoolAllocator)(1024, defaultAllocator());
scope request_allocator = new PoolAllocator(1024, defaultAllocator());
scope(exit) request_allocator.reset();
// some instances that live only while the request is running
FreeListRef!HTTPServerRequest req = FreeListRef!HTTPServerRequest(reqtime, listen_info.bindPort);
FreeListRef!TimeoutHTTPInputStream timeout_http_input_stream;
FreeListRef!LimitedHTTPInputStream limited_http_input_stream;
FreeListRef!ChunkedInputStream chunked_input_stream;
// store the IP address (IPv4 addresses forwarded over IPv6 are stored in IPv4 format)
auto peer_address_string = tcp_connection.peerAddress;
if (peer_address_string.startsWith("::ffff:") && peer_address_string[7 .. $].indexOf(":") < 0)
req.peer = peer_address_string[7 .. $];
else req.peer = peer_address_string;
req.clientAddress = tcp_connection.remoteAddress;
// Default to the first virtual host for this listener
HTTPServerRequestDelegate request_task;
HTTPServerContext context;
foreach (ctx; getContexts())
if (ctx.settings.port == listen_info.bindPort) {
bool found = false;
foreach (addr; ctx.settings.bindAddresses)
if (addr == listen_info.bindAddress)
found = true;
if (!found) continue;
context = ctx;
settings = ctx.settings;
request_task = ctx.requestHandler;
break;
}
if (!settings) {
logWarn("Didn't find a HTTP listening context for incoming connection. Dropping.");
keep_alive = false;
return false;
}
// Create the response object
auto res = FreeListRef!HTTPServerResponse(http_stream, tcp_connection, settings, request_allocator/*.Scoped_payload*/);
req.tls = res.m_tls = listen_info.tlsContext !is null;
if (req.tls) req.clientCertificate = (cast(TLSStream)http_stream).peerCertificate;
// Error page handler
void errorOut(int code, string msg, string debug_msg, Throwable ex){
assert(!res.headerWritten);
// stack traces sometimes contain random bytes - make sure they are replaced
debug_msg = sanitizeUTF8(cast(ubyte[])debug_msg);
res.statusCode = code;
if (settings && settings.errorPageHandler) {
scope err = new HTTPServerErrorInfo;
err.code = code;
err.message = msg;
err.debugMessage = debug_msg;
err.exception = ex;
settings.errorPageHandler(req, res, err);
} else {
res.writeBody(format("%s - %s\n\n%s\n\nInternal error information:\n%s", code, httpStatusText(code), msg, debug_msg));
}
assert(res.headerWritten);
}
bool parsed = false;
/*bool*/ keep_alive = false;
// parse the request
try {
logTrace("reading request..");
// limit the total request time
InputStream reqReader;
if (settings.maxRequestTime == dur!"seconds"(0)) reqReader = http_stream;
else {
timeout_http_input_stream = FreeListRef!TimeoutHTTPInputStream(http_stream, settings.maxRequestTime, reqtime);
reqReader = timeout_http_input_stream;
}
// basic request parsing
parseRequestHeader(req, reqReader, request_allocator, settings.maxRequestHeaderSize);
logTrace("Got request header.");
// find the matching virtual host
string reqhost;
ushort reqport = 0;
import std.algorithm : splitter;
auto reqhostparts = req.host.splitter(":");
if (!reqhostparts.empty) { reqhost = reqhostparts.front; reqhostparts.popFront(); }
if (!reqhostparts.empty) { reqport = reqhostparts.front.to!ushort; reqhostparts.popFront(); }
enforce(reqhostparts.empty, "Invalid suffix found in host header");
foreach (ctx; getContexts())
if (icmp2(ctx.settings.hostName, reqhost) == 0 &&
(!reqport || reqport == ctx.settings.port))
{
if (ctx.settings.port != listen_info.bindPort) continue;
bool found = false;
foreach (addr; ctx.settings.bindAddresses)
if (addr == listen_info.bindAddress)
found = true;
if (!found) continue;
context = ctx;
settings = ctx.settings;
request_task = ctx.requestHandler;
break;
}
req.m_settings = settings;
res.m_settings = settings;
// setup compressed output
if (settings.useCompressionIfPossible) {
if (auto pae = "Accept-Encoding" in req.headers) {
if (canFind(*pae, "gzip")) {
res.headers["Content-Encoding"] = "gzip";
} else if (canFind(*pae, "deflate")) {
res.headers["Content-Encoding"] = "deflate";
}
}
}
// limit request size
if (auto pcl = "Content-Length" in req.headers) {
string v = *pcl;
auto contentLength = parse!ulong(v); // DMDBUG: to! thinks there is a H in the string
enforceBadRequest(v.length == 0, "Invalid content-length");
enforceBadRequest(settings.maxRequestSize <= 0 || contentLength <= settings.maxRequestSize, "Request size too big");
limited_http_input_stream = FreeListRef!LimitedHTTPInputStream(reqReader, contentLength);
} else if (auto pt = "Transfer-Encoding" in req.headers) {
enforceBadRequest(icmp(*pt, "chunked") == 0);
chunked_input_stream = FreeListRef!ChunkedInputStream(reqReader);
limited_http_input_stream = FreeListRef!LimitedHTTPInputStream(chunked_input_stream, settings.maxRequestSize, true);
} else {
limited_http_input_stream = FreeListRef!LimitedHTTPInputStream(reqReader, 0);
}
req.bodyReader = limited_http_input_stream;
// handle Expect header
if (auto pv = "Expect" in req.headers) {
if (icmp2(*pv, "100-continue") == 0) {
logTrace("sending 100 continue");
http_stream.write("HTTP/1.1 100 Continue\r\n\r\n");
}
}
// URL parsing if desired
if (settings.options & HTTPServerOption.parseURL) {
auto url = URL.parse(req.requestURL);
req.path = urlDecode(url.pathString);
req.queryString = url.queryString;
req.username = url.username;
req.password = url.password;
}
// query string parsing if desired
if (settings.options & HTTPServerOption.parseQueryString) {
if (!(settings.options & HTTPServerOption.parseURL))
logWarn("Query string parsing requested but URL parsing is disabled!");
parseURLEncodedForm(req.queryString, req.query);
}
// cookie parsing if desired
if (settings.options & HTTPServerOption.parseCookies) {
auto pv = "cookie" in req.headers;
if (pv) parseCookies(*pv, req.cookies);
}
// lookup the session
if (settings.sessionStore) {
auto pv = settings.sessionIdCookie in req.cookies;
if (pv) {
// use the first cookie that contains a valid session ID in case
// of multiple matching session cookies
foreach (v; req.cookies.getAll(settings.sessionIdCookie)) {
req.session = settings.sessionStore.open(v);
res.m_session = req.session;
if (req.session) break;
}
}
}
if (settings.options & HTTPServerOption.parseFormBody) {
auto ptype = "Content-Type" in req.headers;
if (ptype) parseFormData(req.form, req.files, *ptype, req.bodyReader, MaxHTTPHeaderLineLength);
}
if (settings.options & HTTPServerOption.parseJsonBody) {
if (icmp2(req.contentType, "application/json") == 0) {
auto bodyStr = cast(string)req.bodyReader.readAll();
if (!bodyStr.empty) req.json = parseJson(bodyStr);
}
}
// write default headers
if (req.method == HTTPMethod.HEAD) res.m_isHeadResponse = true;
if (settings.serverString.length)
res.headers["Server"] = settings.serverString;
res.headers["Date"] = formatRFC822DateAlloc(request_allocator, reqtime);
if (req.persistent) res.headers["Keep-Alive"] = formatAlloc(request_allocator, "timeout=%d", settings.keepAliveTimeout.total!"seconds"());
// finished parsing the request
parsed = true;
logTrace("persist: %s", req.persistent);
keep_alive = req.persistent;
// handle the request
logTrace("handle request (body %d)", req.bodyReader.leastSize);
res.httpVersion = req.httpVersion;
request_task(req, res);
// if no one has written anything, return 404
if (!res.headerWritten) {
string dbg_msg;
logDiagnostic("No response written for %s", req.requestURL);
if (settings.options & HTTPServerOption.errorStackTraces)
dbg_msg = format("Not routes match path '%s'", req.requestURL);
errorOut(HTTPStatus.notFound, httpStatusText(HTTPStatus.notFound), dbg_msg, null);
}
} catch (HTTPStatusException err) {
string dbg_msg;
if (settings.options & HTTPServerOption.errorStackTraces) {
if (err.debugMessage != "") dbg_msg = err.debugMessage;
else dbg_msg = err.toString().sanitize;
}
if (!res.headerWritten) errorOut(err.status, err.msg, dbg_msg, err);
else logDiagnostic("HTTPSterrorOutatusException while writing the response: %s", err.msg);
logDebug("Exception while handling request %s %s: %s", req.method, req.requestURL, err.toString().sanitize);
if (!parsed || res.headerWritten || justifiesConnectionClose(err.status))
keep_alive = false;
} catch (UncaughtException e) {
auto status = parsed ? HTTPStatus.internalServerError : HTTPStatus.badRequest;
string dbg_msg;
if (settings.options & HTTPServerOption.errorStackTraces) dbg_msg = e.toString().sanitize;
if (!res.headerWritten && tcp_connection.connected) errorOut(status, httpStatusText(status), dbg_msg, e);
else logDiagnostic("Error while writing the response: %s", e.msg);
logDebug("Exception while handling request %s %s: %s", req.method, req.requestURL, e.toString().sanitize());
if (!parsed || res.headerWritten || !cast(Exception)e) keep_alive = false;
}
if (tcp_connection.connected) {
if (req.bodyReader && !req.bodyReader.empty) {
auto nullWriter = scoped!NullOutputStream();
nullWriter.write(req.bodyReader);
logTrace("dropped body");
}
}
// finalize (e.g. for chunked encoding)
res.finalize();
foreach (k, v ; req.files) {
if (existsFile(v.tempPath)) {
removeFile(v.tempPath);
logDebug("Deleted upload tempfile %s", v.tempPath.toString());
}
}
// log the request to access log
foreach (log; context.loggers)
log.log(req, res);
logTrace("return %s (used pool memory: %s/%s)", keep_alive, request_allocator.allocatedSize, request_allocator.totalSize);
return keep_alive != false;
}
private void parseRequestHeader(HTTPServerRequest req, InputStream http_stream, Allocator alloc, ulong max_header_size)
{
auto stream = FreeListRef!LimitedHTTPInputStream(http_stream, max_header_size);
logTrace("HTTP server reading status line");
auto reqln = cast(string)stream.readLine(MaxHTTPHeaderLineLength, "\r\n", alloc);
logTrace("--------------------");
logTrace("HTTP server request:");
logTrace("--------------------");
logTrace("%s", reqln);
//Method
auto pos = reqln.indexOf(' ');
enforceBadRequest(pos >= 0, "invalid request method");
req.method = httpMethodFromString(reqln[0 .. pos]);
reqln = reqln[pos+1 .. $];
//Path
pos = reqln.indexOf(' ');
enforceBadRequest(pos >= 0, "invalid request path");
req.requestURL = reqln[0 .. pos];
reqln = reqln[pos+1 .. $];
req.httpVersion = parseHTTPVersion(reqln);
//headers
parseRFC5322Header(stream, req.headers, MaxHTTPHeaderLineLength, alloc, false);
foreach (k, v; req.headers)
logTrace("%s: %s", k, v);
logTrace("--------------------");
}
private void parseCookies(string str, ref CookieValueMap cookies)
{
while(str.length > 0) {
auto idx = str.indexOf('=');
enforceBadRequest(idx > 0, "Expected name=value.");
string name = str[0 .. idx].strip();
str = str[idx+1 .. $];
for (idx = 0; idx < str.length && str[idx] != ';'; idx++) {}
string value = str[0 .. idx].strip();
cookies[name] = urlDecode(value);
str = idx < str.length ? str[idx+1 .. $] : null;
}
}
shared static this()
{
g_listenersMutex = new Mutex;
version (VibeNoDefaultArgs) {}
else {
string disthost = s_distHost;
ushort distport = s_distPort;
import vibe.core.args : readOption;
readOption("disthost|d", &disthost, "Sets the name of a vibedist server to use for load balancing.");
readOption("distport", &distport, "Sets the port used for load balancing.");
setVibeDistHost(disthost, distport);
}
}
private string formatRFC822DateAlloc(Allocator alloc, SysTime time)
{
auto app = AllocAppender!string(alloc);
writeRFC822DateTimeString(app, time);
return app.data;
}
version (VibeDebugCatchAll) private alias UncaughtException = Throwable;
else private alias UncaughtException = Exception;
|
D
|
/**
* Utility subroutines
*
* Only used for DMD
*
* Compiler implementation of the
* $(LINK2 http://www.dlang.org, D programming language).
*
* Copyright: Copyright (C) 1984-1998 by Symantec
* Copyright (C) 2000-2021 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 http://www.digitalmars.com, Walter Bright)
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/backend/util2.d, backend/util2.d)
*/
module dmd.backend.util2;
import core.stdc.stdio;
import core.stdc.stdlib;
import core.stdc.string;
import core.stdc.stdint : uint64_t;
import dmd.backend.cc;
import dmd.backend.cdef;
import dmd.backend.global;
import dmd.backend.mem;
extern (C++):
nothrow:
@safe:
void *ph_malloc(size_t nbytes);
void *ph_calloc(size_t nbytes);
void ph_free(void *p);
void *ph_realloc(void *p , size_t nbytes);
void file_progress()
{
}
/****************************
* Clean up and exit program.
*/
void err_exit()
{
util_exit(EXIT_FAILURE);
}
/********************************
* Clean up and exit program.
*/
void err_break()
{
util_exit(255);
}
/****************************
* Clean up and exit program.
*/
@trusted
void util_exit(int exitcode)
{
exit(exitcode); /* terminate abnormally */
}
version (CRuntime_DigitalMars)
{
extern (C) extern __gshared int controlc_saw;
/********************************
* Control C interrupts go here.
*/
@trusted
private extern (C) void controlc_handler()
{
//printf("saw controlc\n");
controlc_saw = 1;
}
/*********************************
* Trap control C interrupts.
*/
version (MARS) { } else
{
extern (C)
{
void controlc_open();
void controlc_close();
alias _controlc_handler_t = void function();
extern __gshared _controlc_handler_t _controlc_handler;
void _STI_controlc()
{
//printf("_STI_controlc()\n");
_controlc_handler = &controlc_handler;
controlc_open(); /* trap control C */
}
void _STD_controlc()
{
//printf("_STD_controlc()\n");
controlc_close();
}
}
}
}
/***********************************
* Send progress report.
*/
void util_progress()
{
version (MARS) { } else {
version (CRuntime_DigitalMars)
{
if (controlc_saw)
err_break();
}
}
}
void util_progress(int linnum)
{
version (MARS) { } else {
version (CRuntime_DigitalMars)
{
if (controlc_saw)
err_break();
}
}
}
/**********************************
* Binary string search.
* Input:
* p . string of characters
* tab array of pointers to strings
* n = number of pointers in the array
* Returns:
* index (0..n-1) into tab[] if we found a string match
* else -1
*/
version (X86) version (CRuntime_DigitalMars)
version = X86asm;
@trusted
int binary(const(char)* p, const(char)* *table,int high)
{
version (X86asm)
{
alias len = high; // reuse parameter storage
asm nothrow
{
// First find the length of the identifier.
xor EAX,EAX ; // Scan for a 0.
mov EDI,p ;
mov ECX,EAX ;
dec ECX ; // Longest possible string.
repne ;
scasb ;
mov EDX,high ; // EDX = high
not ECX ; // length of the id including '/0', stays in ECX
dec EDX ; // high--
js short Lnotfound ;
dec EAX ; // EAX = -1, so that eventually EBX = low (0)
mov len,ECX ;
even ;
L4D: lea EBX,[EAX + 1] ; // low = mid + 1
cmp EBX,EDX ;
jg Lnotfound ;
even ;
L15: lea EAX,[EBX + EDX] ; // EAX = low + high
// Do the string compare.
mov EDI,table ;
sar EAX,1 ; // mid = (low + high) >> 1
mov ESI,p ;
mov EDI,[4*EAX+EDI] ; // Load table[mid]
mov ECX,len ; // length of id
repe ;
cmpsb ;
je short L63 ; // return mid if equal
jns short L4D ; // if (cond < 0)
lea EDX,-1[EAX] ; // high = mid - 1
cmp EBX,EDX ;
jle L15 ;
Lnotfound:
mov EAX,-1 ; // Return -1.
even ;
L63: ;
}
}
else
{
int low = 0;
char cp = *p;
high--;
p++;
while (low <= high)
{
int mid = (low + high) >> 1;
int cond = table[mid][0] - cp;
if (cond == 0)
cond = strcmp(table[mid] + 1,p);
if (cond > 0)
high = mid - 1;
else if (cond < 0)
low = mid + 1;
else
return mid; /* match index */
}
return -1;
}
}
// search table[0 .. high] for p[0 .. len] (where p.length not necessairily equal to len)
@trusted
int binary(const(char)* p, size_t len, const(char)** table, int high)
{
int low = 0;
char cp = *p;
high--;
p++;
len--;
while (low <= high)
{
int mid = (low + high) >> 1;
int cond = table[mid][0] - cp;
if (cond == 0)
{
cond = strncmp(table[mid] + 1, p, len);
if (cond == 0)
cond = table[mid][len+1]; // same as: if (table[mid][len+1] != '\0') cond = 1;
}
if (cond > 0)
high = mid - 1;
else if (cond < 0)
low = mid + 1;
else
return mid; /* match index */
}
return -1;
}
/**********************
* If c is a power of 2, return that power else -1.
*/
int ispow2(uint64_t c)
{ int i;
if (c == 0 || (c & (c - 1)))
i = -1;
else
for (i = 0; c >>= 1; i++)
{ }
return i;
}
/***************************
*/
enum UTIL_PH = true;
version (MEM_DEBUG)
enum MEM_DEBUG = false; //true;
else
enum MEM_DEBUG = false;
version (Windows)
{
void *util_malloc(uint n,uint size)
{
static if (MEM_DEBUG)
{
void *p;
p = mem_malloc(n * size);
//dbg_printf("util_calloc(%d) = %p\n",n * size,p);
return p;
}
else static if (UTIL_PH)
{
return ph_malloc(n * size);
}
else
{
size_t nbytes = cast(size_t)n * cast(size_t)size;
void *p = malloc(nbytes);
if (!p && nbytes)
err_nomem();
return p;
}
}
}
/***************************
*/
version (Windows)
{
void *util_calloc(uint n,uint size)
{
static if (MEM_DEBUG)
{
void *p;
p = mem_calloc(n * size);
//dbg_printf("util_calloc(%d) = %p\n",n * size,p);
return p;
}
else static if (UTIL_PH)
{
return ph_calloc(n * size);
}
else
{
size_t nbytes = cast(size_t) n * cast(size_t) size;
void *p = calloc(n,size);
if (!p && nbytes)
err_nomem();
return p;
}
}
}
/***************************
*/
version (Windows)
{
void util_free(void *p)
{
//dbg_printf("util_free(%p)\n",p);
static if (MEM_DEBUG)
{
mem_free(p);
}
else static if (UTIL_PH)
{
ph_free(p);
}
else
{
free(p);
}
}
}
/***************************
*/
version (Windows)
{
void *util_realloc(void *oldp,size_t n,size_t size)
{
static if (MEM_DEBUG)
{
//dbg_printf("util_realloc(%p,%d)\n",oldp,n * size);
return mem_realloc(oldp,n * size);
}
else static if (UTIL_PH)
{
return ph_realloc(oldp,n * size);
}
else
{
const nbytes = n * size;
void *p = realloc(oldp,nbytes);
if (!p && nbytes)
err_nomem();
return p;
}
}
}
/*****************************
*/
void *mem_malloc2(uint size)
{
return mem_malloc(size);
}
|
D
|
INSTANCE Info_Mod_Dar_Miguel (C_INFO)
{
npc = Mod_782_SLD_Dar_MT;
nr = 1;
condition = Info_Mod_Dar_Miguel_Condition;
information = Info_Mod_Dar_Miguel_Info;
permanent = 0;
important = 1;
};
FUNC INT Info_Mod_Dar_Miguel_Condition()
{
if (Npc_KnowsInfo(hero, Info_Mod_Miguel_Aufgabe3))
&& (Npc_HasItems(hero, ItPo_MiguelForDar) == 1)
{
return 1;
};
};
FUNC VOID Info_Mod_Dar_Miguel_Info()
{
AI_Output(self, hero, "Info_Mod_Dar_Miguel_28_00"); //(unruhig) Hey, was machst du hier?! Oder bringst du mir die Ware von den Banditen?
AI_Output(hero, self, "Info_Mod_Dar_Miguel_15_01"); //Ähhm, ja, das soll ich.
AI_Output(self, hero, "Info_Mod_Dar_Miguel_28_02"); //Na los, dann her mit dem Trank.
B_GiveInvItems (hero, self, ItPo_MiguelForDar, 1);
AI_Output(self, hero, "Info_Mod_Dar_Miguel_28_03"); //Na dann, wohl bekomms ...
CreateInvItems (self, ItPo_Health_01, 1);
B_UseItem (self, ItPo_Health_01);
AI_Output(hero, self, "Info_Mod_Dar_Miguel_15_04"); //Ähh ...
AI_Output(self, hero, "Info_Mod_Dar_Miguel_28_05"); //Buaahh, echt krasses Zeug, haut derbe rein. Mit so was will ich mich am libsten dn gaaanzn Tlg ...
AI_StopProcessInfos (self);
AI_PlayAni (self, "T_DANCE_01");
AI_PlayAni (self, "T_STAND_2_SLEEPGROUND");
B_LogEntry (TOPIC_MOD_BDT_FLIEGENPILZLURKERSCHLEIM, "Dar schlürft das Gebräu selbst leer? Was soll das jetzt? Gesund ist das bestimmt nicht ...");
};
INSTANCE Info_Mod_Dar_EXIT (C_INFO)
{
npc = Mod_782_SLD_Dar_MT;
nr = 1;
condition = Info_Mod_Dar_EXIT_Condition;
information = Info_Mod_Dar_EXIT_Info;
permanent = 1;
important = 0;
description = DIALOG_ENDE;
};
FUNC INT Info_Mod_Dar_EXIT_Condition()
{
return 1;
};
FUNC VOID Info_Mod_Dar_EXIT_Info()
{
AI_StopProcessInfos (self);
};
|
D
|
INSTANCE Mod_7681_ASS_Halbtoter_NW (Npc_Default)
{
// ------ NSC ------
name = "Halbtoter";
guild = GIL_OUT;
id = 7681;
voice = 13;
flags = 0;
npctype = NPCTYPE_MAIN;
// ------ Attribute ------
B_SetAttributesToChapter (self, 4);
// ------ Kampf-Taktik ------
fight_tactic = FAI_HUMAN_NORMAL;
// ------ Equippte Waffen ------
EquipItem (self, ItMw_Assassinenschwert);
EquipItem (self, ItRw_Assassinenbogen);
// ------ Inventory ------
B_CreateAmbientInv (self);
// ------ visuals ------
B_SetNpcVisual (self, MALE, "Hum_Head_Bald", Face_B_Normal_Sharky, BodyTex_B,ITAR_Assassine_01);
Mdl_SetModelFatness (self,0);
//Mdl_ApplyOverlayMds (self, "Humans_Relaxed.mds");
// ------ NSC-relevante Talente vergeben ------
B_GiveNpcTalents (self);
// ------ Kampf-Talente ------
B_SetFightSkills (self, 50);
// ------ TA anmelden ------
daily_routine = Rtn_Start_7681;
};
FUNC VOID Rtn_Start_7681()
{
TA_Sit_Campfire (07,20,01,20,"WP_ASSASSINE_08");
TA_Sit_Campfire (01,20,07,20,"WP_ASSASSINE_08");
};
|
D
|
/*
* DSFML - The Simple and Fast Multimedia Library for D
*
* Copyright (c) 2013 - 2020 Jeremy DeHaan (dehaan.jeremiah@gmail.com)
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the
* use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim
* that you wrote the original software. If you use this software in a product,
* an acknowledgment in the product documentation would be appreciated but is
* not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution
*
*
* DSFML is based on SFML (Copyright Laurent Gomila)
*/
/**
* `Mutex` stands for "MUTual EXclusion". A mutex is a synchronization
* object, used when multiple threads are involved.
*
* When you want to protect a part of the code from being accessed
* simultaneously by multiple threads, you typically use a mutex. When a thread
* is locked by a mutex, any other thread trying to lock it will be blocked
* until the mutex is released by the thread that locked it. This way, you can
* allow only one thread at a time to access a critical region of your code.
*
* Example:
* ---
* // this is a critical resource that needs some protection
* Database database;
* auto mutex = Mutex();
*
* void thread1()
* {
* // this call will block the thread if the mutex is already locked by thread2
* mutex.lock();
* database.write(...);
* // if thread2 was waiting, it will now be unblocked
* mutex.unlock();
* }
*
* void thread2()
* {
* // this call will block the thread if the mutex is already locked by thread1
* mutex.lock();
* database.write(...);
* mutex.unlock(); // if thread1 was waiting, it will now be unblocked
* }
* ---
*
* Be very careful with mutexes. A bad usage can lead to bad problems,
* like deadlocks (two threads are waiting for each other and the application is
* globally stuck).
*
* To make the usage of mutexes more robust, particularly in environments where
* exceptions can be thrown, you should use the helper class $(LOCK_LINK) to
* lock/unlock mutexes.
*
* DSFML mutexes are recursive, which means that you can lock a mutex multiple
* times in the same thread without creating a deadlock. In this case, the first
* call to `lock()` behaves as usual, and the following ones have no effect.
* However, you must call `unlock()` exactly as many times as you called
* `lock()`. If you don't, the mutex won't be released.
*
* Note that the `Mutex` class is added for convenience, and is nothing more
* than a simnple wrapper around the existing `core.sync.mutex.Mutex` class.
*
* See_Also:
* $(LOCK_LINK)
*/
module dsfml.system.mutex;
import core = core.sync.mutex;
/**
* Blocks concurrent access to shared resources from multiple threads.
*/
class Mutex
{
private core.Mutex m_mutex;
/// Default Constructor
@safe this()
{
m_mutex = new core.Mutex();
}
/**
* Lock the mutex
*
* If the mutex is already locked in another thread, this call will block
* the execution until the mutex is released.
*/
@safe void lock()
{
m_mutex.lock();
}
/// Unlock the mutex.
@safe void unlock()
{
m_mutex.unlock();
}
}
unittest
{
import dsfml.system.thread : Thread;
import dsfml.system.sleep : sleep;
import dsfml.system.time : seconds;
import std.stdio : writeln;
writeln("Running Mutex unittest...");
auto mutex = new Mutex();
string result = "";
void thread1()
{
mutex.lock();
for (int i = 0; i < 10; ++i)
{
sleep(seconds(0.01));
result ~= "1";
}
mutex.unlock();
}
void thread2()
{
mutex.lock();
for (int i = 0; i < 10; ++i)
{
sleep(seconds(0.01));
result ~= "2";
}
mutex.unlock();
}
auto t1 = new Thread(&thread1);
auto t2 = new Thread(&thread2);
t1.launch();
// Sometimes t2 is launched before t1
sleep(seconds(0.01));
t2.launch();
// waiting for the threads to finish before calling the asserts.
t1.wait();
t2.wait();
assert(result == "11111111112222222222");
}
|
D
|
/******************************************************************************
This module contains the enumeration of Croc metamethods and some data about
them used by the interpreter.
License:
Copyright (c) 2011 Jarrett Billingsley
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the
use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software in a
product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
******************************************************************************/
module croc.base_metamethods;
package:
// The first several values of this enumeration are also the basis for the secondary
// opcode for many multi-part instructions, so that the metamethods can be looked up
// quickly without needing an opcode-to-MM translation table.
// LAST_OPCODE_MM is the last metamethod type which is like this.
enum MM
{
Add,
Sub,
Mul,
Div,
Mod,
AddEq,
SubEq,
MulEq,
DivEq,
ModEq,
And,
Or,
Xor,
Shl,
Shr,
UShr,
AndEq,
OrEq,
XorEq,
ShlEq,
ShrEq,
UShrEq,
LAST_OPCODE_MM = UShrEq,
Neg,
Com,
Inc,
Dec,
Add_r,
Sub_r,
Mul_r,
Div_r,
Mod_r,
And_r,
Or_r,
Xor_r,
Shl_r,
Shr_r,
UShr_r,
Cat,
CatEq,
Cat_r,
Index,
IndexAssign,
Slice,
SliceAssign,
Field,
FieldAssign,
Length,
LengthAssign,
Cmp,
Equals,
Call,
Method,
Apply,
In,
ToString,
}
const char[][] MetaNames =
[
MM.Add: "opAdd",
MM.Add_r: "opAdd_r",
MM.AddEq: "opAddAssign",
MM.And: "opAnd",
MM.And_r: "opAnd_r",
MM.AndEq: "opAndAssign",
MM.Apply: "opApply",
MM.Call: "opCall",
MM.Cat: "opCat",
MM.Cat_r: "opCat_r",
MM.CatEq: "opCatAssign",
MM.Cmp: "opCmp",
MM.Com: "opCom",
MM.Dec: "opDec",
MM.Div: "opDiv",
MM.Div_r: "opDiv_r",
MM.DivEq: "opDivAssign",
MM.Equals: "opEquals",
MM.Field: "opField",
MM.FieldAssign: "opFieldAssign",
MM.In: "opIn",
MM.Inc: "opInc",
MM.Index: "opIndex",
MM.IndexAssign: "opIndexAssign",
MM.Length: "opLength",
MM.LengthAssign: "opLengthAssign",
MM.Method: "opMethod",
MM.Mod: "opMod",
MM.Mod_r: "opMod_r",
MM.ModEq: "opModAssign",
MM.Mul: "opMul",
MM.Mul_r: "opMul_r",
MM.MulEq: "opMulAssign",
MM.Neg: "opNeg",
MM.Or: "opOr",
MM.Or_r: "opOr_r",
MM.OrEq: "opOrAssign",
MM.Shl: "opShl",
MM.Shl_r: "opShl_r",
MM.ShlEq: "opShlAssign",
MM.Shr: "opShr",
MM.Shr_r: "opShr_r",
MM.ShrEq: "opShrAssign",
MM.Slice: "opSlice",
MM.SliceAssign: "opSliceAssign",
MM.Sub: "opSub",
MM.Sub_r: "opSub_r",
MM.SubEq: "opSubAssign",
MM.ToString: "toString",
MM.UShr: "opUShr",
MM.UShr_r: "opUShr_r",
MM.UShrEq: "opUShrAssign",
MM.Xor: "opXor",
MM.Xor_r: "opXor_r",
MM.XorEq: "opXorAssign",
];
const MM[] MMRev =
[
MM.Add: MM.Add_r,
MM.Sub: MM.Sub_r,
MM.Mul: MM.Mul_r,
MM.Div: MM.Div_r,
MM.Mod: MM.Mod_r,
MM.Cat: MM.Cat_r,
MM.And: MM.And_r,
MM.Or: MM.Or_r,
MM.Xor: MM.Xor_r,
MM.Shl: MM.Shl_r,
MM.Shr: MM.Shr_r,
MM.UShr: MM.UShr_r,
MM.max: cast(MM)-1
];
const bool[] MMCommutative =
[
MM.Add: true,
MM.Mul: true,
MM.And: true,
MM.Or: true,
MM.Xor: true,
MM.max: false
];
|
D
|
/**
* Compiler implementation of the
* $(LINK2 http://www.dlang.org, D programming language).
* Entry point for DMD.
*
* This modules defines the entry point (main) for DMD, as well as related
* utilities needed for arguments parsing, path manipulation, etc...
* This file is not shared with other compilers which use the DMD front-end.
*
* Copyright: Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 http://www.digitalmars.com, Walter Bright)
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/mars.d, _mars.d)
* Documentation: https://dlang.org/phobos/dmd_mars.html
* Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/mars.d
*/
module dmd.mars;
import core.stdc.ctype;
import core.stdc.limits;
import core.stdc.stdio;
import core.stdc.stdlib;
import core.stdc.string;
import dmd.arraytypes;
import dmd.gluelayer;
import dmd.builtin;
import dmd.cond;
import dmd.console;
import dmd.compiler;
import dmd.dinifile;
import dmd.dinterpret;
import dmd.dmodule;
import dmd.doc;
import dmd.dsymbol;
import dmd.dsymbolsem;
import dmd.errors;
import dmd.expression;
import dmd.globals;
import dmd.hdrgen;
import dmd.id;
import dmd.identifier;
import dmd.inline;
import dmd.json;
import dmd.lib;
import dmd.link;
import dmd.mtype;
import dmd.objc;
import dmd.root.array;
import dmd.root.file;
import dmd.root.filename;
import dmd.root.man;
import dmd.root.outbuffer;
import dmd.root.response;
import dmd.root.rmem;
import dmd.root.stringtable;
import dmd.semantic2;
import dmd.semantic3;
import dmd.target;
import dmd.utils;
/**
* Print DMD's logo on stdout
*/
private void logo()
{
printf("DMD%llu D Compiler %s\n%s %s\n", cast(ulong)size_t.sizeof * 8, global._version, global.copyright, global.written);
}
/**
Print DMD's logo with more debug information and error-reporting pointers.
Params:
stream = output stream to print the information on
*/
extern(C) void printInternalFailure(FILE* stream)
{
fputs(("---\n" ~
"ERROR: This is a compiler bug.\n" ~
"Please report it via https://issues.dlang.org/enter_bug.cgi\n" ~
"with, preferably, a reduced, reproducible example and the information below.\n" ~
"DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the reduction.\n" ~
"---\n").ptr, stream);
stream.fprintf("DMD %s\n", global._version);
stream.printPredefinedVersions;
stream.printGlobalConfigs();
fputs("---\n".ptr, stream);
}
/**
* Print DMD's usage message on stdout
*/
private void usage()
{
import dmd.cli : CLIUsage;
logo();
auto help = CLIUsage.usage;
printf("
Documentation: https://dlang.org/
Config file: %s
Usage:
dmd [<option>...] <file>...
dmd [<option>...] -run <file> [<arg>...]
Where:
<file> D source file
<arg> Argument to pass when running the resulting program
<option>:
@<cmdfile> read arguments from cmdfile
%.*s", FileName.canonicalName(global.inifilename), cast(int)help.length, &help[0]);
}
/**
* DMD's real entry point
*
* Parses command line arguments and config file, open and read all
* provided source file and do semantic analysis on them.
*
* Params:
* argc = Number of arguments passed via command line
* argv = Array of string arguments passed via command line
*
* Returns:
* Application return code
*/
private int tryMain(size_t argc, const(char)** argv, ref Param params)
{
Strings files;
Strings libmodules;
global._init();
debug
{
printf("DMD %s DEBUG\n", global._version);
fflush(stdout); // avoid interleaving with stderr output when redirecting
}
// Check for malformed input
if (argc < 1 || !argv)
{
Largs:
error(Loc.initial, "missing or null command line arguments");
fatal();
}
// Convert argc/argv into arguments[] for easier handling
Strings arguments = Strings(argc);
for (size_t i = 0; i < argc; i++)
{
if (!argv[i])
goto Largs;
arguments[i] = argv[i];
}
if (response_expand(&arguments)) // expand response files
error(Loc.initial, "can't open response file");
//for (size_t i = 0; i < arguments.dim; ++i) printf("arguments[%d] = '%s'\n", i, arguments[i]);
files.reserve(arguments.dim - 1);
// Set default values
params.argv0 = arguments[0].toDString;
// Temporary: Use 32 bits OMF as the default on Windows, for config parsing
static if (TARGET.Windows)
{
params.is64bit = false;
params.mscoff = false;
}
global.inifilename = parse_conf_arg(&arguments);
if (global.inifilename)
{
// can be empty as in -conf=
if (strlen(global.inifilename) && !FileName.exists(global.inifilename))
error(Loc.initial, "Config file '%s' does not exist.", global.inifilename);
}
else
{
version (Windows)
{
global.inifilename = findConfFile(params.argv0, "sc.ini").ptr;
}
else version (Posix)
{
global.inifilename = findConfFile(params.argv0, "dmd.conf").ptr;
}
else
{
static assert(0, "fix this");
}
}
// Read the configurarion file
auto inifile = File(global.inifilename);
inifile.read();
/* Need path of configuration file, for use in expanding @P macro
*/
const(char)* inifilepath = FileName.path(global.inifilename);
Strings sections;
StringTable environment;
environment._init(7);
/* Read the [Environment] section, so we can later
* pick up any DFLAGS settings.
*/
sections.push("Environment");
parseConfFile(&environment, global.inifilename, inifilepath, inifile.len, inifile.buffer, §ions);
const(char)* arch = params.is64bit ? "64" : "32"; // use default
arch = parse_arch_arg(&arguments, arch);
// parse architecture from DFLAGS read from [Environment] section
{
Strings dflags;
getenv_setargv(readFromEnv(&environment, "DFLAGS"), &dflags);
environment.reset(7); // erase cached environment updates
arch = parse_arch_arg(&dflags, arch);
}
bool is64bit = arch[0] == '6';
version(Windows) // delete LIB entry in [Environment] (necessary for optlink) to allow inheriting environment for MS-COFF
if (is64bit || strcmp(arch, "32mscoff") == 0)
environment.update("LIB", 3).ptrvalue = null;
// read from DFLAGS in [Environment{arch}] section
char[80] envsection = void;
sprintf(envsection.ptr, "Environment%s", arch);
sections.push(envsection.ptr);
parseConfFile(&environment, global.inifilename, inifilepath, inifile.len, inifile.buffer, §ions);
getenv_setargv(readFromEnv(&environment, "DFLAGS"), &arguments);
updateRealEnvironment(&environment);
environment.reset(1); // don't need environment cache any more
if (parseCommandLine(arguments, argc, params, files))
{
Loc loc;
errorSupplemental(loc, "run `dmd` to print the compiler manual");
errorSupplemental(loc, "run `dmd -man` to open browser on manual");
return EXIT_FAILURE;
}
if (params.usage)
{
usage();
return EXIT_SUCCESS;
}
if (params.logo)
{
logo();
return EXIT_SUCCESS;
}
/*
Prints a supplied usage text to the console and
returns the exit code for the help usage page.
Returns:
`EXIT_SUCCESS` if no errors occurred, `EXIT_FAILURE` otherwise
*/
static int printHelpUsage(string help)
{
printf("%.*s", cast(int)help.length, &help[0]);
return global.errors ? EXIT_FAILURE : EXIT_SUCCESS;
}
/*
Generates code to check for all `params` whether any usage page
has been requested.
If so, the generated code will print the help page of the flag
and return with an exit code.
Params:
params = parameters with `Usage` suffices in `params` for which
their truthness should be checked.
Returns: generated code for checking the usage pages of the provided `params`.
*/
static string generateUsageChecks(string[] params)
{
string s;
foreach (n; params)
{
s ~= q{
if (params.}~n~q{Usage)
return printHelpUsage(CLIUsage.}~n~q{Usage);
};
}
return s;
}
import dmd.cli : CLIUsage;
mixin(generateUsageChecks(["mcpu", "transition", "check", "checkAction",
"preview", "revert", "externStd"]));
if (params.manual)
{
version (Windows)
{
browse("http://dlang.org/dmd-windows.html");
}
version (linux)
{
browse("http://dlang.org/dmd-linux.html");
}
version (OSX)
{
browse("http://dlang.org/dmd-osx.html");
}
version (FreeBSD)
{
browse("http://dlang.org/dmd-freebsd.html");
}
/*NOTE: No regular builds for openbsd/dragonflybsd (yet) */
/*
version (OpenBSD)
{
browse("http://dlang.org/dmd-openbsd.html");
}
version (DragonFlyBSD)
{
browse("http://dlang.org/dmd-dragonflybsd.html");
}
*/
return EXIT_SUCCESS;
}
if (params.color)
global.console = Console.create(core.stdc.stdio.stderr);
setTarget(params); // set target operating system
setTargetCPU(params);
if (params.is64bit != is64bit)
error(Loc.initial, "the architecture must not be changed in the %s section of %s", envsection.ptr, global.inifilename);
if (global.errors)
{
fatal();
}
if (files.dim == 0)
{
if (params.jsonFieldFlags)
{
generateJson(null);
return EXIT_SUCCESS;
}
usage();
return EXIT_FAILURE;
}
reconcileCommands(params, files.dim);
// Add in command line versions
if (params.versionids)
foreach (charz; *params.versionids)
VersionCondition.addGlobalIdent(charz[0 .. strlen(charz)]);
if (params.debugids)
foreach (charz; *params.debugids)
DebugCondition.addGlobalIdent(charz[0 .. strlen(charz)]);
setTarget(params);
// Predefined version identifiers
addDefaultVersionIdentifiers(params);
setDefaultLibrary();
// Initialization
Type._init();
Id.initialize();
Module._init();
target._init(params);
Expression._init();
Objc._init();
builtin_init();
import dmd.filecache : FileCache;
FileCache._init();
version(CRuntime_Microsoft)
{
import dmd.root.longdouble;
initFPU();
}
import dmd.root.ctfloat : CTFloat;
CTFloat.initialize();
if (params.verbose)
{
stdout.printPredefinedVersions();
stdout.printGlobalConfigs();
}
//printf("%d source files\n",files.dim);
// Build import search path
static Strings* buildPath(Strings* imppath)
{
Strings* result = null;
if (imppath)
{
foreach (const path; *imppath)
{
Strings* a = FileName.splitPath(path);
if (a)
{
if (!result)
result = new Strings();
result.append(a);
}
}
}
return result;
}
global.path = buildPath(params.imppath);
global.filePath = buildPath(params.fileImppath);
if (params.addMain)
{
files.push(global.main_d); // a dummy name, we never actually look up this file
}
// Create Modules
Modules modules = createModules(files, libmodules);
// Read files
/* Start by "reading" the dummy main.d file
*/
if (params.addMain)
{
bool added = false;
foreach (m; modules)
{
if (strcmp(m.srcfile.name.toChars(), global.main_d) == 0)
{
string buf = "int main(){return 0;}";
m.srcfile.setbuffer(cast(void*)buf.ptr, buf.length);
m.srcfile._ref = 1;
added = true;
break;
}
}
assert(added);
}
enum ASYNCREAD = false;
static if (ASYNCREAD)
{
// Multi threaded
AsyncRead* aw = AsyncRead.create(modules.dim);
foreach (m; modules)
{
aw.addFile(m.srcfile);
}
aw.start();
}
else
{
// Single threaded
foreach (m; modules)
{
m.read(Loc.initial);
}
}
// Parse files
bool anydocfiles = false;
size_t filecount = modules.dim;
for (size_t filei = 0, modi = 0; filei < filecount; filei++, modi++)
{
Module m = modules[modi];
if (params.verbose)
message("parse %s", m.toChars());
if (!Module.rootModule)
Module.rootModule = m;
m.importedFrom = m; // m.isRoot() == true
if (!params.oneobj || modi == 0 || m.isDocFile)
m.deleteObjFile();
static if (ASYNCREAD)
{
if (aw.read(filei))
{
error(Loc.initial, "cannot read file %s", m.srcfile.name.toChars());
fatal();
}
}
m.parse();
if (m.isHdrFile)
{
// Remove m's object file from list of object files
for (size_t j = 0; j < params.objfiles.dim; j++)
{
if (m.objfile.name.toChars() == params.objfiles[j])
{
params.objfiles.remove(j);
break;
}
}
if (params.objfiles.dim == 0)
params.link = false;
}
if (m.isDocFile)
{
anydocfiles = true;
gendocfile(m);
// Remove m from list of modules
modules.remove(modi);
modi--;
// Remove m's object file from list of object files
for (size_t j = 0; j < params.objfiles.dim; j++)
{
if (m.objfile.name.toChars() == params.objfiles[j])
{
params.objfiles.remove(j);
break;
}
}
if (params.objfiles.dim == 0)
params.link = false;
}
}
static if (ASYNCREAD)
{
AsyncRead.dispose(aw);
}
if (anydocfiles && modules.dim && (params.oneobj || params.objname))
{
error(Loc.initial, "conflicting Ddoc and obj generation options");
fatal();
}
if (global.errors)
fatal();
if (params.doHdrGeneration)
{
/* Generate 'header' import files.
* Since 'header' import files must be independent of command
* line switches and what else is imported, they are generated
* before any semantic analysis.
*/
foreach (m; modules)
{
if (m.isHdrFile)
continue;
if (params.verbose)
message("import %s", m.toChars());
genhdrfile(m);
}
}
if (global.errors)
fatal();
// load all unconditional imports for better symbol resolving
foreach (m; modules)
{
if (params.verbose)
message("importall %s", m.toChars());
m.importAll(null);
}
if (global.errors)
fatal();
backend_init();
// Do semantic analysis
foreach (m; modules)
{
if (params.verbose)
message("semantic %s", m.toChars());
m.dsymbolSemantic(null);
}
//if (global.errors)
// fatal();
Module.dprogress = 1;
Module.runDeferredSemantic();
if (Module.deferred.dim)
{
for (size_t i = 0; i < Module.deferred.dim; i++)
{
Dsymbol sd = Module.deferred[i];
sd.error("unable to resolve forward reference in definition");
}
//fatal();
}
// Do pass 2 semantic analysis
foreach (m; modules)
{
if (params.verbose)
message("semantic2 %s", m.toChars());
m.semantic2(null);
}
Module.runDeferredSemantic2();
if (global.errors)
fatal();
// Do pass 3 semantic analysis
foreach (m; modules)
{
if (params.verbose)
message("semantic3 %s", m.toChars());
m.semantic3(null);
}
if (includeImports)
{
// Note: DO NOT USE foreach here because Module.amodules.dim can
// change on each iteration of the loop
for (size_t i = 0; i < compiledImports.dim; i++)
{
auto m = compiledImports[i];
assert(m.isRoot);
if (params.verbose)
message("semantic3 %s", m.toChars());
m.semantic3(null);
modules.push(m);
}
}
Module.runDeferredSemantic3();
if (global.errors)
fatal();
// Scan for functions to inline
if (params.useInline)
{
foreach (m; modules)
{
if (params.verbose)
message("inline scan %s", m.toChars());
inlineScanModule(m);
}
}
// Do not attempt to generate output files if errors or warnings occurred
if (global.errors || global.warnings)
fatal();
// inlineScan incrementally run semantic3 of each expanded functions.
// So deps file generation should be moved after the inlinig stage.
if (params.moduleDeps)
{
foreach (i; 1 .. modules[0].aimports.dim)
semantic3OnDependencies(modules[0].aimports[i]);
OutBuffer* ob = params.moduleDeps;
if (params.moduleDepsFile)
{
auto deps = File(params.moduleDepsFile);
deps.setbuffer(cast(void*)ob.data, ob.offset);
writeFile(Loc.initial, &deps);
}
else
printf("%.*s", cast(int)ob.offset, ob.data);
}
printCtfePerformanceStats();
Library library = null;
if (params.lib)
{
if (params.objfiles.dim == 0)
{
error(Loc.initial, "no input files");
return EXIT_FAILURE;
}
library = Library.factory();
library.setFilename(params.objdir, params.libname);
// Add input object and input library files to output library
foreach (p; libmodules)
library.addObject(p, null);
}
// Generate output files
if (params.doJsonGeneration)
{
generateJson(&modules);
}
if (!global.errors && params.doDocComments)
{
foreach (m; modules)
{
gendocfile(m);
}
}
if (params.vcg_ast)
{
import dmd.hdrgen;
foreach (mod; modules)
{
auto buf = OutBuffer();
buf.doindent = 1;
moduleToBuffer(&buf, mod);
// write the output to $(filename).cg
auto cgFilename = FileName.addExt(mod.srcfile.toString(), "cg");
auto cgFile = File(cgFilename);
cgFile.setbuffer(buf.data, buf.offset);
cgFile._ref = 1;
cgFile.write();
}
}
if (!params.obj)
{
}
else if (params.oneobj)
{
Module firstm; // first module we generate code for
foreach (m; modules)
{
if (m.isHdrFile)
continue;
if (!firstm)
{
firstm = m;
obj_start(cast(char*)m.srcfile.toChars());
}
if (params.verbose)
message("code %s", m.toChars());
genObjFile(m, false);
if (entrypoint && m == rootHasMain)
genObjFile(entrypoint, false);
}
if (!global.errors && firstm)
{
obj_end(library, firstm.objfile);
}
}
else
{
foreach (m; modules)
{
if (m.isHdrFile)
continue;
if (params.verbose)
message("code %s", m.toChars());
obj_start(m.srcfile.toChars());
genObjFile(m, params.multiobj);
if (entrypoint && m == rootHasMain)
genObjFile(entrypoint, params.multiobj);
obj_end(library, m.objfile);
obj_write_deferred(library);
if (global.errors && !params.lib)
m.deleteObjFile();
}
}
if (params.lib && !global.errors)
library.write();
backend_term();
if (global.errors)
fatal();
int status = EXIT_SUCCESS;
if (!params.objfiles.dim)
{
if (params.link)
error(Loc.initial, "no object files to link");
}
else
{
if (params.link)
status = runLINK();
if (params.run)
{
if (!status)
{
status = runProgram();
/* Delete .obj files and .exe file
*/
foreach (m; modules)
{
m.deleteObjFile();
if (params.oneobj)
break;
}
remove(params.exefile);
}
}
}
if (global.errors || global.warnings)
fatal();
return status;
}
private void generateJson(Modules* modules)
{
OutBuffer buf;
json_generate(&buf, modules);
// Write buf to file
const(char)* name = global.params.jsonfilename;
if (name && name[0] == '-' && name[1] == 0)
{
// Write to stdout; assume it succeeds
size_t n = fwrite(buf.data, 1, buf.offset, stdout);
assert(n == buf.offset); // keep gcc happy about return values
}
else
{
/* The filename generation code here should be harmonized with Module::setOutfile()
*/
const(char)* jsonfilename;
if (name && *name)
{
jsonfilename = FileName.defaultExt(name, global.json_ext);
}
else
{
if (global.params.objfiles.dim == 0)
{
error(Loc.initial, "cannot determine JSON filename, use `-Xf=<file>` or provide a source file");
fatal();
}
// Generate json file name from first obj name
const(char)* n = global.params.objfiles[0];
n = FileName.name(n);
//if (!FileName::absolute(name))
// name = FileName::combine(dir, name);
jsonfilename = FileName.forceExt(n, global.json_ext);
}
ensurePathToNameExists(Loc.initial, jsonfilename);
auto jsonfile = new File(jsonfilename);
jsonfile.setbuffer(buf.data, buf.offset);
jsonfile._ref = 1;
writeFile(Loc.initial, jsonfile);
}
}
/**
* Entry point which forwards to `tryMain`.
*
* Returns:
* Return code of the application
*/
version(NoMain) {} else
int main()
{
import core.memory;
import core.runtime;
version (GC)
{
}
else
{
GC.disable();
}
version(D_Coverage)
{
// for now we need to manually set the source path
string dirName(string path, char separator)
{
for (size_t i = path.length - 1; i > 0; i--)
{
if (path[i] == separator)
return path[0..i];
}
return path;
}
version (Windows)
enum sourcePath = dirName(dirName(__FILE_FULL_PATH__, '\\'), '\\');
else
enum sourcePath = dirName(dirName(__FILE_FULL_PATH__, '/'), '/');
dmd_coverSourcePath(sourcePath);
dmd_coverDestPath(sourcePath);
dmd_coverSetMerge(true);
}
scope(failure) stderr.printInternalFailure;
auto args = Runtime.cArgs();
return tryMain(args.argc, cast(const(char)**)args.argv, global.params);
}
/**
* Parses an environment variable containing command-line flags
* and append them to `args`.
*
* This function is used to read the content of DFLAGS.
* Flags are separated based on spaces and tabs.
*
* Params:
* envvalue = The content of an environment variable
* args = Array to append the flags to, if any.
*/
void getenv_setargv(const(char)* envvalue, Strings* args)
{
if (!envvalue)
return;
char* env = mem.xstrdup(envvalue); // create our own writable copy
//printf("env = '%s'\n", env);
while (1)
{
switch (*env)
{
case ' ':
case '\t':
env++;
break;
case 0:
return;
default:
{
args.push(env); // append
auto p = env;
auto slash = 0;
bool instring = false;
while (1)
{
auto c = *env++;
switch (c)
{
case '"':
p -= (slash >> 1);
if (slash & 1)
{
p--;
goto default;
}
instring ^= true;
slash = 0;
continue;
case ' ':
case '\t':
if (instring)
goto default;
*p = 0;
//if (wildcard)
// wildcardexpand(); // not implemented
break;
case '\\':
slash++;
*p++ = c;
continue;
case 0:
*p = 0;
//if (wildcard)
// wildcardexpand(); // not implemented
return;
default:
slash = 0;
*p++ = c;
continue;
}
break;
}
break;
}
}
}
}
/**
* Parse command line arguments for the last instance of -m32, -m64 or -m32mscoff
* to detect the desired architecture.
*
* Params:
* args = Command line arguments
* arch = Default value to use for architecture.
* Should be "32" or "64"
*
* Returns:
* "32", "64" or "32mscoff" if the "-m32", "-m64", "-m32mscoff" flags were passed,
* respectively. If they weren't, return `arch`.
*/
const(char)* parse_arch_arg(Strings* args, const(char)* arch)
{
foreach (const p; *args)
{
if (p[0] == '-')
{
if (strcmp(p + 1, "m32") == 0 || strcmp(p + 1, "m32mscoff") == 0 || strcmp(p + 1, "m64") == 0)
arch = p + 2;
else if (strcmp(p + 1, "run") == 0)
break;
}
}
return arch;
}
/**
* Parse command line arguments for the last instance of -conf=path.
*
* Params:
* args = Command line arguments
*
* Returns:
* The 'path' in -conf=path, which is the path to the config file to use
*/
const(char)* parse_conf_arg(Strings* args)
{
const(char)* conf = null;
foreach (const p; *args)
{
if (p[0] == '-')
{
if (strncmp(p + 1, "conf=", 5) == 0)
conf = p + 6;
else if (strcmp(p + 1, "run") == 0)
break;
}
}
return conf;
}
/**
* Set the default and debug libraries to link against, if not already set
*
* Must be called after argument parsing is done, as it won't
* override any value.
* Note that if `-defaultlib=` or `-debuglib=` was used,
* we don't override that either.
*/
private void setDefaultLibrary()
{
if (global.params.defaultlibname is null)
{
static if (TARGET.Windows)
{
if (global.params.is64bit)
global.params.defaultlibname = "phobos64";
else if (global.params.mscoff)
global.params.defaultlibname = "phobos32mscoff";
else
global.params.defaultlibname = "phobos";
}
else static if (TARGET.Linux || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris || TARGET.DragonFlyBSD)
{
global.params.defaultlibname = "libphobos2.a";
}
else static if (TARGET.OSX)
{
global.params.defaultlibname = "phobos2";
}
else
{
static assert(0, "fix this");
}
}
else if (!global.params.defaultlibname[0]) // if `-defaultlib=` (i.e. an empty defaultlib)
global.params.defaultlibname = null;
if (global.params.debuglibname is null)
global.params.debuglibname = global.params.defaultlibname;
}
/*************************************
* Set the `is` target fields of `params` according
* to the TARGET value.
* Params:
* params = where the `is` fields are
*/
void setTarget(ref Param params)
{
static if (TARGET.Windows)
params.isWindows = true;
else static if (TARGET.Linux)
params.isLinux = true;
else static if (TARGET.OSX)
params.isOSX = true;
else static if (TARGET.FreeBSD)
params.isFreeBSD = true;
else static if (TARGET.OpenBSD)
params.isOpenBSD = true;
else static if (TARGET.Solaris)
params.isSolaris = true;
else static if (TARGET.DragonFlyBSD)
params.isDragonFlyBSD = true;
else
static assert(0, "unknown TARGET");
}
/**
* Add default `version` identifier for dmd, and set the
* target platform in `params`.
* https://dlang.org/spec/version.html#predefined-versions
*
* Needs to be run after all arguments parsing (command line, DFLAGS environment
* variable and config file) in order to add final flags (such as `X86_64` or
* the `CRuntime` used).
*
* Params:
* params = which target to compile for (set by `setTarget()`)
*/
void addDefaultVersionIdentifiers(const ref Param params)
{
VersionCondition.addPredefinedGlobalIdent("DigitalMars");
if (params.isWindows)
{
VersionCondition.addPredefinedGlobalIdent("Windows");
if (global.params.mscoff)
{
VersionCondition.addPredefinedGlobalIdent("CRuntime_Microsoft");
VersionCondition.addPredefinedGlobalIdent("CppRuntime_Microsoft");
}
else
{
VersionCondition.addPredefinedGlobalIdent("CRuntime_DigitalMars");
VersionCondition.addPredefinedGlobalIdent("CppRuntime_DigitalMars");
}
}
else if (params.isLinux)
{
VersionCondition.addPredefinedGlobalIdent("Posix");
VersionCondition.addPredefinedGlobalIdent("linux");
VersionCondition.addPredefinedGlobalIdent("ELFv1");
VersionCondition.addPredefinedGlobalIdent("CRuntime_Glibc");
VersionCondition.addPredefinedGlobalIdent("CppRuntime_Gcc");
}
else if (params.isOSX)
{
VersionCondition.addPredefinedGlobalIdent("Posix");
VersionCondition.addPredefinedGlobalIdent("OSX");
VersionCondition.addPredefinedGlobalIdent("CppRuntime_Clang");
// For legacy compatibility
VersionCondition.addPredefinedGlobalIdent("darwin");
}
else if (params.isFreeBSD)
{
VersionCondition.addPredefinedGlobalIdent("Posix");
VersionCondition.addPredefinedGlobalIdent("FreeBSD");
VersionCondition.addPredefinedGlobalIdent("ELFv1");
VersionCondition.addPredefinedGlobalIdent("CppRuntime_Clang");
}
else if (params.isOpenBSD)
{
VersionCondition.addPredefinedGlobalIdent("Posix");
VersionCondition.addPredefinedGlobalIdent("OpenBSD");
VersionCondition.addPredefinedGlobalIdent("ELFv1");
VersionCondition.addPredefinedGlobalIdent("CppRuntime_Gcc");
}
else if (params.isDragonFlyBSD)
{
VersionCondition.addPredefinedGlobalIdent("Posix");
VersionCondition.addPredefinedGlobalIdent("DragonFlyBSD");
VersionCondition.addPredefinedGlobalIdent("ELFv1");
VersionCondition.addPredefinedGlobalIdent("CppRuntime_Gcc");
}
else if (params.isSolaris)
{
VersionCondition.addPredefinedGlobalIdent("Posix");
VersionCondition.addPredefinedGlobalIdent("Solaris");
VersionCondition.addPredefinedGlobalIdent("ELFv1");
VersionCondition.addPredefinedGlobalIdent("CppRuntime_Sun");
}
else
{
assert(0);
}
VersionCondition.addPredefinedGlobalIdent("LittleEndian");
VersionCondition.addPredefinedGlobalIdent("D_Version2");
VersionCondition.addPredefinedGlobalIdent("all");
if (params.cpu >= CPU.sse2)
{
VersionCondition.addPredefinedGlobalIdent("D_SIMD");
if (params.cpu >= CPU.avx)
VersionCondition.addPredefinedGlobalIdent("D_AVX");
if (params.cpu >= CPU.avx2)
VersionCondition.addPredefinedGlobalIdent("D_AVX2");
}
if (params.is64bit)
{
VersionCondition.addPredefinedGlobalIdent("D_InlineAsm_X86_64");
VersionCondition.addPredefinedGlobalIdent("X86_64");
if (params.isWindows)
{
VersionCondition.addPredefinedGlobalIdent("Win64");
}
}
else
{
VersionCondition.addPredefinedGlobalIdent("D_InlineAsm"); //legacy
VersionCondition.addPredefinedGlobalIdent("D_InlineAsm_X86");
VersionCondition.addPredefinedGlobalIdent("X86");
if (params.isWindows)
{
VersionCondition.addPredefinedGlobalIdent("Win32");
}
}
if (params.isLP64)
VersionCondition.addPredefinedGlobalIdent("D_LP64");
if (params.doDocComments)
VersionCondition.addPredefinedGlobalIdent("D_Ddoc");
if (params.cov)
VersionCondition.addPredefinedGlobalIdent("D_Coverage");
if (params.pic)
VersionCondition.addPredefinedGlobalIdent("D_PIC");
if (params.useUnitTests)
VersionCondition.addPredefinedGlobalIdent("unittest");
if (params.useAssert == CHECKENABLE.on)
VersionCondition.addPredefinedGlobalIdent("assert");
if (params.useArrayBounds == CHECKENABLE.off)
VersionCondition.addPredefinedGlobalIdent("D_NoBoundsChecks");
if (params.betterC)
{
VersionCondition.addPredefinedGlobalIdent("D_BetterC");
}
else
{
VersionCondition.addPredefinedGlobalIdent("D_ModuleInfo");
VersionCondition.addPredefinedGlobalIdent("D_Exceptions");
VersionCondition.addPredefinedGlobalIdent("D_TypeInfo");
}
VersionCondition.addPredefinedGlobalIdent("D_HardFloat");
}
private void printPredefinedVersions(FILE* stream)
{
if (global.versionids)
{
OutBuffer buf;
foreach (const str; *global.versionids)
{
buf.writeByte(' ');
buf.writestring(str.toChars());
}
stream.fprintf("predefs %s\n", buf.peekString());
}
}
extern(C) void printGlobalConfigs(FILE* stream)
{
stream.fprintf("binary %.*s\n", cast(int)global.params.argv0.length, global.params.argv0.ptr);
stream.fprintf("version %s\n", global._version);
stream.fprintf("config %s\n", global.inifilename ? global.inifilename : "(none)");
// Print DFLAGS environment variable
{
StringTable environment;
environment._init(0);
Strings dflags;
getenv_setargv(readFromEnv(&environment, "DFLAGS"), &dflags);
environment.reset(1);
OutBuffer buf;
foreach (flag; dflags[])
{
bool needsQuoting;
foreach (c; flag[0 .. strlen(flag)])
{
if (!(isalnum(c) || c == '_'))
{
needsQuoting = true;
break;
}
}
if (flag.strchr(' '))
buf.printf("'%s' ", flag);
else
buf.printf("%s ", flag);
}
auto res = buf.peekSlice() ? buf.peekSlice()[0 .. $ - 1] : "(none)";
stream.fprintf("DFLAGS %.*s\n", cast(int)res.length, res.ptr);
}
}
/****************************************
* Determine the instruction set to be used, i.e. set params.cpu
* by combining the command line setting of
* params.cpu with the target operating system.
* Params:
* params = parameters set by command line switch
*/
private void setTargetCPU(ref Param params)
{
if (params.is64bit || params.isOSX)
{
switch (params.cpu)
{
case CPU.baseline:
params.cpu = CPU.sse2;
break;
case CPU.native:
{
import core.cpuid;
params.cpu = core.cpuid.avx2 ? CPU.avx2 :
core.cpuid.avx ? CPU.avx :
CPU.sse2;
break;
}
default:
break;
}
}
else
params.cpu = CPU.x87; // cannot support other instruction sets
}
/**************************************
* we want to write the mixin expansion file also on error, but there
* are too many ways to terminate dmd (e.g. fatal() which calls exit(EXIT_FAILURE)),
* so we cant use scope(exit) ...
* so we do it with atexit(&flushMixins);
*/
extern(C) void flushMixins()
{
if (!global.params.mixinOut)
return;
assert(global.params.mixinFile);
auto f = File(global.params.mixinFile);
OutBuffer* ob = global.params.mixinOut;
f.setbuffer(cast(void*)ob.data, ob.offset);
f.write();
}
/****************************************************
* Parse command line arguments.
*
* Prints message(s) if there are errors.
*
* Params:
* arguments = command line arguments
* argc = argument count
* params = set to result of parsing `arguments`
* files = set to files pulled from `arguments`
* Returns:
* true if errors in command line
*/
bool parseCommandLine(const ref Strings arguments, const size_t argc, ref Param params, ref Strings files)
{
bool errors;
void error(const(char)* format, const(char*) arg = null)
{
dmd.errors.error(Loc.initial, format, arg);
errors = true;
}
/************************************
* Convert string to integer.
* Params:
* p = pointer to start of string digits, ending with 0
* max = max allowable value (inclusive)
* Returns:
* uint.max on error, otherwise converted integer
*/
static pure uint parseDigits(const(char)*p, const uint max)
{
uint value;
bool overflow;
for (uint d; (d = uint(*p) - uint('0')) < 10; ++p)
{
import core.checkedint : mulu, addu;
value = mulu(value, 10, overflow);
value = addu(value, d, overflow);
}
return (overflow || value > max || *p) ? uint.max : value;
}
/********************************
* Params:
* p = 0 terminated string
* s = string
* Returns:
* true if `p` starts with `s`
*/
static pure bool startsWith(const(char)* p, string s)
{
foreach (const c; s)
{
if (c != *p)
return false;
++p;
}
return true;
}
/**
* Print an error messsage about an invalid switch.
* If an optional supplemental message has been provided,
* it will be printed too.
*
* Params:
* p = 0 terminated string
* availableOptions = supplemental help message listing the available options
*/
void errorInvalidSwitch(const(char)* p, string availableOptions = null)
{
error("Switch `%s` is invalid", p);
if (availableOptions !is null)
errorSupplemental(Loc.initial, "%.*s", cast(int)availableOptions.length, availableOptions.ptr);
}
enum CheckOptions { success, error, help }
/*
Checks whether the CLI options contains a valid argument or a help argument.
If a help argument has been used, it will set the `usageFlag`.
Params:
p = 0 terminated string
usageFlag = parameter for the usage help page to set (by `ref`)
missingMsg = error message to use when no argument has been provided
Returns:
`success` if a valid argument has been passed and it's not a help page
`error` if an error occurred (e.g. `-foobar`)
`help` if a help page has been request (e.g. `-flag` or `-flag=h`)
*/
CheckOptions checkOptions(const(char)* p, ref bool usageFlag, string missingMsg)
{
// Checks whether a flag has no options (e.g. -foo or -foo=)
if (*p == 0 || *p == '=' && !p[1])
{
.error(Loc.initial, "%.*s", cast(int)missingMsg.length, missingMsg.ptr);
errors = true;
usageFlag = true;
return CheckOptions.help;
}
if (*p != '=')
return CheckOptions.error;
p++;
/* Checks whether the option pointer supplied is a request
for the help page, e.g. -foo=j */
if (((*p == 'h' || *p == '?') && !p[1]) || // -flag=h || -flag=?
strcmp(p, "help") == 0)
{
usageFlag = true;
return CheckOptions.help;
}
return CheckOptions.success;
}
static string checkOptionsMixin(string usageFlag, string missingMsg)
{
return q{
final switch (checkOptions(p + len - 1, params.}~usageFlag~","~
`"`~missingMsg~`"`~q{))
{
case CheckOptions.error:
goto Lerror;
case CheckOptions.help:
return false;
case CheckOptions.success:
break;
}
};
}
import dmd.cli : Usage;
bool parseCLIOption(string name, Usage.Feature[] features)(ref Param params, const(char)* p)
{
// Parse:
// -<name>=<feature>
const ps = p + name.length + 1;
if (Identifier.isValidIdentifier(ps + 1))
{
string generateTransitionsText()
{
import dmd.cli : Usage;
string buf = `case "all":`;
foreach (t; features)
buf ~= `params.`~t.paramName~` = true;`;
buf ~= "break;";
foreach (t; features)
{
buf ~= `case "`~t.name~`": params.`~t.paramName~` = true; return true;`;
}
return buf;
}
const ident = ps + 1;
switch (ident[0 .. strlen(ident)])
{
mixin(generateTransitionsText());
default:
return false;
}
}
return false;
}
version (none)
{
for (size_t i = 0; i < arguments.dim; i++)
{
printf("arguments[%d] = '%s'\n", i, arguments[i]);
}
}
for (size_t i = 1; i < arguments.dim; i++)
{
const(char)* p = arguments[i];
const(char)[] arg = p[0 .. strlen(p)];
if (*p != '-')
{
static if (TARGET.Windows)
{
const ext = FileName.ext(p);
if (ext && FileName.equals(ext, "exe"))
{
params.objname = p;
continue;
}
if (arg == "/?")
{
params.usage = true;
return false;
}
}
files.push(p);
continue;
}
if (arg == "-allinst") // https://dlang.org/dmd.html#switch-allinst
params.allInst = true;
else if (arg == "-de") // https://dlang.org/dmd.html#switch-de
params.useDeprecated = Diagnostic.error;
else if (arg == "-d") // https://dlang.org/dmd.html#switch-d
params.useDeprecated = Diagnostic.off;
else if (arg == "-dw") // https://dlang.org/dmd.html#switch-dw
params.useDeprecated = Diagnostic.inform;
else if (arg == "-c") // https://dlang.org/dmd.html#switch-c
params.link = false;
else if (startsWith(p + 1, "checkaction")) // https://dlang.org/dmd.html#switch-checkaction
{
/* Parse:
* -checkaction=D|C|halt|context
*/
enum len = "-checkaction=".length;
mixin(checkOptionsMixin("checkActionUsage",
"`-check=<behavior>` requires a behavior"));
if (strcmp(p + len, "D") == 0)
params.checkAction = CHECKACTION.D;
else if (strcmp(p + len, "C") == 0)
params.checkAction = CHECKACTION.C;
else if (strcmp(p + len, "halt") == 0)
params.checkAction = CHECKACTION.halt;
else if (strcmp(p + len, "context") == 0)
params.checkAction = CHECKACTION.context;
else
{
errorInvalidSwitch(p);
params.checkActionUsage = true;
return false;
}
}
else if (startsWith(p + 1, "check")) // https://dlang.org/dmd.html#switch-check
{
enum len = "-check=".length;
mixin(checkOptionsMixin("checkUsage",
"`-check=<action>` requires an action"));
/* Parse:
* -check=[assert|bounds|in|invariant|out|switch][=[on|off]]
*/
// Check for legal option string; return true if so
static bool check(const(char)* p, string name, ref CHECKENABLE ce)
{
p += len;
if (startsWith(p, name))
{
p += name.length;
if (*p == 0 ||
strcmp(p, "=on") == 0)
{
ce = CHECKENABLE.on;
return true;
}
else if (strcmp(p, "=off") == 0)
{
ce = CHECKENABLE.off;
return true;
}
}
return false;
}
if (!(check(p, "assert", params.useAssert ) ||
check(p, "bounds", params.useArrayBounds) ||
check(p, "in", params.useIn ) ||
check(p, "invariant", params.useInvariants ) ||
check(p, "out", params.useOut ) ||
check(p, "switch", params.useSwitchError)))
{
errorInvalidSwitch(p);
params.checkUsage = true;
return false;
}
}
else if (startsWith(p + 1, "color")) // https://dlang.org/dmd.html#switch-color
{
// Parse:
// -color
// -color=auto|on|off
if (p[6] == '=')
{
if (strcmp(p + 7, "on") == 0)
params.color = true;
else if (strcmp(p + 7, "off") == 0)
params.color = false;
else if (strcmp(p + 7, "auto") != 0)
{
errorInvalidSwitch(p, "Available options for `-color` are `on`, `off` and `auto`");
return true;
}
}
else if (p[6])
goto Lerror;
else
params.color = true;
}
else if (startsWith(p + 1, "conf=")) // https://dlang.org/dmd.html#switch-conf
{
// ignore, already handled above
}
else if (startsWith(p + 1, "cov")) // https://dlang.org/dmd.html#switch-cov
{
params.cov = true;
// Parse:
// -cov
// -cov=nnn
if (p[4] == '=')
{
if (isdigit(cast(char)p[5]))
{
const percent = parseDigits(p + 5, 100);
if (percent == uint.max)
goto Lerror;
params.covPercent = cast(ubyte)percent;
}
else
{
errorInvalidSwitch(p, "Only a number can be passed to `-cov=<num>`");
return true;
}
}
else if (p[4])
goto Lerror;
}
else if (arg == "-shared")
params.dll = true;
else if (arg == "-fPIC")
{
static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris || TARGET.DragonFlyBSD)
{
params.pic = 1;
}
else
{
goto Lerror;
}
}
else if (arg == "-map") // https://dlang.org/dmd.html#switch-map
params.map = true;
else if (arg == "-multiobj")
params.multiobj = true;
else if (startsWith(p + 1, "mixin="))
{
auto tmp = p + 6 + 1;
if (!tmp[0])
goto Lnoarg;
// The following are usedin atexit, so we can't rely on main's argv...
params.mixinFile = mem.xstrdup(tmp);
// ... or the GC's memory being valid.
params.mixinOut = cast(OutBuffer*)calloc(1, OutBuffer.sizeof);
atexit(&flushMixins);
}
else if (arg == "-g") // https://dlang.org/dmd.html#switch-g
params.symdebug = 1;
else if (arg == "-gf")
{
if (!params.symdebug)
params.symdebug = 1;
params.symdebugref = true;
}
else if (arg == "-gs") // https://dlang.org/dmd.html#switch-gs
params.alwaysframe = true;
else if (arg == "-gx") // https://dlang.org/dmd.html#switch-gx
params.stackstomp = true;
else if (arg == "-m32") // https://dlang.org/dmd.html#switch-m32
{
static if (TARGET.DragonFlyBSD) {
error("-m32 is not supported on DragonFlyBSD, it is 64-bit only");
} else {
params.is64bit = false;
params.mscoff = false;
}
}
else if (arg == "-m64") // https://dlang.org/dmd.html#switch-m64
{
params.is64bit = true;
static if (TARGET.Windows)
{
params.mscoff = true;
}
}
else if (arg == "-m32mscoff") // https://dlang.org/dmd.html#switch-m32mscoff
{
static if (TARGET.Windows)
{
params.is64bit = 0;
params.mscoff = true;
}
else
{
error("-m32mscoff can only be used on windows");
}
}
else if (strncmp(p + 1, "mscrtlib=", 9) == 0)
{
static if (TARGET.Windows)
{
params.mscrtlib = p + 10;
}
else
{
error("-mscrtlib");
}
}
else if (startsWith(p + 1, "profile")) // https://dlang.org/dmd.html#switch-profile
{
// Parse:
// -profile
// -profile=gc
if (p[8] == '=')
{
if (strcmp(p + 9, "gc") == 0)
params.tracegc = true;
else
{
errorInvalidSwitch(p, "Only `gc` is allowed for `-profile`");
return true;
}
}
else if (p[8])
goto Lerror;
else
params.trace = true;
}
else if (arg == "-v") // https://dlang.org/dmd.html#switch-v
params.verbose = true;
else if (arg == "-vcg-ast")
params.vcg_ast = true;
else if (arg == "-vtls") // https://dlang.org/dmd.html#switch-vtls
params.vtls = true;
else if (arg == "-vcolumns") // https://dlang.org/dmd.html#switch-vcolumns
params.showColumns = true;
else if (arg == "-vgc") // https://dlang.org/dmd.html#switch-vgc
params.vgc = true;
else if (startsWith(p + 1, "verrors")) // https://dlang.org/dmd.html#switch-verrors
{
if (p[8] == '=' && isdigit(cast(char)p[9]))
{
const num = parseDigits(p + 9, int.max);
if (num == uint.max)
goto Lerror;
params.errorLimit = num;
}
else if (startsWith(p + 9, "spec"))
{
params.showGaggedErrors = true;
}
else if (startsWith(p + 9, "context"))
{
params.printErrorContext = true;
}
else
{
errorInvalidSwitch(p, "Only number, `spec`, or `context` are allowed for `-verrors`");
return true;
}
}
else if (startsWith(p + 1, "mcpu")) // https://dlang.org/dmd.html#switch-mcpu
{
enum len = "-mcpu=".length;
// Parse:
// -mcpu=identifier
mixin(checkOptionsMixin("mcpuUsage",
"`-mcpu=<architecture>` requires an architecture"));
if (Identifier.isValidIdentifier(p + len))
{
const ident = p + len;
switch (ident[0 .. strlen(ident)])
{
case "baseline":
params.cpu = CPU.baseline;
break;
case "avx":
params.cpu = CPU.avx;
break;
case "avx2":
params.cpu = CPU.avx2;
break;
case "native":
params.cpu = CPU.native;
break;
default:
errorInvalidSwitch(p, "Only `baseline`, `avx`, `avx2` or `native` are allowed for `-mcpu`");
params.mcpuUsage = true;
return false;
}
}
else
{
errorInvalidSwitch(p, "Only `baseline`, `avx`, `avx2` or `native` are allowed for `-mcpu`");
params.mcpuUsage = true;
return false;
}
}
else if (startsWith(p + 1, "extern-std")) // https://dlang.org/dmd.html#switch-extern-std
{
enum len = "-extern-std=".length;
// Parse:
// -extern-std=identifier
mixin(checkOptionsMixin("externStdUsage",
"`-extern-std=<standard>` requires a standard"));
if (strcmp(p + len, "c++98") == 0)
params.cplusplus = CppStdRevision.cpp98;
else if (strcmp(p + len, "c++11") == 0)
params.cplusplus = CppStdRevision.cpp11;
else if (strcmp(p + len, "c++14") == 0)
params.cplusplus = CppStdRevision.cpp14;
else if (strcmp(p + len, "c++17") == 0)
params.cplusplus = CppStdRevision.cpp17;
else
{
error("Switch `%s` is invalid", p);
params.externStdUsage = true;
return false;
}
}
else if (startsWith(p + 1, "transition")) // https://dlang.org/dmd.html#switch-transition
{
enum len = "-transition=".length;
// Parse:
// -transition=number
mixin(checkOptionsMixin("transitionUsage",
"`-transition=<name>` requires a name"));
if (!parseCLIOption!("transition", Usage.transitions)(params, p))
{
// Legacy -transition flags
// Before DMD 2.085, DMD `-transition` was used for all language flags
// These are kept for backwards compatibility, but no longer documented
if (isdigit(cast(char)p[len]))
{
const num = parseDigits(p + len, int.max);
if (num == uint.max)
goto Lerror;
// Bugzilla issue number
switch (num)
{
case 3449:
params.vfield = true;
break;
case 10378:
params.bug10378 = true;
break;
case 14246:
params.dtorFields = true;
break;
case 14488:
params.vcomplex = true;
break;
case 16997:
params.fix16997 = true;
break;
default:
error("Transition `%s` is invalid", p);
params.transitionUsage = true;
return false;
}
}
else if (Identifier.isValidIdentifier(p + len))
{
const ident = p + len;
switch (ident[0 .. strlen(ident)])
{
case "import":
params.bug10378 = true;
break;
case "dtorfields":
params.dtorFields = true;
break;
case "intpromote":
params.fix16997 = true;
break;
case "markdown":
params.markdown = true;
break;
default:
error("Transition `%s` is invalid", p);
params.transitionUsage = true;
return false;
}
}
errorInvalidSwitch(p);
params.transitionUsage = true;
return false;
}
}
else if (startsWith(p + 1, "preview") ) // https://dlang.org/dmd.html#switch-preview
{
enum len = "-preview=".length;
// Parse:
// -preview=name
mixin(checkOptionsMixin("previewUsage",
"`-preview=<name>` requires a name"));
if (!parseCLIOption!("preview", Usage.previews)(params, p))
{
error("Preview `%s` is invalid", p);
params.previewUsage = true;
return false;
}
// copy previously standalone flags from -transition
// -preview=dip1000 implies -preview=dip25 too
if (params.vsafe)
params.useDIP25 = true;
}
else if (startsWith(p + 1, "revert") ) // https://dlang.org/dmd.html#switch-revert
{
enum len = "-revert=".length;
// Parse:
// -revert=name
mixin(checkOptionsMixin("revertUsage",
"`-revert=<name>` requires a name"));
if (!parseCLIOption!("revert", Usage.reverts)(params, p))
{
error("Revert `%s` is invalid", p);
params.revertUsage = true;
return false;
}
if (params.noDIP25)
params.useDIP25 = false;
}
else if (arg == "-w") // https://dlang.org/dmd.html#switch-w
params.warnings = Diagnostic.error;
else if (arg == "-wi") // https://dlang.org/dmd.html#switch-wi
params.warnings = Diagnostic.inform;
else if (arg == "-O") // https://dlang.org/dmd.html#switch-O
params.optimize = true;
else if (p[1] == 'o')
{
const(char)* path;
switch (p[2])
{
case '-': // https://dlang.org/dmd.html#switch-o-
params.obj = false;
break;
case 'd': // https://dlang.org/dmd.html#switch-od
if (!p[3])
goto Lnoarg;
path = p + 3 + (p[3] == '=');
version (Windows)
{
path = toWinPath(path);
}
params.objdir = path;
break;
case 'f': // https://dlang.org/dmd.html#switch-of
if (!p[3])
goto Lnoarg;
path = p + 3 + (p[3] == '=');
version (Windows)
{
path = toWinPath(path);
}
params.objname = path;
break;
case 'p': // https://dlang.org/dmd.html#switch-op
if (p[3])
goto Lerror;
params.preservePaths = true;
break;
case 0:
error("-o no longer supported, use -of or -od");
break;
default:
goto Lerror;
}
}
else if (p[1] == 'D') // https://dlang.org/dmd.html#switch-D
{
params.doDocComments = true;
switch (p[2])
{
case 'd': // https://dlang.org/dmd.html#switch-Dd
if (!p[3])
goto Lnoarg;
params.docdir = p + 3 + (p[3] == '=');
break;
case 'f': // https://dlang.org/dmd.html#switch-Df
if (!p[3])
goto Lnoarg;
params.docname = p + 3 + (p[3] == '=');
break;
case 0:
break;
default:
goto Lerror;
}
}
else if (p[1] == 'H') // https://dlang.org/dmd.html#switch-H
{
params.doHdrGeneration = true;
switch (p[2])
{
case 'd': // https://dlang.org/dmd.html#switch-Hd
if (!p[3])
goto Lnoarg;
params.hdrdir = p + 3 + (p[3] == '=');
break;
case 'f': // https://dlang.org/dmd.html#switch-Hf
if (!p[3])
goto Lnoarg;
params.hdrname = p + 3 + (p[3] == '=');
break;
case 0:
break;
default:
goto Lerror;
}
}
else if (p[1] == 'X') // https://dlang.org/dmd.html#switch-X
{
params.doJsonGeneration = true;
switch (p[2])
{
case 'f': // https://dlang.org/dmd.html#switch-Xf
if (!p[3])
goto Lnoarg;
params.jsonfilename = p + 3 + (p[3] == '=');
break;
case 'i':
if (!p[3])
goto Lnoarg;
if (p[3] != '=')
goto Lerror;
if (!p[4])
goto Lnoarg;
{
auto flag = tryParseJsonField(p + 4);
if (!flag)
{
error("unknown JSON field `-Xi=%s`, expected one of " ~ jsonFieldNames, p + 4);
continue;
}
global.params.jsonFieldFlags |= flag;
}
break;
case 0:
break;
default:
goto Lerror;
}
}
else if (arg == "-ignore") // https://dlang.org/dmd.html#switch-ignore
params.ignoreUnsupportedPragmas = true;
else if (arg == "-inline") // https://dlang.org/dmd.html#switch-inline
{
params.useInline = true;
params.hdrStripPlainFunctions = false;
}
else if (arg == "-i")
includeImports = true;
else if (startsWith(p + 1, "i="))
{
includeImports = true;
if (!p[3])
{
error("invalid option '%s', module patterns cannot be empty", p);
}
else
{
// NOTE: we could check that the argument only contains valid "module-pattern" characters.
// Invalid characters doesn't break anything but an error message to the user might
// be nice.
includeModulePatterns.push(p + 3);
}
}
else if (arg == "-dip25") // https://dlang.org/dmd.html#switch-dip25
params.useDIP25 = true;
else if (arg == "-dip1000")
{
params.useDIP25 = true;
params.vsafe = true;
}
else if (arg == "-dip1008")
{
params.ehnogc = true;
}
else if (arg == "-lib") // https://dlang.org/dmd.html#switch-lib
params.lib = true;
else if (arg == "-nofloat")
params.nofloat = true;
else if (arg == "-quiet")
{
// Ignore
}
else if (arg == "-release") // https://dlang.org/dmd.html#switch-release
params.release = true;
else if (arg == "-betterC") // https://dlang.org/dmd.html#switch-betterC
params.betterC = true;
else if (arg == "-noboundscheck") // https://dlang.org/dmd.html#switch-noboundscheck
{
params.boundscheck = CHECKENABLE.off;
}
else if (startsWith(p + 1, "boundscheck")) // https://dlang.org/dmd.html#switch-boundscheck
{
// Parse:
// -boundscheck=[on|safeonly|off]
if (p[12] == '=')
{
if (strcmp(p + 13, "on") == 0)
{
params.boundscheck = CHECKENABLE.on;
}
else if (strcmp(p + 13, "safeonly") == 0)
{
params.boundscheck = CHECKENABLE.safeonly;
}
else if (strcmp(p + 13, "off") == 0)
{
params.boundscheck = CHECKENABLE.off;
}
else
goto Lerror;
}
else
goto Lerror;
}
else if (arg == "-unittest")
params.useUnitTests = true;
else if (p[1] == 'I') // https://dlang.org/dmd.html#switch-I
{
if (!params.imppath)
params.imppath = new Strings();
params.imppath.push(p + 2 + (p[2] == '='));
}
else if (p[1] == 'm' && p[2] == 'v' && p[3] == '=') // https://dlang.org/dmd.html#switch-mv
{
if (p[4] && strchr(p + 5, '='))
{
if (!params.modFileAliasStrings)
params.modFileAliasStrings = new Strings();
params.modFileAliasStrings.push(p + 4);
}
else
goto Lerror;
}
else if (p[1] == 'J') // https://dlang.org/dmd.html#switch-J
{
if (!params.fileImppath)
params.fileImppath = new Strings();
params.fileImppath.push(p + 2 + (p[2] == '='));
}
else if (startsWith(p + 1, "debug") && p[6] != 'l') // https://dlang.org/dmd.html#switch-debug
{
// Parse:
// -debug
// -debug=number
// -debug=identifier
if (p[6] == '=')
{
if (isdigit(cast(char)p[7]))
{
const level = parseDigits(p + 7, int.max);
if (level == uint.max)
goto Lerror;
params.debuglevel = level;
}
else if (Identifier.isValidIdentifier(p + 7))
{
if (!params.debugids)
params.debugids = new Array!(const(char)*);
params.debugids.push(p + 7);
}
else
goto Lerror;
}
else if (p[6])
goto Lerror;
else
params.debuglevel = 1;
}
else if (startsWith(p + 1, "version")) // https://dlang.org/dmd.html#switch-version
{
// Parse:
// -version=number
// -version=identifier
if (p[8] == '=')
{
if (isdigit(cast(char)p[9]))
{
const level = parseDigits(p + 9, int.max);
if (level == uint.max)
goto Lerror;
params.versionlevel = level;
}
else if (Identifier.isValidIdentifier(p + 9))
{
if (!params.versionids)
params.versionids = new Array!(const(char)*);
params.versionids.push(p + 9);
}
else
goto Lerror;
}
else
goto Lerror;
}
else if (arg == "--b")
params.debugb = true;
else if (arg == "--c")
params.debugc = true;
else if (arg == "--f")
params.debugf = true;
else if (arg == "--help" ||
arg == "-h")
{
params.usage = true;
return false;
}
else if (arg == "--r")
params.debugr = true;
else if (arg == "--version")
{
params.logo = true;
return false;
}
else if (arg == "--x")
params.debugx = true;
else if (arg == "--y")
params.debugy = true;
else if (p[1] == 'L') // https://dlang.org/dmd.html#switch-L
{
params.linkswitches.push(p + 2 + (p[2] == '='));
}
else if (startsWith(p + 1, "defaultlib=")) // https://dlang.org/dmd.html#switch-defaultlib
{
params.defaultlibname = p + 1 + 11;
}
else if (startsWith(p + 1, "debuglib=")) // https://dlang.org/dmd.html#switch-debuglib
{
params.debuglibname = p + 1 + 9;
}
else if (startsWith(p + 1, "deps")) // https://dlang.org/dmd.html#switch-deps
{
if (params.moduleDeps)
{
error("-deps[=file] can only be provided once!");
break;
}
if (p[5] == '=')
{
params.moduleDepsFile = p + 1 + 5;
if (!params.moduleDepsFile[0])
goto Lnoarg;
}
else if (p[5] != '\0')
{
// Else output to stdout.
goto Lerror;
}
params.moduleDeps = new OutBuffer();
}
else if (arg == "-main") // https://dlang.org/dmd.html#switch-main
{
params.addMain = true;
}
else if (startsWith(p + 1, "man")) // https://dlang.org/dmd.html#switch-man
{
params.manual = true;
return false;
}
else if (arg == "-run") // https://dlang.org/dmd.html#switch-run
{
params.run = true;
size_t length = argc - i - 1;
if (length)
{
const(char)* ext = FileName.ext(arguments[i + 1]);
if (ext && FileName.equals(ext, "d") == 0 && FileName.equals(ext, "di") == 0)
{
error("-run must be followed by a source file, not '%s'", arguments[i + 1]);
break;
}
if (strcmp(arguments[i + 1], "-") == 0)
files.push("__stdin.d");
else
files.push(arguments[i + 1]);
params.runargs.setDim(length - 1);
for (size_t j = 0; j < length - 1; ++j)
{
params.runargs[j] = arguments[i + 2 + j];
}
i += length;
}
else
{
params.run = false;
goto Lnoarg;
}
}
else if (p[1] == '\0')
files.push("__stdin.d");
else
{
Lerror:
error("unrecognized switch '%s'", arguments[i]);
continue;
Lnoarg:
error("argument expected for switch '%s'", arguments[i]);
continue;
}
}
return errors;
}
/***********************************************
* Adjust gathered command line switches and reconcile them.
* Params:
* params = switches gathered from command line,
* and update in place
* numSrcFiles = number of source files
*/
private void reconcileCommands(ref Param params, size_t numSrcFiles)
{
static if (TARGET.OSX)
{
params.pic = 1;
}
static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris || TARGET.DragonFlyBSD)
{
if (params.lib && params.dll)
error(Loc.initial, "cannot mix -lib and -shared");
}
static if (TARGET.Windows)
{
if (params.mscoff && !params.mscrtlib)
{
VSOptions vsopt;
vsopt.initialize();
params.mscrtlib = vsopt.defaultRuntimeLibrary(params.is64bit);
}
}
// Target uses 64bit pointers.
params.isLP64 = params.is64bit;
if (params.boundscheck != CHECKENABLE._default)
{
if (params.useArrayBounds == CHECKENABLE._default)
params.useArrayBounds = params.boundscheck;
}
if (params.useUnitTests)
{
if (params.useAssert == CHECKENABLE._default)
params.useAssert = CHECKENABLE.on;
}
if (params.release)
{
if (params.useInvariants == CHECKENABLE._default)
params.useInvariants = CHECKENABLE.off;
if (params.useIn == CHECKENABLE._default)
params.useIn = CHECKENABLE.off;
if (params.useOut == CHECKENABLE._default)
params.useOut = CHECKENABLE.off;
if (params.useArrayBounds == CHECKENABLE._default)
params.useArrayBounds = CHECKENABLE.safeonly;
if (params.useAssert == CHECKENABLE._default)
params.useAssert = CHECKENABLE.off;
if (params.useSwitchError == CHECKENABLE._default)
params.useSwitchError = CHECKENABLE.off;
}
else
{
if (params.useInvariants == CHECKENABLE._default)
params.useInvariants = CHECKENABLE.on;
if (params.useIn == CHECKENABLE._default)
params.useIn = CHECKENABLE.on;
if (params.useOut == CHECKENABLE._default)
params.useOut = CHECKENABLE.on;
if (params.useArrayBounds == CHECKENABLE._default)
params.useArrayBounds = CHECKENABLE.on;
if (params.useAssert == CHECKENABLE._default)
params.useAssert = CHECKENABLE.on;
if (params.useSwitchError == CHECKENABLE._default)
params.useSwitchError = CHECKENABLE.on;
}
if (params.betterC)
{
params.checkAction = CHECKACTION.C;
params.useModuleInfo = false;
params.useTypeInfo = false;
params.useExceptions = false;
}
if (!params.obj || params.lib)
params.link = false;
if (params.link)
{
params.exefile = params.objname;
params.oneobj = true;
if (params.objname)
{
/* Use this to name the one object file with the same
* name as the exe file.
*/
params.objname = cast(char*)FileName.forceExt(params.objname, global.obj_ext);
/* If output directory is given, use that path rather than
* the exe file path.
*/
if (params.objdir)
{
const(char)* name = FileName.name(params.objname);
params.objname = cast(char*)FileName.combine(params.objdir, name);
}
}
}
else if (params.run)
{
error(Loc.initial, "flags conflict with -run");
fatal();
}
else if (params.lib)
{
params.libname = params.objname;
params.objname = null;
// Haven't investigated handling these options with multiobj
if (!params.cov && !params.trace)
params.multiobj = true;
}
else
{
if (params.objname && numSrcFiles)
{
params.oneobj = true;
//error("multiple source files, but only one .obj name");
//fatal();
}
}
if (params.noDIP25)
params.useDIP25 = false;
}
/**
Creates the list of modules based on the files provided
Files are dispatched in the various arrays
(global.params.{ddocfiles,dllfiles,jsonfiles,etc...})
according to their extension.
Binary files are added to libmodules.
Params:
files = File names to dispatch
libmodules = Array to which binaries (shared/static libs and object files)
will be appended
Returns:
An array of path to D modules
*/
Modules createModules(ref Strings files, ref Strings libmodules)
{
Modules modules;
modules.reserve(files.dim);
bool firstmodule = true;
for (size_t i = 0; i < files.dim; i++)
{
const(char)* name;
version (Windows)
{
files[i] = toWinPath(files[i]);
}
const(char)* p = files[i];
p = FileName.name(p); // strip path
const(char)* ext = FileName.ext(p);
if (ext)
{
/* Deduce what to do with a file based on its extension
*/
if (FileName.equals(ext, global.obj_ext))
{
global.params.objfiles.push(files[i]);
libmodules.push(files[i]);
continue;
}
if (FileName.equals(ext, global.lib_ext))
{
global.params.libfiles.push(files[i]);
libmodules.push(files[i]);
continue;
}
static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris || TARGET.DragonFlyBSD)
{
if (FileName.equals(ext, global.dll_ext))
{
global.params.dllfiles.push(files[i]);
libmodules.push(files[i]);
continue;
}
}
if (strcmp(ext, global.ddoc_ext) == 0)
{
global.params.ddocfiles.push(files[i]);
continue;
}
if (FileName.equals(ext, global.json_ext))
{
global.params.doJsonGeneration = true;
global.params.jsonfilename = files[i];
continue;
}
if (FileName.equals(ext, global.map_ext))
{
global.params.mapfile = files[i];
continue;
}
static if (TARGET.Windows)
{
if (FileName.equals(ext, "res"))
{
global.params.resfile = files[i];
continue;
}
if (FileName.equals(ext, "def"))
{
global.params.deffile = files[i];
continue;
}
if (FileName.equals(ext, "exe"))
{
assert(0); // should have already been handled
}
}
/* Examine extension to see if it is a valid
* D source file extension
*/
if (FileName.equals(ext, global.mars_ext) || FileName.equals(ext, global.hdr_ext) || FileName.equals(ext, "dd"))
{
name = FileName.removeExt(p);
if (name[0] == 0 || strcmp(name, "..") == 0 || strcmp(name, ".") == 0)
{
Linvalid:
error(Loc.initial, "invalid file name '%s'", files[i]);
fatal();
}
}
else
{
error(Loc.initial, "unrecognized file extension %s", ext);
fatal();
}
}
else
{
name = p;
if (!*name)
goto Linvalid;
}
/* At this point, name is the D source file name stripped of
* its path and extension.
*/
auto id = Identifier.idPool(name, cast(uint)strlen(name));
auto m = new Module(files[i], id, global.params.doDocComments, global.params.doHdrGeneration);
modules.push(m);
if (firstmodule)
{
global.params.objfiles.push(m.objfile.name.toChars());
firstmodule = false;
}
}
return modules;
}
|
D
|
module app;
import vibe.core.core;
import vibe.core.log;
import vibe.http.auth.basic_auth;
import vibe.http.client;
import vibe.http.router;
import vibe.http.server;
import vibe.web.auth;
import vibe.web.web;
import std.algorithm : among;
import std.datetime;
import std.format : format;
shared static this()
{
auto settings = new HTTPServerSettings;
settings.port = 9128;
settings.bindAddresses = ["::1", "127.0.0.1"];
auto router = new URLRouter;
router.registerWebInterface(new Service);
listenHTTP(settings, router);
runTask({
scope (exit) exitEventLoop();
void test(string url, string user, HTTPStatus expected)
nothrow {
try {
requestHTTP("http://127.0.0.1:9128"~url, (scope req) {
if (user !is null) req.addBasicAuth(user, "secret");
}, (scope res) {
res.dropBody();
assert(res.statusCode == expected, format("Unexpected status code for GET %s (%s): %s", url, user, res.statusCode));
});
} catch (Exception e) {
assert(false, e.msg);
}
}
test("/public", null, HTTPStatus.ok);
test("/any", null, HTTPStatus.unauthorized);
test("/any", "stacy", HTTPStatus.ok);
test("/any_a", null, HTTPStatus.unauthorized);
test("/any_a", "stacy", HTTPStatus.ok);
test("/admin", null, HTTPStatus.unauthorized);
test("/admin", "admin", HTTPStatus.ok);
test("/admin", "peter", HTTPStatus.forbidden);
test("/admin", "stacy", HTTPStatus.forbidden);
test("/admin_a", null, HTTPStatus.unauthorized);
test("/admin_a", "admin", HTTPStatus.ok);
test("/admin_a", "peter", HTTPStatus.forbidden);
test("/admin_a", "stacy", HTTPStatus.forbidden);
test("/member", "admin", HTTPStatus.forbidden);
test("/member", "peter", HTTPStatus.ok);
test("/member", "stacy", HTTPStatus.forbidden);
test("/admin_member", "peter", HTTPStatus.ok);
test("/admin_member", "admin", HTTPStatus.ok);
test("/admin_member", "stacy", HTTPStatus.forbidden);
logInfo("All auth tests successful.");
});
}
struct Auth {
string username;
bool isAdmin() { return username == "admin"; }
bool isMember() { return username == "peter"; }
}
@requiresAuth
class Service {
@noAuth void getPublic(HTTPServerResponse res) { res.writeBody("success"); }
@anyAuth void getAny(HTTPServerResponse res) { res.writeBody("success"); }
@anyAuth void getAnyA(HTTPServerResponse res, Auth auth) { assert(auth.username.among("admin", "peter", "stacy")); res.writeBody("success"); }
@auth(Role.admin) void getAdmin(HTTPServerResponse res) { res.writeBody("success"); }
@auth(Role.admin) void getAdminA(HTTPServerResponse res, Auth auth) { assert(auth.username == "admin"); res.writeBody("success"); }
@auth(Role.member) void getMember(HTTPServerResponse res) { res.writeBody("success"); }
@auth(Role.admin | Role.member) void getAdminMember(HTTPServerResponse res) { res.writeBody("success"); }
@noRoute Auth authenticate(HTTPServerRequest req, HTTPServerResponse res)
{
Auth ret;
ret.username = performBasicAuth(req, res, "test", (user, pw) { return pw == "secret"; });
return ret;
}
}
|
D
|
func int B_GhostSpecialDamage(var C_Npc oth,var C_Npc slf)
{
var C_Npc Quarho;
var C_Npc Rhadem;
var C_Npc her;
Quarho = Hlp_GetNpc(NONE_ADDON_111_Quarhodron);
Rhadem = Hlp_GetNpc(NONE_ADDON_112_Rhademes);
her = Hlp_GetNpc(PC_Hero);
if((Hlp_GetInstanceID(self) == Hlp_GetInstanceID(Quarho)) || (Hlp_GetInstanceID(self) == Hlp_GetInstanceID(Rhadem)))
{
Wld_PlayEffect("spellFX_BELIARSRAGE",oth,oth,0,0,0,FALSE);
if(oth.flags != NPC_FLAG_IMMORTAL)
{
if(Hlp_GetInstanceID(oth) != Hlp_GetInstanceID(her))
{
Npc_ChangeAttribute(oth,ATR_HITPOINTS,-oth.attribute[ATR_HITPOINTS_MAX]);
}
else
{
GhostAttackWarn = GhostAttackWarn + 1;
if(GhostAttackWarn < 3)
{
oth.attribute[ATR_HITPOINTS] = oth.attribute[ATR_HITPOINTS] / 2;
}
else if(Hlp_GetInstanceID(oth) == Hlp_GetInstanceID(her))
{
oth.attribute[ATR_HITPOINTS] = 0;
AI_PlayAni(oth,"T_DEAD");
};
};
};
};
return FALSE;
};
|
D
|
/Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/Routing.build/RouteBuilder+RouteCollection.swift.o : /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/Branch.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/ParametersContainer.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/RouteBuilder+RouteCollection.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/RouteBuilder+RouteGroup.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/RouteBuilder.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/RouteCollection.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/RouteGroup+RouteBuilder.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/RouteGroup.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/Router+Routes.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/Router.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/Core.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/libc.swiftmodule /Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/Node.swiftmodule /Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/PathIndexable.swiftmodule /Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/Polymorphic.swiftmodule
/Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/Routing.build/RouteBuilder+RouteCollection~partial.swiftmodule : /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/Branch.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/ParametersContainer.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/RouteBuilder+RouteCollection.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/RouteBuilder+RouteGroup.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/RouteBuilder.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/RouteCollection.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/RouteGroup+RouteBuilder.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/RouteGroup.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/Router+Routes.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/Router.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/Core.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/libc.swiftmodule /Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/Node.swiftmodule /Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/PathIndexable.swiftmodule /Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/Polymorphic.swiftmodule
/Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/Routing.build/RouteBuilder+RouteCollection~partial.swiftdoc : /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/Branch.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/ParametersContainer.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/RouteBuilder+RouteCollection.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/RouteBuilder+RouteGroup.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/RouteBuilder.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/RouteCollection.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/RouteGroup+RouteBuilder.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/RouteGroup.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/Router+Routes.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/Routing-1.0.2/Sources/Routing/Router.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/Core.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/libc.swiftmodule /Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/Node.swiftmodule /Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/PathIndexable.swiftmodule /Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/Polymorphic.swiftmodule
|
D
|
// Written in the D programming language.
/**
Bit-level manipulation facilities.
Macros:
WIKI = StdBitarray
Copyright: Copyright Digital Mars 2007 - 2011.
License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
Authors: $(WEB digitalmars.com, Walter Bright),
$(WEB erdani.org, Andrei Alexandrescu),
Jonathan M Davis
Source: $(PHOBOSSRC std/_bitmanip.d)
*/
/*
Copyright Digital Mars 2007 - 2012.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
module std.bitmanip;
//debug = bitarray; // uncomment to turn on debugging printf's
import core.bitop;
import std.range;
import std.system;
import std.traits;
version(unittest)
{
import std.stdio;
import std.typetuple;
}
private string myToStringx(ulong n)
{
enum s = "0123456789";
if (n < 10)
return s[cast(size_t)n..cast(size_t)n+1];
else
return myToStringx(n / 10) ~ myToStringx(n % 10);
}
private string myToString(ulong n)
{
return myToStringx(n) ~ (n > uint.max ? "UL" : "U");
}
private template createAccessors(
string store, T, string name, size_t len, size_t offset)
{
static if (!name.length)
{
// No need to create any accessor
enum result = "";
}
else static if (len == 0)
{
// Fields of length 0 are always zero
enum result = "enum "~T.stringof~" "~name~" = 0;\n";
}
else
{
static if (len + offset <= uint.sizeof * 8)
alias uint MasksType;
else
alias ulong MasksType;
enum MasksType
maskAllElse = ((1uL << len) - 1u) << offset,
signBitCheck = 1uL << (len - 1),
extendSign = ~((cast(MasksType)1u << len) - 1);
static if (T.min < 0)
{
enum long minVal = -(1uL << (len - 1));
enum ulong maxVal = (1uL << (len - 1)) - 1;
}
else
{
enum ulong minVal = 0;
enum ulong maxVal = (1uL << len) - 1;
}
static if (is(T == bool))
{
static assert(len == 1);
enum result =
// getter
"@property @safe bool " ~ name ~ "() pure nothrow const { return "
~"("~store~" & "~myToString(maskAllElse)~") != 0;}\n"
// setter
~"@property @safe void " ~ name ~ "(bool v) pure nothrow {"
~"if (v) "~store~" |= "~myToString(maskAllElse)~";"
~"else "~store~" &= ~"~myToString(maskAllElse)~";}\n";
}
else
{
// getter
enum result = "@property @safe "~T.stringof~" "~name~"() pure nothrow const { auto result = "
"("~store~" & "
~ myToString(maskAllElse) ~ ") >>"
~ myToString(offset) ~ ";"
~ (T.min < 0
? "if (result >= " ~ myToString(signBitCheck)
~ ") result |= " ~ myToString(extendSign) ~ ";"
: "")
~ " return cast("~T.stringof~") result;}\n"
// setter
~"@property @safe void "~name~"("~T.stringof~" v) pure nothrow { "
~"assert(v >= "~name~"_min); "
~"assert(v <= "~name~"_max); "
~store~" = cast(typeof("~store~"))"
" (("~store~" & ~"~myToString(maskAllElse)~")"
" | ((cast(typeof("~store~")) v << "~myToString(offset)~")"
" & "~myToString(maskAllElse)~"));}\n"
// constants
~"enum "~T.stringof~" "~name~"_min = cast("~T.stringof~")"
~myToString(minVal)~"; "
~" enum "~T.stringof~" "~name~"_max = cast("~T.stringof~")"
~myToString(maxVal)~"; ";
}
}
}
private template createStoreName(Ts...)
{
static if (Ts.length < 2)
enum createStoreName = "";
else
enum createStoreName = "_" ~ Ts[1] ~ createStoreName!(Ts[3 .. $]);
}
private template createFields(string store, size_t offset, Ts...)
{
static if (!Ts.length)
{
static if (offset == ubyte.sizeof * 8)
alias ubyte StoreType;
else static if (offset == ushort.sizeof * 8)
alias ushort StoreType;
else static if (offset == uint.sizeof * 8)
alias uint StoreType;
else static if (offset == ulong.sizeof * 8)
alias ulong StoreType;
else
{
static assert(false, "Field widths must sum to 8, 16, 32, or 64");
alias ulong StoreType; // just to avoid another error msg
}
enum result = "private " ~ StoreType.stringof ~ " " ~ store ~ ";";
}
else
{
enum result
= createAccessors!(store, Ts[0], Ts[1], Ts[2], offset).result
~ createFields!(store, offset + Ts[2], Ts[3 .. $]).result;
}
}
/**
Allows creating bit fields inside $(D_PARAM struct)s and $(D_PARAM
class)es.
Example:
----
struct A
{
int a;
mixin(bitfields!(
uint, "x", 2,
int, "y", 3,
uint, "z", 2,
bool, "flag", 1));
}
A obj;
obj.x = 2;
obj.z = obj.x;
----
The example above creates a bitfield pack of eight bits, which fit in
one $(D_PARAM ubyte). The bitfields are allocated starting from the
least significant bit, i.e. x occupies the two least significant bits
of the bitfields storage.
The sum of all bit lengths in one $(D_PARAM bitfield) instantiation
must be exactly 8, 16, 32, or 64. If padding is needed, just allocate
one bitfield with an empty name.
Example:
----
struct A
{
mixin(bitfields!(
bool, "flag1", 1,
bool, "flag2", 1,
uint, "", 6));
}
----
The type of a bit field can be any integral type or enumerated
type. The most efficient type to store in bitfields is $(D_PARAM
bool), followed by unsigned types, followed by signed types.
*/
template bitfields(T...)
{
enum { bitfields = createFields!(createStoreName!(T), 0, T).result }
}
unittest
{
struct Test
{
mixin(bitfields!(bool, "a", 1,
uint, "b", 3,
short, "c", 4));
}
@safe void test() pure nothrow
{
Test t;
t.a = true;
t.b = 5;
t.c = 2;
assert(t.a);
assert(t.b == 5);
assert(t.c == 2);
}
test();
}
unittest
{
static struct Integrals {
bool checkExpectations(bool eb, int ei, short es) { return b == eb && i == ei && s == es; }
mixin(bitfields!(
bool, "b", 1,
uint, "i", 3,
short, "s", 4));
}
Integrals i;
assert(i.checkExpectations(false, 0, 0));
i.b = true;
assert(i.checkExpectations(true, 0, 0));
i.i = 7;
assert(i.checkExpectations(true, 7, 0));
i.s = -8;
assert(i.checkExpectations(true, 7, -8));
i.s = 7;
assert(i.checkExpectations(true, 7, 7));
enum A { True, False }
enum B { One, Two, Three, Four }
static struct Enums {
bool checkExpectations(A ea, B eb) { return a == ea && b == eb; }
mixin(bitfields!(
A, "a", 1,
B, "b", 2,
uint, "", 5));
}
Enums e;
assert(e.checkExpectations(A.True, B.One));
e.a = A.False;
assert(e.checkExpectations(A.False, B.One));
e.b = B.Three;
assert(e.checkExpectations(A.False, B.Three));
static struct SingleMember {
bool checkExpectations(bool eb) { return b == eb; }
mixin(bitfields!(
bool, "b", 1,
uint, "", 7));
}
SingleMember f;
assert(f.checkExpectations(false));
f.b = true;
assert(f.checkExpectations(true));
}
/**
Allows manipulating the fraction, exponent, and sign parts of a
$(D_PARAM float) separately. The definition is:
----
struct FloatRep
{
union
{
float value;
mixin(bitfields!(
uint, "fraction", 23,
ubyte, "exponent", 8,
bool, "sign", 1));
}
enum uint bias = 127, fractionBits = 23, exponentBits = 8, signBits = 1;
}
----
*/
struct FloatRep
{
union
{
float value;
mixin(bitfields!(
uint, "fraction", 23,
ubyte, "exponent", 8,
bool, "sign", 1));
}
enum uint bias = 127, fractionBits = 23, exponentBits = 8, signBits = 1;
}
/**
Allows manipulating the fraction, exponent, and sign parts of a
$(D_PARAM double) separately. The definition is:
----
struct DoubleRep
{
union
{
double value;
mixin(bitfields!(
ulong, "fraction", 52,
ushort, "exponent", 11,
bool, "sign", 1));
}
enum uint bias = 1023, signBits = 1, fractionBits = 52, exponentBits = 11;
}
----
*/
struct DoubleRep
{
union
{
double value;
mixin(bitfields!(
ulong, "fraction", 52,
ushort, "exponent", 11,
bool, "sign", 1));
}
enum uint bias = 1023, signBits = 1, fractionBits = 52, exponentBits = 11;
}
unittest
{
// test reading
DoubleRep x;
x.value = 1.0;
assert(x.fraction == 0 && x.exponent == 1023 && !x.sign);
x.value = -0.5;
assert(x.fraction == 0 && x.exponent == 1022 && x.sign);
x.value = 0.5;
assert(x.fraction == 0 && x.exponent == 1022 && !x.sign);
// test writing
x.fraction = 1125899906842624;
x.exponent = 1025;
x.sign = true;
assert(x.value == -5.0);
// test enums
enum ABC { A, B, C }
struct EnumTest
{
mixin(bitfields!(
ABC, "x", 2,
bool, "y", 1,
ubyte, "z", 5));
}
}
/**
* An array of bits.
*/
struct BitArray
{
size_t len;
size_t* ptr;
enum bitsPerSizeT = size_t.sizeof * 8;
/**********************************************
* Gets the amount of native words backing this $(D BitArray).
*/
@property const size_t dim()
{
return (len + (bitsPerSizeT-1)) / bitsPerSizeT;
}
/**********************************************
* Gets the amount of bits in the $(D BitArray).
*/
@property const size_t length()
{
return len;
}
/**********************************************
* Sets the amount of bits in the $(D BitArray).
*/
@property size_t length(size_t newlen)
{
if (newlen != len)
{
size_t olddim = dim;
size_t newdim = (newlen + (bitsPerSizeT-1)) / bitsPerSizeT;
if (newdim != olddim)
{
// Create a fake array so we can use D's realloc machinery
auto b = ptr[0 .. olddim];
b.length = newdim; // realloc
ptr = b.ptr;
if (newdim & (bitsPerSizeT-1))
{ // Set any pad bits to 0
ptr[newdim - 1] &= ~(~0 << (newdim & (bitsPerSizeT-1)));
}
}
len = newlen;
}
return len;
}
/**********************************************
* Gets the $(D i)'th bit in the $(D BitArray).
*/
bool opIndex(size_t i) const
in
{
assert(i < len);
}
body
{
// Andrei: review for @@@64-bit@@@
return cast(bool) bt(ptr, i);
}
unittest
{
void Fun(const BitArray arr)
{
auto x = arr[0];
assert(x == 1);
}
BitArray a;
a.length = 3;
a[0] = 1;
Fun(a);
}
/**********************************************
* Sets the $(D i)'th bit in the $(D BitArray).
*/
bool opIndexAssign(bool b, size_t i)
in
{
assert(i < len);
}
body
{
if (b)
bts(ptr, i);
else
btr(ptr, i);
return b;
}
/**********************************************
* Duplicates the $(D BitArray) and its contents.
*/
@property BitArray dup() const
{
BitArray ba;
auto b = ptr[0 .. dim].dup;
ba.len = len;
ba.ptr = b.ptr;
return ba;
}
unittest
{
BitArray a;
BitArray b;
int i;
debug(bitarray) printf("BitArray.dup.unittest\n");
a.length = 3;
a[0] = 1; a[1] = 0; a[2] = 1;
b = a.dup;
assert(b.length == 3);
for (i = 0; i < 3; i++)
{ debug(bitarray) printf("b[%d] = %d\n", i, b[i]);
assert(b[i] == (((i ^ 1) & 1) ? true : false));
}
}
/**********************************************
* Support for $(D foreach) loops for $(D BitArray).
*/
int opApply(scope int delegate(ref bool) dg)
{
int result;
for (size_t i = 0; i < len; i++)
{
bool b = opIndex(i);
result = dg(b);
this[i] = b;
if (result)
break;
}
return result;
}
/** ditto */
int opApply(scope int delegate(bool) dg) const
{
int result;
for (size_t i = 0; i < len; i++)
{
bool b = opIndex(i);
result = dg(b);
if (result)
break;
}
return result;
}
/** ditto */
int opApply(scope int delegate(ref size_t, ref bool) dg)
{
int result;
for (size_t i = 0; i < len; i++)
{
bool b = opIndex(i);
result = dg(i, b);
this[i] = b;
if (result)
break;
}
return result;
}
/** ditto */
int opApply(scope int delegate(size_t, bool) dg) const
{
int result;
for (size_t i = 0; i < len; i++)
{
bool b = opIndex(i);
result = dg(i, b);
if (result)
break;
}
return result;
}
unittest
{
debug(bitarray) printf("BitArray.opApply unittest\n");
static bool[] ba = [1,0,1];
BitArray a; a.init(ba);
int i;
foreach (b;a)
{
switch (i)
{
case 0: assert(b == true); break;
case 1: assert(b == false); break;
case 2: assert(b == true); break;
default: assert(0);
}
i++;
}
foreach (j,b;a)
{
switch (j)
{
case 0: assert(b == true); break;
case 1: assert(b == false); break;
case 2: assert(b == true); break;
default: assert(0);
}
}
}
/**********************************************
* Reverses the bits of the $(D BitArray).
*/
@property BitArray reverse()
out (result)
{
assert(result == this);
}
body
{
if (len >= 2)
{
bool t;
size_t lo, hi;
lo = 0;
hi = len - 1;
for (; lo < hi; lo++, hi--)
{
t = this[lo];
this[lo] = this[hi];
this[hi] = t;
}
}
return this;
}
unittest
{
debug(bitarray) printf("BitArray.reverse.unittest\n");
BitArray b;
static bool[5] data = [1,0,1,1,0];
int i;
b.init(data);
b.reverse;
for (i = 0; i < data.length; i++)
{
assert(b[i] == data[4 - i]);
}
}
/**********************************************
* Sorts the $(D BitArray)'s elements.
*/
@property BitArray sort()
out (result)
{
assert(result == this);
}
body
{
if (len >= 2)
{
size_t lo, hi;
lo = 0;
hi = len - 1;
while (1)
{
while (1)
{
if (lo >= hi)
goto Ldone;
if (this[lo] == true)
break;
lo++;
}
while (1)
{
if (lo >= hi)
goto Ldone;
if (this[hi] == false)
break;
hi--;
}
this[lo] = false;
this[hi] = true;
lo++;
hi--;
}
Ldone:
;
}
return this;
}
unittest
{
debug(bitarray) printf("BitArray.sort.unittest\n");
__gshared size_t x = 0b1100011000;
__gshared BitArray ba = { 10, &x };
ba.sort;
for (size_t i = 0; i < 6; i++)
assert(ba[i] == false);
for (size_t i = 6; i < 10; i++)
assert(ba[i] == true);
}
/***************************************
* Support for operators == and != for $(D BitArray).
*/
const bool opEquals(const ref BitArray a2)
{
int i;
if (this.length != a2.length)
return 0; // not equal
byte *p1 = cast(byte*)this.ptr;
byte *p2 = cast(byte*)a2.ptr;
auto n = this.length / 8;
for (i = 0; i < n; i++)
{
if (p1[i] != p2[i])
return 0; // not equal
}
ubyte mask;
n = this.length & 7;
mask = cast(ubyte)((1 << n) - 1);
//printf("i = %d, n = %d, mask = %x, %x, %x\n", i, n, mask, p1[i], p2[i]);
return (mask == 0) || (p1[i] & mask) == (p2[i] & mask);
}
unittest
{
debug(bitarray) printf("BitArray.opEquals unittest\n");
static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1];
static bool[] bc = [1,0,1,0,1,0,1];
static bool[] bd = [1,0,1,1,1];
static bool[] be = [1,0,1,0,1];
BitArray a; a.init(ba);
BitArray b; b.init(bb);
BitArray c; c.init(bc);
BitArray d; d.init(bd);
BitArray e; e.init(be);
assert(a != b);
assert(a != c);
assert(a != d);
assert(a == e);
}
/***************************************
* Supports comparison operators for $(D BitArray).
*/
int opCmp(BitArray a2) const
{
uint i;
auto len = this.length;
if (a2.length < len)
len = a2.length;
ubyte* p1 = cast(ubyte*)this.ptr;
ubyte* p2 = cast(ubyte*)a2.ptr;
auto n = len / 8;
for (i = 0; i < n; i++)
{
if (p1[i] != p2[i])
break; // not equal
}
for (uint j = i * 8; j < len; j++)
{
ubyte mask = cast(ubyte)(1 << j);
int c;
c = cast(int)(p1[i] & mask) - cast(int)(p2[i] & mask);
if (c)
return c;
}
return cast(int)this.len - cast(int)a2.length;
}
unittest
{
debug(bitarray) printf("BitArray.opCmp unittest\n");
static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1];
static bool[] bc = [1,0,1,0,1,0,1];
static bool[] bd = [1,0,1,1,1];
static bool[] be = [1,0,1,0,1];
BitArray a; a.init(ba);
BitArray b; b.init(bb);
BitArray c; c.init(bc);
BitArray d; d.init(bd);
BitArray e; e.init(be);
assert(a > b);
assert(a >= b);
assert(a < c);
assert(a <= c);
assert(a < d);
assert(a <= d);
assert(a == e);
assert(a <= e);
assert(a >= e);
}
/***************************************
* Support for hashing for $(D BitArray).
*/
hash_t toHash() const pure nothrow
{
hash_t hash = 3557;
auto n = len / 8;
for (int i = 0; i < n; i++)
{
hash *= 3559;
hash += (cast(byte*)this.ptr)[i];
}
for (size_t i = 8*n; i < len; i++)
{
hash *= 3571;
hash += bt(this.ptr, i);
}
return hash;
}
/***************************************
* Set this $(D BitArray) to the contents of $(D ba).
*/
void init(bool[] ba)
{
length = ba.length;
foreach (i, b; ba)
{
this[i] = b;
}
}
/***************************************
* Map the $(D BitArray) onto $(D v), with $(D numbits) being the number of bits
* in the array. Does not copy the data.
*
* This is the inverse of $(D opCast).
*/
void init(void[] v, size_t numbits)
in
{
assert(numbits <= v.length * 8);
assert((v.length & 3) == 0);
}
body
{
ptr = cast(size_t*)v.ptr;
len = numbits;
}
unittest
{
debug(bitarray) printf("BitArray.init unittest\n");
static bool[] ba = [1,0,1,0,1];
BitArray a; a.init(ba);
BitArray b;
void[] v;
v = cast(void[])a;
b.init(v, a.length);
assert(b[0] == 1);
assert(b[1] == 0);
assert(b[2] == 1);
assert(b[3] == 0);
assert(b[4] == 1);
a[0] = 0;
assert(b[0] == 0);
assert(a == b);
}
/***************************************
* Convert to $(D void[]).
*/
void[] opCast(T : void[])()
{
return cast(void[])ptr[0 .. dim];
}
/***************************************
* Convert to $(D size_t[]).
*/
size_t[] opCast(T : size_t[])()
{
return ptr[0 .. dim];
}
unittest
{
debug(bitarray) printf("BitArray.opCast unittest\n");
static bool[] ba = [1,0,1,0,1];
BitArray a; a.init(ba);
void[] v = cast(void[])a;
assert(v.length == a.dim * size_t.sizeof);
}
/***************************************
* Support for unary operator ~ for $(D BitArray).
*/
BitArray opCom()
{
auto dim = this.dim;
BitArray result;
result.length = len;
for (size_t i = 0; i < dim; i++)
result.ptr[i] = ~this.ptr[i];
if (len & (bitsPerSizeT-1))
result.ptr[dim - 1] &= ~(~0 << (len & (bitsPerSizeT-1)));
return result;
}
unittest
{
debug(bitarray) printf("BitArray.opCom unittest\n");
static bool[] ba = [1,0,1,0,1];
BitArray a; a.init(ba);
BitArray b = ~a;
assert(b[0] == 0);
assert(b[1] == 1);
assert(b[2] == 0);
assert(b[3] == 1);
assert(b[4] == 0);
}
/***************************************
* Support for binary operator & for $(D BitArray).
*/
BitArray opAnd(BitArray e2)
in
{
assert(len == e2.length);
}
body
{
auto dim = this.dim;
BitArray result;
result.length = len;
for (size_t i = 0; i < dim; i++)
result.ptr[i] = this.ptr[i] & e2.ptr[i];
return result;
}
unittest
{
debug(bitarray) printf("BitArray.opAnd unittest\n");
static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1,1,0];
BitArray a; a.init(ba);
BitArray b; b.init(bb);
BitArray c = a & b;
assert(c[0] == 1);
assert(c[1] == 0);
assert(c[2] == 1);
assert(c[3] == 0);
assert(c[4] == 0);
}
/***************************************
* Support for binary operator | for $(D BitArray).
*/
BitArray opOr(BitArray e2) const
in
{
assert(len == e2.length);
}
body
{
auto dim = this.dim;
BitArray result;
result.length = len;
for (size_t i = 0; i < dim; i++)
result.ptr[i] = this.ptr[i] | e2.ptr[i];
return result;
}
unittest
{
debug(bitarray) printf("BitArray.opOr unittest\n");
static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1,1,0];
BitArray a; a.init(ba);
BitArray b; b.init(bb);
BitArray c = a | b;
assert(c[0] == 1);
assert(c[1] == 0);
assert(c[2] == 1);
assert(c[3] == 1);
assert(c[4] == 1);
}
/***************************************
* Support for binary operator ^ for $(D BitArray).
*/
BitArray opXor(BitArray e2) const
in
{
assert(len == e2.length);
}
body
{
auto dim = this.dim;
BitArray result;
result.length = len;
for (size_t i = 0; i < dim; i++)
result.ptr[i] = this.ptr[i] ^ e2.ptr[i];
return result;
}
unittest
{
debug(bitarray) printf("BitArray.opXor unittest\n");
static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1,1,0];
BitArray a; a.init(ba);
BitArray b; b.init(bb);
BitArray c = a ^ b;
assert(c[0] == 0);
assert(c[1] == 0);
assert(c[2] == 0);
assert(c[3] == 1);
assert(c[4] == 1);
}
/***************************************
* Support for binary operator - for $(D BitArray).
*
* $(D a - b) for $(D BitArray) means the same thing as $(D a & ~b).
*/
BitArray opSub(BitArray e2) const
in
{
assert(len == e2.length);
}
body
{
auto dim = this.dim;
BitArray result;
result.length = len;
for (size_t i = 0; i < dim; i++)
result.ptr[i] = this.ptr[i] & ~e2.ptr[i];
return result;
}
unittest
{
debug(bitarray) printf("BitArray.opSub unittest\n");
static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1,1,0];
BitArray a; a.init(ba);
BitArray b; b.init(bb);
BitArray c = a - b;
assert(c[0] == 0);
assert(c[1] == 0);
assert(c[2] == 0);
assert(c[3] == 0);
assert(c[4] == 1);
}
/***************************************
* Support for operator &= for $(D BitArray).
*/
BitArray opAndAssign(BitArray e2)
in
{
assert(len == e2.length);
}
body
{
auto dim = this.dim;
for (size_t i = 0; i < dim; i++)
ptr[i] &= e2.ptr[i];
return this;
}
unittest
{
debug(bitarray) printf("BitArray.opAndAssign unittest\n");
static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1,1,0];
BitArray a; a.init(ba);
BitArray b; b.init(bb);
a &= b;
assert(a[0] == 1);
assert(a[1] == 0);
assert(a[2] == 1);
assert(a[3] == 0);
assert(a[4] == 0);
}
/***************************************
* Support for operator |= for $(D BitArray).
*/
BitArray opOrAssign(BitArray e2)
in
{
assert(len == e2.length);
}
body
{
auto dim = this.dim;
for (size_t i = 0; i < dim; i++)
ptr[i] |= e2.ptr[i];
return this;
}
unittest
{
debug(bitarray) printf("BitArray.opOrAssign unittest\n");
static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1,1,0];
BitArray a; a.init(ba);
BitArray b; b.init(bb);
a |= b;
assert(a[0] == 1);
assert(a[1] == 0);
assert(a[2] == 1);
assert(a[3] == 1);
assert(a[4] == 1);
}
/***************************************
* Support for operator ^= for $(D BitArray).
*/
BitArray opXorAssign(BitArray e2)
in
{
assert(len == e2.length);
}
body
{
auto dim = this.dim;
for (size_t i = 0; i < dim; i++)
ptr[i] ^= e2.ptr[i];
return this;
}
unittest
{
debug(bitarray) printf("BitArray.opXorAssign unittest\n");
static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1,1,0];
BitArray a; a.init(ba);
BitArray b; b.init(bb);
a ^= b;
assert(a[0] == 0);
assert(a[1] == 0);
assert(a[2] == 0);
assert(a[3] == 1);
assert(a[4] == 1);
}
/***************************************
* Support for operator -= for $(D BitArray).
*
* $(D a -= b) for $(D BitArray) means the same thing as $(D a &= ~b).
*/
BitArray opSubAssign(BitArray e2)
in
{
assert(len == e2.length);
}
body
{
auto dim = this.dim;
for (size_t i = 0; i < dim; i++)
ptr[i] &= ~e2.ptr[i];
return this;
}
unittest
{
debug(bitarray) printf("BitArray.opSubAssign unittest\n");
static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1,1,0];
BitArray a; a.init(ba);
BitArray b; b.init(bb);
a -= b;
assert(a[0] == 0);
assert(a[1] == 0);
assert(a[2] == 0);
assert(a[3] == 0);
assert(a[4] == 1);
}
/***************************************
* Support for operator ~= for $(D BitArray).
*/
BitArray opCatAssign(bool b)
{
length = len + 1;
this[len - 1] = b;
return this;
}
unittest
{
debug(bitarray) printf("BitArray.opCatAssign unittest\n");
static bool[] ba = [1,0,1,0,1];
BitArray a; a.init(ba);
BitArray b;
b = (a ~= true);
assert(a[0] == 1);
assert(a[1] == 0);
assert(a[2] == 1);
assert(a[3] == 0);
assert(a[4] == 1);
assert(a[5] == 1);
assert(b == a);
}
/***************************************
* ditto
*/
BitArray opCatAssign(BitArray b)
{
auto istart = len;
length = len + b.length;
for (auto i = istart; i < len; i++)
this[i] = b[i - istart];
return this;
}
unittest
{
debug(bitarray) printf("BitArray.opCatAssign unittest\n");
static bool[] ba = [1,0];
static bool[] bb = [0,1,0];
BitArray a; a.init(ba);
BitArray b; b.init(bb);
BitArray c;
c = (a ~= b);
assert(a.length == 5);
assert(a[0] == 1);
assert(a[1] == 0);
assert(a[2] == 0);
assert(a[3] == 1);
assert(a[4] == 0);
assert(c == a);
}
/***************************************
* Support for binary operator ~ for $(D BitArray).
*/
BitArray opCat(bool b) const
{
BitArray r;
r = this.dup;
r.length = len + 1;
r[len] = b;
return r;
}
/** ditto */
BitArray opCat_r(bool b) const
{
BitArray r;
r.length = len + 1;
r[0] = b;
for (size_t i = 0; i < len; i++)
r[1 + i] = this[i];
return r;
}
/** ditto */
BitArray opCat(BitArray b) const
{
BitArray r;
r = this.dup();
r ~= b;
return r;
}
unittest
{
debug(bitarray) printf("BitArray.opCat unittest\n");
static bool[] ba = [1,0];
static bool[] bb = [0,1,0];
BitArray a; a.init(ba);
BitArray b; b.init(bb);
BitArray c;
c = (a ~ b);
assert(c.length == 5);
assert(c[0] == 1);
assert(c[1] == 0);
assert(c[2] == 0);
assert(c[3] == 1);
assert(c[4] == 0);
c = (a ~ true);
assert(c.length == 3);
assert(c[0] == 1);
assert(c[1] == 0);
assert(c[2] == 1);
c = (false ~ a);
assert(c.length == 3);
assert(c[0] == 0);
assert(c[1] == 1);
assert(c[2] == 0);
}
}
/++
Swaps the endianness of the given integral value or character.
+/
T swapEndian(T)(T val) @safe pure nothrow
if(isIntegral!T || isSomeChar!T || is(Unqual!T == bool))
{
static if(val.sizeof == 1)
return val;
else static if(isUnsigned!T)
return swapEndianImpl(val);
else static if(isIntegral!T)
return cast(T)swapEndianImpl(cast(Unsigned!T) val);
else static if(is(Unqual!T == wchar))
return cast(T)swapEndian(cast(ushort)val);
else static if(is(Unqual!T == dchar))
return cast(T)swapEndian(cast(uint)val);
else
static assert(0, T.stringof ~ " unsupported by swapEndian.");
}
private ushort swapEndianImpl(ushort val) @safe pure nothrow
{
return ((val & 0xff00U) >> 8) |
((val & 0x00ffU) << 8);
}
private uint swapEndianImpl(uint val) @trusted pure nothrow
{
return bswap(val);
}
private ulong swapEndianImpl(ulong val) @trusted pure nothrow
{
immutable ulong res = bswap(cast(uint)val);
return res << 32 | bswap(cast(uint)(val >> 32));
}
unittest
{
foreach(T; TypeTuple!(bool, byte, ubyte, short, ushort, int, uint, long, ulong, char, wchar, dchar))
{
scope(failure) writefln("Failed type: %s", T.stringof);
T val;
const T cval;
immutable T ival;
assert(swapEndian(swapEndian(val)) == val);
assert(swapEndian(swapEndian(cval)) == cval);
assert(swapEndian(swapEndian(ival)) == ival);
assert(swapEndian(swapEndian(T.min)) == T.min);
assert(swapEndian(swapEndian(T.max)) == T.max);
foreach(i; 2 .. 10)
{
immutable T maxI = cast(T)(T.max / i);
immutable T minI = cast(T)(T.min / i);
assert(swapEndian(swapEndian(maxI)) == maxI);
static if(isSigned!T)
assert(swapEndian(swapEndian(minI)) == minI);
}
static if(isSigned!T)
assert(swapEndian(swapEndian(cast(T)0)) == 0);
// @@@BUG6354@@@
/+
static if(T.sizeof > 1 && isUnsigned!T)
{
T left = 0xffU;
left <<= (T.sizeof - 1) * 8;
T right = 0xffU;
for(size_t i = 1; i < T.sizeof; ++i)
{
assert(swapEndian(left) == right);
assert(swapEndian(right) == left);
left >>= 8;
right <<= 8;
}
}
+/
}
}
private union EndianSwapper(T)
if(isIntegral!T ||
isSomeChar!T ||
is(Unqual!T == bool) ||
is(Unqual!T == float) ||
is(Unqual!T == double))
{
Unqual!T value;
ubyte[T.sizeof] array;
static if(is(Unqual!T == float))
uint intValue;
else static if(is(Unqual!T == double))
ulong intValue;
}
/++
Converts the given value from the native endianness to big endian and
returns it as a $(D ubyte[n]) where $(D n) is the size of the given type.
Returning a $(D ubyte[n]) helps prevent accidentally using a swapped value
as a regular one (and in the case of floating point values, it's necessary,
because the FPU will mess up any swapped floating point values. So, you
can't actually have swapped floating point values as floating point values).
$(D real) is not supported, because its size is implementation-dependent
and therefore could vary from machine to machine (which could make it
unusable if you tried to transfer it to another machine).
Examples:
--------------------
int i = 12345;
ubyte[4] swappedI = nativeToBigEndian(i);
assert(i == bigEndianToNative!int(swappedI));
double d = 123.45;
ubyte[8] swappedD = nativeToBigEndian(d);
assert(d == bigEndianToNative!double(swappedD));
--------------------
+/
auto nativeToBigEndian(T)(T val) @safe pure nothrow
if(isIntegral!T ||
isSomeChar!T ||
is(Unqual!T == bool) ||
is(Unqual!T == float) ||
is(Unqual!T == double))
{
return nativeToBigEndianImpl(val);
}
//Verify Examples
unittest
{
int i = 12345;
ubyte[4] swappedI = nativeToBigEndian(i);
assert(i == bigEndianToNative!int(swappedI));
double d = 123.45;
ubyte[8] swappedD = nativeToBigEndian(d);
assert(d == bigEndianToNative!double(swappedD));
}
private auto nativeToBigEndianImpl(T)(T val) @safe pure nothrow
if(isIntegral!T || isSomeChar!T || is(Unqual!T == bool))
{
EndianSwapper!T es = void;
version(LittleEndian)
es.value = swapEndian(val);
else
es.value = val;
return es.array;
}
private auto nativeToBigEndianImpl(T)(T val) @safe pure nothrow
if(is(Unqual!T == float) || is(Unqual!T == double))
{
version(LittleEndian)
return floatEndianImpl!(T, true)(val);
else
return floatEndianImpl!(T, false)(val);
}
unittest
{
foreach(T; TypeTuple!(bool, byte, ubyte, short, ushort, int, uint, long, ulong,
char, wchar, dchar
/* The trouble here is with floats and doubles being compared against nan
* using a bit compare. There are two kinds of nans, quiet and signaling.
* When a nan passes through the x87, it converts signaling to quiet.
* When a nan passes through the XMM, it does not convert signaling to quiet.
* float.init is a signaling nan.
* The binary API sometimes passes the data through the XMM, sometimes through
* the x87, meaning these will fail the 'is' bit compare under some circumstances.
* I cannot think of a fix for this that makes consistent sense.
*/
/*,float, double*/))
{
scope(failure) writefln("Failed type: %s", T.stringof);
T val;
const T cval;
immutable T ival;
//is instead of == because of NaN for floating point values.
assert(bigEndianToNative!T(nativeToBigEndian(val)) is val);
assert(bigEndianToNative!T(nativeToBigEndian(cval)) is cval);
assert(bigEndianToNative!T(nativeToBigEndian(ival)) is ival);
assert(bigEndianToNative!T(nativeToBigEndian(T.min)) == T.min);
assert(bigEndianToNative!T(nativeToBigEndian(T.max)) == T.max);
static if(isSigned!T)
assert(bigEndianToNative!T(nativeToBigEndian(cast(T)0)) == 0);
static if(!is(T == bool))
{
foreach(i; [2, 4, 6, 7, 9, 11])
{
immutable T maxI = cast(T)(T.max / i);
immutable T minI = cast(T)(T.min / i);
assert(bigEndianToNative!T(nativeToBigEndian(maxI)) == maxI);
static if(T.sizeof > 1)
assert(nativeToBigEndian(maxI) != nativeToLittleEndian(maxI));
else
assert(nativeToBigEndian(maxI) == nativeToLittleEndian(maxI));
static if(isSigned!T)
{
assert(bigEndianToNative!T(nativeToBigEndian(minI)) == minI);
static if(T.sizeof > 1)
assert(nativeToBigEndian(minI) != nativeToLittleEndian(minI));
else
assert(nativeToBigEndian(minI) == nativeToLittleEndian(minI));
}
}
}
static if(isUnsigned!T || T.sizeof == 1 || is(T == wchar))
assert(nativeToBigEndian(T.max) == nativeToLittleEndian(T.max));
else
assert(nativeToBigEndian(T.max) != nativeToLittleEndian(T.max));
static if(isUnsigned!T || T.sizeof == 1 || isSomeChar!T)
assert(nativeToBigEndian(T.min) == nativeToLittleEndian(T.min));
else
assert(nativeToBigEndian(T.min) != nativeToLittleEndian(T.min));
}
}
/++
Converts the given value from big endian to the native endianness and
returns it. The value is given as a $(D ubyte[n]) where $(D n) is the size
of the target type. You must give the target type as a template argument,
because there are multiple types with the same size and so the type of the
argument is not enough to determine the return type.
Taking a $(D ubyte[n]) helps prevent accidentally using a swapped value
as a regular one (and in the case of floating point values, it's necessary,
because the FPU will mess up any swapped floating point values. So, you
can't actually have swapped floating point values as floating point values).
Examples:
--------------------
ushort i = 12345;
ubyte[2] swappedI = nativeToBigEndian(i);
assert(i == bigEndianToNative!ushort(swappedI));
dchar c = 'D';
ubyte[4] swappedC = nativeToBigEndian(c);
assert(c == bigEndianToNative!dchar(swappedC));
--------------------
+/
T bigEndianToNative(T, size_t n)(ubyte[n] val) @safe pure nothrow
if((isIntegral!T ||
isSomeChar!T ||
is(Unqual!T == bool) ||
is(Unqual!T == float) ||
is(Unqual!T == double)) &&
n == T.sizeof)
{
return bigEndianToNativeImpl!(T, n)(val);
}
//Verify Examples.
unittest
{
ushort i = 12345;
ubyte[2] swappedI = nativeToBigEndian(i);
assert(i == bigEndianToNative!ushort(swappedI));
dchar c = 'D';
ubyte[4] swappedC = nativeToBigEndian(c);
assert(c == bigEndianToNative!dchar(swappedC));
}
private T bigEndianToNativeImpl(T, size_t n)(ubyte[n] val) @safe pure nothrow
if((isIntegral!T || isSomeChar!T || is(Unqual!T == bool)) &&
n == T.sizeof)
{
EndianSwapper!T es = void;
es.array = val;
version(LittleEndian)
immutable retval = swapEndian(es.value);
else
immutable retval = es.value;
return retval;
}
private T bigEndianToNativeImpl(T, size_t n)(ubyte[n] val) @safe pure nothrow
if((is(Unqual!T == float) || is(Unqual!T == double)) &&
n == T.sizeof)
{
version(LittleEndian)
return floatEndianImpl!(n, true)(val);
else
return floatEndianImpl!(n, false)(val);
}
/++
Converts the given value from the native endianness to little endian and
returns it as a $(D ubyte[n]) where $(D n) is the size of the given type.
Returning a $(D ubyte[n]) helps prevent accidentally using a swapped value
as a regular one (and in the case of floating point values, it's necessary,
because the FPU will mess up any swapped floating point values. So, you
can't actually have swapped floating point values as floating point values).
Examples:
--------------------
int i = 12345;
ubyte[4] swappedI = nativeToLittleEndian(i);
assert(i == littleEndianToNative!int(swappedI));
double d = 123.45;
ubyte[8] swappedD = nativeToLittleEndian(d);
assert(d == littleEndianToNative!double(swappedD));
--------------------
+/
auto nativeToLittleEndian(T)(T val) @safe pure nothrow
if(isIntegral!T ||
isSomeChar!T ||
is(Unqual!T == bool) ||
is(Unqual!T == float) ||
is(Unqual!T == double))
{
return nativeToLittleEndianImpl(val);
}
//Verify Examples.
unittest
{
int i = 12345;
ubyte[4] swappedI = nativeToLittleEndian(i);
assert(i == littleEndianToNative!int(swappedI));
double d = 123.45;
ubyte[8] swappedD = nativeToLittleEndian(d);
assert(d == littleEndianToNative!double(swappedD));
}
private auto nativeToLittleEndianImpl(T)(T val) @safe pure nothrow
if(isIntegral!T || isSomeChar!T || is(Unqual!T == bool))
{
EndianSwapper!T es = void;
version(BigEndian)
es.value = swapEndian(val);
else
es.value = val;
return es.array;
}
private auto nativeToLittleEndianImpl(T)(T val) @safe pure nothrow
if(is(Unqual!T == float) || is(Unqual!T == double))
{
version(BigEndian)
return floatEndianImpl!(T, true)(val);
else
return floatEndianImpl!(T, false)(val);
}
unittest
{
foreach(T; TypeTuple!(bool, byte, ubyte, short, ushort, int, uint, long, ulong,
char, wchar, dchar/*,
float, double*/))
{
scope(failure) writefln("Failed type: %s", T.stringof);
T val;
const T cval;
immutable T ival;
//is instead of == because of NaN for floating point values.
assert(littleEndianToNative!T(nativeToLittleEndian(val)) is val);
assert(littleEndianToNative!T(nativeToLittleEndian(cval)) is cval);
assert(littleEndianToNative!T(nativeToLittleEndian(ival)) is ival);
assert(littleEndianToNative!T(nativeToLittleEndian(T.min)) == T.min);
assert(littleEndianToNative!T(nativeToLittleEndian(T.max)) == T.max);
static if(isSigned!T)
assert(littleEndianToNative!T(nativeToLittleEndian(cast(T)0)) == 0);
static if(!is(T == bool))
{
foreach(i; 2 .. 10)
{
immutable T maxI = cast(T)(T.max / i);
immutable T minI = cast(T)(T.min / i);
assert(littleEndianToNative!T(nativeToLittleEndian(maxI)) == maxI);
static if(isSigned!T)
assert(littleEndianToNative!T(nativeToLittleEndian(minI)) == minI);
}
}
}
}
/++
Converts the given value from little endian to the native endianness and
returns it. The value is given as a $(D ubyte[n]) where $(D n) is the size
of the target type. You must give the target type as a template argument,
because there are multiple types with the same size and so the type of the
argument is not enough to determine the return type.
Taking a $(D ubyte[n]) helps prevent accidentally using a swapped value
as a regular one (and in the case of floating point values, it's necessary,
because the FPU will mess up any swapped floating point values. So, you
can't actually have swapped floating point values as floating point values).
$(D real) is not supported, because its size is implementation-dependent
and therefore could vary from machine to machine (which could make it
unusable if you tried to transfer it to another machine).
Examples:
--------------------
ushort i = 12345;
ubyte[2] swappedI = nativeToLittleEndian(i);
assert(i == littleEndianToNative!ushort(swappedI));
dchar c = 'D';
ubyte[4] swappedC = nativeToLittleEndian(c);
assert(c == littleEndianToNative!dchar(swappedC));
--------------------
+/
T littleEndianToNative(T, size_t n)(ubyte[n] val) @safe pure nothrow
if((isIntegral!T ||
isSomeChar!T ||
is(Unqual!T == bool) ||
is(Unqual!T == float) ||
is(Unqual!T == double)) &&
n == T.sizeof)
{
return littleEndianToNativeImpl!T(val);
}
//Verify Unittest.
unittest
{
ushort i = 12345;
ubyte[2] swappedI = nativeToLittleEndian(i);
assert(i == littleEndianToNative!ushort(swappedI));
dchar c = 'D';
ubyte[4] swappedC = nativeToLittleEndian(c);
assert(c == littleEndianToNative!dchar(swappedC));
}
private T littleEndianToNativeImpl(T, size_t n)(ubyte[n] val) @safe pure nothrow
if((isIntegral!T || isSomeChar!T || is(Unqual!T == bool)) &&
n == T.sizeof)
{
EndianSwapper!T es = void;
es.array = val;
version(BigEndian)
immutable retval = swapEndian(es.value);
else
immutable retval = es.value;
return retval;
}
private T littleEndianToNativeImpl(T, size_t n)(ubyte[n] val) @safe pure nothrow
if(((is(Unqual!T == float) || is(Unqual!T == double)) &&
n == T.sizeof))
{
version(BigEndian)
return floatEndianImpl!(n, true)(val);
else
return floatEndianImpl!(n, false)(val);
}
private auto floatEndianImpl(T, bool swap)(T val) @safe pure nothrow
if(is(Unqual!T == float) || is(Unqual!T == double))
{
EndianSwapper!T es = void;
es.value = val;
static if(swap)
es.intValue = swapEndian(es.intValue);
return es.array;
}
private auto floatEndianImpl(size_t n, bool swap)(ubyte[n] val) @safe pure nothrow
if(n == 4 || n == 8)
{
static if(n == 4) EndianSwapper!float es = void;
else static if(n == 8) EndianSwapper!double es = void;
es.array = val;
static if(swap)
es.intValue = swapEndian(es.intValue);
return es.value;
}
/++
Takes a range of $(D ubyte)s and converts the first $(D T.sizeof) bytes to
$(D T). The value returned is converted from the given endianness to the
native endianness. The range is not consumed.
Parems:
T = The integral type to convert the first $(D T.sizeof) bytes to.
endianness = The endianness that the bytes are assumed to be in.
range = The range to read from.
index = The index to start reading from (instead of starting at the
front). If index is a pointer, then it is updated to the index
after the bytes read. The overloads with index are only
available if $(D hasSlicing!R) is $(D true).
Examples:
--------------------
ubyte[] buffer = [1, 5, 22, 9, 44, 255, 8];
assert(buffer.peek!uint() == 17110537);
assert(buffer.peek!ushort() == 261);
assert(buffer.peek!ubyte() == 1);
assert(buffer.peek!uint(2) == 369700095);
assert(buffer.peek!ushort(2) == 5641);
assert(buffer.peek!ubyte(2) == 22);
size_t index = 0;
assert(buffer.peek!ushort(&index) == 261);
assert(index == 2);
assert(buffer.peek!uint(&index) == 369700095);
assert(index == 6);
assert(buffer.peek!ubyte(&index) == 8);
assert(index == 7);
--------------------
+/
T peek(T, Endian endianness = Endian.bigEndian, R)(R range)
if(isIntegral!T && isForwardRange!R && is(ElementType!R : const ubyte))
{
static if(hasSlicing!R)
const ubyte[T.sizeof] bytes = range[0 .. T.sizeof];
else
{
ubyte[T.sizeof] bytes;
//Make sure that range is not consumed, even if it's a class.
range = range.save;
foreach(ref e; bytes)
{
e = range.front;
range.popFront();
}
}
static if(endianness == Endian.bigEndian)
return bigEndianToNative!T(bytes);
else
return littleEndianToNative!T(bytes);
}
/++ Ditto +/
T peek(T, Endian endianness = Endian.bigEndian, R)(R range, size_t index)
if(isIntegral!T &&
isForwardRange!R &&
hasSlicing!R &&
is(ElementType!R : const ubyte))
{
return peek!(T, endianness)(range, &index);
}
/++ Ditto +/
T peek(T, Endian endianness = Endian.bigEndian, R)(R range, size_t* index)
if(isIntegral!T &&
isForwardRange!R &&
hasSlicing!R &&
is(ElementType!R : const ubyte))
{
assert(index);
immutable begin = *index;
immutable end = begin + T.sizeof;
const ubyte[T.sizeof] bytes = range[begin .. end];
*index = end;
static if(endianness == Endian.bigEndian)
return bigEndianToNative!T(bytes);
else
return littleEndianToNative!T(bytes);
}
//Verify Example.
unittest
{
ubyte[] buffer = [1, 5, 22, 9, 44, 255, 8];
assert(buffer.peek!uint() == 17110537);
assert(buffer.peek!ushort() == 261);
assert(buffer.peek!ubyte() == 1);
assert(buffer.peek!uint(2) == 369700095);
assert(buffer.peek!ushort(2) == 5641);
assert(buffer.peek!ubyte(2) == 22);
size_t index = 0;
assert(buffer.peek!ushort(&index) == 261);
assert(index == 2);
assert(buffer.peek!uint(&index) == 369700095);
assert(index == 6);
assert(buffer.peek!ubyte(&index) == 8);
assert(index == 7);
}
unittest
{
import std.algorithm;
ubyte[] buffer = [1, 5, 22, 9, 44, 255, 7];
auto range = filter!"true"(buffer);
assert(range.peek!uint() == 17110537);
assert(range.peek!ushort() == 261);
assert(range.peek!ubyte() == 1);
}
/++
Takes a range of $(D ubyte)s and converts the first $(D T.sizeof) bytes to
$(D T). The value returned is converted from the given endianness to the
native endianness. The $(D T.sizeof) bytes which are read are consumed from
the range.
Parems:
T = The integral type to convert the first $(D T.sizeof) bytes to.
endianness = The endianness that the bytes are assumed to be in.
range = The range to read from.
Examples:
--------------------
ubyte[] buffer = [1, 5, 22, 9, 44, 255, 8];
assert(buffer.length == 7);
assert(buffer.read!ushort() == 261);
assert(buffer.length == 5);
assert(buffer.read!uint() == 369700095);
assert(buffer.length == 1);
assert(buffer.read!ubyte() == 8);
assert(buffer.empty);
--------------------
+/
T read(T, Endian endianness = Endian.bigEndian, R)(ref R range)
if(isIntegral!T && isInputRange!R && is(ElementType!R : const ubyte))
{
static if(hasSlicing!R)
{
const ubyte[T.sizeof] bytes = range[0 .. T.sizeof];
range.popFrontN(T.sizeof);
}
else
{
ubyte[T.sizeof] bytes;
foreach(ref e; bytes)
{
e = range.front;
range.popFront();
}
}
static if(endianness == Endian.bigEndian)
return bigEndianToNative!T(bytes);
else
return littleEndianToNative!T(bytes);
}
//Verify Example.
unittest
{
ubyte[] buffer = [1, 5, 22, 9, 44, 255, 8];
assert(buffer.length == 7);
assert(buffer.read!ushort() == 261);
assert(buffer.length == 5);
assert(buffer.read!uint() == 369700095);
assert(buffer.length == 1);
assert(buffer.read!ubyte() == 8);
assert(buffer.empty);
}
unittest
{
import std.algorithm;
ubyte[] buffer = [1, 5, 22, 9, 44, 255, 8];
auto range = filter!"true"(buffer);
assert(walkLength(range) == 7);
assert(range.read!ushort() == 261);
assert(walkLength(range) == 5);
assert(range.read!uint() == 369700095);
assert(walkLength(range) == 1);
assert(range.read!ubyte() == 8);
assert(range.empty);
}
/++
Takes an integral value, converts it to the given endianness, and writes it
to the given range of $(D ubyte)s as a sequence of $(D T.sizeof) $(D ubyte)s
starting at index. $(D hasSlicing!R) must be $(D true).
Parems:
T = The integral type to convert the first $(D T.sizeof) bytes to.
endianness = The endianness to write the bytes in.
range = The range to write to.
index = The index to start writing to. If index is a pointer, then it
is updated to the index after the bytes read.
Examples:
--------------------
//Bug# 8129 forces the casts. They shouldn't be necessary.
{
ubyte[] buffer = [0, 0, 0, 0, 0, 0, 0];
buffer.write!uint(29110231u, 0);
assert(buffer == [1, 188, 47, 215, 0, 0, 0]);
buffer.write!ushort(cast(ushort)927, 0);
assert(buffer == [3, 159, 47, 215, 0, 0, 0]);
buffer.write!ubyte(cast(ubyte)42, 0);
assert(buffer == [42, 159, 47, 215, 0, 0, 0]);
}
{
ubyte[] buffer = [0, 0, 0, 0, 0, 0, 0];
buffer.write!uint(142700095u, 2);
assert(buffer == [0, 0, 8, 129, 110, 63, 0]);
buffer.write!ushort(cast(ushort)19839, 2);
assert(buffer == [0, 0, 77, 127, 110, 63, 0]);
buffer.write!ubyte(cast(ubyte)132, 2);
assert(buffer == [0, 0, 132, 127, 110, 63, 0]);
}
{
ubyte[] buffer = [0, 0, 0, 0, 0, 0, 0];
size_t index = 0;
buffer.write!ushort(cast(ushort)261, &index);
assert(buffer == [1, 5, 0, 0, 0, 0, 0]);
assert(index == 2);
buffer.write!uint(369700095u, &index);
assert(buffer == [1, 5, 22, 9, 44, 255, 0]);
assert(index == 6);
buffer.write!ubyte(cast(ubyte)8, &index);
assert(buffer == [1, 5, 22, 9, 44, 255, 8]);
assert(index == 7);
}
--------------------
+/
void write(T, Endian endianness = Endian.bigEndian, R)(R range, T value, size_t index)
if(isIntegral!T &&
isForwardRange!R &&
hasSlicing!R &&
is(ElementType!R : ubyte))
{
write!(T, endianness)(range, value, &index);
}
/++ Ditto +/
void write(T, Endian endianness = Endian.bigEndian, R)(R range, T value, size_t* index)
if(isIntegral!T &&
isForwardRange!R &&
hasSlicing!R &&
is(ElementType!R : ubyte))
{
assert(index);
static if(endianness == Endian.bigEndian)
immutable bytes = nativeToBigEndian!T(value);
else
immutable bytes = nativeToLittleEndian!T(value);
immutable begin = *index;
immutable end = begin + T.sizeof;
*index = end;
range[begin .. end] = bytes[0 .. T.sizeof];
}
//Verify Example.
unittest
{
//Bug# 8129 forces the casts. They shouldn't be necessary.
{
ubyte[] buffer = [0, 0, 0, 0, 0, 0, 0];
buffer.write!uint(29110231u, 0);
assert(buffer == [1, 188, 47, 215, 0, 0, 0]);
buffer.write!ushort(cast(ushort)927, 0);
assert(buffer == [3, 159, 47, 215, 0, 0, 0]);
buffer.write!ubyte(cast(ubyte)42, 0);
assert(buffer == [42, 159, 47, 215, 0, 0, 0]);
}
{
ubyte[] buffer = [0, 0, 0, 0, 0, 0, 0];
buffer.write!uint(142700095u, 2);
assert(buffer == [0, 0, 8, 129, 110, 63, 0]);
buffer.write!ushort(cast(ushort)19839, 2);
assert(buffer == [0, 0, 77, 127, 110, 63, 0]);
buffer.write!ubyte(cast(ubyte)132, 2);
assert(buffer == [0, 0, 132, 127, 110, 63, 0]);
}
{
ubyte[] buffer = [0, 0, 0, 0, 0, 0, 0];
size_t index = 0;
buffer.write!ushort(cast(ushort)261, &index);
assert(buffer == [1, 5, 0, 0, 0, 0, 0]);
assert(index == 2);
buffer.write!uint(369700095u, &index);
assert(buffer == [1, 5, 22, 9, 44, 255, 0]);
assert(index == 6);
buffer.write!ubyte(cast(ubyte)8, &index);
assert(buffer == [1, 5, 22, 9, 44, 255, 8]);
assert(index == 7);
}
}
/++
Takes an integral value, converts it to the given endianness, and appends
it to the given range of $(D ubyte)s (using $(D put)) as a sequence of
$(D T.sizeof) $(D ubyte)s starting at index. $(D hasSlicing!R) must be
$(D true).
Parems:
T = The integral type to convert the first $(D T.sizeof) bytes to.
endianness = The endianness to write the bytes in.
range = The range to append to.
Examples:
--------------------
//Bug# 8129 forces the casts. They shouldn't be necessary.
auto buffer = appender!(const ubyte[])();
buffer.append!ushort(cast(ushort)261);
assert(buffer.data == [1, 5]);
buffer.append!uint(369700095u);
assert(buffer.data == [1, 5, 22, 9, 44, 255]);
buffer.append!ubyte(cast(ubyte)8);
assert(buffer.data == [1, 5, 22, 9, 44, 255, 8]);
--------------------
+/
void append(T, Endian endianness = Endian.bigEndian, R)(R range, T value)
if(isIntegral!T && isOutputRange!(R, ubyte))
{
static if(endianness == Endian.bigEndian)
immutable bytes = nativeToBigEndian!T(value);
else
immutable bytes = nativeToLittleEndian!T(value);
put(range, bytes[]);
}
//Verify Example.
unittest
{
//Bug# 8129 forces the casts. They shouldn't be necessary.
auto buffer = appender!(const ubyte[])();
buffer.append!ushort(cast(ushort)261);
assert(buffer.data == [1, 5]);
buffer.append!uint(369700095u);
assert(buffer.data == [1, 5, 22, 9, 44, 255]);
buffer.append!ubyte(cast(ubyte)8);
assert(buffer.data == [1, 5, 22, 9, 44, 255, 8]);
}
unittest
{
import std.string;
foreach(endianness; TypeTuple!(Endian.bigEndian, Endian.littleEndian))
{
auto toWrite = appender!(ubyte[])();
alias TypeTuple!(uint, int, long, ulong, short, ubyte, ushort, byte, uint) Types;
ulong[] values = [42, -11, long.max, 1098911981329L, 16, 255, 19012, 2, 17];
assert(Types.length == values.length);
size_t index = 0;
size_t length = 0;
foreach(T; Types)
{
toWrite.append!T(cast(T)values[index++]);
length += T.sizeof;
}
auto toRead = toWrite.data;
assert(toRead.length == length);
index = 0;
foreach(T; Types)
{
assert(toRead.peek!T() == values[index], format("Failed Index: %s", index));
assert(toRead.peek!T(0) == values[index], format("Failed Index: %s", index));
assert(toRead.length == length,
format("Failed Index [%s], Actual Length: %s", index, toRead.length));
assert(toRead.read!T() == values[index], format("Failed Index: %s", index));
length -= T.sizeof;
assert(toRead.length == length,
format("Failed Index [%s], Actual Length: %s", index, toRead.length));
++index;
}
assert(toRead.empty);
}
}
|
D
|
/Users/doriankinoocrutcher/Documents/blockheads/Blockstagram/blockstagram/contract/target/wasm32-unknown-unknown/debug/deps/keccak-96349553626b1b05.rmeta: /Users/doriankinoocrutcher/.cargo/registry/src/github.com-1ecc6299db9ec823/keccak-0.1.0/src/lib.rs
/Users/doriankinoocrutcher/Documents/blockheads/Blockstagram/blockstagram/contract/target/wasm32-unknown-unknown/debug/deps/libkeccak-96349553626b1b05.rlib: /Users/doriankinoocrutcher/.cargo/registry/src/github.com-1ecc6299db9ec823/keccak-0.1.0/src/lib.rs
/Users/doriankinoocrutcher/Documents/blockheads/Blockstagram/blockstagram/contract/target/wasm32-unknown-unknown/debug/deps/keccak-96349553626b1b05.d: /Users/doriankinoocrutcher/.cargo/registry/src/github.com-1ecc6299db9ec823/keccak-0.1.0/src/lib.rs
/Users/doriankinoocrutcher/.cargo/registry/src/github.com-1ecc6299db9ec823/keccak-0.1.0/src/lib.rs:
|
D
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Contains <b>experimental</b> functionality for generating Thrift IDL files
* (.thrift) from existing D data structures, i.e. the reverse of what the
* Thrift compiler does.
*/
module thrift.codegen.idlgen;
import std.algorithm : find;
import std.array : empty, front;
import std.conv : to;
import std.traits : EnumMembers, isSomeFunction, OriginalType,
ParameterTypeTuple, ReturnType;
import std.typetuple : allSatisfy, staticIndexOf, staticMap, NoDuplicates,
TypeTuple;
import thrift.base;
import thrift.codegen.base;
import thrift.internal.codegen;
import thrift.internal.ctfe;
import thrift.util.hashset;
/**
* True if the passed type is a Thrift entity (struct, exception, enum,
* service).
*/
alias Any!(isStruct, isException, isEnum, isService) isThriftEntity;
/**
* Returns an IDL string describing the passed »root« entities and all types
* they depend on.
*/
template idlString(Roots...) if (allSatisfy!(isThriftEntity, Roots)) {
enum idlString = idlStringImpl!Roots.result;
}
private {
template idlStringImpl(Roots...) if (allSatisfy!(isThriftEntity, Roots)) {
alias ForAllWithList!(
ConfinedTuple!(StaticFilter!(isService, Roots)),
AddBaseServices
) Services;
alias TypeTuple!(
StaticFilter!(isEnum, Roots),
ForAllWithList!(
ConfinedTuple!(
StaticFilter!(Any!(isException, isStruct), Roots),
staticMap!(CompositeTypeDeps, staticMap!(ServiceTypeDeps, Services))
),
AddStructWithDeps
)
) Types;
enum result = ctfeJoin(
[
staticMap!(
enumIdlString,
StaticFilter!(isEnum, Types)
),
staticMap!(
structIdlString,
StaticFilter!(Any!(isStruct, isException), Types)
),
staticMap!(
serviceIdlString,
Services
)
],
"\n"
);
}
template ServiceTypeDeps(T) if (isService!T) {
alias staticMap!(
PApply!(MethodTypeDeps, T),
FilterMethodNames!(T, __traits(derivedMembers, T))
) ServiceTypeDeps;
}
template MethodTypeDeps(T, string name) if (
isService!T && isSomeFunction!(MemberType!(T, name))
) {
alias TypeTuple!(
ReturnType!(MemberType!(T, name)),
ParameterTypeTuple!(MemberType!(T, name)),
ExceptionTypes!(T, name)
) MethodTypeDeps;
}
template ExceptionTypes(T, string name) if (
isService!T && isSomeFunction!(MemberType!(T, name))
) {
mixin({
enum meta = find!`a.name == b`(getMethodMeta!T, name);
if (meta.empty) return "alias TypeTuple!() ExceptionTypes;";
string result = "alias TypeTuple!(";
foreach (i, e; meta.front.exceptions) {
if (i > 0) result ~= ", ";
result ~= "mixin(`T." ~ e.type ~ "`)";
}
result ~= ") ExceptionTypes;";
return result;
}());
}
template AddBaseServices(T, List...) {
static if (staticIndexOf!(T, List) == -1) {
alias NoDuplicates!(BaseServices!T, List) AddBaseServices;
} else {
alias List AddStructWithDeps;
}
}
unittest {
interface A {}
interface B : A {}
interface C : B {}
interface D : A {}
static assert(is(AddBaseServices!(C) == TypeTuple!(A, B, C)));
static assert(is(ForAllWithList!(ConfinedTuple!(C, D), AddBaseServices) ==
TypeTuple!(A, D, B, C)));
}
template BaseServices(T, Rest...) if (isService!T) {
static if (isDerivedService!T) {
alias BaseServices!(BaseService!T, T, Rest) BaseServices;
} else {
alias TypeTuple!(T, Rest) BaseServices;
}
}
template AddStructWithDeps(T, List...) {
static if (staticIndexOf!(T, List) == -1) {
// T is not already in the List, so add T and the types it depends on in
// the front. Because with the Thrift compiler types can only depend on
// other types that have already been defined, we collect all the
// dependencies, prepend them to the list, and then prune the duplicates
// (keeping the first occurences). If this requirement should ever be
// dropped from Thrift, this could be easily adapted to handle circular
// dependencies by passing TypeTuple!(T, List) to ForAllWithList instead
// of appending List afterwards, and removing the now unneccesary
// NoDuplicates.
alias NoDuplicates!(
ForAllWithList!(
ConfinedTuple!(
staticMap!(
CompositeTypeDeps,
staticMap!(
PApply!(MemberType, T),
FieldNames!T
)
)
),
.AddStructWithDeps,
T
),
List
) AddStructWithDeps;
} else {
alias List AddStructWithDeps;
}
}
version (unittest) {
struct A {}
struct B {
A a;
int b;
A c;
string d;
}
struct C {
B b;
A a;
}
static assert(is(AddStructWithDeps!C == TypeTuple!(A, B, C)));
struct D {
C c;
mixin TStructHelpers!([TFieldMeta("c", 0, TReq.IGNORE)]);
}
static assert(is(AddStructWithDeps!D == TypeTuple!(D)));
}
version (unittest) {
// Circles in the type dependency graph are not allowed in Thrift, but make
// sure we fail in a sane way instead of crashing the compiler.
struct Rec1 {
Rec2[] other;
}
struct Rec2 {
Rec1[] other;
}
static assert(!__traits(compiles, AddStructWithDeps!Rec1));
}
/*
* Returns the non-primitive types T directly depends on.
*
* For example, CompositeTypeDeps!int would yield an empty type tuple,
* CompositeTypeDeps!SomeStruct would give SomeStruct, and
* CompositeTypeDeps!(A[B]) both CompositeTypeDeps!A and CompositeTypeDeps!B.
*/
template CompositeTypeDeps(T) {
static if (is(FullyUnqual!T == bool) || is(FullyUnqual!T == byte) ||
is(FullyUnqual!T == short) || is(FullyUnqual!T == int) ||
is(FullyUnqual!T == long) || is(FullyUnqual!T : string) ||
is(FullyUnqual!T == double) || is(FullyUnqual!T == void)
) {
alias TypeTuple!() CompositeTypeDeps;
} else static if (is(FullyUnqual!T _ : U[], U)) {
alias CompositeTypeDeps!U CompositeTypeDeps;
} else static if (is(FullyUnqual!T _ : HashSet!E, E)) {
alias CompositeTypeDeps!E CompositeTypeDeps;
} else static if (is(FullyUnqual!T _ : V[K], K, V)) {
alias TypeTuple!(CompositeTypeDeps!K, CompositeTypeDeps!V) CompositeTypeDeps;
} else static if (is(FullyUnqual!T == enum) || is(FullyUnqual!T == struct) ||
is(FullyUnqual!T : TException)
) {
alias TypeTuple!(FullyUnqual!T) CompositeTypeDeps;
} else {
static assert(false, "Cannot represent type in Thrift: " ~ T.stringof);
}
}
}
/**
* Returns an IDL string describing the passed service. IDL code for any type
* dependcies is not included.
*/
template serviceIdlString(T) if (isService!T) {
enum serviceIdlString = {
string result = "service " ~ T.stringof;
static if (isDerivedService!T) {
result ~= " extends " ~ BaseService!T.stringof;
}
result ~= " {\n";
foreach (methodName; FilterMethodNames!(T, __traits(derivedMembers, T))) {
result ~= " ";
enum meta = find!`a.name == b`(T.methodMeta, methodName);
static if (!meta.empty && meta.front.type == TMethodType.ONEWAY) {
result ~= "oneway ";
}
alias ReturnType!(MemberType!(T, methodName)) RT;
static if (is(RT == void)) {
// We special-case this here instead of adding void to dToIdlType to
// avoid accepting things like void[].
result ~= "void ";
} else {
result ~= dToIdlType!RT ~ " ";
}
result ~= methodName ~ "(";
short lastId;
foreach (i, ParamType; ParameterTypeTuple!(MemberType!(T, methodName))) {
static if (!meta.empty && i < meta.front.params.length) {
enum havePM = true;
} else {
enum havePM = false;
}
short id;
static if (havePM) {
id = meta.front.params[i].id;
} else {
id = --lastId;
}
string paramName;
static if (havePM) {
paramName = meta.front.params[i].name;
} else {
paramName = "param" ~ to!string(i + 1);
}
result ~= to!string(id) ~ ": " ~ dToIdlType!ParamType ~ " " ~ paramName;
static if (havePM && !meta.front.params[i].defaultValue.empty) {
result ~= " = " ~ dToIdlConst(mixin(meta.front.params[i].defaultValue));
} else {
// Unfortunately, getting the default value for parameters from a
// function alias isn't possible – we can't transfer the default
// value to the IDL e.g. for interface Foo { void foo(int a = 5); }
// without the user explicitly declaring it in metadata.
}
result ~= ", ";
}
result ~= ")";
static if (!meta.empty && !meta.front.exceptions.empty) {
result ~= " throws (";
foreach (e; meta.front.exceptions) {
result ~= to!string(e.id) ~ ": " ~ e.type ~ " " ~ e.name ~ ", ";
}
result ~= ")";
}
result ~= ",\n";
}
result ~= "}\n";
return result;
}();
}
/**
* Returns an IDL string describing the passed enum. IDL code for any type
* dependcies is not included.
*/
template enumIdlString(T) if (isEnum!T) {
enum enumIdlString = {
static assert(is(OriginalType!T : long),
"Can only have integer enums in Thrift (not " ~ OriginalType!T.stringof ~
", for " ~ T.stringof ~ ").");
string result = "enum " ~ T.stringof ~ " {\n";
foreach (name; __traits(derivedMembers, T)) {
result ~= " " ~ name ~ " = " ~ dToIdlConst(GetMember!(T, name)) ~ ",\n";
}
result ~= "}\n";
return result;
}();
}
/**
* Returns an IDL string describing the passed struct. IDL code for any type
* dependcies is not included.
*/
template structIdlString(T) if (isStruct!T || isException!T) {
enum structIdlString = {
mixin({
string code = "";
foreach (field; getFieldMeta!T) {
code ~= "static assert(is(MemberType!(T, `" ~ field.name ~ "`)));\n";
}
return code;
}());
string result;
static if (isException!T) {
result = "exception ";
} else {
result = "struct ";
}
result ~= T.stringof ~ " {\n";
// The last automatically assigned id – fields with no meta information
// are assigned (in lexical order) descending negative ids, starting with
// -1, just like the Thrift compiler does.
short lastId;
foreach (name; FieldNames!T) {
enum meta = find!`a.name == b`(getFieldMeta!T, name);
static if (meta.empty || meta.front.req != TReq.IGNORE) {
short id;
static if (meta.empty) {
id = --lastId;
} else {
id = meta.front.id;
}
result ~= " " ~ to!string(id) ~ ":";
static if (!meta.empty) {
result ~= dToIdlReq(meta.front.req);
}
result ~= " " ~ dToIdlType!(MemberType!(T, name)) ~ " " ~ name;
static if (!meta.empty && !meta.front.defaultValue.empty) {
result ~= " = " ~ dToIdlConst(mixin(meta.front.defaultValue));
} else static if (__traits(compiles, fieldInitA!(T, name))) {
static if (is(typeof(fieldInitA!(T, name))) &&
!is(typeof(fieldInitA!(T, name)) == void)
) {
result ~= " = " ~ dToIdlConst(fieldInitA!(T, name));
}
} else static if (is(typeof(fieldInitB!(T, name))) &&
!is(typeof(fieldInitB!(T, name)) == void)
) {
result ~= " = " ~ dToIdlConst(fieldInitB!(T, name));
}
result ~= ",\n";
}
}
result ~= "}\n";
return result;
}();
}
private {
// This very convoluted way of doing things was chosen because putting the
// static if directly into structIdlString caused »not evaluatable at compile
// time« errors to slip through even though typeof() was used, resp. the
// condition to be true even though the value couldn't actually be read at
// compile time due to a @@BUG@@ in DMD 2.055.
// The extra »compiled« field in fieldInitA is needed because we must not try
// to use != if !is compiled as well (but was false), e.g. for floating point
// types.
template fieldInitA(T, string name) {
static if (mixin("T.init." ~ name) !is MemberType!(T, name).init) {
enum fieldInitA = mixin("T.init." ~ name);
}
}
template fieldInitB(T, string name) {
static if (mixin("T.init." ~ name) != MemberType!(T, name).init) {
enum fieldInitB = mixin("T.init." ~ name);
}
}
template dToIdlType(T) {
static if (is(FullyUnqual!T == bool)) {
enum dToIdlType = "bool";
} else static if (is(FullyUnqual!T == byte)) {
enum dToIdlType = "byte";
} else static if (is(FullyUnqual!T == double)) {
enum dToIdlType = "double";
} else static if (is(FullyUnqual!T == short)) {
enum dToIdlType = "i16";
} else static if (is(FullyUnqual!T == int)) {
enum dToIdlType = "i32";
} else static if (is(FullyUnqual!T == long)) {
enum dToIdlType = "i64";
} else static if (is(FullyUnqual!T : string)) {
enum dToIdlType = "string";
} else static if (is(FullyUnqual!T _ : U[], U)) {
enum dToIdlType = "list<" ~ dToIdlType!U ~ ">";
} else static if (is(FullyUnqual!T _ : V[K], K, V)) {
enum dToIdlType = "map<" ~ dToIdlType!K ~ ", " ~ dToIdlType!V ~ ">";
} else static if (is(FullyUnqual!T _ : HashSet!E, E)) {
enum dToIdlType = "set<" ~ dToIdlType!E ~ ">";
} else static if (is(FullyUnqual!T == struct) || is(FullyUnqual!T == enum) ||
is(FullyUnqual!T : TException)
) {
enum dToIdlType = FullyUnqual!(T).stringof;
} else {
static assert(false, "Cannot represent type in Thrift: " ~ T.stringof);
}
}
string dToIdlReq(TReq req) {
switch (req) {
case TReq.REQUIRED: return " required";
case TReq.OPTIONAL: return " optional";
default: return "";
}
}
string dToIdlConst(T)(T value) {
static if (is(FullyUnqual!T == bool)) {
return value ? "1" : "0";
} else static if (is(FullyUnqual!T == byte) ||
is(FullyUnqual!T == short) || is(FullyUnqual!T == int) ||
is(FullyUnqual!T == long)
) {
return to!string(value);
} else static if (is(FullyUnqual!T : string)) {
return `"` ~ to!string(value) ~ `"`;
} else static if (is(FullyUnqual!T == double)) {
return ctfeToString(value);
} else static if (is(FullyUnqual!T _ : U[], U) ||
is(FullyUnqual!T _ : HashSet!E, E)
) {
string result = "[";
foreach (e; value) {
result ~= dToIdlConst(e) ~ ", ";
}
result ~= "]";
return result;
} else static if (is(FullyUnqual!T _ : V[K], K, V)) {
string result = "{";
foreach (key, val; value) {
result ~= dToIdlConst(key) ~ ": " ~ dToIdlConst(val) ~ ", ";
}
result ~= "}";
return result;
} else static if (is(FullyUnqual!T == enum)) {
import std.conv;
import std.traits;
return to!string(cast(OriginalType!T)value);
} else static if (is(FullyUnqual!T == struct) ||
is(FullyUnqual!T : TException)
) {
string result = "{";
foreach (name; __traits(derivedMembers, T)) {
static if (memberReq!(T, name) != TReq.IGNORE) {
result ~= name ~ ": " ~ dToIdlConst(mixin("value." ~ name)) ~ ", ";
}
}
result ~= "}";
return result;
} else {
static assert(false, "Cannot represent type in Thrift: " ~ T.stringof);
}
}
}
version (unittest) {
enum Foo {
a = 1,
b = 10,
c = 5
}
static assert(enumIdlString!Foo ==
`enum Foo {
a = 1,
b = 10,
c = 5,
}
`);
}
version (unittest) {
struct WithoutMeta {
string a;
int b;
}
struct WithDefaults {
string a = "asdf";
double b = 3.14;
WithoutMeta c;
mixin TStructHelpers!([
TFieldMeta("c", 1, TReq.init, `WithoutMeta("foo", 3)`)
]);
}
// These are from DebugProtoTest.thrift.
struct OneOfEach {
bool im_true;
bool im_false;
byte a_bite;
short integer16;
int integer32;
long integer64;
double double_precision;
string some_characters;
string zomg_unicode;
bool what_who;
string base64;
byte[] byte_list;
short[] i16_list;
long[] i64_list;
mixin TStructHelpers!([
TFieldMeta(`im_true`, 1),
TFieldMeta(`im_false`, 2),
TFieldMeta(`a_bite`, 3, TReq.OPT_IN_REQ_OUT, q{cast(byte)127}),
TFieldMeta(`integer16`, 4, TReq.OPT_IN_REQ_OUT, q{cast(short)32767}),
TFieldMeta(`integer32`, 5),
TFieldMeta(`integer64`, 6, TReq.OPT_IN_REQ_OUT, q{10000000000L}),
TFieldMeta(`double_precision`, 7),
TFieldMeta(`some_characters`, 8),
TFieldMeta(`zomg_unicode`, 9),
TFieldMeta(`what_who`, 10),
TFieldMeta(`base64`, 11),
TFieldMeta(`byte_list`, 12, TReq.OPT_IN_REQ_OUT, q{{
byte[] v;
v ~= cast(byte)1;
v ~= cast(byte)2;
v ~= cast(byte)3;
return v;
}()}),
TFieldMeta(`i16_list`, 13, TReq.OPT_IN_REQ_OUT, q{{
short[] v;
v ~= cast(short)1;
v ~= cast(short)2;
v ~= cast(short)3;
return v;
}()}),
TFieldMeta(`i64_list`, 14, TReq.OPT_IN_REQ_OUT, q{{
long[] v;
v ~= 1L;
v ~= 2L;
v ~= 3L;
return v;
}()})
]);
}
struct Bonk {
int type;
string message;
mixin TStructHelpers!([
TFieldMeta(`type`, 1),
TFieldMeta(`message`, 2)
]);
}
struct HolyMoley {
OneOfEach[] big;
HashSet!(string[]) contain;
Bonk[][string] bonks;
mixin TStructHelpers!([
TFieldMeta(`big`, 1),
TFieldMeta(`contain`, 2),
TFieldMeta(`bonks`, 3)
]);
}
static assert(structIdlString!WithoutMeta ==
`struct WithoutMeta {
-1: string a,
-2: i32 b,
}
`);
static assert(structIdlString!WithDefaults ==
`struct WithDefaults {
-1: string a = "asdf",
-2: double b = 3.14,
1: WithoutMeta c = {a: "foo", b: 3, },
}
`);
static assert(structIdlString!OneOfEach ==
`struct OneOfEach {
1: bool im_true,
2: bool im_false,
3: byte a_bite = 127,
4: i16 integer16 = 32767,
5: i32 integer32,
6: i64 integer64 = 10000000000,
7: double double_precision,
8: string some_characters,
9: string zomg_unicode,
10: bool what_who,
11: string base64,
12: list<byte> byte_list = [1, 2, 3, ],
13: list<i16> i16_list = [1, 2, 3, ],
14: list<i64> i64_list = [1, 2, 3, ],
}
`);
static assert(structIdlString!Bonk ==
`struct Bonk {
1: i32 type,
2: string message,
}
`);
static assert(structIdlString!HolyMoley ==
`struct HolyMoley {
1: list<OneOfEach> big,
2: set<list<string>> contain,
3: map<string, list<Bonk>> bonks,
}
`);
}
version (unittest) {
class ExceptionWithAMap : TException {
string blah;
string[string] map_field;
mixin TStructHelpers!([
TFieldMeta(`blah`, 1),
TFieldMeta(`map_field`, 2)
]);
}
interface Srv {
void voidMethod();
int primitiveMethod();
OneOfEach structMethod();
void methodWithDefaultArgs(int something);
void onewayMethod();
void exceptionMethod();
alias .ExceptionWithAMap ExceptionWithAMap;
enum methodMeta = [
TMethodMeta(`methodWithDefaultArgs`,
[TParamMeta(`something`, 1, q{2})]
),
TMethodMeta(`onewayMethod`,
[],
[],
TMethodType.ONEWAY
),
TMethodMeta(`exceptionMethod`,
[],
[
TExceptionMeta("a", 1, "ExceptionWithAMap"),
TExceptionMeta("b", 2, "ExceptionWithAMap")
]
)
];
}
interface ChildSrv : Srv {
int childMethod(int arg);
}
static assert(idlString!ChildSrv ==
`exception ExceptionWithAMap {
1: string blah,
2: map<string, string> map_field,
}
struct OneOfEach {
1: bool im_true,
2: bool im_false,
3: byte a_bite = 127,
4: i16 integer16 = 32767,
5: i32 integer32,
6: i64 integer64 = 10000000000,
7: double double_precision,
8: string some_characters,
9: string zomg_unicode,
10: bool what_who,
11: string base64,
12: list<byte> byte_list = [1, 2, 3, ],
13: list<i16> i16_list = [1, 2, 3, ],
14: list<i64> i64_list = [1, 2, 3, ],
}
service Srv {
void voidMethod(),
i32 primitiveMethod(),
OneOfEach structMethod(),
void methodWithDefaultArgs(1: i32 something = 2, ),
oneway void onewayMethod(),
void exceptionMethod() throws (1: ExceptionWithAMap a, 2: ExceptionWithAMap b, ),
}
service ChildSrv extends Srv {
i32 childMethod(-1: i32 param1, ),
}
`);
}
|
D
|
module xfbuild.Linker;
private {
import xfbuild.GlobalParams;
import xfbuild.Module;
import xfbuild.Process;
import xfbuild.Misc;
import tango.sys.Process;
import tango.io.stream.Lines;
import tango.stdc.ctype : isalnum;
import tango.text.Util : contains;
import Array=tango.core.Array;
// TODO: better logging
import tango.io.Stdout;
}
/+private {
Regex linkerFileRegex;
}
static this() {
//defend\terrain\Generator.obj(Generator)
//linkerFileRegex = Regex(`([a-zA-Z0-9.:_\-\\/]+)\(.*\)`);
}+/
bool isValidObjFileName(const(char)[] f) {
foreach (c; f) {
if (!isalnum(c) && !(`.:_-\/`.contains(c))) {
return false;
}
}
return true;
}
bool link(ref Module[char[]] modules,const(char[])[] mainFiles=null)
{
bool retryCompile;
const(char)[][] args;
args ~= globalParams.compilerName;
args ~= globalParams.compilerOptions;
foreach (k;mainFiles){
foreach(m; modules)
{
if(m.path==k){
if(! m.isHeader) args ~= m.objFile;
break;
}
}
}
foreach(k,m; modules)
{
if(m.isHeader || Array.contains(mainFiles,m.path))
continue;
args ~= m.objFile;
}
args ~= "-of" ~ globalParams.outputFile;
if (!globalParams.recompileOnUndefinedReference) {
executeCompilerViaResponseFile(
args[0],
args[1..$],
globalParams.linkerAffinityMask
);
} else {
scope process = new Process(true, args);
execute(process);
const(char)[] currentFile = null;
Module currentModule = null;
version (Windows) {
auto procOut = process.stdout;
} else {
auto procOut = process.stderr;
}
foreach (line; new Lines!(char)(procOut))
{
line = TextUtil.trim(line);
if (line.length > 0) {
Stdout.formatln("linker: '{}'", line);
}
try
{
auto arr = line.decomposeString(cast(char[])null, "(", null, ")");
//if(linkerFileRegex.test(line))
if (arr && isValidObjFileName(arr[1]))
{
//currentFile = linkerFileRegex[1];
currentFile = arr[1];
foreach(m; modules)
if(m.objFile == currentFile)
currentModule = m;
if(!currentModule && globalParams.verbose)
{
Stdout.formatln("{} doesn't belong to any known module", currentFile);
continue;
}
if(globalParams.verbose)
Stdout.formatln("linker error in file {} (module {})", currentFile, currentModule);
}
else if(/*undefinedReferenceRegex.test(line)*/ line.startsWith("Error 42:") && globalParams.recompileOnUndefinedReference)
{
if(globalParams.verbose)
{
if(!currentFile || !currentModule)
{
Stdout.formatln("no file.. wtf?");
//continue; // as i currently recompile every file anyway...
}
/*Stdout.formatln("undefined reference to {}, will try to recompile {}", undefinedReferenceRegex[1], currentModule);
currentModule.needRecompile = true;
retryCompile = true;*/
Stdout.formatln("undefined reference, will try teh full recompile :F");
foreach(m; modules) m.needRecompile = true;
retryCompile = true;
break;
}
}
}
catch(Exception e)
{
if(currentFile && currentModule)
{
Stdout.formatln("{}", e);
Stdout.formatln("utf8 exception caught, assuming linker error in file {}", currentModule);
// orly!
foreach(m; modules) m.needRecompile = true;
retryCompile = true;
break;
} else {
throw e;
}
}
}
try
{
checkProcessFail(process);
}
catch(Exception e)
{
version (Windows) {
// I don't know if Windows is affected too?
} else {
// DMD somehow puts some linker errors onto stdout :S
Stderr.copy(process.stdout).flush;
}
if(retryCompile && globalParams.verbose)
Stdout.formatln("ignoring linker error, will try to recompile");
else if(!retryCompile)
throw e; // rethrow exception since we're not going to retry what we did
}
}
globalParams.recompileOnUndefinedReference = false; // avoid infinite loop
return retryCompile;
}
|
D
|
void foo(int x, int y = 3)
{
}
foo(4); // same as foo(4, 3);
|
D
|
import derelict.sdl2.sdl;
struct Key {
bool state;
int kEnum;
}
enum {
W, A, S, D, UP, DOWN, LEFT, RIGHT, ATTACK, SELECT, LAST
}
private Key[] keys = [
{0, SDL_SCANCODE_W},
{0, SDL_SCANCODE_A},
{0, SDL_SCANCODE_S},
{0, SDL_SCANCODE_D},
{0, SDL_SCANCODE_UP},
{0, SDL_SCANCODE_DOWN},
{0, SDL_SCANCODE_LEFT},
{0, SDL_SCANCODE_RIGHT},
{0, SDL_SCANCODE_LCTRL},
{0, SDL_SCANCODE_RETURN},
];
Key[] oldKeys;
void init() {
oldKeys ~= keys[0..LAST];
}
bool isPressed(uint k) {
bool* curKeys = getKeys();
keys[k].state = curKeys[keys[k].kEnum];
oldKeys[0..LAST] = keys[0..LAST];
return keys[k].state;
}
bool hasChanged() {
bool* newKeys = getKeys();
for (int i = 0; i < LAST; i++)
if (newKeys[keys[i].kEnum] != keys[i].state)
return true;
return false;
}
bool* getKeys() {
return cast(bool*) SDL_GetKeyboardState(null);
}
|
D
|
/*
TEST_OUTPUT:
---
fail_compilation/ice13816.d(15): Error: alias `ice13816.ItemProperty!().ItemProperty` recursive alias declaration
fail_compilation/ice13816.d(20): Error: template instance `ice13816.ItemProperty!()` error instantiating
---
*/
alias TypeTuple(T...) = T;
template ItemProperty()
{
static if (true)
{
alias ItemProperty = TypeTuple!(ItemProperty!());
}
}
void main()
{
alias items = ItemProperty!();
enum num = items.length;
}
|
D
|
instance Mod_7462_RIT_Gerold_IR (Npc_Default)
{
// ------ NSC ------
name = "Gerold";
guild = GIL_OUT;
id = 7462;
voice = 0;
flags = 0;
npctype = NPCTYPE_MAIN;
// ------ Attribute ------
B_SetAttributesToChapter (self, 4);
// ------ Kampf-Taktik ------
fight_tactic = FAI_HUMAN_MASTER;
aivar[AIV_Partymember] = TRUE;
// ------ Equippte Waffen ------
EquipItem (self, ItMw_Schwert_03);
EquipItem (self, ItRw_Mil_Crossbow_Schmetter);
// ------ Inventory ------
B_CreateAmbientInv (self);
// ------ visuals ------
B_SetNpcVisual (self, MALE, "Hum_Head_FatBald", Face_N_Normal_Blade, BodyTex_N, ITAR_PAL_M);
Mdl_SetModelFatness (self, 1);
Mdl_ApplyOverlayMds (self, "Humans_Militia.mds");
// ------ NSC-relevante Talente vergeben ------
B_GiveNpcTalents (self);
// ------ Kampf-Talente ------
B_SetFightSkills (self, 70);
// ------ TA anmelden ------
daily_routine = Rtn_Start_7462;
};
FUNC VOID Rtn_Start_7462 ()
{
TA_Practice_Sword (08,00,22,00,"SHIP_DECK_10");
TA_Practice_Sword (22,00,08,00,"SHIP_DECK_10");
};
FUNC VOID Rtn_Follow_7462 ()
{
TA_Follow_Player (08,00,20,00,"SHIP_CREW_19");
TA_Follow_Player (20,00,08,00,"SHIP_CREW_19");
};
FUNC VOID Rtn_Waiting_7462 ()
{
TA_Stand_ArmsCrossed (08,00,20,00,"DI_DRACONIANAREA_17");
TA_Stand_ArmsCrossed (20,00,08,00,"DI_DRACONIANAREA_17");
};
|
D
|
/Users/reececomo/Documents/Dev/opensource/SFSymbols/.build/x86_64-apple-macosx/debug/SFSymbols.build/SFSymbols.swift.o : /Users/reececomo/Documents/Dev/opensource/SFSymbols/Sources/SFSymbols/SFSymbols.swift /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/Swift.swiftmodule/x86_64.swiftmodule /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/SwiftOnoneSupport.swiftmodule/x86_64.swiftmodule
/Users/reececomo/Documents/Dev/opensource/SFSymbols/.build/x86_64-apple-macosx/debug/SFSymbols.build/SFSymbols~partial.swiftmodule : /Users/reececomo/Documents/Dev/opensource/SFSymbols/Sources/SFSymbols/SFSymbols.swift /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/Swift.swiftmodule/x86_64.swiftmodule /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/SwiftOnoneSupport.swiftmodule/x86_64.swiftmodule
/Users/reececomo/Documents/Dev/opensource/SFSymbols/.build/x86_64-apple-macosx/debug/SFSymbols.build/SFSymbols~partial.swiftdoc : /Users/reececomo/Documents/Dev/opensource/SFSymbols/Sources/SFSymbols/SFSymbols.swift /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/Swift.swiftmodule/x86_64.swiftmodule /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/SwiftOnoneSupport.swiftmodule/x86_64.swiftmodule
|
D
|
module UnrealScript.TribesGame.TrFlagTeamRabbit;
import ScriptClasses;
import UnrealScript.Helpers;
import UnrealScript.Engine.Controller;
import UnrealScript.TribesGame.TrFlagBase;
extern(C++) interface TrFlagTeamRabbit : TrFlagBase
{
public extern(D):
private static __gshared ScriptClass mStaticClass;
@property final static ScriptClass StaticClass() { mixin(MGSCC("Class TribesGame.TrFlagTeamRabbit")); }
private static __gshared TrFlagTeamRabbit mDefaultProperties;
@property final static TrFlagTeamRabbit DefaultProperties() { mixin(MGDPC("TrFlagTeamRabbit", "TrFlagTeamRabbit TribesGame.Default__TrFlagTeamRabbit")); }
static struct Functions
{
private static __gshared
{
ScriptFunction mSetHolder;
ScriptFunction mClearHolder;
ScriptFunction mSendHome;
ScriptFunction mBroadcastReturnedMessage;
ScriptFunction mClientReturnedHome;
}
public @property static final
{
ScriptFunction SetHolder() { mixin(MGF("mSetHolder", "Function TribesGame.TrFlagTeamRabbit.SetHolder")); }
ScriptFunction ClearHolder() { mixin(MGF("mClearHolder", "Function TribesGame.TrFlagTeamRabbit.ClearHolder")); }
ScriptFunction SendHome() { mixin(MGF("mSendHome", "Function TribesGame.TrFlagTeamRabbit.SendHome")); }
ScriptFunction BroadcastReturnedMessage() { mixin(MGF("mBroadcastReturnedMessage", "Function TribesGame.TrFlagTeamRabbit.BroadcastReturnedMessage")); }
ScriptFunction ClientReturnedHome() { mixin(MGF("mClientReturnedHome", "Function TribesGame.TrFlagTeamRabbit.ClientReturnedHome")); }
}
}
static struct Home
{
private static __gshared ScriptState mStaticClass;
@property final static ScriptState StaticClass() { mixin(MGSCSA("State TribesGame.TrFlagTeamRabbit.Home")); }
}
static struct Dropped
{
private static __gshared ScriptState mStaticClass;
@property final static ScriptState StaticClass() { mixin(MGSCSA("State TribesGame.TrFlagTeamRabbit.Dropped")); }
}
static struct Held
{
private static __gshared ScriptState mStaticClass;
@property final static ScriptState StaticClass() { mixin(MGSCSA("State TribesGame.TrFlagTeamRabbit.Held")); }
}
final:
void SetHolder(Controller C)
{
ubyte params[4];
params[] = 0;
*cast(Controller*)params.ptr = C;
(cast(ScriptObject)this).ProcessEvent(Functions.SetHolder, params.ptr, cast(void*)0);
}
void ClearHolder()
{
(cast(ScriptObject)this).ProcessEvent(Functions.ClearHolder, cast(void*)0, cast(void*)0);
}
void SendHome(Controller Returner)
{
ubyte params[4];
params[] = 0;
*cast(Controller*)params.ptr = Returner;
(cast(ScriptObject)this).ProcessEvent(Functions.SendHome, params.ptr, cast(void*)0);
}
void BroadcastReturnedMessage()
{
(cast(ScriptObject)this).ProcessEvent(Functions.BroadcastReturnedMessage, cast(void*)0, cast(void*)0);
}
void ClientReturnedHome()
{
(cast(ScriptObject)this).ProcessEvent(Functions.ClientReturnedHome, cast(void*)0, cast(void*)0);
}
}
|
D
|
module day9.part1.main;
import std;
import core.thread;
void main()
{
auto memory = File("input", "r").readln.strip.splitter(",").map!(to!long).array;
memory.length = 2048;
auto input = [1L];
auto output = outputRange!((long e) { e.writeln; })();
Scheduler().schedule(createFiber(memory, input, output)).run();
}
struct Scheduler
{
private:
Fiber[] fibers = [];
public:
auto schedule(Fiber fiber)
{
this.fibers ~= fiber;
return this;
}
void run()
{
while (!fibers.empty)
{
fibers.each!(fiber => fiber.call());
fibers = fibers.filter!(f => f.state != Fiber.State.TERM).array;
}
}
}
alias Continue = Flag!"continue";
auto mode(const long value, const size_t paramIdx)
{
return (value / (100 * 10 ^^ paramIdx)) % 10;
}
ref long param(const size_t ip, long[] memory, const size_t rb, const size_t paramIdx)
{
immutable m = mode(memory[ip], paramIdx);
switch (m)
{
case 0:
return memory[memory[ip + 1 + paramIdx]];
case 1:
return memory[ip + 1 + paramIdx];
case 2:
return memory[rb + memory[ip + 1 + paramIdx]];
default:
throw new Exception("Invalid parameter mode %s".format(m));
}
}
alias addInstruction = (ref size_t ip, long[] memory, ref size_t rb) => ({
param(ip, memory, rb, 2) = param(ip, memory, rb, 0) + param(ip, memory, rb, 1);
ip += 4;
return Continue.yes;
});
alias multiplyInstruction = (ref size_t ip, long[] memory, ref size_t rb) => ({
param(ip, memory, rb, 2) = param(ip, memory, rb, 0) * param(ip, memory, rb, 1);
ip += 4;
return Continue.yes;
});
alias inputInstruction = (ref size_t ip, long[] memory, ref size_t rb, ref input) => ({
Fiber.yield();
param(ip, memory, rb, 0) = input.front;
input.popFront();
ip += 2;
return Continue.yes;
});
alias outputInstruction = (ref size_t ip, long[] memory, ref size_t rb, ref output) => ({
output.put(param(ip, memory, rb, 0));
ip += 2;
return Continue.yes;
});
alias jumpIfTrueInstruction = (ref size_t ip, long[] memory, ref size_t rb) => ({
if (param(ip, memory, rb, 0) != 0)
ip = param(ip, memory, rb, 1).to!size_t;
else
ip += 3;
return Continue.yes;
});
alias jumpIfFalseInstruction = (ref size_t ip, long[] memory, ref size_t rb) => ({
if (param(ip, memory, rb, 0) == 0)
ip = param(ip, memory, rb, 1).to!size_t;
else
ip += 3;
return Continue.yes;
});
alias lessThanInstruction = (ref size_t ip, long[] memory, ref size_t rb) => ({
param(ip, memory, rb, 2) = param(ip, memory, rb, 0) < param(ip, memory, rb, 1) ? 1 : 0;
ip += 4;
return Continue.yes;
});
alias equalsInstruction = (ref size_t ip, long[] memory, ref size_t rb) => ({
param(ip, memory, rb, 2) = param(ip, memory, rb, 0) == param(ip, memory, rb, 1) ? 1 : 0;
ip += 4;
return Continue.yes;
});
alias adjustRelatieBaseInstruction = (ref size_t ip, long[] memory, ref size_t rb) => ({
rb += param(ip, memory, rb, 0);
ip += 2;
return Continue.yes;
});
alias haltInstruction = (ref size_t ip, long[] memory, ref size_t rb) => delegate() => Continue.no;
auto createFiber(Input, Output)(long[] memory, Input input, Output output)
{
return new Fiber(() {
size_t ip = 0;
size_t rb = 0;
while (true)
{
immutable opcode = memory[ip] % 100;
immutable _continue = [
1: addInstruction(ip, memory, rb),
2: multiplyInstruction(ip, memory, rb),
3: inputInstruction(ip, memory, rb, input),
4: outputInstruction(ip, memory, rb, output),
5: jumpIfTrueInstruction(ip, memory, rb),
6: jumpIfFalseInstruction(ip, memory, rb),
7: lessThanInstruction(ip, memory, rb),
8: equalsInstruction(ip, memory, rb),
9: adjustRelatieBaseInstruction(ip, memory, rb),
99: haltInstruction(ip, memory, rb),
][opcode]();
if (_continue == Continue.no)
break;
}
});
}
auto outputRange(alias fn)()
{
struct R
{
void put(Parameters!fn e)
{
fn(e);
}
}
return R();
}
@("basic math")
{
unittest
{
// given
auto memory = [1, 0, 0, 0, 99L];
long[] input = [];
// when
Scheduler().schedule(createFiber(memory, input, nullSink)).run();
// then
assert(memory == [2, 0, 0, 0, 99]);
}
unittest
{
// given
auto memory = [2, 3, 0, 3, 99L];
long[] input = [];
// when
Scheduler().schedule(createFiber(memory, input, nullSink)).run();
// then
assert(memory == [2, 3, 0, 6, 99]);
}
unittest
{
// given
auto memory = [2, 4, 4, 5, 99, 0L];
long[] input = [];
// when
Scheduler().schedule(createFiber(memory, input, nullSink)).run();
// then
assert(memory == [2, 4, 4, 5, 99, 9801]);
}
unittest
{
// given
auto memory = [1, 1, 1, 4, 99, 5, 6, 0, 99L];
long[] input = [];
// when
Scheduler().schedule(createFiber(memory, input, nullSink)).run();
// then
assert(memory == [30, 1, 1, 4, 2, 5, 6, 0, 99]);
}
unittest
{
// given
auto memory = [
1, 12, 2, 3, 1, 1, 2, 3, 1, 3, 4, 3, 1, 5, 0, 3, 2, 6, 1, 19, 1,
19, 5, 23, 2, 9, 23, 27, 1, 5, 27, 31, 1, 5, 31, 35, 1, 35, 13,
39, 1, 39, 9, 43, 1, 5, 43, 47, 1, 47, 6, 51, 1, 51, 13, 55, 1, 55,
9, 59, 1, 59, 13, 63, 2, 63, 13, 67, 1, 67, 10, 71, 1, 71, 6, 75,
2, 10, 75, 79, 2, 10, 79, 83, 1, 5, 83, 87, 2, 6, 87, 91, 1, 91, 6,
95, 1, 95, 13, 99, 2, 99, 13, 103, 1, 103, 9, 107, 1, 10, 107,
111, 2, 111, 13, 115, 1, 10, 115, 119, 1, 10, 119, 123, 2, 13,
123, 127, 2, 6, 127, 131, 1, 13, 131, 135, 1, 135, 2, 139, 1, 139,
6, 0, 99, 2, 0, 14, 0L
];
long[] input = [];
// when
Scheduler().schedule(createFiber(memory, input, nullSink)).run();
// then
assert(memory[0] == 4_090_689);
}
}
@(
"Using position mode, consider whether the input is equal to 8; output 1 (if it is) or 0 (if it is not).")
{
unittest
{
// given
auto memory = [3, 9, 8, 9, 10, 9, 4, 9, 99, -1, 8L];
long result;
auto input = only(8);
auto output = outputRange!((long e) { result = e; })();
// when
Scheduler().schedule(createFiber(memory, input, output)).run();
// then
assert(result == 1);
}
unittest
{
// given
auto memory = [3, 9, 8, 9, 10, 9, 4, 9, 99, -1, 8L];
long result;
auto input = only(7);
auto output = outputRange!((long e) { result = e; })();
// when
Scheduler().schedule(createFiber(memory, input, output)).run();
// then
assert(result == 0);
}
}
@(
"Using position mode, consider whether the input is less than 8; output 1 (if it is) or 0 (if it is not).")
{
unittest
{
// given
auto memory = [3, 9, 7, 9, 10, 9, 4, 9, 99, -1, 8L];
long result;
auto input = only(7);
auto output = outputRange!((long e) { result = e; })();
// when
Scheduler().schedule(createFiber(memory, input, output)).run();
// then
assert(result == 1);
}
unittest
{
// given
auto memory = [3, 9, 7, 9, 10, 9, 4, 9, 99, -1, 8L];
long result;
auto input = only(8);
auto output = outputRange!((long e) { result = e; })();
// when
Scheduler().schedule(createFiber(memory, input, output)).run();
// then
assert(result == 0);
}
}
@(
"Using immediate mode, consider whether the input is equal to 8; output 1 (if it is) or 0 (if it is not).")
{
unittest
{
// given
auto memory = [3, 3, 1108, -1, 8, 3, 4, 3, 99L];
long result;
auto input = only(8);
auto output = outputRange!((long e) { result = e; })();
// when
Scheduler().schedule(createFiber(memory, input, output)).run();
// then
assert(result == 1);
}
unittest
{
// given
auto memory = [3, 3, 1108, -1, 8, 3, 4, 3, 99L];
long result;
auto input = only(7);
auto output = outputRange!((long e) { result = e; })();
// when
Scheduler().schedule(createFiber(memory, input, output)).run();
// then
assert(result == 0);
}
}
@(
"Using immediate mode, consider whether the input is less than 8; output 1 (if it is) or 0 (if it is not).")
{
unittest
{
// given
auto memory = [3, 3, 1107, -1, 8, 3, 4, 3, 99L];
long result;
auto input = only(7);
auto output = outputRange!((long e) { result = e; })();
// when
Scheduler().schedule(createFiber(memory, input, output)).run();
// then
assert(result == 1);
}
unittest
{
// given
auto memory = [3, 3, 1107, -1, 8, 3, 4, 3, 99L];
long result;
auto input = only(8);
auto output = outputRange!((long e) { result = e; })();
// when
Scheduler().schedule(createFiber(memory, input, output)).run();
// then
assert(result == 0);
}
}
@(
"Consider whether the input is below 8, equal to 8 or above 8; output 999 (below), 1000 (equal) or 1001 (above)")
{
unittest
{
// given
auto memory = [
3, 21, 1008, 21, 8, 20, 1005, 20, 22, 107, 8, 21, 20, 1006, 20,
31, 1106, 0, 36, 98, 0, 0, 1002, 21, 125, 20, 4, 20, 1105, 1, 46,
104, 999, 1105, 1, 46, 1101, 1000, 1, 20, 4, 20, 1105, 1, 46, 98, 99L
];
long result;
auto input = only(7);
auto output = outputRange!((long e) { result = e; })();
// when
Scheduler().schedule(createFiber(memory, input, output)).run();
// then
assert(result == 999);
}
unittest
{
// given
auto memory = [
3, 21, 1008, 21, 8, 20, 1005, 20, 22, 107, 8, 21, 20, 1006, 20,
31, 1106, 0, 36, 98, 0, 0, 1002, 21, 125, 20, 4, 20, 1105, 1, 46,
104, 999, 1105, 1, 46, 1101, 1000, 1, 20, 4, 20, 1105, 1, 46, 98, 99L
];
long result;
auto input = only(8);
auto output = outputRange!((long e) { result = e; })();
// when
Scheduler().schedule(createFiber(memory, input, output)).run();
// then
assert(result == 1000);
}
unittest
{
// given
auto memory = [
3, 21, 1008, 21, 8, 20, 1005, 20, 22, 107, 8, 21, 20, 1006, 20,
31, 1106, 0, 36, 98, 0, 0, 1002, 21, 125, 20, 4, 20, 1105, 1, 46,
104, 999, 1105, 1, 46, 1101, 1000, 1, 20, 4, 20, 1105, 1, 46, 98, 99L
];
long result;
auto input = only(9);
auto output = outputRange!((long e) { result = e; })();
// when
Scheduler().schedule(createFiber(memory, input, output)).run();
// then
assert(result == 1001);
}
}
@("relative mode")
{
unittest
{
// given
immutable program = [
109, 1, 204, -1, 1001, 100, 1, 100, 1008, 100, 16, 101, 1006, 101, 0,
99L
];
long[] memory = program.dup;
memory.length = 128;
long[] result;
long[] input = [];
auto output = outputRange!((long e) { result ~= e; })();
// when
Scheduler().schedule(createFiber(memory, input, output)).run();
// then
assert(result == program);
}
}
@("large numbers")
{
unittest
{
// given
immutable program = [1102, 34_915_192, 34_915_192, 7, 4, 7, 99, 0L];
long[] memory = program.dup;
long result;
long[] input = [];
auto output = outputRange!((long e) { result = e; })();
// when
Scheduler().schedule(createFiber(memory, input, output)).run();
// then
assert(result < 10_000_000_000_000_000 && result > 999_999_999_999_999);
}
unittest
{
// given
immutable program = [104, 1_125_899_906_842_624, 99L];
long[] memory = program.dup;
long result;
long[] input = [];
auto output = outputRange!((long e) { result = e; })();
// when
Scheduler().schedule(createFiber(memory, input, output)).run();
// then
assert(result == 1_125_899_906_842_624);
}
}
|
D
|
/home/fluix/Documents/CMPT383/Final_Project/Round2/CMPT383-Raytracer/raytracer/server/target/debug/build/log-0313cea0e944b064/build_script_build-0313cea0e944b064: /home/fluix/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.11/build.rs
/home/fluix/Documents/CMPT383/Final_Project/Round2/CMPT383-Raytracer/raytracer/server/target/debug/build/log-0313cea0e944b064/build_script_build-0313cea0e944b064.d: /home/fluix/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.11/build.rs
/home/fluix/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.11/build.rs:
|
D
|
short
short_vars(uint i)
{
short v1;
short v2 = 10;
short v3 = 23u;
short v4 = 32762u;
short v5 = v2;
short v6;
short v7 = 1;
v7 = 20;
v6 = v4;
if (i == 1) { return v1; }
else if (i == 2) { return v2; }
else if (i == 3) { return v3; }
else if (i == 4) { return v4; }
else if (i == 5) { return v5; }
else if (i == 6) { return v6; }
else if (i == 7) { return v7; }
return 0;
}
ushort
ushort_vars(uint i)
{
ushort v1 = 2;
ushort v2 = 100u;
ushort v3 = v1;
ushort v4;
ushort v5;
ushort v6;
v4 = v2;
v5 = 10;
if (i == 0) { return 23; }
else if (i == 1) { return v1; }
else if (i == 2) { return v2; }
else if (i == 3) { return v3; }
else if (i == 4) { return v4; }
else if (i == 5) { return v5; }
else if (i == 6) { return v6; }
return 0;
}
byte
byte_vars(uint i)
{
byte v1;
byte v2 = 10;
byte v3 = 27u;
byte v4 = -120;
byte v5 = v2;
byte v6;
byte v7 = 1;
v7 = 20;
v6 = v4;
if (i == 1) { return v1; }
else if (i == 2) { return v2; }
else if (i == 3) { return v3; }
else if (i == 4) { return v4; }
else if (i == 5) { return v5; }
else if (i == 6) { return v6; }
else if (i == 7) { return v7; }
return 0;
}
ubyte
ubyte_vars(uint i)
{
ubyte v1;
ubyte v2 = 3;
ubyte v3 = 111u;
ubyte v4 = v2;
ubyte v5;
ubyte v6 = 1;
v5 = v3;
v6 = 20;
if (i == 1) { return v1; }
else if (i == 2) { return v2; }
else if (i == 3) { return v3; }
else if (i == 4) { return v4; }
else if (i == 5) { return v5; }
else if (i == 6) { return v6; }
return 0;
}
/*
* wrappers to allow call test functions with C calling convention
*/
extern (C)
{
short
call_short_vars(uint i)
{
return short_vars(i);
}
ushort
call_ushort_vars(uint i)
{
return ushort_vars(i);
}
byte
call_byte_vars(uint i)
{
return byte_vars(i);
}
ubyte
call_ubyte_vars(uint i)
{
return ubyte_vars(i);
}
}
|
D
|
import std.algorithm,
std.array,
std.csv,
std.file,
std.format,
std.getopt,
std.random,
std.stdio,
std.string,
std.typecons,
std.utf;
class MemorizerException : Exception
{
this ( string mes, string file = __FILE__, uint line = __LINE__ )
{
super( mes, file, line );
}
}
class App
{
enum AppName = "MEMORIZER";
enum Version = "0.0.1";
enum License = "LGPL-3.0";
enum AppInfo = "[%s v%s] %s".format( AppName, Version, License );
enum ErrorMes
{
NoFile = "File '%s' doesn't exist.",
LessQuestCount = "Quest count must be 1 or more.",
FileIOFail = "Failed to read/write file '%s'.",
NotUTF8 = "File '%s' is not utf-8."
}
alias DictionaryItem = Tuple!( string, "key", string, "value" );
protected static DictionaryItem[] loadQuestions ( string filepath )
{
string csvData;
try {
csvData = readText( filepath );
} catch ( FileException e ) {
throw new MemorizerException( ErrorMes.FileIOFail.format( filepath ) );
} catch ( UTFException e ) {
throw new MemorizerException( ErrorMes.NotUTF8.format( filepath ) );
}
DictionaryItem[] questions;
foreach ( record; csvData.csvReader!DictionaryItem ) {
questions ~= record;
}
return questions;
}
protected static bool checkAnswer ( string value, string answer )
{
auto result = (answer == value);
string formattedMes;
if ( result ) {
formattedMes = "\x1B[32m"~"CORRECT"~"\x1B[0m"~": %s == %s";
} else {
formattedMes = "\x1B[31m"~"WRONG"~"\x1B[0m"~": %s != %s";
}
formattedMes.writefln( value, answer );
return result;
}
protected bool _shouldExit;
protected string _filepath;
protected uint _questCount;
protected bool _questReverse;
protected bool _questRandomReverse;
this ( string[] args )
{
_shouldExit = false;
_filepath = "";
_questCount = uint.max;
parseArgs( args );
}
protected void goExit ()
{
_shouldExit = true;
}
protected void parseArgs ( string[] args )
{
auto opts = args.getopt(
"file|f" , "Path to CSV file." , &_filepath,
"count|c" , "Number of questions." , &_questCount,
"reverse|r" , "Reverses key and value." , &_questReverse,
"random-reverse", "Reverses a part of items.", &_questRandomReverse
);
if ( opts.helpWanted ) {
defaultGetoptPrinter( AppInfo, opts.options );
goExit();
} else if ( !exists( _filepath ) ) {
throw new MemorizerException( ErrorMes.NoFile.format( _filepath ) );
} else if ( _questCount == 0 ) {
throw new MemorizerException( ErrorMes.LessQuestCount );
}
}
protected void randomizeQuestions ( ref DictionaryItem[] questions )
{
questions = questions.randomShuffle().array;
questions.length = min( questions.length, _questCount );
}
protected void reverseQuestions ( ref DictionaryItem[] questions )
{
foreach ( ref q; questions ) {
if ( _questReverse ) {
swap( q.key, q.value );
}
if ( _questRandomReverse && !!dice(0.5,0.5) ) {
swap( q.key, q.value );
}
}
}
protected string showPrompt ( ulong index, ulong length, string key )
{
"%d/%d, %s".writefln( index, length, key );
"> ".write;
return readln().chomp;
}
void exec ()
{
if ( _shouldExit ) return;
auto questions = loadQuestions( _filepath );
randomizeQuestions( questions );
reverseQuestions( questions );
uint correctAnswers = 0;
uint wrongAnswers = 0;
foreach ( i,q; questions )
{
if ( _shouldExit ) break;
auto answer = showPrompt( i+1, questions.length, q.key );
if ( checkAnswer( answer, q.value ) ) {
correctAnswers++;
} else {
wrongAnswers++;
}
"--------------------".writeln;
}
auto ratio = correctAnswers*1.0/(correctAnswers+wrongAnswers);
"POINT: %f/100".writefln( ratio*100 );
}
}
int main( string[] args )
{
try {
new App( args ).exec();
return 0;
} catch ( MemorizerException e ) {
e.msg.writeln;
return -1;
}
}
|
D
|
/Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Vapor.build/Routing/RouteCollection.swift.o : /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Utilities/FileIO.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/FormDataCoder+HTTP.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/SessionData.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Utilities/Thread.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/URLEncoded.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Deprecated.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Commands/ServeCommand.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Commands/RoutesCommand.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Commands/BootCommand.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router+Method.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/SessionCache.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/ResponseCodable.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Request/RequestCodable.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router+Middleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Middleware/Middleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Middleware/CORSMiddleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Middleware/FileMiddleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Middleware/DateMiddleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Middleware/ErrorMiddleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/SessionsMiddleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router+LazyMiddleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/Response.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Utilities/AnyResponse.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Middleware/MiddlewareConfig.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Server/NIOServerConfig.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/SessionsConfig.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/ContentConfig.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Request/HTTPMethod+String.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router+Path.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/JSONCoder+Custom.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/Request+Session.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/Session.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Application.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/RouteCollection.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router+Function.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Services/VaporProvider.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/Responder.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/BasicResponder.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/ApplicationResponder.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/WebSocket/WebSocketResponder.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/PlaintextEncoder.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/HTTPMessageContainer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/ParametersContainer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/ContentContainer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/QueryContainer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/EngineRouter.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Server/Server.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Server/NIOServer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Server/RunningServer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/WebSocket/WebSocketServer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/WebSocket/NIOWebSocketServer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Error/Error.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Logging/Logger+LogError.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Error/AbortError.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/Sessions.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/KeyedCacheSessions.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/MemorySessions.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/ContentCoders.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Utilities/Exports.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/HTTPStatus.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/Redirect.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/SingleValueGet.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Services/Config+Default.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Commands/CommandConfig+Default.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Services/Services+Default.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Client/Client.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Client/FoundationClient.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/WebSocket/WebSocketClient.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/WebSocket/NIOWebSocketClient.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router+Content.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/Content.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Error/Abort.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Request/Request.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/View/Vapor+View.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOHTTP1.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOOpenSSL.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/HTTP.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOTLS.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Command.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Service.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Console.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Logging.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Routing.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/COperatingSystem.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Random.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/URLEncodedForm.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Validation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Crypto.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOFoundationCompat.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/WebSocket.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOWebSocket.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/DatabaseKit.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/TemplateKit.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Multipart.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOSHA1/include/c_nio_sha1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/asn1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/tls1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/dtls1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pkcs12.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl2.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pem2.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl23.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl3.h /usr/local/Cellar/libressl/2.7.4/include/openssl/x509v3.h /usr/local/Cellar/libressl/2.7.4/include/openssl/md5.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pkcs7.h /usr/local/Cellar/libressl/2.7.4/include/openssl/x509.h /usr/local/Cellar/libressl/2.7.4/include/openssl/sha.h /usr/local/Cellar/libressl/2.7.4/include/openssl/dsa.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ecdsa.h /usr/local/Cellar/libressl/2.7.4/include/openssl/rsa.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOZlib/include/c_nio_zlib.h /usr/local/Cellar/libressl/2.7.4/include/openssl/obj_mac.h /usr/local/Cellar/libressl/2.7.4/include/openssl/hmac.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ec.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /usr/local/Cellar/libressl/2.7.4/include/openssl/rand.h /usr/local/Cellar/libressl/2.7.4/include/openssl/conf.h /usr/local/Cellar/libressl/2.7.4/include/openssl/opensslconf.h /usr/local/Cellar/libressl/2.7.4/include/openssl/dh.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ecdh.h /usr/local/Cellar/libressl/2.7.4/include/openssl/lhash.h /usr/local/Cellar/libressl/2.7.4/include/openssl/stack.h /usr/local/Cellar/libressl/2.7.4/include/openssl/safestack.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl.h /Users/work/Projects/Hello/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/CNIOOpenSSL/include/c_nio_openssl.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pem.h /usr/local/Cellar/libressl/2.7.4/include/openssl/bn.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /usr/local/Cellar/libressl/2.7.4/include/openssl/bio.h /usr/local/Cellar/libressl/2.7.4/include/openssl/crypto.h /usr/local/Cellar/libressl/2.7.4/include/openssl/srtp.h /usr/local/Cellar/libressl/2.7.4/include/openssl/evp.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/2.7.4/include/openssl/buffer.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOHTTPParser/include/c_nio_http_parser.h /usr/local/Cellar/libressl/2.7.4/include/openssl/err.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /usr/local/Cellar/libressl/2.7.4/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/2.7.4/include/openssl/objects.h /usr/local/Cellar/libressl/2.7.4/include/openssl/opensslv.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /usr/local/Cellar/libressl/2.7.4/include/openssl/x509_vfy.h /Users/work/Projects/Hello/.build/checkouts/swift-nio-ssl-support.git--2359138821295600615/module.modulemap /Users/work/Projects/Hello/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Users/work/Projects/Hello/.build/checkouts/crypto.git-7980259129511365902/Sources/libbcrypt/include/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
/Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Vapor.build/RouteCollection~partial.swiftmodule : /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Utilities/FileIO.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/FormDataCoder+HTTP.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/SessionData.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Utilities/Thread.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/URLEncoded.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Deprecated.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Commands/ServeCommand.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Commands/RoutesCommand.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Commands/BootCommand.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router+Method.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/SessionCache.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/ResponseCodable.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Request/RequestCodable.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router+Middleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Middleware/Middleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Middleware/CORSMiddleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Middleware/FileMiddleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Middleware/DateMiddleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Middleware/ErrorMiddleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/SessionsMiddleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router+LazyMiddleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/Response.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Utilities/AnyResponse.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Middleware/MiddlewareConfig.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Server/NIOServerConfig.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/SessionsConfig.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/ContentConfig.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Request/HTTPMethod+String.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router+Path.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/JSONCoder+Custom.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/Request+Session.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/Session.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Application.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/RouteCollection.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router+Function.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Services/VaporProvider.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/Responder.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/BasicResponder.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/ApplicationResponder.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/WebSocket/WebSocketResponder.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/PlaintextEncoder.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/HTTPMessageContainer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/ParametersContainer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/ContentContainer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/QueryContainer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/EngineRouter.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Server/Server.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Server/NIOServer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Server/RunningServer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/WebSocket/WebSocketServer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/WebSocket/NIOWebSocketServer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Error/Error.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Logging/Logger+LogError.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Error/AbortError.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/Sessions.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/KeyedCacheSessions.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/MemorySessions.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/ContentCoders.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Utilities/Exports.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/HTTPStatus.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/Redirect.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/SingleValueGet.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Services/Config+Default.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Commands/CommandConfig+Default.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Services/Services+Default.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Client/Client.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Client/FoundationClient.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/WebSocket/WebSocketClient.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/WebSocket/NIOWebSocketClient.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router+Content.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/Content.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Error/Abort.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Request/Request.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/View/Vapor+View.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOHTTP1.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOOpenSSL.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/HTTP.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOTLS.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Command.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Service.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Console.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Logging.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Routing.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/COperatingSystem.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Random.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/URLEncodedForm.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Validation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Crypto.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOFoundationCompat.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/WebSocket.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOWebSocket.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/DatabaseKit.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/TemplateKit.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Multipart.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOSHA1/include/c_nio_sha1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/asn1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/tls1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/dtls1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pkcs12.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl2.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pem2.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl23.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl3.h /usr/local/Cellar/libressl/2.7.4/include/openssl/x509v3.h /usr/local/Cellar/libressl/2.7.4/include/openssl/md5.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pkcs7.h /usr/local/Cellar/libressl/2.7.4/include/openssl/x509.h /usr/local/Cellar/libressl/2.7.4/include/openssl/sha.h /usr/local/Cellar/libressl/2.7.4/include/openssl/dsa.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ecdsa.h /usr/local/Cellar/libressl/2.7.4/include/openssl/rsa.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOZlib/include/c_nio_zlib.h /usr/local/Cellar/libressl/2.7.4/include/openssl/obj_mac.h /usr/local/Cellar/libressl/2.7.4/include/openssl/hmac.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ec.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /usr/local/Cellar/libressl/2.7.4/include/openssl/rand.h /usr/local/Cellar/libressl/2.7.4/include/openssl/conf.h /usr/local/Cellar/libressl/2.7.4/include/openssl/opensslconf.h /usr/local/Cellar/libressl/2.7.4/include/openssl/dh.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ecdh.h /usr/local/Cellar/libressl/2.7.4/include/openssl/lhash.h /usr/local/Cellar/libressl/2.7.4/include/openssl/stack.h /usr/local/Cellar/libressl/2.7.4/include/openssl/safestack.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl.h /Users/work/Projects/Hello/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/CNIOOpenSSL/include/c_nio_openssl.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pem.h /usr/local/Cellar/libressl/2.7.4/include/openssl/bn.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /usr/local/Cellar/libressl/2.7.4/include/openssl/bio.h /usr/local/Cellar/libressl/2.7.4/include/openssl/crypto.h /usr/local/Cellar/libressl/2.7.4/include/openssl/srtp.h /usr/local/Cellar/libressl/2.7.4/include/openssl/evp.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/2.7.4/include/openssl/buffer.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOHTTPParser/include/c_nio_http_parser.h /usr/local/Cellar/libressl/2.7.4/include/openssl/err.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /usr/local/Cellar/libressl/2.7.4/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/2.7.4/include/openssl/objects.h /usr/local/Cellar/libressl/2.7.4/include/openssl/opensslv.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /usr/local/Cellar/libressl/2.7.4/include/openssl/x509_vfy.h /Users/work/Projects/Hello/.build/checkouts/swift-nio-ssl-support.git--2359138821295600615/module.modulemap /Users/work/Projects/Hello/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Users/work/Projects/Hello/.build/checkouts/crypto.git-7980259129511365902/Sources/libbcrypt/include/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
/Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Vapor.build/RouteCollection~partial.swiftdoc : /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Utilities/FileIO.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/FormDataCoder+HTTP.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/SessionData.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Utilities/Thread.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/URLEncoded.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Deprecated.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Commands/ServeCommand.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Commands/RoutesCommand.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Commands/BootCommand.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router+Method.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/SessionCache.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/ResponseCodable.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Request/RequestCodable.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router+Middleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Middleware/Middleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Middleware/CORSMiddleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Middleware/FileMiddleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Middleware/DateMiddleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Middleware/ErrorMiddleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/SessionsMiddleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router+LazyMiddleware.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/Response.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Utilities/AnyResponse.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Middleware/MiddlewareConfig.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Server/NIOServerConfig.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/SessionsConfig.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/ContentConfig.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Request/HTTPMethod+String.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router+Path.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/JSONCoder+Custom.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/Request+Session.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/Session.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Application.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/RouteCollection.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router+Function.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Services/VaporProvider.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/Responder.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/BasicResponder.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/ApplicationResponder.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/WebSocket/WebSocketResponder.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/PlaintextEncoder.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/HTTPMessageContainer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/ParametersContainer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/ContentContainer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/QueryContainer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/EngineRouter.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Server/Server.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Server/NIOServer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Server/RunningServer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/WebSocket/WebSocketServer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/WebSocket/NIOWebSocketServer.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Error/Error.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Logging/Logger+LogError.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Error/AbortError.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/Sessions.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/KeyedCacheSessions.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Sessions/MemorySessions.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/ContentCoders.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Utilities/Exports.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/HTTPStatus.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Response/Redirect.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/SingleValueGet.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Services/Config+Default.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Commands/CommandConfig+Default.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Services/Services+Default.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Client/Client.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Client/FoundationClient.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/WebSocket/WebSocketClient.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/WebSocket/NIOWebSocketClient.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Routing/Router+Content.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Content/Content.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Error/Abort.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/Request/Request.swift /Users/work/Projects/Hello/.build/checkouts/vapor.git-5492988889259800272/Sources/Vapor/View/Vapor+View.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOHTTP1.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOOpenSSL.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/HTTP.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOTLS.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Command.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Service.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Console.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Logging.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Routing.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/COperatingSystem.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Random.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/URLEncodedForm.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Validation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Crypto.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOFoundationCompat.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/WebSocket.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/NIOWebSocket.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/DatabaseKit.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/TemplateKit.swiftmodule /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/Multipart.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOSHA1/include/c_nio_sha1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/asn1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/tls1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/dtls1.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pkcs12.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl2.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pem2.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl23.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl3.h /usr/local/Cellar/libressl/2.7.4/include/openssl/x509v3.h /usr/local/Cellar/libressl/2.7.4/include/openssl/md5.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pkcs7.h /usr/local/Cellar/libressl/2.7.4/include/openssl/x509.h /usr/local/Cellar/libressl/2.7.4/include/openssl/sha.h /usr/local/Cellar/libressl/2.7.4/include/openssl/dsa.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ecdsa.h /usr/local/Cellar/libressl/2.7.4/include/openssl/rsa.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOZlib/include/c_nio_zlib.h /usr/local/Cellar/libressl/2.7.4/include/openssl/obj_mac.h /usr/local/Cellar/libressl/2.7.4/include/openssl/hmac.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ec.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /usr/local/Cellar/libressl/2.7.4/include/openssl/rand.h /usr/local/Cellar/libressl/2.7.4/include/openssl/conf.h /usr/local/Cellar/libressl/2.7.4/include/openssl/opensslconf.h /usr/local/Cellar/libressl/2.7.4/include/openssl/dh.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ecdh.h /usr/local/Cellar/libressl/2.7.4/include/openssl/lhash.h /usr/local/Cellar/libressl/2.7.4/include/openssl/stack.h /usr/local/Cellar/libressl/2.7.4/include/openssl/safestack.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ssl.h /Users/work/Projects/Hello/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/CNIOOpenSSL/include/c_nio_openssl.h /usr/local/Cellar/libressl/2.7.4/include/openssl/pem.h /usr/local/Cellar/libressl/2.7.4/include/openssl/bn.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /usr/local/Cellar/libressl/2.7.4/include/openssl/bio.h /usr/local/Cellar/libressl/2.7.4/include/openssl/crypto.h /usr/local/Cellar/libressl/2.7.4/include/openssl/srtp.h /usr/local/Cellar/libressl/2.7.4/include/openssl/evp.h /usr/local/Cellar/libressl/2.7.4/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/2.7.4/include/openssl/buffer.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOHTTPParser/include/c_nio_http_parser.h /usr/local/Cellar/libressl/2.7.4/include/openssl/err.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /usr/local/Cellar/libressl/2.7.4/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/2.7.4/include/openssl/objects.h /usr/local/Cellar/libressl/2.7.4/include/openssl/opensslv.h /Users/work/Projects/Hello/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /usr/local/Cellar/libressl/2.7.4/include/openssl/x509_vfy.h /Users/work/Projects/Hello/.build/checkouts/swift-nio-ssl-support.git--2359138821295600615/module.modulemap /Users/work/Projects/Hello/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/work/Projects/Hello/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Users/work/Projects/Hello/.build/checkouts/crypto.git-7980259129511365902/Sources/libbcrypt/include/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
|
D
|
// This file is part of Visual D
//
// Visual D integrates the D programming language into Visual Studio
// Copyright (c) 2010 by Rainer Schuetze, All Rights Reserved
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
module visuald.viewfilter;
import visuald.windows;
import visuald.comutil;
import visuald.logutil;
import visuald.hierutil;
import visuald.fileutil;
import visuald.stringutil;
import visuald.pkgutil;
import visuald.dpackage;
import visuald.dproject;
import visuald.hierarchy;
import visuald.chiernode;
import visuald.dimagelist;
import visuald.completion;
import visuald.simpleparser;
import visuald.intellisense;
import visuald.searchsymbol;
import visuald.expansionprovider;
import visuald.dlangsvc;
import visuald.winctrl;
import visuald.tokenreplace;
import visuald.cppwizard;
import visuald.config;
import visuald.build;
import visuald.help;
import visuald.lexutil;
import vdc.lexer;
import sdk.port.vsi;
import sdk.vsi.textmgr;
import sdk.vsi.textmgr2;
import sdk.vsi.stdidcmd;
import sdk.vsi.vsshell;
import sdk.vsi.vsshell80;
import sdk.vsi.vsdbgcmd;
import sdk.vsi.vsdebugguids;
import sdk.vsi.msdbg;
import stdext.array;
import stdext.path;
import stdext.string;
import std.string;
import std.ascii;
import std.utf;
import std.conv;
import std.algorithm;
import std.array;
import std.file;
import std.path;
///////////////////////////////////////////////////////////////////////////////
interface IVsCustomDataTip : IUnknown
{
static const GUID iid = uuid("80DD0557-F6FE-48e3-9651-398C5E7D8D78");
HRESULT DisplayDataTip();
}
// version = tip;
class ViewFilter : DisposingComObject, IVsTextViewFilter, IOleCommandTarget,
IVsTextViewEvents, IVsExpansionEvents
{
CodeWindowManager mCodeWinMgr;
IVsTextView mView;
uint mCookieTextViewEvents;
IOleCommandTarget mNextTarget;
int mLastHighlightBracesLine;
ViewCol mLastHighlightBracesCol;
version(tip)
TextTipData mTextTipData;
this(CodeWindowManager mgr, IVsTextView view)
{
mCodeWinMgr = mgr;
mView = addref(view);
mCookieTextViewEvents = Advise!(IVsTextViewEvents)(mView, this);
mView.AddCommandFilter(this, &mNextTarget);
hookWindowProc(cast(HWND) mView.GetWindowHandle());
version(tip)
mTextTipData = addref(newCom!TextTipData);
}
~this()
{
}
override void Dispose()
{
if(mView)
{
mView.RemoveCommandFilter(this);
if(mCookieTextViewEvents)
Unadvise!(IVsTextViewEvents)(mView, mCookieTextViewEvents);
mView = release(mView);
}
version(tip)
if(mTextTipData)
{
// we need to break the circular reference TextTipData<->IVsMethodTipWindow
mTextTipData.Dispose();
mTextTipData = release(mTextTipData);
}
unhookWindowProc();
mCodeWinMgr = null;
}
WNDPROC mPrevProc;
HWND mHwnd;
static ViewFilter[HWND] sHooks;
extern(Windows) static int WindowProcHook(HWND hWnd, uint uMsg, WPARAM wParam, LPARAM lParam)
{
WNDPROC proc;
ViewFilter* pvf = hWnd in sHooks;
if (pvf)
proc = pvf.mPrevProc;
if(!proc)
proc = &DefWindowProcA;
int res = proc(hWnd,uMsg,wParam,lParam);
if(Package.GetGlobalOptions().showCoverageMargin)
if(uMsg == WM_PAINT && pvf)
pvf.mCodeWinMgr.mSource.mColorizer.drawCoverageOverlay(hWnd, wParam, lParam, pvf.mView);
return res;
}
bool hookWindowProc(HWND hwnd)
{
if(mHwnd)
return false;
mPrevProc = cast(WNDPROC)GetWindowLongPtr(hwnd, GWL_WNDPROC);
mHwnd = hwnd;
sHooks[mHwnd] = this;
SetWindowLongPtr(hwnd, GWL_WNDPROC, cast(uint) &WindowProcHook);
return true;
}
bool unhookWindowProc()
{
if(!mHwnd)
return false;
SetWindowLongPtr(mHwnd, GWL_WNDPROC, cast(uint) mPrevProc);
sHooks.remove(mHwnd);
mHwnd = null;
mPrevProc = null;
return true;
}
override HRESULT QueryInterface(in IID* riid, void** pvObject)
{
if(queryInterface!(IVsTextViewFilter) (this, riid, pvObject))
return S_OK;
if(queryInterface!(IVsTextViewEvents) (this, riid, pvObject))
return S_OK;
if(queryInterface!(IOleCommandTarget) (this, riid, pvObject))
return S_OK;
if(queryInterface!(IVsExpansionEvents) (this, riid, pvObject))
return S_OK;
return super.QueryInterface(riid, pvObject);
}
// IOleCommandTarget //////////////////////////////////////
override int QueryStatus( /* [unique][in] */ in GUID *pguidCmdGroup,
/* [in] */ in uint cCmds,
/* [out][in][size_is] */ OLECMD *prgCmds,
/* [unique][out][in] */ OLECMDTEXT *pCmdText)
{
// mixin(LogCallMix);
for (uint i = 0; i < cCmds; i++)
{
int rc = QueryCommandStatus(pguidCmdGroup, prgCmds[i].cmdID);
if(rc == E_FAIL)
{
if(mNextTarget)
return mNextTarget.QueryStatus(pguidCmdGroup, cCmds, prgCmds, pCmdText);
return rc;
}
prgCmds[i].cmdf = cast(uint)rc;
}
return S_OK;
}
override int Exec( /* [unique][in] */ in GUID *pguidCmdGroup,
/* [in] */ in uint nCmdID,
/* [in] */ in uint nCmdexecopt,
/* [unique][in] */ in VARIANT *pvaIn,
/* [unique][out][in] */ VARIANT *pvaOut)
{
if(*pguidCmdGroup == CMDSETID_StandardCommandSet2K && nCmdID == 1627 /*OutputPaneCombo*/)
return OLECMDERR_E_NOTSUPPORTED; // do not litter output
debug
{
bool logit = true;
if(*pguidCmdGroup == CMDSETID_StandardCommandSet2K)
{
switch(nCmdID)
{
case ECMD_HANDLEIMEMESSAGE:
logit = false;
break;
default:
break;
}
}
else if(*pguidCmdGroup == guidVSDebugCommand)
{
switch(nCmdID)
{
case cmdidOutputPaneCombo:
case cmdidProcessList:
case cmdidThreadList:
case cmdidStackFrameList:
logit = false;
break;
default:
break;
}
}
if(logit)
logCall("%s.Exec(this=%s, pguidCmdGroup=%s, nCmdId=%d: %s)",
this, cast(void*) this, _toLog(pguidCmdGroup), nCmdID, cmd2string(*pguidCmdGroup, nCmdID));
}
Package.GetLanguageService().OnExec();
ushort lo = (nCmdexecopt & 0xffff);
ushort hi = (nCmdexecopt >> 16);
bool wasCompletorActive = mCodeWinMgr.mSource.IsCompletorActive();
bool gotEnterKey = false;
ExpansionProvider ep = GetExpansionProvider();
if(ep) //if (ep.InTemplateEditingMode)
if (ep.HandlePreExec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut))
return S_OK;
if(*pguidCmdGroup == CMDSETID_StandardCommandSet97)
{
switch (nCmdID)
{
case cmdidPasteNextTBXCBItem:
if(PasteFromRing() == S_OK)
return S_OK;
break;
case cmdidGotoDefn:
return HandleGotoDef();
case cmdidF1Help:
return HandleHelp();
default:
break;
}
}
if(*pguidCmdGroup == CMDSETID_StandardCommandSet2K)
{
switch (nCmdID)
{
case ECMD_RETURN:
gotEnterKey = true;
break;
case ECMD_INVOKESNIPPETFROMSHORTCUT:
return HandleSnippet();
case ECMD_PARAMINFO:
return HandleMethodTip();
case ECMD_FORMATSELECTION:
return ReindentLines();
case ECMD_COMMENTBLOCK:
case ECMD_COMMENT_BLOCK:
return CommentLines(Source.ForceComment);
case ECMD_UNCOMMENTBLOCK:
case ECMD_UNCOMMENT_BLOCK:
return CommentLines(Source.ForceUncomment);
case ECMD_COMPLETEWORD:
case ECMD_AUTOCOMPLETE:
if(mCodeWinMgr.mSource.IsCompletorActive())
moreCompletions();
else
initCompletion(true);
return S_OK;
case ECMD_SURROUNDWITH:
if (mView && ep)
//ep.DisplayExpansionBrowser(mView, "Insert Snippet", ["type1", "type2"], true, ["kind1", "kind2"], true);
ep.DisplayExpansionBrowser(mView, "Surround with", [], true, [], true);
break;
case ECMD_INSERTSNIPPET:
if (mView && ep)
//ep.DisplayExpansionBrowser(mView, "Insert Snippet", ["type1", "type2"], true, ["kind1", "kind2"], true);
ep.DisplayExpansionBrowser(mView, "Insert Snippet", [], false, [], false);
break;
case ECMD_COMPILE:
return CompileDoc(false, false);
case ECMD_GOTOBRACE:
return GotoMatchingPair(false);
case ECMD_GOTOBRACE_EXT:
return GotoMatchingPair(true);
case ECMD_OUTLN_STOP_HIDING_ALL:
return mCodeWinMgr.mSource.StopOutlining();
case ECMD_OUTLN_TOGGLE_ALL:
return mCodeWinMgr.mSource.ToggleOutlining();
default:
break;
}
}
if(g_commandSetCLSID == *pguidCmdGroup)
{
switch (nCmdID)
{
case CmdShowScope:
return showCurrentScope();
case CmdShowMethodTip:
return HandleMethodTip();
case CmdToggleComment:
return CommentLines(Source.AutoComment);
case CmdConvSelection:
return ConvertSelection();
case CmdCompileAndRun:
return CompileDoc(true, true);
case CmdCollapseUnittest:
return mCodeWinMgr.mSource.CollapseDisabled(true, false);
case CmdCollapseDisabled:
return mCodeWinMgr.mSource.CollapseDisabled(false, true);
default:
break;
}
}
/+
switch (lo)
{
case OLECMDEXECOPT.OLECMDEXECOPT_SHOWHELP:
if((nCmdexecopt >> 16) == VsMenus.VSCmdOptQueryParameterList) {
return QueryParameterList(ref guidCmdGroup, nCmdId, nCmdexecopt, pvaIn, pvaOut);
}
break;
default:
// On every command, update the tip window if it's active.
if(this.textTipData != null && this.textTipData.IsActive())
textTipData.CheckCaretPosition(this.textView);
int rc = 0;
try {
rc = ExecCommand(ref guidCmdGroup, nCmdId, nCmdexecopt, pvaIn, pvaOut);
} catch (COMException e) {
int hr = e.ErrorCode;
// We silently fail on the following errors because the user has
// most likely already been prompted with things like source control checkout
// dialogs and so forth.
if(hr != (int)TextBufferErrors.BUFFER_E_LOCKED &&
hr != (int)TextBufferErrors.BUFFER_E_READONLY &&
hr != (int)TextBufferErrors.BUFFER_E_READONLY_REGION &&
hr != (int)TextBufferErrors.BUFFER_E_SCC_READONLY) {
throw;
}
}
return rc;
}
return OLECMDERR_E_NOTSUPPORTED;
+/
int rc = mNextTarget.Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
if (ep)
if (ep.HandlePostExec(pguidCmdGroup, nCmdID, nCmdexecopt, gotEnterKey, pvaIn, pvaOut))
return rc;
if(*pguidCmdGroup == CMDSETID_StandardCommandSet97)
{
switch (nCmdID)
{
case cmdidPasteNextTBXCBItem:
case cmdidPaste:
ReindentPastedLines();
break;
default:
break;
}
}
if(*pguidCmdGroup == CMDSETID_StandardCommandSet2K)
{
switch (nCmdID)
{
case ECMD_RETURN:
if(!wasCompletorActive)
HandleSmartIndent('\n');
break;
case ECMD_LEFT:
case ECMD_RIGHT:
stopCompletions();
goto case ECMD_UP;
case ECMD_BACKSPACE:
if(mCodeWinMgr.mSource.IsCompletorActive())
initCompletion(false);
goto case;
case ECMD_UP:
case ECMD_DOWN:
if(mCodeWinMgr.mSource.IsMethodTipActive())
HandleMethodTip();
break;
case ECMD_TYPECHAR:
dchar ch = pvaIn.uiVal;
if(ch == '.' && Package.GetGlobalOptions().expandTrigger >= 1 && Package.GetGlobalOptions().expandFromSemantics)
initCompletion(false);
else if(mCodeWinMgr.mSource.IsCompletorActive() || Package.GetGlobalOptions().expandTrigger >= 2)
{
if(isAlphaNum(ch) || ch == '_')
initCompletion(false);
else
stopCompletions();
}
if(ch == '{' || ch == '}' || ch == '[' || ch == ']' ||
ch == 'n' || ch == 't' || ch == 'y') // last characters of "in", "out" and "body"
HandleSmartIndent(ch);
if(mCodeWinMgr.mSource.IsMethodTipActive())
{
if(ch == ',' || ch == ')')
HandleMethodTip();
}
else if(ch == '(')
{
LANGPREFERENCES langPrefs;
if(GetUserPreferences(&langPrefs) == S_OK && langPrefs.fAutoListParams)
_HandleMethodTip(false);
}
break;
default:
if(nCmdID < ECMD_FINAL && nCmdID != ECMD_HANDLEIMEMESSAGE)
stopCompletions();
break;
}
}
// delayed into idle: HighlightMatchingPairs();
return rc;
}
//////////////////////////////
HRESULT CompileDoc(bool rdmd, bool run)
{
IVsUIShellOpenDocument pIVsUIShellOpenDocument = queryService!(IVsUIShellOpenDocument);
if(!pIVsUIShellOpenDocument)
return returnError(E_FAIL);
scope(exit) release(pIVsUIShellOpenDocument);
string fname = mCodeWinMgr.mSource.GetFileName();
wchar* wfname = _toUTF16z(fname);
string addopt;
Config cfg;
CFileNode pFile;
IVsUIHierarchy pUIH;
uint itemid;
IServiceProvider pSP;
VSDOCINPROJECT docInProj;
if(pIVsUIShellOpenDocument.IsDocumentInAProject(wfname, &pUIH, &itemid, &pSP, &docInProj) != S_OK)
return S_OK;
scope(exit) release(pSP);
scope(exit) release(pUIH);
if(!pUIH)
return returnError(E_FAIL);
Project proj = qi_cast!Project(pUIH);
scope(exit) release(proj);
BSTR bstrSelText;
string selText;
if(mView.GetSelectedText(&bstrSelText) == S_OK)
selText = detachBSTR(bstrSelText);
if(!proj)
{
// not in Visual D project, but in workspace project
ProjectFactory factory = newCom!ProjectFactory(Package.s_instance);
string filename = normalizeDir(tempDir()) ~ "__compile__.vdproj";
string srcfile = Package.GetGlobalOptions().VisualDInstallDir ~ "Templates/ProjectItems/ConsoleApp/ConsoleApp.visualdproj";
proj = newCom!Project(factory, "__compile__", filename, "Win32", "Debug").addref();
pFile = newCom!CFileNode(fname);
proj.GetProjectNode().Add(pFile);
IVsCfgProvider pCfgProvider;
IVsCfg icfg;
scope(exit) release(pCfgProvider);
scope(exit) release(icfg);
if(proj.GetCfgProvider(&pCfgProvider) == S_OK)
if(pCfgProvider.GetCfgs(1, &icfg, null, null) == S_OK)
cfg = qi_cast!Config(icfg);
if(cfg)
{
cfg.GetProjectOptions().outdir = normalizeDir(tempDir()) ~ "__vdcompile";
cfg.GetProjectOptions().release = false;
}
string modname = getModuleDeclarationName(fname);
if(modname.length)
{
// add the path that seems to be the root of the package
string ipath;
while(findSkip(modname, "."))
ipath ~= "/..";
if(ipath.length)
addopt ~= " -I" ~ normalizeDir(dirName(fname)) ~ ipath[1..$];
}
}
else
{
CHierNode pNode = proj.VSITEMID2Node(itemid);
if(!pNode)
return returnError(E_INVALIDARG);
pFile = cast(CFileNode) pNode;
if(!pFile)
return S_OK;
auto solutionBuildManager = queryService!(IVsSolutionBuildManager)();
scope(exit) release(solutionBuildManager);
IVsProjectCfg activeCfg;
scope(exit) release(activeCfg);
if(solutionBuildManager)
if(solutionBuildManager.FindActiveProjectCfg(null, null, proj, &activeCfg) == S_OK)
cfg = qi_cast!Config(activeCfg);
}
if(!cfg || !pFile)
return S_OK;
if(pFile.SaveDoc(SLNSAVEOPT_SaveIfDirty) != S_OK)
return returnError(E_FAIL);
mCodeWinMgr.mSource.OnBufferSave(null); // save current modification position
scope(exit) release(cfg);
string stool = cfg.GetStaticCompileTool(pFile, cfg.getCfgName());
if(stool == "DMD")
stool = "DMDsingle";
if(stool == "DMDsingle")
{
if(rdmd)
{
stool = "RDMD";
if(selText.length)
{
string[] lines = splitLines(selText);
foreach(ln; lines)
{
string line = strip(detab(ln));
if(line.length)
addopt ~= " \"--eval=" ~ replace(line, "\"", "\\\\\\\"") ~ "\"";
}
}
}
else if(run)
addopt ~= " -run";
}
if(stool == "RDMD")
addopt = " " ~ Package.GetGlobalOptions().compileAndRunOpts ~ addopt;
string cmd = cfg.GetCompileCommand(pFile, !run, stool, addopt);
if(cmd.length)
{
cmd ~= "if not errorlevel 1 echo Compilation successful.\n";
string workdir = cfg.GetProjectDir();
string outfile = cfg.GetOutputFile(pFile, stool);
string cmdfile = makeFilenameAbsolute(outfile ~ ".syntax", workdir);
removeCachedFileTime(makeFilenameAbsolute(outfile, workdir));
auto pane = getBuildOutputPane();
scope(exit) release(pane);
clearBuildOutputPane();
if(pane)
pane.Activate();
HRESULT hr = RunCustomBuildBatchFile(outfile, cmdfile, cmd, pane, cfg.getBuilder());
if(run)
Package.GetGlobalOptions().addExecutionPath(cfg.GetProjectDir(), null);
}
return S_OK;
}
//////////////////////////////
void initCompletion(bool autoInsert)
{
CompletionSet cs = mCodeWinMgr.mSource.GetCompletionSet();
Declarations decl = new Declarations;
decl.StartExpansions(mView, mCodeWinMgr.mSource, autoInsert);
}
void moreCompletions()
{
CompletionSet cs = mCodeWinMgr.mSource.GetCompletionSet();
Declarations decl = cs.mDecls;
decl.MoreExpansions(mView, mCodeWinMgr.mSource);
}
void stopCompletions()
{
if(CompletionSet cs = mCodeWinMgr.mSource.GetCompletionSet())
if(Declarations decl = cs.mDecls)
decl.StopExpansions();
mCodeWinMgr.mSource.DismissCompletor();
}
int QueryCommandStatus(in GUID *guidCmdGroup, uint cmdID)
{
if(*guidCmdGroup == CMDSETID_StandardCommandSet97)
{
switch (cmdID)
{
case cmdidPasteNextTBXCBItem:
return OLECMDF_SUPPORTED | OLECMDF_ENABLED;
case cmdidGotoDefn:
//case VsCommands.GotoDecl:
//case VsCommands.GotoRef:
return OLECMDF_SUPPORTED | OLECMDF_ENABLED;
default:
break;
}
}
if(*guidCmdGroup == CMDSETID_StandardCommandSet2K)
{
switch (cmdID)
{
case ECMD_PARAMINFO:
case ECMD_FORMATSELECTION:
case ECMD_COMMENTBLOCK:
case ECMD_COMMENT_BLOCK:
case ECMD_UNCOMMENTBLOCK:
case ECMD_UNCOMMENT_BLOCK:
case ECMD_COMPLETEWORD:
case ECMD_INSERTSNIPPET:
case ECMD_INVOKESNIPPETFROMSHORTCUT:
case ECMD_SURROUNDWITH:
case ECMD_AUTOCOMPLETE:
case ECMD_GOTOBRACE:
case ECMD_GOTOBRACE_EXT:
case ECMD_OUTLN_STOP_HIDING_ALL:
case ECMD_OUTLN_TOGGLE_ALL:
case ECMD_COMPILE:
return OLECMDF_SUPPORTED | OLECMDF_ENABLED;
default:
break;
}
}
if(g_commandSetCLSID == *guidCmdGroup)
{
switch (cmdID)
{
case CmdShowScope:
case CmdShowMethodTip:
case CmdToggleComment:
case CmdConvSelection:
case CmdCompileAndRun:
case CmdCollapseUnittest:
case CmdCollapseDisabled:
return OLECMDF_SUPPORTED | OLECMDF_ENABLED;
default:
break;
}
}
return E_FAIL;
}
int HighlightComment(wstring txt, int line, ref ViewCol idx, out int otherLine, out int otherIndex)
{
int iState, tokidx;
uint pos;
size_t idxpos = idx;
if(Lexer.isStartingComment(txt, idxpos))
{
idx = cast(ViewCol) idxpos;
tokidx = mCodeWinMgr.mSource.FindLineToken(line, idx, iState, pos);
if(pos == idx)
{
int startState = iState;
if(dLex.scan(iState, txt, pos) == TokenCat.Comment)
{
//if(iState == Lexer.toState(Lexer.State.kNestedComment, 1, 0) ||
if(iState == Lexer.State.kWhite)
{
// terminated on same line
otherLine = line;
otherIndex = pos - 2; //assume 2 character comment extro
return S_OK;
}
if(Lexer.isCommentState(Lexer.scanState(iState)))
{
if(mCodeWinMgr.mSource.FindEndOfComment(startState, iState, line, pos))
{
otherLine = line;
otherIndex = pos - 2; //assume 2 character comment extro
return S_OK;
}
}
}
}
}
if(Lexer.isEndingComment(txt, idxpos))
{
idx = cast(ViewCol) idxpos;
tokidx = mCodeWinMgr.mSource.FindLineToken(line, idx, iState, pos);
if(tokidx >= 0)
{
int startState = iState;
uint startpos = pos;
if(dLex.scan(iState, txt, pos) == TokenCat.Comment)
{
if(startState == iState ||
mCodeWinMgr.mSource.FindStartOfComment(startState, line, startpos))
{
otherLine = line;
otherIndex = startpos;
return S_OK;
}
}
/+
int prevpos = pos;
int prevline = line;
Lexer.scan(iState, txt, pos);
if(pos == idx + 2 && iState == Lexer.State.kWhite)
{
while(line > 0)
{
TokenInfo[] lineInfo = mCodeWinMgr.mSource.GetLineInfo(line);
if(tokidx < 0)
tokidx = lineInfo.length - 1;
while(tokidx >= 0)
{
if(lineInfo[tokidx].type != TokenCat.Comment)
{
otherLine = prevline;
otherIndex = prevpos;
return S_OK;
}
prevpos = lineInfo[tokidx].StartIndex;
prevline = line;
tokidx--;
}
line--;
}
}
+/
}
}
return S_FALSE;
}
int HighlightString(wstring txt, int line, ref ViewCol idx, out int otherLine, out int otherIndex)
{
int iState;
uint pos;
auto src = mCodeWinMgr.mSource;
int tokidx = src.FindLineToken(line, idx, iState, pos);
if(tokidx < 0)
return S_FALSE;
uint startPos = pos;
int startState = iState;
int type = dLex.scan(iState, txt, pos);
if(type == TokenCat.String)
{
Lexer.State sstate;
sstate = Lexer.scanState(startState);
if(idx == startPos && !Lexer.isStringState(sstate))
{
if(src.FindEndOfString(startState, iState, line, pos))
{
otherLine = line;
otherIndex = pos - 1;
return S_OK;
}
return S_FALSE;
}
sstate = Lexer.scanState(iState);
if(idx == pos - 1 && !Lexer.isStringState(sstate))
{
if(src.FindStartOfString(startState, line, startPos))
{
otherLine = line;
otherIndex = startPos;
return S_OK;
}
}
}
return S_FALSE;
}
int HighlightMatchingPairs()
{
int line, otherLine;
ViewCol idx, otherIndex;
int highlightLen;
bool checkMismatch;
if(int rc = mView.GetCaretPos(&line, &idx))
return rc;
if(FindMatchingPairs(line, idx, otherLine, otherIndex, highlightLen, checkMismatch) != S_OK)
return S_OK;
TextSpan[2] spans;
spans[0].iStartLine = line;
spans[0].iStartIndex = idx;
spans[0].iEndLine = line;
spans[0].iEndIndex = idx + highlightLen;
spans[1].iStartLine = otherLine;
spans[1].iStartIndex = otherIndex;
spans[1].iEndLine = otherLine;
spans[1].iEndIndex = otherIndex + highlightLen;
// HIGHLIGHTMATCHINGBRACEFLAGS.USERECTANGLEBRACES
HRESULT hr = mView.HighlightMatchingBrace(0, 2, spans.ptr);
if(highlightLen == 1 && checkMismatch)
{
wstring txt = mCodeWinMgr.mSource.GetText(line, idx, line, idx + 1);
wstring otxt = mCodeWinMgr.mSource.GetText(otherLine, otherIndex, otherLine, otherIndex + 1);
if(!otxt.length || !Lexer.isBracketPair(txt[0], otxt[0]))
showStatusBarText("mismatched bracket " ~ otxt);
}
return hr;
}
int FindMatchingPairs(int line, ref ViewCol idx, out int otherLine, out ViewCol otherIndex,
out int highlightLen, out bool checkMismatch)
{
wstring txt = mCodeWinMgr.mSource.GetText(line, 0, line, -1);
if(txt.length <= idx)
return S_FALSE;
highlightLen = 1;
checkMismatch = true;
if(HighlightComment(txt, line, idx, otherLine, otherIndex) == S_OK)
highlightLen = 2;
else if(HighlightString(txt, line, idx, otherLine, otherIndex) == S_OK)
checkMismatch = false;
else if(!Lexer.isOpeningBracket(txt[idx]) &&
!Lexer.isClosingBracket(txt[idx]))
return S_FALSE;
else if(!FindMatchingBrace(line, idx, otherLine, otherIndex))
{
// showStatusBarText("no matching bracket found"w);
return S_FALSE;
}
return S_OK;
}
bool FindMatchingBrace(int line, int idx, out int otherLine, out int otherIndex)
{
int iState;
uint pos;
int tok = mCodeWinMgr.mSource.FindLineToken(line, idx, iState, pos);
if(tok < 0)
return false;
wstring text = mCodeWinMgr.mSource.GetText(line, 0, line, -1);
uint ppos = pos;
int toktype = dLex.scan(iState, text, pos);
if(toktype != TokenCat.Operator)
return false;
if(Lexer.isOpeningBracket(text[ppos]))
return mCodeWinMgr.mSource.FindClosingBracketForward(line, iState, pos, otherLine, otherIndex);
else if(Lexer.isClosingBracket(text[ppos]))
return mCodeWinMgr.mSource.FindOpeningBracketBackward(line, tok, otherLine, otherIndex);
return false;
}
int FindClosingMatchingPairs(out int line, out ViewCol idx, out int otherLine, out ViewCol otherIndex,
out int highlightLen, out bool checkMismatch)
{
if(int rc = mView.GetCaretPos(&line, &idx))
return rc;
int caretLine = line;
int caretIndex = idx;
while(line >= 0)
{
wstring text = mCodeWinMgr.mSource.GetText(line, 0, line, -1);
if(idx < 0)
idx = text.length;
while(--idx >= 0)
{
if(Lexer.isOpeningBracket(text[idx]) ||
text[idx] == '\"' || text[idx] == '`' || text[idx] == '/')
{
if(FindMatchingPairs(line, idx, otherLine, otherIndex, highlightLen, checkMismatch) == S_OK)
if(otherLine > caretLine ||
(otherLine == caretLine && otherIndex > caretIndex))
return S_OK;
}
}
line--;
}
return S_FALSE;
}
int GotoMatchingPair(bool select)
{
int line, otherLine;
ViewCol idx, otherIndex;
int highlightLen;
bool checkMismatch;
if(mView.GetCaretPos(&line, &idx) != S_OK)
return S_FALSE;
if(FindMatchingPairs(line, idx, otherLine, otherIndex, highlightLen, checkMismatch) != S_OK)
if(FindClosingMatchingPairs(line, idx, otherLine, otherIndex, highlightLen, checkMismatch) != S_OK)
return S_OK;
mView.SetCaretPos(otherLine, otherIndex);
TextSpan span;
span.iStartLine = otherLine;
span.iStartIndex = otherIndex;
span.iEndLine = otherLine;
span.iEndIndex = otherIndex + highlightLen;
mView.EnsureSpanVisible(span);
if(select)
mView.SetSelection (line, idx, otherLine, otherIndex + highlightLen);
return S_OK;
}
//////////////////////////////
wstring GetWordAtCaret()
{
int line, idx;
if(mView.GetCaretPos(&line, &idx) != S_OK)
return "";
int startIdx, endIdx;
if(!mCodeWinMgr.mSource.GetWordExtent(line, idx, WORDEXT_CURRENT, startIdx, endIdx))
return "";
return mCodeWinMgr.mSource.GetText(line, startIdx, line, endIdx);
}
ExpansionProvider GetExpansionProvider()
{
return mCodeWinMgr.mSource.GetExpansionProvider();
}
int HandleSnippet()
{
int line, idx;
if(mView.GetCaretPos(&line, &idx) != S_OK)
return S_FALSE;
int startIdx, endIdx;
if(!mCodeWinMgr.mSource.GetWordExtent(line, idx, WORDEXT_CURRENT, startIdx, endIdx))
return S_FALSE;
wstring shortcut = mCodeWinMgr.mSource.GetText(line, startIdx, line, endIdx);
TextSpan ts = TextSpan(startIdx, line, endIdx, line);
string title, path;
ExpansionProvider ep = GetExpansionProvider();
return ep.InvokeExpansionByShortcut(mView, shortcut, ts, true, title, path);
}
//////////////////////////////////////////////////////////////
int showCurrentScope()
{
TextSpan span;
if(mView.GetCaretPos(&span.iStartLine, &span.iStartIndex) != S_OK)
return S_FALSE;
int line = span.iStartLine;
int idx = span.iStartIndex;
int iState;
uint pos;
int tok = mCodeWinMgr.mSource.FindLineToken(line, idx, iState, pos);
wstring curScope;
int otherLine, otherIndex;
Source src = mCodeWinMgr.mSource;
while(src.FindOpeningBracketBackward(line, tok, otherLine, otherIndex))
{
tok = mCodeWinMgr.mSource.FindLineToken(line, otherIndex, iState, pos);
wstring bracket = src.GetText(otherLine, otherIndex, otherLine, otherIndex + 1);
if(bracket == "{"w)
{
wstring fn;
src.findStatementStart(otherLine, otherIndex, fn);
wstring name = src.getScopeIdentifer(otherLine, otherIndex, fn);
if(name.length && name != "{")
{
if(curScope.length)
curScope = "." ~ curScope;
curScope = name ~ curScope;
}
}
line = otherLine;
}
if(curScope.length)
showStatusBarText("Scope: " ~ curScope);
else
showStatusBarText("Scope: at module scope"w);
return S_OK;
}
//////////////////////////////////////////////////////////////
int ConvertSelection()
{
if(convertSelection(mView))
return S_OK;
return S_FALSE;
}
//////////////////////////////////////////////////////////////
int HandleSmartIndent(dchar ch)
{
LANGPREFERENCES langPrefs;
if(int rc = GetUserPreferences(&langPrefs))
return rc;
if(langPrefs.IndentStyle != vsIndentStyleSmart)
return S_FALSE;
int line, idx, len;
if(int rc = mView.GetCaretPos(&line, &idx))
return rc;
if(ch != '\n')
idx--;
else if(mCodeWinMgr.mSource.mBuffer.GetLengthOfLine(line, &len) == S_OK && len > 0)
return ReindentLines();
wstring linetxt = mCodeWinMgr.mSource.GetText(line, 0, line, -1);
int p, orgn = countVisualSpaces(linetxt, langPrefs.uTabSize, &p);
wstring trimmed;
if(std.ascii.isAlpha(ch) && ((trimmed = strip(linetxt)) == "in" || trimmed == "out" || trimmed == "body"))
return ReindentLines();
if(idx > p || (ch != '\n' && linetxt[p] != ch))
return S_FALSE; // do nothing if not at beginning of line
Source.CacheLineIndentInfo cacheInfo;
int n = mCodeWinMgr.mSource.CalcLineIndent(line, ch, &langPrefs, cacheInfo);
if(n < 0 || n == orgn)
return S_OK;
if(ch == '\n')
return mView.SetCaretPos(line, n);
else
return mCodeWinMgr.mSource.doReplaceLineIndent(line, p, n, &langPrefs);
}
int ReindentLines()
{
int iStartLine, iStartIndex, iEndLine, iEndIndex;
int hr = GetSelectionForward(mView, &iStartLine, &iStartIndex, &iEndLine, &iEndIndex);
if(FAILED(hr)) // S_FALSE if no selection, but caret-coordinates returned
return hr;
return ReindentLines(iStartLine, iEndLine);
}
int ReindentLines(int iStartLine, int iEndLine)
{
if(iEndLine < iStartLine)
std.algorithm.swap(iStartLine, iEndLine);
IVsCompoundAction compAct = qi_cast!IVsCompoundAction(mView);
if(compAct)
compAct.OpenCompoundAction("ReindentLines"w.ptr);
int hr = mCodeWinMgr.mSource.ReindentLines(iStartLine, iEndLine);
if(compAct)
{
compAct.CloseCompoundAction();
compAct.Release();
}
return hr;
}
int ReindentPastedLines()
{
if(Package.GetGlobalOptions().pasteIndent)
with(mCodeWinMgr.mSource.mLastTextLineChange)
if(iStartLine != iNewEndLine)
return ReindentLines(iStartLine, iNewEndLine);
return S_OK;
}
//////////////////////////////////////////////////////////////
int CommentLines(int commentMode)
{
int iStartLine, iStartIndex, iEndLine, iEndIndex;
int hr = GetSelectionForward(mView, &iStartLine, &iStartIndex, &iEndLine, &iEndIndex);
if(FAILED(hr)) // S_FALSE if no selection, but caret-coordinates returned
return hr;
if(iEndIndex == 0 && iEndLine > iStartLine)
iEndLine--;
IVsCompoundAction compAct = qi_cast!IVsCompoundAction(mView);
if(compAct)
compAct.OpenCompoundAction("CommentLines"w.ptr);
hr = mCodeWinMgr.mSource.CommentLines(iStartLine, iEndLine, commentMode);
if(compAct)
{
compAct.CloseCompoundAction();
compAct.Release();
}
return hr;
}
//////////////////////////////////////////////////////////////
int PasteFromRing()
{
if(auto svc = queryService!(IVsToolbox, IVsToolboxClipboardCycler))
{
scope(exit) release(svc);
wstring[] entries;
int[] entryIndex;
int cntEntries = 0;
svc.BeginCycle();
IVsToolboxUser tbuser = qi_cast!IVsToolboxUser(mView);
scope(exit) release(tbuser);
BOOL itemsAvailable;
if(svc.AreDataObjectsAvailable(tbuser, &itemsAvailable) == S_OK && itemsAvailable)
{
IDataObject firstDataObject;
IDataObject pDataObject;
while(entries.length < 30 &&
svc.GetAndSelectNextDataObject(tbuser, &pDataObject) == S_OK)
{
scope(exit) release(pDataObject);
if(pDataObject is firstDataObject)
break;
if(!firstDataObject)
firstDataObject = addref(pDataObject);
FORMATETC fmt;
fmt.cfFormat = CF_UNICODETEXT;
fmt.ptd = null;
fmt.dwAspect = DVASPECT_CONTENT;
fmt.lindex = -1;
fmt.tymed = TYMED_HGLOBAL;
STGMEDIUM medium;
if(pDataObject.GetData(&fmt, &medium) == S_OK)
{
if(medium.tymed == TYMED_HGLOBAL)
{
wstring s = UtilGetStringFromHGLOBAL(medium.hGlobal);
.GlobalFree(medium.hGlobal);
s = createPasteString(s);
if(!contains(entries, s))
{
entries ~= s;
entryIndex ~= cntEntries;
}
}
}
cntEntries++;
}
release(firstDataObject);
if(entries.length > 0)
{
TextSpan span;
if(mView.GetCaretPos (&span.iStartLine, &span.iStartIndex) == S_OK)
{
span.iEndLine = span.iStartLine;
span.iEndIndex = span.iStartIndex;
mView.EnsureSpanVisible(span);
POINT pt;
if(mView.GetPointOfLineColumn (span.iStartLine, span.iStartIndex, &pt) == S_OK)
{
int height;
mView.GetLineHeight (&height);
pt.y += height;
HWND hwnd = cast(HWND) mView.GetWindowHandle();
ClientToScreen(hwnd, &pt);
for(int k = 0; k < 10 && k < entries.length; k++)
entries[k] = entries[k] ~ "\t(&" ~ cast(wchar)('0' + ((k + 1) % 10)) ~ ")";
int sel = PopupContextMenu(hwnd, pt, entries);
if(sel >= 0 && sel < entryIndex.length)
{
int cnt = entryIndex[sel];
svc.BeginCycle();
for(int i = 0; i <= cnt; i++)
{
if(svc.GetAndSelectNextDataObject(tbuser, &pDataObject) == S_OK)
release(pDataObject);
}
return E_NOTIMPL; // forward to VS for insert
}
}
}
}
return S_OK; // do not pass to VS, insert cancelled
}
}
return E_NOTIMPL; // forward to VS for insert
}
//////////////////////////////////////////////////////////////
int RemoveUnittests()
{
int endLine, endCol;
mCodeWinMgr.mSource.GetLastLineIndex(endLine, endCol);
wstring wtxt = mCodeWinMgr.mSource.GetText(0, 0, endLine, endCol);
ReplaceOptions opt;
version(none)
{
string txt = to!string(wtxt);
string rtxt = replaceTokenSequence(txt, "unittest { $any }", "", opt, null);
if(txt == rtxt)
return S_OK;
wstring wrtxt = to!wstring(rtxt);
}
else
wstring wrtxt = replaceTokenSequence(wtxt, 1, 0, "unittest { $any }", "", opt, null);
TextSpan changedSpan;
return mCodeWinMgr.mSource.mBuffer.ReplaceLines(0, 0, endLine, endCol, wrtxt.ptr, wrtxt.length, &changedSpan);
}
//////////////////////////////////////////////////////////////
int HandleGotoDef()
{
int line, idx;
if(mView.GetCaretPos(&line, &idx) != S_OK)
return S_FALSE;
string file = mCodeWinMgr.mSource.GetFileName();
wstring impw = mCodeWinMgr.mSource.GetImportModule(line, idx, false);
if(impw.length)
{
string imp = to!string(impw);
imp = replace(imp, ".", "\\") ~ ".d";
HRESULT hr = OpenFileInSolution(imp, -1, file, false); // also searches import paths
if(hr != S_OK)
{
imp ~= "i";
hr = OpenFileInSolution(imp, -1, file, false);
}
return hr;
}
if(Package.GetGlobalOptions().semanticGotoDef)
{
TextSpan span;
span.iStartLine = span.iEndLine = line;
span.iStartIndex = span.iEndIndex = idx;
if (!mCodeWinMgr.mSource.GetTipSpan(&span))
return S_FALSE;
mLastGotoDef = to!string(mCodeWinMgr.mSource.GetText(span.iStartLine, span.iStartIndex, span.iEndLine, span.iEndIndex));
Package.GetLanguageService().GetDefinition(mCodeWinMgr.mSource, &span, &GotoDefinitionCallBack);
return S_FALSE;
}
else
{
string word = toUTF8(GetWordAtCaret());
if(word.length <= 0)
return S_FALSE;
return GotoDefinitionJSON(file, word);
}
}
HRESULT GotoDefinitionJSON(string file, string word)
{
Definition[] defs = Package.GetLibInfos().findDefinition(word);
if(defs.length == 0)
{
showStatusBarText("No definition found for '" ~ word ~ "'");
return S_FALSE;
}
if(defs.length > 1)
{
showStatusBarText("Multiple definitions found for '" ~ word ~ "'");
showSearchWindow(false, word);
return S_FALSE;
}
string deffile = defs[0].filename;
int defline = defs[0].line;
HRESULT hr = OpenFileInSolution(deffile, defline, file, true);
if(hr != S_OK)
showStatusBarText(format("Cannot open %s(%d) for definition of '%s'", deffile, defline, word));
return hr;
}
extern(D)
void GotoDefinitionCallBack(uint request, string fname, sdk.vsi.sdk_shared.TextSpan span)
{
if (fname.length)
{
HRESULT hr = OpenFileInSolution(fname, span.iStartLine, null, false);
if(hr != S_OK)
showStatusBarText(format("Cannot open %s(%d) for goto definition", fname, span.iStartLine));
}
else
{
string word = split(mLastGotoDef, ".")[$-1];
GotoDefinitionJSON(mCodeWinMgr.mSource.GetFileName(), word);
//showStatusBarText("No definition found for '" ~ mLastGotoDef ~ "'");
}
}
//////////////////////////////////////////////////////////////
int HandleHelp()
{
string word = toUTF8(GetWordAtCaret());
if(word.length <= 0)
return S_FALSE;
if(!openHelp(word))
showStatusBarText(text("No documentation found for '", word, "'."));
return S_OK;
}
//////////////////////////////////////////////////////////////
int HandleMethodTip()
{
int rc = _HandleMethodTip();
if(rc != S_OK)
mCodeWinMgr.mSource.DismissMethodTip();
return rc;
}
int _HandleMethodTip(bool tryUpper = true)
{
TextSpan span;
if(mView.GetCaretPos(&span.iStartLine, &span.iStartIndex) != S_OK)
return S_FALSE;
int line = span.iStartLine;
int idx = span.iStartIndex;
int iState;
uint pos;
int tok = mCodeWinMgr.mSource.FindLineToken(line, idx, iState, pos);
stepUp:
int otherLine, otherIndex, cntComma;
Source src = mCodeWinMgr.mSource;
if(!src.FindOpeningBracketBackward(line, tok, otherLine, otherIndex, &cntComma))
return S_FALSE;
wstring bracket = src.GetText(otherLine, otherIndex, otherLine, otherIndex + 1);
if(bracket != "("w)
return S_FALSE;
tok = mCodeWinMgr.mSource.FindLineToken(otherLine, otherIndex, iState, pos);
string word = toUTF8(src.FindIdentifierBackward(otherLine, tok));
if(word.length <= 0)
{
line = otherLine;
idx = otherIndex;
if(!tryUpper)
return S_FALSE;
goto stepUp;
}
Definition[] defs = Package.GetLibInfos().findDefinition(word);
if(defs.length == 0)
return S_FALSE;
MethodData md = src.GetMethodData();
span.iEndLine = span.iStartLine;
span.iEndIndex = span.iStartIndex + 1;
md.Refresh(mView, defs, cntComma, span);
return S_OK;
}
// IVsTextViewFilter //////////////////////////////////////
override int GetWordExtent(in int iLine, in CharIndex iIndex, in uint dwFlags, /* [out] */ TextSpan *pSpan)
{
mixin(LogCallMix);
int startIdx, endIdx;
if(!mCodeWinMgr.mSource.GetWordExtent(iLine, iIndex, dwFlags, startIdx, endIdx))
return S_FALSE;
pSpan.iStartLine = iLine;
pSpan.iStartIndex = startIdx;
pSpan.iEndLine = iLine;
pSpan.iEndIndex = endIdx;
return S_OK;
}
override int GetDataTipText( /* [out][in] */ TextSpan *pSpan, /* [out] */ BSTR *pbstrText)
{
mixin(LogCallMix);
HRESULT resFwd = TIP_S_ONLYIFNOMARKER; // enable and prefer TextMarker tooltips
TextSpan span = *pSpan;
if(!mCodeWinMgr.mSource.GetTipSpan(pSpan))
return resFwd;
// when implementing IVsTextViewFilter, VS2010 will no longer ask the debugger
// for tooltips, so we have to do it ourselves
if(IVsDebugger srpVsDebugger = queryService!(IVsDebugger))
{
scope(exit) release(srpVsDebugger);
HRESULT hr = srpVsDebugger.GetDataTipValue(mCodeWinMgr.mSource.mBuffer, pSpan, null, pbstrText);
if(hr == 0x45001) // always returned when debugger active, so no other tooltips then
{
if(IVsCustomDataTip tip = qi_cast!IVsCustomDataTip(srpVsDebugger))
{
scope(exit) release(tip);
if(SUCCEEDED (tip.DisplayDataTip()))
return S_OK;
}
else
return hr;
} // return hr; // this triggers HandoffNoDefaultTipToDebugger
}
version(none) // quick info tooltips not good enough yet
{
string word = toUTF8(mCodeWinMgr.mSource.GetText(pSpan.iStartLine, pSpan.iStartIndex, pSpan.iEndLine, pSpan.iEndIndex));
if(word.length <= 0)
return resFwd;
Definition[] defs = Package.GetLibInfos().findDefinition(word);
if(defs.length == 0)
return resFwd;
string msg = word;
foreach(def; defs)
{
string m = "\n" ~ def.kind ~ "\t" ~ def.filename;
if(def.line > 0)
m ~= ":" ~ to!(string)(def.line);
msg ~= m;
}
*pbstrText = allocBSTR(msg);
}
if(Package.GetGlobalOptions().showTypeInTooltip)
{
if(mPendingSpan == span && mTipRequest == mPendingRequest)
{
*pbstrText = allocBSTR(mTipText);
*pSpan = mTipSpan;
}
else
{
if(mPendingSpan != span)
{
mPendingSpan = span;
mPendingRequest = Package.GetLanguageService().GetTip(mCodeWinMgr.mSource, &span, &OnGetTipText);
}
return E_PENDING;
}
}
return resFwd;
}
override int GetPairExtents(in int iLine, in CharIndex iIndex, /* [out] */ TextSpan *pSpan)
{
mixin(LogCallMix);
return E_NOTIMPL;
}
// IVsTextViewEvents //////////////////////////////////////
override int OnSetFocus(IVsTextView pView)
{
mixin(LogCallMix);
mCodeWinMgr.mLangSvc.mLastActiveView = this;
return S_OK;
}
override int OnKillFocus(IVsTextView pView)
{
mixin(LogCallMix);
if(mCodeWinMgr.mLangSvc.mLastActiveView is this)
mCodeWinMgr.mLangSvc.mLastActiveView = null;
return S_OK;
}
override int OnSetBuffer(IVsTextView pView, IVsTextLines pBuffer)
{
mixin(LogCallMix);
return S_OK;
}
override int OnChangeScrollInfo(IVsTextView pView, in int iBar,
in int iMinUnit, in int iMaxUnits,
in int iVisibleUnits, in int iFirstVisibleUnit)
{
// mixin(LogCallMix);
return S_OK;
}
override int OnChangeCaretLine(IVsTextView pView, in int iNewLine, in int iOldLine)
{
// mixin(LogCallMix);
return S_OK;
}
// IVsExpansionEvents //////////////////////////////////////
override int OnAfterSnippetsUpdate()
{
mixin(LogCallMix);
return S_OK;
}
override int OnAfterSnippetsKeyBindingChange(in uint dwCmdGuid, in uint dwCmdId, in BOOL fBound)
{
mixin(LogCallMix);
return S_OK;
}
//////////////////////////////
TextSpan mPendingSpan;
uint mPendingRequest;
TextSpan mTipSpan;
string mTipText;
uint mTipRequest;
string mLastGotoDef;
extern(D) void OnGetTipText(uint request, string filename, string text, TextSpan span)
{
mTipText = text;
mTipSpan = span;
mTipRequest = request;
}
bool OnIdle()
{
int line;
ViewCol idx;
if(int rc = mView.GetCaretPos(&line, &idx))
return false;
if(mLastHighlightBracesLine == line && mLastHighlightBracesCol == idx)
return false;
mLastHighlightBracesLine = line;
mLastHighlightBracesCol = idx;
HighlightMatchingPairs();
version(tip)
{
string msg = mCodeWinMgr.mSource.getParseError(line, idx);
if(msg.length)
{
mTextTipData.Init(mView, msg);
mTextTipData.UpdateView();
}
else
mTextTipData.Dismiss();
}
return true;
}
}
class TextTipData : DisposingComObject, IVsTextTipData
{
IVsTextTipWindow mTipWindow;
IVsTextView mTextView;
string mTipText;
bool mDisplayed;
this()
{
mTipText = "Tipp";
auto uuid = uuid_coclass_VsTextTipWindow;
mTipWindow = VsLocalCreateInstance!IVsTextTipWindow (&uuid, sdk.win32.wtypes.CLSCTX_INPROC_SERVER);
if (mTipWindow)
mTipWindow.SetTextTipData(this);
}
override HRESULT QueryInterface(in IID* riid, void** pvObject)
{
if(queryInterface!(IVsTextTipData) (this, riid, pvObject))
return S_OK;
return super.QueryInterface(riid, pvObject);
}
void Init(IVsTextView textView, string tip)
{
Close();
mTextView = textView;
mTipText = tip;
mDisplayed = false;
}
void Close()
{
Dismiss();
}
void Dismiss()
{
if (mDisplayed && mTextView)
mTextView.UpdateTipWindow(mTipWindow, UTW_DISMISS);
OnDismiss();
}
override void Dispose()
{
Close();
if (mTipWindow)
mTipWindow.SetTextTipData(null);
mTipWindow = release(mTipWindow);
}
HRESULT GetTipText (/+[out, custom(uuid_IVsTextTipData, "optional")]+/ BSTR *pbstrText,
/+[out]+/ BOOL *pfGetFontInfo)
{
if(pbstrText)
*pbstrText = allocBSTR(mTipText);
if(pfGetFontInfo)
*pfGetFontInfo = FALSE;
return S_OK;
}
// NOTE: *pdwFontAttr will already have been memset-ed to zeroes, so you can set only the indices that are not normal
HRESULT GetTipFontInfo (in int cChars, /+[out, size_is(cChars)]+/ ULONG *pdwFontAttr)
{
return E_NOTIMPL;
}
HRESULT GetContextStream(/+[out]+/ int *piPos, /+[out]+/ int *piLength)
{
int line, idx, vspace, endpos;
if(HRESULT rc = mTextView.GetCaretPos(&line, &idx))
return rc;
if(HRESULT rc = mTextView.GetNearestPosition(line, idx, piPos, &vspace))
return rc;
*piLength = 1;
return S_OK;
}
HRESULT OnDismiss ()
{
mTextView = null;
mDisplayed = false;
return S_OK;
}
HRESULT UpdateView ()
{
if (mTextView && mTipWindow)
{
mTextView.UpdateTipWindow(mTipWindow, UTW_CONTENTCHANGED);
mDisplayed = true;
}
return S_OK;
}
}
|
D
|
import std.stdio;
import std.process;
void convertFile() {
auto WordToTxtPID = spawnProcess("WordToTxt");
if (wait(WordToTxtPID) != 0)
writeln("Conversion failed!");
}
void convertFile(string filePath) {
auto WordToTxtPID = spawnProcess(["WordToTxt", filePath]);
if (wait(WordToTxtPID) != 0)
writeln("Conversion failed!");
}
|
D
|
/**
Ported by Laeeth Isharc 2014 to the D Programming Language
Use at your own risk!
This example shows how to create a chunked dataset. The
program first writes integers in a hyperslab selection to
a chunked dataset with dataspace dimensions of DIM0xDIM1
and chunk size of CHUNK0xCHUNK1, then closes the file.
Next, it reopens the file, reads back the data, and
outputs it to the screen. Finally it reads the data again
using a different hyperslab selection, and outputs
the result to the screen.
This file is intended for use with HDF5 Library version 1.6
*/
import hdf5.hdf5;
import std.stdio;
import std.exception;
import std.conv:to;
string fname="h5ex_d_chunk.h5";
string DATASET="DS1";
enum DIM0 =6L;
enum DIM1 =8L;
enum CHUNK0 =4L;
enum CHUNK1 =4L;
int main(string[] args)
{
hsize_t[2] dims=[DIM0,DIM1];
hsize_t[2] chunkDimensions=[CHUNK0,CHUNK1];
hsize_t[2] start,stride,count,block;
int[DIM1][DIM0] wdata,rdata; // write buffer, read buffer
// Initialize data to "1", to make it easier to see the selections.
foreach(i;0..DIM0)
foreach(j;0..DIM1)
wdata[i][j] = 1;
// Print the data to the screen.
writefln("Original Data:\n");
foreach(i;0..DIM0)
{
writefln(" [");
foreach(j;0..DIM1)
writefln(" %3d", wdata[i][j]);
writefln("]\n");
}
// Create a new file using the default properties.
auto file = H5F.create(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
// Create dataspace. Setting maximum size to NULL sets the maximum size to be the current size.
auto space = H5S.create_simple(dims);
// Create the dataset creation property list, and set the chunk size
auto dcpl = H5P.create (H5P_DATASET_CREATE);
H5P.set_chunk(dcpl, chunkDimensions);
// Create the chunked dataset.
auto dset = H5D.create2(file, DATASET, H5T_STD_I32LE, space, H5P_DEFAULT,dcpl,H5P_DEFAULT);
// Define and select the first part of the hyperslab selection.
start[0] = 0;
start[1] = 0;
stride[0] = 3;
stride[1] = 3;
count[0] = 2;
count[1] = 3;
block[0] = 2;
block[1] = 2;
H5S.select_hyperslab(space, H5SSeloper.Set , start, stride, count, block);
/**
Define and select the second part of the hyperslab selection,
which is subtracted from the first selection by the use of H5S_SELECT_NOTB
*/
block[0] = 1;
block[1] = 1;
H5S.select_hyperslab (space, H5SSeloper.NotB, start, stride, count, block);
// Write the data to the dataset.
H5D.write (dset, H5T_NATIVE_INT, H5S_ALL, space, H5P_DEFAULT, cast(ubyte*)&wdata);
// Close and release resources.
H5P.close(dcpl);
H5D.close(dset);
H5S.close(space);
H5F.close(file);
/*
* Now we begin the read section of this example.
*/
/*
* Open file and dataset using the default properties.
*/
file = H5F.open(fname, H5F_ACC_RDONLY, H5P_DEFAULT);
dset = H5D.open2(file, DATASET,H5P_DEFAULT);
/*
* Retrieve the dataset creation property list, and print the
* storage layout.
*/
dcpl = H5D.get_create_plist (dset);
auto layout = H5P.get_layout (dcpl);
writefln("\nStorage layout for %s is: ", DATASET);
writefln(layout.to!string);
writefln("**** about to read data");
// Read the data using the default properties.
H5D.read(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)rdata.ptr);
// Output the data to the screen.
writefln("\nData as written to disk by hyberslabs:");
foreach(i;0..DIM0) {
writef(" [");
foreach(j;0..DIM1)
writef(" %3d", rdata[i][j]);
writefln("]");
}
// Initialize the read array.
foreach(i;0..DIM0)
foreach(j;0..DIM1)
rdata[i][j] = 0;
// Define and select the hyperslab to use for reading.
space = H5D.get_space (dset);
start[0] = 0;
start[1] = 1;
stride[0] = 4;
stride[1] = 4;
count[0] = 2;
count[1] = 2;
block[0] = 2;
block[1] = 3;
H5S.select_hyperslab (space, H5SSeloper.Set, start, stride, count, block);
H5D.read(dset, H5T_NATIVE_INT, H5S_ALL, space, H5P_DEFAULT, cast(ubyte*)rdata.ptr);
/*
* Output the data to the screen.
*/
writefln("\nData as read from disk by hyperslab:");
foreach(row;rdata)
{
writef(" [");
foreach(cell;row)
writef(" %3d", cell);
writefln("]");
}
enforce(rdata[0][]==[0 , 1 , 0 , 0 , 0 , 0 , 0 , 1]);
enforce(rdata[1][]==[0 , 1 , 0 , 1 , 0 , 0 , 1 , 1]);
enforce(rdata[2][]==[0 , 0 , 0 , 0 , 0 , 0 , 0 , 0]);
enforce(rdata[3][]==[0 , 0 , 0 , 0 , 0 , 0 , 0 , 0]);
enforce(rdata[4][]==[0 , 1 , 0 , 1 , 0 , 0 , 1 , 1]);
enforce(rdata[5][]==[0 , 0 , 0 , 0 , 0 , 0 , 0 , 0]);
writefln("Test passed - we read back the correct data");
// Close and release resources.
H5P.close(dcpl);
H5D.close(dset);
H5S.close(space);
H5F.close(file);
return 0;
}
|
D
|
/**
Copyright: Copyright (c) 2015-2016 Andrey Penechko.
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: Andrey Penechko.
*/
module voxelman.math.utils;
import std.traits : isFloatingPoint;
import voxelman.math;
void nansToZero(T, int size)(ref Vector!(T, size) vector)
if (isFloatingPoint!T)
{
foreach(ref item; vector.arrayof)
{
item = isNaN(item) ? 0 : item;
}
}
void nansToZero(T, int size)(ref T[size] vector)
if (isFloatingPoint!T)
{
foreach(ref item; vector)
{
item = isNaN(item) ? 0 : item;
}
}
T nextPOT(T)(T x) {
--x;
x |= x >> 1;
x |= x >> 2;
x |= x >> 4;
static if (T.sizeof >= 16) x |= x >> 8;
static if (T.sizeof >= 32) x |= x >> 16;
static if (T.sizeof >= 64) x |= x >> 32;
++x;
return x;
}
unittest {
assert(nextPOT(1) == 1);
assert(nextPOT(2) == 2);
assert(nextPOT(3) == 4);
assert(nextPOT(4) == 4);
assert(nextPOT(5) == 8);
assert(nextPOT(10) == 16);
assert(nextPOT(30) == 32);
assert(nextPOT(250) == 256);
assert(nextPOT(1<<15+1) == 1<<16);
assert(nextPOT(1UL<<31+1) == 1UL<<32);
assert(nextPOT(1UL<<49+1) == 1UL<<50);
}
|
D
|
module test.ProgressBarTest;
import hunt.console.error.LogicException;
import hunt.console.output.Output;
import hunt.console.output.StreamOutput;
import hunt.console.output.Verbosity;
import hunt.console.util.StringUtils;
import hunt.console.helper.ProgressBar;
import test.asserts;
import std.string;
import hunt.io.ByteArrayOutputStream;
import hunt.console.helper.PlaceholderFormatter;
import hunt.console.helper.AbstractHelper;
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output);
// bar.start();
// bar.advance();
// bar.start();
// assertEqual(
// generateOutput(" 0 [>---------------------------]") ~
// generateOutput(" 1 [->--------------------------]") ~
// generateOutput(" 0 [>---------------------------]"),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output);
// bar.start();
// bar.advance();
// assertEqual(
// generateOutput(" 0 [>---------------------------]") ~
// generateOutput(" 1 [->--------------------------]"),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output);
// bar.start();
// bar.advance(5);
// assertEqual(
// generateOutput(" 0 [>---------------------------]") ~
// generateOutput(" 5 [----->----------------------]"),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output);
// bar.start();
// bar.advance(3);
// bar.advance(2);
// assertEqual(
// generateOutput(" 0 [>---------------------------]") ~
// generateOutput(" 3 [--->------------------------]") ~
// generateOutput(" 5 [----->----------------------]"),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output, 10);
// bar.setProgress(9);
// bar.advance();
// bar.advance();
// assertEqual(
// generateOutput(" 9/10 [=========================>--] 90%") ~
// generateOutput(" 10/10 [============================] 100%") ~
// generateOutput(" 11/11 [============================] 100%"),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output, 10);
// bar.setBarWidth(10);
// bar.setBarCharacter("_");
// bar.setEmptyBarCharacter(" ");
// bar.setProgressCharacter("/");
// bar.setFormat(" %current%/%max% [%bar%] %percent:3s%%");
// bar.start();
// bar.advance();
// assertEqual(
// generateOutput(" 0/10 [/ ] 0%") ~
// generateOutput(" 1/10 [_/ ] 10%"),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output, 50);
// bar.display();
// assertEqual(
// generateOutput(" 0/50 [>---------------------------] 0%"),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream(true, Verbosity.QUIET);
// ProgressBar bar = new ProgressBar(output, 50);
// bar.display();
// assertEqual(
// "",
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output, 50);
// bar.finish();
// assertEqual(
// generateOutput(" 50/50 [============================] 100%"),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output, 50);
// bar.start();
// bar.display();
// bar.advance();
// bar.advance();
// assertEqual(
// generateOutput(" 0/50 [>---------------------------] 0%") ~
// generateOutput(" 0/50 [>---------------------------] 0%") ~
// generateOutput(" 1/50 [>---------------------------] 2%") ~
// generateOutput(" 2/50 [=>--------------------------] 4%"),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output, 50);
// bar.setFormat(" %current%/%max% [%bar%] %percent:3s%%");
// bar.start();
// bar.display();
// bar.advance();
// // set shorter format
// bar.setFormat(" %current%/%max% [%bar%]");
// bar.advance();
// assertEqual(
// generateOutput(" 0/50 [>---------------------------] 0%") ~
// generateOutput(" 0/50 [>---------------------------] 0%") ~
// generateOutput(" 1/50 [>---------------------------] 2%") ~
// generateOutput(" 2/50 [=>--------------------------] "),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output);
// bar.setFormat("%current%/%max% [%bar%]");
// bar.start(50);
// bar.advance();
// assertEqual(
// generateOutput(" 0/50 [>---------------------------]") ~
// generateOutput(" 1/50 [>---------------------------]"),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output, 50);
// bar.start();
// bar.display();
// bar.advance();
// bar.setProgress(15);
// bar.setProgress(25);
// assertEqual(
// generateOutput(" 0/50 [>---------------------------] 0%") ~
// generateOutput(" 0/50 [>---------------------------] 0%") ~
// generateOutput(" 1/50 [>---------------------------] 2%") ~
// generateOutput(" 15/50 [========>-------------------] 30%") ~
// generateOutput(" 25/50 [==============>-------------] 50%"),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output);
// bar.setProgress(15);
// assert(bar.getStartTime() != long.init);
// }
// // unittest
// // {
// // StreamOutput output = getOutputStream();
// // ProgressBar bar = new ProgressBar(output, 50);
// // bar.start();
// // bar.setProgress(15);
// // bar.setProgress(10);
// // }
// // unittest
// // {
// // StreamOutput output = getOutputStream();
// // ProgressBar bar = new ProgressBar(output, 6);
// // bar = spy(bar);
// // bar.setRedrawFrequency(2);
// // bar.start();
// // bar.setProgress(1);
// // bar.advance(2);
// // bar.advance(2);
// // bar.advance(1);
// // verify(bar, times(4)).display();
// // }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output);
// bar.start();
// bar.setBarCharacter("■");
// bar.advance(3);
// assertEqual(
// generateOutput(" 0 [>---------------------------]") ~
// generateOutput(" 3 [■■■>------------------------]"),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output, 50);
// bar.start();
// bar.setProgress(25);
// bar.clear();
// assertEqual(
// generateOutput(" 0/50 [>---------------------------] 0%") ~
// generateOutput(" 25/50 [==============>-------------] 50%") ~
// generateOutput(" "),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output, 200);
// bar.start();
// bar.display();
// bar.advance(199);
// bar.advance();
// assertEqual(
// generateOutput(" 0/200 [>---------------------------] 0%") ~
// generateOutput(" 0/200 [>---------------------------] 0%") ~
// generateOutput(" 199/200 [===========================>] 99%") ~
// generateOutput(" 200/200 [============================] 100%"),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream(false, Verbosity.NORMAL);
// ProgressBar bar = new ProgressBar(output, 200);
// bar.start();
// for (int i = 0; i < 200; i++) {
// bar.advance();
// }
// bar.finish();
// assertEqual(
// " 0/200 [>---------------------------] 0%\n" ~
// " 20/200 [==>-------------------------] 10%\n" ~
// " 40/200 [=====>----------------------] 20%\n" ~
// " 60/200 [========>-------------------] 30%\n" ~
// " 80/200 [===========>----------------] 40%\n" ~
// " 100/200 [==============>-------------] 50%\n" ~
// " 120/200 [================>-----------] 60%\n" ~
// " 140/200 [===================>--------] 70%\n" ~
// " 160/200 [======================>-----] 80%\n" ~
// " 180/200 [=========================>--] 90%\n" ~
// " 200/200 [============================] 100%",
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream(false, Verbosity.NORMAL);
// ProgressBar bar = new ProgressBar(output, 50);
// bar.start();
// bar.setProgress(25);
// bar.clear();
// bar.setProgress(50);
// bar.finish();
// assertEqual(
// " 0/50 [>---------------------------] 0%\n" ~
// " 25/50 [==============>-------------] 50%\n" ~
// " 50/50 [============================] 100%",
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream(false, Verbosity.NORMAL);
// ProgressBar bar = new ProgressBar(output);
// bar.start();
// bar.advance();
// assertEqual(
// " 0 [>---------------------------]\n" ~
// " 1 [->--------------------------]",
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar1 = new ProgressBar(output, 2);
// ProgressBar bar2 = new ProgressBar(output, 3);
// bar2.setProgressCharacter("#");
// ProgressBar bar3 = new ProgressBar(output);
// bar1.start();
// output.write("\n");
// bar2.start();
// output.write("\n");
// bar3.start();
// for (int i = 1; i <= 3; i++) {
// // up two lines
// output.write("\033[2A");
// if (i <= 2) {
// bar1.advance();
// }
// output.write("\n");
// bar2.advance();
// output.write("\n");
// bar3.advance();
// }
// output.write("\033[2A");
// output.write("\n");
// output.write("\n");
// bar3.finish();
// assertEqual(
// generateOutput(" 0/2 [>---------------------------] 0%") ~ "\n" ~
// generateOutput(" 0/3 [#---------------------------] 0%") ~ "\n" ~
// StringUtils.rtrim(generateOutput(" 0 [>---------------------------]")) ~
// "\033[2A" ~
// generateOutput(" 1/2 [==============>-------------] 50%") ~ "\n" ~
// generateOutput(" 1/3 [=========#------------------] 33%") ~ "\n" ~
// StringUtils.rtrim(generateOutput(" 1 [->--------------------------]")) ~
// "\033[2A" ~
// generateOutput(" 2/2 [============================] 100%") ~ "\n" ~
// generateOutput(" 2/3 [==================#---------] 66%") ~ "\n" ~
// StringUtils.rtrim(generateOutput(" 2 [-->-------------------------]")) ~
// "\033[2A" ~
// "\n" ~
// generateOutput(" 3/3 [============================] 100%") ~ "\n" ~
// StringUtils.rtrim(generateOutput(" 3 [--->------------------------]")) ~
// "\033[2A" ~
// "\n" ~
// "\n" ~
// StringUtils.rtrim(generateOutput(" 3 [============================]")),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output);
// bar.start();
// bar.advance();
// bar.advance();
// bar.advance();
// bar.finish();
// assertEqual(
// generateOutput(" 0 [>---------------------------]") ~
// generateOutput(" 1 [->--------------------------]") ~
// generateOutput(" 2 [-->-------------------------]") ~
// generateOutput(" 3 [--->------------------------]") ~
// generateOutput(" 3 [============================]"),
// getOutputString(output)
// );
// }
// unittest
// {
// ProgressBar.setPlaceholderFormatter("remaining_steps", new class PlaceholderFormatter
// {
// override
// public string format(ProgressBar bar, Output output)
// {
// import std.conv;
// return to!string(bar.getMaxSteps() - bar.getProgress());
// }
// });
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output, 3);
// bar.setFormat(" %remaining_steps% [%bar%]");
// bar.start();
// bar.advance();
// bar.finish();
// assertEqual(
// generateOutput(" 3 [>---------------------------]") ~
// generateOutput(" 2 [=========>------------------]") ~
// generateOutput(" 0 [============================]"),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output, 3);
// bar.setFormat("%bar%\nfoobar");
// bar.start();
// bar.advance();
// bar.clear();
// bar.finish();
// assertEqual(
// generateOutput(">---------------------------\nfoobar") ~
// generateOutput("=========>------------------\nfoobar ") ~
// generateOutput(" \n ") ~
// generateOutput("============================\nfoobar "),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output, 15);
// ProgressBar.setPlaceholderFormatter("memory", new class PlaceholderFormatter
// {
// private int i = 0;
// override
// public string format(ProgressBar bar, Output output)
// {
// long mem = 100000 * i++;
// string colors ="44;37";
// return "\033[" ~ colors ~ "m " ~ AbstractHelper.formatMemory(mem) ~ " \033[0m";
// }
// });
// bar.setFormat(r" \033[44;37m %title:-37s% \033[0m\n %current%/%max% %bar% %percent:3s%%\n \uD83C\uDFC1 %remaining:-10s% %memory:37s%");
// string done = "\033[32m●\033[0m";
// bar.setBarCharacter(done);
// string empty = "\033[31m●\033[0m";
// bar.setEmptyBarCharacter(empty);
// string progress = "\033[32m➤ \033[0m";
// bar.setProgressCharacter(progress);
// bar.setMessage("Starting the demo... fingers crossed", "title");
// bar.start();
// bar.setMessage("Looks good to me...", "title");
// bar.advance(4);
// bar.setMessage("Thanks, bye", "title");
// bar.finish();
// assertEqual(
// generateOutput(
// " \033[44;37m Starting the demo... fingers crossed \033[0m\n" ~
// " 0/15 " ~ progress ~ StringUtils.padRight("", 26, empty) ~ " 0%\n" ~
// r" \uD83C\uDFC1 1 sec \033[44;37m 0 B \033[0m"
// ) ~
// generateOutput(
// " \033[44;37m Looks good to me... \033[0m\n" ~
// " 4/15 " ~ StringUtils.padRight("", 7, done) ~ progress ~ StringUtils.padRight("", 19, empty) ~ " 26%\n" ~
// r" \uD83C\uDFC1 1 sec \033[44;37m 97 KiB \033[0m"
// ) ~
// generateOutput(
// " \033[44;37m Thanks, bye \033[0m\n" ~
// " 15/15 " ~ StringUtils.padRight("", 28, done) ~ " 100%\n" ~
// r" \uD83C\uDFC1 1 sec \033[44;37m 195 KiB \033[0m"
// ),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output);
// bar.setFormat("normal");
// bar.start();
// assertEqual(
// generateOutput(" 0 [>---------------------------]"),
// getOutputString(output)
// );
// output = getOutputStream();
// bar = new ProgressBar(output, 10);
// bar.setFormat("normal");
// bar.start();
// assertEqual(
// generateOutput(" 0/10 [>---------------------------] 0%"),
// getOutputString(output)
// );
// }
// unittest
// {
// StreamOutput output = getOutputStream();
// ProgressBar bar = new ProgressBar(output);
// bar.setFormat("normal");
// bar.start();
// assertNotEqual("", getOutputString(output));
// output = getOutputStream();
// bar = new ProgressBar(output);
// bar.setFormat("verbose");
// bar.start();
// assertNotEqual("", getOutputString(output));
// output = getOutputStream();
// bar = new ProgressBar(output);
// bar.setFormat("very_verbose");
// bar.start();
// assertNotEqual("", getOutputString(output));
// output = getOutputStream();
// bar = new ProgressBar(output);
// bar.setFormat("debug");
// bar.start();
// assertNotEqual("", getOutputString(output));
// }
// private StreamOutput getOutputStream()
// {
// return new StreamOutput(new ByteArrayOutputStream());
// }
// private StreamOutput getOutputStream(bool decorated, Verbosity verbosity)
// {
// return new StreamOutput(new ByteArrayOutputStream(), verbosity, decorated);
// }
// private string getOutputString(StreamOutput output)
// {
// return cast(string)((cast(ByteArrayOutputStream) output.getStream()).toByteArray());
// }
// private string generateOutput(string expected)
// {
// int count = StringUtils.count(expected, '\n');
// return "\r" ~ (count > 0 ? format("\033[%dA", count) : "") ~ expected;
// }
|
D
|
// { dg-options "-I $srcdir/gdc.dg -I $srcdir/gdc.dg/imports" }
// { dg-additional-sources "imports/gdc27.d imports/gdc231.d" }
// { dg-do compile }
import core.simd;
import gcc.attribute;
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=27
import imports.gdc27;
interface I_B : I_A
{
void b();
}
abstract class C_B : C_A, I_B
{
abstract void b();
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=108
@attribute("forceinline")
void forceinline108()
{
}
@attribute("noinline")
void noinline108()
{
}
@attribute("flatten")
void flatten108()
{
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=170
import imports.gdc170;
void test170()
{
foo!void.foo1!void();
foo!void.foo2!void();
foo!void.foo3();
foo!void.foo3!void();
foo!void.foo4();
foo!void.foo4!void();
foo!void.foo5!void(null);
foo!void.foo6!void(null);
foo!void.foo7(null);
foo!void.foo7!void(null);
foo!void.foo8(null);
foo!void.foo8!void(null);
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=212
template hasElaborateAssign212(S)
{
enum hasElaborateAssign212 = is(typeof(S.init.opAssign(rvalueOf212!S))) ||
is(typeof(lvalueOf212!S)) ;
}
T rvalueOf212(T)();
T lvalueOf212(T)();
template TypeTuple212(TList...)
{
alias TypeTuple212 = TList;
}
template Tuple212()
{
struct Tuple212
{
void opAssign(R)(R)
{
if (hasElaborateAssign212!R)
{
}
}
}
}
ref emplaceRef212()
{
static if (!hasElaborateAssign212!(Tuple212!()))
chunk;
}
class TaskPool212
{
void reduce()
{
Tuple212!() seed = void;
Tuple212!()[] results;
foreach(i; TypeTuple212!(0, 1))
results[i] = seed;
}
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=213
struct S213
{
int4 vec;
}
void test213()
{
S213 s, b;
assert(s == b);
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=218
struct S218a
{
this(int* pdata_)
{
pdata = pdata_;
}
void opIndexAssign(int, size_t) { }
int* pdata;
};
struct S218
{
S218a getS218a()
{
return S218a(data.ptr);
}
int[] data;
int[] tab2;
};
S218 f()
{
S218 r;
for(int i = 0; i < 1; ++i)
r.getS218a()[0] = 0;
return r;
}
S218 var;
static this()
{
var = f();
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=223
struct S223
{
long[8] field;
}
class C223
{
long[8] field;
}
S223 test223_1();
real test223_2();
string[long[8]] test223_3();
C223 test223_4();
long test223_5();
long[] test223_6();
long[8] test223_7();
C223[8] test223_8();
void delegate() test223_9();
bool test223()
{
return test223_1() == test223_1() &&
test223_1() is test223_1() &&
test223_2() == test223_2() &&
test223_2() is test223_2() &&
test223_3() == test223_3() &&
test223_3() is test223_3() &&
test223_4() == test223_4() &&
test223_4() is test223_4() &&
test223_5() == test223_5() &&
test223_5() is test223_5() &&
test223_6() == test223_6() &&
test223_6() is test223_6() &&
test223_7() == test223_7() &&
test223_7() is test223_7() &&
test223_8() == test223_8() &&
test223_8() is test223_8() &&
test223_9() == test223_9() &&
test223_9() is test223_9();
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=231
import imports.gdc231;
class Range231 : Widget231
{
override void* getStruct()
{
return null;
}
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=239
import imports.gdc239;
class C239
{
C239a *foo;
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=240
interface I204
{
void f();
}
class C204 : I204
{
void f();
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=241
import imports.gdc241a;
import imports.gdc241b : S241, C241, E241, N241;
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=242
struct S242a
{
enum M = S242a();
void iter() { }
}
void test242a()
{
return S242a.M.iter;
}
struct S242b
{
enum M = S242b();
void iter() { }
}
void test242b()
{
S242b.M.iter;
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=251
import imports.gdc251a;
import imports.gdc251b : C251;
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=253
import imports.gdc253;
class C253 : C253a
{
void test253() { }
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=255
class C255
{
void f2()
{
class C1
{
void f1()
{
void f0()
{
class C0
{
void test255()
{
f2();
}
}
}
}
}
}
}
class C255a
{
void f3()
{
class C1
{
void f2()
{
void f1()
{
void f0()
{
class C0
{
void test255a()
{
f3();
}
}
}
}
}
}
}
}
class C255b
{
void f4()
{
class C2
{
void f3()
{
void f2()
{
class C1
{
void f1()
{
void f0()
{
class C0
{
void test255b()
{
f4();
}
}
}
}
}
}
}
}
}
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=256
import imports.gdcpkg256 : gdc256;
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=261
void test261()
{
class C1
{
void f1()
{
class C2
{
void f2()
{
auto v = &f1;
}
}
}
}
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=280
struct RBNode280
{
RBNode280* _parent;
@property left(RBNode280*)
{
_parent = &this;
}
}
class RedBlackTree280
{
RBNode280* _end;
RBNode280* _begin;
this(int[] elems...)
{
_end = new RBNode280;
foreach (e; elems)
{
_end.left = _begin;
}
}
}
__gshared s = new RedBlackTree280('h');
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=284
alias v284 = __vector(int[2]);
v284 test284(v284 a, ...)
{
return a + a;
}
|
D
|
INSTANCE Info_Mod_Gritta_Hi (C_INFO)
{
npc = Mod_580_NONE_Gritta_NW;
nr = 1;
condition = Info_Mod_Gritta_Hi_Condition;
information = Info_Mod_Gritta_Hi_Info;
permanent = 0;
important = 0;
description = "Wer bist du?";
};
FUNC INT Info_Mod_Gritta_Hi_Condition()
{
return 1;
};
FUNC VOID Info_Mod_Gritta_Hi_Info()
{
B_Say (hero, self, "$WHOAREYOU");
AI_Output(self, hero, "Info_Mod_Gritta_Hi_16_01"); //Ich bin Gritta.
};
INSTANCE Info_Mod_Gritta_ThorbenLehrling (C_INFO)
{
npc = Mod_580_NONE_Gritta_NW;
nr = 1;
condition = Info_Mod_Gritta_ThorbenLehrling_Condition;
information = Info_Mod_Gritta_ThorbenLehrling_Info;
permanent = 0;
important = 1;
};
FUNC INT Info_Mod_Gritta_ThorbenLehrling_Condition()
{
if (Mod_Thorben_KO == 1)
{
return 1;
};
};
FUNC VOID Info_Mod_Gritta_ThorbenLehrling_Info()
{
AI_Output(self, hero, "Info_Mod_Gritta_ThorbenLehrling_16_00"); //Du willst zu Thorben, oder?
AI_Output(hero, self, "Info_Mod_Gritta_ThorbenLehrling_15_01"); //Ja ... Stimmt was nicht?
AI_Output(self, hero, "Info_Mod_Gritta_ThorbenLehrling_16_02"); //Er ... Es sieht schlimm aus. Der Arzt meint, es sei ein Schlaganfall gewesen und dass er wieder aufwachen wird.
AI_Output(self, hero, "Info_Mod_Gritta_ThorbenLehrling_16_03"); //Aber wie viel von seinem Gedächtnis verloren geht, weiß niemand.
AI_Output(hero, self, "Info_Mod_Gritta_ThorbenLehrling_15_04"); //Das tut mir leid. Kann ich irgendetwas für ihn tun?
AI_Output(self, hero, "Info_Mod_Gritta_ThorbenLehrling_16_05"); //Du bist sein Lehrling, nicht wahr? Er würde sich bestimmt über ein kleines selbstgefertigtes Geschenk freuen, oh ja.
AI_Output(hero, self, "Info_Mod_Gritta_ThorbenLehrling_15_06"); //Ich werde mir etwas einfallen lassen. Mach's gut.
Log_CreateTopic (TOPIC_MOD_LEHRLING_THORBEN_FOUR, LOG_MISSION);
B_SetTopicStatus (TOPIC_MOD_LEHRLING_THORBEN_FOUR, LOG_RUNNING);
B_LogEntry (TOPIC_MOD_LEHRLING_THORBEN_FOUR, "Thorben hat es voll erwischt. Seine Nichte meint, er würde sich über ein selbstgefertigtes Geschenk freuen. Nun ja, ein wenig kitschig ist es schon, aber wenn es hilft ... Ich sollte noch ein Mal Brahim nach einer Zeichnung fragen. Selbst wenn er sie nicht selbst machen will, so kann er mich doch vielleicht weiterleiten.");
};
INSTANCE Info_Mod_Gritta_ThorbenLehrling2 (C_INFO)
{
npc = Mod_580_NONE_Gritta_NW;
nr = 1;
condition = Info_Mod_Gritta_ThorbenLehrling2_Condition;
information = Info_Mod_Gritta_ThorbenLehrling2_Info;
permanent = 0;
important = 1;
};
FUNC INT Info_Mod_Gritta_ThorbenLehrling2_Condition()
{
if (Mod_Thorben_Geschenk == 1)
{
return 1;
};
};
FUNC VOID Info_Mod_Gritta_ThorbenLehrling2_Info()
{
AI_Output(self, hero, "Info_Mod_Gritta_ThorbenLehrling2_16_00"); //Du hast ein Geschenk für meinen Onkel?
AI_Output(hero, self, "Info_Mod_Gritta_ThorbenLehrling2_15_01"); //Ja. Ist er denn bei Bewusstsein?
AI_Output(self, hero, "Info_Mod_Gritta_ThorbenLehrling2_16_02"); //Seit letzter Nacht. Es geht ihm schon wieder besser, und er scheint sich an alles zu erinnern. Bring ihm ruhig dein Geschenk.
};
INSTANCE Info_Mod_Gritta_Shakir (C_INFO)
{
npc = Mod_580_NONE_Gritta_NW;
nr = 1;
condition = Info_Mod_Gritta_Shakir_Condition;
information = Info_Mod_Gritta_Shakir_Info;
permanent = 0;
important = 0;
description = "Innos zum Gruß. Wie geht es dir?";
};
FUNC INT Info_Mod_Gritta_Shakir_Condition()
{
if (Npc_KnowsInfo(hero, Info_Mod_Jana_Shakir))
{
return 1;
};
};
FUNC VOID Info_Mod_Gritta_Shakir_Info()
{
AI_Output(hero, self, "Info_Mod_Gritta_Shakir_15_00"); //Innos zum Gruß. Wie geht es dir?
AI_Output(self, hero, "Info_Mod_Gritta_Shakir_16_01"); //Schlecht. Wer fragt das?
AI_Output(hero, self, "Info_Mod_Gritta_Shakir_15_02"); //Ein Freier.
AI_Output(self, hero, "Info_Mod_Gritta_Shakir_16_03"); //Du willst mich heiraten? Wieso?
AI_Output(hero, self, "Info_Mod_Gritta_Shakir_15_04"); //Das nicht. Man sagt, du stehst auf schöne Kleider.
AI_Output(self, hero, "Info_Mod_Gritta_Shakir_16_05"); //Das will ich meinen. Hast du welche?
AI_Output(hero, self, "Info_Mod_Gritta_Shakir_15_06"); //Nein. Aber ich könnte dir eines besorgen. Feinster Stoff, eleganter Schnitt, beste Qualität.
AI_Output(self, hero, "Info_Mod_Gritta_Shakir_16_07"); //Nur her damit! Was willst du dafür?
AI_Output(hero, self, "Info_Mod_Gritta_Shakir_15_08"); //Nur eine Gefälligkeit. Ein guter Freund von mir möchte mal mit einer Frau zusammensein.
AI_Output(hero, self, "Info_Mod_Gritta_Shakir_15_09"); //Er hat eine gemütliche Unterkunft draussen vor der Stadt ...
AI_Output(self, hero, "Info_Mod_Gritta_Shakir_16_10"); //Verstehe. Wann bekomme ich das Teil?
AI_Output(hero, self, "Info_Mod_Gritta_Shakir_15_11"); //Mein Freund wird es dir geben.
B_LogEntry (TOPIC_MOD_ASS_SHAKIR_FRAU, "Ich konnte Gritta 'engagieren'. Muss ihr ein Kleid vom Schneider in Khorata besorgen und es Shakir geben.");
};
INSTANCE Info_Mod_Gritta_Shakir2 (C_INFO)
{
npc = Mod_580_NONE_Gritta_NW;
nr = 1;
condition = Info_Mod_Gritta_Shakir2_Condition;
information = Info_Mod_Gritta_Shakir2_Info;
permanent = 0;
important = 0;
description = "Hallo! Ich habe bekommen, was du wolltest.";
};
FUNC INT Info_Mod_Gritta_Shakir2_Condition()
{
if (Mod_ASS_Gritta == 0)
&& (Mod_ASS_Schneider == 1)
{
return 1;
};
};
FUNC VOID Info_Mod_Gritta_Shakir2_Info()
{
AI_Output(hero, self, "Info_Mod_Gritta_Shakir2_15_00"); //Hallo! Ich habe bekommen, was du wolltest.
AI_Output(self, hero, "Info_Mod_Gritta_Shakir2_16_01"); //Ein neues Kleid?
AI_Output(hero, self, "Info_Mod_Gritta_Shakir2_15_02"); //Gewiss. Haute couture vom schwulen Versage.
AI_Output(self, hero, "Info_Mod_Gritta_Shakir2_16_03"); //Ja und? Diese Leute haben wenigstens Geschmack.
AI_Output(hero, self, "Info_Mod_Gritta_Shakir2_15_04"); //Wie du meinst. Lass uns gehen.
Mod_ASS_Gritta = 1;
AI_StopProcessInfos (self);
B_StartOtherRoutine (self, "FOLLOWTOSHAKIR");
B_LogEntry (TOPIC_MOD_ASS_SHAKIR_FRAU, "Werde sie zur Höhle bringen und Shakir Bescheid sagen.");
};
INSTANCE Info_Mod_Gritta_Shakir3 (C_INFO)
{
npc = Mod_580_NONE_Gritta_NW;
nr = 1;
condition = Info_Mod_Gritta_Shakir3_Condition;
information = Info_Mod_Gritta_Shakir3_Info;
permanent = 0;
important = 1;
};
FUNC INT Info_Mod_Gritta_Shakir3_Condition()
{
if (Mod_ASS_Gritta == 1)
&& (Npc_GetDistToWP(hero, "NW_CITY_SMFOREST_05") < 500)
{
return 1;
};
};
FUNC VOID Info_Mod_Gritta_Shakir3_Info()
{
AI_Output(self, hero, "Info_Mod_Gritta_Shakir3_16_00"); //Das nennst du gemütliche Unterkunft?
AI_Output(hero, self, "Info_Mod_Gritta_Shakir3_15_01"); //Nun ja. Jedenfalls seid ihr hier ungestört. Schön warm ist es auch.
AI_Output(self, hero, "Info_Mod_Gritta_Shakir3_16_02"); //Und wo ist dein guter Freund?
AI_Output(hero, self, "Info_Mod_Gritta_Shakir3_15_03"); //Ich sag ihm Bescheid. Er heißt Shakir. Schenk dir inzwischen etwas Wein ein, wenn du möchtest.
AI_Output(self, hero, "Info_Mod_Gritta_Shakir3_16_04"); //Und mein Kleid?
AI_Output(hero, self, "Info_Mod_Gritta_Shakir3_15_05"); //Wird er mitbringen.
AI_StopProcessInfos (self);
B_StartOtherRoutine (self, "ATSHAKIR");
};
INSTANCE Info_Mod_Gritta_Flugblaetter (C_INFO)
{
npc = Mod_580_NONE_Gritta_NW;
nr = 1;
condition = Info_Mod_Gritta_Flugblaetter_Condition;
information = Info_Mod_Gritta_Flugblaetter_Info;
permanent = 0;
important = 0;
description = "Ich hab hier ein Flugblatt für dich.";
};
FUNC INT Info_Mod_Gritta_Flugblaetter_Condition()
{
if (Npc_KnowsInfo(hero, Info_Mod_Matteo_Auftrag_2))
&& (Npc_HasItems(hero, MatteoFlugblaetter) >= 1)
&& (Mod_Flugblaetter < 20)
&&(!Npc_KnowsInfo(hero, Info_Mod_Matteo_Flugblaetter))
&& (Npc_KnowsInfo(hero, Info_Mod_Gritta_Hi))
{
return 1;
};
};
FUNC VOID Info_Mod_Gritta_Flugblaetter_Info()
{
B_Say (hero, self, "$MATTEOPAPER");
B_GiveInvItems (hero, self, MatteoFlugblaetter, 1);
AI_Output(self, hero, "Info_Mod_Gritta_Flugblaetter_16_01"); //(affektiert) Hmm, schöne Kleider hat Matteo aber glaube ich nicht.
Mod_Flugblaetter += 1;
};
INSTANCE Info_Mod_Gritta_Pickpocket (C_INFO)
{
npc = Mod_580_NONE_Gritta_NW;
nr = 1;
condition = Info_Mod_Gritta_Pickpocket_Condition;
information = Info_Mod_Gritta_Pickpocket_Info;
permanent = 1;
important = 0;
description = Pickpocket_60_Female;
};
FUNC INT Info_Mod_Gritta_Pickpocket_Condition()
{
C_Beklauen (36, ItMi_Gold, 75);
};
FUNC VOID Info_Mod_Gritta_Pickpocket_Info()
{
Info_ClearChoices (Info_Mod_Gritta_Pickpocket);
Info_AddChoice (Info_Mod_Gritta_Pickpocket, DIALOG_BACK, Info_Mod_Gritta_Pickpocket_BACK);
Info_AddChoice (Info_Mod_Gritta_Pickpocket, DIALOG_PICKPOCKET, Info_Mod_Gritta_Pickpocket_DoIt);
};
FUNC VOID Info_Mod_Gritta_Pickpocket_BACK()
{
Info_ClearChoices (Info_Mod_Gritta_Pickpocket);
};
FUNC VOID Info_Mod_Gritta_Pickpocket_DoIt()
{
if (B_Beklauen() == TRUE)
{
Info_ClearChoices (Info_Mod_Gritta_Pickpocket);
}
else
{
Info_ClearChoices (Info_Mod_Gritta_Pickpocket);
Info_AddChoice (Info_Mod_Gritta_Pickpocket, DIALOG_PP_BESCHIMPFEN, Info_Mod_Gritta_Pickpocket_Beschimpfen);
Info_AddChoice (Info_Mod_Gritta_Pickpocket, DIALOG_PP_BESTECHUNG, Info_Mod_Gritta_Pickpocket_Bestechung);
Info_AddChoice (Info_Mod_Gritta_Pickpocket, DIALOG_PP_HERAUSREDEN, Info_Mod_Gritta_Pickpocket_Herausreden);
};
};
FUNC VOID Info_Mod_Gritta_Pickpocket_Beschimpfen()
{
B_Say (hero, self, "$PICKPOCKET_BESCHIMPFEN");
B_Say (self, hero, "$DIRTYTHIEF");
Info_ClearChoices (Info_Mod_Gritta_Pickpocket);
AI_StopProcessInfos (self);
B_Attack (self, hero, AR_Theft, 1);
};
FUNC VOID Info_Mod_Gritta_Pickpocket_Bestechung()
{
B_Say (hero, self, "$PICKPOCKET_BESTECHUNG");
var int rnd; rnd = r_max(99);
if (rnd < 25)
|| ((rnd >= 25) && (rnd < 50) && (Npc_HasItems(hero, ItMi_Gold) < 50))
|| ((rnd >= 50) && (rnd < 75) && (Npc_HasItems(hero, ItMi_Gold) < 100))
|| ((rnd >= 75) && (rnd < 100) && (Npc_HasItems(hero, ItMi_Gold) < 200))
{
B_Say (self, hero, "$DIRTYTHIEF");
Info_ClearChoices (Info_Mod_Gritta_Pickpocket);
AI_StopProcessInfos (self);
B_Attack (self, hero, AR_Theft, 1);
}
else
{
if (rnd >= 75)
{
B_GiveInvItems (hero, self, ItMi_Gold, 200);
}
else if (rnd >= 50)
{
B_GiveInvItems (hero, self, ItMi_Gold, 100);
}
else if (rnd >= 25)
{
B_GiveInvItems (hero, self, ItMi_Gold, 50);
};
B_Say (self, hero, "$PICKPOCKET_BESTECHUNG_01");
Info_ClearChoices (Info_Mod_Gritta_Pickpocket);
AI_StopProcessInfos (self);
};
};
FUNC VOID Info_Mod_Gritta_Pickpocket_Herausreden()
{
B_Say (hero, self, "$PICKPOCKET_HERAUSREDEN");
if (r_max(99) < Mod_Verhandlungsgeschick)
{
B_Say (self, hero, "$PICKPOCKET_HERAUSREDEN_01");
Info_ClearChoices (Info_Mod_Gritta_Pickpocket);
}
else
{
B_Say (self, hero, "$PICKPOCKET_HERAUSREDEN_02");
};
};
INSTANCE Info_Mod_Gritta_EXIT (C_INFO)
{
npc = Mod_580_NONE_Gritta_NW;
nr = 1;
condition = Info_Mod_Gritta_EXIT_Condition;
information = Info_Mod_Gritta_EXIT_Info;
permanent = 1;
important = 0;
description = DIALOG_ENDE;
};
FUNC INT Info_Mod_Gritta_EXIT_Condition()
{
return 1;
};
FUNC VOID Info_Mod_Gritta_EXIT_Info()
{
AI_StopProcessInfos (self);
};
|
D
|
// 1.
CHAIN
IF ~InParty("C#Ajantis")
See("C#Ajantis")
!StateCheck("C#Ajantis",CD_STATE_NOTVALID)
!StateCheck("O#Coran",CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
Global("G#XB.AjantisCoranBanter1","GLOBAL",0)~ THEN BO#CORAN AjantisCoranBanter#1.1
~Ajantis, what say you about a game of ball?~
DO ~SetGlobal("G#XB.AjantisCoranBanter1","GLOBAL",1)~
== C#AJANB ~A game of Ball? Here? Now? Coran, you should know better than to propose a game of Ball to a paldin of Helm on duty.~
== BO#CORAN ~That's a no, then?~
== C#AJANB ~That's a no, indeed.~
== BO#CORAN ~But even a paladin needs a time out. You were young once, don't you remember the games and playfulness? Don't you miss it?~
== C#AJANB ~I was very young when I heard the call of my god. No, I do not miss the games from my childhood. Serving my god Helm gives me more joy than any children's game could.~
== BO#CORAN ~(sigh) That answer was more than predictable. Allright, look at it like this: You could see it as a training. Catching the ball improves your reflexes - surely your mentor did teach you this.~
== C#AJANB ~Hm.. Under these premises, if <CHARNAME> allows *and* no danger is to be expected...~
== BO#CORAN ~Wonderful! Let me know when you are ready.~
EXIT
// 2.
CHAIN
IF ~InParty("C#Ajantis")
See("C#Ajantis")
!StateCheck("C#Ajantis",CD_STATE_NOTVALID)
!StateCheck("O#Coran",CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
Global("G#XB.AjantisCoranBanter1","GLOBAL",1) // first banter must fire, first
Global("G#XB.AjantisCoranBanter2","GLOBAL",0)~ THEN BO#CORAN AjantisCoranBanter#2.1
~What say you about another game of ball? I want a rematch.~
DO ~SetGlobal("G#XB.AjantisCoranBanter2","GLOBAL",1)~
== C#AJANB ~Are you sure, Coran? I would not want you to dive after the ball again, after all.~
== BO#CORAN ~(laugh) Oh, I remember. That farm north of Baldur's Gate? The ball fell into the river crawling with zombies, and I came out soaking wet and buried to the knee in zombie bits. But it was fun!~
== BO#CORAN ~Come on! I saw a nice lawn at Government District. Let's break a window or two, eh?~
== C#AJANB ~You are on! But watch it, rogue: another sign of cheating from you, and you will regret it.~
== BO#CORAN ~Oh, no cheating from me, I assure you... Wait. You look far too innocent for this. Whatever do you mean?~
== C#AJANB ~Oh, nothing. Just that the Government District never lacked fountains.~
EXIT
// 3.
CHAIN IF
~InParty("O#Coran")
See("O#Coran")
!StateCheck("C#Coran",CD_STATE_NOTVALID)
!StateCheck("C#Ajantis",CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
Global("G#XB.AjantisCoranBanter3","GLOBAL",0)~ THEN C#AJANB AjantisCoranBanter#3.1
~...No. Don't even think about it, rogue. It is enough that you drink at all hours: I will not let you involve <CHARNAME> into this life of debauchery.~
DO ~SetGlobal("G#XB.AjantisCoranBanter3","GLOBAL",1)~
== BO#CORAN ~Who said anything about <CHARNAME>? Our leader is a prim and proper young <PRO_MANWOMAN>(that is, until you turn away): I was talking about you, my paladin friend! Come, a glass of Elverquisst near the fire will do you good. We could play a game of chess, roast some apples -~
== C#AJANB ~I cannot say I dislike the idea entirely -~
== BO#CORAN ~- wink at a serving wench or two -~
== C#AJANB ~Absolutely not.~
== BO#CORAN ~(sigh) Spoilsport. Very well, but do not complain again if our singing wakes you up.~
== C#AJANB ~Coran, singing I can tolerate, even at three hours in the morning. But horrible screeching that came out the other night was an offence to all minstrels everywhere.~
== BO#CORAN ~You wound me, comrade. Those were two brethren of your Order, heading for Matzica in the morning!~
== C#AJANB ~...I pity the Matzican Prelate already.~
EXIT
// 4.
CHAIN
IF ~InParty("C#Ajantis")
See("C#Ajantis")
!StateCheck("C#Ajantis",CD_STATE_NOTVALID)
!StateCheck("O#Coran",CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
Global("G#XB.AjantisCoranBanter4","GLOBAL",0)~ THEN BO#CORAN AjantisCoranBanter#4.1
~I noticed a hunting knife in your hands the other day. Beautiful silverwork. Cormanthor, I take it?~
DO ~SetGlobal("G#XB.AjantisCoranBanter4","GLOBAL",1)~
== C#AJANB ~The Dalelands. It is... it was a gift from a comrade in the Order.~
== BO#CORAN ~I gave my younger brother a hunting knife once. He lost it the very next day. But this item must be very dear to you: you polish it nearly every time you rest. If I may ask, Ajantis, where is your friend now?~
== C#AJANB ~He perished in the Windspear Hills over a year ago with two other knights.~
== BO#CORAN ~Lord Firkraag employed his black magics even then, I take it?~
== C#AJANB ~He did. The Order did not know it at the time, but we all suspected a black presence. Alas, not all made it out alive.~
== BO#CORAN ~I am sorry, Ajantis.~
== C#AJANB ~Helm guides my path and gives me comfort. But if I could turn back the time, expose the villain and save my friends, I would.~
EXIT
|
D
|
module flipper.chips.base;
version (Tango) {
alias char[] string;
}
import flipper.devices.device;
import flipper.memory;
import flipper.protocols.jtag;
class Chip {
TAPStateMachine sm;
Memory[string] memory;
this( TAPStateMachine sm ) {
this.sm = sm;
}
void addMemory( string name, Memory inst ) {
memory[name] = inst;
}
Memory getMemory( string name ) {
if ( name in memory ) {
return memory[name];
}
throw new Exception( "Invalid memory specified" );
}
public abstract void showInformation( ) {
}
}
|
D
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.