code
stringlengths 3
10M
| language
stringclasses 31
values |
|---|---|
<?xml version="1.0" encoding="ASCII"?>
<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="_KkQdsFz5Eemem_7_jX00Yw7ffd0441-6512-4e18-827f-aeee38889ebf-Sequence.notation#_-_76Yl0CEemHZIzWnsr2RQ"/>
</availablePage>
</pageList>
<sashModel currentSelection="//@sashModel/@windows.0/@children.0">
<windows>
<children xsi:type="di:TabFolder">
<children>
<emfPageIdentifier href="_KkQdsFz5Eemem_7_jX00Yw7ffd0441-6512-4e18-827f-aeee38889ebf-Sequence.notation#_-_76Yl0CEemHZIzWnsr2RQ"/>
</children>
</children>
</windows>
</sashModel>
</di:SashWindowsMngr>
|
D
|
instance DIA_SALENTIN_EXIT(C_Info)
{
npc = vlk_6108_salentin;
nr = 999;
condition = dia_salentin_exit_condition;
information = dia_salentin_exit_info;
permanent = TRUE;
description = Dialog_Ende;
};
func int dia_salentin_exit_condition()
{
return TRUE;
};
func void dia_salentin_exit_info()
{
AI_StopProcessInfos(self);
};
instance DIA_SALENTIN_HALLO(C_Info)
{
npc = vlk_6108_salentin;
nr = 1;
condition = dia_salentin_hallo_condition;
information = dia_salentin_hallo_info;
permanent = FALSE;
important = TRUE;
};
func int dia_salentin_hallo_condition()
{
return TRUE;
};
func void dia_salentin_hallo_info()
{
AI_Output(self,other,"DIA_Salentin_Hallo_01_00"); //Hej! CO TADY DĚLÁŠ?!... (udiveně) A jak se tu sakra dostal?!
AI_Output(self,other,"DIA_Salentin_Hallo_01_01"); //Jestli tě paladinové uvidí, zabijou te!
AI_Output(other,self,"DIA_Salentin_Hallo_01_02"); //Bez obav, řekněme, že se k nim potřebuji dostat.
AI_Output(self,other,"DIA_Salentin_Hallo_01_03"); //COŽE?! VÍŠ VŮBEC KDE JSI?!
AI_Output(self,other,"DIA_Salentin_Hallo_01_04"); //Ó, chlape, zmiz, než tě najdou... (soucitne)
BEONETLU = TRUE;
AI_StopProcessInfos(self);
};
instance DIA_SALENTIN_BAUERNAUFSTAND(C_Info)
{
npc = vlk_6108_salentin;
nr = 2;
condition = dia_salentin_bauernaufstand_condition;
information = dia_salentin_bauernaufstand_info;
permanent = FALSE;
description = "Kdo jsi?";
};
func int dia_salentin_bauernaufstand_condition()
{
return TRUE;
};
func void dia_salentin_bauernaufstand_info()
{
AI_Output(other,self,"DIA_Salentin_Bauernaufstand_01_00"); //Kdo jsi?
AI_Output(self,other,"DIA_Salentin_Bauernaufstand_01_01"); //COŽE?! Ty jsi stále tady!... (nervózně)
AI_Output(other,self,"DIA_Salentin_Bauernaufstand_01_03"); //Nebojte se! Jsem tady služebně.
AI_Output(self,other,"DIA_Salentin_Bauernaufstand_01_04"); //A co je to za práci, že tě sem dostala?
AI_Output(other,self,"DIA_Salentin_Bauernaufstand_01_05"); //Hledám jeden amulet. Přesněji - amulet Triramar. Víš o nem neco?
AI_Output(self,other,"DIA_Salentin_Bauernaufstand_01_06"); //Jaké Triramar? Co to je?
AI_Output(other,self,"DIA_Salentin_Bauernaufstand_01_08"); //Potřebuji ho a bez něj neodejdu.
AI_Output(self,other,"DIA_Salentin_Bauernaufstand_01_09"); //(smích) Ty odsud už stejně nikam neodejdeš!
AI_Output(self,other,"DIA_Salentin_Bauernaufstand_01_10"); //Jediný způsob, jak se dostat z tohoto ostrova - je použít magický portál v kapli na severu, ale ta je střežena paladiny.
AI_Output(self,other,"DIA_Salentin_Bauernaufstand_01_11"); //Ale nemyslím si, že tě odsud pustí živího.
AI_Output(self,other,"DIA_Salentin_Bauernaufstand_01_12"); //Ano chlapče, chytil ses!
};
instance DIA_SALENTIN_TRIRAMAR(C_Info)
{
npc = vlk_6108_salentin;
nr = 2;
condition = dia_salentin_triramar_condition;
information = dia_salentin_triramar_info;
permanent = FALSE;
description = "A kde paladinové střeží ten amulet?";
};
func int dia_salentin_triramar_condition()
{
if(Npc_KnowsInfo(other,dia_salentin_bauernaufstand))
{
return TRUE;
};
};
func void dia_salentin_triramar_info()
{
AI_Output(other,self,"DIA_Salentin_Triramar_01_00"); //Kaple, říkáš? (zamyšleně) a nemůže tam být ten amulet?
AI_Output(self,other,"DIA_Salentin_Triramar_01_01"); //Nemám ponětí co je tam schované. Nepřibližuj se k ní na dosah střeli, jestli máš svůj život rád.
AI_Output(other,self,"DIA_Salentin_Triramar_01_03"); //Přestaň mě strašit a řekni mě, kde je ta kaple.
AI_Output(self,other,"DIA_Salentin_Triramar_01_04"); //Blázne, zešílel jsi.
AI_Output(self,other,"DIA_Salentin_Triramar_01_06"); //Kaple se nachází sverně od mé chaty. A když už se tam chystáš, poprosím tě o jednu laskavost.
AI_Output(self,other,"DIA_Salentin_Triramar_01_07"); //... postarej se ať tě nezabijou moc daleko ode mně - hodila by se mně tvoje výbava. (sarkasticky)
AI_Output(other,self,"DIA_Salentin_Triramar_01_08"); //Koukám, že jsi veselá kopa. Řekni mě radši, kolik je v kapli paladinů?
AI_Output(self,other,"DIA_Salentin_Triramar_01_11"); //Ne moc, většina je společně s velitelem v táboře ve východní části ostrova.
AI_Output(other,self,"DIA_Salentin_Triramar_01_12"); //Pak se vplížím k nim do tábora.
AI_Output(self,other,"DIA_Salentin_Triramar_01_13"); //Cože?! (přeskakuje mu hlas) Ach, ano, jo, běž, utíkej... ať se můžeš vydat za světlem.
};
instance DIA_SALENTIN_GETOUT(C_Info)
{
npc = vlk_6108_salentin;
nr = 2;
condition = dia_salentin_getout_condition;
information = dia_salentin_getout_info;
permanent = FALSE;
description = "Jak jinak se dá dostat z tohoto ostrova?";
};
func int dia_salentin_getout_condition()
{
if(Npc_KnowsInfo(other,dia_salentin_bauernaufstand))
{
return TRUE;
};
};
func void dia_salentin_getout_info()
{
AI_Output(other,self,"DIA_Salentin_GetOut_01_00"); //Jak jinak se dá dostat z tohoto ostrova?
AI_Output(self,other,"DIA_Salentin_GetOut_02_01"); //Nijak. Myslíš, že bych jinak tady trčel tak dlouho!
AI_Output(self,other,"DIA_Salentin_GetOut_04_03"); //Tenhle ostrov mě přivádí k šílenství.
AI_Output(self,other,"DIA_Salentin_GetOut_05_04"); //Paladinové, chvála Innosovi, mě nechávají na pokoji. Ale k portálu mě taky nepustí.
};
instance DIA_SALENTIN_HOWIN(C_Info)
{
npc = vlk_6108_salentin;
nr = 2;
condition = dia_salentin_howin_condition;
information = dia_salentin_howin_info;
permanent = FALSE;
description = "A jak ses sem dostal?";
};
func int dia_salentin_howin_condition()
{
if(Npc_KnowsInfo(other,dia_salentin_bauernaufstand))
{
return TRUE;
};
};
func void dia_salentin_howin_info()
{
AI_Output(other,self,"DIA_Salentin_HowIn_01_00"); //A jak ses sem dostal?
AI_Output(self,other,"DIA_Salentin_HowIn_01_04"); //Byl jsem námořníkem na jedné obchodní lodi. Přepravovali jsme magickou rudu z jedné bohem zapomenuté kolonie...
AI_Output(self,other,"DIA_Salentin_HowIn_01_05"); //Když jsme se vraceli na pevninu, tak nás zastihla hrozná bouře. Loď to nepřežila, rozlomila se na dvě části a mě to smetlo do moře.
AI_Output(self,other,"DIA_Salentin_HowIn_01_09"); //Probudil jsem se na ostrově a kolem mě spousta paladinů.
AI_Output(other,self,"DIA_Salentin_HowIn_01_10"); //Proč tě nechali žít?
AI_Output(self,other,"DIA_Salentin_HowIn_01_11"); //Nejsou to divoký zvířata. A já jsem se na jejich ostrov dostal nedobrovolně.
AI_Output(self,other,"DIA_Salentin_HowIn_01_13"); //Dovolili mě žít na tomto ostrově - dali mě jídlo, nové oblečení a dokonce i nástroje.
AI_Output(other,self,"DIA_Salentin_HowIn_01_14"); //A proč jsi nezůstal žít s nima?
AI_Output(self,other,"DIA_Salentin_HowIn_01_15"); //Chlapče, je to vojenský tábor, ne hostinec.
AI_Output(self,other,"DIA_Salentin_HowIn_01_23"); //Snažím se být jim co nejméně na očích a radím ti, udělej to také.
};
instance DIA_SALENTIN_CANPASS(C_Info)
{
npc = vlk_6108_salentin;
nr = 1;
condition = dia_salentin_canpass_condition;
information = dia_salentin_canpass_info;
permanent = FALSE;
description = "Chodíš do tábora paladinů?";
};
func int dia_salentin_canpass_condition()
{
if(Npc_KnowsInfo(other,dia_salentin_howin) && (MIS_BELIARHELPME == LOG_SUCCESS) && (CANUSEZIGOSMAGIC == TRUE) && (MEHASTRIRAVAR == TRUE))
{
return TRUE;
};
};
func void dia_salentin_canpass_info()
{
AI_Output(other,self,"DIA_Salentin_CanPass_01_00"); //Chodíš do tábora paladinů?
AI_Output(self,other,"DIA_Salentin_CanPass_01_01"); //Ano, několikrát za měsíc jim nosím ryby co nalovím.
AI_Output(self,other,"DIA_Salentin_CanPass_01_02"); //Na oplátku mě dají maso a vodu. Tak co hlady tady neumřu.
AI_Output(other,self,"DIA_Salentin_CanPass_01_03"); //Takže ti věří když máš povolenej vstup do tábora?
AI_Output(self,other,"DIA_Salentin_CanPass_01_04"); //Ne že by mě důvěřovali, ale nepředstavuju pro ně žádné nebezpečí. Tak mě trpí.
AI_Output(self,other,"DIA_Salentin_CanPass_01_05"); //A já se snažím je nenaštvat. A proč se ptáš?
TELLSALENTINLAGER = TRUE;
Info_ClearChoices(dia_salentin_canpass);
if(ZIGOSMAGICISON == TRUE)
{
Info_AddChoice(dia_salentin_canpass,"Myslím, že mě můžeš být užitečnej.",dia_salentin_canpass_yes);
};
Info_AddChoice(dia_salentin_canpass,"Jen se tak ptám.",dia_salentin_canpass_no);
};
func void dia_salentin_canpass_no()
{
AI_Output(other,self,"DIA_Salentin_CanPass_No_01_00"); //Jen se tak ptám.
AI_Output(self,other,"DIA_Salentin_CanPass_No_01_01"); //Hmmm...
Info_ClearChoices(dia_salentin_canpass);
};
func void dia_salentin_canpass_yes()
{
AI_Output(other,self,"DIA_Salentin_CanPass_Yes_01_00"); //Myslím, že mě můžeš být užitečnej.
AI_Output(other,self,"DIA_Salentin_CanPass_Yes_01_01"); //Vzhledem k tomu, že ti věří - využiju tě abych se dostal k nim do tábora.
AI_Output(self,other,"DIA_Salentin_CanPass_Yes_01_02"); //(opatrně) To znamená? Co máš za lubem?
Info_ClearChoices(dia_salentin_canpass);
if(ZIGOSMAGICISON == TRUE)
{
Info_AddChoice(dia_salentin_canpass,"... GVAR SAX ESK SHATAR...!",dia_salentin_canpass_use);
};
};
func void dia_salentin_canpass_use()
{
B_GivePlayerXP(100);
Snd_Play("DEM_WARN");
Wld_PlayEffect("FX_EarthQuake",self,self,0,0,0,FALSE);
Wld_PlayEffect("spellFX_Innoseye",self,self,0,0,0,FALSE);
AI_PlayAni(other,"T_MAGRUN_2_HEASHOOT");
AI_Output(other,self,"DIA_Salentin_CanPass_Use_01_00"); //... GVAR SAX ESK SHATAR...
AI_Output(other,self,"DIA_Salentin_CanPass_Use_01_01"); //Beliare, pane temnoty! Dej mi svou sílu, převzít tvar člověka.
AI_Output(other,self,"DIA_Salentin_CanPass_Use_01_02"); //Teď dokončím to proč jsem tady!
AI_PlayAni(other,"T_MAGRUN_2_HEASHOOT");
AI_Output(self,other,"DIA_Salentin_CanPass_Use_01_03"); //O Innos! Kdo jsi? (v panice) Ty sloužíš Beliarovi?!
AI_Output(self,other,"DIA_Salentin_CanPass_Use_01_04"); //A co je to za magii?! Innos, co se se mnou děje! Neee...
USESALENTINAMULET = TRUE;
Info_ClearChoices(dia_salentin_canpass);
if(ZIGOSMAGICISON == TRUE)
{
Info_AddChoice(dia_salentin_canpass,"(použít amulet)",dia_salentin_canpass_usedead);
};
};
func void dia_salentin_canpass_usedead()
{
AI_StopProcessInfos(self);
Npc_SetRefuseTalk(self,10);
B_Attack(self,other,0,0);
};
instance DIA_SALENTIN_CANPASSAGAIN(C_Info)
{
npc = vlk_6108_salentin;
nr = 1;
condition = dia_salentin_canpassagain_condition;
information = dia_salentin_canpassagain_info;
permanent = TRUE;
description = "Mám pro tebe řešení.";
};
func int dia_salentin_canpassagain_condition()
{
if((TELLSALENTINLAGER == TRUE) && (USESALENTINAMULET == FALSE) && (CANUSEZIGOSMAGIC == TRUE) && (MEHASTRIRAVAR == TRUE))
{
return TRUE;
};
};
func void dia_salentin_canpassagain_info()
{
AI_Output(other,self,"DIA_Salentin_CanPassAgain_01_00"); //Mám pro tebe řešení.
AI_Output(self,other,"DIA_Salentin_CanPassAgain_01_01"); //A jaké?
Info_ClearChoices(dia_salentin_canpassagain);
if(ZIGOSMAGICISON == TRUE)
{
Info_AddChoice(dia_salentin_canpassagain,"Myslím, že mě můžeš být užitečnej.",dia_salentin_canpassagain_yes);
};
Info_AddChoice(dia_salentin_canpassagain,"Jen se tak ptám.",dia_salentin_canpassagain_no);
};
func void dia_salentin_canpassagain_no()
{
AI_Output(other,self,"DIA_Salentin_CanPassAgain_No_01_00"); //Zapomeň na to
AI_Output(self,other,"DIA_Salentin_CanPassAgain_No_01_01"); //Hnn... Dobře, jak říkáš.
Info_ClearChoices(dia_salentin_canpassagain);
};
func void dia_salentin_canpassagain_yes()
{
AI_Output(other,self,"DIA_Salentin_CanPass_Yes_01_00"); //Myslím, že mě můžeš být užitečnej.
AI_Output(other,self,"DIA_Salentin_CanPass_Yes_01_01"); //Vzhledem k tomu, že ti věří - využiju tě abych se dostal k nim do tábora.
AI_Output(self,other,"DIA_Salentin_CanPass_Yes_01_02"); //(opatrně) To znamená? Co máš za lubem?
Info_ClearChoices(dia_salentin_canpassagain);
if(ZIGOSMAGICISON == TRUE)
{
Info_AddChoice(dia_salentin_canpassagain,"... GVAR SAX ESK SHATAR...!",dia_salentin_canpassagain_use);
};
};
func void dia_salentin_canpassagain_use()
{
B_GivePlayerXP(100);
Snd_Play("DEM_WARN");
Wld_PlayEffect("FX_EarthQuake",self,self,0,0,0,FALSE);
Wld_PlayEffect("spellFX_Innoseye",self,self,0,0,0,FALSE);
AI_PlayAni(other,"T_MAGRUN_2_HEASHOOT");
AI_Output(other,self,"DIA_Salentin_CanPass_Use_01_00"); //... GVAR SAX ESK SHATAR...!
AI_Output(other,self,"DIA_Salentin_CanPass_Use_01_01"); //Beliare, pane temnoty! Dej mi svou sílu, převzít tvar člověka.
AI_Output(other,self,"DIA_Salentin_CanPass_Use_01_02"); //Teď dokončím to proč jsem tady!
AI_PlayAni(other,"T_MAGRUN_2_HEASHOOT");
AI_Output(self,other,"DIA_Salentin_CanPass_Use_01_03"); //O Innos! Kdo jsi? (v panice) Ty sloužíš Beliarovi?!
AI_Output(self,other,"DIA_Salentin_CanPass_Use_01_04"); //A co je to za magii?! Innos, co se se mnou děje! Neéé...
USESALENTINAMULET = TRUE;
Info_ClearChoices(dia_salentin_canpassagain);
if(ZIGOSMAGICISON == TRUE)
{
Info_AddChoice(dia_salentin_canpassagain,"(použít amulet)",dia_salentin_canpassagain_usedead);
};
};
func void dia_salentin_canpassagain_usedead()
{
AI_StopProcessInfos(self);
Npc_SetRefuseTalk(self,10);
B_Attack(self,other,0,0);
};
instance DIA_SALENTIN_ADVICE(C_Info)
{
npc = vlk_6108_salentin;
nr = 1;
condition = dia_salentin_advice_condition;
information = dia_salentin_advice_info;
permanent = FALSE;
important = TRUE;
};
func int dia_salentin_advice_condition()
{
if(Npc_KnowsInfo(hero,dia_salentin_triramar) && (USESALENTINAMULET == FALSE) && Npc_KnowsInfo(hero,dia_salentin_howin))
{
return TRUE;
};
};
func void dia_salentin_advice_info()
{
AI_Output(self,other,"DIA_Salentin_Advice_01_00"); //Hej, počkej!
AI_Output(other,self,"DIA_Salentin_Advice_01_01"); //Co ještě?
AI_Output(self,other,"DIA_Salentin_Advice_01_02"); //Jestli opravdu chceš navštívit tábor paladinů,...
AI_Output(self,other,"DIA_Salentin_Advice_01_04"); //Nechoď tam přes den- nebudeš mít jedinou šanci cokoliv udělat, bez ohledu na to co jsi měl za lubem.
AI_Output(self,other,"DIA_Salentin_Advice_01_05"); //Nejlepší je to v noci, když všichni spí. Snad až na pár výjimek.
AI_Output(other,self,"DIA_Salentin_Advice_01_07"); //Odkud tohle všechno víš?
AI_Output(self,other,"DIA_Salentin_Advice_01_08"); //A není to jedno? Prostě si pamatuj co jsem ti řek.
};
|
D
|
module android.java.android.app.FragmentManager_OnBackStackChangedListener;
public import android.java.android.app.FragmentManager_OnBackStackChangedListener_d_interface;
import arsd.jni : ImportExportImpl;
mixin ImportExportImpl!FragmentManager_OnBackStackChangedListener;
import import0 = android.java.java.lang.Class;
|
D
|
/* GML utils
* coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
* Understanding is not required. Only obedience.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License ONLY.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
module gaem.utils.cliarg is aliced;
import gaem.parser;
import gaem.utils.loader;
import gaem.ungmk;
// ////////////////////////////////////////////////////////////////////////// //
public bool cliLoadGmkScripts = true;
// ////////////////////////////////////////////////////////////////////////// //
NodeFunc[] cliProcessArgs(Opts...) (ref string[] args, void delegate (Gmk gmk) procgmk=null) {
NodeFunc[] funcs;
bool nomore = false;
string[] scargs;
bool doScripts = true;
bool doActions = true;
bool dumpFileNames = false;
foreach (string fname; args[1..$]) {
import std.file;
import std.path;
if (nomore) {
scargs ~= fname;
} else {
if (fname.length == 0) continue;
if (fname == "--") { nomore = true; continue; }
if (fname == "-S") { doScripts = false; continue; }
if (fname == "-A") { doActions = false; continue; }
if (fname == "-d") { dumpFileNames = true; continue; }
bool found = false;
foreach (immutable idx, immutable val; Opts) {
static if (idx%2 == 0) {
if (fname == Opts[idx]) { found = true; Opts[idx+1](fname); break; }
}
}
if (found) continue;
if (fname[0] == '-') throw new Exception("invalid option: '"~fname~"'");
if (fname[0] == '@') {
if (fname.length < 2) assert(0, "gmk file?");
if (dumpFileNames) { import std.stdio; writeln("loading '", fname[1..$], "'..."); }
auto gmk = new Gmk(fname[1..$]);
if (cliLoadGmkScripts) {
funcs ~= gmkLoadScripts(gmk, doScripts:doScripts, doActions:doActions);
}
if (procgmk !is null) procgmk(gmk);
continue;
}
if (isDir(fname)) {
foreach (auto de; dirEntries(fname, "*.gm[lx]", SpanMode.breadth)) {
bool doit = true;
foreach (auto pt; pathSplitter(de.dirName)) {
if (pt.length && pt[0] == '_') { doit = false; break; }
}
if (doit) {
if (dumpFileNames) { import std.stdio; writeln("loading '", de.name, "'..."); }
funcs ~= loadScript(de.name, true);
}
}
} else {
if (dumpFileNames) { import std.stdio; writeln("loading '", fname, "'..."); }
funcs ~= loadScript(fname, true);
}
}
}
args = scargs;
return funcs;
}
|
D
|
<?xml version="1.0" encoding="ASCII" standalone="no"?>
<di:SashWindowsMngr xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmi:version="2.0">
<pageList>
<availablePage>
<emfPageIdentifier href="VAR_26_MobileMedia-3327557241.notation#_copSALmGEeKQQp7P9cQvNQ"/>
</availablePage>
</pageList>
<sashModel currentSelection="//@sashModel/@windows.0/@children.0">
<windows>
<children xsi:type="di:TabFolder">
<children>
<emfPageIdentifier href="VAR_26_MobileMedia-3327557241.notation#_copSALmGEeKQQp7P9cQvNQ"/>
</children>
</children>
</windows>
</sashModel>
</di:SashWindowsMngr>
|
D
|
// Written by Christopher E. Miller
// See the included license.txt for copyright and license details.
///
module os.win.gui.panel;
private import os.win.gui.control, os.win.gui.base, os.win.gui.x.winapi;
///
class Panel: ContainerControl // docmain
{
///
void borderStyle(BorderStyle bs) // setter
{
switch(bs)
{
case BorderStyle.FIXED_3D:
_style(_style() & ~WS_BORDER);
_exStyle(_exStyle() | WS_EX_CLIENTEDGE);
break;
case BorderStyle.FIXED_SINGLE:
_exStyle(_exStyle() & ~WS_EX_CLIENTEDGE);
_style(_style() | WS_BORDER);
break;
case BorderStyle.NONE:
_style(_style() & ~WS_BORDER);
_exStyle(_exStyle() & ~WS_EX_CLIENTEDGE);
break;
}
if(created)
{
redrawEntire();
}
}
/// ditto
BorderStyle borderStyle() // getter
{
if(_exStyle() & WS_EX_CLIENTEDGE)
return BorderStyle.FIXED_3D;
else if(_style() & WS_BORDER)
return BorderStyle.FIXED_SINGLE;
return BorderStyle.NONE;
}
this()
{
//ctrlStyle |= ControlStyles.SELECTABLE | ControlStyles.CONTAINER_CONTROL;
ctrlStyle |= ControlStyles.CONTAINER_CONTROL;
/+ wstyle |= WS_TABSTOP; +/ // Should WS_TABSTOP be set?
//wexstyle |= WS_EX_CONTROLPARENT; // Allow tabbing through children. ?
}
}
|
D
|
/*************************************************************************
** Undead Orc Warrior Prototype **
*************************************************************************/
PROTOTYPE Mst_Default_UndeadOrcWarrior (C_Npc)
{
name = "Temple Guard";
guild = GIL_UNDEADORC;
aivar[AIV_MM_REAL_ID] = ID_UNDEADORCWARRIOR;
level = 25;
//----------------------------------------------------------
attribute [ATR_STRENGTH] = 100;
attribute [ATR_DEXTERITY] = 100;
attribute [ATR_HITPOINTS_MAX] = 400;
attribute [ATR_HITPOINTS] = 400;
attribute [ATR_MANA_MAX] = 0;
attribute [ATR_MANA] = 0;
//----------------------------------------------------------
protection [PROT_BLUNT] = 50; //9999; //immun
protection [PROT_EDGE] = 50; //9999; //immun
protection [PROT_POINT] = 25; //9999; //immun
protection [PROT_FIRE] = 50; //9999; //immun
protection [PROT_FLY] = 50; //9999; //immun
protection [PROT_MAGIC] = 50; //120;
//----------------------------------------------------------
damagetype = DAM_EDGE;
// damage [DAM_INDEX_BLUNT] = 0;
// damage [DAM_INDEX_EDGE] = 0;
// damage [DAM_INDEX_POINT] = 0;
// damage [DAM_INDEX_FIRE] = 0;
// damage [DAM_INDEX_FLY] = 0;
// damage [DAM_INDEX_MAGIC] = 0;
//---------------------------------------------------------
fight_tactic = FAI_ORC;
//---------------------------------------------------------
senses = SENSE_HEAR | SENSE_SEE | SENSE_SMELL;
senses_range = 3000;
aivar[AIV_MM_Behaviour] = PASSIVE;
aivar[AIV_MM_PercRange] = 1200;
aivar[AIV_MM_DrohRange] = 1000;
aivar[AIV_MM_AttackRange] = 700;
aivar[AIV_MM_DrohTime] = 5;
aivar[AIV_MM_FollowTime] = 10;
aivar[AIV_MM_FollowInWater] = FALSE;
//-------------------------------------------------------------
start_aistate = ZS_MM_AllScheduler;
//aivar[AIV_MM_RestStart] = OnlyRoutine;
};
//-------------------------------------------------------------
func void Set_UndeadOrcWarrior_Visuals()
{
Mdl_SetVisual (self, "Orc.mds");
// Body-Mesh Body-Tex Skin-Color Head-MMS Head-Tex Teeth-Tex ARMOR
Mdl_SetVisualBody (self, "UOW_Body", DEFAULT, DEFAULT, "", DEFAULT, DEFAULT, -1);
};
/*************************************************************************
** Orc Warrior Undead **
*************************************************************************/
// in den Instanz-Scripten bitte NUR die Werte eintragen, die vom Prototyp abweichen sollen!
INSTANCE UndeadOrcWarrior (Mst_Default_UndeadOrcWarrior)
{
Set_UndeadOrcWarrior_Visuals();
EquipItem (self, ItMw2hOrcMace01);
};
INSTANCE UndeadOWH (Mst_Default_UndeadOrcWarrior)
{
name = "High Temple Guard";
level = 40;
attribute [ATR_STRENGTH] = 120;
//----------------------------------------------------------
protection [PROT_BLUNT] = 70; //9999; //immun
protection [PROT_EDGE] = 70; //9999; //immun
protection [PROT_POINT] = 35; //9999; //immun
protection [PROT_FIRE] = 70; //9999; //immun
protection [PROT_FLY] = 70; //9999; //immun
protection [PROT_MAGIC] = 70; //120;
Set_UndeadOrcWarrior_Visuals();
EquipItem (self, ItMw2hOrcMace01);
};
|
D
|
/* -------------------- CZ CHANGELOG -------------------- */
/*
v1.01:
(4x) MIS_ORcGREATWAR - MIS_ORCGREATWAR (cyrilice -> latinka)
*/
instance DIA_garond_EXIT(C_Info)
{
npc = PAL_250_Garond;
nr = 999;
condition = DIA_Garond_EXIT_Condition;
information = DIA_Garond_EXIT_Info;
permanent = TRUE;
description = Dialog_Ende;
};
func int DIA_Garond_EXIT_Condition()
{
if(Kapitel < 3)
{
return TRUE;
};
};
func void DIA_Garond_EXIT_Info()
{
if((MIS_ScoutMine == LOG_Running) && (KAPITELORCATC == FALSE) && (MIS_LostPaladins == FALSE))
{
AI_Output(self,other,"DIA_Garond_SeekPaladin_01_00"); //Počkej...
AI_Output(self,other,"DIA_Garond_SeekPaladin_01_01"); //Je tady jeden problém, se kterým bys mi mohl pomoct.
AI_Output(other,self,"DIA_Garond_SeekPaladin_01_02"); //O co jde?
AI_Output(self,other,"DIA_Garond_SeekPaladin_01_03"); //Když jsme se vydali na hrad, rozdělili jsme se do tří skupin, abychom u skřetů nepřitahovali moc pozornosti.
AI_Output(self,other,"DIA_Garond_SeekPaladin_01_04"); //První skupinu jsem vedl já. Ostatní dvě paladinové Albert a Wenzel.
AI_Output(self,other,"DIA_Garond_SeekPaladin_01_05"); //Ale od té doby jsem o nich neslyšel. Nevím, jestli jsou vůbec naživu!
AI_Output(self,other,"DIA_Garond_SeekPaladin_01_06"); //Proto bych byl rád, kdybys zjistil, co s nimi je.
AI_Output(other,self,"DIA_Garond_SeekPaladin_01_07"); //V pořádku. Udělám, co můžu.
AI_Output(self,other,"DIA_Garond_SeekPaladin_01_08"); //Budu očekávat tvůj návrat.
MIS_LostPaladins = LOG_Running;
Log_CreateTopic(TOPIC_LostPaladins,LOG_MISSION);
Log_SetTopicStatus(TOPIC_LostPaladins,LOG_Running);
B_LogEntry(TOPIC_LostPaladins,"Garond mě požádal, abych zjistil, co se stalo se skupinami, kterým veleli Albert a Wenzel.");
};
AI_StopProcessInfos(self);
};
var int Garond_LastPetzCounter;
var int Garond_LastPetzCrime;
instance DIA_Garond_PMSchulden(C_Info)
{
npc = PAL_250_Garond;
nr = 1;
condition = DIA_Garond_PMSchulden_Condition;
information = DIA_Garond_PMSchulden_Info;
permanent = TRUE;
important = TRUE;
};
func int DIA_Garond_PMSchulden_Condition()
{
if(Npc_IsInState(self,ZS_Talk) && (Garond_Schulden > 0) && (B_GetGreatestPetzCrime(self) <= Garond_LastPetzCrime) && (KAPITELORCATC == FALSE))
{
return TRUE;
};
};
func void dia_garond_petzmaster_attackmurder()
{
var string concatText;
AI_StopProcessInfos(self);
B_Attack(self,other,AR_HumanMurderedHuman,0);
GLOBAL_MAKE_BANDIT_FORCITY = 1;
GARONDTROUBLE = TRUE;
concatText = "Paladinové tě označili za psance!";
AI_Print(concatText);
};
func void dia_garond_pmschulden_attackmurder()
{
var string concatText;
AI_StopProcessInfos(self);
B_Attack(self,other,AR_HumanMurderedHuman,0);
GLOBAL_MAKE_BANDIT_FORCITY = 1;
GARONDTROUBLE = TRUE;
concatText = "Paladinové tě označili za psance!";
AI_Print(concatText);
};
func void DIA_Garond_PMSchulden_Info()
{
var int diff;
var string concatText1;
var string concatText2;
var string concattextschulden;
var string tsettext1;
var string tsettext2;
var string tsettext3;
var int temp1;
AI_Output(self,other,"DIA_Garond_PMSchulden_10_00"); //Nemáme se o čem bavit, dokud nezaplatíš pokutu.
temp1 = 0;
if(GLOBAL_OLDCAMP_MURDER > 2)
{
temp1 = 1;
};
if(GLOBAL_OLDCAMP_THEFT > 10)
{
temp1 = 1;
};
if(GLOBAL_OLDCAMP_ATTACK > 5)
{
temp1 = 1;
};
if(temp1 == 1)
{
if(GLOBAL_OLDCAMP_MURDER > 2)
{
tsettext1 = ConcatStrings(IntToString(GLOBAL_OLDCAMP_MURDER),"");
tsettext2 = ConcatStrings(tsettext1,PRINT_MURDERCOUNT2_OLDCAMP);
tsettext3 = ConcatStrings(PRINT_MURDERCOUNT_OLDCAMP,tsettext2);
AI_Output(self,other,"DIA_Garond_PMSchulden_08_36"); //Ale když se podívám na tvé nedávné chování...
AI_Output(self,other,"DIA_Garond_PMSchulden_08_37"); //Jsi vrah! A má svatá povinnost je zbavit svět takových, jako jsi ty!
AI_Output(self,other,"DIA_Garond_PMSchulden_08_38"); //A věř mi, že tuhle povinnost k lidem a Innosovi splním, ať to stojí, co to stojí!
AI_ReadyMeleeWeapon(self);
AI_Output(self,other,"DIA_Garond_PMSchulden_08_39"); //Zemři!
}
else if(GLOBAL_OLDCAMP_ATTACK > 5)
{
tsettext1 = ConcatStrings(IntToString(GLOBAL_OLDCAMP_ATTACK),"");
tsettext2 = ConcatStrings(tsettext1,PRINT_ATTACKCOUNT2_OLDCAMP);
tsettext3 = ConcatStrings(PRINT_ATTACKCOUNT_OLDCAMP,tsettext2);
AI_Output(self,other,"DIA_Garond_PMSchulden_08_40"); //Ale když se podívám na tvé nedávné chování...
AI_Output(self,other,"DIA_Garond_PMSchulden_08_41"); //Jsi bandita a rváč! A má svatá povinnost je zbavit svět takových, jako jsi ty!
AI_Output(self,other,"DIA_Garond_PMSchulden_08_42"); //A věř mi, že tuhle povinnost k lidem a Innosovi splním, ať to stojí, co to stojí!
AI_ReadyMeleeWeapon(self);
AI_Output(self,other,"DIA_Garond_PMSchulden_08_43"); //Zemři!
}
else if(GLOBAL_OLDCAMP_THEFT > 10)
{
tsettext1 = ConcatStrings(IntToString(GLOBAL_OLDCAMP_THEFT),"");
tsettext2 = ConcatStrings(tsettext1,PRINT_THEFTCOUNT2_OLDCAMP);
tsettext3 = ConcatStrings(PRINT_THEFTCOUNT_OLDCAMP,tsettext2);
AI_Output(self,other,"DIA_Garond_PMSchulden_08_44"); //Ale když se podívám na tvé nedávné chování...
AI_Output(self,other,"DIA_Garond_PMSchulden_08_45"); //Jsi zloděj! A má svatá povinnost je zbavit svět takových, jako jsi ty!
AI_Output(self,other,"DIA_Garond_PMSchulden_08_46"); //A věř mi, že tuhle povinnost k lidem a Innosovi splním, ať to stojí, co to stojí!
AI_ReadyMeleeWeapon(self);
AI_Output(self,other,"DIA_Garond_PMSchulden_08_47"); //Zemři!
};
Log_CreateTopic(TOPIC_DIPLOM,LOG_NOTE);
B_LogEntry(TOPIC_DIPLOM,"Moje vztahy s paladiny jsou kvůli mým neustálým výstřelkům na hradě na bodu mrazu. Teď mě považují za psance - a to i ve městě!");
Info_ClearChoices(DIA_Garond_PMSchulden);
Info_ClearChoices(DIA_Garond_PETZMASTER);
Info_AddChoice(DIA_Garond_PMSchulden,"Počkej... (utéct)",dia_garond_pmschulden_attackmurder);
}
else
{
if(B_GetTotalPetzCounter(self) > Garond_LastPetzCounter)
{
AI_Output(self,other,"DIA_Garond_PMSchulden_10_01"); //A ta podle posledních obvinění dokonce ještě vzrostla.
AI_Output(self,other,"DIA_Garond_PMSchulden_10_02"); //Zase ses dostal do dalších potíží.
diff = B_GetTotalPetzCounter(self) - Garond_LastPetzCounter;
if(diff > 0)
{
Garond_Schulden = Garond_Schulden + (diff * 250);
};
if(Garond_Schulden < 1000)
{
AI_Output(self,other,"DIA_Garond_PMSchulden_10_03"); //Ale doufám, že teď už konečně tu pokutu zaplatíš. Celkem...
AI_Output(other,self,"DIA_Garond_PMSchulden_10_03A"); //Kolik?
if(Garond_Schulden <= 1000)
{
B_Say_Gold(self,other,Garond_Schulden);
}
else
{
concatText1 = ConcatStrings(IntToString(Garond_Schulden),"");
concatText2 = ConcatStrings(concatText1,PRINT_SHULDEN2);
concattextschulden = ConcatStrings(PRINT_SHULDEN,concatText2);
AI_Print(concattextschulden);
};
}
else
{
AI_Output(self,other,"DIA_Garond_PMSchulden_10_04"); //Zklamal jsi mě. Ta pokuta je celkem...
AI_Output(other,self,"DIA_Garond_PMSchulden_10_04A"); //Kolik?
if(Garond_Schulden <= 1000)
{
B_Say_Gold(self,other,Garond_Schulden);
}
else
{
concatText1 = ConcatStrings(IntToString(Garond_Schulden),"");
concatText2 = ConcatStrings(concatText1,PRINT_SHULDEN2);
concattextschulden = ConcatStrings(PRINT_SHULDEN,concatText2);
AI_Print(concattextschulden);
};
};
}
else if(B_GetGreatestPetzCrime(self) < Garond_LastPetzCrime)
{
AI_Output(self,other,"DIA_Garond_PMSchulden_10_05"); //Zaslechl jsem nějaké novinky.
if(Garond_LastPetzCrime == CRIME_MURDER)
{
AI_Output(self,other,"DIA_Garond_PMSchulden_10_06"); //Najednou tě už nikdo neobviňuje z vraždy.
GLOBAL_OLDCAMP_MURDER = GLOBAL_OLDCAMP_MURDER - 1;
if(GLOBAL_OLDCAMP_MURDER < 0)
{
GLOBAL_OLDCAMP_MURDER = 0;
};
};
if((Garond_LastPetzCrime == CRIME_THEFT) || ((Garond_LastPetzCrime > CRIME_THEFT) && (B_GetGreatestPetzCrime(self) < CRIME_THEFT)))
{
AI_Output(self,other,"DIA_Garond_PMSchulden_10_07"); //Nikdo si nepamatuje, že bys byl zloděj.
GLOBAL_OLDCAMP_THEFT = GLOBAL_OLDCAMP_THEFT - 1;
if(GLOBAL_OLDCAMP_THEFT < 0)
{
GLOBAL_OLDCAMP_THEFT = 0;
};
};
if((Garond_LastPetzCrime == CRIME_ATTACK) || ((Garond_LastPetzCrime > CRIME_ATTACK) && (B_GetGreatestPetzCrime(self) < CRIME_ATTACK)))
{
AI_Output(self,other,"DIA_Garond_PMSchulden_10_08"); //Už není nikdo, kdo by tvrdil, že tě viděl zapleteného do nějaké rvačky.
GLOBAL_OLDCAMP_ATTACK = GLOBAL_OLDCAMP_ATTACK - 1;
if(GLOBAL_OLDCAMP_ATTACK < 0)
{
GLOBAL_OLDCAMP_ATTACK = 0;
};
};
if(B_GetGreatestPetzCrime(self) == CRIME_NONE)
{
AI_Output(self,other,"DIA_Garond_PMSchulden_10_09"); //Vypadá to, že svědci svá obvinění stáhli.
};
AI_Output(self,other,"DIA_Garond_PMSchulden_10_10"); //Nevím, co se stalo, ale varuji tě! Už to nezkoušej!
if(B_GetGreatestPetzCrime(self) == CRIME_NONE)
{
AI_Output(self,other,"DIA_Garond_PMSchulden_10_11"); //Rozhodl jsem se odpustit ti tvé pokuty.
AI_Output(self,other,"DIA_Garond_PMSchulden_10_12"); //Ale nedělej už tady na hradě problémy!
Garond_Schulden = 0;
Garond_LastPetzCounter = 0;
Garond_LastPetzCrime = CRIME_NONE;
}
else
{
AI_Output(self,other,"DIA_Garond_PMSchulden_10_13"); //Abychom si to vyjasnili: pokutu budeš muset zaplatit tak jako tak.
if(Garond_Schulden <= 1000)
{
B_Say_Gold(self,other,Garond_Schulden);
}
else
{
concatText1 = ConcatStrings(IntToString(Garond_Schulden),"");
concatText2 = ConcatStrings(concatText1,PRINT_SHULDEN2);
concattextschulden = ConcatStrings(PRINT_SHULDEN,concatText2);
AI_Print(concattextschulden);
};
AI_Output(self,other,"DIA_Garond_PMSchulden_10_14"); //Takže jak to vyřešíme?
};
};
if(B_GetGreatestPetzCrime(self) != CRIME_NONE)
{
Info_ClearChoices(DIA_Garond_PMSchulden);
Info_ClearChoices(DIA_Garond_PETZMASTER);
Info_AddChoice(DIA_Garond_PMSchulden,"Nemám tolik zlata!",DIA_Garond_PETZMASTER_PayLater);
Info_AddChoice(DIA_Garond_PMSchulden,"Kolik mám zaplatit?",DIA_Garond_PMSchulden_HowMuchAgain);
if(Npc_HasItems(other,ItMi_Gold) >= Garond_Schulden)
{
Info_AddChoice(DIA_Garond_PMSchulden,"Zaplatím.",DIA_Garond_PETZMASTER_PayNow);
};
};
};
};
func void DIA_Garond_PMSchulden_HowMuchAgain()
{
var string concatText1;
var string concatText2;
var string concattextschulden;
AI_Output(other,self,"DIA_Garond_PMSchulden_HowMuchAgain_15_00"); //Kolik mám zaplatit?
if(Garond_Schulden <= 1000)
{
B_Say_Gold(self,other,Garond_Schulden);
}
else
{
concatText1 = ConcatStrings(IntToString(Garond_Schulden),"");
concatText2 = ConcatStrings(concatText1,PRINT_SHULDEN2);
concattextschulden = ConcatStrings(PRINT_SHULDEN,concatText2);
AI_Print(concattextschulden);
};
Info_ClearChoices(DIA_Garond_PMSchulden);
Info_ClearChoices(DIA_Garond_PETZMASTER);
Info_AddChoice(DIA_Garond_PMSchulden,"Nemám dost zlata!",DIA_Garond_PETZMASTER_PayLater);
Info_AddChoice(DIA_Garond_PMSchulden,"Kolik mám zaplatit?",DIA_Garond_PMSchulden_HowMuchAgain);
if(Npc_HasItems(other,ItMi_Gold) >= Garond_Schulden)
{
Info_AddChoice(DIA_Garond_PMSchulden,"Zaplatím.",DIA_Garond_PETZMASTER_PayNow);
};
};
instance DIA_Garond_PETZMASTER(C_Info)
{
npc = PAL_250_Garond;
nr = 1;
condition = DIA_Garond_PETZMASTER_Condition;
information = DIA_Garond_PETZMASTER_Info;
permanent = TRUE;
important = TRUE;
};
func int DIA_Garond_PETZMASTER_Condition()
{
if((B_GetGreatestPetzCrime(self) > Garond_LastPetzCrime) && (KAPITELORCATC == FALSE))
{
return TRUE;
};
};
func void DIA_Garond_PETZMASTER_Info()
{
var string concatText1;
var string concatText2;
var string concattextschulden;
var string tsettext1;
var string tsettext2;
var string tsettext3;
var int temp1;
Garond_Schulden = 0;
if(self.aivar[AIV_TalkedToPlayer] == FALSE)
{
AI_Output(self,other,"DIA_Garond_PETZMASTER_10_00"); //Takže ty jsi ten chlápek, který nám tu na hradě dělá problémy.
};
temp1 = 0;
if(GLOBAL_OLDCAMP_MURDER > 2)
{
temp1 = 1;
};
if(GLOBAL_OLDCAMP_THEFT > 10)
{
temp1 = 1;
};
if(GLOBAL_OLDCAMP_ATTACK > 5)
{
temp1 = 1;
};
if(temp1 == 1)
{
if(GLOBAL_OLDCAMP_MURDER > 2)
{
tsettext1 = ConcatStrings(IntToString(GLOBAL_OLDCAMP_MURDER),"");
tsettext2 = ConcatStrings(tsettext1,PRINT_MURDERCOUNT2_OLDCAMP);
tsettext3 = ConcatStrings(PRINT_MURDERCOUNT_OLDCAMP,tsettext2);
AI_Output(self,other,"DIA_Garond_PETZMASTER_08_48"); //Ale když se podívám na tvé nedávné chování...
AI_Output(self,other,"DIA_Garond_PETZMASTER_08_49"); //Pro krvežíznivé bastardy jako jsi ty mezi námi není místo - a proto tě světská spravedlnost bude soudit ještě před tou nebeskou.
AI_Output(self,other,"DIA_Garond_PETZMASTER_08_50"); //A věř mi, že tuhle povinnost k lidem a Innosovi splním, ať to stojí, co to stojí!
AI_ReadyMeleeWeapon(self);
AI_Output(self,other,"DIA_Garond_PETZMASTER_08_51"); //Zemři!
}
else if(GLOBAL_OLDCAMP_ATTACK > 5)
{
tsettext1 = ConcatStrings(IntToString(GLOBAL_OLDCAMP_ATTACK),"");
tsettext2 = ConcatStrings(tsettext1,PRINT_ATTACKCOUNT2_OLDCAMP);
tsettext3 = ConcatStrings(PRINT_ATTACKCOUNT_OLDCAMP,tsettext2);
AI_Output(self,other,"DIA_Garond_PETZMASTER_08_52"); //Ale když se podívám na tvé nedávné chování...
AI_Output(self,other,"DIA_Garond_PETZMASTER_08_53"); //Jsi bandita a rváč! A má svatá povinnost je zbavit svět takových, jako jsi ty!
AI_Output(self,other,"DIA_Garond_PETZMASTER_08_54"); //A věř mi, že tuhle povinnost k lidem a Innosovi splním, ať to stojí, co to stojí!
AI_ReadyMeleeWeapon(self);
AI_Output(self,other,"DIA_Garond_PETZMASTER_08_55"); //Zemři!
}
else if(GLOBAL_OLDCAMP_THEFT > 10)
{
tsettext1 = ConcatStrings(IntToString(GLOBAL_OLDCAMP_THEFT),"");
tsettext2 = ConcatStrings(tsettext1,PRINT_THEFTCOUNT2_OLDCAMP);
tsettext3 = ConcatStrings(PRINT_THEFTCOUNT_OLDCAMP,tsettext2);
AI_Output(self,other,"DIA_Garond_PETZMASTER_08_56"); //Ale když se podívám na tvé nedávné chování...
AI_Output(self,other,"DIA_Garond_PETZMASTER_08_57"); //Jsi zloděj! A má svatá povinnost je zbavit svět takových, jako jsi ty!
AI_Output(self,other,"DIA_Garond_PETZMASTER_08_58"); //A věř mi, že tuhle povinnost k lidem a Innosovi splním, ať to stojí, co to stojí!
AI_ReadyMeleeWeapon(self);
AI_Output(self,other,"DIA_Garond_PETZMASTER_08_59"); //Zemři!
};
Log_CreateTopic(TOPIC_DIPLOM,LOG_NOTE);
B_LogEntry(TOPIC_DIPLOM,"Moje vztahy s paladiny jsou kvůli mým neustálým výstřelkům na hradě na bodu mrazu. Teď mě považují za psance - a to i ve městě!");
Info_ClearChoices(DIA_Garond_PMSchulden);
Info_ClearChoices(DIA_Garond_PETZMASTER);
Info_AddChoice(DIA_Garond_PETZMASTER,"Počkej! (utéct)",dia_garond_petzmaster_attackmurder);
}
else
{
if(B_GetGreatestPetzCrime(self) == CRIME_MURDER)
{
AI_Output(self,other,"DIA_Garond_PETZMASTER_10_01"); //Sám sebe jsem se ptal, jak dlouho bude trvat, než za mnou přijdeš.
AI_Output(self,other,"DIA_Garond_PETZMASTER_10_02"); //Vražda je to poslední, co tady potřebujeme.
AI_Output(self,other,"DIA_Garond_PETZMASTER_10_03"); //Jsem odpovědný za každého svého muže - a teď mám zase o jednoho méně!
Garond_Schulden = B_GetTotalPetzCounter(self) * 1500;
if((PETZCOUNTER_City_Theft + PETZCOUNTER_City_Attack + PETZCOUNTER_City_Sheepkiller) > 0)
{
AI_Output(self,other,"DIA_Garond_PETZMASTER_10_04"); //Nemluvě o dalších věcech, cos udělal.
};
AI_Output(self,other,"DIA_Garond_PETZMASTER_10_05"); //Dovol mi něco ti vysvětlit. Jsme tu všichni ve stejné pasti.
AI_Output(self,other,"DIA_Garond_PETZMASTER_10_06"); //A já jsem odpovědný za každého muže - včetně tebe.
AI_Output(self,other,"DIA_Garond_PETZMASTER_10_07"); //Pokud potřebuješ někoho zabít, vylez před bránu a vybij se na skřetech! Je jich tam dost.
AI_Output(self,other,"DIA_Garond_PETZMASTER_10_08"); //Dám ti pokutu a ty už nezkoušej tyhle blbosti!
};
if(B_GetGreatestPetzCrime(self) == CRIME_THEFT)
{
AI_Output(self,other,"DIA_Garond_PETZMASTER_10_09"); //Slyšel jsem, že jsi kradl?
if((PETZCOUNTER_City_Attack + PETZCOUNTER_City_Sheepkiller) > 0)
{
AI_Output(self,other,"DIA_Garond_PETZMASTER_10_10"); //Nemluvě o těch ostatních věcech, cos udělal...
};
AI_Output(self,other,"DIA_Garond_PETZMASTER_10_11"); //Nemůžu ti to dovolit. Zdá se, že podceňuješ vážnost situace.
AI_Output(self,other,"DIA_Garond_PETZMASTER_10_12"); //Zaplatíš pokutu jako kompenzaci za tvé činy!
Garond_Schulden = B_GetTotalPetzCounter(self) * 500;
};
if(B_GetGreatestPetzCrime(self) == CRIME_ATTACK)
{
AI_Output(self,other,"DIA_Garond_PETZMASTER_10_13"); //Nerad vidím rvačky mezi mými lidmi.
if(PETZCOUNTER_City_Sheepkiller > 0)
{
AI_Output(self,other,"DIA_Garond_PETZMASTER_10_14"); //A ta věc s ovcemi ti taky zrovna nedělá čest.
};
AI_Output(self,other,"DIA_Garond_PETZMASTER_10_15"); //Budeš muset zaplatit pokutu!
Garond_Schulden = B_GetTotalPetzCounter(self) * 750;
};
if(B_GetGreatestPetzCrime(self) == CRIME_SHEEPKILLER)
{
AI_Output(self,other,"DIA_Garond_PETZMASTER_10_16"); //Ty zabíjíš naše ovce? Patří přece nám všem.
AI_Output(self,other,"DIA_Garond_PETZMASTER_10_17"); //Pak zaplatíš za jejich maso.
Garond_Schulden = 250;
};
AI_Output(other,self,"DIA_Garond_PETZMASTER_15_18"); //Kolik?
if(Garond_Schulden <= 1000)
{
B_Say_Gold(self,other,Garond_Schulden);
}
else
{
concatText1 = ConcatStrings(IntToString(Garond_Schulden),"");
concatText2 = ConcatStrings(concatText1,PRINT_SHULDEN2);
concattextschulden = ConcatStrings(PRINT_SHULDEN,concatText2);
AI_Print(concattextschulden);
};
Info_ClearChoices(DIA_Garond_PMSchulden);
Info_ClearChoices(DIA_Garond_PETZMASTER);
Info_AddChoice(DIA_Garond_PETZMASTER,"Nemám tolik zlata!",DIA_Garond_PETZMASTER_PayLater);
if(Npc_HasItems(other,ItMi_Gold) >= Garond_Schulden)
{
Info_AddChoice(DIA_Garond_PETZMASTER,"Zaplatím.",DIA_Garond_PETZMASTER_PayNow);
};
};
};
func void DIA_Garond_PETZMASTER_PayNow()
{
AI_Output(other,self,"DIA_Garond_PETZMASTER_PayNow_15_00"); //Zaplatím!
B_GiveInvItems(other,self,ItMi_Gold,Garond_Schulden);
AI_Output(self,other,"DIA_Garond_PETZMASTER_PayNow_10_01"); //Dobrá, řeknu to chlapům, aby se uklidnili. Ale ať se to už neopakuje!
B_GrantAbsolution(LOC_OLDCAMP);
Garond_Schulden = 0;
Garond_LastPetzCounter = 0;
Garond_LastPetzCrime = CRIME_NONE;
Info_ClearChoices(DIA_Garond_PETZMASTER);
Info_ClearChoices(DIA_Garond_PMSchulden);
};
func void DIA_Garond_PETZMASTER_PayLater()
{
AI_Output(other,self,"DIA_Garond_PETZMASTER_PayLater_15_00"); //Nemám dost zlata!
AI_Output(self,other,"DIA_Garond_PETZMASTER_PayLater_10_01"); //Tak si ho co nejrychleji sežeň.
AI_Output(self,other,"DIA_Garond_PETZMASTER_PayLater_10_02"); //A varuji tě - pokud nepřestaneš dělat tyhle hlouposti, pokuta ještě poroste!
Garond_LastPetzCounter = B_GetTotalPetzCounter(self);
Garond_LastPetzCrime = B_GetGreatestPetzCrime(self);
AI_StopProcessInfos(self);
};
instance DIA_Garond_Hello(C_Info)
{
npc = PAL_250_Garond;
nr = 4;
condition = DIA_Garond_Hello_Condition;
information = DIA_Garond_Hello_Info;
important = TRUE;
permanent = FALSE;
};
func int DIA_Garond_Hello_Condition()
{
if((Kapitel == 2) && Npc_IsInState(self,ZS_Talk))
{
return TRUE;
};
};
func void DIA_Garond_Hello_Info()
{
AI_Output(self,other,"DIA_Garond_Hello_10_00"); //Odkud jsi přišel? Nejsi nikdo z trestanců ani nikdo z mých lidí. Kdo jsi?
AI_Output(other,self,"DIA_Garond_Hello_15_01"); //Prošel jsem průsmykem.
AI_Output(self,other,"DIA_Garond_Hello_10_02"); //Průsmykem? Takže to někdo dokázal... U Innose!
if(hero.guild == GIL_KDF)
{
AI_Output(self,other,"DIA_Garond_Hello_10_03"); //Proč jsi vážil tuto cestu, mágu?
}
else if(hero.guild == GIL_MIL)
{
AI_Output(self,other,"DIA_Garond_Hello_10_04"); //Jaké jsou tvé rozkazy, vojáku?
}
else if(hero.guild == GIL_SLD)
{
AI_Output(self,other,"DIA_Garond_Hello_10_05"); //Přemýšlím, proč by chtěl žoldák něco takového. Co tady děláš?
}
else if(hero.guild == GIL_KDW)
{
AI_Output(self,other,"DIA_Garond_Hello_10_06"); //Co tady pohledává úctyhodný mág Vody?
}
else if(hero.guild == GIL_KDM)
{
AI_Output(self,other,"DIA_Garond_Hello_10_07"); //A jaká síla tu přitáhla nekromanta?
}
else if(hero.guild == GIL_SEK)
{
AI_Output(self,other,"DIA_Garond_Hello_10_08"); //Podobáš se chlápkům z té sekty, která sídlila v bažinách. Co tady chceš?
}
else
{
AI_Output(self,other,"DIA_Garond_Hello_10_09"); //Co tady děláš?
};
};
instance DIA_Garond_NeedProof(C_Info)
{
npc = PAL_250_Garond;
nr = 1;
condition = DIA_Garond_NeedProof_Condition;
information = DIA_Garond_NeedProof_Info;
description = "Přicházím od lorda Hagena.";
};
func int DIA_Garond_NeedProof_Condition()
{
if(Npc_KnowsInfo(other,DIA_Garond_Hello) && (MIS_OLDWORLD == LOG_Running) && (Kapitel == 2))
{
return TRUE;
};
};
func void DIA_Garond_NeedProof_Info()
{
AI_Output(other,self,"DIA_Garond_NeedProof_15_00"); //Přicházím od lorda Hagena. Chce, abych mu přinesl důkaz o přítomnosti draků.
AI_Output(self,other,"DIA_Garond_NeedProof_10_01"); //A to jsi přišel jen proto, abys ho sebral a zase zmizel?
AI_Output(other,self,"DIA_Garond_NeedProof_15_02"); //Přesně to jsem měl v plánu.
AI_Output(self,other,"DIA_Garond_NeedProof_10_03"); //Takže on chce důkaz? Má ho mít. Ale nemůžu tě poslat zpátky za lordem Hagenem, aniž bych mu řekl o rudě.
AI_Output(self,other,"DIA_Garond_NeedProof_10_04"); //Poslouchej - lord Hagen se musí bezpodmínečně dozvědět o zdejší situaci a o tom, kolik rudy se nám podařilo vydolovat.
AI_Output(other,self,"DIA_Garond_NeedProof_15_05"); //Dobrá, co chceš, abych pro tebe udělal?
AI_Output(self,other,"DIA_Garond_NeedProof_10_06"); //Vyslal jsem tři skupinky kopáčů, ale nedorazil ani nuget.
AI_Output(self,other,"DIA_Garond_NeedProof_10_07"); //Obejdi všechny doly a nahlas mi, kolik rudy už vytěžili.
AI_Output(self,other,"DIA_Garond_NeedProof_10_08"); //Pak ti napíšu dopis, který doneseš zpátky lordu Hagenovi.
AI_Output(other,self,"DIA_Garond_NeedProof_15_09"); //Dobrá. Zdá se, že nemám na výběr.
if(((hero.guild == GIL_GUR) || (hero.guild == GIL_TPL)) && (MIS_PALADINWATCH == LOG_Running) && (IDOLORANQUESTIONTWO == FALSE))
{
IDOLORANQUESTIONTWO = TRUE;
B_LogEntry(TOPIC_PALADINWATCH,"Zdá se, že hlavní příčinou příchodu paladinů na ostrov je magická ruda. Bez dostatečného množství rudy nebude král mít šanci proti skřetům. Posádka, která přišla do Hornického údolí, má za úkol objasnit situaci ohledně možnosti těžby tady na ostrově. Poté se zřejmě plánují vrátit zpátky na kontinent.");
};
if(((hero.guild == GIL_GUR) || (hero.guild == GIL_TPL)) && (MIS_PALADINWATCH == LOG_Running) && (IDOLORANQUESTIONTHREE == FALSE))
{
IDOLORANQUESTIONTHREE = TRUE;
B_LogEntry(TOPIC_PALADINWATCH,"Skupina paladinů, kterou lord Hagen poslal do údolí se opevnila na starém hradě rudobaronů. Nejsou na tom dobře. Podle Garonda pořád nemají zprávy o rudě a navíc skřeti rozbili kolem hradu ležení. Na optimismu jim určitě nepřidávají ani nedávné útoky draků.");
};
MIS_ScoutMine = LOG_Running;
B_StartOtherRoutine(Jergan,"FAJETH");
B_LogEntry(Topic_MISOLDWORLD,"Než mi Garond dá důkazy, chce, abych našel jeho tři jednotky, které poslal těžit rudu, a řekl mu, kolik rudy vytěžili.");
Log_CreateTopic(TOPIC_ScoutMine,LOG_MISSION);
Log_SetTopicStatus(TOPIC_ScoutMine,LOG_Running);
B_LogEntry_Quiet(TOPIC_ScoutMine,"Velitel Garond mi dal za úkol najít tři skupiny kopáčů, kteří šli těžit rudu. Zatím o nich nebyly žádné zprávy.");
B_LogEntry_Quiet(TOPIC_ScoutMine,"Mám najít ty kopáče a zjistit, kolik rudy mají.");
};
instance DIA_Garond_WhyNot(C_Info)
{
npc = PAL_250_Garond;
nr = 1;
condition = DIA_Garond_WhyNot_Condition;
information = DIA_Garond_WhyNot_Info;
description = "Proč jsi neposlal lidi do ostatních dolů?";
};
func int DIA_Garond_WhyNot_Condition()
{
if((Npc_KnowsInfo(other,DIA_Garond_NeedProof) == TRUE) && (Kapitel <= 5))
{
return TRUE;
};
};
func void DIA_Garond_WhyNot_Info()
{
AI_Output(other,self,"DIA_Garond_WhyNot_01_00"); //Proč jsi neposlal lidi do Starého dolu?
AI_Output(self,other,"DIA_Garond_WhyNot_01_01"); //(vážně) Pokud je mi známo, Starý důl byl zasypán.
AI_Output(self,other,"DIA_Garond_WhyNot_01_02"); //Je nepravděpodobné, že bychom tam mohli úspěšně těžit.
AI_Output(self,other,"DIA_Garond_WhyNot_01_03"); //A navíc tam teď určitě bude i plno nemrtvých.
AI_Output(self,other,"DIA_Garond_WhyNot_01_04"); //A já nebudu posílat své lidi na jistou smrt! Už i tak jich mám málo...
AI_Output(other,self,"DIA_Garond_WhyNot_01_05"); //Existuje taky důl v Novém táboře.
AI_Output(self,other,"DIA_Garond_WhyNot_01_06"); //Důl v Novém táboře? Nějaký další?
AI_Output(other,self,"DIA_Garond_WhyNot_01_07"); //Tys o něm nevěděl?
AI_Output(self,other,"DIA_Garond_WhyNot_01_08"); //Myslím, že jeden z trestanců říkal něco podobného, ale nevěnoval jsem mu moc pozornosti.
AI_Output(other,self,"DIA_Garond_WhyNot_01_09"); //Mágové Vody tam těžili magickou rudu pro své experimenty.
AI_Output(self,other,"DIA_Garond_WhyNot_01_10"); //Pokud ano... (zamyšleně) Měli bychom to prověřit.
AI_Output(self,other,"DIA_Garond_WhyNot_01_11"); //Udělej to! Zjisti, v jakém stavu se důl nachází a jestli se tam dá těžit.
MIS_ScoutNewMine = LOG_Running;
Log_CreateTopic(TOPIC_ScoutNewMine,LOG_MISSION);
Log_SetTopicStatus(TOPIC_ScoutNewMine,LOG_Running);
B_LogEntry(TOPIC_ScoutNewMine,"Garond byl překvapen zprávou o dolu v Novém táboře. Mám zjistit, jaká je v dolu situace.");
};
var int SFRM_01;
var int SFRM_02;
instance DIA_Garond_ScoutNewMine(C_Info)
{
npc = PAL_250_Garond;
nr = 1;
condition = DIA_Garond_ScoutNewMine_Condition;
information = DIA_Garond_ScoutNewMine_Info;
permanent = TRUE;
description = "Ohledně dolu v Novém táboře...";
};
func int DIA_Garond_ScoutNewMine_Condition()
{
if((MIS_ScoutNewMine == LOG_Running) && ((ScoutFreeMine == TRUE) || (ScoutFreeLager == TRUE) || (FreeMineGeneralIsDead == TRUE)))
{
return TRUE;
};
};
func void DIA_Garond_ScoutNewMine_Info()
{
var int sumqx;
sumqx = FALSE;
AI_Output(other,self,"DIA_Garond_ScoutNewMine_01_00"); //Ohledně dolu v Novém táboře...
AI_Output(self,other,"DIA_Garond_ScoutNewMine_01_01"); //Poslouchám.
if(FreeMineGeneralIsDead == FALSE)
{
if((ScoutFreeLager == TRUE) && (SFRM_01 == FALSE))
{
sumqx = sumqx + 200;
AI_Output(other,self,"DIA_Garond_ScoutNewMine_01_02"); //Skřeti ovládají všechny přístupové cesty vedoucí do dolu.
AI_Output(other,self,"DIA_Garond_ScoutNewMine_01_03"); //Je jich tam opravdu hodně.
AI_Output(self,other,"DIA_Garond_ScoutNewMine_01_04"); //To mě ani nepřekvapuje. To by si tyhle stvůry nenechali ujít.
SFRM_01 = TRUE;
};
if((ScoutFreeMine == TRUE) && (SFRM_02 == FALSE))
{
sumqx = sumqx + 200;
AI_Output(other,self,"DIA_Garond_ScoutNewMine_01_05"); //Podařilo se mi dostat i do samotného dolu. I ten je plný skřetů!
AI_Output(self,other,"DIA_Garond_ScoutNewMine_01_06"); //Ano, je logické, že ho nenechají bez obrany.
AI_Output(self,other,"DIA_Garond_ScoutNewMine_01_07"); //Abychom mohli začít s těžbou, je potřeba je odtud vyhnat!
SFRM_02 = TRUE;
};
if(sumqx > 0)
{
B_GivePlayerXP(sumqx);
};
AI_Output(other,self,"DIA_Garond_ScoutNewMine_01_08"); //Jinak nic nového.
AI_Output(self,other,"DIA_Garond_ScoutNewMine_01_09"); //Dobře! Dej mi vědět, pokud se situace nějak změní.
}
else
{
if((SFRM_01 == FALSE) && (SFRM_02 == FALSE))
{
B_GivePlayerXP(500);
}
else
{
B_GivePlayerXP(1000);
};
AI_Output(other,self,"DIA_Garond_ScoutNewMine_01_10"); //Postaral jsem je o ty skřety. Důl je teď volný.
AI_Output(self,other,"DIA_Garond_ScoutNewMine_01_11"); //To myslíš vážně? Upřímně, to jsem od tebe nečekal.
AI_Output(self,other,"DIA_Garond_ScoutNewMine_01_12"); //Dobře! Jakmile se postaráme o to ležení kolem hradu, pošlu tam skupinku mých lidí.
AI_Output(self,other,"DIA_Garond_ScoutNewMine_01_13"); //Podívají se na zásoby magické rudy.
AI_Output(self,other,"DIA_Garond_ScoutNewMine_01_14"); //Tady máš nějaké zlato jako odměnu.
B_GiveInvItems(self,other,ItMi_Gold,1500);
MIS_ScoutNewMine = LOG_Success;
Log_SetTopicStatus(TOPIC_ScoutNewMine,LOG_Success);
B_LogEntry(TOPIC_ScoutNewMine,"Garond měl ohromnou radost, že se mi podařilo vyčistit důl v Novém táboře od skřetů.");
AI_StopProcessInfos(self);
};
};
var int AlbertGroupDone;
var int VenzelGroupDone;
instance DIA_GAROND_GROUP4(C_Info)
{
npc = PAL_250_Garond;
nr = 2;
condition = dia_garond_group4_condition;
information = dia_garond_group4_info;
permanent = FALSE;
description = "Našel jsem oddíl paladina Alberta.";
};
func int dia_garond_group4_condition()
{
if((MIS_LostPaladins == LOG_Running) && (KAPITELORCATC == FALSE) && (AlbertGroup == TRUE))
{
return TRUE;
};
};
func void dia_garond_group4_info()
{
B_GivePlayerXP(250);
AI_Output(other,self,"DIA_Garond_Group4_15_01"); //Našel jsem oddíl paladina Alberta.
AI_Output(self,other,"DIA_Garond_Group4_10_00"); //Jak jsou na tom?
AI_Output(other,self,"DIA_Garond_Group4_15_02"); //Uchýlili se do jeskyně za skřetí palisádou.
AI_Output(other,self,"DIA_Garond_Group4_15_03"); //Ptá se, co má dělat.
AI_Output(self,other,"DIA_Garond_Group4_10_01"); //Innos nám dnes poslal dobré zprávy!
AI_Output(self,other,"DIA_Garond_Group4_10_02"); //Pokud se ti znovu podaří se s nimi spojit, odevzdej jim mé rozkazy - ať tam zůstanou, než přijde do údolí lord Hagen a jeho muži.
AI_Output(self,other,"DIA_Garond_Group4_10_04"); //Pak ať udeří na skřety zezadu!
AI_Output(self,other,"DIA_Garond_Group4_10_05"); //Jestli se nám podaří zaútočit od Khorinisu, hradu a moře najednou, zasejeme mezi skřety paniku.
AI_Output(self,other,"DIA_Garond_Group4_10_06"); //Pak budeme mít mnohem větší šanci.
B_LogEntry(TOPIC_LostPaladins,"Informoval jsem Garonda o nalezení skupiny paladinů, kterou poslal k moři.");
if(MIS_EscapeMine == LOG_Success)
{
MIS_LostPaladins = LOG_Success;
Log_SetTopicStatus(TOPIC_LostPaladins,LOG_Success);
};
MIS_FINDEDOCGROUP = LOG_Running;
Log_CreateTopic(TOPIC_FINDEDOCGROUP,LOG_MISSION);
Log_SetTopicStatus(TOPIC_FINDEDOCGROUP,LOG_Running);
B_LogEntry_Quiet(TOPIC_FINDEDOCGROUP,"Garond mě požádal, abych vzkázal Albertovi, ať zůstane na místě a počká na příjezd posil lorda Hagena.");
};
instance DIA_GAROND_Venzel(C_Info)
{
npc = PAL_250_Garond;
nr = 2;
condition = dia_garond_Venzel_condition;
information = dia_garond_Venzel_info;
permanent = FALSE;
description = "Pokud jde o skupinu paladina Wenzela...";
};
func int dia_garond_Venzel_condition()
{
if((MIS_LostPaladins == LOG_Running) && (KAPITELORCATC == FALSE) && (HintVenzelOrcs_01 == TRUE) && (HintVenzelOrcs_02 == TRUE))
{
return TRUE;
};
};
func void dia_garond_Venzel_info()
{
B_GivePlayerXP(250);
AI_Output(other,self,"DIA_Garond_Venzel_01_01"); //Pokud jde o skupinu paladina Wenzela...
AI_Output(self,other,"DIA_Garond_Venzel_01_02"); //Poslouchám.
AI_Output(other,self,"DIA_Garond_Venzel_01_03"); //Před pár dny jeden z lovců viděl zraněného paladina u břehu řeky.
AI_Output(other,self,"DIA_Garond_Venzel_01_04"); //Možná to byl někdo z Wenzelovy skupiny.
AI_Output(self,other,"DIA_Garond_Venzel_01_05"); //Zajímavé... Nic jiného jsi už nezjistil?
AI_Output(other,self,"DIA_Garond_Venzel_01_06"); //Zvěd Jergan nedávno zpozoroval, jak skupina skřetů vedla zajatce do svého tábora.
AI_Output(other,self,"DIA_Garond_Venzel_01_07"); //Bohužel je nebyl schopný rozpoznat.
AI_Output(other,self,"DIA_Garond_Venzel_01_08"); //Proto si zatím nemůžeme být jisti.
AI_Output(self,other,"DIA_Garond_Venzel_01_09"); //Pokud jsou stále naživu a zajatci skřetů, musíme se je nějak snažit dostat z jejich spárů.
AI_Output(self,other,"DIA_Garond_Venzel_01_10"); //(důrazně) Kde jsou teď?
AI_Output(other,self,"DIA_Garond_Venzel_01_11"); //Obávám se, že tohle nebude vědět nikdo jiný než samotní skřeti.
AI_Output(self,other,"DIA_Garond_Venzel_01_12"); //Víš, je mi jedno, jak to uděláš... (vážně) Ale musíš zjistit, co je to za lidi!
AI_Output(self,other,"DIA_Garond_Venzel_01_13"); //A pokud někteří z nich budou mí bratři ve zbroji, pokus se je zachránit.
AI_Output(self,other,"DIA_Garond_Venzel_01_14"); //Dokonči tenhle úkol, a já ti, při Innosovi, odpovím na vše, co budeš chtít vědět.
AI_Output(other,self,"DIA_Garond_Venzel_01_15"); //No, jestli je to pro tebe tak důležité...
B_LogEntry(TOPIC_LostPaladins,"Řekl jsem Garondovi o Wenzelově situaci. Samozřejmě, nepotěšilo ho to. Naléhal, abych zjistil, co se stalo s lidmi, které skřeti vzali do hor a popřípadě je zachránil. Víc budou vědět asi jen skřeti.");
KnowVenzelOrcs = TRUE;
};
instance DIA_PAL_250_Garond_VenzelDone(C_Info)
{
npc = PAL_250_Garond;
nr = 2;
condition = DIA_PAL_250_Garond_VenzelDone_condition;
information = DIA_PAL_250_Garond_VenzelDone_info;
permanent = FALSE;
description = "Zjistil jsem, co se stalo s Wenzelem.";
};
func int DIA_PAL_250_Garond_VenzelDone_condition()
{
if((MIS_LostPaladins == LOG_Running) && (MIS_EscapeMine == LOG_Success))
{
return TRUE;
};
};
func void DIA_PAL_250_Garond_VenzelDone_info()
{
B_GivePlayerXP(250);
AI_Output(other,self,"DIA_PAL_250_Garond_VenzelDone_01_01"); //Zjistil jsem, co se stalo s Wenzelem.
AI_Output(self,other,"DIA_PAL_250_Garond_VenzelDone_01_02"); //Tak mluv, rychle. Je naživu?
AI_Output(other,self,"DIA_PAL_250_Garond_VenzelDone_01_03"); //Žije, ale byl zajat skřety. Poslali ho do dolu těžit železnou rudu.
AI_Output(self,other,"DIA_PAL_250_Garond_VenzelDone_01_04"); //Chvála Innosovi... (ulehčeně) Takže ještě není všechno ztraceno! Musíme ho dostat ven.
AI_Output(other,self,"DIA_PAL_250_Garond_VenzelDone_01_05"); //Není třeba. V skřetím dole jsem našel magický portál.
AI_Output(other,self,"DIA_PAL_250_Garond_VenzelDone_01_06"); //Wenzel a ostatní otroci ho použili, aby utekli.
AI_Output(other,self,"DIA_PAL_250_Garond_VenzelDone_01_07"); //Nicméně ten portál pravděpodobně vede přímo na pevninu.
AI_Output(other,self,"DIA_PAL_250_Garond_VenzelDone_01_08"); //Proto ti Wenzel vzkazuje, že se už na Khorinis asi nevrátí.
AI_Output(self,other,"DIA_PAL_250_Garond_VenzelDone_01_09"); //Nu, budiž. Hlavně, že bude v pořádku.
AI_Output(other,self,"DIA_PAL_250_Garond_VenzelDone_01_10"); //Říkal, že se vrátí do Myrtany a bude tam bojovat se skřety.
AI_Output(other,self,"DIA_PAL_250_Garond_VenzelDone_01_11"); //Vypadá to, že měl pravdu, když říkal, že král je na tom stejně špatně jako vy.
AI_Output(self,other,"DIA_PAL_250_Garond_VenzelDone_01_12"); //Ti zatracení skřeti... (nahněvaně) Zamořili tuhle krajinu jako kobylky!
AI_Output(self,other,"DIA_PAL_250_Garond_VenzelDone_01_13"); //Ale my budeme bojovat do posledního muže! Nenecháme se jimi zlomit!
AI_Output(self,other,"DIA_PAL_250_Garond_VenzelDone_01_14"); //A ohledně kontinentu... (neochotně) Nebudu ti lhát. Je to tak.
AI_Output(self,other,"DIA_PAL_250_Garond_VenzelDone_01_15"); //Král se z posledních sil snaží zadržet hordy skřetů z Nordmaru.
AI_Output(self,other,"DIA_PAL_250_Garond_VenzelDone_01_16"); //Ale nepovede se mu to. Skřetů je příliš mnoho a král nemá dost vojáků ani zbraní.
AI_Output(self,other,"DIA_PAL_250_Garond_VenzelDone_01_17"); //My jsme nyní jedinou nadějí. Magická ruda by možná dokázala otočit průběh války.
AI_Output(self,other,"DIA_PAL_250_Garond_VenzelDone_01_18"); //Ale, jak vidíš, i my máme plno práce s odrážením skřetů.
AI_Output(self,other,"DIA_PAL_250_Garond_VenzelDone_01_19"); //Nejsem zvyklý vzdávat se, ale... (odevzdaně) Tahle válka je už zřejmě nadobro prohraná.
AI_Output(self,other,"DIA_PAL_250_Garond_VenzelDone_01_20"); //Ale ať tě ani nenapadne to někomu říkat!
AI_Output(self,other,"DIA_PAL_250_Garond_VenzelDone_01_21"); //Nedovolím, aby mí muži ztratili morálku jen kvůli nějakým hloupým dohadům.
AI_Output(other,self,"DIA_PAL_250_Garond_VenzelDone_01_22"); //Samo sebou.
MIS_LostPaladins = LOG_Success;
Log_SetTopicStatus(TOPIC_LostPaladins,LOG_Success);
B_LogEntry(TOPIC_LostPaladins,"Řekl jsem Garondovi o Wenzelově osudu.");
};
instance DIA_Garond_Why(C_Info)
{
npc = PAL_250_Garond;
nr = 4;
condition = DIA_Garond_Why_Condition;
information = DIA_Garond_Why_Info;
permanent = FALSE;
description = "Ale proč zrovna já?";
};
func int DIA_Garond_Why_Condition()
{
if((MIS_ScoutMine == LOG_Running) && (Kapitel == 2))
{
return TRUE;
};
};
func void DIA_Garond_Why_Info()
{
AI_Output(other,self,"DIA_Garond_Why_15_00"); //Ale proč zrovna já?
AI_Output(self,other,"DIA_Garond_Why_10_01"); //Protože víš, jak proklouznout mezi skřety. Moji chlapci by tam byli beznadějně ztracení.
AI_Output(self,other,"DIA_Garond_Why_10_02"); //Ty jsi mezi nimi ale už jednou prošel - to je nejlepší důkaz, že jsi pro tenhle úkol ten pravý.
};
instance DIA_Garond_Equipment(C_Info)
{
npc = PAL_250_Garond;
nr = 4;
condition = DIA_Garond_Equipment_Condition;
information = DIA_Garond_Equipment_Info;
permanent = FALSE;
description = "Potřebuji nějaké vybavení.";
};
func int DIA_Garond_Equipment_Condition()
{
if((MIS_ScoutMine == LOG_Running) && (Kapitel == 2) && ((other.guild == GIL_KDF) || (other.guild == GIL_MIL)))
{
return TRUE;
};
};
func void DIA_Garond_Equipment_Info()
{
AI_Output(other,self,"DIA_Garond_Equipment_15_00"); //Potřebuji nějaké vybavení.
if(other.guild == GIL_KDF)
{
AI_Output(self,other,"DIA_Garond_Equipment_10_01"); //Promluv si s mágem Miltenem, je tady na hradě. On bude vědět, co by se ti mohlo hodit.
};
if(other.guild == GIL_MIL)
{
AI_Output(self,other,"DIA_Garond_Equipment_10_02"); //Promluv si o tom s Tandorem. Dá ti všechno, co budeš potřebovat.
Log_CreateTopic(TOPIC_Trader_OC,LOG_NOTE);
B_LogEntry(TOPIC_Trader_OC,"Tandor na hradě prodává zbraně.");
};
};
instance DIA_Garond_zahlen(C_Info)
{
npc = PAL_250_Garond;
nr = 4;
condition = DIA_Garond_zahlen_Condition;
information = DIA_Garond_zahlen_Info;
permanent = FALSE;
description = "Kolik mi za to zaplatíš?";
};
func int DIA_Garond_zahlen_Condition()
{
if((MIS_ScoutMine == LOG_Running) && (Kapitel == 2) && (other.guild == GIL_SLD))
{
return TRUE;
};
};
func void DIA_Garond_zahlen_Info()
{
AI_Output(other,self,"DIA_Garond_zahlen_15_00"); //Kolik mi za to zaplatíš?
AI_Output(self,other,"DIA_Garond_zahlen_10_01"); //Nejsem zvyklý vyjednávat s vámi žoldáky.
AI_Output(self,other,"DIA_Garond_zahlen_10_02"); //Ale zřejmě nemám na výběr. Když splníš tenhle úkol, dám ti pět set zlatých.
};
instance DIA_Garond_Wo(C_Info)
{
npc = PAL_250_Garond;
nr = 4;
condition = DIA_Garond_Wo_Condition;
information = DIA_Garond_Wo_Info;
permanent = FALSE;
description = "Kde můžu najít stanoviště kopáčů?";
};
func int DIA_Garond_Wo_Condition()
{
if((MIS_ScoutMine == LOG_Running) && (Kapitel == 2))
{
return TRUE;
};
};
func void DIA_Garond_Wo_Info()
{
AI_Output(other,self,"DIA_Garond_Wo_15_00"); //Kde můžu najít stanoviště kopáčů?
AI_Output(self,other,"DIA_Garond_Wo_10_01"); //Vezmi si tuhle mapu. Jsou na ní zakreslené dvě oblasti, ve kterých jsou doly.
CreateInvItems(self,itwr_map_oldworld_oremines_mis_1,1);
B_GiveInvItems(self,other,itwr_map_oldworld_oremines_mis_1,1);
AI_Output(self,other,"DIA_Garond_Wo_10_02"); //Jestli máš ještě nějaké další otázky, promluv s Parcivalem. Řekne ti vše, co potřebuješ vědět.
B_LogEntry(TOPIC_ScoutMine,"Paladin Parcival mi může poskytnout další informace o kopáčích.");
};
func void B_Garond_OreCounter3()
{
AI_Output(self,other,"B_Garond_OreCounter3_10_00"); //Zatraceně, to nás přišel vyhladit samotný Beliar?
AI_Output(self,other,"B_Garond_OreCounter3_10_01"); //Moji muži jsou téměř všichni mrtví a s tou trochou rudy, co máme, bychom nezastavili JEDINÉHO SKŘETA, NATOŽ CELOU ARMÁDU!
AI_Output(self,other,"B_Garond_OreCounter3_10_02"); //Tato výprava je odsouzena k záhubě.
};
instance DIA_Garond_Fajeth(C_Info)
{
npc = PAL_250_Garond;
nr = 2;
condition = DIA_Garond_Fajeth_Condition;
information = DIA_Garond_Fajeth_Info;
permanent = FALSE;
description = "Mluvil jsem s Fajethem.";
};
func int DIA_Garond_Fajeth_Condition()
{
if((MIS_ScoutMine == LOG_Running) && (Kapitel == 2) && (Fajeth_Ore == TRUE))
{
return TRUE;
};
};
func void DIA_Garond_Fajeth_Info()
{
AI_Output(other,self,"DIA_Garond_Fajeth_15_00"); //Mluvil jsem s Fajethem.
AI_Output(self,other,"DIA_Garond_Fajeth_10_01"); //Co má na srdci?
AI_Output(other,self,"DIA_Garond_Fajeth_15_02"); //Jeho lidé vydolovali dvě bedny rudy.
AI_Output(self,other,"DIA_Garond_Fajeth_10_03"); //Hmm... dvě bedny? Nepotřebuji dvě bedny - potřebuji DVĚ STOVKY!
AI_Output(other,self,"DIA_Garond_Fajeth_15_04"); //Mám ti vyřídit, že potřebuje víc mužů.
AI_Output(self,other,"DIA_Garond_Fajeth_10_05"); //Cože? To mám poslat další lidi na jistou smrt? Na to může zapomenout.
Ore_Counter = Ore_Counter + 1;
B_GivePlayerXP(XP_Fajeth_Ore);
if(Ore_Counter >= 3)
{
B_Garond_OreCounter3();
};
};
instance DIA_Garond_Silvestro(C_Info)
{
npc = PAL_250_Garond;
nr = 2;
condition = DIA_Garond_Silvestro_Condition;
information = DIA_Garond_Silvestro_Info;
permanent = FALSE;
description = "Co se Silvestrova dolu týče...";
};
func int DIA_Garond_Silvestro_Condition()
{
if((MIS_ScoutMine == LOG_Running) && (Kapitel == 2) && (Silvestro_Ore == TRUE))
{
return TRUE;
};
};
func void DIA_Garond_Silvestro_Info()
{
AI_Output(other,self,"DIA_Garond_Silvestro_15_00"); //Co se Silvestrova dolu týče...
AI_Output(self,other,"DIA_Garond_Silvestro_10_01"); //Mluvil jsi s ním?
AI_Output(other,self,"DIA_Garond_Silvestro_15_02"); //Celá skupina je mrtvá. Překvapili je důlní červi.
AI_Output(self,other,"DIA_Garond_Silvestro_10_03"); //A co ruda? Kolik vydolovali?
AI_Output(other,self,"DIA_Garond_Silvestro_15_04"); //Podařilo se jim zajistit několik beden. Jsou v jeskyni poblíž cesty mezi hradem a dolem.
AI_Output(self,other,"DIA_Garond_Silvestro_10_05"); //Zatraceně! Byli to vážně dobří chlapi - Innos měj slitování nad jejich dušemi.
Ore_Counter = Ore_Counter + 1;
B_GivePlayerXP(XP_Silvestro_Ore);
if(Ore_Counter >= 3)
{
B_Garond_OreCounter3();
};
};
instance DIA_Garond_Marcos(C_Info)
{
npc = PAL_250_Garond;
nr = 2;
condition = DIA_Garond_Marcos_Condition;
information = DIA_Garond_Marcos_Info;
permanent = FALSE;
description = "Potkal jsem Markose.";
};
func int DIA_Garond_Marcos_Condition()
{
if((MIS_ScoutMine == LOG_Running) && (Kapitel == 2) && (Marcos_Ore == TRUE))
{
return TRUE;
};
};
func void DIA_Garond_Marcos_Info()
{
AI_Output(other,self,"DIA_Garond_Marcos_15_00"); //Potkal jsem Markose.
AI_Output(self,other,"DIA_Garond_Marcos_10_01"); //A? Co hlásí? Kolik má rudy?
AI_Output(other,self,"DIA_Garond_Marcos_15_02"); //Čtyři bedny. Musel opustit důl, aby je dostal do bezpečí.
AI_Output(other,self,"DIA_Garond_Marcos_15_03"); //Nyní je střeží v malém údolíčku za skřetími liniemi. Potřebuje posily.
AI_Output(self,other,"DIA_Garond_Marcos_10_04"); //Jen čtyři bedny a opustil důl? Sakra, to není dobré.
AI_Output(self,other,"DIA_Garond_Marcos_10_05"); //A teď chce ještě další muže? No dobrá, pošlu mu dva chlapy.
Marcos_Guard1.flags = 0;
Marcos_Guard2.flags = 0;
B_StartOtherRoutine(Marcos_Guard1,"MARCOS");
B_StartOtherRoutine(Marcos_Guard2,"MARCOS");
AI_Teleport(Marcos_Guard1,"OW_STAND_GUARDS");
AI_Teleport(Marcos_Guard1,"OW_STAND_GUARDS");
Ore_Counter = Ore_Counter + 1;
MIS_Marcos_Jungs = LOG_SUCCESS;
B_GivePlayerXP(XP_Marcos_Ore);
if(Ore_Counter >= 3)
{
B_Garond_OreCounter3();
};
};
instance DIA_Garond_Success(C_Info)
{
npc = PAL_250_Garond;
nr = 4;
condition = DIA_Garond_Success_Condition;
information = DIA_Garond_Success_Info;
permanent = FALSE;
description = "A co ten dopis pro lorda Hagena?";
};
func int DIA_Garond_Success_Condition()
{
if((MIS_ScoutMine == LOG_Running) && (Kapitel == 2) && (Ore_Counter >= 3))
{
return TRUE;
};
};
func void DIA_Garond_Success_Info()
{
AI_Output(other,self,"DIA_Garond_Success_15_00"); //A co ten dopis pro lorda Hagena?
AI_Output(self,other,"DIA_Garond_Success_10_01"); //Máme dohromady deset beden rudy - a ztratili jsme dvakrát tolik dobrých mužů.
AI_Output(self,other,"DIA_Garond_Success_10_02"); //Dostaneš svůj dopis. Lord Hagen se o tom MUSÍ dozvědět. Tohle údolí je prokleté...
CreateInvItems(self,ItWr_PaladinLetter_MIS,1);
B_GiveInvItems(self,other,ItWr_PaladinLetter_MIS,1);
KnowsPaladins_Ore = TRUE;
if(((hero.guild == GIL_GUR) || (hero.guild == GIL_TPL)) && (MIS_PALADINWATCH == LOG_Running) && (IDOLORANQUESTIONFOUR == FALSE))
{
IDOLORANQUESTIONFOUR = TRUE;
B_LogEntry(TOPIC_PALADINWATCH,"Podle Garonda je výprava ztracena. V dolech není dost rudy na zásobování celé královské armády a další doly obsadili skřeti. Dal mi dopis pro Hagena, ve kterém žádá o posily.");
};
B_LogEntry(Topic_MISOLDWORLD,"Garond mi předal dopis s důkazem pro lorda Hagena. Měl bych mu ho doručit.");
MIS_ScoutMine = LOG_SUCCESS;
B_GivePlayerXP(XP_ScoutMine);
MIS_ReadyForChapter3 = TRUE;
B_NPC_IsAliveCheck(OldWorld_Zen);
};
instance DIA_Garond_SLD(C_Info)
{
npc = PAL_250_Garond;
nr = 4;
condition = DIA_Garond_SLD_Condition;
information = DIA_Garond_SLD_Info;
permanent = FALSE;
description = "A co můj žold?";
};
func int DIA_Garond_SLD_Condition()
{
if((MIS_ScoutMine == LOG_SUCCESS) && (other.guild == GIL_SLD) && (KAPITELORCATC == FALSE))
{
return TRUE;
};
};
func void DIA_Garond_SLD_Info()
{
AI_Output(other,self,"DIA_Garond_SLD_15_00"); //A co můj žold?
AI_Output(self,other,"DIA_Garond_SLD_10_01"); //Ach, ano, jistě. Ještě ti vlastně dlužím nějaké zlato. Tady je tvoje odměna.
B_GiveInvItems(self,other,ItMi_Gold,500);
};
instance DIA_Garond_Running(C_Info)
{
npc = PAL_250_Garond;
nr = 10;
condition = DIA_Garond_Running_Condition;
information = DIA_Garond_Running_Info;
permanent = TRUE;
description = "Jak to vypadá?";
};
func int DIA_Garond_Running_Condition()
{
if((MIS_ScoutMine == LOG_Running) && (Kapitel == 2) && (Ore_Counter < 3))
{
return TRUE;
};
};
func void DIA_Garond_Running_Info()
{
AI_Output(other,self,"DIA_Garond_Running_15_00"); //Jak to vypadá?
if(Ore_Counter == 2)
{
AI_Output(self,other,"DIA_Garond_Running_10_01"); //Teď už jen čekám na zprávy z posledního dolu - a doufám, že to budou dobré zprávy.
}
else if(Ore_Counter == 1)
{
AI_Output(self,other,"DIA_Garond_Running_10_02"); //Potřebuji zprávy o tom, jak to vypadá v dalších dvou dolech. Pak se uvidí.
}
else
{
AI_Output(self,other,"DIA_Garond_Running_10_03"); //Měl by ses vydat hledat ty doly. Zoufale potřebuji zprávy o tom, jak to vypadá s dobýváním rudy.
};
};
instance DIA_Garond_Gorn(C_Info)
{
npc = PAL_250_Garond;
nr = 4;
condition = DIA_Garond_Gorn_Condition;
information = DIA_Garond_Gorn_Info;
permanent = FALSE;
description = "Chci, abys pustil Gorna.";
};
func int DIA_Garond_Gorn_Condition()
{
if(Npc_KnowsInfo(other,DIA_MiltenOW_Gorn) && (Kapitel == 2) && Npc_KnowsInfo(other,DIA_Garond_NeedProof))
{
return TRUE;
};
};
func void DIA_Garond_Gorn_Info()
{
AI_Output(other,self,"DIA_Garond_Gorn_15_00"); //Chci, abys pustil Gorna.
AI_Output(self,other,"DIA_Garond_Gorn_10_01"); //Nemůžu ho propustit. Spáchal mnoho zločinů, za které musí pykat.
AI_Output(other,self,"DIA_Garond_Gorn_15_02"); //Můžu za něj zaplatit jeho pokutu?
AI_Output(self,other,"DIA_Garond_Gorn_10_03"); //To by možná šlo - ale rozhodně to nebude levné. Za Gorna budu chtít tisíc zlatých.
AI_Output(other,self,"DIA_Garond_Gorn_15_04"); //To je hodně peněz.
AI_Output(self,other,"DIA_Garond_Gorn_10_05"); //Gorn taky není žádný neviňátko. Přines mi ty peníze a já Gorna propustím.
MIS_RescueGorn = LOG_Running;
B_LogEntry(TOPIC_RescueGorn,"Garond chce za Gornovu svobodu 1000 zlatých.");
};
instance DIA_Garond_Pay(C_Info)
{
npc = PAL_250_Garond;
nr = 4;
condition = DIA_Garond_Pay_Condition;
information = DIA_Garond_Pay_Info;
permanent = TRUE;
description = "Chtěl bych vykoupit Gorna. (Zaplatit 1000 zlatých)";
};
func int DIA_Garond_Pay_Condition()
{
if((MIS_RescueGorn == LOG_Running) && (Kapitel == 2) && (Garond_Kerkerauf == FALSE))
{
return TRUE;
};
};
func void DIA_Garond_Pay_Info()
{
AI_Output(other,self,"DIA_Garond_Pay_15_00"); //Chtěl bych vykoupit Gorna.
if(B_GiveInvItems(other,self,ItMi_Gold,1000))
{
AI_Output(self,other,"DIA_Garond_Pay_10_01"); //Dobrá. Běž za Geroldem a řekni mu, ať na můj rozkaz Gorna propustí.
Garond_Kerkerauf = TRUE;
B_LogEntry(TOPIC_RescueGorn,"Zaplatil jsem Garondovi. Teď se Gorn může dostat z lochu - strážce Gerold ho pustí.");
}
else
{
AI_Output(self,other,"DIA_Garond_Pay_10_02"); //V tom případě mi přines tisíc zlatých.
};
};
instance DIA_Garond_Perm2(C_Info)
{
npc = PAL_250_Garond;
nr = 9;
condition = DIA_Garond_Perm2_Condition;
information = DIA_Garond_Perm2_Info;
permanent = TRUE;
description = "Co budeš dělat teď?";
};
func int DIA_Garond_Perm2_Condition()
{
if(Npc_KnowsInfo(other,DIA_Garond_Success) && (Kapitel == 2))
{
return TRUE;
};
};
func void DIA_Garond_Perm2_Info()
{
AI_Output(other,self,"DIA_Garond_Perm2_15_00"); //Co budeš dělat teď?
AI_Output(self,other,"DIA_Garond_Perm2_10_01"); //Mám už všeho dost. Moje jediná naděje jsi teď ty - a že mi lord Hagen pošle posily.
AI_Output(self,other,"DIA_Garond_Perm2_10_02"); //Budeme stát pevně jako skála a modlit se k Innosovi, aby nás v této temné hodině nenechal klesnout na mysli.
};
instance DIA_Garond_KAP3_EXIT(C_Info)
{
npc = PAL_250_Garond;
nr = 999;
condition = DIA_Garond_KAP3_EXIT_Condition;
information = DIA_Garond_KAP3_EXIT_Info;
permanent = TRUE;
description = Dialog_Ende;
};
func int DIA_Garond_KAP3_EXIT_Condition()
{
if(Kapitel == 3)
{
return TRUE;
};
};
func void DIA_Garond_KAP3_EXIT_Info()
{
AI_StopProcessInfos(self);
};
instance DIA_Garond_WASGIBTSNEUES(C_Info)
{
npc = PAL_250_Garond;
nr = 30;
condition = DIA_Garond_WASGIBTSNEUES_Condition;
information = DIA_Garond_WASGIBTSNEUES_Info;
permanent = TRUE;
description = "Co je nového?";
};
func int DIA_Garond_WASGIBTSNEUES_Condition()
{
if(Kapitel == 3)
{
return TRUE;
};
};
func void DIA_Garond_WASGIBTSNEUES_Info()
{
AI_Output(other,self,"DIA_Garond_WASGIBTSNEUES_15_00"); //Co je nového?
AI_Output(self,other,"DIA_Garond_WASGIBTSNEUES_10_01"); //Zatraceně. Co se tady flákáš? Potřebuji ty zatracené posily!
AI_Output(self,other,"DIA_Garond_WASGIBTSNEUES_10_02"); //Dokonce i Milten opustil hrad. Ale já nepotřebuji míň lidí - potřebuji jich víc!
};
instance DIA_Garond_KAP4_EXIT(C_Info)
{
npc = PAL_250_Garond;
nr = 999;
condition = DIA_Garond_KAP4_EXIT_Condition;
information = DIA_Garond_KAP4_EXIT_Info;
permanent = TRUE;
description = Dialog_Ende;
};
func int DIA_Garond_KAP4_EXIT_Condition()
{
if(Kapitel == 4)
{
return TRUE;
};
};
func void DIA_Garond_KAP4_EXIT_Info()
{
AI_StopProcessInfos(self);
};
instance DIA_Garond_BACKINKAP4(C_Info)
{
npc = PAL_250_Garond;
nr = 12;
condition = DIA_Garond_BACKINKAP4_Condition;
information = DIA_Garond_BACKINKAP4_Info;
permanent = FALSE;
description = "Jsem zpět.";
};
func int DIA_Garond_BACKINKAP4_Condition()
{
if(Kapitel == 4)
{
return TRUE;
};
};
func void DIA_Garond_BACKINKAP4_Info()
{
AI_Output(other,self,"DIA_Garond_BACKINKAP4_15_00"); //Jsem zpět.
AI_Output(self,other,"DIA_Garond_BACKINKAP4_10_01"); //No to vidím. Kde jsou ty posily?
AI_Output(other,self,"DIA_Garond_BACKINKAP4_15_02"); //Lord Hagen přijde, jakmile vyřídí všechny nezbytné záležitosti. Hodně se toho stalo.
AI_Output(self,other,"DIA_Garond_BACKINKAP4_10_03"); //To mě nezajímá. Mě zajímají vojáci. Skřetů je čím dál tím víc a moc dlouho se už neudržíme.
AI_Output(self,other,"DIA_Garond_BACKINKAP4_10_04"); //Muži jsou unavení a dochází nám proviant.
AI_Output(other,self,"DIA_Garond_BACKINKAP4_15_05"); //Přijelo pár dobrovolníků.
if(hero.guild == GIL_DJG)
{
AI_Output(self,other,"DIA_Garond_BACKINKAP4_10_06"); //Myslíš sebe a těch tvých pár drakobijců, co? Můžete nám sice pomoci, ale pořád vás není dost.
}
else
{
AI_Output(self,other,"DIA_Garond_BACKINKAP4_10_07"); //Myslíš ty drakobijce na dvoře? Ti nám sice mohou pomoci, ale pořád jich není dost.
};
AI_Output(self,other,"DIA_Garond_BACKINKAP4_10_08"); //Jestli Hagen co nejdřív nepošle nějaké muže, pak za nic neručím.
B_InitNpcGlobals();
AI_Teleport(DJG_Angar,"OW_DJG_WATCH_STONEHENGE_01");
B_StartOtherRoutine(DJG_Angar,"Start");
DJG_Angar_SentToStones = TRUE;
B_StartOtherRoutine(Kjorn,"START");
B_StartOtherRoutine(Godar,"START");
B_StartOtherRoutine(Hokurn,"START");
B_StartOtherRoutine(PC_Fighter_DJG,"START");
B_StartOtherRoutine(Kurgan,"START");
if(DJG_BiffParty == FALSE)
{
B_StartOtherRoutine(Biff,"START");
};
};
instance DIA_Garond_DragonPlettBericht(C_Info)
{
npc = PAL_250_Garond;
nr = 11;
condition = DIA_Garond_DragonPlettBericht_Condition;
information = DIA_Garond_DragonPlettBericht_Info;
permanent = TRUE;
description = "Ohledně draků...";
};
var int DIA_Garond_DragonPlettBericht_NoPerm;
func int DIA_Garond_DragonPlettBericht_Condition()
{
if((Kapitel >= 4) && Npc_KnowsInfo(other,DIA_Garond_BACKINKAP4) && (DIA_Garond_DragonPlettBericht_NoPerm == FALSE) && (KAPITELORCATC == FALSE))
{
return TRUE;
};
};
var int Garond_DragonCounter;
var int Garond_SwampdragonKilled_OneTime;
var int Garond_RockdragonKilled_OneTime;
var int Garond_FireDragonKilled_OneTime;
var int Garond_IcedragonKilled_OneTime;
var int Garond_OricExperte_OneTime;
func void DIA_Garond_DragonPlettBericht_Info()
{
var int CurrentDragonCount;
var int Drachengeld;
var int XP_LocalGarond;
B_LogEntry(TOPIC_DRACHENJAGD,"Garond se pravděpodobně velmi zajímá o tu věc s draky, ale navenek se jí nijak neúčastní.");
if(Garond_DragonCounter < MIS_KilledDragons)
{
AI_Output(other,self,"DIA_Garond_DragonPlettBericht_15_00"); //Ohledně draků...
AI_Output(self,other,"DIA_Garond_DragonPlettBericht_10_01"); //Mluv!
CurrentDragonCount = 0;
if(Npc_IsDead(SwampDragon) && (Garond_SwampdragonKilled_OneTime == FALSE))
{
AI_Output(other,self,"DIA_Garond_DragonPlettBericht_15_02"); //Zabil jsem draka v bažině na východ odsud.
Garond_SwampdragonKilled_OneTime = TRUE;
CurrentDragonCount = CurrentDragonCount + 1;
if((SLD_Rod_is_alive == TRUE) && !Npc_IsDead(DJG_702_Rod))
{
Npc_ExchangeRoutine(DJG_702_Rod,"ONDCamp");
AI_Teleport(DJG_702_Rod,"OW_MOVEMENT_LURKER_NEARBGOBBO03");
};
if((SLD_Cipher_is_alive == TRUE) && !Npc_IsDead(DJG_703_Cipher))
{
Npc_ExchangeRoutine(DJG_703_Cipher,"ONDCamp");
AI_Teleport(DJG_703_Cipher,"VORPOSTEN");
};
};
if(Npc_IsDead(RockDragon) && (Garond_RockdragonKilled_OneTime == FALSE))
{
AI_Output(other,self,"DIA_Garond_DragonPlettBericht_15_03"); //Drak ve skalní pevnosti na jihu je mrtvý.
Garond_RockdragonKilled_OneTime = TRUE;
CurrentDragonCount = CurrentDragonCount + 1;
};
if(Npc_IsDead(FireDragon) && (Garond_FireDragonKilled_OneTime == FALSE))
{
AI_Output(other,self,"DIA_Garond_DragonPlettBericht_15_04"); //Ohnivý drak v sopce na jihu už nebude tropit žádné potíže.
Garond_FireDragonKilled_OneTime = TRUE;
CurrentDragonCount = CurrentDragonCount + 1;
};
if(Npc_IsDead(IceDragon) && (Garond_IcedragonKilled_OneTime == FALSE))
{
AI_Output(other,self,"DIA_Garond_DragonPlettBericht_15_05"); //Vydal jsem se do zmrzlé oblasti na západě a zlikvidoval tamního draka.
Garond_IcedragonKilled_OneTime = TRUE;
CurrentDragonCount = CurrentDragonCount + 1;
};
AI_Output(self,other,"DIA_Garond_DragonPlettBericht_10_06"); //To jsou dobré zprávy. Tady. Vezmi si nějaké peníze na doplnění výbavy.
Drachengeld = CurrentDragonCount * Garond_KilledDragonGeld;
XP_LocalGarond = CurrentDragonCount * XP_Garond_KilledDragon;
B_GivePlayerXP(XP_LocalGarond);
CreateInvItems(self,ItMi_Gold,Drachengeld);
B_GiveInvItems(self,other,ItMi_Gold,Drachengeld);
Garond_DragonCounter = MIS_KilledDragons;
if(MIS_AllDragonsDead == TRUE)
{
DIA_Garond_DragonPlettBericht_NoPerm = TRUE;
};
};
if((Garond_OricExperte_OneTime == FALSE) && (Npc_IsDead(Oric) == FALSE) && (MIS_AllDragonsDead == FALSE))
{
AI_Output(other,self,"DIA_Garond_DragonPlettBericht_15_07"); //Můžeš mi dát nějaké další informace o dracích?
AI_Output(self,other,"DIA_Garond_DragonPlettBericht_10_08"); //Vrásky mi teď dělají jiné věci. Oric, můj důstojník přes strategické věci, ti o tom řekne víc.
B_LogEntry(TOPIC_DRACHENJAGD,"Garond mi řekl, že jeho poradce Oric má informace o dracích.");
Garond_OricExperte_OneTime = TRUE;
}
else if(MIS_AllDragonsDead == FALSE)
{
AI_Output(other,self,"DIA_Garond_DragonPlettBericht_15_09"); //Provedli draci mezitím nějaký další útok?
AI_Output(self,other,"DIA_Garond_DragonPlettBericht_10_10"); //Naštěstí ne. Prozatím se drží zpátky.
};
};
instance DIA_Garond_AllDragonDead(C_Info)
{
npc = PAL_250_Garond;
nr = 12;
condition = DIA_Garond_AllDragonDead_Condition;
information = DIA_Garond_AllDragonDead_Info;
permanent = FALSE;
description = "Všichni draci jsou mrtví.";
};
func int DIA_Garond_AllDragonDead_Condition()
{
if((MIS_AllDragonsDead == TRUE) && (DIA_Garond_DragonPlettBericht_NoPerm == TRUE) && (Kapitel >= 4) && (KAPITELORCATC == FALSE))
{
return TRUE;
};
};
func void DIA_Garond_AllDragonDead_Info()
{
B_GivePlayerXP(1500);
AI_Output(other,self,"DIA_Garond_AllDragonDead_15_00"); //Všichni draci jsou mrtví.
AI_Output(self,other,"DIA_Garond_AllDragonDead_10_01"); //(nevěřícně) Všichni? Takže zlo bylo navždy zažehnáno?
AI_Output(other,self,"DIA_Garond_AllDragonDead_15_02"); //Ne, to bohužel ne. Ještě pořád zbývá jejich vůdce.
AI_Output(self,other,"DIA_Garond_AllDragonDead_10_03"); //Copak nebyli draci veliteli skřetů?
AI_Output(other,self,"DIA_Garond_AllDragonDead_15_04"); //Ano, to ano, ale mají svého vlastního pána. Toho se musíme také zbavit.
AI_Output(self,other,"DIA_Garond_AllDragonDead_10_05"); //Zatraceně, do toho jít nemůžu. Musím hlídat rudu, a ještě navíc tu jsou pořád ti skřeti.
AI_Output(self,other,"DIA_Garond_AllDragonDead_10_06"); //Budeš se o to muset postarat sám. Nemůžu ti pomoci.
AI_Output(self,other,"DIA_Garond_AllDragonDead_10_07"); //Nechť tě Innos ochraňuje.
OWDragonsDeadIsDead = TRUE;
};
instance DIA_Garond_JanBecomeSmith(C_Info)
{
npc = PAL_250_Garond;
nr = 12;
condition = DIA_Garond_JanBecomeSmith_Condition;
information = DIA_Garond_JanBecomeSmith_Info;
permanent = TRUE;
description = "Máme problém s kovářem.";
};
func int DIA_Garond_JanBecomeSmith_Condition()
{
if((MIS_JanBecomesSmith == LOG_Running) && (Kapitel >= 4) && (KAPITELORCATC == FALSE))
{
return TRUE;
};
};
func void DIA_Garond_JanBecomeSmith_Info()
{
AI_Output(other,self,"DIA_Garond_JanBecomeSmith_15_00"); //Máme problém s kovářem.
AI_Output(self,other,"DIA_Garond_JanBecomeSmith_10_01"); //Jakým kovářem? Před několika dny přece zmizel.
AI_Output(self,other,"DIA_Garond_JanBecomeSmith_10_02"); //On se vrátil? V tom případě mu řekni...
AI_Output(other,self,"DIA_Garond_JanBecomeSmith_15_03"); //Ne, já mluvím o Janovi.
if(hero.guild == GIL_DJG)
{
AI_Output(other,self,"DIA_Garond_JanBecomeSmith_15_04"); //Je to drakobijec jako já, a je to dobrý kovář.
}
else
{
AI_Output(other,self,"DIA_Garond_JanBecomeSmith_15_05"); //Jeden z drakobijců. Je to kovář.
};
AI_Output(self,other,"DIA_Garond_JanBecomeSmith_10_06"); //To je dobře. Náš předchozí kovář zmizel, zbabělec.
AI_Output(other,self,"DIA_Garond_JanBecomeSmith_15_07"); //Jan se o kovárnu rád postará.
AI_Output(self,other,"DIA_Garond_JanBecomeSmith_10_08"); //Říkáš, že bych mu měl věřit?
AI_Output(other,self,"DIA_Garond_JanBecomeSmith_15_09"); //Ano.
AI_Output(self,other,"DIA_Garond_JanBecomeSmith_10_10"); //Pokud si jsi tak jistý, můžeš se za něj zaručit.
AI_Output(self,other,"DIA_Garond_JanBecomeSmith_10_11"); //Jestliže bude dělat nějaké potíže, budeš se za to zodpovídat ty. Souhlasíš?
DobarOut = TRUE;
Info_ClearChoices(DIA_Garond_JanBecomeSmith);
Info_AddChoice(DIA_Garond_JanBecomeSmith,"Budu o tom přemýšlet.",DIA_Garond_JanBecomeSmith_No);
Info_AddChoice(DIA_Garond_JanBecomeSmith,"Zaručím se za Jana.",DIA_Garond_JanBecomeSmith_Yes);
};
func void DIA_Garond_JanBecomeSmith_No()
{
AI_Output(other,self,"DIA_Garond_JanBecomeSmith_No_15_00"); //Budu o tom přemýšlet.
AI_Output(self,other,"DIA_Garond_JanBecomeSmith_No_10_01"); //Jak mu mám věřit já, když mu nedůvěřuješ ani ty sám?
AI_Output(self,other,"DIA_Garond_JanBecomeSmith_No_10_02"); //Než se za něj někdo zaručí, bude muset držet ruce od kovárny.
Info_ClearChoices(DIA_Garond_JanBecomeSmith);
};
func void DIA_Garond_JanBecomeSmith_Yes()
{
AI_Output(other,self,"DIA_Garond_JanBecomeSmith_Yes_15_00"); //Zaručím se za Jana.
AI_Output(self,other,"DIA_Garond_JanBecomeSmith_Yes_10_01"); //Dobrá. V tom případě může kovárnu používat. Samozřejmě také bude muset udělat meče pro mé muže.
Info_ClearChoices(DIA_Garond_JanBecomeSmith);
MIS_JanBecomesSmith = LOG_SUCCESS;
B_GivePlayerXP(XP_Ambient);
};
instance DIA_Garond_DobarOut(C_Info)
{
npc = PAL_250_Garond;
nr = 12;
condition = DIA_Garond_DobarOut_Condition;
information = DIA_Garond_DobarOut_Info;
permanent = FALSE;
description = "Řekl jste, že váš kovář unikl.";
};
func int DIA_Garond_DobarOut_Condition()
{
if((DobarOut == TRUE) && (Npc_IsDead(VLK_4107_Parlaf) == FALSE) && (ParlafIsDead == FALSE))
{
return TRUE;
};
};
func void DIA_Garond_DobarOut_Info()
{
B_GivePlayerXP(1500);
AI_Output(other,self,"DIA_Garond_DobarOut_01_00"); //Řekl jste, že váš kovář unikl.
AI_Output(self,other,"DIA_Garond_DobarOut_01_01"); //Ano, a ne sám, ale společně se svým asistentem. Nicméně, si nemyslím, že by mohli dojít daleko.
AI_Output(self,other,"DIA_Garond_DobarOut_01_02"); //V posledních dnech v údolí je ještě více skřetů a všelijaké jiné havěti a oni dva nebyli dobří bojovníci.
AI_Output(self,other,"DIA_Garond_DobarOut_01_03"); //Víš, ať ti mizerní zbabělci utečou, ale Innos s nimi. V každém případě, není to nejhorší - mám na mysli, když skřeti ovládnou hrad - to by byl konec.
AI_Output(other,self,"DIA_Garond_DobarOut_01_04"); //Možná, bych se po nich šel podívat.
if(MIS_JanBecomesSmith == LOG_SUCCESS)
{
AI_Output(self,other,"DIA_Garond_DobarOut_01_05"); //Chcete-li mou upřímnost, v současné situaci, je mi to jedno. Kováře už máme.
}
else
{
AI_Output(self,other,"DIA_Garond_DobarOut_01_06"); //Chcete-li mou upřímnost, v současné situaci, je mi to jedno.
};
AI_Output(self,other,"DIA_Garond_DobarOut_01_07"); //Ale zas to nepřeháněj s tím běháním po údolí, jednou tě chytí a zničíš tím sám sebe.
AI_Output(other,self,"DIA_Garond_DobarOut_01_08"); //Rozumím.
DayParlafDead = Wld_GetDay();
MIS_DobarOut = LOG_Running;
Log_CreateTopic(TOPIC_DobarOut,LOG_MISSION);
Log_SetTopicStatus(TOPIC_DobarOut,LOG_Running);
B_LogEntry(TOPIC_DobarOut,"Během mé nepřítomnosti na hradě došlo k mnoha změnám, to platí nejenom s drakobijci. Kovář Dobar a jeho asistent Parlaf se rozhodli pro útěk z hradu. Budu se muset na ně podívat.");
};
instance DIA_Garond_DobarOut_Done(C_Info)
{
npc = PAL_250_Garond;
nr = 2;
condition = DIA_Garond_DobarOut_Done_Condition;
information = DIA_Garond_DobarOut_Done_Info;
permanent = FALSE;
description = "Našel jsem Parlafa.";
};
func int DIA_Garond_DobarOut_Done_Condition()
{
if((MIS_DobarOut == LOG_Running) && ((ParlafOnPlace == TRUE) || (ParlafOnPlaceDead == TRUE)))
{
return TRUE;
};
};
func void DIA_Garond_DobarOut_Done_Info()
{
AI_Output(other,self,"DIA_Garond_DobarOut_Done_01_00"); //Našel jsem Parlafa.
AI_Output(self,other,"DIA_Garond_DobarOut_Done_01_01"); //Kde bylo to štěně?
if(ParlafNoExcort == TRUE)
{
B_GivePlayerXP(100);
AI_Output(other,self,"DIA_Garond_DobarOut_Done_01_02"); //Schoval se v jeskyni nedaleko hradu.
AI_Output(other,self,"DIA_Garond_DobarOut_Done_01_03"); //Požádal mě, abych ho doprovodil zpátky do hradu, ale bohužel se mi nadobro ztratil.
AI_Output(self,other,"DIA_Garond_DobarOut_Done_01_04"); //No... aspoň se mu podařilo utéct.
AI_Output(self,other,"DIA_Garond_DobarOut_Done_01_05"); //Nemůžu říct, že by mi nějak chyběl.
B_LogEntry(TOPIC_DobarOut,"Řekl jsem Garondovi, že živého sem Parlafa nikdy nedostanu.");
GarondKnowParlaf = TRUE;
if(GarondKnowDobar == TRUE)
{
MIS_DobarOut = LOG_SUCCESS;
Log_SetTopicStatus(TOPIC_DobarOut,LOG_SUCCESS);
B_LogEntry_Quiet(TOPIC_DobarOut,"Domnívám se, že moje hledání je u konce.");
};
}
else if(ParlafOnPlaceDead == TRUE)
{
AI_Output(other,self,"DIA_Garond_DobarOut_Done_01_06"); //Schoval se v jeskyni nedaleko hradu, bohužel než jsem se k němu stihl dostat, zemřel už hlady.
AI_Output(self,other,"DIA_Garond_DobarOut_Done_01_07"); //(sarkasticky) Cože, tam není jídlo lepší než tady? Zatracení fňukalové...
AI_Output(other,self,"DIA_Garond_DobarOut_Done_01_08"); //Není na místě urážet mrtvé.
AI_Output(self,other,"DIA_Garond_DobarOut_Done_01_09"); //Och, Innosi. VŠICHNI jsme na půl mrtví! Čekáš, že projevím lítost za zbabělého dezertéra?
AI_Output(other,self,"DIA_Garond_DobarOut_Done_01_10"); //Nic vám nevnucuju.
B_LogEntry(TOPIC_DobarOut,"Ohlásil jsem Garondovy Parlafovu smrt. Zdá se, že na něj moc nezapůsobyla.");
GarondKnowParlaf = TRUE;
if(GarondKnowDobar == TRUE)
{
MIS_DobarOut = LOG_SUCCESS;
Log_SetTopicStatus(TOPIC_DobarOut,LOG_SUCCESS);
B_LogEntry_Quiet(TOPIC_DobarOut,"Parlaf je zpátky.");
};
}
else if(ParlafOnPlace == TRUE)
{
B_GivePlayerXP(250);
AI_Output(other,self,"DIA_Garond_DobarOut_Done_01_11"); //Schoval se v jeskyni vedle hradu. Jen díky mně se mu podařilo přežít.
AI_Output(other,self,"DIA_Garond_DobarOut_Done_01_12"); //Požádal mě, abych ho doprovodil zpátky do hradu. Myslím, že si uvědomí, že udělal chybu.
AI_Output(self,other,"DIA_Garond_DobarOut_Done_01_13"); //No... v takové situaci bych ho hodil do vězení. Ale jestliže si uvědomil pošetilost svého činu, nebudu to dělat.
AI_Output(self,other,"DIA_Garond_DobarOut_Done_01_14"); //Kromě toho je to poučení pro něj - ať pomůže tomu drakobijci jménem Jan v kovárně.
AI_Output(other,self,"DIA_Garond_DobarOut_Done_01_15"); //Dobře, řeknu mu to.
B_LogEntry(TOPIC_DobarOut,"Dovedl jsem Parlafa zpět do hradu za Garondem a ten mu přikázal, aby šel pomáhat do kovárny.");
GarondKnowParlaf = TRUE;
if(GarondKnowDobar == TRUE)
{
MIS_DobarOut = LOG_SUCCESS;
Log_SetTopicStatus(TOPIC_DobarOut,LOG_SUCCESS);
B_LogEntry_Quiet(TOPIC_DobarOut,"Hádám, že moje hledání je u konce.");
};
};
};
instance DIA_Garond_DobarOut_Xone(C_Info)
{
npc = PAL_250_Garond;
nr = 2;
condition = DIA_Garond_DobarOut_Xone_Condition;
information = DIA_Garond_DobarOut_Xone_Info;
permanent = FALSE;
description = "Našel jsem Dobara.";
};
func int DIA_Garond_DobarOut_Xone_Condition()
{
if((MIS_DobarOut == LOG_Running) && (DobarOnPlace == TRUE))
{
return TRUE;
};
};
func void DIA_Garond_DobarOut_Xone_Info()
{
B_GivePlayerXP(150);
AI_Output(other,self,"DIA_Garond_DobarOut_Xone_01_00"); //Našel jsem Dobara.
AI_Output(self,other,"DIA_Garond_DobarOut_Xone_01_01"); //Co se mu stalo?
AI_Output(other,self,"DIA_Garond_DobarOut_Xone_01_02"); //Je mrtvý.
AI_Output(self,other,"DIA_Garond_DobarOut_Xone_01_03"); //Nejsem vůbec překvapen touto zprávou. Ano, byl to dobrý kovář, ale plakat určitě nebudu.
GarondKnowDobar = TRUE;
B_LogEntry(TOPIC_DobarOut,"Řekl jsem Garondovi, že Dobar je mrtvý.");
if(GarondKnowParlaf == TRUE)
{
MIS_DobarOut = LOG_SUCCESS;
Log_SetTopicStatus(TOPIC_DobarOut,LOG_SUCCESS);
B_LogEntry_Quiet(TOPIC_DobarOut,"Hádám, že moje hledání je u konce.");
};
};
instance DIA_Garond_KAP5_EXIT(C_Info)
{
npc = PAL_250_Garond;
nr = 999;
condition = DIA_Garond_KAP5_EXIT_Condition;
information = DIA_Garond_KAP5_EXIT_Info;
permanent = TRUE;
description = Dialog_Ende;
};
func int DIA_Garond_KAP5_EXIT_Condition()
{
if(Kapitel == 5)
{
return TRUE;
};
};
func void DIA_Garond_KAP5_EXIT_Info()
{
AI_StopProcessInfos(self);
};
instance DIA_Garond_PERM5(C_Info)
{
npc = PAL_250_Garond;
nr = 59;
condition = DIA_Garond_PERM5_Condition;
information = DIA_Garond_PERM5_Info;
permanent = TRUE;
description = "Jak to vypadá?";
};
func int DIA_Garond_PERM5_Condition()
{
if(Kapitel == 5)
{
return TRUE;
};
};
func void DIA_Garond_PERM5_Info()
{
AI_Output(other,self,"DIA_Garond_PERM5_15_00"); //Jak to vypadá?
if(MIS_OCGateOpen == TRUE)
{
AI_Output(self,other,"DIA_Garond_PERM5_10_01"); //Zatraceně! Nějaký parchant nechal hlavní bránu otevřenou. Teď je z nás žrádlo pro vlky.
AI_Output(self,other,"DIA_Garond_PERM5_10_02"); //Až dostanu toho zrádce do rukou...
}
else
{
AI_Output(self,other,"DIA_Garond_PERM5_10_03"); //Pokud Hagen nepřijde co nejdřív, pochcípáme tady jako mouchy.
};
};
instance DIA_Garond_KAP6_EXIT(C_Info)
{
npc = PAL_250_Garond;
nr = 999;
condition = DIA_Garond_KAP6_EXIT_Condition;
information = DIA_Garond_KAP6_EXIT_Info;
permanent = TRUE;
description = Dialog_Ende;
};
func int DIA_Garond_KAP6_EXIT_Condition()
{
if(Kapitel >= 6)
{
return TRUE;
};
};
func void DIA_Garond_KAP6_EXIT_Info()
{
AI_StopProcessInfos(self);
};
instance DIA_GAROND_MADERZ(C_Info)
{
npc = PAL_250_Garond;
nr = 1;
condition = dia_garond_maderz_condition;
information = dia_garond_maderz_info;
permanent = FALSE;
description = "Mám pro tebe novinky.";
};
func int dia_garond_maderz_condition()
{
if((MIS_MADERZ == LOG_Running) && (KAPITELORCATC == FALSE))
{
return TRUE;
};
};
func void dia_garond_maderz_info()
{
B_GivePlayerXP(300);
AI_Output(other,self,"DIA_Garond_MadErz_01_00"); //Mám pro tebe novinky.
AI_Output(other,self,"DIA_Garond_MadErz_01_04"); //Nedaleko ruin starého skřetího města jsem našel skladiště rudy. Je tam minimálně kolem dvaceti beden!
AI_Output(self,other,"DIA_Garond_MadErz_01_05"); //Ne! Je to pravda?
AI_Output(self,other,"DIA_Garond_MadErz_01_07"); //Nevěřím svým uším! To jsou jednoduše vynikající zprávy!
AI_Output(self,other,"DIA_Garond_MadErz_01_08"); //Dvacet beden je dvakrát více, než máme!
AI_Output(self,other,"DIA_Garond_MadErz_01_10"); //Ale nesmíme se radovat předčasně.
AI_Output(self,other,"DIA_Garond_MadErz_01_12"); //Měli bychom vyřešit, co s tou nalezenou rudou.
AI_Output(other,self,"DIA_Garond_MadErz_01_13"); //Myslím, že pro začátek bys tam měl poslat pár lidí.
AI_Output(self,other,"DIA_Garond_MadErz_01_14"); //To je pravda, pošlu tam nějaké rytíře. Koneckonců je to jediná věc, kterou mohu udělat.
AI_Output(self,other,"DIA_Garond_MadErz_01_21"); //A ty - ty si zasloužíš odměnu.
AI_Output(self,other,"DIA_Garond_MadErz_01_22"); //Vyber si, co potřebuješ!
MIS_MADERZ = LOG_SUCCESS;
Log_SetTopicStatus(TOPIC_MADERZ,LOG_SUCCESS);
B_LogEntry(TOPIC_MADERZ,"Informoval jsem Garonda o rudě nalezené poblíž ruin skřetího města. Byl velice rád. Poslal tam pár lidí, kteří rudu přepraví na hrad.");
Info_ClearChoices(dia_garond_maderz);
Info_AddChoice(dia_garond_maderz,"Zlato.",dia_garond_maderz_gold);
Info_AddChoice(dia_garond_maderz,"Elixír many.",dia_garond_maderz_mana);
Info_AddChoice(dia_garond_maderz,"Elixír života.",dia_garond_maderz_health);
Info_AddChoice(dia_garond_maderz,"Elixír obratnosti.",dia_garond_maderz_dex);
Info_AddChoice(dia_garond_maderz,"Elixír síly.",dia_garond_maderz_str);
};
func void dia_garond_maderz_gold()
{
AI_Output(other,self,"DIA_Garond_MadErz_Gold_01_00"); //Zlato neuškodí.
AI_Output(self,other,"DIA_Garond_MadErz_Gold_01_01"); //Dobrá! Tady máš tisíc zlatých.
B_GiveInvItems(self,other,ItMi_Gold,1000);
AI_Output(self,other,"DIA_Garond_MadErz_Gold_01_02"); //Doufám, že je utratíš za rozumnou věc.
Info_ClearChoices(dia_garond_maderz);
Wld_InsertNpc(pal_9165_ritter,"WP_ORCTEMPLEORE_01");
Wld_InsertNpc(pal_9166_ritter,"WP_ORCTEMPLEORE_02");
Wld_InsertNpc(pal_9167_ritter,"WP_ORCTEMPLEORE_03");
};
func void dia_garond_maderz_mana()
{
AI_Output(other,self,"DIA_Garond_MadErz_Mana_01_00"); //Dej mi elixír many.
AI_Output(self,other,"DIA_Garond_MadErz_Mana_01_01"); //Tady je.
B_GiveInvItems(self,other,ItPo_Perm_Mana,1);
AI_Output(self,other,"DIA_Garond_MadErz_Mana_01_02"); //Doufám, že ti pomůže.
Info_ClearChoices(dia_garond_maderz);
Wld_InsertNpc(pal_9165_ritter,"WP_ORCTEMPLEORE_01");
Wld_InsertNpc(pal_9166_ritter,"WP_ORCTEMPLEORE_02");
Wld_InsertNpc(pal_9167_ritter,"WP_ORCTEMPLEORE_03");
};
func void dia_garond_maderz_str()
{
AI_Output(other,self,"DIA_Garond_MadErz_Str_01_00"); //Dej mi elixír síly.
AI_Output(self,other,"DIA_Garond_MadErz_Str_01_01"); //Tady je.
B_GiveInvItems(self,other,ItPo_Perm_STR,1);
AI_Output(self,other,"DIA_Garond_MadErz_Str_01_02"); //Doufám, že ti pomůže.
Info_ClearChoices(dia_garond_maderz);
Wld_InsertNpc(pal_9165_ritter,"WP_ORCTEMPLEORE_01");
Wld_InsertNpc(pal_9166_ritter,"WP_ORCTEMPLEORE_02");
Wld_InsertNpc(pal_9167_ritter,"WP_ORCTEMPLEORE_03");
};
func void dia_garond_maderz_dex()
{
AI_Output(other,self,"DIA_Garond_MadErz_Dex_01_00"); //Dej mi elixír obratnosti.
AI_Output(self,other,"DIA_Garond_MadErz_Dex_01_01"); //Tady je.
B_GiveInvItems(self,other,ItPo_Perm_DEX,1);
AI_Output(self,other,"DIA_Garond_MadErz_Dex_01_02"); //Doufám, že ti pomůže.
Info_ClearChoices(dia_garond_maderz);
Wld_InsertNpc(pal_9165_ritter,"WP_ORCTEMPLEORE_01");
Wld_InsertNpc(pal_9166_ritter,"WP_ORCTEMPLEORE_02");
Wld_InsertNpc(pal_9167_ritter,"WP_ORCTEMPLEORE_03");
};
func void dia_garond_maderz_health()
{
AI_Output(other,self,"DIA_Garond_MadErz_Health_01_00"); //Dej mi elixír života.
AI_Output(self,other,"DIA_Garond_MadErz_Health_01_01"); //Tady je.
B_GiveInvItems(self,other,ItPo_Perm_Health,1);
AI_Output(self,other,"DIA_Garond_MadErz_Health_01_02"); //Doufám, že ti pomůže.
Info_ClearChoices(dia_garond_maderz);
Wld_InsertNpc(pal_9165_ritter,"WP_ORCTEMPLEORE_01");
Wld_InsertNpc(pal_9166_ritter,"WP_ORCTEMPLEORE_02");
Wld_InsertNpc(pal_9167_ritter,"WP_ORCTEMPLEORE_03");
};
instance DIA_GAROND_CAPTURED(C_Info)
{
npc = PAL_250_Garond;
nr = 12;
condition = dia_garond_captured_condition;
information = dia_garond_captured_info;
permanent = FALSE;
important = TRUE;
};
func int dia_garond_captured_condition()
{
if(Npc_IsInState(self,ZS_Talk) && (MIS_ORCGREATWAR == LOG_Running))
{
return TRUE;
};
};
func void dia_garond_captured_info()
{
B_GivePlayerXP(300);
AI_Output(self,other,"DIA_Garond_Captured_01_00"); //Jsi to ty? Jak ses sem dostal?
AI_Output(other,self,"DIA_Garond_Captured_01_94"); //To je vlastně jedno. Radši mi řekni - co se to tady stalo?
AI_Output(self,other,"DIA_Garond_Captured_01_05"); //Nevím! Poslední věc, kterou si pamatuji, je rána do hlavy, po které jsem ztratil vědomí.
AI_Output(self,other,"DIA_Garond_Captured_01_06"); //Probudil jsem se až tady spolu s ostatními chlapy.
KNOWABOUTGAROND = TRUE;
if(MIS_RESCUEGAROND == LOG_Running)
{
B_LogEntry(TOPIC_RESCUEGAROND,"Lord Hagen se určitě rád dozví, že Garond a jeho lidé žijí. Teď bych jim však měl z téhle zapeklité situace pomoci.");
};
if(MIS_NEWSSURVIVERS == LOG_Running)
{
B_LogEntry(TOPIC_NEWSSURVIVERS,"Dostal jsem se na hrad, který obsadili skřeti. Zpočátku jsem ani nevěřil svým očím, když jsem viděl Garonda a jeho lidi živé a zdravé. Z nějakého důvodu je skřeti jenom zajali. Měl bych je odsud nějak dostat.");
};
if(MIS_STURMCASTLE == LOG_Running)
{
B_LogEntry(TOPIC_STURMCASTLE,"Zpočátku jsem ani nevěřil svým očím, když jsem viděl Garonda a jeho lidi živé a zdravé. Z nějakého důvodu je skřeti jenom zajali. Měl bych je odsud nějak dostat. Nejlehčí by zřejmě bylo vyklidit hrad od skřetů.");
};
if(DGJMOVEPALADIN == TRUE)
{
b_readydgjmove();
};
};
instance DIA_GAROND_ABOUTSLAVE(C_Info)
{
npc = PAL_250_Garond;
nr = 12;
condition = DIA_GAROND_ABOUTSLAVE_condition;
information = DIA_GAROND_ABOUTSLAVE_info;
permanent = FALSE;
description = "A kde jsou ostatní vězni?";
};
func int DIA_GAROND_ABOUTSLAVE_condition()
{
if((MIS_ORCGREATWAR == LOG_Running) && (PALADINCASTELFREE == FALSE) && (CASTLEISFREE == FALSE))
{
return TRUE;
};
};
func void DIA_GAROND_ABOUTSLAVE_info()
{
B_GivePlayerXP(100);
AI_Output(other,self,"DIA_GAROND_ABOUTSLAVE_01_00"); //A kde jsou ostatní vězni?
AI_Output(self,other,"DIA_GAROND_ABOUTSLAVE_01_01"); //Skřeti je někam odvedli, ale nevím kam.
AI_Output(self,other,"DIA_GAROND_ABOUTSLAVE_01_02"); //Možná je drží v nějakém skřetím dolu.
AI_Output(self,other,"DIA_GAROND_ABOUTSLAVE_01_03"); //Nebo hůř, prostě je zmasakrovali.
};
instance DIA_GAROND_FINDAWAY(C_Info)
{
npc = PAL_250_Garond;
nr = 12;
condition = dia_garond_findaway_condition;
information = dia_garond_findaway_info;
permanent = FALSE;
description = "Musíte se odsud nějak dostat!";
};
func int dia_garond_findaway_condition()
{
if((MIS_ORCGREATWAR == LOG_Running) && (PALADINCASTELFREE == FALSE) && (CASTLEISFREE == FALSE))
{
return TRUE;
};
};
func void dia_garond_findaway_info()
{
AI_Output(other,self,"DIA_Garond_FindAway_01_00"); //Musíte se odsud nějak dostat!
AI_Output(self,other,"DIA_Garond_FindAway_01_01"); //A co asi tak navrhuješ?
AI_Output(self,other,"DIA_Garond_FindAway_01_02"); //Hrad padl a je plný skřetů! Než se dostaneme k bráně, je po nás.
AI_Output(other,self,"DIA_Garond_FindAway_01_04"); //Něco vymyslím.
AI_Output(self,other,"DIA_Garond_FindAway_01_05"); //To doufám. V každém případě mě napadá jen jedna možnost.
AI_Output(self,other,"DIA_Garond_FindAway_01_09"); //Zabít všechny skřety a osvobodit hrad.
AI_Output(self,other,"DIA_Garond_FindAway_01_10"); //Nicméně pochybuji, že by to kdokoli dokázal - včetně tebe.
};
instance DIA_GAROND_PALADINFREE(C_Info)
{
npc = PAL_250_Garond;
nr = 1;
condition = dia_garond_paladinfree_condition;
information = dia_garond_paladinfree_info;
permanent = FALSE;
description = "Pohyb! Jste volní.";
};
func int dia_garond_paladinfree_condition()
{
if((MIS_ORCGREATWAR == LOG_Running) && ((CANFREEPALADIN == TRUE) || (CASTLEISFREE == TRUE)))
{
return TRUE;
};
};
func void dia_garond_paladinfree_info()
{
B_GivePlayerXP(200);
AI_Output(other,self,"DIA_Garond_PaladinFree_01_00"); //Pohyb! Jste volní.
AI_Output(self,other,"DIA_Garond_PaladinFree_01_01"); //Co? (zmateně) Ty jsi to dokázal?
if(CASTLEISFREE == TRUE)
{
AI_Output(other,self,"DIA_Garond_PaladinFree_01_02"); //Hrad jsme znovu obsadili my!
AI_Output(self,other,"DIA_Garond_PaladinFree_01_03"); //Opravdu?! Opravdu si porazil skřety v pevnosti?
AI_Output(self,other,"DIA_Garond_PaladinFree_01_05"); //Neuvěřitelné! Nemohu tomu uvěřit!
AI_Output(self,other,"DIA_Garond_PaladinFree_01_09"); //Ale pro začátek pusť mě a mé chlapy z těch zatracených cel.
PALADINCASTELFREE = TRUE;
if(MIS_NEWSSURVIVERS == LOG_Running)
{
MIS_NEWSSURVIVERS = LOG_SUCCESS;
Log_SetTopicStatus(TOPIC_NEWSSURVIVERS,LOG_SUCCESS);
};
if(MIS_STURMCASTLE == LOG_Running)
{
MIS_STURMCASTLE = LOG_SUCCESS;
Log_SetTopicStatus(TOPIC_STURMCASTLE,LOG_SUCCESS);
};
if(MIS_RESCUEGAROND == LOG_Running)
{
B_LogEntry(TOPIC_RESCUEGAROND,"Osvobodil jsem Garonda a jeho lidi. Teď se musíme co nejrychleji dostat z údolí.");
};
AI_StopProcessInfos(self);
if(DGJMOVEPALADIN == TRUE)
{
b_readydgjmove();
};
}
else if(CANFREEPALADIN == TRUE)
{
AI_Output(other,self,"DIA_Garond_PaladinFree_01_12"); //Musíme se dostat co nejrychleji ven!
AI_Output(self,other,"DIA_Garond_PaladinFree_01_13"); //Ha! A kde asi tak půjdeme? Všude jsou skřeti.
AI_Output(other,self,"DIA_Garond_PaladinFree_01_17"); //Dojednal jsem s jejich vůdcem vaše propuštění.
AI_Output(other,self,"DIA_Garond_PaladinFree_01_18"); //Takže pokud tady neplánujete čekat, až skřeti změní názor, měli byste se pohnout.
AI_Output(self,other,"DIA_Garond_PaladinFree_01_19"); //Hmmm... Když to říkáš.
AI_Output(self,other,"DIA_Garond_PaladinFree_01_20"); //Ale pro začátek pusť mě a mé chlapy z těch zatracených cel.
PALADINCASTELFREE = TRUE;
SAFEFLAGPALADIN = TRUE;
if(MIS_NEWSSURVIVERS == LOG_Running)
{
MIS_NEWSSURVIVERS = LOG_SUCCESS;
Log_SetTopicStatus(TOPIC_NEWSSURVIVERS,LOG_SUCCESS);
};
if(MIS_STURMCASTLE == LOG_Running)
{
MIS_STURMCASTLE = LOG_SUCCESS;
Log_SetTopicStatus(TOPIC_STURMCASTLE,LOG_SUCCESS);
};
if(MIS_RESCUEGAROND == LOG_Running)
{
B_LogEntry(TOPIC_RESCUEGAROND,"Osvobodil jsem Garonda a jeho lidi. Teď se musíme co nejrychleji dostat z údolí.");
};
AI_StopProcessInfos(self);
if(DGJMOVEPALADIN == TRUE)
{
b_readydgjmove();
};
};
};
instance DIA_GAROND_WHATWAIT(C_Info)
{
npc = PAL_250_Garond;
nr = 1;
condition = dia_garond_whatwait_condition;
information = dia_garond_whatwait_info;
permanent = TRUE;
important = TRUE;
};
func int dia_garond_whatwait_condition()
{
if(Npc_IsInState(self,ZS_Talk) && (PALADINCASTELFREE == TRUE) && ((OLDCAMDGATEOPEN_01 == FALSE) || (OLDCAMDGATEOPEN_02 == FALSE) || (OLDCAMDGATEOPEN_03 == FALSE)))
{
return TRUE;
};
};
func void dia_garond_whatwait_info()
{
AI_Output(self,other,"DIA_Garond_WhatWait_01_00"); //Necháš nás tu sedět ještě dlouho? Na co čekáš?
AI_Output(self,other,"DIA_Garond_WhatWait_01_01"); //No tak, pospěš si!
AI_StopProcessInfos(self);
};
instance DIA_GAROND_PEOPLEFREE(C_Info)
{
npc = PAL_250_Garond;
nr = 1;
condition = dia_garond_peoplefree_condition;
information = dia_garond_peoplefree_info;
permanent = FALSE;
important = TRUE;
};
func int dia_garond_peoplefree_condition()
{
if(Npc_IsInState(self,ZS_Talk) && (PALADINCASTELFREE == TRUE) && (OLDCAMDGATEOPEN_01 == TRUE) && (OLDCAMDGATEOPEN_02 == TRUE) && (OLDCAMDGATEOPEN_03 == TRUE))
{
return TRUE;
};
};
func void dia_garond_peoplefree_info()
{
AI_Output(self,other,"DIA_Garond_PeopleFree_01_00"); //Bezva! O moc lepší!
AI_Output(other,self,"DIA_Garond_PeopleFree_01_01"); //Teď mizíme!
if(CANFREEPALADIN == TRUE)
{
AI_Output(other,self,"DIA_Garond_PeopleFree_01_02"); //Musíme se dostat ke skupině paladinů, která čeká při východu z údolí.
AI_Output(self,other,"DIA_Garond_PeopleFree_01_03"); //Dobrá, pak neztrácejme čas. Veď nás.
ALLAWAYFROMCASTLE = TRUE;
Info_ClearChoices(dia_garond_peoplefree);
Info_AddChoice(dia_garond_peoplefree,"Jdeme!",dia_garond_peoplefree_go);
}
else if(CASTLEISFREE == TRUE)
{
AI_Output(other,self,"DIA_Garond_PeopleFree_01_05"); //Musíme okamžitě zmizet.
AI_Output(self,other,"DIA_Garond_PeopleFree_01_06"); //Ale proč?
AI_Output(other,self,"DIA_Garond_PeopleFree_01_07"); //Skřeti sem brzy pošlou své jednotky, a pak budeme mít problémy.
AI_Output(self,other,"DIA_Garond_PeopleFree_01_14"); //Hmmm... (zamyšleně) No dobrá.
AI_Output(self,other,"DIA_Garond_PeopleFree_01_15"); //Pak neztrácejme čas a honem odsud!
ALLAWAYFROMCASTLE = TRUE;
Info_ClearChoices(dia_garond_peoplefree);
Info_AddChoice(dia_garond_peoplefree,"Jdeme!",dia_garond_peoplefree_go);
};
};
func void dia_garond_peoplefree_go()
{
AI_Output(other,self,"DIA_Garond_PeopleFree_Go_01_01"); //Jdeme!
AI_StopProcessInfos(self);
b_paladinawayone();
};
instance DIA_GAROND_PEOPLEAWAY(C_Info)
{
npc = PAL_250_Garond;
nr = 1;
condition = dia_garond_peopleaway_condition;
information = dia_garond_peopleaway_info;
permanent = FALSE;
important = TRUE;
};
func int dia_garond_peopleaway_condition()
{
if((ALLAWAYFROMCASTLE == TRUE) && (GARONDARRIVESEXIT == TRUE))
{
return TRUE;
};
};
func void dia_garond_peopleaway_info()
{
B_GivePlayerXP(200);
AI_Output(self,other,"DIA_Garond_PeopleAway_01_00"); //Tak jsme tady! Myslím, že tu jsme už v bezpečí.
AI_Output(other,self,"DIA_Garond_PeopleAway_01_03"); //Ale pořád musíme dál. Každá minuta je drahá!
AI_Output(self,other,"DIA_Garond_PeopleAway_01_04"); //Souhlasím. Tak projdi průsmykem, budeme hned za tebou.
AI_Output(other,self,"DIA_Garond_PeopleAway_01_05"); //Dobře. Potkáme se na druhé straně.
ALLAWAYFROMPLACE = TRUE;
AI_StopProcessInfos(self);
b_paladinawaytwo();
};
instance DIA_GAROND_WHATWAITAGAIN(C_Info)
{
npc = PAL_250_Garond;
nr = 1;
condition = dia_garond_whatwaitagain_condition;
information = dia_garond_whatwaitagain_info;
permanent = TRUE;
important = TRUE;
};
func int dia_garond_whatwaitagain_condition()
{
if(Npc_IsInState(self,ZS_Talk) && (ALLAWAYFROMPLACE == TRUE))
{
return TRUE;
};
};
func void dia_garond_whatwaitagain_info()
{
AI_Output(self,other,"DIA_Garond_WhatWaitAgain_01_00"); //No tak, jdi! Jsme hned za tebou.
AI_StopProcessInfos(self);
};
instance DIA_Garond_OrcTraitor(C_Info)
{
npc = PAL_250_Garond;
nr = 1;
condition = DIA_Garond_OrcTraitor_Condition;
information = DIA_Garond_OrcTraitor_Info;
permanent = FALSE;
description = "Mám něco pro tebe.";
};
func int DIA_Garond_OrcTraitor_Condition()
{
if((MIS_HeroOrcJoin_T2 == LOG_Running) && (Npc_HasItems(other,ItWr_UrKarrasLetter) >= 1) && (OrcClanBossLetterDeliver == FALSE))
{
return TRUE;
};
};
func void DIA_Garond_OrcTraitor_Info()
{
var int RanGonezPlace;
B_GivePlayerXP(1000);
AI_Output(other,self,"DIA_Garond_OrcTraitor_01_00"); //Mám něco pro tebe.
AI_Output(self,other,"DIA_Garond_OrcTraitor_01_01"); //Doufám, že je to něco opravdu důležitého a ne nějaká prkotina.
AI_Output(other,self,"DIA_Garond_OrcTraitor_01_02"); //Tady, podívej.
B_GiveInvItems(other,self,ItWr_UrKarrasLetter,1);
AI_Output(self,other,"DIA_Garond_OrcTraitor_01_03"); //Co to je?
AI_Output(other,self,"DIA_Garond_OrcTraitor_01_04"); //Zpráva skřetího generála jednomu z vůdců horských kmenů. Už máš zájem?
AI_Output(self,other,"DIA_Garond_OrcTraitor_01_05"); //(se zájmem) No tak, nech mě podívat...
B_UseFakeScroll();
AI_Output(self,other,"DIA_Garond_OrcTraitor_01_06"); //Ale tato zpráva je psána skřetím jazykem!
AI_Output(other,self,"DIA_Garond_OrcTraitor_01_07"); //Samozřejmě, že ano, vždyť ji psal skřet! Potřebuješ tlumočníka?
AI_Output(self,other,"DIA_Garond_OrcTraitor_01_08"); //Ne, přečtu to. (rozezleně) Za ty dlouhé roky, které už s těmi stvůrami válčím, jsem pochytil kousek z jejich jazyka.
B_UseFakeScroll();
AI_Output(self,other,"DIA_Garond_OrcTraitor_01_09"); //Nevěřím svým očím! Tohle, cos přinesl - to jsou vskutku velice důležité informace!
AI_Output(other,self,"DIA_Garond_OrcTraitor_01_10"); //Co se tam píše?
AI_Output(self,other,"DIA_Garond_OrcTraitor_01_11"); //Skřeti se prý chystají k útoku na hrad a shromažďují veškeré zálohy.
AI_Output(self,other,"DIA_Garond_OrcTraitor_01_12"); //Chtějí nás překvapit útokem ze všech stran. Nu, teď se jim to rozhodně nepovede.
AI_Output(self,other,"DIA_Garond_OrcTraitor_01_13"); //Zdvojnásobíme stráže a dobudujeme naše opevnění.
AI_Output(other,self,"DIA_Garond_OrcTraitor_01_14"); //Máš na to dost mužů?
AI_Output(self,other,"DIA_Garond_OrcTraitor_01_15"); //Zatím ano. Naše situace není nejlepší, ale máme dostatek lidí, abychom ubránili hrad z více stran.
AI_Output(self,other,"DIA_Garond_OrcTraitor_01_16"); //Samozřejmě, že bez dodatečných opatření by to pro nás bylo složitější.
AI_Output(self,other,"DIA_Garond_OrcTraitor_01_17"); //Ale naštěstí teď máme dost času, abychom se na útok dobře připravili.
AI_Output(other,self,"DIA_Garond_OrcTraitor_01_18"); //Jsem rád, že ti tahle informace pomohla.
AI_Output(self,other,"DIA_Garond_OrcTraitor_01_19"); //Tvoje pomoc v téhle záležitosti byla neocenitelná. Děkuji ti jménem všech paladinů v pevnosti.
AI_Output(self,other,"DIA_Garond_OrcTraitor_01_20"); //Tady, vezmi si tohle jako odměnu...
B_GiveInvItems(self,other,ItPo_Perm_Health,1);
AI_Output(self,other,"DIA_Garond_OrcTraitor_01_21"); //Sám víš, že naše zásoby jsou velice omezené.
AI_Output(self,other,"DIA_Garond_OrcTraitor_01_22"); //Ale prostě bych ti nemohl nepoděkovat za to, cos pro nás udělal.
OrcTraitor = TRUE;
B_LogEntry(TOPIC_HeroOrcJoin_T2,"Místo toho, abych předal Ur-Karrasovu zprávu vůdci klanu Vysoké skály jsem ji odnesl lidem na hradu. Z dopisu vyplynulo, že skřeti se připravují na další útok a shromažďují posily od ostatních klanů. Jak jsem předpokládal, tahle informace byla pro paladiny velmi důležitá. Po téhle zradě bych se už však raději neměl vracet do Skřetího města. Skřeti si určitě všimli moji přítomnost na hradě a vyšlou k Ur-Karrasovi posla, aby mu o mé zradě řekl. Jestli se mi nepovede toho posla zastavit, určitě to Ur-Karrasovi ohlásí. Měl bych si pospíšit, protože mi zřejmě zůstává jen velmi málo času...");
RanGonezPlace = Hlp_Random(100);
DayGonezStart = Wld_GetDay();
if(RanGonezPlace >= 60)
{
Wld_InsertNpc(OrkElite_Addon2_Gonez,"FP_ROAM_URKARRAS_GONEZ_01");
}
else if(RanGonezPlace >= 30)
{
Wld_InsertNpc(OrkElite_Addon2_Gonez,"FP_ROAM_URKARRAS_GONEZ_02");
}
else if(RanGonezPlace >= 0)
{
Wld_InsertNpc(OrkElite_Addon2_Gonez,"FP_ROAM_URKARRAS_GONEZ_03");
};
};
instance DIA_Garond_PICKPOCKET(C_Info)
{
npc = PAL_250_Garond;
nr = 900;
condition = DIA_Garond_pickpocket_condition;
information = DIA_Garond_pickpocket_info;
permanent = TRUE;
description = "(Pokusit se ukrást jeho klíč)";
};
func int DIA_Garond_pickpocket_condition()
{
if((Npc_GetTalentSkill(other,NPC_TALENT_PICKPOCKET) >= 1) && (self.aivar[AIV_PlayerHasPickedMyPocket] == FALSE))
{
return TRUE;
};
};
func void DIA_Garond_pickpocket_info()
{
Info_ClearChoices(DIA_Garond_pickpocket);
Info_AddChoice(DIA_Garond_pickpocket,Dialog_Back,DIA_Garond_pickpocket_back);
Info_AddChoice(DIA_Garond_pickpocket,DIALOG_PICKPOCKET,DIA_Garond_pickpocket_doit);
};
func void DIA_Garond_pickpocket_doit()
{
AI_PlayAni(other,"T_STEAL");
AI_Wait(other,1);
if((other.attribute[ATR_DEXTERITY] + PickPocketBonusCount) >= 150)
{
if((other.guild == GIL_PAL) || (other.guild == GIL_KDF))
{
INNOSCRIMECOUNT = INNOSCRIMECOUNT + 1;
}
else
{
GlobalThiefCount += 1;
if(GlobalThiefCount >= 3)
{
INNOSCRIMECOUNT = INNOSCRIMECOUNT + 1;
GlobalThiefCount = FALSE;
};
};
B_GiveInvItems(self,other,ItKe_Garond,1);
self.aivar[AIV_PlayerHasPickedMyPocket] = TRUE;
B_GiveThiefXP();
Info_ClearChoices(DIA_Garond_pickpocket);
}
else
{
if((other.guild == GIL_PAL) || (other.guild == GIL_KDF))
{
INNOSCRIMECOUNT = INNOSCRIMECOUNT + 1;
};
THIEFCATCHER = Hlp_GetNpc(self);
HERO_CANESCAPEFROMGOTCHA = TRUE;
B_ResetThiefLevel();
AI_StopProcessInfos(self);
};
};
func void DIA_Garond_pickpocket_back()
{
Info_ClearChoices(DIA_Garond_pickpocket);
};
|
D
|
/Users/triggullberg/Desktop/LpRocks/Build/Intermediates/LpRocks.build/Debug-iphonesimulator/LpRocks.build/Objects-normal/x86_64/NVActivityIndicatorAnimationAudioEqualizer.o : /Users/triggullberg/Desktop/LpRocks/LpRocks/OnboardVC.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/MainVC.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/StartVC.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulseSync.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScalePulseOutRapid.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScale.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScale.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/NVActivityIndicatorViewable.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleMultiple.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleRippleMultiple.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotateMultiple.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleRipple.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/NVActivityIndicatorShape.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallRotateChase.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulseRise.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallGridPulse.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotatePulse.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulse.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/NVActivityIndicatorAnimationDelegate.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/AppDelegate.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallRotate.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotate.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallZigZag.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallTrianglePath.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBlank.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationPacman.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationSemiCircleSpin.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationSquareSpin.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationTriangleSkewSpin.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationCubeTransition.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineSpinFadeLoader.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallSpinFadeLoader.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/NVActivityIndicatorPresenter.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationAudioEqualizer.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallGridBeat.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallBeat.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallZigZagDeflect.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationOrbit.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScalePulseOut.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/NVActivityIndicatorView.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScaleParty.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/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/simd.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/AVFoundation.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/CoreAudio.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/triggullberg/Desktop/LpRocks/Pods/Leanplum-iOS-SDK/Leanplum.framework/Headers/Leanplum.h /Users/triggullberg/Desktop/LpRocks/Pods/Leanplum-iOS-UIEditor/LeanplumUIEditor.framework/Headers/LeanplumUIEditor.h /Users/triggullberg/Desktop/LpRocks/Pods/Leanplum-iOS-SDK/Leanplum.framework/Headers/LPInbox.h /Users/triggullberg/Desktop/LpRocks/Pods/Leanplum-iOS-SDK/Leanplum.framework/Modules/module.modulemap /Users/triggullberg/Desktop/LpRocks/Pods/Leanplum-iOS-UIEditor/LeanplumUIEditor.framework/Modules/module.modulemap /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/AVFoundation.framework/Headers/AVFoundation.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/AdSupport.framework/Headers/AdSupport.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.apinotes
/Users/triggullberg/Desktop/LpRocks/Build/Intermediates/LpRocks.build/Debug-iphonesimulator/LpRocks.build/Objects-normal/x86_64/NVActivityIndicatorAnimationAudioEqualizer~partial.swiftmodule : /Users/triggullberg/Desktop/LpRocks/LpRocks/OnboardVC.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/MainVC.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/StartVC.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulseSync.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScalePulseOutRapid.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScale.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScale.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/NVActivityIndicatorViewable.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleMultiple.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleRippleMultiple.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotateMultiple.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleRipple.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/NVActivityIndicatorShape.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallRotateChase.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulseRise.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallGridPulse.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotatePulse.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulse.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/NVActivityIndicatorAnimationDelegate.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/AppDelegate.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallRotate.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotate.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallZigZag.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallTrianglePath.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBlank.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationPacman.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationSemiCircleSpin.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationSquareSpin.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationTriangleSkewSpin.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationCubeTransition.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineSpinFadeLoader.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallSpinFadeLoader.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/NVActivityIndicatorPresenter.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationAudioEqualizer.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallGridBeat.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallBeat.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallZigZagDeflect.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationOrbit.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScalePulseOut.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/NVActivityIndicatorView.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScaleParty.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/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/simd.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/AVFoundation.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/CoreAudio.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/triggullberg/Desktop/LpRocks/Pods/Leanplum-iOS-SDK/Leanplum.framework/Headers/Leanplum.h /Users/triggullberg/Desktop/LpRocks/Pods/Leanplum-iOS-UIEditor/LeanplumUIEditor.framework/Headers/LeanplumUIEditor.h /Users/triggullberg/Desktop/LpRocks/Pods/Leanplum-iOS-SDK/Leanplum.framework/Headers/LPInbox.h /Users/triggullberg/Desktop/LpRocks/Pods/Leanplum-iOS-SDK/Leanplum.framework/Modules/module.modulemap /Users/triggullberg/Desktop/LpRocks/Pods/Leanplum-iOS-UIEditor/LeanplumUIEditor.framework/Modules/module.modulemap /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/AVFoundation.framework/Headers/AVFoundation.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/AdSupport.framework/Headers/AdSupport.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.apinotes
/Users/triggullberg/Desktop/LpRocks/Build/Intermediates/LpRocks.build/Debug-iphonesimulator/LpRocks.build/Objects-normal/x86_64/NVActivityIndicatorAnimationAudioEqualizer~partial.swiftdoc : /Users/triggullberg/Desktop/LpRocks/LpRocks/OnboardVC.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/MainVC.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/StartVC.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulseSync.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScalePulseOutRapid.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScale.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScale.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/NVActivityIndicatorViewable.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleMultiple.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleRippleMultiple.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotateMultiple.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleRipple.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/NVActivityIndicatorShape.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallRotateChase.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulseRise.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallGridPulse.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotatePulse.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulse.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/NVActivityIndicatorAnimationDelegate.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/AppDelegate.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallRotate.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotate.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallZigZag.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallTrianglePath.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBlank.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationPacman.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationSemiCircleSpin.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationSquareSpin.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationTriangleSkewSpin.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationCubeTransition.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineSpinFadeLoader.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallSpinFadeLoader.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/NVActivityIndicatorPresenter.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationAudioEqualizer.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallGridBeat.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallBeat.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallZigZagDeflect.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationOrbit.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScalePulseOut.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/NVActivityIndicatorView.swift /Users/triggullberg/Desktop/LpRocks/LpRocks/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScaleParty.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/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/simd.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/AVFoundation.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/CoreAudio.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/triggullberg/Desktop/LpRocks/Pods/Leanplum-iOS-SDK/Leanplum.framework/Headers/Leanplum.h /Users/triggullberg/Desktop/LpRocks/Pods/Leanplum-iOS-UIEditor/LeanplumUIEditor.framework/Headers/LeanplumUIEditor.h /Users/triggullberg/Desktop/LpRocks/Pods/Leanplum-iOS-SDK/Leanplum.framework/Headers/LPInbox.h /Users/triggullberg/Desktop/LpRocks/Pods/Leanplum-iOS-SDK/Leanplum.framework/Modules/module.modulemap /Users/triggullberg/Desktop/LpRocks/Pods/Leanplum-iOS-UIEditor/LeanplumUIEditor.framework/Modules/module.modulemap /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/AVFoundation.framework/Headers/AVFoundation.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/AdSupport.framework/Headers/AdSupport.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.apinotes
|
D
|
// PERMUTE_ARGS: -g
// EXTRA_CPP_SOURCES: cppb.cpp
import core.stdc.stdio;
import core.stdc.stdarg;
import core.stdc.config;
extern (C++)
int foob(int i, int j, int k);
class C
{
extern (C++) int bar(int i, int j, int k)
{
printf("this = %p\n", this);
printf("i = %d\n", i);
printf("j = %d\n", j);
printf("k = %d\n", k);
return 1;
}
}
extern (C++)
int foo(int i, int j, int k)
{
printf("i = %d\n", i);
printf("j = %d\n", j);
printf("k = %d\n", k);
assert(i == 1);
assert(j == 2);
assert(k == 3);
return 1;
}
void test1()
{
foo(1, 2, 3);
auto i = foob(1, 2, 3);
assert(i == 7);
C c = new C();
c.bar(4, 5, 6);
}
/****************************************/
extern (C++) interface D
{
int bar(int i, int j, int k);
}
extern (C++) D getD();
void test2()
{
D d = getD();
int i = d.bar(9,10,11);
assert(i == 8);
}
/****************************************/
extern (C++) int callE(E);
extern (C++) interface E
{
int bar(int i, int j, int k);
}
class F : E
{
extern (C++) int bar(int i, int j, int k)
{
printf("F.bar: i = %d\n", i);
printf("F.bar: j = %d\n", j);
printf("F.bar: k = %d\n", k);
assert(i == 11);
assert(j == 12);
assert(k == 13);
return 8;
}
}
void test3()
{
F f = new F();
int i = callE(f);
assert(i == 8);
}
/****************************************/
extern (C++) void foo4(char* p);
void test4()
{
foo4(null);
}
/****************************************/
extern(C++)
{
struct foo5 { int i; int j; void* p; }
interface bar5{
foo5 getFoo(int i);
}
bar5 newBar();
}
void test5()
{
bar5 b = newBar();
foo5 f = b.getFoo(4);
printf("f.p = %p, b = %p\n", f.p, cast(void*)b);
assert(f.p == cast(void*)b);
}
/****************************************/
extern(C++)
{
struct S6
{
int i;
double d;
}
union S6_2
{
int i;
double d;
}
enum S6_3
{
A, B
}
S6 foo6();
S6_2 foo6_2();
S6_3 foo6_3();
}
extern (C) int foosize6();
void test6()
{
S6 f = foo6();
printf("%d %d\n", foosize6(), S6.sizeof);
assert(foosize6() == S6.sizeof);
version (X86)
{
assert(f.i == 42);
printf("f.d = %g\n", f.d);
assert(f.d == 2.5);
assert(foo6_2().i == 42);
assert(foo6_3() == S6_3.A);
}
}
/****************************************/
extern (C) int foo7();
struct S
{
int i;
long l;
}
void test7()
{
printf("%d %d\n", foo7(), S.sizeof);
assert(foo7() == S.sizeof);
}
/****************************************/
extern (C++) void foo8(const(char)*);
void test8()
{
char c;
foo8(&c);
}
/****************************************/
// 4059
struct elem9 { }
extern(C++) void foobar9(elem9*, elem9*);
void test9()
{
elem9 *a;
foobar9(a, a);
}
/****************************************/
struct A11802;
struct B11802;
extern(C++) class C11802
{
int x;
void fun(A11802*) { x += 2; }
void fun(B11802*) { x *= 2; }
}
extern(C++) class D11802 : C11802
{
override void fun(A11802*) { x += 3; }
override void fun(B11802*) { x *= 3; }
}
extern(C++) void test11802x(D11802);
void test11802()
{
auto x = new D11802();
x.x = 0;
test11802x(x);
assert(x.x == 9);
}
/****************************************/
struct S13956
{
}
extern(C++) void func13956(S13956 arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6);
extern(C++) void check13956(S13956 arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6)
{
assert(arg0 == S13956());
assert(arg1 == 1);
assert(arg2 == 2);
assert(arg3 == 3);
assert(arg4 == 4);
assert(arg5 == 5);
version (OSX)
{
version (D_LP64)
assert(arg6 == 6);
// fails on OSX 32-bit
}
else
assert(arg6 == 6);
}
void test13956()
{
func13956(S13956(), 1, 2, 3, 4, 5, 6);
}
/****************************************/
// 5148
extern (C++)
{
void foo10(const(char)*, const(char)*);
void foo10(const int, const int);
void foo10(const char, const char);
void foo10(bool, bool);
struct MyStructType { }
void foo10(const MyStructType s, const MyStructType t);
enum MyEnumType { onemember }
void foo10(const MyEnumType s, const MyEnumType t);
}
void test10()
{
char* p;
foo10(p, p);
foo10(1,2);
foo10('c','d');
MyStructType s;
foo10(s,s);
MyEnumType e;
foo10(e,e);
}
/****************************************/
extern (C++, N11.M) { void bar11(); }
extern (C++, A11.B) { extern (C++, C) { void bar(); }}
void test11()
{
bar11();
A11.B.C.bar();
}
/****************************************/
struct Struct10071
{
void *p;
c_long_double r;
}
extern(C++) size_t offset10071();
void test10071()
{
assert(offset10071() == Struct10071.r.offsetof);
}
/****************************************/
version(LDC)
{
version(X86_64)
{
version(Win64) {}
else version = LDC_SystemV;
}
}
version(LDC_SystemV)
alias __va_list_tag* cpp_va_list;
else
alias va_list cpp_va_list;
char[100] valistbuffer;
extern(C++) void myvprintfx(const(char)* format, cpp_va_list va)
{
vsprintf(valistbuffer.ptr, format, cast(va_list) va);
}
extern(C++) void myvprintf(const(char)*, cpp_va_list);
extern(C++) void myprintf(const(char)* format, ...)
{
va_list ap;
va_start(ap, format);
myvprintf(format, cast(cpp_va_list) ap);
va_end(ap);
}
void testvalist()
{
myprintf("hello %d", 999);
assert(valistbuffer[0..9] == "hello 999");
}
/****************************************/
// 12825
extern(C++) class C12825
{
uint a = 0x12345678;
}
void test12825()
{
auto c = new C12825();
}
/****************************************/
struct S13955a
{
float a;
double b;
}
struct S13955b
{
double a;
float b;
}
struct S13955c
{
float a;
float b;
}
struct S13955d
{
double a;
double b;
}
extern(C++) void check13955(S13955a a, S13955b b, S13955c c, S13955d d)
{
assert(a.a == 2);
assert(a.b == 4);
assert(b.a == 8);
assert(b.b == 16);
assert(c.a == 32);
assert(c.b == 64);
assert(d.a == 128);
assert(d.b == 256);
}
extern(C++) void func13955(S13955a a, S13955b b, S13955c c, S13955d d);
void test13955()
{
func13955(S13955a(2, 4), S13955b(8, 16), S13955c(32, 64), S13955d(128, 256));
}
/****************************************/
extern(C++) class C13161
{
void dummyfunc();
long val_5;
uint val_9;
}
extern(C++) class Test : C13161
{
uint val_0;
long val_1;
}
extern(C++) size_t getoffset13161();
extern(C++) class C13161a
{
void dummyfunc();
c_long_double val_5;
uint val_9;
}
extern(C++) class Testa : C13161a
{
bool val_0;
}
extern(C++) size_t getoffset13161a();
void test13161()
{
assert(getoffset13161() == Test.val_0.offsetof);
assert(getoffset13161a() == Testa.val_0.offsetof);
}
/****************************************/
version (linux)
{
extern(C++, __gnu_cxx)
{
struct new_allocator(T)
{
alias size_type = size_t;
static if (is(T : char))
void deallocate(T*, size_type) { }
else
void deallocate(T*, size_type);
}
}
}
extern (C++, std)
{
struct allocator(T)
{
version (linux)
{
alias size_type = size_t;
void deallocate(T* p, size_type sz)
{ (cast(__gnu_cxx.new_allocator!T*)&this).deallocate(p, sz); }
}
}
version (linux)
{
class vector(T, A = allocator!T)
{
final void push_back(ref const T);
}
struct char_traits(T)
{
}
// https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
version (none)
{
extern (C++, __cxx11)
{
struct basic_string(T, C = char_traits!T, A = allocator!T)
{
}
}
}
else
{
struct basic_string(T, C = char_traits!T, A = allocator!T)
{
}
}
struct basic_istream(T, C = char_traits!T)
{
}
struct basic_ostream(T, C = char_traits!T)
{
}
struct basic_iostream(T, C = char_traits!T)
{
}
}
class exception { }
// 14956
extern(C++, N14956)
{
struct S14956 { }
}
}
extern (C++)
{
version (linux)
{
void foo14(std.vector!(int) p);
void foo14a(std.basic_string!(char) *p);
void foo14b(std.basic_string!(int) *p);
void foo14c(std.basic_istream!(char) *p);
void foo14d(std.basic_ostream!(char) *p);
void foo14e(std.basic_iostream!(char) *p);
void foo14f(std.char_traits!char* x, std.basic_string!char* p, std.basic_string!char* q);
}
}
void test14()
{
version (linux)
{
std.vector!int p;
foo14(p);
foo14a(null);
foo14b(null);
foo14c(null);
foo14d(null);
foo14e(null);
foo14f(null, null, null);
}
}
version (linux)
{
void test14a(std.allocator!int * pa)
{
pa.deallocate(null, 0);
}
void gun(std.vector!int pa)
{
int x = 42;
pa.push_back(x);
}
}
void test13289()
{
assert(f13289_cpp_wchar_t('a') == 'A');
assert(f13289_cpp_wchar_t('B') == 'B');
assert(f13289_d_wchar('c') == 'C');
assert(f13289_d_wchar('D') == 'D');
assert(f13289_d_dchar('e') == 'E');
assert(f13289_d_dchar('F') == 'F');
assert(f13289_cpp_test());
}
extern(C++)
{
bool f13289_cpp_test();
version(Posix)
{
dchar f13289_cpp_wchar_t(dchar);
}
else version(Windows)
{
wchar f13289_cpp_wchar_t(wchar);
}
wchar f13289_d_wchar(wchar ch)
{
if (ch <= 'z' && ch >= 'a')
{
return cast(wchar)(ch - ('a' - 'A'));
}
else
{
return ch;
}
}
dchar f13289_d_dchar(dchar ch)
{
if (ch <= 'z' && ch >= 'a')
{
return ch - ('a' - 'A');
}
else
{
return ch;
}
}
}
/****************************************/
version (CRuntime_Microsoft)
{
struct __c_long_double
{
this(double d) { ld = d; }
double ld;
alias ld this;
}
alias __c_long_double myld;
}
else
alias c_long_double myld;
extern (C++) myld testld(myld);
void test15()
{
myld ld = 5.0;
ld = testld(ld);
assert(ld == 6.0);
}
/****************************************/
version( Windows )
{
alias int x_long;
alias uint x_ulong;
}
else
{
static if( (void*).sizeof > int.sizeof )
{
alias long x_long;
alias ulong x_ulong;
}
else
{
alias int x_long;
alias uint x_ulong;
}
}
struct __c_long
{
this(x_long d) { ld = d; }
x_long ld;
alias ld this;
}
struct __c_ulong
{
this(x_ulong d) { ld = d; }
x_ulong ld;
alias ld this;
}
alias __c_long mylong;
alias __c_ulong myulong;
extern (C++) mylong testl(mylong);
extern (C++) myulong testul(myulong);
void test16()
{
{
mylong ld = 5;
ld = testl(ld);
assert(ld == 5 + mylong.sizeof);
}
{
myulong ld = 5;
ld = testul(ld);
assert(ld == 5 + myulong.sizeof);
}
}
/****************************************/
struct S13707
{
void* a;
void* b;
this(void* a, void* b)
{
this.a = a;
this.b = b;
}
}
extern(C++) S13707 func13707();
void test13707()
{
auto p = func13707();
assert(p.a == null);
assert(p.b == null);
}
/****************************************/
struct S13932(int x)
{
int member;
}
extern(C++) void func13932(S13932!(-1) s);
/****************************************/
extern(C++, N13337.M13337)
{
struct S13337{}
void foo13337(S13337 s);
}
/****************************************/
// 14195
struct Delegate1(T) {}
struct Delegate2(T1, T2) {}
template Signature(T)
{
alias Signature = typeof(*(T.init));
}
extern(C++)
{
alias del1_t = Delegate1!(Signature!(void function()));
alias del2_t = Delegate2!(Signature!(int function(float, double)), Signature!(int function(float, double)));
void test14195a(del1_t);
void test14195b(del2_t);
}
void test14195()
{
test14195a(del1_t());
test14195b(del2_t());
}
/****************************************/
// 14200
template Tuple14200(T...)
{
alias Tuple14200 = T;
}
extern(C++) void test14200a(Tuple14200!(int));
extern(C++) void test14200b(float, Tuple14200!(int, double));
void test14200()
{
test14200a(1);
test14200b(1.0f, 1, 1.0);
}
/****************************************/
// 14956
extern(C++) void test14956(S14956 s);
/****************************************/
// check order of overloads in vtable
extern (C++) class Statement {}
extern (C++) class ErrorStatement {}
extern (C++) class PeelStatement {}
extern (C++) class ExpStatement {}
extern (C++) class DtorExpStatement {}
extern (C++) class Visitor
{
public:
int visit(Statement) { return 1; }
int visit(ErrorStatement) { return 2; }
int visit(PeelStatement) { return 3; }
}
extern (C++) class Visitor2 : Visitor
{
int visit2(ExpStatement) { return 4; }
int visit2(DtorExpStatement) { return 5; }
}
extern(C++) bool testVtableCpp(Visitor2 sv);
extern(C++) Visitor2 getVisitor2();
bool testVtableD(Visitor2 sv)
{
Statement s1;
ErrorStatement s2;
PeelStatement s3;
ExpStatement s4;
DtorExpStatement s5;
if (sv.visit(s1) != 1) return false;
if (sv.visit(s2) != 2) return false;
if (sv.visit(s3) != 3) return false;
if (sv.visit2(s4) != 4) return false;
if (sv.visit2(s5) != 5) return false;
return true;
}
void testVtable()
{
Visitor2 dinst = new Visitor2;
if (!testVtableCpp(dinst))
assert(0);
Visitor2 cppinst = getVisitor2();
if (!testVtableD(cppinst))
assert(0);
}
/****************************************/
/* problems detected by fuzzer */
extern(C++) void fuzz1_cppvararg(long arg10, long arg11, bool arg12);
extern(C++) void fuzz1_dvararg(long arg10, long arg11, bool arg12)
{
fuzz1_checkValues(arg10, arg11, arg12);
}
extern(C++) void fuzz1_checkValues(long arg10, long arg11, bool arg12)
{
assert(arg10 == 103);
assert(arg11 == 104);
assert(arg12 == false);
}
void fuzz1()
{
long arg10 = 103;
long arg11 = 104;
bool arg12 = false;
fuzz1_dvararg(arg10, arg11, arg12);
fuzz1_cppvararg(arg10, arg11, arg12);
}
////////
extern(C++) void fuzz2_cppvararg(ulong arg10, ulong arg11, bool arg12);
extern(C++) void fuzz2_dvararg(ulong arg10, ulong arg11, bool arg12)
{
fuzz2_checkValues(arg10, arg11, arg12);
}
extern(C++) void fuzz2_checkValues(ulong arg10, ulong arg11, bool arg12)
{
assert(arg10 == 103);
assert(arg11 == 104);
assert(arg12 == false);
}
void fuzz2()
{
ulong arg10 = 103;
ulong arg11 = 104;
bool arg12 = false;
fuzz2_dvararg(arg10, arg11, arg12);
fuzz2_cppvararg(arg10, arg11, arg12);
}
////////
extern(C++) void fuzz3_cppvararg(wchar arg10, wchar arg11, bool arg12);
extern(C++) void fuzz3_dvararg(wchar arg10, wchar arg11, bool arg12)
{
fuzz2_checkValues(arg10, arg11, arg12);
}
extern(C++) void fuzz3_checkValues(wchar arg10, wchar arg11, bool arg12)
{
assert(arg10 == 103);
assert(arg11 == 104);
assert(arg12 == false);
}
void fuzz3()
{
wchar arg10 = 103;
wchar arg11 = 104;
bool arg12 = false;
fuzz3_dvararg(arg10, arg11, arg12);
fuzz3_cppvararg(arg10, arg11, arg12);
}
void fuzz()
{
fuzz1();
fuzz2();
fuzz3();
}
/****************************************/
version (LDC)
{
version (OSX)
{
// FIXME: C++ exceptions not caught
}
else
version = LDC_CppEH;
}
extern (C++)
{
void throwit();
}
void testeh()
{
printf("testeh()\n");
version (LDC_CppEH) // LDC: was `version (linux)`
{
version (all) // LDC: was `version (X86_64)`
{
bool caught;
try
{
throwit();
}
catch (std.exception e)
{
caught = true;
}
assert(caught);
}
}
}
/****************************************/
version (LDC_CppEH) // LDC: was `version (linux)`
{
version (all) // LDC: was `version (X86_64)`
{
bool raii_works = false;
struct RAIITest
{
~this()
{
raii_works = true;
}
}
void dFunction()
{
RAIITest rt;
throwit();
}
void testeh2()
{
printf("testeh2()\n");
try
{
dFunction();
}
catch(std.exception e)
{
assert(raii_works);
}
}
}
else
void testeh2() { }
}
else
void testeh2() { }
/****************************************/
extern (C++) { void throwle(); void throwpe(); }
void testeh3()
{
printf("testeh3()\n");
version (LDC_CppEH) // LDC: was `version (linux)`
{
version (all) // LDC: was `version (X86_64)`
{
bool caught = false;
try
{
throwle();
}
catch (std.exception e) //polymorphism test.
{
caught = true;
}
assert(caught);
}
}
}
/****************************************/
// 15576
extern (C++, ns15576)
{
extern __gshared int global15576;
extern (C++, ns)
{
extern __gshared int n_global15576;
}
}
void test15576()
{
global15576 = n_global15576 = 123;
}
/****************************************/
// 15579
extern (C++)
{
class Base
{
//~this() {}
void based() { }
ubyte x = 4;
}
interface Interface
{
int MethodCPP();
int MethodD();
}
class Derived : Base, Interface
{
short y = 5;
int MethodCPP();
int MethodD() {
printf("Derived.MethodD(): this = %p, x = %d, y = %d\n", this, x, y);
Derived p = this;
//p = cast(Derived)(cast(void*)p - 16);
assert(p.x == 4 || p.x == 7);
assert(p.y == 5 || p.y == 8);
return 3;
}
int Method() { return 6; }
}
Derived cppfoo(Derived);
Interface cppfooi(Interface);
}
void test15579()
{
Derived d = new Derived();
printf("d = %p\n", d);
assert(d.x == 4);
assert(d.y == 5);
assert((cast(Interface)d).MethodCPP() == 30);
assert((cast(Interface)d).MethodD() == 3);
assert(d.MethodCPP() == 30);
assert(d.MethodD() == 3);
assert(d.Method() == 6);
d = cppfoo(d);
assert(d.x == 7);
assert(d.y == 8);
printf("d2 = %p\n", d);
/* Casting to an interface involves thunks in the vtbl[].
* g++ puts the thunks for MethodD in the same COMDAT as MethodD.
* But D doesn't, so when the linker "picks one" of the D generated MethodD
* or the g++ generated MethodD, it may wind up with a messed up thunk,
* resulting in a seg fault. The solution is to not expect objects of the same
* type to be constructed on both sides of the D/C++ divide if the same member
* function (in this case, MethodD) is also defined on both sides.
*/
version (Windows)
{
assert((cast(Interface)d).MethodD() == 3);
}
assert((cast(Interface)d).MethodCPP() == 30);
assert(d.Method() == 6);
printf("d = %p, i = %p\n", d, cast(Interface)d);
version (Windows)
{
Interface i = cppfooi(d);
printf("i2: %p\n", i);
assert(i.MethodD() == 3);
assert(i.MethodCPP() == 30);
}
printf("test15579() done\n");
}
/****************************************/
// 15610
extern(C++) class Base2
{
int i;
void baser() { }
}
extern(C++) interface Interface2 { abstract void f(); }
extern(C++) class Derived2 : Base2, Interface2
{
final
override void f();
}
void test15610()
{
auto c = new Derived2();
printf("test15610(): c = %p\n", c);
c.i = 3;
c.f();
}
/******************************************/
// 15455
struct X6
{
ushort a;
ushort b;
ubyte c;
ubyte d;
}
static assert(X6.sizeof == 6);
struct X8
{
ushort a;
X6 b;
}
static assert(X8.sizeof == 8);
void test15455a(X8 s)
{
assert(s.a == 1);
assert(s.b.a == 2);
assert(s.b.b == 3);
assert(s.b.c == 4);
assert(s.b.d == 5);
}
extern (C++) void test15455b(X8 s);
void test15455()
{
X8 s;
s.a = 1;
s.b.a = 2;
s.b.b = 3;
s.b.c = 4;
s.b.d = 5;
test15455a(s);
test15455b(s);
}
/****************************************/
// 15372
extern(C++) int foo15372(T)(T v);
void test15372()
{
version(Windows){}
else
assert(foo15372!int(1) == 1);
}
/****************************************/
// 15802
extern(C++) {
template Foo15802(T) {
static int boo(T v);
}
}
void test15802()
{
version(Windows){}
else
assert(Foo15802!(int).boo(1) == 1);
}
/****************************************/
// 16536 - mangling mismatch on OSX
version(OSX) extern(C++) ulong pass16536(ulong);
void test16536()
{
version(OSX) assert(pass16536(123) == 123);
}
/****************************************/
void main()
{
test1();
test2();
test3();
test4();
test13956();
test5();
test6();
test10071();
test7();
test8();
test11802();
test9();
test10();
test13955();
test11();
testvalist();
test12825();
test13161();
test14();
test13289();
test15();
test16();
func13707();
func13932(S13932!(-1)(0));
foo13337(S13337());
test14195();
test14200();
test14956(S14956());
testVtable();
fuzz();
testeh();
testeh2();
testeh3();
test15576();
test15579();
test15610();
test15455();
test15372();
test15802();
test16536();
printf("Success\n");
}
|
D
|
/*
Boost Software License - Version 1.0 - August 17th, 2003
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 derelict.purple.sound;
import derelict.glib.gtypes;
import derelict.glib.glibconfig;
import derelict.purple.account;
extern (C):
alias _PurpleSoundEventID PurpleSoundEventID;
alias _PurpleSoundUiOps PurpleSoundUiOps;
enum _PurpleSoundEventID
{
PURPLE_SOUND_BUDDY_ARRIVE = 0,
PURPLE_SOUND_BUDDY_LEAVE = 1,
PURPLE_SOUND_RECEIVE = 2,
PURPLE_SOUND_FIRST_RECEIVE = 3,
PURPLE_SOUND_SEND = 4,
PURPLE_SOUND_CHAT_JOIN = 5,
PURPLE_SOUND_CHAT_LEAVE = 6,
PURPLE_SOUND_CHAT_YOU_SAY = 7,
PURPLE_SOUND_CHAT_SAY = 8,
PURPLE_SOUND_POUNCE_DEFAULT = 9,
PURPLE_SOUND_CHAT_NICK = 10,
PURPLE_SOUND_GOT_ATTENTION = 11,
PURPLE_NUM_SOUNDS = 12
}
struct _PurpleSoundUiOps
{
void function () init;
void function () uninit;
void function (const(char)*) play_file;
void function (PurpleSoundEventID) play_event;
void function () _purple_reserved1;
void function () _purple_reserved2;
void function () _purple_reserved3;
void function () _purple_reserved4;
}
version(Derelict_Link_Static)
{
extern( C ) nothrow
{
void purple_sound_play_file(const(char)* filename, const(PurpleAccount)* account);
void purple_sound_play_event(PurpleSoundEventID event, const(PurpleAccount)* account);
void purple_sound_set_ui_ops(PurpleSoundUiOps* ops);
PurpleSoundUiOps* purple_sound_get_ui_ops();
void purple_sound_init();
void purple_sound_uninit();
void* purple_sounds_get_handle();
}
}
else
{
extern( C ) nothrow
{
alias da_purple_sound_play_file = void function(const(char)* filename, const(PurpleAccount)* account);
alias da_purple_sound_play_event = void function(PurpleSoundEventID event, const(PurpleAccount)* account);
alias da_purple_sound_set_ui_ops = void function(PurpleSoundUiOps* ops);
alias da_purple_sound_get_ui_ops = PurpleSoundUiOps* function();
alias da_purple_sound_init = void function();
alias da_purple_sound_uninit = void function();
alias da_purple_sounds_get_handle = void* function();
}
__gshared
{
da_purple_sound_play_file purple_sound_play_file;
da_purple_sound_play_event purple_sound_play_event;
da_purple_sound_set_ui_ops purple_sound_set_ui_ops;
da_purple_sound_get_ui_ops purple_sound_get_ui_ops;
da_purple_sound_init purple_sound_init;
da_purple_sound_uninit purple_sound_uninit;
da_purple_sounds_get_handle purple_sounds_get_handle;
}
}
|
D
|
/*
* Stack-less Just-In-Time compiler
*
* Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) 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 HOLDER(S) 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.
*/
module sljitExecAllocator;
import sljitConfigInternal;
import sljitUtils;
extern(C):
/*
This file contains a simple executable memory allocator
It is assumed, that executable code blocks are usually medium (or sometimes
large) memory blocks, and the allocator is not too frequently called (less
optimized than other allocators). Thus, using it as a generic allocator is
not suggested.
How does it work:
Memory is allocated in continuous memory areas called chunks by alloc_chunk()
Chunk format:
[ block ][ block ] ... [ block ][ block terminator ]
All blocks and the block terminator is started with block_header. The block
header contains the size of the previous and the next block. These sizes
can also contain special values.
Block size:
0 - The block is a free_block, with a different size member.
1 - The block is a block terminator.
n - The block is used at the moment, and the value contains its size.
Previous block size:
0 - This is the first block of the memory chunk.
n - The size of the previous block.
Using these size values we can go forward or backward on the block chain.
The unused blocks are stored in a chain list pointed by free_blocks. This
list is useful if we need to find a suitable memory area when the allocator
is called.
When a block is freed, the new free block is connected to its adjacent free
blocks if possible.
[ free block ][ used block ][ free block ]
and "used block" is freed, the three blocks are connected together:
[ one big free block ]
*/
/* --------------------------------------------------------------------- */
/* System (OS) functions */
/* --------------------------------------------------------------------- */
/* 64 KByte. */
enum CHUNK_SIZE = 0x10000;
/*
alloc_chunk / free_chunk :
* allocate executable system memory chunks
* the size is always divisible by CHUNK_SIZE
allocator_grab_lock / allocator_release_lock :
* make the allocator thread safe
* can be empty if the OS (or the application) does not support threading
* only the allocator requires this lock, sljit is fully thread safe
as it only uses local variables
*/
version(Windows) {
void* alloc_chunk(sljit_uw size)
{
import core.sys.windows.windows : VirtualAlloc, MEM_COMMIT, MEM_RESERVE, PAGE_EXECUTE_READWRITE;
return VirtualAlloc(null, size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
}
void free_chunk(void* chunk, sljit_uw size)
{
import core.sys.windows.windows : VirtualFree, MEM_RELEASE;
VirtualFree(chunk, 0, MEM_RELEASE);
}
} else {
void* alloc_chunk(sljit_uw size)
{
import core.sys.posix.sys.mman;
void* retval;
if (dev_zero < 0) {
if (open_dev_zero())
return null;
}
retval = mmap(null, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, dev_zero, 0);
return (retval != MAP_FAILED) ? retval : null;
}
void free_chunk(void* chunk, sljit_uw size)
{
munmap(chunk, size);
}
}
/* --------------------------------------------------------------------- */
/* Common functions */
/* --------------------------------------------------------------------- */
enum CHUNK_MASK = ~(CHUNK_SIZE - 1);
struct block_header {
sljit_uw size;
sljit_uw prev_size;
}
struct free_block {
block_header header;
free_block *next;
free_block *prev;
sljit_uw size;
}
block_header* AS_BLOCK_HEADER(void* base, sljit_uw offset) {
return cast(block_header*)((cast(sljit_ub*)base) + offset);
}
free_block* AS_FREE_BLOCK(void* base, sljit_uw offset) {
return cast(free_block*)((cast(sljit_ub*)base) + offset);
}
void* MEM_START(void* base) {
return cast(void*)((cast(sljit_ub*)base)+block_header.sizeof);
}
sljit_uw ALIGN_SIZE(sljit_uw size) {
return (size + block_header.sizeof + 7) & ~7;
}
static __gshared {
free_block* free_blocks;
sljit_uw allocated_size;
sljit_uw total_size;
}
void sljit_insert_free_block(free_block *free_block, sljit_uw size)
{
free_block.header.size = 0;
free_block.size = size;
free_block.next = free_blocks;
free_block.prev = null;
if (free_blocks)
free_blocks.prev = free_block;
free_blocks = free_block;
}
void sljit_remove_free_block(free_block *free_block)
{
if (free_block.next)
free_block.next.prev = free_block.prev;
if (free_block.prev)
free_block.prev.next = free_block.next;
else {
SLJIT_ASSERT(free_blocks == free_block);
free_blocks = free_block.next;
}
}
void* sljit_malloc_exec(sljit_uw size)
{
block_header *header;
block_header *next_header;
free_block *free_block;
sljit_uw chunk_size;
allocator_grab_lock();
if (size < free_block.sizeof)
size = free_block.sizeof;
size = ALIGN_SIZE(size);
free_block = free_blocks;
while (free_block) {
if (free_block.size >= size) {
chunk_size = free_block.size;
if (chunk_size > size + 64) {
/* We just cut a block from the end of the free block. */
chunk_size -= size;
free_block.size = chunk_size;
header = AS_BLOCK_HEADER(free_block, chunk_size);
header.prev_size = chunk_size;
AS_BLOCK_HEADER(header, size).prev_size = size;
}
else {
sljit_remove_free_block(free_block);
header = cast(block_header*)free_block;
size = chunk_size;
}
allocated_size += size;
header.size = size;
allocator_release_lock();
return MEM_START(header);
}
free_block = free_block.next;
}
chunk_size = (size + block_header.sizeof + CHUNK_SIZE - 1) & CHUNK_MASK;
header = cast(block_header*)alloc_chunk(chunk_size);
if (!header) {
allocator_release_lock();
return null;
}
chunk_size -= block_header.sizeof;
total_size += chunk_size;
header.prev_size = 0;
if (chunk_size > size + 64) {
/* Cut the allocated space into a free and a used block. */
allocated_size += size;
header.size = size;
chunk_size -= size;
free_block = AS_FREE_BLOCK(header, size);
free_block.header.prev_size = size;
sljit_insert_free_block(free_block, chunk_size);
next_header = AS_BLOCK_HEADER(free_block, chunk_size);
}
else {
/* All space belongs to this allocation. */
allocated_size += chunk_size;
header.size = chunk_size;
next_header = AS_BLOCK_HEADER(header, chunk_size);
}
next_header.size = 1;
next_header.prev_size = chunk_size;
allocator_release_lock();
return MEM_START(header);
}
void sljit_free_exec(void* ptr)
{
block_header *header;
free_block* free_block_v;
allocator_grab_lock();
header = AS_BLOCK_HEADER(ptr, -cast(sljit_sw)block_header.sizeof);
allocated_size -= header.size;
/* Connecting free blocks together if possible. */
/* If header.prev_size == 0, free_block will equal to header.
In this case, free_block.header.size will be > 0. */
free_block_v = AS_FREE_BLOCK(header, -cast(sljit_sw)header.prev_size);
if (SLJIT_UNLIKELY(!free_block_v.header.size)) {
free_block_v.size += header.size;
header = AS_BLOCK_HEADER(free_block_v, free_block_v.size);
header.prev_size = free_block_v.size;
}
else {
free_block_v = cast(free_block*)header;
sljit_insert_free_block(free_block_v, header.size);
}
header = AS_BLOCK_HEADER(free_block_v, free_block_v.size);
if (SLJIT_UNLIKELY(!header.size)) {
free_block_v.size += (cast(free_block*)header).size;
sljit_remove_free_block(cast(free_block*)header);
header = AS_BLOCK_HEADER(free_block_v, free_block_v.size);
header.prev_size = free_block_v.size;
}
/* The whole chunk is free. */
if (SLJIT_UNLIKELY(!free_block_v.header.prev_size && header.size == 1)) {
/* If this block is freed, we still have (allocated_size / 2) free space. */
if (total_size - free_block_v.size > (allocated_size * 3 / 2)) {
total_size -= free_block_v.size;
sljit_remove_free_block(free_block_v);
free_chunk(free_block_v, free_block_v.size + block_header.sizeof);
}
}
allocator_release_lock();
}
void sljit_free_unused_memory_exec()
{
free_block* free_block_v;
free_block* next_free_block;
allocator_grab_lock();
free_block_v = free_blocks;
while (free_block_v) {
next_free_block = free_block_v.next;
if (!free_block_v.header.prev_size &&
AS_BLOCK_HEADER(free_block_v, free_block_v.size).size == 1) {
total_size -= free_block_v.size;
sljit_remove_free_block(free_block_v);
free_chunk(free_block_v, free_block_v.size + block_header.sizeof);
}
free_block_v = next_free_block;
}
SLJIT_ASSERT((total_size && free_blocks) || (!total_size && !free_blocks));
allocator_release_lock();
}
|
D
|
module views.mainView;
import std.stdio;
import std.conv;
import gtk.Alignment;
import gtk.Button;
import gtk.CellRendererToggle;
import gtk.Label;
import gtk.Main;
import gtk.SpinButton;
import gtk.TreeIter;
import gtk.TreePath;
import gtk.TreeSelection;
import gtk.TreeStore;
import gtk.ListStore;
import gtk.TreeView;
import gtk.TreeViewColumn;
import gtk.Widget;
import gdk.Event;
// These are necessary for the implicit conversion functions needed to
// be able to convert them to type "Widget" so they can be dynamically
// added to containers (ie currentSidePaneView). If you remove them,
// it will cease to function. It needs the top level widget for each
// view added in to alignmentSidePane
import gtk.Grid;
import gobject.Type;
import utility.accessorTemplate;
import utility.debugPrint;
import controllers.mainController;
import models.masterList;
import models.traits.armyCharacteristic;
import views.genericView;
/**
* Constant string which is the name of our UI description file.
*/
immutable string WIDGET_RESOURCE = "mainView.glade";
/**
* Constant string which is the name of our parent window
*/
immutable string WIDGET_NAME = "mainWindow";
/**
* Template to emit code to hook a spin button to a callback function
*
* @param buttonName name of the button
*/
template hookSpinButton(string buttonName) {
const char[] hookSpinButton = "
SpinButton "~buttonName~" = cast(SpinButton)builder.getObject(
\""~buttonName~"\");
if("~buttonName~" is null) {
writefln(\"Unable to get button: "~buttonName~"\");
retVal = 1;
}
else {
"~buttonName~".addOnValueChanged(&"~buttonName~"Changed);
}";
}
/**
* Generate a callback for the spin button.
*
* This callback will automatically update the given variable with
* the current value of the SpinButton
*
* @param variableName name of the base variable from which all things
* are derived.
*/
mixin template generateSpinButtonCallback(string variableName) {
mixin (
"private void sbArmy"~variableName~"Changed(SpinButton button) {
controller."~variableName~"Updated(button.getValueAsInt());
}"
);
}
/**
* Class to control the main view
*/
class mainView : genericView {
/**
* Reference to our controller
*
* This is used to inform our controller of updates
*/
mixin declarationAndProperties!("mainController", "controller");
/**
* Reference to the current side pane
*/
mixin declarationAndProperties!("Widget", "currentSidePaneView");
/**
* Reference to the label in the window which we want to update
* with the calculated army cost.
*/
mixin declarationAndProperties!("Label", "lblArmyBaseCost");
/**
* Callback passed to GTK to handle updates to the DEX spin button
*/
mixin generateSpinButtonCallback!("DEX");
/**
* Callback passed to GTK to handle updates to the STR spin button
*/
mixin generateSpinButtonCallback!("STR");
/**
* Callback passed to GTK to handle updates to the CON spin button
*/
mixin generateSpinButtonCallback!("CON");
/**
* Callback passed to GTK to handle updates to the TEK spin button
*/
mixin generateSpinButtonCallback!("TEK");
/**
* Callback passed to GTK to handle updates to the MOR spin button
*/
mixin generateSpinButtonCallback!("MOR");
/**
* Callback passed to GTK to handle updates to the PRE spin button
*/
mixin generateSpinButtonCallback!("PRE");
/**
* Initializing constructor
*
* @param controller the controller to which callbacks should be
* directed.
*/
this(mainController controller) {
this.controller = controller;
currentSidePaneView = null;
}
/**
* Initialization function
*
* This function must be called before calling any other functions
*
* @param args arguments passed on the command line
*
* @return true on success
* @return false on failure
*/
bool init(string[] args) {
// IMPORTANT: Main.init needs to be called before Builder is
// created.
bool retVal = true;
string gladeString = import(WIDGET_RESOURCE);
Main.init(args);
if (!super.init(gladeString, WIDGET_RESOURCE, WIDGET_NAME)) {
retVal = false;
}
else {
widget.addOnDelete(
delegate bool (Event event, Widget aux) {
Main.quit();
// We return true here because this is the
// last handler - quit and we're
// done. Propagating to other handlers results
// in attempts to call hooks where thinks have
// already been freed, resulting in segfaults
// due to access of nonexistent resources.
return true;
}
);
lblArmyBaseCost = cast(Label)builder.getObject("lblArmyBaseCost");
if (lblArmyBaseCost is null) {
writefln("Unable to get label lblArmyBaseCost");
retVal = false;
}
mixin(hookSpinButton!("sbArmyDEX"));
mixin(hookSpinButton!("sbArmySTR"));
mixin(hookSpinButton!("sbArmyCON"));
mixin(hookSpinButton!("sbArmyTEK"));
mixin(hookSpinButton!("sbArmyMOR"));
mixin(hookSpinButton!("sbArmyPRE"));
// Initial list population
tsArmyPopulate();
TreeView tvArmy = cast(TreeView)builder.getObject("tvArmy");
if (tvArmy is null) {
writefln("Unable to get tree view tvArmy");
}
else {
tvArmy.addOnCursorChanged(
delegate void (TreeView treeView) {
controller.tvArmyUpdated();
}
);
// Set it to a single selection "browse" mode
TreeSelection selection = tvArmy.getSelection();
selection.setMode(GtkSelectionMode.BROWSE);
}
}
return retVal;
}
/**
* Get the current selection for tvArmy
*
* @return the selection as a path string - a series of integer
* indices (0 based) separated by commas. So, 2,4 is the
* fifth child of the third node
* @return null if error or nothing selected
*/
string tvArmyGetSelection() {
string retVal = null;
TreeView tvArmy = cast(TreeView)builder.getObject("tvArmy");
if (tvArmy is null) {
writefln("Unable to get tree view tvArmy");
}
else {
TreePath path = new TreePath();
TreeViewColumn column = new TreeViewColumn();
tvArmy.getCursor(path, column);
retVal = path.toString();
}
return retVal;
}
/**
* Update the army base cost label
*
* @param value Value to which the label should be set.
*/
void armyBaseCostUpdate(int value) {
lblArmyBaseCost.setText(to!string(value));
}
/**
* Show the view and run the main GTK message pump.
*/
void run() {
widget.showAll();
Main.run();
}
/**
* Populate the army TreeStore from the master list
*
* @param list the master list or null if you just want to
* populate the list "headers".
*/
void tsArmyPopulate(masterList list = null) {
TreeStore tsArmy = cast(TreeStore)builder.getObject("tsArmy");
if (tsArmy is null) {
writefln("Unable to get tree store tsArmy");
}
else {
// Destroy the store first
tsArmy.clear();
// Then rebuild
// Iterators used to keep track of column "headers" - top
// level expandoflyout doodads
TreeIter iterBasicUnits;
TreeIter iterEliteUnits;
TreeIter iterSupportUnits;
TreeIter iterArmors;
TreeIter iterRangedWeapons;
TreeIter iterMeleeWeapons;
// Add the top level headers
iterBasicUnits = tsArmy.append(null);
tsArmy.setValue(iterBasicUnits, 0, "Basic Units");
iterEliteUnits = tsArmy.append(null);
tsArmy.setValue(iterEliteUnits, 0, "Elite Units");
iterBasicUnits = tsArmy.append(null);
tsArmy.setValue(iterBasicUnits, 0, "Support Units");
iterArmors = tsArmy.append(null);
tsArmy.setValue(iterArmors, 0, "Armors");
iterRangedWeapons = tsArmy.append(null);
tsArmy.setValue(iterRangedWeapons, 0, "Ranged Weapons");
iterMeleeWeapons = tsArmy.append(null);
tsArmy.setValue(iterMeleeWeapons, 0, "Melee Weapons");
if (list !is null) {
writefln("TODO populate things\n");
}
}
}
/**
* Replace the current side pane with the the given one
*
* @param newView view to add in
*
*/
void replaceSidePane(Widget newView) {
if (currentSidePaneView is null) {
// we're replacing the default "replace me" one
currentSidePaneView = cast(Widget)builder.getObject(
"gridReplaceMe");
}
if (currentSidePaneView is null) {
writefln("currentSidePaneView is null (and shouldn't be)");
}
else {
Alignment alignmentSidePane = cast(Alignment)builder.getObject(
"alignmentSidePane");
if (alignmentSidePane is null) {
writefln("Unable to get alignment alignmentSidePane");
}
else {
alignmentSidePane.remove(currentSidePaneView);
currentSidePaneView = newView;
alignmentSidePane.add(currentSidePaneView);
}
}
}
/**
* Populate the list store of characteristics
*
* @param traits list of characteristics to put into the list store
*/
// FIXME - this is nearly identical to armorView's
// lsTraitPopulate. Likely a candidate for a mixin.
void lsCharacteristicPopulate(
armyCharacteristic[] characteristics = null) {
ListStore lsCharacteristics = cast(ListStore)builder.getObject(
"lsCharacteristics");
if (lsCharacteristics is null) {
writefln("Unable to get list store lsCharacteristics");
}
else {
// Destroy the store first
lsCharacteristics.clear();
TreeIter iterator = new TreeIter();
// Then rebuild
if (characteristics !is null) {
foreach (armyCharacteristic characteristic; characteristics) {
writefln("Set value to %s", characteristic.name);
lsCharacteristics.append(iterator);
// Column 1 is the name
lsCharacteristics.setValue(iterator, 1,
characteristic.name);
}
}
CellRendererToggle toggle =
cast(CellRendererToggle)builder.getObject(
"toggleArmyCharacteristic");
if (toggle is null) {
writefln("Unable to get toggle toggleArmyCharacteristic");
}
else {
toggle.addOnToggled(&controller.onToggleArmyCharacteristic);
}
}
}
/**
* Toggle the armor trait setting
*
* @param path The tree path of the selection which was toggled
* @param value The value to which the selection is to be set
*/
// FIXME - this is nearly identical to armorView's
// toggleArmorTrait. Mixin?
void toggleArmyCharacteristic(string path, bool value) {
ListStore lsCharacteristics = cast(ListStore)builder.getObject(
"lsCharacteristics");
if (lsCharacteristics is null) {
writefln("Unable to get list store lsCharacteristics");
}
else {
TreeIter iterator = new TreeIter();
lsCharacteristics.getIterFromString(iterator, path);
if (iterator is null) {
writefln("Unable to get iterator for path %s", path);
}
else {
lsCharacteristics.setValue(iterator, 0, value);
}
}
}
/**
* Stub satisfy abstract base class
*
* @return true, always
*/
override bool build() {
return true;
}
}
|
D
|
<?xml version="1.0" encoding="ASCII" standalone="no"?>
<di:SashWindowsMngr xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmi:version="2.0">
<pageList>
<availablePage>
<emfPageIdentifier href="VAR_3_BeT-3291647214.notation#_copSALmGEeKQQp7P9cQvNQ"/>
</availablePage>
</pageList>
<sashModel currentSelection="//@sashModel/@windows.0/@children.0">
<windows>
<children xsi:type="di:TabFolder">
<children>
<emfPageIdentifier href="VAR_3_BeT-3291647214.notation#_copSALmGEeKQQp7P9cQvNQ"/>
</children>
</children>
</windows>
</sashModel>
</di:SashWindowsMngr>
|
D
|
// generated by fakerjsgenerator
///
module faked.faker_zu_za;
import faked.base;
///
class Faker_zu_za : Faker {
@safe:
import std.random;
import std.array;
import std.format;
import std.conv : to;
///
this(int seed) {
super(seed);
}
///
override string phoneNumberFormats() {
auto data = [
"01# ### #####",
"02# ### #####",
"03# ### #####",
"04# ### #####",
"05# ### #####",
"0800 ### ###",
"0860 ### ###",
"01#########",
"01# ########"
];
return this.digitBuild(choice(data, this.rnd));
}
///
override string cellPhoneFormats() {
auto data = [
"082 ### ####",
"084 ### ####",
"083 ### ####",
"065 ### ####",
"082#######",
"082 #######"
];
return this.digitBuild(choice(data, this.rnd));
}
///
override string companySuffix() {
auto data = [
"Pty Ltd",
"Ltd",
"CC'"
];
return choice(data, this.rnd);
}
///
override string internetDomainSuffix() {
auto data = [
"co.za",
"com",
"org.za",
"info",
"net.za'"
];
return choice(data, this.rnd);
}
///
override string addressPostcode() {
auto data = [
"#####",
"####'"
];
return this.digitBuild(choice(data, this.rnd));
}
override string addressCity() {
final switch(uniform(0, 4, this.rnd)) {
case 0: return addressCityPrefix() ~ " " ~ nameFirstName() ~ addressCitySuffix();
case 1: return addressCityPrefix() ~ " " ~ nameFirstName();
case 2: return nameFirstName() ~ addressCitySuffix();
case 3: return nameLastName() ~ addressCitySuffix();
}
}
///
override string addressDefaultCountry() {
auto data = [
"South Africa'"
];
return choice(data, this.rnd);
}
override string addressStreet() {
final switch(uniform(0, 2, this.rnd)) {
case 0: return nameFirstName() ~ " " ~ addressStreetSuffix();
case 1: return nameLastName() ~ " " ~ addressStreetSuffix();
}
}
///
override string nameLastName() {
auto data = [
"Bengu",
"Bhengu",
"Buthelezi",
"Bhuyeni",
"Bhembe",
"Bhengani",
"Bayeni",
"Chiliza",
"Cele",
"Cebekhulu",
"Dingiswayo",
"Dlamini",
"Dube",
"Fuze",
"Gwacela",
"Gigaba",
"Gumede",
"Guliwe",
"Gwala",
"Gama",
"Gumede",
"Hlongwa",
"Luthuli",
"Msibi",
"Mthethwa",
"Mashinini",
"Ndebele",
"Ngubane",
"Nondlela",
"Nzimande",
"Radebe",
"Seme",
"Senzangakhona",
"Sondisa",
"Zuma",
"Dhlomo",
"Nhleko",
"Mabizela",
"Khumalo",
"Kunene",
"Khawula",
"Khuzwayo",
"Lamula",
"Lembede",
"Lamula",
"Mkhatshwa",
"Moseley",
"Mavundla",
"Magoza",
"Malinga",
"Mbatha",
"Mqwebu",
"Mbende",
"Maduma",
"Mgenge",
"Mehloluhlaza",
"Maphisa",
"Mfeka",
"Mfumu",
"Musi",
"Mtolo",
"Nonyana",
"Ngema",
"Ngwazi",
"Nozulu",
"Ntombela",
"Ntanzi",
"Mbuso",
"Ngcolosi",
"Gabhezi",
"Nsele",
"Nyanda",
"Thusi",
"Mbatha",
"Biyela",
"Gumede",
"Nomvethe",
"Ndandali",
"Ncusi",
"Sibiya",
"Siyaya",
"Sothole",
"Sokhela",
"Sithuli",
"Shezi",
"Siwele",
"Tshabalala",
"Thoyana",
"Thumbeza",
"Delazy",
"Zungu",
"Mthembu",
"Vilakazi",
"Vezi",
"Mabhida",
"Wosiyane",
"Yengwa",
"Zondo",
"Zondi",
"Zubane"
];
return choice(data, this.rnd);
}
///
override string nameFirstName() {
auto data = [
"Ayanda",
"Uluthando",
"Nofoto",
"Yibanathi",
"Thadie",
"Ulwazi",
"Lerato",
"Amahle",
"Khulekani",
"Jabulile",
"Mthunzi",
"Sindisiwe",
"Inyoni",
"Ntombizodwa",
"Zobuhle",
"Samukelisiwe",
"Nonhlanhla",
"Nhlakanipho",
"Liyana",
"Nonjabulo",
"Ntokozo",
"Nokuthula",
"Buhle",
"Isisa",
"Thobeka",
"Thabisa",
"Zanele",
"Sizani",
"Nkosingiphile",
"Mhambi",
"Nomvula",
"Thulisile",
"Lukhona",
"Mbalienhle",
"Sizakele",
"Khethiwe",
"Nolwazi",
"Sinenhlanhla",
"Ayize",
"Duduzile",
"Busisiwe",
"Hlengiwe",
"Jabulile",
"Khanyisile",
"Nandi",
"Ndondoloza",
"Nozipho",
"Nonkululeko",
"Sibongile",
"Siphephelo",
"Bonginkosi",
"Kagiso",
"Bhekizizwe",
"Bhekumbuso",
"Shaka",
"Funani",
"Kgabu",
"Solomon",
"Gatsha",
"Langa",
"Phila",
"Msizi",
"Nkosiyabo",
"Linda",
"Mpilo",
"Siyanda",
"Nkanyezi",
"Bafana",
"Lwandle",
"Sfiso",
"Thulani",
"Thando",
"Sanele",
"Anele",
"Lungelo",
"Dumisani",
"Bangizwe",
"Fanyana",
"Bhekimuzi",
"Mandla",
"Maphikelela",
"Mpumelelo",
"Mthunzi",
"Philani",
"Musawenkosi",
"Nkosenye",
"Nkosinhle",
"Phiwokwakhe",
"Sifiso",
"Zithulele",
"Sithembiso",
"Sipho",
"Siphiwe",
"Sibusiso",
"Velaphi",
"Thamsanqa",
"Vusumuzi",
"Themba",
"Zenzele",
"Ndleleni"
];
return choice(data, this.rnd);
}
///
override string nameMaleFirstName() {
auto data = [
"Bonginkosi",
"Kagiso",
"Bhekizizwe",
"Bhekumbuso",
"Shaka",
"Funani",
"Kgabu",
"Solomon",
"Gatsha",
"Langa",
"Phila",
"Msizi",
"Nkosiyabo",
"Linda",
"Mpilo",
"Siyanda",
"Nkanyezi",
"Bafana",
"Lwandle",
"Sfiso",
"Thulani",
"Thando",
"Sanele",
"Anele",
"Lungelo",
"Dumisani",
"Bangizwe",
"Fanyana",
"Bhekimuzi",
"Mandla",
"Maphikelela",
"Mpumelelo",
"Mthunzi",
"Philani",
"Musawenkosi",
"Nkosenye",
"Nkosinhle",
"Phiwokwakhe",
"Sifiso",
"Zithulele",
"Sithembiso",
"Sipho",
"Siphiwe",
"Sibusiso",
"Velaphi",
"Thamsanqa",
"Vusumuzi",
"Themba",
"Zenzele",
"Ndleleni"
];
return choice(data, this.rnd);
}
///
override string nameFemaleFirstName() {
auto data = [
"Ayanda",
"Uluthando",
"Nofoto",
"Yibanathi",
"Thadie",
"Ulwazi",
"Lerato",
"Amahle",
"Khulekani",
"Jabulile",
"Mthunzi",
"Sindisiwe",
"Inyoni",
"Ntombizodwa",
"Zobuhle",
"Samukelisiwe",
"Nonhlanhla",
"Nhlakanipho",
"Liyana",
"Nonjabulo",
"Ntokozo",
"Nokuthula",
"Buhle",
"Isisa",
"Thobeka",
"Thabisa",
"Zanele",
"Sizani",
"Nkosingiphile",
"Mhambi",
"Nomvula",
"Thulisile",
"Lukhona",
"Mbalienhle",
"Sizakele",
"Khethiwe",
"Nolwazi",
"Sinenhlanhla",
"Ayize",
"Duduzile",
"Busisiwe",
"Hlengiwe",
"Jabulile",
"Khanyisile",
"Nandi",
"Ndondoloza",
"Nozipho",
"Nonkululeko",
"Sibongile",
"Siphephelo"
];
return choice(data, this.rnd);
}
}
|
D
|
module UnrealScript.TribesGame.TrAttachment_ArmoredClaymore;
import ScriptClasses;
import UnrealScript.Helpers;
import UnrealScript.TribesGame.TrDeviceAttachment;
extern(C++) interface TrAttachment_ArmoredClaymore : TrDeviceAttachment
{
public extern(D):
private static __gshared ScriptClass mStaticClass;
@property final static ScriptClass StaticClass() { mixin(MGSCC("Class TribesGame.TrAttachment_ArmoredClaymore")); }
private static __gshared TrAttachment_ArmoredClaymore mDefaultProperties;
@property final static TrAttachment_ArmoredClaymore DefaultProperties() { mixin(MGDPC("TrAttachment_ArmoredClaymore", "TrAttachment_ArmoredClaymore TribesGame.Default__TrAttachment_ArmoredClaymore")); }
}
|
D
|
/Users/GMoran/Desktop/ClassicPlayer/DerivedData/ClassicPlayer/Build/Intermediates/IBDesignables/Intermediates/ClassicPlayer.build/Debug-iphonesimulator/ClassicPlayer.build/Objects-normal/x86_64/SettingsVC.o : /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/NowPlayingVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/AboutScreenVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/SettingsVC.swift /Users/GMoran/Desktop/ClassicPlayer/AboutVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/MusicMenuVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/MainMenuVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/AlbumsMenuVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/PlaylistsMenuVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/ArtistsMenuVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/SongListMenuVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/Array+Shuffle.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/AppDelegate.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/C2AClickWheel.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/ImageTableCell.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/SettingsTableCell.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/MenuTableCell.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/ViewController.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/SettingsScreenViewController.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/StatusBarViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.apinotesc /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/Foundation.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/AVFoundation.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/MediaPlayer.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreText.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/AudioToolbox.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/CoreMedia.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/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/AVFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreAudio.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/GMoran/Desktop/ClassicPlayer/DerivedData/ClassicPlayer/Build/Intermediates/IBDesignables/Intermediates/ClassicPlayer.build/Debug-iphonesimulator/ClassicPlayer.build/Objects-normal/x86_64/SettingsVC~partial.swiftmodule : /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/NowPlayingVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/AboutScreenVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/SettingsVC.swift /Users/GMoran/Desktop/ClassicPlayer/AboutVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/MusicMenuVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/MainMenuVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/AlbumsMenuVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/PlaylistsMenuVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/ArtistsMenuVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/SongListMenuVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/Array+Shuffle.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/AppDelegate.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/C2AClickWheel.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/ImageTableCell.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/SettingsTableCell.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/MenuTableCell.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/ViewController.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/SettingsScreenViewController.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/StatusBarViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.apinotesc /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/Foundation.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/AVFoundation.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/MediaPlayer.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreText.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/AudioToolbox.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/CoreMedia.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/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/AVFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreAudio.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/GMoran/Desktop/ClassicPlayer/DerivedData/ClassicPlayer/Build/Intermediates/IBDesignables/Intermediates/ClassicPlayer.build/Debug-iphonesimulator/ClassicPlayer.build/Objects-normal/x86_64/SettingsVC~partial.swiftdoc : /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/NowPlayingVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/AboutScreenVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/SettingsVC.swift /Users/GMoran/Desktop/ClassicPlayer/AboutVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/MusicMenuVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/MainMenuVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/AlbumsMenuVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/PlaylistsMenuVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/ArtistsMenuVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/SongListMenuVC.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/Array+Shuffle.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/AppDelegate.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/C2AClickWheel.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/ImageTableCell.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/SettingsTableCell.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/MenuTableCell.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/ViewController.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/SettingsScreenViewController.swift /Users/GMoran/Desktop/ClassicPlayer/ClassicPlayer/StatusBarViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.apinotesc /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/Foundation.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/AVFoundation.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/MediaPlayer.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreText.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/AudioToolbox.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/CoreMedia.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/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/AVFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreAudio.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
|
D
|
a division of some larger or more complex organization
a division of a stem, or secondary stem arising from the main stem of a plant
a part of a forked or branching shape
a natural consequence of development
a stream or river connected to a larger one
any projection that is thought to resemble a human arm
grow and send out branches or branch-like structures
divide into two or more branches so as to form a fork
|
D
|
/Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/.build/debug/FluentTester.build/Tester+Utilities.swift.o : /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Atom.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Compound.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Student.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Tester+InsertAndFind.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Tester+PivotsAndRelations.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Tester+Schema.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Tester+Utilities.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Tester.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/Fluent.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/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/FluentTester.build/Tester+Utilities~partial.swiftmodule : /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Atom.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Compound.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Student.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Tester+InsertAndFind.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Tester+PivotsAndRelations.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Tester+Schema.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Tester+Utilities.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Tester.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/Fluent.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/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/FluentTester.build/Tester+Utilities~partial.swiftdoc : /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Atom.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Compound.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Student.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Tester+InsertAndFind.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Tester+PivotsAndRelations.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Tester+Schema.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Tester+Utilities.swift /Users/okasho/serverProject/tryswift/get_post_patch_and_delate/swift/Packages/Fluent-1.4.1/Sources/FluentTester/Tester.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/Fluent.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/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
|
/** LEB128 (Little Endian Base 128).
See_Also: https://en.wikipedia.org/wiki/LEB128
See_Also: http://forum.dlang.org/post/ykskvwqdsxlyjispappj@forum.dlang.org
TODO Move to Phobos at std/experimental/codings/leb128.d
*/
module leb128;
import std.range : isOutputRange;
import std.traits : isUnsigned, isSigned;
import std.traits : Unqual;
/// Encode a LEB128-encoded value of signed integer type `SInt` to `os`.
void encodeLEB128(SInt, Output)(ref Output os, Unqual!SInt value)
if (isOutputRange!(Output, ubyte) &&
isSigned!SInt)
{
bool more = false;
do
{
ubyte byte_ = value & 0x7f;
// assumes that this signed shift is an arithmetic right shift
value >>= 7;
more = !(((value == 0 ) && ((byte_ & 0x40) == 0)) ||
((value == -1) && ((byte_ & 0x40) != 0)));
if (more)
byte_ |= 0x80; // mark this byte to show that more bytes will follow
os.put(byte_);
}
while (more);
}
/// Decode a LEB128-encoded value of signed integer type `SInt`.
SInt decodeLEB128(SInt)(ubyte *p, uint *n = null)
{
const ubyte *orig_p = p;
SInt value = 0;
uint shift = 0;
ubyte byte_;
do
{
byte_ = *p++;
value |= ((byte_ & 0x7f) << shift);
shift += 7;
} while (byte_ >= 128);
// sign extend negative numbers
if (byte_ & 0x40)
// TODO Unsigned!SInt
value |= (cast(ulong)-1) << shift; // value |= (-1ULL) << shift;
if (n)
*n = cast(uint)(p - orig_p);
return value;
}
version(unittest)
{
import dbgio : dln;
import std.algorithm.comparison : equal;
import std.array : Appender;
alias Raw = Appender!(ubyte[]);
// import array_ex : UniqueArray;
// alias Raw = UniqueArray!ubyte;
}
@safe pure nothrow unittest
{
alias SInt = long;
foreach (immutable i; 0 .. 64)
{
Raw os;
os.encodeLEB128!SInt(i);
assert(os.data.equal([i]));
// const value = os.data.decodeLEB128!SInt();
}
foreach (immutable i; 64 .. 128)
{
Raw os;
os.encodeLEB128!SInt(i);
assert(os.data.equal([128 + i, 0]));
}
}
/// Encode a ULEB128 value to `os`.
void encodeULEB128(UInt, Output)(ref Output os, Unqual!UInt value)
if (isOutputRange!(Output, ubyte) &&
isUnsigned!UInt)
{
do
{
ubyte byte_ = value & 0x7f;
value >>= 7;
if (value != 0)
byte_ |= 0x80; // mark this byte to show that more bytes will follow
os.put(char(byte_));
}
while (value != 0);
}
/// Decode a ULEB128 value.
ulong decodeULEB128(ubyte *p, uint *n = null)
{
const ubyte *orig_p = p;
ulong value = 0;
uint shift = 0;
do
{
value += ulong(*p & 0x7f) << shift;
shift += 7;
}
while (*p++ >= 128);
if (n)
*n = cast(uint)(p - orig_p);
return value;
}
@safe pure nothrow unittest
{
alias UInt = ulong;
foreach (immutable i; 0 .. 128)
{
Raw os;
os.encodeULEB128!UInt(i);
assert(os.data.equal([i]));
}
foreach (immutable i; 128 .. 256)
{
Raw os;
os.encodeULEB128!UInt(i);
assert(os.data.equal([i, 1]));
}
foreach (immutable i; 256 .. 256 + 128)
{
Raw os;
os.encodeULEB128!UInt(i);
assert(os.data.equal([i - 128, 2]));
}
foreach (immutable i; 256 + 128 .. 512)
{
Raw os;
os.encodeULEB128!UInt(i);
assert(os.data.equal([i - 256, 3]));
}
}
/** Encode a ULEB128 value to a buffer.
Returns: length in bytes of the encoded value.
*/
uint encodeULEB128(ulong value, ubyte *p)
{
ubyte *orig_p = p;
do
{
ubyte byte_ = value & 0x7f;
value >>= 7;
if (value != 0)
byte_ |= 0x80; // mark this byte to show that more bytes will follow
*p++ = byte_;
}
while (value != 0);
return cast(uint)(p - orig_p);
}
|
D
|
/substrate-node-template/target/release/wbuild-runner/node-template-runtime5682408938209815743/target/release/build/getrandom-180a6cd0a33dbd39/build_script_build-180a6cd0a33dbd39: /root/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.1.15/build.rs
/substrate-node-template/target/release/wbuild-runner/node-template-runtime5682408938209815743/target/release/build/getrandom-180a6cd0a33dbd39/build_script_build-180a6cd0a33dbd39.d: /root/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.1.15/build.rs
/root/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.1.15/build.rs:
|
D
|
/// Generate by tools
module java.net.Inet4Address;
import java.lang.exceptions;
public class Inet4Address
{
public this()
{
implMissing();
}
}
|
D
|
/Users/markmoussa/HackathonProjects/Rhabit/DerivedData/Rhabit/Build/Intermediates/Pods.build/Debug-iphonesimulator/Charts.build/Objects-normal/x86_64/LineRadarChartRenderer.o : /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BarChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BarChartDataEntry.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/BarChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Highlight/BarChartHighlighter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/BarChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/BarChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/BarLineChartViewBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BarLineScatterCandleBubbleChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/BarLineScatterCandleBubbleChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BubbleChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BubbleChartDataEntry.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/BubbleChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BubbleChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/BubbleChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/BubbleChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/CandleChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/CandleChartDataEntry.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/CandleChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/CandleChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/CandleStickChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/CandleStickChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Animation/ChartAnimationEasing.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Animation/ChartAnimator.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartAxisBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartAxisRendererBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/ChartBaseDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartColorTemplates.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartComponentBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/ChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Filters/ChartDataApproximatorFilter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Filters/ChartDataBaseFilter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/ChartDataEntry.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/ChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartDataRendererBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/ChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Formatters/ChartDefaultXAxisValueFormatter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartFill.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Formatters/ChartFillFormatter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Highlight/ChartHighlight.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Highlight/ChartHighlighter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartLegend.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartLegendRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartLimitLine.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartMarker.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Highlight/ChartRange.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartRendererBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartSelectionDetail.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartTransformer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartTransformerHorizontalBarChart.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartUtils.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/ChartViewBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartViewPortHandler.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartXAxis.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartXAxisRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartXAxisRendererBarChart.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartXAxisRendererHorizontalBarChart.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartXAxisRendererRadarChart.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Formatters/ChartXAxisValueFormatter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartYAxis.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartYAxisRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartYAxisRendererHorizontalBarChart.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartYAxisRendererRadarChart.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/CombinedChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/CombinedChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/CombinedChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Highlight/CombinedHighlighter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Highlight/HorizontalBarChartHighlighter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/HorizontalBarChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/HorizontalBarChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IBarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IBarLineScatterCandleBubbleChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IBubbleChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/ICandleChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/ILineChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/ILineRadarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/ILineScatterCandleRadarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IPieChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IRadarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IScatterChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/LineChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/LineChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/LineChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/LineChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/LineChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/LineRadarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/LineRadarChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/LineScatterCandleRadarChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/PieChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/PieChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/PieChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/PieChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/PieRadarChartViewBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/RadarChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/RadarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/RadarChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/RadarChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/ScatterChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/ScatterChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/ScatterChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ScatterChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/ScatterChartView.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Users/markmoussa/HackathonProjects/Rhabit/Pods/Target\ Support\ Files/Charts/Charts-umbrella.h /Users/markmoussa/HackathonProjects/Rhabit/DerivedData/Rhabit/Build/Intermediates/Pods.build/Debug-iphonesimulator/Charts.build/unextended-module.modulemap /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/Foundation.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/Dispatch.swiftmodule /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/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule
/Users/markmoussa/HackathonProjects/Rhabit/DerivedData/Rhabit/Build/Intermediates/Pods.build/Debug-iphonesimulator/Charts.build/Objects-normal/x86_64/LineRadarChartRenderer~partial.swiftmodule : /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BarChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BarChartDataEntry.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/BarChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Highlight/BarChartHighlighter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/BarChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/BarChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/BarLineChartViewBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BarLineScatterCandleBubbleChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/BarLineScatterCandleBubbleChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BubbleChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BubbleChartDataEntry.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/BubbleChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BubbleChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/BubbleChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/BubbleChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/CandleChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/CandleChartDataEntry.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/CandleChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/CandleChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/CandleStickChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/CandleStickChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Animation/ChartAnimationEasing.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Animation/ChartAnimator.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartAxisBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartAxisRendererBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/ChartBaseDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartColorTemplates.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartComponentBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/ChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Filters/ChartDataApproximatorFilter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Filters/ChartDataBaseFilter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/ChartDataEntry.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/ChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartDataRendererBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/ChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Formatters/ChartDefaultXAxisValueFormatter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartFill.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Formatters/ChartFillFormatter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Highlight/ChartHighlight.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Highlight/ChartHighlighter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartLegend.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartLegendRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartLimitLine.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartMarker.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Highlight/ChartRange.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartRendererBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartSelectionDetail.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartTransformer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartTransformerHorizontalBarChart.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartUtils.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/ChartViewBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartViewPortHandler.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartXAxis.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartXAxisRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartXAxisRendererBarChart.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartXAxisRendererHorizontalBarChart.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartXAxisRendererRadarChart.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Formatters/ChartXAxisValueFormatter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartYAxis.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartYAxisRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartYAxisRendererHorizontalBarChart.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartYAxisRendererRadarChart.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/CombinedChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/CombinedChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/CombinedChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Highlight/CombinedHighlighter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Highlight/HorizontalBarChartHighlighter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/HorizontalBarChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/HorizontalBarChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IBarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IBarLineScatterCandleBubbleChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IBubbleChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/ICandleChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/ILineChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/ILineRadarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/ILineScatterCandleRadarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IPieChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IRadarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IScatterChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/LineChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/LineChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/LineChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/LineChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/LineChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/LineRadarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/LineRadarChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/LineScatterCandleRadarChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/PieChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/PieChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/PieChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/PieChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/PieRadarChartViewBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/RadarChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/RadarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/RadarChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/RadarChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/ScatterChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/ScatterChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/ScatterChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ScatterChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/ScatterChartView.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Users/markmoussa/HackathonProjects/Rhabit/Pods/Target\ Support\ Files/Charts/Charts-umbrella.h /Users/markmoussa/HackathonProjects/Rhabit/DerivedData/Rhabit/Build/Intermediates/Pods.build/Debug-iphonesimulator/Charts.build/unextended-module.modulemap /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/Foundation.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/Dispatch.swiftmodule /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/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule
/Users/markmoussa/HackathonProjects/Rhabit/DerivedData/Rhabit/Build/Intermediates/Pods.build/Debug-iphonesimulator/Charts.build/Objects-normal/x86_64/LineRadarChartRenderer~partial.swiftdoc : /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BarChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BarChartDataEntry.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/BarChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Highlight/BarChartHighlighter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/BarChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/BarChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/BarLineChartViewBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BarLineScatterCandleBubbleChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/BarLineScatterCandleBubbleChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BubbleChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BubbleChartDataEntry.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/BubbleChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/BubbleChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/BubbleChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/BubbleChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/CandleChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/CandleChartDataEntry.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/CandleChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/CandleChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/CandleStickChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/CandleStickChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Animation/ChartAnimationEasing.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Animation/ChartAnimator.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartAxisBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartAxisRendererBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/ChartBaseDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartColorTemplates.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartComponentBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/ChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Filters/ChartDataApproximatorFilter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Filters/ChartDataBaseFilter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/ChartDataEntry.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/ChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartDataRendererBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/ChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Formatters/ChartDefaultXAxisValueFormatter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartFill.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Formatters/ChartFillFormatter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Highlight/ChartHighlight.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Highlight/ChartHighlighter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartLegend.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartLegendRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartLimitLine.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartMarker.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Highlight/ChartRange.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartRendererBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartSelectionDetail.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartTransformer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartTransformerHorizontalBarChart.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartUtils.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/ChartViewBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Utils/ChartViewPortHandler.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartXAxis.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartXAxisRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartXAxisRendererBarChart.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartXAxisRendererHorizontalBarChart.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartXAxisRendererRadarChart.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Formatters/ChartXAxisValueFormatter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Components/ChartYAxis.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartYAxisRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartYAxisRendererHorizontalBarChart.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ChartYAxisRendererRadarChart.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/CombinedChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/CombinedChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/CombinedChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Highlight/CombinedHighlighter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Highlight/HorizontalBarChartHighlighter.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/HorizontalBarChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/HorizontalBarChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IBarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IBarLineScatterCandleBubbleChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IBubbleChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/ICandleChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/ILineChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/ILineRadarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/ILineScatterCandleRadarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IPieChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IRadarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Interfaces/IScatterChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/LineChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/LineChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/LineChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/LineChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/LineChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/LineRadarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/LineRadarChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/LineScatterCandleRadarChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/PieChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/PieChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/PieChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/PieChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/PieRadarChartViewBase.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/RadarChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/RadarChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/RadarChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/RadarChartView.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/ScatterChartData.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Interfaces/ScatterChartDataProvider.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Data/Implementations/Standard/ScatterChartDataSet.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Renderers/ScatterChartRenderer.swift /Users/markmoussa/HackathonProjects/Rhabit/Pods/Charts/Charts/Classes/Charts/ScatterChartView.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Users/markmoussa/HackathonProjects/Rhabit/Pods/Target\ Support\ Files/Charts/Charts-umbrella.h /Users/markmoussa/HackathonProjects/Rhabit/DerivedData/Rhabit/Build/Intermediates/Pods.build/Debug-iphonesimulator/Charts.build/unextended-module.modulemap /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/Foundation.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/Dispatch.swiftmodule /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/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule
|
D
|
/Users/oslo/code/swift_vapor_server/.build/debug/Settings.build/Config+Directory.swift.o : /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Config+Arguments.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Config+Directory.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Config.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/KeyAccessible+Merge.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/KeyAccessible.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Node+Merge.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Source.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Env/Env.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Env/Node+Env.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Env/String+Env.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/oslo/code/swift_vapor_server/.build/debug/Core.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/libc.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/JSON.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/Jay.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/Node.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/PathIndexable.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/Polymorphic.swiftmodule
/Users/oslo/code/swift_vapor_server/.build/debug/Settings.build/Config+Directory~partial.swiftmodule : /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Config+Arguments.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Config+Directory.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Config.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/KeyAccessible+Merge.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/KeyAccessible.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Node+Merge.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Source.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Env/Env.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Env/Node+Env.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Env/String+Env.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/oslo/code/swift_vapor_server/.build/debug/Core.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/libc.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/JSON.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/Jay.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/Node.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/PathIndexable.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/Polymorphic.swiftmodule
/Users/oslo/code/swift_vapor_server/.build/debug/Settings.build/Config+Directory~partial.swiftdoc : /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Config+Arguments.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Config+Directory.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Config.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/KeyAccessible+Merge.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/KeyAccessible.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Node+Merge.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Source.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Env/Env.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Env/Node+Env.swift /Users/oslo/code/swift_vapor_server/Packages/Vapor-1.5.12/Sources/Settings/Env/String+Env.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/oslo/code/swift_vapor_server/.build/debug/Core.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/libc.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/JSON.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/Jay.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/Node.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/PathIndexable.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/Polymorphic.swiftmodule
|
D
|
// Written in the D programming language
/*
Copyright (C) 2004-2011 Christopher E. Miller
Boost Software License - Version 1.0 - August 17th, 2003
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.
socket.d 1.4
Jan 2011
Thanks to Benjamin Herr for his assistance.
*/
/**
* Socket primitives.
* Example: See $(SAMPLESRC listener.d) and $(SAMPLESRC htmlget.d)
* License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Christopher E. Miller, $(HTTP klickverbot.at, David Nadlinger),
* $(HTTP thecybershadow.net, Vladimir Panteleev)
* Source: $(PHOBOSSRC std/_socket.d)
*/
module std.socket;
import core.stdc.stdint, core.stdc.stdlib, core.stdc.string, std.conv, std.string;
import core.stdc.config;
import core.time : dur, Duration;
import std.exception;
import std.internal.cstring;
@safe:
version(Windows)
{
pragma (lib, "ws2_32.lib");
pragma (lib, "wsock32.lib");
import core.sys.windows.windows, std.windows.syserror;
public import core.sys.windows.winsock2;
private alias _ctimeval = core.sys.windows.winsock2.timeval;
private alias _clinger = core.sys.windows.winsock2.linger;
enum socket_t : SOCKET { INVALID_SOCKET }
private const int _SOCKET_ERROR = SOCKET_ERROR;
private int _lasterr() nothrow @nogc
{
return WSAGetLastError();
}
}
else version(Posix)
{
version(linux)
{
enum : int
{
TCP_KEEPIDLE = 4,
TCP_KEEPINTVL = 5
}
}
public import core.sys.posix.netinet.in_;
import core.sys.posix.arpa.inet;
import core.sys.posix.fcntl;
import core.sys.posix.netdb;
import core.sys.posix.netinet.tcp;
import core.sys.posix.sys.select;
import core.sys.posix.sys.socket;
import core.sys.posix.sys.time;
import core.sys.posix.sys.un : sockaddr_un;
import core.sys.posix.unistd;
private alias _ctimeval = core.sys.posix.sys.time.timeval;
private alias _clinger = core.sys.posix.sys.socket.linger;
import core.stdc.errno;
enum socket_t : int32_t { init = -1 }
private const int _SOCKET_ERROR = -1;
private enum : int
{
SD_RECEIVE = SHUT_RD,
SD_SEND = SHUT_WR,
SD_BOTH = SHUT_RDWR
}
private int _lasterr() nothrow @nogc
{
return errno;
}
}
else
{
static assert(0); // No socket support yet.
}
version(unittest)
{
static assert(is(uint32_t == uint));
static assert(is(uint16_t == ushort));
import std.stdio : writefln;
// Print a message on exception instead of failing the unittest.
private void softUnittest(void delegate() @safe test, int line = __LINE__) @trusted
{
try
test();
catch (Throwable e)
{
writefln(" --- std.socket(%d) test fails depending on environment ---", line);
writefln(" (%s)", e);
}
}
}
/// Base exception thrown by $(D std.socket).
class SocketException: Exception
{
mixin basicExceptionCtors;
}
version (CRuntime_Glibc) version = GNU_STRERROR;
version (CRuntime_UClibc) version = GNU_STRERROR;
/*
* Needs to be public so that SocketOSException can be thrown outside of
* std.socket (since it uses it as a default argument), but it probably doesn't
* need to actually show up in the docs, since there's not really any public
* need for it outside of being a default argument.
*/
string formatSocketError(int err) @trusted
{
version(Posix)
{
char[80] buf;
const(char)* cs;
version (GNU_STRERROR)
{
cs = strerror_r(err, buf.ptr, buf.length);
}
else
{
auto errs = strerror_r(err, buf.ptr, buf.length);
if (errs == 0)
cs = buf.ptr;
else
return "Socket error " ~ to!string(err);
}
auto len = strlen(cs);
if (cs[len - 1] == '\n')
len--;
if (cs[len - 1] == '\r')
len--;
return cs[0 .. len].idup;
}
else
version(Windows)
{
return sysErrorString(err);
}
else
return "Socket error " ~ to!string(err);
}
/// Retrieve the error message for the most recently encountered network error.
@property string lastSocketError()
{
return formatSocketError(_lasterr());
}
/**
* Socket exceptions representing network errors reported by the operating
* system.
*/
class SocketOSException: SocketException
{
int errorCode; /// Platform-specific error code.
///
this(string msg,
string file = __FILE__,
size_t line = __LINE__,
Throwable next = null,
int err = _lasterr(),
string function(int) @trusted errorFormatter = &formatSocketError)
{
errorCode = err;
if (msg.length)
super(msg ~ ": " ~ errorFormatter(err), file, line, next);
else
super(errorFormatter(err), file, line, next);
}
///
this(string msg,
Throwable next,
string file = __FILE__,
size_t line = __LINE__,
int err = _lasterr(),
string function(int) @trusted errorFormatter = &formatSocketError)
{
this(msg, file, line, next, err, errorFormatter);
}
///
this(string msg,
int err,
string function(int) @trusted errorFormatter = &formatSocketError,
string file = __FILE__,
size_t line = __LINE__,
Throwable next = null)
{
this(msg, file, line, next, err, errorFormatter);
}
}
/// Socket exceptions representing invalid parameters specified by user code.
class SocketParameterException: SocketException
{
mixin basicExceptionCtors;
}
/**
* Socket exceptions representing attempts to use network capabilities not
* available on the current system.
*/
class SocketFeatureException: SocketException
{
mixin basicExceptionCtors;
}
/**
* Returns:
* $(D true) if the last socket operation failed because the socket
* was in non-blocking mode and the operation would have blocked.
*/
bool wouldHaveBlocked() nothrow @nogc
{
version(Windows)
return _lasterr() == WSAEWOULDBLOCK;
else version(Posix)
return _lasterr() == EAGAIN;
else
static assert(0);
}
private immutable
{
typeof(&getnameinfo) getnameinfoPointer;
typeof(&getaddrinfo) getaddrinfoPointer;
typeof(&freeaddrinfo) freeaddrinfoPointer;
}
shared static this() @system
{
version(Windows)
{
WSADATA wd;
// Winsock will still load if an older version is present.
// The version is just a request.
int val;
val = WSAStartup(0x2020, &wd);
if (val) // Request Winsock 2.2 for IPv6.
throw new SocketOSException("Unable to initialize socket library", val);
// These functions may not be present on older Windows versions.
// See the comment in InternetAddress.toHostNameString() for details.
auto ws2Lib = GetModuleHandleA("ws2_32.dll");
if (ws2Lib)
{
getnameinfoPointer = cast(typeof(getnameinfoPointer))
GetProcAddress(ws2Lib, "getnameinfo");
getaddrinfoPointer = cast(typeof(getaddrinfoPointer))
GetProcAddress(ws2Lib, "getaddrinfo");
freeaddrinfoPointer = cast(typeof(freeaddrinfoPointer))
GetProcAddress(ws2Lib, "freeaddrinfo");
}
}
else version(Posix)
{
getnameinfoPointer = &getnameinfo;
getaddrinfoPointer = &getaddrinfo;
freeaddrinfoPointer = &freeaddrinfo;
}
}
shared static ~this() @system nothrow @nogc
{
version(Windows)
{
WSACleanup();
}
}
/**
* The communication domain used to resolve an address.
*/
enum AddressFamily: int
{
UNSPEC = AF_UNSPEC, /// Unspecified address family
UNIX = AF_UNIX, /// Local communication
INET = AF_INET, /// Internet Protocol version 4
IPX = AF_IPX, /// Novell IPX
APPLETALK = AF_APPLETALK, /// AppleTalk
INET6 = AF_INET6, /// Internet Protocol version 6
}
/**
* Communication semantics
*/
enum SocketType: int
{
STREAM = SOCK_STREAM, /// Sequenced, reliable, two-way communication-based byte streams
DGRAM = SOCK_DGRAM, /// Connectionless, unreliable datagrams with a fixed maximum length; data may be lost or arrive out of order
RAW = SOCK_RAW, /// Raw protocol access
RDM = SOCK_RDM, /// Reliably-delivered message datagrams
SEQPACKET = SOCK_SEQPACKET, /// Sequenced, reliable, two-way connection-based datagrams with a fixed maximum length
}
/**
* Protocol
*/
enum ProtocolType: int
{
IP = IPPROTO_IP, /// Internet Protocol version 4
ICMP = IPPROTO_ICMP, /// Internet Control Message Protocol
IGMP = IPPROTO_IGMP, /// Internet Group Management Protocol
GGP = IPPROTO_GGP, /// Gateway to Gateway Protocol
TCP = IPPROTO_TCP, /// Transmission Control Protocol
PUP = IPPROTO_PUP, /// PARC Universal Packet Protocol
UDP = IPPROTO_UDP, /// User Datagram Protocol
IDP = IPPROTO_IDP, /// Xerox NS protocol
RAW = IPPROTO_RAW, /// Raw IP packets
IPV6 = IPPROTO_IPV6, /// Internet Protocol version 6
}
/**
* $(D Protocol) is a class for retrieving protocol information.
*
* Example:
* ---
* auto proto = new Protocol;
* writeln("About protocol TCP:");
* if (proto.getProtocolByType(ProtocolType.TCP))
* {
* writefln(" Name: %s", proto.name);
* foreach (string s; proto.aliases)
* writefln(" Alias: %s", s);
* }
* else
* writeln(" No information found");
* ---
*/
class Protocol
{
/// These members are populated when one of the following functions are called successfully:
ProtocolType type;
string name; /// ditto
string[] aliases; /// ditto
void populate(protoent* proto) @system pure nothrow
{
type = cast(ProtocolType) proto.p_proto;
name = to!string(proto.p_name);
int i;
for (i = 0;; i++)
{
if (!proto.p_aliases[i])
break;
}
if (i)
{
aliases = new string[i];
for (i = 0; i != aliases.length; i++)
{
aliases[i] =
to!string(proto.p_aliases[i]);
}
}
else
{
aliases = null;
}
}
/** Returns: false on failure */
bool getProtocolByName(in char[] name) @trusted nothrow
{
protoent* proto;
proto = getprotobyname(name.tempCString());
if (!proto)
return false;
populate(proto);
return true;
}
/** Returns: false on failure */
// Same as getprotobynumber().
bool getProtocolByType(ProtocolType type) @trusted nothrow
{
protoent* proto;
proto = getprotobynumber(type);
if (!proto)
return false;
populate(proto);
return true;
}
}
// Skip this test on Android because getprotobyname/number are
// unimplemented in bionic.
version(CRuntime_Bionic) {} else
@safe unittest
{
softUnittest({
Protocol proto = new Protocol;
assert(proto.getProtocolByType(ProtocolType.TCP));
//writeln("About protocol TCP:");
//writefln("\tName: %s", proto.name);
// foreach (string s; proto.aliases)
// {
// writefln("\tAlias: %s", s);
// }
assert(proto.name == "tcp");
assert(proto.aliases.length == 1 && proto.aliases[0] == "TCP");
});
}
/**
* $(D Service) is a class for retrieving service information.
*
* Example:
* ---
* auto serv = new Service;
* writeln("About service epmap:");
* if (serv.getServiceByName("epmap", "tcp"))
* {
* writefln(" Service: %s", serv.name);
* writefln(" Port: %d", serv.port);
* writefln(" Protocol: %s", serv.protocolName);
* foreach (string s; serv.aliases)
* writefln(" Alias: %s", s);
* }
* else
* writefln(" No service for epmap.");
* ---
*/
class Service
{
/// These members are populated when one of the following functions are called successfully:
string name;
string[] aliases; /// ditto
ushort port; /// ditto
string protocolName; /// ditto
void populate(servent* serv) @system pure nothrow
{
name = to!string(serv.s_name);
port = ntohs(cast(ushort) serv.s_port);
protocolName = to!string(serv.s_proto);
int i;
for (i = 0;; i++)
{
if (!serv.s_aliases[i])
break;
}
if (i)
{
aliases = new string[i];
for (i = 0; i != aliases.length; i++)
{
aliases[i] =
to!string(serv.s_aliases[i]);
}
}
else
{
aliases = null;
}
}
/**
* If a protocol name is omitted, any protocol will be matched.
* Returns: false on failure.
*/
bool getServiceByName(in char[] name, in char[] protocolName = null) @trusted nothrow
{
servent* serv;
serv = getservbyname(name.tempCString(), protocolName.tempCString());
if (!serv)
return false;
populate(serv);
return true;
}
/// ditto
bool getServiceByPort(ushort port, in char[] protocolName = null) @trusted nothrow
{
servent* serv;
serv = getservbyport(port, protocolName.tempCString());
if (!serv)
return false;
populate(serv);
return true;
}
}
@safe unittest
{
softUnittest({
Service serv = new Service;
if (serv.getServiceByName("epmap", "tcp"))
{
// writefln("About service epmap:");
// writefln("\tService: %s", serv.name);
// writefln("\tPort: %d", serv.port);
// writefln("\tProtocol: %s", serv.protocolName);
// foreach (string s; serv.aliases)
// {
// writefln("\tAlias: %s", s);
// }
// For reasons unknown this is loc-srv on Wine and epmap on Windows
assert(serv.name == "loc-srv" || serv.name == "epmap", serv.name);
assert(serv.port == 135);
assert(serv.protocolName == "tcp");
}
else
{
writefln("No service for epmap.");
}
});
}
private mixin template socketOSExceptionCtors()
{
///
this(string msg, string file = __FILE__, size_t line = __LINE__,
Throwable next = null, int err = _lasterr())
{
super(msg, file, line, next, err);
}
///
this(string msg, Throwable next, string file = __FILE__,
size_t line = __LINE__, int err = _lasterr())
{
super(msg, next, file, line, err);
}
///
this(string msg, int err, string file = __FILE__, size_t line = __LINE__,
Throwable next = null)
{
super(msg, next, file, line, err);
}
}
/**
* Class for exceptions thrown from an `InternetHost`.
*/
class HostException: SocketOSException
{
mixin socketOSExceptionCtors;
}
/**
* `InternetHost` is a class for resolving IPv4 addresses.
*
* Consider using `getAddress`, `parseAddress` and `Address` methods
* instead of using this class directly.
*/
class InternetHost
{
/// These members are populated when one of the following functions are called successfully:
string name;
string[] aliases; /// ditto
uint[] addrList; /// ditto
void validHostent(in hostent* he)
{
if (he.h_addrtype != cast(int) AddressFamily.INET || he.h_length != 4)
throw new HostException("Address family mismatch");
}
void populate(hostent* he) @system pure nothrow
{
int i;
char* p;
name = to!string(he.h_name);
for (i = 0;; i++)
{
p = he.h_aliases[i];
if (!p)
break;
}
if (i)
{
aliases = new string[i];
for (i = 0; i != aliases.length; i++)
{
aliases[i] =
to!string(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] = ntohl(*(cast(uint*) he.h_addr_list[i]));
}
}
else
{
addrList = null;
}
}
private bool getHostNoSync(string opMixin, T)(T param) @system
{
mixin(opMixin);
if (!he)
return false;
validHostent(he);
populate(he);
return true;
}
version(Windows)
alias getHost = getHostNoSync;
else
{
// posix systems use global state for return value, so we
// must synchronize across all threads
private bool getHost(string opMixin, T)(T param) @system
{
synchronized(this.classinfo)
return getHostNoSync!(opMixin, T)(param);
}
}
/**
* Resolve host name.
* Returns: false if unable to resolve.
*/
bool getHostByName(in char[] name) @trusted
{
static if (is(typeof(gethostbyname_r)))
{
return getHostNoSync!q{
hostent he_v;
hostent* he;
ubyte[256] buffer_v = void;
auto buffer = buffer_v[];
auto param_zTmp = param.tempCString();
while (true)
{
he = &he_v;
int errno;
if (gethostbyname_r(param_zTmp, he, buffer.ptr, buffer.length, &he, &errno) == ERANGE)
buffer.length = buffer.length * 2;
else
break;
}
}(name);
}
else
{
return getHost!q{
auto he = gethostbyname(param.tempCString());
}(name);
}
}
/**
* Resolve IPv4 address number.
*
* Params:
* addr = The IPv4 address to resolve, in host byte order.
* Returns:
* false if unable to resolve.
*/
bool getHostByAddr(uint addr) @trusted
{
return getHost!q{
auto x = htonl(param);
auto he = gethostbyaddr(&x, 4, cast(int) AddressFamily.INET);
}(addr);
}
/**
* Same as previous, but addr is an IPv4 address string in the
* dotted-decimal form $(I a.b.c.d).
* Returns: false if unable to resolve.
*/
bool getHostByAddr(in char[] addr) @trusted
{
return getHost!q{
auto x = inet_addr(param.tempCString());
enforce(x != INADDR_NONE,
new SocketParameterException("Invalid IPv4 address"));
auto he = gethostbyaddr(&x, 4, cast(int) AddressFamily.INET);
}(addr);
}
}
///
@safe unittest
{
InternetHost ih = new InternetHost;
ih.getHostByAddr(0x7F_00_00_01);
assert(ih.addrList[0] == 0x7F_00_00_01);
ih.getHostByAddr("127.0.0.1");
assert(ih.addrList[0] == 0x7F_00_00_01);
if (!ih.getHostByName("www.digitalmars.com"))
return; // don't fail if not connected to internet
assert(ih.addrList.length);
InternetAddress ia = new InternetAddress(ih.addrList[0], InternetAddress.PORT_ANY);
assert(ih.name == "www.digitalmars.com" || ih.name == "digitalmars.com",
ih.name);
assert(ih.getHostByAddr(ih.addrList[0]));
string getHostNameFromInt = ih.name.dup;
assert(ih.getHostByAddr(ia.toAddrString()));
string getHostNameFromStr = ih.name.dup;
assert(getHostNameFromInt == getHostNameFromStr);
}
/// Holds information about a socket _address retrieved by $(D getAddressInfo).
struct AddressInfo
{
AddressFamily family; /// Address _family
SocketType type; /// Socket _type
ProtocolType protocol; /// Protocol
Address address; /// Socket _address
string canonicalName; /// Canonical name, when $(D AddressInfoFlags.CANONNAME) is used.
}
/**
* A subset of flags supported on all platforms with getaddrinfo.
* Specifies option flags for $(D getAddressInfo).
*/
enum AddressInfoFlags: int
{
/// The resulting addresses will be used in a call to $(D Socket.bind).
PASSIVE = AI_PASSIVE,
/// The canonical name is returned in $(D canonicalName) member in the first $(D AddressInfo).
CANONNAME = AI_CANONNAME,
/**
* The $(D node) parameter passed to $(D getAddressInfo) must be a numeric string.
* This will suppress any potentially lengthy network host address lookups.
*/
NUMERICHOST = AI_NUMERICHOST,
}
/**
* On POSIX, getaddrinfo uses its own error codes, and thus has its own
* formatting function.
*/
private string formatGaiError(int err) @trusted
{
version(Windows)
{
return sysErrorString(err);
}
else
{
synchronized
return to!string(gai_strerror(err));
}
}
/**
* Provides _protocol-independent translation from host names to socket
* addresses. If advanced functionality is not required, consider using
* $(D getAddress) for compatibility with older systems.
*
* Returns: Array with one $(D AddressInfo) per socket address.
*
* Throws: $(D SocketOSException) on failure, or $(D SocketFeatureException)
* if this functionality is not available on the current system.
*
* Params:
* node = string containing host name or numeric address
* options = optional additional parameters, identified by type:
* $(UL $(LI $(D string) - service name or port number)
* $(LI $(D AddressInfoFlags) - option flags)
* $(LI $(D AddressFamily) - address family to filter by)
* $(LI $(D SocketType) - socket type to filter by)
* $(LI $(D ProtocolType) - protocol to filter by))
*
* Example:
* ---
* // Roundtrip DNS resolution
* auto results = getAddressInfo("www.digitalmars.com");
* assert(results[0].address.toHostNameString() ==
* "digitalmars.com");
*
* // Canonical name
* results = getAddressInfo("www.digitalmars.com",
* AddressInfoFlags.CANONNAME);
* assert(results[0].canonicalName == "digitalmars.com");
*
* // IPv6 resolution
* results = getAddressInfo("ipv6.google.com");
* assert(results[0].family == AddressFamily.INET6);
*
* // Multihomed resolution
* results = getAddressInfo("google.com");
* assert(results.length > 1);
*
* // Parsing IPv4
* results = getAddressInfo("127.0.0.1",
* AddressInfoFlags.NUMERICHOST);
* assert(results.length && results[0].family ==
* AddressFamily.INET);
*
* // Parsing IPv6
* results = getAddressInfo("::1",
* AddressInfoFlags.NUMERICHOST);
* assert(results.length && results[0].family ==
* AddressFamily.INET6);
* ---
*/
AddressInfo[] getAddressInfo(T...)(in char[] node, T options)
{
const(char)[] service = null;
addrinfo hints;
hints.ai_family = AF_UNSPEC;
foreach (option; options)
{
static if (is(typeof(option) : const(char)[]))
service = option;
else
static if (is(typeof(option) == AddressInfoFlags))
hints.ai_flags |= option;
else
static if (is(typeof(option) == AddressFamily))
hints.ai_family = option;
else
static if (is(typeof(option) == SocketType))
hints.ai_socktype = option;
else
static if (is(typeof(option) == ProtocolType))
hints.ai_protocol = option;
else
static assert(0, "Unknown getAddressInfo option type: " ~ typeof(option).stringof);
}
return () @trusted { return getAddressInfoImpl(node, service, &hints); }();
}
@system unittest
{
struct Oops
{
const(char[]) breakSafety()
{
*cast(int*) 0xcafebabe = 0xdeadbeef;
return null;
}
alias breakSafety this;
}
assert(!__traits(compiles, () {
getAddressInfo("", Oops.init);
}), "getAddressInfo breaks @safe");
}
private AddressInfo[] getAddressInfoImpl(in char[] node, in char[] service, addrinfo* hints) @system
{
import std.array : appender;
if (getaddrinfoPointer && freeaddrinfoPointer)
{
addrinfo* ai_res;
int ret = getaddrinfoPointer(
node.tempCString(),
service.tempCString(),
hints, &ai_res);
enforce(ret == 0, new SocketOSException("getaddrinfo error", ret, &formatGaiError));
scope(exit) freeaddrinfoPointer(ai_res);
auto result = appender!(AddressInfo[])();
// Use const to force UnknownAddressReference to copy the sockaddr.
for (const(addrinfo)* ai = ai_res; ai; ai = ai.ai_next)
result ~= AddressInfo(
cast(AddressFamily) ai.ai_family,
cast(SocketType ) ai.ai_socktype,
cast(ProtocolType ) ai.ai_protocol,
new UnknownAddressReference(ai.ai_addr, cast(socklen_t) ai.ai_addrlen),
ai.ai_canonname ? to!string(ai.ai_canonname) : null);
assert(result.data.length > 0);
return result.data;
}
throw new SocketFeatureException("Address info lookup is not available " ~
"on this system.");
}
@safe unittest
{
softUnittest({
if (getaddrinfoPointer)
{
// Roundtrip DNS resolution
auto results = getAddressInfo("www.digitalmars.com");
assert(results[0].address.toHostNameString() == "digitalmars.com");
// Canonical name
results = getAddressInfo("www.digitalmars.com",
AddressInfoFlags.CANONNAME);
assert(results[0].canonicalName == "digitalmars.com");
// IPv6 resolution
//results = getAddressInfo("ipv6.google.com");
//assert(results[0].family == AddressFamily.INET6);
// Multihomed resolution
//results = getAddressInfo("google.com");
//assert(results.length > 1);
// Parsing IPv4
results = getAddressInfo("127.0.0.1", AddressInfoFlags.NUMERICHOST);
assert(results.length && results[0].family == AddressFamily.INET);
// Parsing IPv6
results = getAddressInfo("::1", AddressInfoFlags.NUMERICHOST);
assert(results.length && results[0].family == AddressFamily.INET6);
}
});
if (getaddrinfoPointer)
{
auto results = getAddressInfo(null, "1234", AddressInfoFlags.PASSIVE,
SocketType.STREAM, ProtocolType.TCP, AddressFamily.INET);
assert(results.length == 1 && results[0].address.toString() == "0.0.0.0:1234");
}
}
private ushort serviceToPort(in char[] service)
{
if (service == "")
return InternetAddress.PORT_ANY;
else
if (isNumeric(service))
return to!ushort(service);
else
{
auto s = new Service();
s.getServiceByName(service);
return s.port;
}
}
/**
* Provides _protocol-independent translation from host names to socket
* addresses. Uses $(D getAddressInfo) if the current system supports it,
* and $(D InternetHost) otherwise.
*
* Returns: Array with one $(D Address) instance per socket address.
*
* Throws: $(D SocketOSException) on failure.
*
* Example:
* ---
* writeln("Resolving www.digitalmars.com:");
* try
* {
* auto addresses = getAddress("www.digitalmars.com");
* foreach (address; addresses)
* writefln(" IP: %s", address.toAddrString());
* }
* catch (SocketException e)
* writefln(" Lookup failed: %s", e.msg);
* ---
*/
Address[] getAddress(in char[] hostname, in char[] service = null)
{
if (getaddrinfoPointer && freeaddrinfoPointer)
{
// use getAddressInfo
auto infos = getAddressInfo(hostname, service);
Address[] results;
results.length = infos.length;
foreach (i, ref result; results)
result = infos[i].address;
return results;
}
else
return getAddress(hostname, serviceToPort(service));
}
/// ditto
Address[] getAddress(in char[] hostname, ushort port)
{
if (getaddrinfoPointer && freeaddrinfoPointer)
return getAddress(hostname, to!string(port));
else
{
// use getHostByName
auto ih = new InternetHost;
if (!ih.getHostByName(hostname))
throw new AddressException(
text("Unable to resolve host '", hostname, "'"));
Address[] results;
foreach (uint addr; ih.addrList)
results ~= new InternetAddress(addr, port);
return results;
}
}
@safe unittest
{
softUnittest({
auto addresses = getAddress("63.105.9.61");
assert(addresses.length && addresses[0].toAddrString() == "63.105.9.61");
if (getaddrinfoPointer)
{
// test via gethostbyname
auto getaddrinfoPointerBackup = getaddrinfoPointer;
cast() getaddrinfoPointer = null;
scope(exit) cast() getaddrinfoPointer = getaddrinfoPointerBackup;
addresses = getAddress("63.105.9.61");
assert(addresses.length && addresses[0].toAddrString() == "63.105.9.61");
}
});
}
/**
* Provides _protocol-independent parsing of network addresses. Does not
* attempt name resolution. Uses $(D getAddressInfo) with
* $(D AddressInfoFlags.NUMERICHOST) if the current system supports it, and
* $(D InternetAddress) otherwise.
*
* Returns: An $(D Address) instance representing specified address.
*
* Throws: $(D SocketException) on failure.
*
* Example:
* ---
* writeln("Enter IP address:");
* string ip = readln().chomp();
* try
* {
* Address address = parseAddress(ip);
* writefln("Looking up reverse of %s:",
* address.toAddrString());
* try
* {
* string reverse = address.toHostNameString();
* if (reverse)
* writefln(" Reverse name: %s", reverse);
* else
* writeln(" Reverse hostname not found.");
* }
* catch (SocketException e)
* writefln(" Lookup error: %s", e.msg);
* }
* catch (SocketException e)
* {
* writefln(" %s is not a valid IP address: %s",
* ip, e.msg);
* }
* ---
*/
Address parseAddress(in char[] hostaddr, in char[] service = null)
{
if (getaddrinfoPointer && freeaddrinfoPointer)
return getAddressInfo(hostaddr, service, AddressInfoFlags.NUMERICHOST)[0].address;
else
return parseAddress(hostaddr, serviceToPort(service));
}
/// ditto
Address parseAddress(in char[] hostaddr, ushort port)
{
if (getaddrinfoPointer && freeaddrinfoPointer)
return parseAddress(hostaddr, to!string(port));
else
{
auto in4_addr = InternetAddress.parse(hostaddr);
enforce(in4_addr != InternetAddress.ADDR_NONE,
new SocketParameterException("Invalid IP address"));
return new InternetAddress(in4_addr, port);
}
}
@safe unittest
{
softUnittest({
auto address = parseAddress("63.105.9.61");
assert(address.toAddrString() == "63.105.9.61");
if (getaddrinfoPointer)
{
// test via inet_addr
auto getaddrinfoPointerBackup = getaddrinfoPointer;
cast() getaddrinfoPointer = null;
scope(exit) cast() getaddrinfoPointer = getaddrinfoPointerBackup;
address = parseAddress("63.105.9.61");
assert(address.toAddrString() == "63.105.9.61");
}
assert(collectException!SocketException(parseAddress("Invalid IP address")));
});
}
/**
* Class for exceptions thrown from an $(D Address).
*/
class AddressException: SocketOSException
{
mixin socketOSExceptionCtors;
}
/**
* $(D Address) is an abstract class for representing a socket addresses.
*
* Example:
* ---
* writeln("About www.google.com port 80:");
* try
* {
* Address[] addresses = getAddress("www.google.com", 80);
* writefln(" %d addresses found.", addresses.length);
* foreach (int i, Address a; addresses)
* {
* writefln(" Address %d:", i+1);
* writefln(" IP address: %s", a.toAddrString());
* writefln(" Hostname: %s", a.toHostNameString());
* writefln(" Port: %s", a.toPortString());
* writefln(" Service name: %s",
* a.toServiceNameString());
* }
* }
* catch (SocketException e)
* writefln(" Lookup error: %s", e.msg);
* ---
*/
abstract class Address
{
/// Returns pointer to underlying $(D sockaddr) structure.
abstract @property sockaddr* name() pure nothrow @nogc;
abstract @property const(sockaddr)* name() const pure nothrow @nogc; /// ditto
/// Returns actual size of underlying $(D sockaddr) structure.
abstract @property socklen_t nameLen() const pure nothrow @nogc;
// Socket.remoteAddress, Socket.localAddress, and Socket.receiveFrom
// use setNameLen to set the actual size of the address as returned by
// getsockname, getpeername, and recvfrom, respectively.
// The following implementation is sufficient for fixed-length addresses,
// and ensures that the length is not changed.
// Must be overridden for variable-length addresses.
protected void setNameLen(socklen_t len)
{
if (len != this.nameLen)
throw new AddressException(
format("%s expects address of length %d, not %d", typeid(this),
this.nameLen, len), 0);
}
/// Family of this address.
@property AddressFamily addressFamily() const pure nothrow @nogc
{
return cast(AddressFamily) name.sa_family;
}
// Common code for toAddrString and toHostNameString
private string toHostString(bool numeric) @trusted const
{
// getnameinfo() is the recommended way to perform a reverse (name)
// lookup on both Posix and Windows. However, it is only available
// on Windows XP and above, and not included with the WinSock import
// libraries shipped with DMD. Thus, we check for getnameinfo at
// runtime in the shared module constructor, and use it if it's
// available in the base class method. Classes for specific network
// families (e.g. InternetHost) override this method and use a
// deprecated, albeit commonly-available method when getnameinfo()
// is not available.
// http://technet.microsoft.com/en-us/library/aa450403.aspx
if (getnameinfoPointer)
{
auto buf = new char[NI_MAXHOST];
auto ret = getnameinfoPointer(
name, nameLen,
buf.ptr, cast(uint) buf.length,
null, 0,
numeric ? NI_NUMERICHOST : NI_NAMEREQD);
if (!numeric)
{
if (ret == EAI_NONAME)
return null;
version(Windows)
if (ret == WSANO_DATA)
return null;
}
enforce(ret == 0, new AddressException("Could not get " ~
(numeric ? "host address" : "host name")));
return assumeUnique(buf[0 .. strlen(buf.ptr)]);
}
throw new SocketFeatureException((numeric ? "Host address" : "Host name") ~
" lookup for this address family is not available on this system.");
}
// Common code for toPortString and toServiceNameString
private string toServiceString(bool numeric) @trusted const
{
// See toHostNameString() for details about getnameinfo().
if (getnameinfoPointer)
{
auto buf = new char[NI_MAXSERV];
enforce(getnameinfoPointer(
name, nameLen,
null, 0,
buf.ptr, cast(uint) buf.length,
numeric ? NI_NUMERICSERV : NI_NAMEREQD
) == 0, new AddressException("Could not get " ~
(numeric ? "port number" : "service name")));
return assumeUnique(buf[0 .. strlen(buf.ptr)]);
}
throw new SocketFeatureException((numeric ? "Port number" : "Service name") ~
" lookup for this address family is not available on this system.");
}
/**
* Attempts to retrieve the host address as a human-readable string.
*
* Throws: $(D AddressException) on failure, or $(D SocketFeatureException)
* if address retrieval for this address family is not available on the
* current system.
*/
string toAddrString() const
{
return toHostString(true);
}
/**
* Attempts to retrieve the host name as a fully qualified domain name.
*
* Returns: The FQDN corresponding to this $(D Address), or $(D null) if
* the host name did not resolve.
*
* Throws: $(D AddressException) on error, or $(D SocketFeatureException)
* if host name lookup for this address family is not available on the
* current system.
*/
string toHostNameString() const
{
return toHostString(false);
}
/**
* Attempts to retrieve the numeric port number as a string.
*
* Throws: $(D AddressException) on failure, or $(D SocketFeatureException)
* if port number retrieval for this address family is not available on the
* current system.
*/
string toPortString() const
{
return toServiceString(true);
}
/**
* Attempts to retrieve the service name as a string.
*
* Throws: $(D AddressException) on failure, or $(D SocketFeatureException)
* if service name lookup for this address family is not available on the
* current system.
*/
string toServiceNameString() const
{
return toServiceString(false);
}
/// Human readable string representing this address.
override string toString() const
{
try
{
string host = toAddrString();
string port = toPortString();
if (host.indexOf(':') >= 0)
return "[" ~ host ~ "]:" ~ port;
else
return host ~ ":" ~ port;
}
catch (SocketException)
return "Unknown";
}
}
/**
* $(D UnknownAddress) encapsulates an unknown socket address.
*/
class UnknownAddress: Address
{
protected:
sockaddr sa;
public:
override @property sockaddr* name()
{
return &sa;
}
override @property const(sockaddr)* name() const
{
return &sa;
}
override @property socklen_t nameLen() const
{
return cast(socklen_t) sa.sizeof;
}
}
/**
* $(D UnknownAddressReference) encapsulates a reference to an arbitrary
* socket address.
*/
class UnknownAddressReference: Address
{
protected:
sockaddr* sa;
socklen_t len;
public:
/// Constructs an $(D Address) with a reference to the specified $(D sockaddr).
this(sockaddr* sa, socklen_t len) pure nothrow @nogc
{
this.sa = sa;
this.len = len;
}
/// Constructs an $(D Address) with a copy of the specified $(D sockaddr).
this(const(sockaddr)* sa, socklen_t len) @system pure nothrow
{
this.sa = cast(sockaddr*) (cast(ubyte*) sa)[0 .. len].dup.ptr;
this.len = len;
}
override @property sockaddr* name()
{
return sa;
}
override @property const(sockaddr)* name() const
{
return sa;
}
override @property socklen_t nameLen() const
{
return cast(socklen_t) len;
}
}
/**
* $(D InternetAddress) encapsulates an IPv4 (Internet Protocol version 4)
* socket address.
*
* Consider using $(D getAddress), $(D parseAddress) and $(D Address) methods
* instead of using this class directly.
*/
class InternetAddress: Address
{
protected:
sockaddr_in sin;
this() pure nothrow @nogc
{
}
public:
override @property sockaddr* name()
{
return cast(sockaddr*)&sin;
}
override @property const(sockaddr)* name() const
{
return cast(const(sockaddr)*)&sin;
}
override @property socklen_t nameLen() const
{
return cast(socklen_t) sin.sizeof;
}
enum uint ADDR_ANY = INADDR_ANY; /// Any IPv4 host address.
enum uint ADDR_NONE = INADDR_NONE; /// An invalid IPv4 host address.
enum ushort PORT_ANY = 0; /// Any IPv4 port number.
/// Returns the IPv4 _port number (in host byte order).
@property ushort port() const pure nothrow @nogc
{
return ntohs(sin.sin_port);
}
/// Returns the IPv4 address number (in host byte order).
@property uint addr() const pure nothrow @nogc
{
return ntohl(sin.sin_addr.s_addr);
}
/**
* Construct a new $(D InternetAddress).
* Params:
* addr = an IPv4 address string in the dotted-decimal form a.b.c.d,
* or a host name which will be resolved using an $(D InternetHost)
* object.
* port = port number, may be $(D PORT_ANY).
*/
this(in char[] addr, ushort port)
{
uint uiaddr = parse(addr);
if (ADDR_NONE == uiaddr)
{
InternetHost ih = new InternetHost;
if (!ih.getHostByName(addr))
//throw new AddressException("Invalid internet address");
throw new AddressException(
text("Unable to resolve host '", addr, "'"));
uiaddr = ih.addrList[0];
}
sin.sin_family = AddressFamily.INET;
sin.sin_addr.s_addr = htonl(uiaddr);
sin.sin_port = htons(port);
}
/**
* Construct a new $(D InternetAddress).
* Params:
* addr = (optional) an IPv4 address in host byte order, may be $(D ADDR_ANY).
* port = port number, may be $(D PORT_ANY).
*/
this(uint addr, ushort port) pure nothrow @nogc
{
sin.sin_family = AddressFamily.INET;
sin.sin_addr.s_addr = htonl(addr);
sin.sin_port = htons(port);
}
/// ditto
this(ushort port) pure nothrow @nogc
{
sin.sin_family = AddressFamily.INET;
sin.sin_addr.s_addr = ADDR_ANY;
sin.sin_port = htons(port);
}
/**
* Construct a new $(D InternetAddress).
* Params:
* addr = A sockaddr_in as obtained from lower-level API calls such as getifaddrs.
*/
this(sockaddr_in addr) pure nothrow @nogc
{
assert(addr.sin_family == AddressFamily.INET);
sin = addr;
}
/// Human readable string representing the IPv4 address in dotted-decimal form.
override string toAddrString() @trusted const
{
return to!string(inet_ntoa(sin.sin_addr));
}
/// Human readable string representing the IPv4 port.
override string toPortString() const
{
return std.conv.to!string(port);
}
/**
* Attempts to retrieve the host name as a fully qualified domain name.
*
* Returns: The FQDN corresponding to this $(D InternetAddress), or
* $(D null) if the host name did not resolve.
*
* Throws: $(D AddressException) on error.
*/
override string toHostNameString() const
{
// getnameinfo() is the recommended way to perform a reverse (name)
// lookup on both Posix and Windows. However, it is only available
// on Windows XP and above, and not included with the WinSock import
// libraries shipped with DMD. Thus, we check for getnameinfo at
// runtime in the shared module constructor, and fall back to the
// deprecated getHostByAddr() if it could not be found. See also:
// http://technet.microsoft.com/en-us/library/aa450403.aspx
if (getnameinfoPointer)
return super.toHostNameString();
else
{
auto host = new InternetHost();
if (!host.getHostByAddr(ntohl(sin.sin_addr.s_addr)))
return null;
return host.name;
}
}
/**
* Compares with another InternetAddress of same type for equality
* Returns: true if the InternetAddresses share the same address and
* port number.
*/
override bool opEquals(Object o) const
{
auto other = cast(InternetAddress) o;
return other && this.sin.sin_addr.s_addr == other.sin.sin_addr.s_addr &&
this.sin.sin_port == other.sin.sin_port;
}
///
@system unittest
{
auto addr1 = new InternetAddress("127.0.0.1", 80);
auto addr2 = new InternetAddress("127.0.0.2", 80);
assert(addr1 == addr1);
assert(addr1 != addr2);
}
/**
* Parse an IPv4 address string in the dotted-decimal form $(I a.b.c.d)
* and return the number.
* Returns: If the string is not a legitimate IPv4 address,
* $(D ADDR_NONE) is returned.
*/
static uint parse(in char[] addr) @trusted nothrow
{
return ntohl(inet_addr(addr.tempCString()));
}
/**
* Convert an IPv4 address number in host byte order to a human readable
* string representing the IPv4 address in dotted-decimal form.
*/
static string addrToString(uint addr) @trusted nothrow
{
in_addr sin_addr;
sin_addr.s_addr = htonl(addr);
return to!string(inet_ntoa(sin_addr));
}
}
@safe unittest
{
softUnittest({
const InternetAddress ia = new InternetAddress("63.105.9.61", 80);
assert(ia.toString() == "63.105.9.61:80");
});
softUnittest({
// test construction from a sockaddr_in
sockaddr_in sin;
sin.sin_addr.s_addr = htonl(0x7F_00_00_01); // 127.0.0.1
sin.sin_family = AddressFamily.INET;
sin.sin_port = htons(80);
const InternetAddress ia = new InternetAddress(sin);
assert(ia.toString() == "127.0.0.1:80");
});
softUnittest({
// test reverse lookup
auto ih = new InternetHost;
if (ih.getHostByName("digitalmars.com"))
{
const ia = new InternetAddress(ih.addrList[0], 80);
assert(ia.toHostNameString() == "digitalmars.com");
if (getnameinfoPointer)
{
// test reverse lookup, via gethostbyaddr
auto getnameinfoPointerBackup = getnameinfoPointer;
cast() getnameinfoPointer = null;
scope(exit) cast() getnameinfoPointer = getnameinfoPointerBackup;
assert(ia.toHostNameString() == "digitalmars.com");
}
}
});
version (SlowTests)
softUnittest({
// test failing reverse lookup
const InternetAddress ia = new InternetAddress("127.114.111.120", 80);
assert(ia.toHostNameString() is null);
if (getnameinfoPointer)
{
// test failing reverse lookup, via gethostbyaddr
auto getnameinfoPointerBackup = getnameinfoPointer;
getnameinfoPointer = null;
scope(exit) getnameinfoPointer = getnameinfoPointerBackup;
assert(ia.toHostNameString() is null);
}
});
}
/**
* $(D Internet6Address) encapsulates an IPv6 (Internet Protocol version 6)
* socket address.
*
* Consider using $(D getAddress), $(D parseAddress) and $(D Address) methods
* instead of using this class directly.
*/
class Internet6Address: Address
{
protected:
sockaddr_in6 sin6;
this() pure nothrow @nogc
{
}
public:
override @property sockaddr* name()
{
return cast(sockaddr*)&sin6;
}
override @property const(sockaddr)* name() const
{
return cast(const(sockaddr)*)&sin6;
}
override @property socklen_t nameLen() const
{
return cast(socklen_t) sin6.sizeof;
}
/// Any IPv6 host address.
static @property ref const(ubyte)[16] ADDR_ANY() pure nothrow @nogc
{
const(ubyte)[16]* addr;
static if (is(typeof(IN6ADDR_ANY)))
{
addr = &IN6ADDR_ANY.s6_addr;
return *addr;
}
else static if (is(typeof(in6addr_any)))
{
addr = &in6addr_any.s6_addr;
return *addr;
}
else
static assert(0);
}
/// Any IPv6 port number.
enum ushort PORT_ANY = 0;
/// Returns the IPv6 port number.
@property ushort port() const pure nothrow @nogc
{
return ntohs(sin6.sin6_port);
}
/// Returns the IPv6 address.
@property ubyte[16] addr() const pure nothrow @nogc
{
return sin6.sin6_addr.s6_addr;
}
/**
* Construct a new $(D Internet6Address).
* Params:
* addr = an IPv6 host address string in the form described in RFC 2373,
* or a host name which will be resolved using $(D getAddressInfo).
* service = (optional) service name.
*/
this(in char[] addr, in char[] service = null) @trusted
{
auto results = getAddressInfo(addr, service, AddressFamily.INET6);
assert(results.length && results[0].family == AddressFamily.INET6);
sin6 = *cast(sockaddr_in6*) results[0].address.name;
}
/**
* Construct a new $(D Internet6Address).
* Params:
* addr = an IPv6 host address string in the form described in RFC 2373,
* or a host name which will be resolved using $(D getAddressInfo).
* port = port number, may be $(D PORT_ANY).
*/
this(in char[] addr, ushort port)
{
if (port == PORT_ANY)
this(addr);
else
this(addr, to!string(port));
}
/**
* Construct a new $(D Internet6Address).
* Params:
* addr = (optional) an IPv6 host address in host byte order, or
* $(D ADDR_ANY).
* port = port number, may be $(D PORT_ANY).
*/
this(ubyte[16] addr, ushort port) pure nothrow @nogc
{
sin6.sin6_family = AddressFamily.INET6;
sin6.sin6_addr.s6_addr = addr;
sin6.sin6_port = htons(port);
}
/// ditto
this(ushort port) pure nothrow @nogc
{
sin6.sin6_family = AddressFamily.INET6;
sin6.sin6_addr.s6_addr = ADDR_ANY;
sin6.sin6_port = htons(port);
}
/**
* Construct a new $(D Internet6Address).
* Params:
* addr = A sockaddr_in6 as obtained from lower-level API calls such as getifaddrs.
*/
this(sockaddr_in6 addr) pure nothrow @nogc
{
assert(addr.sin6_family == AddressFamily.INET6);
sin6 = addr;
}
/**
* Parse an IPv6 host address string as described in RFC 2373, and return the
* address.
* Throws: $(D SocketException) on error.
*/
static ubyte[16] parse(in char[] addr) @trusted
{
// Although we could use inet_pton here, it's only available on Windows
// versions starting with Vista, so use getAddressInfo with NUMERICHOST
// instead.
auto results = getAddressInfo(addr, AddressInfoFlags.NUMERICHOST);
if (results.length && results[0].family == AddressFamily.INET6)
return (cast(sockaddr_in6*) results[0].address.name).sin6_addr.s6_addr;
throw new AddressException("Not an IPv6 address", 0);
}
}
@safe unittest
{
softUnittest({
const Internet6Address ia = new Internet6Address("::1", 80);
assert(ia.toString() == "[::1]:80");
});
softUnittest({
// test construction from a sockaddr_in6
sockaddr_in6 sin;
sin.sin6_addr.s6_addr = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]; // [::1]
sin.sin6_family = AddressFamily.INET6;
sin.sin6_port = htons(80);
const Internet6Address ia = new Internet6Address(sin);
assert(ia.toString() == "[::1]:80");
});
}
version(StdDdoc)
{
static if (!is(sockaddr_un))
{
// This exists only to allow the constructor taking
// a sockaddr_un to be compilable for documentation
// on platforms that don't supply a sockaddr_un.
struct sockaddr_un
{
}
}
/**
* $(D UnixAddress) encapsulates an address for a Unix domain socket
* ($(D AF_UNIX)), i.e. a socket bound to a path name in the file system.
* Available only on supported systems.
*
* Linux also supports an abstract address namespace, in which addresses
* are independent of the file system. A socket address is abstract
* iff `path` starts with a _null byte (`'\0'`). Null bytes in other
* positions of an abstract address are allowed and have no special
* meaning.
*
* Example:
* ---
* auto addr = new UnixAddress("/var/run/dbus/system_bus_socket");
* auto abstractAddr = new UnixAddress("\0/tmp/dbus-OtHLWmCLPR");
* ---
*
* See_Also: $(HTTP http://man7.org/linux/man-pages/man7/unix.7.html, UNIX(7))
*/
class UnixAddress: Address
{
private this() pure nothrow @nogc {}
/// Construct a new $(D UnixAddress) from the specified path.
this(in char[] path) { }
/**
* Construct a new $(D UnixAddress).
* Params:
* addr = A sockaddr_un as obtained from lower-level API calls.
*/
this(sockaddr_un addr) pure nothrow @nogc { }
/// Get the underlying _path.
@property string path() const { return null; }
/// ditto
override string toString() const { return null; }
override @property sockaddr* name() { return null; }
override @property const(sockaddr)* name() const { return null; }
override @property socklen_t nameLen() const { return 0; }
}
}
else
static if (is(sockaddr_un))
{
class UnixAddress: Address
{
protected:
socklen_t _nameLen;
struct
{
align (1):
sockaddr_un sun;
char unused = '\0'; // placeholder for a terminating '\0'
}
this() pure nothrow @nogc
{
sun.sun_family = AddressFamily.UNIX;
sun.sun_path = '?';
_nameLen = sun.sizeof;
}
override void setNameLen(socklen_t len) @trusted
{
if (len > sun.sizeof)
throw new SocketParameterException("Not enough socket address storage");
_nameLen = len;
}
public:
override @property sockaddr* name()
{
return cast(sockaddr*)&sun;
}
override @property const(sockaddr)* name() const
{
return cast(const(sockaddr)*)&sun;
}
override @property socklen_t nameLen() @trusted const
{
return _nameLen;
}
this(in char[] path) @trusted pure
{
enforce(path.length <= sun.sun_path.sizeof, new SocketParameterException("Path too long"));
sun.sun_family = AddressFamily.UNIX;
sun.sun_path.ptr[0 .. path.length] = (cast(byte[]) path)[];
_nameLen = cast(socklen_t)
{
auto len = sockaddr_un.init.sun_path.offsetof + path.length;
// Pathname socket address must be terminated with '\0'
// which must be included in the address length.
if (sun.sun_path.ptr[0])
{
sun.sun_path.ptr[path.length] = 0;
++len;
}
return len;
}();
}
this(sockaddr_un addr) pure nothrow @nogc
{
assert(addr.sun_family == AddressFamily.UNIX);
sun = addr;
}
@property string path() @trusted const pure
{
auto len = _nameLen - sockaddr_un.init.sun_path.offsetof;
// For pathname socket address we need to strip off the terminating '\0'
if (sun.sun_path.ptr[0])
--len;
return (cast(const(char)*) sun.sun_path.ptr)[0 .. len].idup;
}
override string toString() const pure
{
return path;
}
}
@safe unittest
{
import core.stdc.stdio : remove;
import std.file : deleteme;
immutable ubyte[] data = [1, 2, 3, 4];
Socket[2] pair;
auto names = [ deleteme ~ "-unix-socket" ];
version (linux)
names ~= "\0" ~ deleteme ~ "-abstract\0unix\0socket";
foreach (name; names)
{
auto address = new UnixAddress(name);
auto listener = new Socket(AddressFamily.UNIX, SocketType.STREAM);
scope(exit) listener.close();
listener.bind(address);
scope(exit) () @trusted { if (name[0]) remove(name.tempCString()); } ();
assert(listener.localAddress.toString == name);
listener.listen(1);
pair[0] = new Socket(AddressFamily.UNIX, SocketType.STREAM);
scope(exit) listener.close();
pair[0].connect(address);
scope(exit) pair[0].close();
pair[1] = listener.accept();
scope(exit) pair[1].close();
pair[0].send(data);
auto buf = new ubyte[data.length];
pair[1].receive(buf);
assert(buf == data);
}
}
}
/**
* Class for exceptions thrown by $(D Socket.accept).
*/
class SocketAcceptException: SocketOSException
{
mixin socketOSExceptionCtors;
}
/// How a socket is shutdown:
enum SocketShutdown: int
{
RECEIVE = SD_RECEIVE, /// socket receives are disallowed
SEND = SD_SEND, /// socket sends are disallowed
BOTH = SD_BOTH, /// both RECEIVE and SEND
}
/// Flags may be OR'ed together:
enum SocketFlags: int
{
NONE = 0, /// no flags specified
OOB = MSG_OOB, /// out-of-band stream data
PEEK = MSG_PEEK, /// peek at incoming data without removing it from the queue, only for receiving
DONTROUTE = MSG_DONTROUTE, /// data should not be subject to routing; this flag may be ignored. Only for sending
}
private mixin template FieldProxy(string target, string field)
{
mixin(`
@property typeof(`~target~`) `~field~`() const pure nothrow @nogc
{
return `~target~`;
}
/// ditto
@property typeof(`~target~`) `~field~`(typeof(`~target~`) value) pure nothrow @nogc
{
return `~target~` = value;
}
`);
}
/// Duration timeout value.
struct TimeVal
{
_ctimeval ctimeval;
alias tv_sec_t = typeof(ctimeval.tv_sec);
alias tv_usec_t = typeof(ctimeval.tv_usec);
version (StdDdoc) // no DDoc for string mixins, can't forward individual fields
{
tv_sec_t seconds; /// Number of _seconds.
tv_usec_t microseconds; /// Number of additional _microseconds.
}
else
{
// D interface
mixin FieldProxy!(`ctimeval.tv_sec`, `seconds`);
mixin FieldProxy!(`ctimeval.tv_usec`, `microseconds`);
}
}
/**
* A collection of sockets for use with $(D Socket.select).
*
* $(D SocketSet) wraps the platform $(D fd_set) type. However, unlike
* $(D fd_set), $(D SocketSet) is not statically limited to $(D FD_SETSIZE)
* or any other limit, and grows as needed.
*/
class SocketSet
{
private:
version (Windows)
{
// On Windows, fd_set is an array of socket handles,
// following a word containing the fd_set instance size.
// We use one dynamic array for everything, and use its first
// element(s) for the count.
alias fd_set_count_type = typeof(fd_set.init.fd_count);
alias fd_set_type = typeof(fd_set.init.fd_array[0]);
static assert(fd_set_type.sizeof == socket_t.sizeof);
// Number of fd_set_type elements at the start of our array that are
// used for the socket count and alignment
enum FD_SET_OFFSET = fd_set.fd_array.offsetof / fd_set_type.sizeof;
static assert(FD_SET_OFFSET);
static assert(fd_set.fd_count.offsetof % fd_set_type.sizeof == 0);
fd_set_type[] set;
void resize(size_t size) pure nothrow
{
set.length = FD_SET_OFFSET + size;
}
ref inout(fd_set_count_type) count() @trusted @property inout pure nothrow @nogc
{
assert(set.length);
return *cast(inout(fd_set_count_type)*)set.ptr;
}
size_t capacity() @property const pure nothrow @nogc
{
return set.length - FD_SET_OFFSET;
}
inout(socket_t)[] fds() @trusted inout @property pure nothrow @nogc
{
return cast(inout(socket_t)[])set[FD_SET_OFFSET .. FD_SET_OFFSET+count];
}
}
else
version (Posix)
{
// On Posix, fd_set is a bit array. We assume that the fd_set
// type (declared in core.sys.posix.sys.select) is a structure
// containing a single field, a static array.
static assert(fd_set.tupleof.length == 1);
// This is the type used in the fd_set array.
// Using the type of the correct size is important for big-endian
// architectures.
alias fd_set_type = typeof(fd_set.init.tupleof[0][0]);
// Number of file descriptors represented by one fd_set_type
enum FD_NFDBITS = 8 * fd_set_type.sizeof;
static fd_set_type mask(uint n) pure nothrow @nogc
{
return (cast(fd_set_type) 1) << (n % FD_NFDBITS);
}
// Array size to fit that many sockets
static size_t lengthFor(size_t size) pure nothrow @nogc
{
return (size + (FD_NFDBITS-1)) / FD_NFDBITS;
}
fd_set_type[] set;
void resize(size_t size) pure nothrow
{
set.length = lengthFor(size);
}
// Make sure we can fit that many sockets
void setMinCapacity(size_t size) pure nothrow
{
auto length = lengthFor(size);
if (set.length < length)
set.length = length;
}
size_t capacity() @property const pure nothrow @nogc
{
return set.length * FD_NFDBITS;
}
int maxfd;
}
else
static assert(false, "Unknown platform");
public:
/**
* Create a SocketSet with a specific initial capacity (defaults to
* $(D FD_SETSIZE), the system's default capacity).
*/
this(size_t size = FD_SETSIZE) pure nothrow
{
resize(size);
reset();
}
/// Reset the $(D SocketSet) so that there are 0 $(D Socket)s in the collection.
void reset() pure nothrow @nogc
{
version (Windows)
count = 0;
else
{
set[] = 0;
maxfd = -1;
}
}
void add(socket_t s) @trusted pure nothrow
{
version (Windows)
{
if (count == capacity)
{
set.length *= 2;
set.length = set.capacity;
}
++count;
fds[$-1] = s;
}
else
{
auto index = s / FD_NFDBITS;
auto length = set.length;
if (index >= length)
{
while (index >= length)
length *= 2;
set.length = length;
set.length = set.capacity;
}
set[index] |= mask(s);
if (maxfd < s)
maxfd = s;
}
}
/**
* Add a $(D Socket) to the collection.
* The socket must not already be in the collection.
*/
void add(Socket s) pure nothrow
{
add(s.sock);
}
void remove(socket_t s) pure nothrow
{
version (Windows)
{
import std.algorithm.searching : countUntil;
auto fds = fds;
auto p = fds.countUntil(s);
if (p >= 0)
fds[p] = fds[--count];
}
else
{
auto index = s / FD_NFDBITS;
if (index >= set.length)
return;
set[index] &= ~mask(s);
// note: adjusting maxfd would require scanning the set, not worth it
}
}
/**
* Remove this $(D Socket) from the collection.
* Does nothing if the socket is not in the collection already.
*/
void remove(Socket s) pure nothrow
{
remove(s.sock);
}
int isSet(socket_t s) const pure nothrow @nogc
{
version (Windows)
{
import std.algorithm.searching : canFind;
return fds.canFind(s) ? 1 : 0;
}
else
{
if (s > maxfd)
return 0;
auto index = s / FD_NFDBITS;
return (set[index] & mask(s)) ? 1 : 0;
}
}
/// Return nonzero if this $(D Socket) is in the collection.
int isSet(Socket s) const pure nothrow @nogc
{
return isSet(s.sock);
}
/**
* Returns:
* The current capacity of this $(D SocketSet). The exact
* meaning of the return value varies from platform to platform.
*
* Note:
* Since D 2.065, this value does not indicate a
* restriction, and $(D SocketSet) will grow its capacity as
* needed automatically.
*/
@property uint max() const pure nothrow @nogc
{
return cast(uint) capacity;
}
fd_set* toFd_set() @trusted pure nothrow @nogc
{
return cast(fd_set*) set.ptr;
}
int selectn() const pure nothrow @nogc
{
version (Windows)
{
return count;
}
else version (Posix)
{
return maxfd + 1;
}
}
}
@safe unittest
{
auto fds = cast(socket_t[])
[cast(socket_t) 1, 2, 0, 1024, 17, 42, 1234, 77, 77+32, 77+64];
auto set = new SocketSet();
foreach (fd; fds) assert(!set.isSet(fd));
foreach (fd; fds) set.add(fd);
foreach (fd; fds) assert(set.isSet(fd));
// Make sure SocketSet reimplements fd_set correctly
auto fdset = set.toFd_set();
foreach (fd; fds[0]..cast(socket_t)(fds[$-1]+1))
assert(cast(bool) set.isSet(fd) == cast(bool)(() @trusted => FD_ISSET(fd, fdset))());
foreach (fd; fds)
{
assert(set.isSet(fd));
set.remove(fd);
assert(!set.isSet(fd));
}
}
@safe unittest
{
softUnittest({
enum PAIRS = 768;
version(Posix)
() @trusted
{
enum LIMIT = 2048;
static assert(LIMIT > PAIRS*2);
import core.sys.posix.sys.resource;
rlimit fileLimit;
getrlimit(RLIMIT_NOFILE, &fileLimit);
assert(fileLimit.rlim_max > LIMIT, "Open file hard limit too low");
fileLimit.rlim_cur = LIMIT;
setrlimit(RLIMIT_NOFILE, &fileLimit);
} ();
Socket[2][PAIRS] pairs;
foreach (ref pair; pairs)
pair = socketPair();
scope(exit)
{
foreach (pair; pairs)
{
pair[0].close();
pair[1].close();
}
}
import std.random;
auto rng = Xorshift(42);
pairs[].randomShuffle(rng);
auto readSet = new SocketSet();
auto writeSet = new SocketSet();
auto errorSet = new SocketSet();
foreach (testPair; pairs)
{
void fillSets()
{
readSet.reset();
writeSet.reset();
errorSet.reset();
foreach (ref pair; pairs)
foreach (s; pair[])
{
readSet.add(s);
writeSet.add(s);
errorSet.add(s);
}
}
fillSets();
auto n = Socket.select(readSet, writeSet, errorSet);
assert(n == PAIRS*2); // All in writeSet
assert(writeSet.isSet(testPair[0]));
assert(writeSet.isSet(testPair[1]));
assert(!readSet.isSet(testPair[0]));
assert(!readSet.isSet(testPair[1]));
assert(!errorSet.isSet(testPair[0]));
assert(!errorSet.isSet(testPair[1]));
ubyte[1] b;
testPair[0].send(b[]);
fillSets();
n = Socket.select(readSet, null, null);
assert(n == 1); // testPair[1]
assert(readSet.isSet(testPair[1]));
assert(!readSet.isSet(testPair[0]));
testPair[1].receive(b[]);
}
});
}
@safe unittest // Issue 14012, 14013
{
auto set = new SocketSet(1);
assert(set.max >= 0);
enum LIMIT = 4096;
foreach (n; 0 .. LIMIT)
set.add(cast(socket_t) n);
assert(set.max >= LIMIT);
}
/// The level at which a socket option is defined:
enum SocketOptionLevel: int
{
SOCKET = SOL_SOCKET, /// Socket level
IP = ProtocolType.IP, /// Internet Protocol version 4 level
ICMP = ProtocolType.ICMP, /// Internet Control Message Protocol level
IGMP = ProtocolType.IGMP, /// Internet Group Management Protocol level
GGP = ProtocolType.GGP, /// Gateway to Gateway Protocol level
TCP = ProtocolType.TCP, /// Transmission Control Protocol level
PUP = ProtocolType.PUP, /// PARC Universal Packet Protocol level
UDP = ProtocolType.UDP, /// User Datagram Protocol level
IDP = ProtocolType.IDP, /// Xerox NS protocol level
RAW = ProtocolType.RAW, /// Raw IP packet level
IPV6 = ProtocolType.IPV6, /// Internet Protocol version 6 level
}
/// _Linger information for use with SocketOption.LINGER.
struct Linger
{
_clinger clinger;
version (StdDdoc) // no DDoc for string mixins, can't forward individual fields
{
private alias l_onoff_t = typeof(_clinger.init.l_onoff );
private alias l_linger_t = typeof(_clinger.init.l_linger);
l_onoff_t on; /// Nonzero for _on.
l_linger_t time; /// Linger _time.
}
else
{
// D interface
mixin FieldProxy!(`clinger.l_onoff`, `on`);
mixin FieldProxy!(`clinger.l_linger`, `time`);
}
}
/// Specifies a socket option:
enum SocketOption: int
{
DEBUG = SO_DEBUG, /// Record debugging information
BROADCAST = SO_BROADCAST, /// Allow transmission of broadcast messages
REUSEADDR = SO_REUSEADDR, /// Allow local reuse of address
LINGER = SO_LINGER, /// Linger on close if unsent data is present
OOBINLINE = SO_OOBINLINE, /// Receive out-of-band data in band
SNDBUF = SO_SNDBUF, /// Send buffer size
RCVBUF = SO_RCVBUF, /// Receive buffer size
DONTROUTE = SO_DONTROUTE, /// Do not route
SNDTIMEO = SO_SNDTIMEO, /// Send timeout
RCVTIMEO = SO_RCVTIMEO, /// Receive timeout
ERROR = SO_ERROR, /// Retrieve and clear error status
KEEPALIVE = SO_KEEPALIVE, /// Enable keep-alive packets
ACCEPTCONN = SO_ACCEPTCONN, /// Listen
RCVLOWAT = SO_RCVLOWAT, /// Minimum number of input bytes to process
SNDLOWAT = SO_SNDLOWAT, /// Minimum number of output bytes to process
TYPE = SO_TYPE, /// Socket type
// SocketOptionLevel.TCP:
TCP_NODELAY = .TCP_NODELAY, /// Disable the Nagle algorithm for send coalescing
// SocketOptionLevel.IPV6:
IPV6_UNICAST_HOPS = .IPV6_UNICAST_HOPS, /// IP unicast hop limit
IPV6_MULTICAST_IF = .IPV6_MULTICAST_IF, /// IP multicast interface
IPV6_MULTICAST_LOOP = .IPV6_MULTICAST_LOOP, /// IP multicast loopback
IPV6_MULTICAST_HOPS = .IPV6_MULTICAST_HOPS, /// IP multicast hops
IPV6_JOIN_GROUP = .IPV6_JOIN_GROUP, /// Add an IP group membership
IPV6_LEAVE_GROUP = .IPV6_LEAVE_GROUP, /// Drop an IP group membership
IPV6_V6ONLY = .IPV6_V6ONLY, /// Treat wildcard bind as AF_INET6-only
}
/**
* $(D Socket) is a class that creates a network communication endpoint using
* the Berkeley sockets interface.
*/
class Socket
{
private:
socket_t sock;
AddressFamily _family;
version(Windows)
bool _blocking = false; /// Property to get or set whether the socket is blocking or nonblocking.
// The WinSock timeouts seem to be effectively skewed by a constant
// offset of about half a second (value in milliseconds). This has
// been confirmed on updated (as of Jun 2011) Windows XP, Windows 7
// and Windows Server 2008 R2 boxes. The unittest below tests this
// behavior.
enum WINSOCK_TIMEOUT_SKEW = 500;
@safe unittest
{
version(SlowTests)
softUnittest({
import std.datetime.stopwatch;
import std.typecons;
enum msecs = 1000;
auto pair = socketPair();
auto sock = pair[0];
sock.setOption(SocketOptionLevel.SOCKET,
SocketOption.RCVTIMEO, dur!"msecs"(msecs));
auto sw = StopWatch(Yes.autoStart);
ubyte[1] buf;
sock.receive(buf);
sw.stop();
Duration readBack = void;
sock.getOption(SocketOptionLevel.SOCKET, SocketOption.RCVTIMEO, readBack);
assert(readBack.total!"msecs" == msecs);
assert(sw.peek().total!"msecs" > msecs - 100 && sw.peek().total!"msecs" < msecs + 100);
});
}
void setSock(socket_t handle)
{
assert(handle != socket_t.init);
sock = handle;
// Set the option to disable SIGPIPE on send() if the platform
// has it (e.g. on OS X).
static if (is(typeof(SO_NOSIGPIPE)))
{
setOption(SocketOptionLevel.SOCKET, cast(SocketOption) SO_NOSIGPIPE, true);
}
}
// For use with accepting().
protected this() pure nothrow @nogc
{
}
public:
/**
* Create a blocking socket. If a single protocol type exists to support
* this socket type within the address family, the $(D ProtocolType) may be
* omitted.
*/
this(AddressFamily af, SocketType type, ProtocolType protocol) @trusted
{
_family = af;
auto handle = cast(socket_t) socket(af, type, protocol);
if (handle == socket_t.init)
throw new SocketOSException("Unable to create socket");
setSock(handle);
}
/// ditto
this(AddressFamily af, SocketType type)
{
/* A single protocol exists to support this socket type within the
* protocol family, so the ProtocolType is assumed.
*/
this(af, type, cast(ProtocolType) 0); // Pseudo protocol number.
}
/// ditto
this(AddressFamily af, SocketType type, in char[] protocolName) @trusted
{
protoent* proto;
proto = getprotobyname(protocolName.tempCString());
if (!proto)
throw new SocketOSException("Unable to find the protocol");
this(af, type, cast(ProtocolType) proto.p_proto);
}
/**
* Create a blocking socket using the parameters from the specified
* $(D AddressInfo) structure.
*/
this(in AddressInfo info)
{
this(info.family, info.type, info.protocol);
}
/// Use an existing socket handle.
this(socket_t sock, AddressFamily af) pure nothrow @nogc
{
assert(sock != socket_t.init);
this.sock = sock;
this._family = af;
}
~this() nothrow @nogc
{
close();
}
/// Get underlying socket handle.
@property socket_t handle() const pure nothrow @nogc
{
return sock;
}
/**
* Get/set socket's blocking flag.
*
* When a socket is blocking, calls to receive(), accept(), and send()
* will block and wait for data/action.
* A non-blocking socket will immediately return instead of blocking.
*/
@property bool blocking() @trusted const nothrow @nogc
{
version(Windows)
{
return _blocking;
}
else version(Posix)
{
return !(fcntl(handle, F_GETFL, 0) & O_NONBLOCK);
}
}
/// ditto
@property void blocking(bool byes) @trusted
{
version(Windows)
{
uint num = !byes;
if (_SOCKET_ERROR == ioctlsocket(sock, FIONBIO, &num))
goto err;
_blocking = byes;
}
else version(Posix)
{
int x = fcntl(sock, F_GETFL, 0);
if (-1 == x)
goto err;
if (byes)
x &= ~O_NONBLOCK;
else
x |= O_NONBLOCK;
if (-1 == fcntl(sock, F_SETFL, x))
goto err;
}
return; // Success.
err:
throw new SocketOSException("Unable to set socket blocking");
}
/// Get the socket's address family.
@property AddressFamily addressFamily()
{
return _family;
}
/// Property that indicates if this is a valid, alive socket.
@property bool isAlive() @trusted const
{
int type;
socklen_t typesize = cast(socklen_t) type.sizeof;
return !getsockopt(sock, SOL_SOCKET, SO_TYPE, cast(char*)&type, &typesize);
}
/// Associate a local address with this socket.
void bind(Address addr) @trusted
{
if (_SOCKET_ERROR == .bind(sock, addr.name, addr.nameLen))
throw new SocketOSException("Unable to bind socket");
}
/**
* Establish a connection. If the socket is blocking, connect waits for
* the connection to be made. If the socket is nonblocking, connect
* returns immediately and the connection attempt is still in progress.
*/
void connect(Address to) @trusted
{
if (_SOCKET_ERROR == .connect(sock, to.name, to.nameLen))
{
int err;
err = _lasterr();
if (!blocking)
{
version(Windows)
{
if (WSAEWOULDBLOCK == err)
return;
}
else version(Posix)
{
if (EINPROGRESS == err)
return;
}
else
{
static assert(0);
}
}
throw new SocketOSException("Unable to connect socket", err);
}
}
/**
* Listen for an incoming connection. $(D bind) must be called before you
* can $(D listen). The $(D backlog) is a request of how many pending
* incoming connections are queued until $(D accept)ed.
*/
void listen(int backlog) @trusted
{
if (_SOCKET_ERROR == .listen(sock, backlog))
throw new SocketOSException("Unable to listen on socket");
}
/**
* Called by $(D accept) when a new $(D Socket) must be created for a new
* connection. To use a derived class, override this method and return an
* instance of your class. The returned $(D Socket)'s handle must not be
* set; $(D Socket) has a protected constructor $(D this()) to use in this
* situation.
*
* Override to use a derived class.
* The returned socket's handle must not be set.
*/
protected Socket accepting() pure nothrow
{
return new Socket;
}
/**
* Accept an incoming connection. If the socket is blocking, $(D accept)
* waits for a connection request. Throws $(D SocketAcceptException) if
* unable to _accept. See $(D accepting) for use with derived classes.
*/
Socket accept() @trusted
{
auto newsock = cast(socket_t).accept(sock, null, null);
if (socket_t.init == newsock)
throw new SocketAcceptException("Unable to accept socket connection");
Socket newSocket;
try
{
newSocket = accepting();
assert(newSocket.sock == socket_t.init);
newSocket.setSock(newsock);
version(Windows)
newSocket._blocking = _blocking; //inherits blocking mode
newSocket._family = _family; //same family
}
catch (Throwable o)
{
_close(newsock);
throw o;
}
return newSocket;
}
/// Disables sends and/or receives.
void shutdown(SocketShutdown how) @trusted nothrow @nogc
{
.shutdown(sock, cast(int) how);
}
private static void _close(socket_t sock) @system nothrow @nogc
{
version(Windows)
{
.closesocket(sock);
}
else version(Posix)
{
.close(sock);
}
}
/**
* Immediately drop any connections and release socket resources.
* Calling $(D shutdown) before $(D close) is recommended for
* connection-oriented sockets. The $(D Socket) object is no longer
* usable after $(D close).
* Calling shutdown() before this is recommended
* for connection-oriented sockets.
*/
void close() @trusted nothrow @nogc
{
_close(sock);
sock = socket_t.init;
}
/**
* Returns: the local machine's host name
*/
static @property string hostName() @trusted // getter
{
char[256] result; // Host names are limited to 255 chars.
if (_SOCKET_ERROR == .gethostname(result.ptr, result.length))
throw new SocketOSException("Unable to obtain host name");
return to!string(result.ptr);
}
/// Remote endpoint $(D Address).
@property Address remoteAddress() @trusted
{
Address addr = createAddress();
socklen_t nameLen = addr.nameLen;
if (_SOCKET_ERROR == .getpeername(sock, addr.name, &nameLen))
throw new SocketOSException("Unable to obtain remote socket address");
addr.setNameLen(nameLen);
assert(addr.addressFamily == _family);
return addr;
}
/// Local endpoint $(D Address).
@property Address localAddress() @trusted
{
Address addr = createAddress();
socklen_t nameLen = addr.nameLen;
if (_SOCKET_ERROR == .getsockname(sock, addr.name, &nameLen))
throw new SocketOSException("Unable to obtain local socket address");
addr.setNameLen(nameLen);
assert(addr.addressFamily == _family);
return addr;
}
/**
* Send or receive error code. See $(D wouldHaveBlocked),
* $(D lastSocketError) and $(D Socket.getErrorText) for obtaining more
* information about the error.
*/
enum int ERROR = _SOCKET_ERROR;
private static int capToInt(size_t size) nothrow @nogc
{
// Windows uses int instead of size_t for length arguments.
// Luckily, the send/recv functions make no guarantee that
// all the data is sent, so we use that to send at most
// int.max bytes.
return size > size_t(int.max) ? int.max : cast(int) size;
}
/**
* Send data on the connection. If the socket is blocking and there is no
* buffer space left, $(D send) waits.
* Returns: The number of bytes actually sent, or $(D Socket.ERROR) on
* failure.
*/
ptrdiff_t send(const(void)[] buf, SocketFlags flags) @trusted
{
static if (is(typeof(MSG_NOSIGNAL)))
{
flags = cast(SocketFlags)(flags | MSG_NOSIGNAL);
}
version( Windows )
auto sent = .send(sock, buf.ptr, capToInt(buf.length), cast(int) flags);
else
auto sent = .send(sock, buf.ptr, buf.length, cast(int) flags);
return sent;
}
/// ditto
ptrdiff_t send(const(void)[] buf)
{
return send(buf, SocketFlags.NONE);
}
/**
* 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, $(D sendTo) waits.
* Returns: The number of bytes actually sent, or $(D Socket.ERROR) on
* failure.
*/
ptrdiff_t sendTo(const(void)[] buf, SocketFlags flags, Address to) @trusted
{
static if (is(typeof(MSG_NOSIGNAL)))
{
flags = cast(SocketFlags)(flags | MSG_NOSIGNAL);
}
version( Windows )
return .sendto(
sock, buf.ptr, capToInt(buf.length),
cast(int) flags, to.name, to.nameLen
);
else
return .sendto(sock, buf.ptr, buf.length, cast(int) flags, to.name, to.nameLen);
}
/// ditto
ptrdiff_t sendTo(const(void)[] buf, Address to)
{
return sendTo(buf, SocketFlags.NONE, to);
}
//assumes you connect()ed
/// ditto
ptrdiff_t sendTo(const(void)[] buf, SocketFlags flags) @trusted
{
static if (is(typeof(MSG_NOSIGNAL)))
{
flags = cast(SocketFlags)(flags | MSG_NOSIGNAL);
}
version(Windows)
return .sendto(sock, buf.ptr, capToInt(buf.length), cast(int) flags, null, 0);
else
return .sendto(sock, buf.ptr, buf.length, cast(int) flags, null, 0);
}
//assumes you connect()ed
/// ditto
ptrdiff_t sendTo(const(void)[] buf)
{
return sendTo(buf, SocketFlags.NONE);
}
/**
* Receive data on the connection. If the socket is blocking, $(D receive)
* waits until there is data to be received.
* Returns: The number of bytes actually received, $(D 0) if the remote side
* has closed the connection, or $(D Socket.ERROR) on failure.
*/
ptrdiff_t receive(void[] buf, SocketFlags flags) @trusted
{
version(Windows) // Does not use size_t
{
return buf.length
? .recv(sock, buf.ptr, capToInt(buf.length), cast(int) flags)
: 0;
}
else
{
return buf.length
? .recv(sock, buf.ptr, buf.length, cast(int) flags)
: 0;
}
}
/// ditto
ptrdiff_t receive(void[] buf)
{
return receive(buf, SocketFlags.NONE);
}
/**
* Receive data and get the remote endpoint $(D Address).
* If the socket is blocking, $(D receiveFrom) waits until there is data to
* be received.
* Returns: The number of bytes actually received, $(D 0) if the remote side
* has closed the connection, or $(D Socket.ERROR) on failure.
*/
ptrdiff_t receiveFrom(void[] buf, SocketFlags flags, ref Address from) @trusted
{
if (!buf.length) //return 0 and don't think the connection closed
return 0;
if (from is null || from.addressFamily != _family)
from = createAddress();
socklen_t nameLen = from.nameLen;
version(Windows)
{
auto read = .recvfrom(sock, buf.ptr, capToInt(buf.length), cast(int) flags, from.name, &nameLen);
from.setNameLen(nameLen);
assert(from.addressFamily == _family);
// if (!read) //connection closed
return read;
}
else
{
auto read = .recvfrom(sock, buf.ptr, buf.length, cast(int) flags, from.name, &nameLen);
from.setNameLen(nameLen);
assert(from.addressFamily == _family);
// if (!read) //connection closed
return read;
}
}
/// ditto
ptrdiff_t receiveFrom(void[] buf, ref Address from)
{
return receiveFrom(buf, SocketFlags.NONE, from);
}
//assumes you connect()ed
/// ditto
ptrdiff_t receiveFrom(void[] buf, SocketFlags flags) @trusted
{
if (!buf.length) //return 0 and don't think the connection closed
return 0;
version(Windows)
{
auto read = .recvfrom(sock, buf.ptr, capToInt(buf.length), cast(int) flags, null, null);
// if (!read) //connection closed
return read;
}
else
{
auto read = .recvfrom(sock, buf.ptr, buf.length, cast(int) flags, null, null);
// if (!read) //connection closed
return read;
}
}
//assumes you connect()ed
/// ditto
ptrdiff_t receiveFrom(void[] buf)
{
return receiveFrom(buf, SocketFlags.NONE);
}
/**
* Get a socket option.
* Returns: The number of bytes written to $(D result).
* The length, in bytes, of the actual result - very different from getsockopt()
*/
int getOption(SocketOptionLevel level, SocketOption option, void[] result) @trusted
{
socklen_t len = cast(socklen_t) result.length;
if (_SOCKET_ERROR == .getsockopt(sock, cast(int) level, cast(int) option, result.ptr, &len))
throw new SocketOSException("Unable to get socket option");
return len;
}
/// Common case of getting integer and boolean options.
int getOption(SocketOptionLevel level, SocketOption option, out int32_t result) @trusted
{
return getOption(level, option, (&result)[0 .. 1]);
}
/// Get the linger option.
int getOption(SocketOptionLevel level, SocketOption option, out Linger result) @trusted
{
//return getOption(cast(SocketOptionLevel) SocketOptionLevel.SOCKET, SocketOption.LINGER, (&result)[0 .. 1]);
return getOption(level, option, (&result.clinger)[0 .. 1]);
}
/// Get a timeout (duration) option.
void getOption(SocketOptionLevel level, SocketOption option, out Duration result) @trusted
{
enforce(option == SocketOption.SNDTIMEO || option == SocketOption.RCVTIMEO,
new SocketParameterException("Not a valid timeout option: " ~ to!string(option)));
// WinSock returns the timeout values as a milliseconds DWORD,
// while Linux and BSD return a timeval struct.
version (Windows)
{
int msecs;
getOption(level, option, (&msecs)[0 .. 1]);
if (option == SocketOption.RCVTIMEO)
msecs += WINSOCK_TIMEOUT_SKEW;
result = dur!"msecs"(msecs);
}
else version (Posix)
{
TimeVal tv;
getOption(level, option, (&tv.ctimeval)[0 .. 1]);
result = dur!"seconds"(tv.seconds) + dur!"usecs"(tv.microseconds);
}
else static assert(false);
}
/// Set a socket option.
void setOption(SocketOptionLevel level, SocketOption option, void[] value) @trusted
{
if (_SOCKET_ERROR == .setsockopt(sock, cast(int) level,
cast(int) option, value.ptr, cast(uint) value.length))
throw new SocketOSException("Unable to set socket option");
}
/// Common case for setting integer and boolean options.
void setOption(SocketOptionLevel level, SocketOption option, int32_t value) @trusted
{
setOption(level, option, (&value)[0 .. 1]);
}
/// Set the linger option.
void setOption(SocketOptionLevel level, SocketOption option, Linger value) @trusted
{
//setOption(cast(SocketOptionLevel) SocketOptionLevel.SOCKET, SocketOption.LINGER, (&value)[0 .. 1]);
setOption(level, option, (&value.clinger)[0 .. 1]);
}
/**
* Sets a timeout (duration) option, i.e. $(D SocketOption.SNDTIMEO) or
* $(D RCVTIMEO). Zero indicates no timeout.
*
* In a typical application, you might also want to consider using
* a non-blocking socket instead of setting a timeout on a blocking one.
*
* Note: While the receive timeout setting is generally quite accurate
* on *nix systems even for smaller durations, there are two issues to
* be aware of on Windows: First, although undocumented, the effective
* timeout duration seems to be the one set on the socket plus half
* a second. $(D setOption()) tries to compensate for that, but still,
* timeouts under 500ms are not possible on Windows. Second, be aware
* that the actual amount of time spent until a blocking call returns
* randomly varies on the order of 10ms.
*
* Params:
* level = The level at which a socket option is defined.
* option = Either $(D SocketOption.SNDTIMEO) or $(D SocketOption.RCVTIMEO).
* value = The timeout duration to set. Must not be negative.
*
* Throws: $(D SocketException) if setting the options fails.
*
* Example:
* ---
* import std.datetime;
* import std.typecons;
* auto pair = socketPair();
* scope(exit) foreach (s; pair) s.close();
*
* // Set a receive timeout, and then wait at one end of
* // the socket pair, knowing that no data will arrive.
* pair[0].setOption(SocketOptionLevel.SOCKET,
* SocketOption.RCVTIMEO, dur!"seconds"(1));
*
* auto sw = StopWatch(Yes.autoStart);
* ubyte[1] buffer;
* pair[0].receive(buffer);
* writefln("Waited %s ms until the socket timed out.",
* sw.peek.msecs);
* ---
*/
void setOption(SocketOptionLevel level, SocketOption option, Duration value) @trusted
{
enforce(option == SocketOption.SNDTIMEO || option == SocketOption.RCVTIMEO,
new SocketParameterException("Not a valid timeout option: " ~ to!string(option)));
enforce(value >= dur!"hnsecs"(0), new SocketParameterException(
"Timeout duration must not be negative."));
version (Windows)
{
import std.algorithm.comparison : max;
auto msecs = to!int(value.total!"msecs");
if (msecs != 0 && option == SocketOption.RCVTIMEO)
msecs = max(1, msecs - WINSOCK_TIMEOUT_SKEW);
setOption(level, option, msecs);
}
else version (Posix)
{
_ctimeval tv;
value.split!("seconds", "usecs")(tv.tv_sec, tv.tv_usec);
setOption(level, option, (&tv)[0 .. 1]);
}
else static assert(false);
}
/**
* Get a text description of this socket's error status, and clear the
* socket's error status.
*/
string getErrorText()
{
int32_t error;
getOption(SocketOptionLevel.SOCKET, SocketOption.ERROR, error);
return formatSocketError(error);
}
/**
* Enables TCP keep-alive with the specified parameters.
*
* Params:
* time = Number of seconds with no activity until the first
* keep-alive packet is sent.
* interval = Number of seconds between when successive keep-alive
* packets are sent if no acknowledgement is received.
*
* Throws: $(D SocketOSException) if setting the options fails, or
* $(D SocketFeatureException) if setting keep-alive parameters is
* unsupported on the current platform.
*/
void setKeepAlive(int time, int interval) @trusted
{
version(Windows)
{
tcp_keepalive options;
options.onoff = 1;
options.keepalivetime = time * 1000;
options.keepaliveinterval = interval * 1000;
uint cbBytesReturned;
enforce(WSAIoctl(sock, SIO_KEEPALIVE_VALS,
&options, options.sizeof,
null, 0,
&cbBytesReturned, null, null) == 0,
new SocketOSException("Error setting keep-alive"));
}
else
static if (is(typeof(TCP_KEEPIDLE)) && is(typeof(TCP_KEEPINTVL)))
{
setOption(SocketOptionLevel.TCP, cast(SocketOption) TCP_KEEPIDLE, time);
setOption(SocketOptionLevel.TCP, cast(SocketOption) TCP_KEEPINTVL, interval);
setOption(SocketOptionLevel.SOCKET, SocketOption.KEEPALIVE, true);
}
else
throw new SocketFeatureException("Setting keep-alive options " ~
"is not supported on this platform");
}
/**
* Wait for a socket to change status. A wait timeout of $(REF Duration, core, time) or
* $(D TimeVal), may be specified; if a timeout is not specified or the
* $(D TimeVal) is $(D null), the maximum timeout is used. The $(D TimeVal)
* timeout has an unspecified value when $(D select) returns.
* Returns: The number of sockets with status changes, $(D 0) on timeout,
* or $(D -1) on interruption. If the return value is greater than $(D 0),
* the $(D SocketSets) are updated to only contain the sockets having status
* changes. For a connecting socket, a write status change means the
* connection is established and it's able to send. For a listening socket,
* a read status change means there is an incoming connection request and
* it's able to accept.
*
* `SocketSet`'s updated to include only those sockets which an event occured.
* 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.
*
* Returns:
* the number of events, 0 on timeout, or -1 on interruption
*/
static int select(SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, Duration timeout) @trusted
{
auto vals = timeout.split!("seconds", "usecs")();
TimeVal tv;
tv.seconds = cast(tv.tv_sec_t ) vals.seconds;
tv.microseconds = cast(tv.tv_usec_t) vals.usecs;
return select(checkRead, checkWrite, checkError, &tv);
}
/// ditto
//maximum timeout
static int select(SocketSet checkRead, SocketSet checkWrite, SocketSet checkError)
{
return select(checkRead, checkWrite, checkError, null);
}
/// Ditto
static int select(SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, TimeVal* timeout) @trusted
in
{
//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);
}
}
do
{
fd_set* fr, fw, fe;
int n = 0;
version(Windows)
{
// 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
{
if (checkRead)
{
fr = checkRead.toFd_set();
n = checkRead.selectn();
}
else
{
fr = null;
}
if (checkWrite)
{
fw = checkWrite.toFd_set();
int _n;
_n = checkWrite.selectn();
if (_n > n)
n = _n;
}
else
{
fw = null;
}
if (checkError)
{
fe = checkError.toFd_set();
int _n;
_n = checkError.selectn();
if (_n > n)
n = _n;
}
else
{
fe = null;
}
// Make sure the sets' capacity matches, to avoid select reading
// out of bounds just because one set was bigger than another
if (checkRead ) checkRead .setMinCapacity(n);
if (checkWrite) checkWrite.setMinCapacity(n);
if (checkError) checkError.setMinCapacity(n);
}
int result = .select(n, fr, fw, fe, &timeout.ctimeval);
version(Windows)
{
if (_SOCKET_ERROR == result && WSAGetLastError() == WSAEINTR)
return -1;
}
else version(Posix)
{
if (_SOCKET_ERROR == result && errno == EINTR)
return -1;
}
else
{
static assert(0);
}
if (_SOCKET_ERROR == result)
throw new SocketOSException("Socket select error");
return result;
}
/**
* Can be overridden to support other addresses.
* Returns: a new `Address` object for the current address family.
*/
protected Address createAddress() pure nothrow
{
Address result;
switch (_family)
{
static if (is(sockaddr_un))
{
case AddressFamily.UNIX:
result = new UnixAddress;
break;
}
case AddressFamily.INET:
result = new InternetAddress;
break;
case AddressFamily.INET6:
result = new Internet6Address;
break;
default:
result = new UnknownAddress;
}
return result;
}
}
/// $(D TcpSocket) is a shortcut class for a TCP Socket.
class TcpSocket: Socket
{
/// Constructs a blocking TCP Socket.
this(AddressFamily family)
{
super(family, SocketType.STREAM, ProtocolType.TCP);
}
/// Constructs a blocking IPv4 TCP Socket.
this()
{
this(AddressFamily.INET);
}
//shortcut
/// Constructs a blocking TCP Socket and connects to an $(D Address).
this(Address connectTo)
{
this(connectTo.addressFamily);
connect(connectTo);
}
}
/// $(D UdpSocket) is a shortcut class for a UDP Socket.
class UdpSocket: Socket
{
/// Constructs a blocking UDP Socket.
this(AddressFamily family)
{
super(family, SocketType.DGRAM, ProtocolType.UDP);
}
/// Constructs a blocking IPv4 UDP Socket.
this()
{
this(AddressFamily.INET);
}
}
// Issue 16514
@safe unittest
{
class TestSocket : Socket
{
override
{
const pure nothrow @nogc @property @safe socket_t handle() { assert(0); }
const nothrow @nogc @property @trusted bool blocking() { assert(0); }
@property @trusted void blocking(bool byes) { assert(0); }
@property @safe AddressFamily addressFamily() { assert(0); }
const @property @trusted bool isAlive() { assert(0); }
@trusted void bind(Address addr) { assert(0); }
@trusted void connect(Address to) { assert(0); }
@trusted void listen(int backlog) { assert(0); }
protected pure nothrow @safe Socket accepting() { assert(0); }
@trusted Socket accept() { assert(0); }
nothrow @nogc @trusted void shutdown(SocketShutdown how) { assert(0); }
nothrow @nogc @trusted void close() { assert(0); }
@property @trusted Address remoteAddress() { assert(0); }
@property @trusted Address localAddress() { assert(0); }
@trusted ptrdiff_t send(const(void)[] buf, SocketFlags flags) { assert(0); }
@safe ptrdiff_t send(const(void)[] buf) { assert(0); }
@trusted ptrdiff_t sendTo(const(void)[] buf, SocketFlags flags, Address to) { assert(0); }
@safe ptrdiff_t sendTo(const(void)[] buf, Address to) { assert(0); }
@trusted ptrdiff_t sendTo(const(void)[] buf, SocketFlags flags) { assert(0); }
@safe ptrdiff_t sendTo(const(void)[] buf) { assert(0); }
@trusted ptrdiff_t receive(void[] buf, SocketFlags flags) { assert(0); }
@safe ptrdiff_t receive(void[] buf) { assert(0); }
@trusted ptrdiff_t receiveFrom(void[] buf, SocketFlags flags, ref Address from) { assert(0); }
@safe ptrdiff_t receiveFrom(void[] buf, ref Address from) { assert(0); }
@trusted ptrdiff_t receiveFrom(void[] buf, SocketFlags flags) { assert(0); }
@safe ptrdiff_t receiveFrom(void[] buf) { assert(0); }
@trusted int getOption(SocketOptionLevel level, SocketOption option, void[] result) { assert(0); }
@trusted int getOption(SocketOptionLevel level, SocketOption option, out int32_t result) { assert(0); }
@trusted int getOption(SocketOptionLevel level, SocketOption option, out Linger result) { assert(0); }
@trusted void getOption(SocketOptionLevel level, SocketOption option, out Duration result) { assert(0); }
@trusted void setOption(SocketOptionLevel level, SocketOption option, void[] value) { assert(0); }
@trusted void setOption(SocketOptionLevel level, SocketOption option, int32_t value) { assert(0); }
@trusted void setOption(SocketOptionLevel level, SocketOption option, Linger value) { assert(0); }
@trusted void setOption(SocketOptionLevel level, SocketOption option, Duration value) { assert(0); }
@safe string getErrorText() { assert(0); }
@trusted void setKeepAlive(int time, int interval) { assert(0); }
protected pure nothrow @safe Address createAddress() { assert(0); }
}
}
}
/**
* Creates a pair of connected sockets.
*
* The two sockets are indistinguishable.
*
* Throws: $(D SocketException) if creation of the sockets fails.
*/
Socket[2] socketPair() @trusted
{
version(Posix)
{
int[2] socks;
if (socketpair(AF_UNIX, SOCK_STREAM, 0, socks) == -1)
throw new SocketOSException("Unable to create socket pair");
Socket toSocket(size_t id)
{
auto s = new Socket;
s.setSock(cast(socket_t) socks[id]);
s._family = AddressFamily.UNIX;
return s;
}
return [toSocket(0), toSocket(1)];
}
else version(Windows)
{
// We do not have socketpair() on Windows, just manually create a
// pair of sockets connected over some localhost port.
Socket[2] result;
auto listener = new TcpSocket();
listener.setOption(SocketOptionLevel.SOCKET, SocketOption.REUSEADDR, true);
listener.bind(new InternetAddress(INADDR_LOOPBACK, InternetAddress.PORT_ANY));
auto addr = listener.localAddress;
listener.listen(1);
result[0] = new TcpSocket(addr);
result[1] = listener.accept();
listener.close();
return result;
}
else
static assert(false);
}
///
@safe unittest
{
immutable ubyte[] data = [1, 2, 3, 4];
auto pair = socketPair();
scope(exit) foreach (s; pair) s.close();
pair[0].send(data);
auto buf = new ubyte[data.length];
pair[1].receive(buf);
assert(buf == data);
}
|
D
|
module android.java.java.nio.file.ReadOnlyFileSystemException;
public import android.java.java.nio.file.ReadOnlyFileSystemException_d_interface;
import arsd.jni : ImportExportImpl;
mixin ImportExportImpl!ReadOnlyFileSystemException;
import import4 = android.java.java.lang.Class;
import import3 = android.java.java.lang.StackTraceElement;
import import0 = android.java.java.lang.JavaThrowable;
|
D
|
func int C_NpcIsDown(var C_Npc slf)
{
if(Npc_IsInState(slf,ZS_Unconscious) || Npc_IsInState(slf,ZS_MagicSleep) || Npc_IsDead(slf))
{
return TRUE;
}
else
{
return FALSE;
};
};
|
D
|
/**
* Forms the symbols available to all D programs. Includes Object, which is
* the root of the class object hierarchy. This module is implicitly
* imported.
* Macros:
* WIKI = Object
*
* Copyright: Copyright Digital Mars 2000 - 2011.
* 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 - 2011.
* 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 object;
//debug=PRINTF;
private
{
import core.atomic;
import core.stdc.string;
import core.stdc.stdlib;
import rt.util.hash;
import rt.util.string;
import rt.util.console;
import rt.minfo;
debug(PRINTF) import core.stdc.stdio;
extern (C) void onOutOfMemoryError();
extern (C) Object _d_newclass(TypeInfo_Class ci);
extern (C) void _d_arrayshrinkfit(TypeInfo ti, void[] arr);
extern (C) size_t _d_arraysetcapacity(TypeInfo ti, size_t newcapacity, void *arrptr);
extern (C) void rt_finalize(void *data, bool det=true);
}
// NOTE: For some reason, this declaration method doesn't work
// in this particular file (and this file only). It must
// be a DMD thing.
//alias typeof(int.sizeof) size_t;
//alias typeof(cast(void*)0 - cast(void*)0) ptrdiff_t;
version(D_LP64)
{
alias ulong size_t;
alias long ptrdiff_t;
alias long sizediff_t;
}
else
{
alias uint size_t;
alias int ptrdiff_t;
alias int sizediff_t;
}
alias size_t hash_t;
alias bool equals_t;
alias immutable(char)[] string;
alias immutable(wchar)[] wstring;
alias immutable(dchar)[] dstring;
/**
* All D class objects inherit from Object.
*/
class Object
{
/**
* Convert Object to a human readable string.
*/
string toString()
{
return this.classinfo.name;
}
/**
* Compute hash function for Object.
*/
hash_t toHash()
{
// BUG: this prevents a compacting GC from working, needs to be fixed
return cast(hash_t)cast(void*)this;
}
/**
* Compare with another Object obj.
* Returns:
* $(TABLE
* $(TR $(TD this < obj) $(TD < 0))
* $(TR $(TD this == obj) $(TD 0))
* $(TR $(TD this > obj) $(TD > 0))
* )
*/
int opCmp(Object o)
{
// BUG: this prevents a compacting GC from working, needs to be fixed
//return cast(int)cast(void*)this - cast(int)cast(void*)o;
throw new Exception("need opCmp for class " ~ this.classinfo.name);
//return this !is o;
}
/**
* Returns !=0 if this object does have the same contents as obj.
*/
equals_t opEquals(Object o)
{
return this is o;
}
equals_t opEquals(Object lhs, Object rhs)
{
if (lhs is rhs)
return true;
if (lhs is null || rhs is null)
return false;
if (typeid(lhs) == typeid(rhs))
return lhs.opEquals(rhs);
return lhs.opEquals(rhs) &&
rhs.opEquals(lhs);
}
interface Monitor
{
void lock();
void unlock();
}
/**
* Create instance of class specified by classname.
* The class must either have no constructors or have
* a default constructor.
* Returns:
* null if failed
*/
static Object factory(string classname)
{
auto ci = TypeInfo_Class.find(classname);
if (ci)
{
return ci.create();
}
return null;
}
}
/************************
* Returns true if lhs and rhs are equal.
*/
bool opEquals(Object lhs, Object rhs)
{
// If aliased to the same object or both null => equal
if (lhs is rhs) return true;
// If either is null => non-equal
if (lhs is null || rhs is null) return false;
// If same exact type => one call to method opEquals
if (typeid(lhs) is typeid(rhs) || typeid(lhs).opEquals(typeid(rhs)))
return lhs.opEquals(rhs);
// General case => symmetric calls to method opEquals
return lhs.opEquals(rhs) && rhs.opEquals(lhs);
}
bool opEquals(TypeInfo lhs, TypeInfo rhs)
{
// If aliased to the same object or both null => equal
if (lhs is rhs) return true;
// If either is null => non-equal
if (lhs is null || rhs is null) return false;
// If same exact type => one call to method opEquals
if (typeid(lhs) == typeid(rhs)) return lhs.opEquals(rhs);
//printf("%.*s and %.*s, %d %d\n", lhs.toString(), rhs.toString(), lhs.opEquals(rhs), rhs.opEquals(lhs));
// Factor out top level const
// (This still isn't right, should follow same rules as compiler does for type equality.)
TypeInfo_Const c = cast(TypeInfo_Const) lhs;
if (c)
lhs = c.base;
c = cast(TypeInfo_Const) rhs;
if (c)
rhs = c.base;
// General case => symmetric calls to method opEquals
return lhs.opEquals(rhs) && rhs.opEquals(lhs);
}
/**
* Information about an interface.
* When an object is accessed via an interface, an Interface* appears as the
* first entry in its vtbl.
*/
struct Interface
{
TypeInfo_Class classinfo; /// .classinfo for this interface (not for containing class)
void*[] vtbl;
ptrdiff_t offset; /// offset to Interface 'this' from Object 'this'
}
/**
* Runtime type information about a class. Can be retrieved for any class type
* or instance by using the .classinfo property.
* A pointer to this appears as the first entry in the class's vtbl[].
*/
alias TypeInfo_Class Classinfo;
/**
* Array of pairs giving the offset and type information for each
* member in an aggregate.
*/
struct OffsetTypeInfo
{
size_t offset; /// Offset of member from start of object
TypeInfo ti; /// TypeInfo for this member
}
/**
* Runtime type information about a type.
* Can be retrieved for any type using a
* <a href="../expression.html#typeidexpression">TypeidExpression</a>.
*/
class TypeInfo
{
override hash_t toHash()
{
auto data = this.toString();
return hashOf(data.ptr, data.length);
}
override int opCmp(Object o)
{
if (this is o)
return 0;
TypeInfo ti = cast(TypeInfo)o;
if (ti is null)
return 1;
return dstrcmp(this.toString(), ti.toString());
}
override equals_t opEquals(Object o)
{
/* TypeInfo instances are singletons, but duplicates can exist
* across DLL's. Therefore, comparing for a name match is
* sufficient.
*/
if (this is o)
return true;
TypeInfo ti = cast(TypeInfo)o;
return ti && this.toString() == ti.toString();
}
/// Returns a hash of the instance of a type.
hash_t getHash(in void* p) { return cast(hash_t)p; }
/// Compares two instances for equality.
equals_t equals(in void* p1, in void* p2) { return p1 == p2; }
/// Compares two instances for <, ==, or >.
int compare(in void* p1, in void* p2) { return 0; }
/// Returns size of the type.
@property size_t tsize() nothrow pure { return 0; }
/// Swaps two instances of the type.
void swap(void* p1, void* p2)
{
size_t n = tsize;
for (size_t i = 0; i < n; i++)
{
byte t = (cast(byte *)p1)[i];
(cast(byte*)p1)[i] = (cast(byte*)p2)[i];
(cast(byte*)p2)[i] = t;
}
}
/// Get TypeInfo for 'next' type, as defined by what kind of type this is,
/// null if none.
@property TypeInfo next() nothrow pure { return null; }
/// Return default initializer. If the type should be initialized to all zeros,
/// an array with a null ptr and a length equal to the type size will be returned.
// TODO: make this a property, but may need to be renamed to diambiguate with T.init...
void[] init() nothrow pure { return null; }
/// Get flags for type: 1 means GC should scan for pointers
@property uint flags() nothrow pure { return 0; }
/// Get type information on the contents of the type; null if not available
OffsetTypeInfo[] offTi() { return null; }
/// Run the destructor on the object and all its sub-objects
void destroy(void* p) {}
/// Run the postblit on the object and all its sub-objects
void postblit(void* p) {}
/// Return alignment of type
@property size_t talign() nothrow pure { return tsize; }
/** Return internal info on arguments fitting into 8byte.
* See X86-64 ABI 3.2.3
*/
version (X86_64) int argTypes(out TypeInfo arg1, out TypeInfo arg2)
{ arg1 = this;
return 0;
}
}
class TypeInfo_Typedef : TypeInfo
{
override string toString() { return name; }
override equals_t opEquals(Object o)
{
TypeInfo_Typedef c;
return this is o ||
((c = cast(TypeInfo_Typedef)o) !is null &&
this.name == c.name &&
this.base == c.base);
}
override hash_t getHash(in void* p) { return base.getHash(p); }
override equals_t equals(in void* p1, in void* p2) { return base.equals(p1, p2); }
override int compare(in void* p1, in void* p2) { return base.compare(p1, p2); }
@property override size_t tsize() nothrow pure { return base.tsize; }
override void swap(void* p1, void* p2) { return base.swap(p1, p2); }
@property override TypeInfo next() nothrow pure { return base.next; }
@property override uint flags() nothrow pure { return base.flags; }
override void[] init() nothrow pure { return m_init.length ? m_init : base.init(); }
@property override size_t talign() nothrow pure { return base.talign; }
version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
{ return base.argTypes(arg1, arg2);
}
TypeInfo base;
string name;
void[] m_init;
}
class TypeInfo_Enum : TypeInfo_Typedef
{
}
class TypeInfo_Pointer : TypeInfo
{
override string toString() { return m_next.toString() ~ "*"; }
override equals_t opEquals(Object o)
{
TypeInfo_Pointer c;
return this is o ||
((c = cast(TypeInfo_Pointer)o) !is null &&
this.m_next == c.m_next);
}
override hash_t getHash(in void* p)
{
return cast(hash_t)*cast(void**)p;
}
override equals_t equals(in void* p1, in void* p2)
{
return *cast(void**)p1 == *cast(void**)p2;
}
override int compare(in void* p1, in void* p2)
{
if (*cast(void**)p1 < *cast(void**)p2)
return -1;
else if (*cast(void**)p1 > *cast(void**)p2)
return 1;
else
return 0;
}
@property override size_t tsize() nothrow pure
{
return (void*).sizeof;
}
override void swap(void* p1, void* p2)
{
void* tmp = *cast(void**)p1;
*cast(void**)p1 = *cast(void**)p2;
*cast(void**)p2 = tmp;
}
@property override TypeInfo next() nothrow pure { return m_next; }
@property override uint flags() nothrow pure { return 1; }
TypeInfo m_next;
}
class TypeInfo_Array : TypeInfo
{
override string toString() { return value.toString() ~ "[]"; }
override equals_t opEquals(Object o)
{
TypeInfo_Array c;
return this is o ||
((c = cast(TypeInfo_Array)o) !is null &&
this.value == c.value);
}
override hash_t getHash(in void* p)
{
void[] a = *cast(void[]*)p;
return hashOf(a.ptr, a.length);
}
override equals_t equals(in void* p1, in void* p2)
{
void[] a1 = *cast(void[]*)p1;
void[] a2 = *cast(void[]*)p2;
if (a1.length != a2.length)
return false;
size_t sz = value.tsize;
for (size_t i = 0; i < a1.length; i++)
{
if (!value.equals(a1.ptr + i * sz, a2.ptr + i * sz))
return false;
}
return true;
}
override int compare(in void* p1, in void* p2)
{
void[] a1 = *cast(void[]*)p1;
void[] a2 = *cast(void[]*)p2;
size_t sz = value.tsize;
size_t len = a1.length;
if (a2.length < len)
len = a2.length;
for (size_t u = 0; u < len; u++)
{
int result = value.compare(a1.ptr + u * sz, a2.ptr + u * sz);
if (result)
return result;
}
return cast(int)a1.length - cast(int)a2.length;
}
@property override size_t tsize() nothrow pure
{
return (void[]).sizeof;
}
override void swap(void* p1, void* p2)
{
void[] tmp = *cast(void[]*)p1;
*cast(void[]*)p1 = *cast(void[]*)p2;
*cast(void[]*)p2 = tmp;
}
TypeInfo value;
@property override TypeInfo next() nothrow pure
{
return value;
}
@property override uint flags() nothrow pure { return 1; }
@property override size_t talign() nothrow pure
{
return (void[]).alignof;
}
version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
{ //arg1 = typeid(size_t);
//arg2 = typeid(void*);
return 0;
}
}
class TypeInfo_StaticArray : TypeInfo
{
override string toString()
{
char[20] tmp = void;
return cast(string)(value.toString() ~ "[" ~ tmp.intToString(len) ~ "]");
}
override equals_t opEquals(Object o)
{
TypeInfo_StaticArray c;
return this is o ||
((c = cast(TypeInfo_StaticArray)o) !is null &&
this.len == c.len &&
this.value == c.value);
}
override hash_t getHash(in void* p)
{
size_t sz = value.tsize;
hash_t hash = 0;
for (size_t i = 0; i < len; i++)
hash += value.getHash(p + i * sz);
return hash;
}
override equals_t equals(in void* p1, in void* p2)
{
size_t sz = value.tsize;
for (size_t u = 0; u < len; u++)
{
if (!value.equals(p1 + u * sz, p2 + u * sz))
return false;
}
return true;
}
override int compare(in void* p1, in void* p2)
{
size_t sz = value.tsize;
for (size_t u = 0; u < len; u++)
{
int result = value.compare(p1 + u * sz, p2 + u * sz);
if (result)
return result;
}
return 0;
}
@property override size_t tsize() nothrow pure
{
return len * value.tsize;
}
override void swap(void* p1, void* p2)
{
void* tmp;
size_t sz = value.tsize;
ubyte[16] buffer;
void* pbuffer;
if (sz < buffer.sizeof)
tmp = buffer.ptr;
else
tmp = pbuffer = (new void[sz]).ptr;
for (size_t u = 0; u < len; u += sz)
{ size_t o = u * sz;
memcpy(tmp, p1 + o, sz);
memcpy(p1 + o, p2 + o, sz);
memcpy(p2 + o, tmp, sz);
}
if (pbuffer)
delete pbuffer;
}
override void[] init() nothrow pure { return value.init(); }
@property override TypeInfo next() nothrow pure { return value; }
@property override uint flags() nothrow pure { return value.flags(); }
override void destroy(void* p)
{
auto sz = value.tsize;
p += sz * len;
foreach (i; 0 .. len)
{
p -= sz;
value.destroy(p);
}
}
override void postblit(void* p)
{
auto sz = value.tsize;
foreach (i; 0 .. len)
{
value.postblit(p);
p += sz;
}
}
TypeInfo value;
size_t len;
@property override size_t talign() nothrow pure
{
return value.talign;
}
version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
{ arg1 = typeid(void*);
return 0;
}
}
class TypeInfo_AssociativeArray : TypeInfo
{
override string toString()
{
return cast(string)(next.toString() ~ "[" ~ key.toString() ~ "]");
}
override equals_t opEquals(Object o)
{
TypeInfo_AssociativeArray c;
return this is o ||
((c = cast(TypeInfo_AssociativeArray)o) !is null &&
this.key == c.key &&
this.value == c.value);
}
// BUG: need to add the rest of the functions
@property override size_t tsize() nothrow pure
{
return (char[int]).sizeof;
}
@property override TypeInfo next() nothrow pure { return value; }
@property override uint flags() nothrow pure { return 1; }
TypeInfo value;
TypeInfo key;
TypeInfo impl;
@property override size_t talign() nothrow pure
{
return (char[int]).alignof;
}
version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
{ arg1 = typeid(void*);
return 0;
}
}
class TypeInfo_Function : TypeInfo
{
override string toString()
{
return cast(string)(next.toString() ~ "()");
}
override equals_t opEquals(Object o)
{
TypeInfo_Function c;
return this is o ||
((c = cast(TypeInfo_Function)o) !is null &&
this.deco == c.deco);
}
// BUG: need to add the rest of the functions
@property override size_t tsize() nothrow pure
{
return 0; // no size for functions
}
TypeInfo next;
string deco;
}
class TypeInfo_Delegate : TypeInfo
{
override string toString()
{
return cast(string)(next.toString() ~ " delegate()");
}
override equals_t opEquals(Object o)
{
TypeInfo_Delegate c;
return this is o ||
((c = cast(TypeInfo_Delegate)o) !is null &&
this.deco == c.deco);
}
// BUG: need to add the rest of the functions
@property override size_t tsize() nothrow pure
{
alias int delegate() dg;
return dg.sizeof;
}
@property override uint flags() nothrow pure { return 1; }
TypeInfo next;
string deco;
@property override size_t talign() nothrow pure
{ alias int delegate() dg;
return dg.alignof;
}
version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
{ //arg1 = typeid(void*);
//arg2 = typeid(void*);
return 0;
}
}
/**
* Runtime type information about a class.
* Can be retrieved from an object instance by using the
* $(LINK2 ../property.html#classinfo, .classinfo) property.
*/
class TypeInfo_Class : TypeInfo
{
override string toString() { return info.name; }
override equals_t opEquals(Object o)
{
TypeInfo_Class c;
return this is o ||
((c = cast(TypeInfo_Class)o) !is null &&
this.info.name == c.info.name);
}
override hash_t getHash(in void* p)
{
Object o = *cast(Object*)p;
return o ? o.toHash() : 0;
}
override equals_t equals(in void* p1, in void* p2)
{
Object o1 = *cast(Object*)p1;
Object o2 = *cast(Object*)p2;
return (o1 is o2) || (o1 && o1.opEquals(o2));
}
override int compare(in void* p1, in void* p2)
{
Object o1 = *cast(Object*)p1;
Object o2 = *cast(Object*)p2;
int c = 0;
// Regard null references as always being "less than"
if (o1 !is o2)
{
if (o1)
{
if (!o2)
c = 1;
else
c = o1.opCmp(o2);
}
else
c = -1;
}
return c;
}
@property override size_t tsize() nothrow pure
{
return Object.sizeof;
}
@property override uint flags() nothrow pure { return 1; }
@property override OffsetTypeInfo[] offTi() nothrow pure
{
return m_offTi;
}
@property TypeInfo_Class info() nothrow pure { return this; }
@property TypeInfo typeinfo() nothrow pure { return this; }
byte[] init; /** class static initializer
* (init.length gives size in bytes of class)
*/
string name; /// class name
void*[] vtbl; /// virtual function pointer table
Interface[] interfaces; /// interfaces this class implements
TypeInfo_Class base; /// base class
void* destructor;
void function(Object) classInvariant;
uint m_flags;
// 1: // is IUnknown or is derived from IUnknown
// 2: // has no possible pointers into GC memory
// 4: // has offTi[] member
// 8: // has constructors
// 16: // has xgetMembers member
// 32: // has typeinfo member
// 64: // is not constructable
void* deallocator;
OffsetTypeInfo[] m_offTi;
void function(Object) defaultConstructor; // default Constructor
const(MemberInfo[]) function(in char[]) xgetMembers;
/**
* Search all modules for TypeInfo_Class corresponding to classname.
* Returns: null if not found
*/
static TypeInfo_Class find(in char[] classname)
{
foreach (m; ModuleInfo)
{
if (m)
//writefln("module %s, %d", m.name, m.localClasses.length);
foreach (c; m.localClasses)
{
//writefln("\tclass %s", c.name);
if (c.name == classname)
return c;
}
}
return null;
}
/**
* Create instance of Object represented by 'this'.
*/
Object create()
{
if (m_flags & 8 && !defaultConstructor)
return null;
if (m_flags & 64) // abstract
return null;
Object o = _d_newclass(this);
if (m_flags & 8 && defaultConstructor)
{
defaultConstructor(o);
}
return o;
}
/**
* Search for all members with the name 'name'.
* If name[] is null, return all members.
*/
const(MemberInfo[]) getMembers(in char[] name)
{
if (m_flags & 16 && xgetMembers)
return xgetMembers(name);
return null;
}
}
alias TypeInfo_Class ClassInfo;
class TypeInfo_Interface : TypeInfo
{
override string toString() { return info.name; }
override equals_t opEquals(Object o)
{
TypeInfo_Interface c;
return this is o ||
((c = cast(TypeInfo_Interface)o) !is null &&
this.info.name == c.classinfo.name);
}
override hash_t getHash(in void* p)
{
Interface* pi = **cast(Interface ***)*cast(void**)p;
Object o = cast(Object)(*cast(void**)p - pi.offset);
assert(o);
return o.toHash();
}
override equals_t equals(in void* p1, in void* p2)
{
Interface* pi = **cast(Interface ***)*cast(void**)p1;
Object o1 = cast(Object)(*cast(void**)p1 - pi.offset);
pi = **cast(Interface ***)*cast(void**)p2;
Object o2 = cast(Object)(*cast(void**)p2 - pi.offset);
return o1 == o2 || (o1 && o1.opCmp(o2) == 0);
}
override int compare(in void* p1, in void* p2)
{
Interface* pi = **cast(Interface ***)*cast(void**)p1;
Object o1 = cast(Object)(*cast(void**)p1 - pi.offset);
pi = **cast(Interface ***)*cast(void**)p2;
Object o2 = cast(Object)(*cast(void**)p2 - pi.offset);
int c = 0;
// Regard null references as always being "less than"
if (o1 != o2)
{
if (o1)
{
if (!o2)
c = 1;
else
c = o1.opCmp(o2);
}
else
c = -1;
}
return c;
}
@property override size_t tsize() nothrow pure
{
return Object.sizeof;
}
@property override uint flags() nothrow pure { return 1; }
TypeInfo_Class info;
}
class TypeInfo_Struct : TypeInfo
{
override string toString() { return name; }
override equals_t opEquals(Object o)
{
TypeInfo_Struct s;
return this is o ||
((s = cast(TypeInfo_Struct)o) !is null &&
this.name == s.name &&
this.init().length == s.init().length);
}
override hash_t getHash(in void* p)
{
assert(p);
if (xtoHash)
{
debug(PRINTF) printf("getHash() using xtoHash\n");
return (*xtoHash)(p);
}
else
{
debug(PRINTF) printf("getHash() using default hash\n");
return hashOf(p, init().length);
}
}
override equals_t equals(in void* p1, in void* p2)
{
if (!p1 || !p2)
return false;
else if (xopEquals)
return (*xopEquals)(p1, p2);
else if (p1 == p2)
return true;
else
// BUG: relies on the GC not moving objects
return memcmp(p1, p2, init().length) == 0;
}
override int compare(in void* p1, in void* p2)
{
// Regard null references as always being "less than"
if (p1 != p2)
{
if (p1)
{
if (!p2)
return true;
else if (xopCmp)
return (*xopCmp)(p2, p1);
else
// BUG: relies on the GC not moving objects
return memcmp(p1, p2, init().length);
}
else
return -1;
}
return 0;
}
@property override size_t tsize() nothrow pure
{
return init().length;
}
override void[] init() nothrow pure { return m_init; }
@property override uint flags() nothrow pure { return m_flags; }
@property override size_t talign() nothrow pure { return m_align; }
override void destroy(void* p)
{
if (xdtor)
(*xdtor)(p);
}
override void postblit(void* p)
{
if (xpostblit)
(*xpostblit)(p);
}
string name;
void[] m_init; // initializer; init.ptr == null if 0 initialize
hash_t function(in void*) xtoHash;
equals_t function(in void*, in void*) xopEquals;
int function(in void*, in void*) xopCmp;
char[] function(in void*) xtoString;
uint m_flags;
const(MemberInfo[]) function(in char[]) xgetMembers;
void function(void*) xdtor;
void function(void*) xpostblit;
uint m_align;
version (X86_64)
{
override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
{ arg1 = m_arg1;
arg2 = m_arg2;
return 0;
}
TypeInfo m_arg1;
TypeInfo m_arg2;
}
}
unittest
{
struct S
{
const bool opEquals(ref const S rhs)
{
return false;
}
}
S s;
assert(!typeid(S).equals(&s, &s));
}
class TypeInfo_Tuple : TypeInfo
{
TypeInfo[] elements;
override string toString()
{
string s = "(";
foreach (i, element; elements)
{
if (i)
s ~= ',';
s ~= element.toString();
}
s ~= ")";
return s;
}
override equals_t opEquals(Object o)
{
if (this is o)
return true;
auto t = cast(TypeInfo_Tuple)o;
if (t && elements.length == t.elements.length)
{
for (size_t i = 0; i < elements.length; i++)
{
if (elements[i] != t.elements[i])
return false;
}
return true;
}
return false;
}
override hash_t getHash(in void* p)
{
assert(0);
}
override equals_t equals(in void* p1, in void* p2)
{
assert(0);
}
override int compare(in void* p1, in void* p2)
{
assert(0);
}
@property override size_t tsize() nothrow pure
{
assert(0);
}
override void swap(void* p1, void* p2)
{
assert(0);
}
override void destroy(void* p)
{
assert(0);
}
override void postblit(void* p)
{
assert(0);
}
@property override size_t talign() nothrow pure
{
assert(0);
}
version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
{
assert(0);
}
}
class TypeInfo_Const : TypeInfo
{
override string toString()
{
return cast(string) ("const(" ~ base.toString() ~ ")");
}
//override equals_t opEquals(Object o) { return base.opEquals(o); }
override equals_t opEquals(Object o)
{
if (this is o)
return true;
if (typeid(this) != typeid(o))
return false;
auto t = cast(TypeInfo_Const)o;
if (base.opEquals(t.base))
{
return true;
}
return false;
}
override hash_t getHash(in void *p) { return base.getHash(p); }
override equals_t equals(in void *p1, in void *p2) { return base.equals(p1, p2); }
override int compare(in void *p1, in void *p2) { return base.compare(p1, p2); }
@property override size_t tsize() nothrow pure { return base.tsize; }
override void swap(void *p1, void *p2) { return base.swap(p1, p2); }
@property override TypeInfo next() nothrow pure { return base.next; }
@property override uint flags() nothrow pure { return base.flags; }
override void[] init() nothrow pure { return base.init(); }
@property override size_t talign() nothrow pure { return base.talign(); }
version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
{ return base.argTypes(arg1, arg2);
}
TypeInfo base;
}
class TypeInfo_Invariant : TypeInfo_Const
{
override string toString()
{
return cast(string) ("immutable(" ~ base.toString() ~ ")");
}
}
class TypeInfo_Shared : TypeInfo_Const
{
override string toString()
{
return cast(string) ("shared(" ~ base.toString() ~ ")");
}
}
class TypeInfo_Inout : TypeInfo_Const
{
override string toString()
{
return cast(string) ("inout(" ~ base.toString() ~ ")");
}
}
abstract class MemberInfo
{
@property string name() nothrow pure;
}
class MemberInfo_field : MemberInfo
{
this(string name, TypeInfo ti, size_t offset)
{
m_name = name;
m_typeinfo = ti;
m_offset = offset;
}
@property override string name() nothrow pure { return m_name; }
@property TypeInfo typeInfo() nothrow pure { return m_typeinfo; }
@property size_t offset() nothrow pure { return m_offset; }
string m_name;
TypeInfo m_typeinfo;
size_t m_offset;
}
class MemberInfo_function : MemberInfo
{
this(string name, TypeInfo ti, void* fp, uint flags)
{
m_name = name;
m_typeinfo = ti;
m_fp = fp;
m_flags = flags;
}
@property override string name() nothrow pure { return m_name; }
@property TypeInfo typeInfo() nothrow pure { return m_typeinfo; }
@property void* fp() nothrow pure { return m_fp; }
@property uint flags() nothrow pure { return m_flags; }
string m_name;
TypeInfo m_typeinfo;
void* m_fp;
uint m_flags;
}
///////////////////////////////////////////////////////////////////////////////
// Throwable
///////////////////////////////////////////////////////////////////////////////
class Throwable : Object
{
interface TraceInfo
{
int opApply(scope int delegate(ref char[]));
int opApply(scope int delegate(ref size_t, ref char[]));
string toString();
}
string msg;
string file;
size_t line;
TraceInfo info;
Throwable next;
this(string msg, Throwable next = null)
{
this.msg = msg;
this.next = next;
//this.info = _d_traceContext();
}
this(string msg, string file, size_t line, Throwable next = null)
{
this(msg, next);
this.file = file;
this.line = line;
//this.info = _d_traceContext();
}
override string toString()
{
char[20] tmp = void;
char[] buf;
if (file)
{
buf ~= this.classinfo.name ~ "@" ~ file ~ "(" ~ tmp.intToString(line) ~ ")";
}
else
{
buf ~= this.classinfo.name;
}
if (msg)
{
buf ~= ": " ~ msg;
}
if (info)
{
buf ~= "\n----------------";
foreach (t; info)
buf ~= "\n" ~ t;
}
return cast(string) buf;
}
}
alias Throwable.TraceInfo function(void* ptr) TraceHandler;
private __gshared TraceHandler traceHandler = null;
/**
* Overrides the default trace hander with a user-supplied version.
*
* Params:
* h = The new trace handler. Set to null to use the default handler.
*/
extern (C) void rt_setTraceHandler(TraceHandler h)
{
traceHandler = h;
}
/**
* Return the current trace handler
*/
extern (C) TraceHandler rt_getTraceHandler()
{
return traceHandler;
}
/**
* This function will be called when an exception is constructed. The
* user-supplied trace handler will be called if one has been supplied,
* otherwise no trace will be generated.
*
* Params:
* ptr = A pointer to the location from which to generate the trace, or null
* if the trace should be generated from within the trace handler
* itself.
*
* Returns:
* An object describing the current calling context or null if no handler is
* supplied.
*/
extern (C) Throwable.TraceInfo _d_traceContext(void* ptr = null)
{
if (traceHandler is null)
return null;
return traceHandler(ptr);
}
class Exception : Throwable
{
this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null)
{
super(msg, file, line, next);
}
this(string msg, Throwable next, string file = __FILE__, size_t line = __LINE__)
{
super(msg, file, line, next);
}
}
unittest
{
{
auto e = new Exception("msg");
assert(e.file == __FILE__);
assert(e.line == __LINE__ - 2);
assert(e.next is null);
assert(e.msg == "msg");
}
{
auto e = new Exception("msg", new Exception("It's an Excepton!"), "hello", 42);
assert(e.file == "hello");
assert(e.line == 42);
assert(e.next !is null);
assert(e.msg == "msg");
}
{
auto e = new Exception("msg", "hello", 42, new Exception("It's an Exception!"));
assert(e.file == "hello");
assert(e.line == 42);
assert(e.next !is null);
assert(e.msg == "msg");
}
}
class Error : Throwable
{
this(string msg, Throwable next = null)
{
super(msg, next);
bypassedException = null;
}
this(string msg, string file, size_t line, Throwable next = null)
{
super(msg, file, line, next);
bypassedException = null;
}
/// The first Exception which was bypassed when this Error was thrown,
/// or null if no Exceptions were pending.
Throwable bypassedException;
}
unittest
{
{
auto e = new Error("msg");
assert(e.file is null);
assert(e.line == 0);
assert(e.next is null);
assert(e.msg == "msg");
assert(e.bypassedException is null);
}
{
auto e = new Error("msg", new Exception("It's an Excepton!"));
assert(e.file is null);
assert(e.line == 0);
assert(e.next !is null);
assert(e.msg == "msg");
assert(e.bypassedException is null);
}
{
auto e = new Error("msg", "hello", 42, new Exception("It's an Exception!"));
assert(e.file == "hello");
assert(e.line == 42);
assert(e.next !is null);
assert(e.msg == "msg");
assert(e.bypassedException is null);
}
}
///////////////////////////////////////////////////////////////////////////////
// ModuleInfo
///////////////////////////////////////////////////////////////////////////////
enum
{
MIctorstart = 1, // we've started constructing it
MIctordone = 2, // finished construction
MIstandalone = 4, // module ctor does not depend on other module
// ctors being done first
MItlsctor = 8,
MItlsdtor = 0x10,
MIctor = 0x20,
MIdtor = 0x40,
MIxgetMembers = 0x80,
MIictor = 0x100,
MIunitTest = 0x200,
MIimportedModules = 0x400,
MIlocalClasses = 0x800,
MInew = 0x80000000 // it's the "new" layout
}
struct ModuleInfo
{
struct New
{
uint flags;
uint index; // index into _moduleinfo_array[]
/* Order of appearance, depending on flags
* tlsctor
* tlsdtor
* xgetMembers
* ctor
* dtor
* ictor
* importedModules
* localClasses
* name
*/
}
struct Old
{
string name;
ModuleInfo*[] importedModules;
TypeInfo_Class[] localClasses;
uint flags;
void function() ctor; // module shared static constructor (order dependent)
void function() dtor; // module shared static destructor
void function() unitTest; // module unit tests
void* xgetMembers; // module getMembers() function
void function() ictor; // module shared static constructor (order independent)
void function() tlsctor; // module thread local static constructor (order dependent)
void function() tlsdtor; // module thread local static destructor
uint index; // index into _moduleinfo_array[]
void*[1] reserved; // for future expansion
}
union
{
New n;
Old o;
}
@property bool isNew() nothrow pure { return (n.flags & MInew) != 0; }
@property uint index() nothrow pure { return isNew ? n.index : o.index; }
@property void index(uint i) nothrow pure { if (isNew) n.index = i; else o.index = i; }
@property uint flags() nothrow pure { return isNew ? n.flags : o.flags; }
@property void flags(uint f) nothrow pure { if (isNew) n.flags = f; else o.flags = f; }
@property void function() tlsctor() nothrow pure
{
if (isNew)
{
if (n.flags & MItlsctor)
{
size_t off = New.sizeof;
return *cast(typeof(return)*)(cast(void*)(&this) + off);
}
return null;
}
else
return o.tlsctor;
}
@property void function() tlsdtor() nothrow pure
{
if (isNew)
{
if (n.flags & MItlsdtor)
{
size_t off = New.sizeof;
if (n.flags & MItlsctor)
off += o.tlsctor.sizeof;
return *cast(typeof(return)*)(cast(void*)(&this) + off);
}
return null;
}
else
return o.tlsdtor;
}
@property void* xgetMembers() nothrow pure
{
if (isNew)
{
if (n.flags & MIxgetMembers)
{
size_t off = New.sizeof;
if (n.flags & MItlsctor)
off += o.tlsctor.sizeof;
if (n.flags & MItlsdtor)
off += o.tlsdtor.sizeof;
return *cast(typeof(return)*)(cast(void*)(&this) + off);
}
return null;
}
return o.xgetMembers;
}
@property void function() ctor() nothrow pure
{
if (isNew)
{
if (n.flags & MIctor)
{
size_t off = New.sizeof;
if (n.flags & MItlsctor)
off += o.tlsctor.sizeof;
if (n.flags & MItlsdtor)
off += o.tlsdtor.sizeof;
if (n.flags & MIxgetMembers)
off += o.xgetMembers.sizeof;
return *cast(typeof(return)*)(cast(void*)(&this) + off);
}
return null;
}
return o.ctor;
}
@property void function() dtor() nothrow pure
{
if (isNew)
{
if (n.flags & MIdtor)
{
size_t off = New.sizeof;
if (n.flags & MItlsctor)
off += o.tlsctor.sizeof;
if (n.flags & MItlsdtor)
off += o.tlsdtor.sizeof;
if (n.flags & MIxgetMembers)
off += o.xgetMembers.sizeof;
if (n.flags & MIctor)
off += o.ctor.sizeof;
return *cast(typeof(return)*)(cast(void*)(&this) + off);
}
return null;
}
return o.ctor;
}
@property void function() ictor() nothrow pure
{
if (isNew)
{
if (n.flags & MIictor)
{
size_t off = New.sizeof;
if (n.flags & MItlsctor)
off += o.tlsctor.sizeof;
if (n.flags & MItlsdtor)
off += o.tlsdtor.sizeof;
if (n.flags & MIxgetMembers)
off += o.xgetMembers.sizeof;
if (n.flags & MIctor)
off += o.ctor.sizeof;
if (n.flags & MIdtor)
off += o.ctor.sizeof;
return *cast(typeof(return)*)(cast(void*)(&this) + off);
}
return null;
}
return o.ictor;
}
@property void function() unitTest() nothrow pure
{
if (isNew)
{
if (n.flags & MIunitTest)
{
size_t off = New.sizeof;
if (n.flags & MItlsctor)
off += o.tlsctor.sizeof;
if (n.flags & MItlsdtor)
off += o.tlsdtor.sizeof;
if (n.flags & MIxgetMembers)
off += o.xgetMembers.sizeof;
if (n.flags & MIctor)
off += o.ctor.sizeof;
if (n.flags & MIdtor)
off += o.ctor.sizeof;
if (n.flags & MIictor)
off += o.ictor.sizeof;
return *cast(typeof(return)*)(cast(void*)(&this) + off);
}
return null;
}
return o.unitTest;
}
@property ModuleInfo*[] importedModules() nothrow pure
{
if (isNew)
{
if (n.flags & MIimportedModules)
{
size_t off = New.sizeof;
if (n.flags & MItlsctor)
off += o.tlsctor.sizeof;
if (n.flags & MItlsdtor)
off += o.tlsdtor.sizeof;
if (n.flags & MIxgetMembers)
off += o.xgetMembers.sizeof;
if (n.flags & MIctor)
off += o.ctor.sizeof;
if (n.flags & MIdtor)
off += o.ctor.sizeof;
if (n.flags & MIictor)
off += o.ictor.sizeof;
if (n.flags & MIunitTest)
off += o.unitTest.sizeof;
auto plength = cast(size_t*)(cast(void*)(&this) + off);
ModuleInfo** pm = cast(ModuleInfo**)(plength + 1);
return pm[0 .. *plength];
}
return null;
}
return o.importedModules;
}
@property TypeInfo_Class[] localClasses() nothrow pure
{
if (isNew)
{
if (n.flags & MIlocalClasses)
{
size_t off = New.sizeof;
if (n.flags & MItlsctor)
off += o.tlsctor.sizeof;
if (n.flags & MItlsdtor)
off += o.tlsdtor.sizeof;
if (n.flags & MIxgetMembers)
off += o.xgetMembers.sizeof;
if (n.flags & MIctor)
off += o.ctor.sizeof;
if (n.flags & MIdtor)
off += o.ctor.sizeof;
if (n.flags & MIictor)
off += o.ictor.sizeof;
if (n.flags & MIunitTest)
off += o.unitTest.sizeof;
if (n.flags & MIimportedModules)
{
auto plength = cast(size_t*)(cast(void*)(&this) + off);
off += size_t.sizeof + *plength * plength.sizeof;
}
auto plength = cast(size_t*)(cast(void*)(&this) + off);
TypeInfo_Class* pt = cast(TypeInfo_Class*)(plength + 1);
return pt[0 .. *plength];
}
return null;
}
return o.localClasses;
}
@property string name() nothrow pure
{
if (isNew)
{
size_t off = New.sizeof;
if (n.flags & MItlsctor)
off += o.tlsctor.sizeof;
if (n.flags & MItlsdtor)
off += o.tlsdtor.sizeof;
if (n.flags & MIxgetMembers)
off += o.xgetMembers.sizeof;
if (n.flags & MIctor)
off += o.ctor.sizeof;
if (n.flags & MIdtor)
off += o.ctor.sizeof;
if (n.flags & MIictor)
off += o.ictor.sizeof;
if (n.flags & MIunitTest)
off += o.unitTest.sizeof;
if (n.flags & MIimportedModules)
{
auto plength = cast(size_t*)(cast(void*)(&this) + off);
off += size_t.sizeof + *plength * plength.sizeof;
}
if (n.flags & MIlocalClasses)
{
auto plength = cast(size_t*)(cast(void*)(&this) + off);
off += size_t.sizeof + *plength * plength.sizeof;
}
auto p = cast(immutable(char)*)(cast(void*)(&this) + off);
auto len = strlen(p);
return p[0 .. len];
}
return o.name;
}
alias int delegate(ref ModuleInfo*) ApplyDg;
static int opApply(scope ApplyDg dg)
{
return rt.minfo.moduleinfos_apply(dg);
}
}
///////////////////////////////////////////////////////////////////////////////
// Monitor
///////////////////////////////////////////////////////////////////////////////
alias Object.Monitor IMonitor;
alias void delegate(Object) DEvent;
// NOTE: The dtor callback feature is only supported for monitors that are not
// supplied by the user. The assumption is that any object with a user-
// supplied monitor may have special storage or lifetime requirements and
// that as a result, storing references to local objects within Monitor
// may not be safe or desirable. Thus, devt is only valid if impl is
// null.
struct Monitor
{
IMonitor impl;
/* internal */
DEvent[] devt;
size_t refs;
/* stuff */
}
Monitor* getMonitor(Object h)
{
return cast(Monitor*) h.__monitor;
}
void setMonitor(Object h, Monitor* m)
{
h.__monitor = m;
}
void setSameMutex(shared Object ownee, shared Object owner)
in
{
assert(ownee.__monitor is null);
}
body
{
auto m = cast(shared(Monitor)*) owner.__monitor;
if (m is null)
{
_d_monitor_create(cast(Object) owner);
m = cast(shared(Monitor)*) owner.__monitor;
}
auto i = m.impl;
if (i is null)
{
atomicOp!("+=")(m.refs, cast(size_t)1);
ownee.__monitor = owner.__monitor;
return;
}
// If m.impl is set (ie. if this is a user-created monitor), assume
// the monitor is garbage collected and simply copy the reference.
ownee.__monitor = owner.__monitor;
}
extern (C) void _d_monitor_create(Object);
extern (C) void _d_monitor_destroy(Object);
extern (C) void _d_monitor_lock(Object);
extern (C) int _d_monitor_unlock(Object);
extern (C) void _d_monitordelete(Object h, bool det)
{
// det is true when the object is being destroyed deterministically (ie.
// when it is explicitly deleted or is a scope object whose time is up).
Monitor* m = getMonitor(h);
if (m !is null)
{
IMonitor i = m.impl;
if (i is null)
{
auto s = cast(shared(Monitor)*) m;
if(!atomicOp!("-=")(s.refs, cast(size_t) 1))
{
_d_monitor_devt(m, h);
_d_monitor_destroy(h);
setMonitor(h, null);
}
return;
}
// NOTE: Since a monitor can be shared via setSameMutex it isn't safe
// to explicitly delete user-created monitors--there's no
// refcount and it may have multiple owners.
/+
if (det && (cast(void*) i) !is (cast(void*) h))
delete i;
+/
setMonitor(h, null);
}
}
extern (C) void _d_monitorenter(Object h)
{
Monitor* m = getMonitor(h);
if (m is null)
{
_d_monitor_create(h);
m = getMonitor(h);
}
IMonitor i = m.impl;
if (i is null)
{
_d_monitor_lock(h);
return;
}
i.lock();
}
extern (C) void _d_monitorexit(Object h)
{
Monitor* m = getMonitor(h);
IMonitor i = m.impl;
if (i is null)
{
_d_monitor_unlock(h);
return;
}
i.unlock();
}
extern (C) void _d_monitor_devt(Monitor* m, Object h)
{
if (m.devt.length)
{
DEvent[] devt;
synchronized (h)
{
devt = m.devt;
m.devt = null;
}
foreach (v; devt)
{
if (v)
v(h);
}
free(devt.ptr);
}
}
extern (C) void rt_attachDisposeEvent(Object h, DEvent e)
{
synchronized (h)
{
Monitor* m = getMonitor(h);
assert(m.impl is null);
foreach (ref v; m.devt)
{
if (v is null || v == e)
{
v = e;
return;
}
}
auto len = m.devt.length + 4; // grow by 4 elements
auto pos = m.devt.length; // insert position
auto p = realloc(m.devt.ptr, DEvent.sizeof * len);
if (!p)
onOutOfMemoryError();
m.devt = (cast(DEvent*)p)[0 .. len];
m.devt[pos+1 .. len] = null;
m.devt[pos] = e;
}
}
extern (C) void rt_detachDisposeEvent(Object h, DEvent e)
{
synchronized (h)
{
Monitor* m = getMonitor(h);
assert(m.impl is null);
foreach (p, v; m.devt)
{
if (v == e)
{
memmove(&m.devt[p],
&m.devt[p+1],
(m.devt.length - p - 1) * DEvent.sizeof);
m.devt[$ - 1] = null;
return;
}
}
}
}
extern (C)
{
// from druntime/src/compiler/dmd/aaA.d
size_t _aaLen(void* p);
void* _aaGet(void** pp, TypeInfo keyti, size_t valuesize, ...);
void* _aaGetRvalue(void* p, TypeInfo keyti, size_t valuesize, ...);
void* _aaIn(void* p, TypeInfo keyti);
void _aaDel(void* p, TypeInfo keyti, ...);
void[] _aaValues(void* p, size_t keysize, size_t valuesize);
void[] _aaKeys(void* p, size_t keysize);
void* _aaRehash(void** pp, TypeInfo keyti);
extern (D) alias scope int delegate(void *) _dg_t;
int _aaApply(void* aa, size_t keysize, _dg_t dg);
extern (D) alias scope int delegate(void *, void *) _dg2_t;
int _aaApply2(void* aa, size_t keysize, _dg2_t dg);
void* _d_assocarrayliteralT(TypeInfo_AssociativeArray ti, size_t length, ...);
}
struct AssociativeArray(Key, Value)
{
void* p;
@property size_t length() { return _aaLen(p); }
Value[Key] rehash() @property
{
auto p = _aaRehash(&p, typeid(Value[Key]));
return *cast(Value[Key]*)(&p);
}
Value[] values() @property
{
auto a = _aaValues(p, Key.sizeof, Value.sizeof);
return *cast(Value[]*) &a;
}
Key[] keys() @property
{
auto a = _aaKeys(p, Key.sizeof);
return *cast(Key[]*) &a;
}
int opApply(scope int delegate(ref Key, ref Value) dg)
{
return _aaApply2(p, Key.sizeof, cast(_dg2_t)dg);
}
int opApply(scope int delegate(ref Value) dg)
{
return _aaApply(p, Key.sizeof, cast(_dg_t)dg);
}
int delegate(int delegate(ref Key) dg) byKey()
{
// Discard the Value part and just do the Key
int foo(int delegate(ref Key) dg)
{
int byKeydg(ref Key key, ref Value value)
{
return dg(key);
}
return _aaApply2(p, Key.sizeof, cast(_dg2_t)&byKeydg);
}
return &foo;
}
int delegate(int delegate(ref Value) dg) byValue()
{
return &opApply;
}
Value get(Key key, lazy Value defaultValue)
{
auto p = key in *cast(Value[Key]*)(&p);
return p ? *p : defaultValue;
}
static if (is(typeof({ Value[Key] r; r[Key.init] = Value.init; }())))
@property Value[Key] dup()
{
Value[Key] result;
foreach (k, v; this)
{
result[k] = v;
}
return result;
}
}
unittest
{
auto a = [ 1:"one", 2:"two", 3:"three" ];
auto b = a.dup;
assert(b == [ 1:"one", 2:"two", 3:"three" ]);
}
unittest
{
// test for bug 5925
const a = [4:0];
const b = [4:0];
assert(a == b);
}
void clear(T)(T obj) if (is(T == class))
{
rt_finalize(cast(void*)obj);
}
version(unittest) unittest
{
{
class A { string s = "A"; this() {} }
auto a = new A;
a.s = "asd";
clear(a);
assert(a.s == "A");
}
{
static bool destroyed = false;
class B
{
string s = "B";
this() {}
~this()
{
destroyed = true;
}
}
auto a = new B;
a.s = "asd";
clear(a);
assert(destroyed);
assert(a.s == "B");
}
// this test is invalid now that the default ctor is not run after clearing
version(none)
{
class C
{
string s;
this()
{
s = "C";
}
}
auto a = new C;
a.s = "asd";
clear(a);
assert(a.s == "C");
}
}
void clear(T)(ref T obj) if (is(T == struct))
{
typeid(T).destroy( &obj );
auto buf = (cast(ubyte*) &obj)[0 .. T.sizeof];
auto init = cast(ubyte[])typeid(T).init();
if(init.ptr is null) // null ptr means initialize to 0s
buf[] = 0;
else
buf[] = init[];
}
version(unittest) unittest
{
{
struct A { string s = "A"; }
A a;
a.s = "asd";
clear(a);
assert(a.s == "A");
}
{
static int destroyed = 0;
struct C
{
string s = "C";
~this()
{
destroyed ++;
}
}
struct B
{
C c;
string s = "B";
~this()
{
destroyed ++;
}
}
B a;
a.s = "asd";
a.c.s = "jkl";
clear(a);
assert(destroyed == 2);
assert(a.s == "B");
assert(a.c.s == "C" );
}
}
void clear(T : U[n], U, size_t n)(ref T obj)
{
obj = T.init;
}
version(unittest) unittest
{
int[2] a;
a[0] = 1;
a[1] = 2;
clear(a);
assert(a == [ 0, 0 ]);
}
void clear(T)(ref T obj)
if (!is(T == struct) && !is(T == class) && !_isStaticArray!T)
{
obj = T.init;
}
template _isStaticArray(T : U[N], U, size_t N)
{
enum bool _isStaticArray = true;
}
template _isStaticArray(T)
{
enum bool _isStaticArray = false;
}
version(unittest) unittest
{
{
int a = 42;
clear(a);
assert(a == 0);
}
{
float a = 42;
clear(a);
assert(isnan(a));
}
}
version (unittest)
{
bool isnan(float x)
{
return x != x;
}
}
/**
* (Property) Get the current capacity of an array. The capacity is the number
* of elements that the array can grow to before the array must be
* extended/reallocated.
*/
@property size_t capacity(T)(T[] arr)
{
return _d_arraysetcapacity(typeid(T[]), 0, cast(void *)&arr);
}
/**
* Try to reserve capacity for an array. The capacity is the number of
* elements that the array can grow to before the array must be
* extended/reallocated.
*
* The return value is the new capacity of the array (which may be larger than
* the requested capacity).
*/
size_t reserve(T)(ref T[] arr, size_t newcapacity)
{
return _d_arraysetcapacity(typeid(T[]), newcapacity, cast(void *)&arr);
}
/**
* Assume that it is safe to append to this array. Appends made to this array
* after calling this function may append in place, even if the array was a
* slice of a larger array to begin with.
*
* Use this only when you are sure no elements are in use beyond the array in
* the memory block. If there are, those elements could be overwritten by
* appending to this array.
*
* Calling this function, and then using references to data located after the
* given array results in undefined behavior.
*/
void assumeSafeAppend(T)(T[] arr)
{
_d_arrayshrinkfit(typeid(T[]), *(cast(void[]*)&arr));
}
version (unittest) unittest
{
{
int[] arr;
auto newcap = arr.reserve(2000);
assert(newcap >= 2000);
assert(newcap == arr.capacity);
auto ptr = arr.ptr;
foreach(i; 0..2000)
arr ~= i;
assert(ptr == arr.ptr);
arr = arr[0..1];
arr.assumeSafeAppend();
arr ~= 5;
assert(ptr == arr.ptr);
}
}
version (none)
{
// enforce() copied from Phobos std.contracts for clear(), left out until
// we decide whether to use it.
T _enforce(T, string file = __FILE__, int line = __LINE__)
(T value, lazy const(char)[] msg = null)
{
if (!value) bailOut(file, line, msg);
return value;
}
T _enforce(T, string file = __FILE__, int line = __LINE__)
(T value, scope void delegate() dg)
{
if (!value) dg();
return value;
}
T _enforce(T)(T value, lazy Exception ex)
{
if (!value) throw ex();
return value;
}
private void _bailOut(string file, int line, in char[] msg)
{
char[21] buf;
throw new Exception(cast(string)(file ~ "(" ~ ulongToString(buf[], line) ~ "): " ~ (msg ? msg : "Enforcement failed")));
}
}
/***************************************
* Helper function used to see if two containers of different
* types have the same contents in the same sequence.
*/
bool _ArrayEq(T1, T2)(T1[] a1, T2[] a2)
{
if (a1.length != a2.length)
return false;
foreach(i, a; a1)
{
if (a != a2[i])
return false;
}
return true;
}
bool _xopEquals(in void*, in void*)
{
throw new Error("TypeInfo.equals is not implemented");
}
|
D
|
/*
Copyright (c) 2019 Timur Gafarov
Boost Software License - Version 1.0 - August 17th, 2003
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 dagon.render.shaders.ssao;
import std.stdio;
import std.math;
import dlib.core.memory;
import dlib.core.ownership;
import dlib.math.vector;
import dlib.math.matrix;
import dlib.math.transformation;
import dlib.math.interpolation;
import dlib.image.color;
import dlib.text.unmanagedstring;
import dagon.core.bindings;
import dagon.graphics.shader;
import dagon.graphics.state;
class SSAOShader: Shader
{
String vs, fs;
int samples = 16;
float radius = 0.2f;
float power = 4.0f;
this(Owner owner)
{
vs = Shader.load("data/__internal/shaders/SSAO/SSAO.vert.glsl");
fs = Shader.load("data/__internal/shaders/SSAO/SSAO.frag.glsl");
auto myProgram = New!ShaderProgram(vs, fs, this);
super(myProgram, owner);
}
~this()
{
vs.free();
fs.free();
}
override void bindParameters(GraphicsState* state)
{
setParameter("viewMatrix", state.viewMatrix);
setParameter("invViewMatrix", state.invViewMatrix);
setParameter("projectionMatrix", state.projectionMatrix);
setParameter("invProjectionMatrix", state.invProjectionMatrix);
setParameter("resolution", state.resolution);
setParameter("zNear", state.zNear);
setParameter("zFar", state.zFar);
// Texture 0 - color buffer
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, state.colorTexture);
setParameter("colorBuffer", 0);
// Texture 1 - depth buffer
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, state.depthTexture);
setParameter("depthBuffer", 1);
// Texture 2 - normal buffer
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, state.normalTexture);
setParameter("normalBuffer", 2);
setParameter("ssaoSamples", samples);
setParameter("ssaoRadius", radius);
setParameter("ssaoPower", power);
glActiveTexture(GL_TEXTURE0);
super.bindParameters(state);
}
override void unbindParameters(GraphicsState* state)
{
super.unbindParameters(state);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE0);
}
}
|
D
|
import std.stdio, std.algorithm, std.random, std.exception, std.format, std.conv;
import uni;
import icu;
//dump the vicinity of idx
void dump(C)(C[] buf, size_t idx)
{
size_t back = idx > 10 ? idx-10 : 0;
size_t fwd = idx + 10 < buf.length ? idx+10 : buf.length;
writefln("back: %d; fwd %d; len %d", back, fwd, fwd-back);
writefln("[%( 0x%05x, %)]", buf[back..fwd]);
}
int main(string args[])
{
if(args.length < 5 || args.length > 6){
stderr.writeln("Usage: monkey {nfc|nfd|nfkc|nfkd} <codepoint interval> <sample> <x> [seed]\n
where:
codepoint interval is a pair of hex integers separated by dash e.g. 1000-2000;
sample: number of codepoints per sample
x: number of samples to test in this range.");
return 1;
}
UNormalizer2* icu;
auto normalizer(string kind){
int code;
switch(kind){
case "nfc":
icu = unorm2_getNFCInstance_50(&code);
assert(code <= 0, text("ICU get norm:", code));
return (dchar[] inp){ return normalize!NFC(inp); };
case "nfd":
icu = unorm2_getNFDInstance_50(&code);
assert(code <= 0, text("ICU get norm:", code));
return (dchar[] inp){ return normalize!NFD(inp); };
case "nfkd":
icu = unorm2_getNFKDInstance_50(&code);
assert(code <= 0, text("ICU get norm:", code));
return (dchar[] inp){ return normalize!NFKD(inp); };
case "nfkc":
icu = unorm2_getNFKCInstance_50(&code);
assert(code <= 0, text("ICU get norm:", code));
return (dchar[] inp){ return normalize!NFKC(inp); };
default:
enforce(false, "no normalization form: " ~ kind);
assert(false);
}
}
auto fn = normalizer(args[1]);
string spec = args[2];
uint start, end;
formattedRead(spec, "%x-%x", &start, &end);
enforce(start >= 0 && start <= dchar.max);
enforce(end >= 0 && end <= dchar.max && end >= start);
uint sample = to!uint(args[3]);
uint count = to!uint(args[4]);
uint seed = args.length == 6 ? to!uint(args[5]) : unpredictableSeed();
auto rng = Xorshift(seed);
dchar[] buffer = new dchar[sample];
dchar[] d_buffer = new dchar[sample];
foreach(dummy; 0..count){
foreach(ref v; buffer){
v = cast(dchar)uniform!"[]"(start, end);
}
d_buffer[] = buffer[];//to avoid any aliasing to original
auto d_result = fn(d_buffer);
int icu_code;
auto icu_buf = to!(wchar[])(buffer);
wchar[] icu_dest = new wchar[icu_buf.length*18];
int total = unorm2_normalize_50(icu, icu_buf.ptr, cast(int)icu_buf.length, icu_dest.ptr, cast(int)icu_dest.length, &icu_code);
assert(icu_code <=0, text("ICU norm:", icu_code));
icu_dest = icu_dest[0..total];
auto icu_result = to!(dchar[])(icu_dest);
if(!equal(d_result,icu_result)){
writefln("ORIGINAL: [%(%05x,%)]", buffer);
writefln("D: [%(%05x,%)]", d_result);
writefln("ICU: [%(%05x,%)]", icu_result);
}
}
return 0;
}
|
D
|
/*
TEST_OUTPUT:
---
fail_compilation/fail6611.d(11): Error: cannot post-increment array slice `x[]`, use pre-increment instead
---
*/
void main()
{
auto x = new int[](10);
x[]++;
}
|
D
|
module main;
import core.atomic : atomicOp;
import core.sync.mutex : Mutex;
import core.sys.posix.pthread;
import core.thread : thread_joinAll;
import custom_locks;
import std.concurrency : spawn;
import std.conv : to;
import std.datetime : benchmark,Clock;
import std.getopt;
import std.json : JSONValue;
import std.stdio : stdout,writeln,writefln,writef;
import std.string : format;
import std.traits : EnumMembers;
import std.typecons : staticIota;
static import std.compiler;
enum LockPlacement
{
Stack,
Heap,
}
struct Resource(LockPlacement lockPlacement, LockMechanism mechanism)
{
static if (lockPlacement == LockPlacement.Stack)
{
shared SpinLock!mechanism lock;
}
else static if (lockPlacement == LockPlacement.Heap)
{
shared SpinLock!mechanism* lock = new shared SpinLock!mechanism();
}
int special_resource;
auto obtainLock() shared
{
static if (lockPlacement == LockPlacement.Stack)
return lockGuard(&lock);
else static if (lockPlacement == LockPlacement.Heap)
return lockGuard(lock);
}
~this() shared
{
//writefln("Resource destr from: 0x%x", getCurrentThreadId);
}
}
enum SyncApproach
{
custom_spin_lock_manual,
custom_spin_lock_raii,
d_synchronized_stmt_only,
d_synchronized_stmt_global_mutex,
global_pthread_mutex_test,
global_pthread_spinlock_test,
atomic_inc,
unsafe_inc
}
__gshared Mutex my_own_mutex;
__gshared pthread_spinlock_t p_spin_lock;
__gshared pthread_mutex_t p_mutex;
shared static this()
{
my_own_mutex = new Mutex();
pthread_spin_init(&p_spin_lock, 0);
pthread_mutex_init(&p_mutex, null);
}
void testWith(SyncApproach approach, LockPlacement placement, LockMechanism mechanism)
(ushort threadCount = 12, size_t increments_count = 150_000)
{
alias ResObj = Resource!(placement, mechanism);
shared ResObj r; r.lock.initialize();
shared bool start_flag = false;
foreach(_; 0 .. threadCount)
{
auto id = spawn(
&testBody!(approach, ResObj),
&r, &start_flag, increments_count);
}
start_flag = true;
thread_joinAll();
//"%6s ".writef(r.special_resource);
r.special_resource = 0;
}
void testBody(SyncApproach approach, T)
(shared T* r, shared bool* start_flag, size_t increments_count)
{
while (!start_flag) { }
foreach (_; 0 .. increments_count)
{
static if (approach == SyncApproach.d_synchronized_stmt_only)
{
synchronized { (cast()r.special_resource)++; }
}
else static if (approach == SyncApproach.d_synchronized_stmt_global_mutex)
{
synchronized (my_own_mutex) { (cast()r.special_resource)++; }
}
else static if (approach == SyncApproach.global_pthread_mutex_test)
{
pthread_mutex_lock(&p_mutex);
(cast()r.special_resource)++;
pthread_mutex_unlock(&p_mutex);
}
else static if (approach == SyncApproach.global_pthread_spinlock_test)
{
pthread_spin_lock(&p_spin_lock);
(cast()r.special_resource)++;
pthread_spin_unlock(&p_spin_lock);
}
else static if (approach == SyncApproach.custom_spin_lock_manual)
{
r.lock.lock();
(cast()r.special_resource)++;
r.lock.unlock();
}
else static if (approach == SyncApproach.custom_spin_lock_raii)
{
auto l = r.obtainLock();
(cast()r.special_resource)++;
}
else static if (approach == SyncApproach.unsafe_inc)
{
(cast()r.special_resource)++;
}
else static if (approach == SyncApproach.atomic_inc)
{
atomicOp!"+="(r.special_resource, 1);
}
}
}
void main(string[] args)
{
ushort test_thread_count = 12;
size_t test_increments_count = 150_000;
uint test_repetitions_count = 20;
auto cmdline_info = getopt(args, "thread_count|t", "Thread count - more threads, more contention. Example: lock_benchmark -t6.", &test_thread_count,
"increments_count|i", "Number of incrementations - size of workload. Example: lock_benchmark -i150000.", &test_increments_count,
"repetitions_count|r", "Repetitions count - improves average result stability. Example: lock_benchmark -r20.", &test_repetitions_count);
if (cmdline_info.helpWanted)
{
defaultGetoptFormatter(stdout.lockingTextWriter(), "Lock benchmark", cmdline_info.options);
writeln();
return;
}
auto start_time = Clock.currTime;
"Hello! lock_benchmark was comiled with %s v%s.%s and is running on %s.\n"
"The time is %s.\n"
"Thread count: %s, increments count: %s, repetitions count: %s."
.writefln(
std.compiler.name,
std.compiler.version_major,
std.compiler.version_minor,
(void*).sizeof == 4? "32-bit" : "64-bit",
start_time,
test_thread_count,
test_increments_count,
test_repetitions_count);
JSONValue series = new JSONValue[0];
foreach (approach; EnumMembers!SyncApproach)
{
enum is_custom_approach =
approach == SyncApproach.custom_spin_lock_manual ||
approach == SyncApproach.custom_spin_lock_raii;
foreach (mechanism; EnumMembers!LockMechanism)
{
foreach (placement; EnumMembers!LockPlacement)
{
JSONValue[string] aa;
aa["name"] = is_custom_approach?
"%s %s %s".format(placement, mechanism, approach):
"%s".format(approach);
aa["data"] = new JSONValue[0];
JSONValue serie = aa;
foreach_reverse (ushort curr_thread_count; 1 .. test_thread_count + 1)
{
if (is_custom_approach)
"TC: %2s, %5s %11s %21s: [".writef(curr_thread_count, placement, mechanism, approach);
else
"TC: %2s, %21s: [".writef(curr_thread_count, approach);
stdout.flush();
auto result = benchmark!( {
testWith!(approach, placement, mechanism)
(curr_thread_count, test_increments_count);
})(test_repetitions_count);
serie["data"].array ~= JSONValue(result[0].to!("msecs", double)());
"], total time: %s".writefln(result[0].to!("msecs", double));
}
series.array ~= serie;
writeln();
static if (!is_custom_approach) break;
}
static if (!is_custom_approach) break;
}
}
writeln(series.toPrettyString());
auto end = Clock.currTime;
writefln("All done! The time is: %s\nTotal time: %s", end, end - start_time);
//readln();
}
|
D
|
/home/asus/Desktop/browser-engine/target/debug/build/x11-dl-0b1b370e0f95b7b0/build_script_build-0b1b370e0f95b7b0: /home/asus/.cargo/registry/src/github.com-1ecc6299db9ec823/x11-dl-2.18.5/build.rs
/home/asus/Desktop/browser-engine/target/debug/build/x11-dl-0b1b370e0f95b7b0/build_script_build-0b1b370e0f95b7b0.d: /home/asus/.cargo/registry/src/github.com-1ecc6299db9ec823/x11-dl-2.18.5/build.rs
/home/asus/.cargo/registry/src/github.com-1ecc6299db9ec823/x11-dl-2.18.5/build.rs:
|
D
|
module during.tests.timeout;
import during.tests.base;
@("timeout set/remove")
unittest
{
// set 5.4, remove 5.5
version (D_BetterC) errmsg = "Not implemented";
else throw new Exception("Not implemented");
}
@("link timeout")
unittest
{
// 5.5
version (D_BetterC) errmsg = "Not implemented";
else throw new Exception("Not implemented");
}
|
D
|
module webtank.net.service.config;
public import webtank.net.service.config.iface: IServiceConfig;
public import webtank.net.service.config.config: ServiceConfig;
|
D
|
import std.stdio,std.range;
import std.algorithm;
|
D
|
/Users/oslo/code/swift_vapor_server/.build/debug/Console.build/Console/Console+Run.swift.o : /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Bar/Bar.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Argument.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Command+Print.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Command.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Group.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Option.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Runnable.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Value.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console+Ask.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console+Center.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console+Confirm.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console+Options.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console+Print.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console+Run.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/ConsoleError.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Stream/FileHandle+Stream.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Stream/Pipe+Stream.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Stream/Stream.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Terminal/ConsoleColor+Terminal.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Terminal/ConsoleStyle+Terminal.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Terminal/String+ANSI.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Terminal/Terminal+Command.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Terminal/Terminal.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Utilities/Bool+Polymorphic.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Utilities/String+Trim.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Bar/Loading/Console+LoadingBar.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Bar/Loading/LoadingBar.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Bar/Progress/Console+ProgressBar.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Bar/Progress/ProgressBar.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Clear/ConsoleClear.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Color/ConsoleColor.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Style/Console+ConsoleStyle.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Style/ConsoleStyle.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/oslo/code/swift_vapor_server/.build/debug/libc.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/Polymorphic.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/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/oslo/code/swift_vapor_server/.build/debug/Core.swiftmodule
/Users/oslo/code/swift_vapor_server/.build/debug/Console.build/Console+Run~partial.swiftmodule : /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Bar/Bar.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Argument.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Command+Print.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Command.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Group.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Option.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Runnable.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Value.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console+Ask.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console+Center.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console+Confirm.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console+Options.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console+Print.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console+Run.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/ConsoleError.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Stream/FileHandle+Stream.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Stream/Pipe+Stream.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Stream/Stream.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Terminal/ConsoleColor+Terminal.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Terminal/ConsoleStyle+Terminal.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Terminal/String+ANSI.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Terminal/Terminal+Command.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Terminal/Terminal.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Utilities/Bool+Polymorphic.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Utilities/String+Trim.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Bar/Loading/Console+LoadingBar.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Bar/Loading/LoadingBar.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Bar/Progress/Console+ProgressBar.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Bar/Progress/ProgressBar.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Clear/ConsoleClear.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Color/ConsoleColor.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Style/Console+ConsoleStyle.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Style/ConsoleStyle.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/oslo/code/swift_vapor_server/.build/debug/libc.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/Polymorphic.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/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/oslo/code/swift_vapor_server/.build/debug/Core.swiftmodule
/Users/oslo/code/swift_vapor_server/.build/debug/Console.build/Console+Run~partial.swiftdoc : /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Bar/Bar.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Argument.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Command+Print.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Command.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Group.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Option.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Runnable.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Command/Value.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console+Ask.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console+Center.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console+Confirm.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console+Options.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console+Print.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console+Run.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Console.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/ConsoleError.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Stream/FileHandle+Stream.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Stream/Pipe+Stream.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Stream/Stream.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Terminal/ConsoleColor+Terminal.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Terminal/ConsoleStyle+Terminal.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Terminal/String+ANSI.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Terminal/Terminal+Command.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Terminal/Terminal.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Utilities/Bool+Polymorphic.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Utilities/String+Trim.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Bar/Loading/Console+LoadingBar.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Bar/Loading/LoadingBar.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Bar/Progress/Console+ProgressBar.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Bar/Progress/ProgressBar.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Clear/ConsoleClear.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Color/ConsoleColor.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Style/Console+ConsoleStyle.swift /Users/oslo/code/swift_vapor_server/Packages/Console-1.0.2/Sources/Console/Console/Style/ConsoleStyle.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/oslo/code/swift_vapor_server/.build/debug/libc.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Users/oslo/code/swift_vapor_server/.build/debug/Polymorphic.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/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/oslo/code/swift_vapor_server/.build/debug/Core.swiftmodule
|
D
|
/*******************************************************************************
* Copyright (c) 2000, 2004 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
* D Port:
* Bill Baxter
*******************************************************************************/
module coolbar.Snippet150;
/*
* CoolBar example snippet: create a coolbar (relayout when resized)
*
* For a list of all SWT example snippets see
* http://www.eclipse.org/swt/snippets/
*
* @since 3.0
*/
import dwt.DWT;
import dwt.graphics.Point;
import dwt.widgets.Button;
import dwt.widgets.Display;
import dwt.widgets.CoolBar;
import dwt.widgets.CoolItem;
import dwt.widgets.ToolBar;
import dwt.widgets.ToolItem;
import dwt.widgets.Shell;
import dwt.widgets.Text;
import dwt.widgets.Event;
import dwt.widgets.Listener;
import dwt.layout.FormLayout;
import dwt.layout.FormData;
import dwt.layout.FormAttachment;
import tango.util.Convert;
int itemCount;
CoolItem createItem(CoolBar coolBar, int count) {
ToolBar toolBar = new ToolBar(coolBar, DWT.FLAT);
for (int i = 0; i < count; i++) {
ToolItem item = new ToolItem(toolBar, DWT.PUSH);
item.setText(to!(char[])(itemCount++) ~"");
}
toolBar.pack();
Point size = toolBar.getSize();
CoolItem item = new CoolItem(coolBar, DWT.NONE);
item.setControl(toolBar);
Point preferred = item.computeSize(size.x, size.y);
item.setPreferredSize(preferred);
return item;
}
void main () {
Display display = new Display();
final Shell shell = new Shell(display);
CoolBar coolBar = new CoolBar(shell, DWT.NONE);
createItem(coolBar, 3);
createItem(coolBar, 2);
createItem(coolBar, 3);
createItem(coolBar, 4);
int style = DWT.BORDER | DWT.H_SCROLL | DWT.V_SCROLL;
Text text = new Text(shell, style);
FormLayout layout = new FormLayout();
shell.setLayout(layout);
FormData coolData = new FormData();
coolData.left = new FormAttachment(0);
coolData.right = new FormAttachment(100);
coolData.top = new FormAttachment(0);
coolBar.setLayoutData(coolData);
coolBar.addListener(DWT.Resize, new class() Listener {
void handleEvent(Event event) {
shell.layout();
}
});
FormData textData = new FormData();
textData.left = new FormAttachment(0);
textData.right = new FormAttachment(100);
textData.top = new FormAttachment(coolBar);
textData.bottom = new FormAttachment(100);
text.setLayoutData(textData);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
|
D
|
module ui.parse.css.number;
import ui.parse.css.stringiterator : StringIterator;
bool parse_number( StringIterator range, float* result )
{
// https://developer.mozilla.org/en-US/docs/Web/CSS/number
/*
12 A raw <integer> is also a <number>.
4.01 Positive fraction
-456.8 Negative fraction
0.0 Zero
+0.0 Zero, with a leading +
-0.0 Zero, with a leading -
.60 Fractional number without a leading zero
10e3 Scientific notation
-3.4e-2 Complicated scientific notation
*/
//import std.uni : byGrapheme;
import std.encoding : codePoints;
import std.math : pow;
import std.range : front;
import std.range : empty;
import std.range : popFront;
import std.range : tee;
import std.uni : isNumber;
//
int sign = 1;
bool isFloat = false;
int floatIndeger = 0;
float floatDecimal = 0.0;
float floatMultiplier = 1.0;
bool floatIndegerParsed = false;
int integer = 0;
int scientificSign = 1;
int scientificNumber = 0;
bool isScientific = false;
const int multiplier = 10;
auto c = range.front;
// +
if ( c == '+' )
{
sign = +1;
range.popFront();
c = range.front;
}
else
// -
if ( c == '-' )
{
sign = -1;
range.popFront();
c = range.front;
}
// .1 float
if ( c == '.' )
{
isFloat = true;
floatIndeger = 0;
floatDecimal = 0;
floatIndegerParsed = true;
range.popFront();
}
//
// not number
if ( !range.front.isNumber() )
{
return false;
}
else
// float
if ( isFloat )
{
// parse float decimal
goto parseFloatDecimal;
}
else
// integer | float
{
// parse int | float
for ( ; !range.empty; range.popFront() )
{
c = range.front;
switch ( c )
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
// number readed
integer *= multiplier;
integer += c - '0';
break;
case 'e':
// Scientific notation int | float readed
range.popFront();
isScientific = true;
goto parseScientificNotation;
case '.':
// float integer readed
isFloat = true;
floatIndeger = integer;
floatDecimal = 0;
floatIndegerParsed = true;
range.popFront();
goto parseFloatDecimal;
default:
goto end; // break loop
}
}
}
goto end;
parseFloatDecimal:
// parse float decimal
for ( ; !range.empty; range.popFront() )
{
c = range.front;
switch ( c )
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
// number readed
floatMultiplier /= multiplier;
floatDecimal += floatMultiplier * ( c - '0' );
//writeln( "floatMultiplier * ( dc - '0' ): ", floatMultiplier * ( dc - '0' ) );
break;
case 'e':
// Scientific notation int | float readed
range.popFront();
isScientific = true;
goto parseScientificNotation;
default:
goto end; // break loop
}
}
goto end;
parseScientificNotation:
// parse Scientific notation
//scientificSign
//
c = range.front;
if ( c == '+' )
{
scientificSign = +1;
range.popFront();
c = range.front;
}
else
if ( c == '-' )
{
scientificSign = -1;
range.popFront();
c = range.front;
}
//
for ( ; !range.empty; range.popFront() )
{
c = range.front;
switch ( c )
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
// number readed
scientificNumber *= multiplier;
scientificNumber += ( c - '0' );
break;
default:
break; // break loop
}
}
end:
// float
if ( isFloat )
{
*result = sign * ( floatIndeger + floatDecimal );
// with e...
if ( isScientific )
{
if ( scientificSign == +1 )
*result *= pow( 10, scientificNumber );
else
*result /= pow( 10, scientificNumber );
}
}
else
// integer
{
*result = sign * integer;
// with e...
if ( isScientific )
{
*result *= pow( scientificSign * 10, scientificNumber );
}
}
return true;
}
unittest
{
float number;
assert( parse_number( new StringIterator( "1" ), &number ) && number == 1.0 );
assert( parse_number( new StringIterator( "10" ), &number ) && number == 10.0 );
assert( parse_number( new StringIterator( "123" ), &number ) && number == 123.0 );
assert( parse_number( new StringIterator( "-1" ), &number ) && number == -1.0 );
assert( parse_number( new StringIterator( "-10" ), &number ) && number == -10.0 );
assert( parse_number( new StringIterator( "-123" ), &number ) && number == -123.0 );
assert( parse_number( new StringIterator( "+1" ), &number ) && number == 1.0 );
assert( parse_number( new StringIterator( "+10" ), &number ) && number == 10.0 );
assert( parse_number( new StringIterator( "+123" ), &number ) && number == 123.0 );
assert( parse_number( new StringIterator( ".1" ), &number ) && number == .1f );
assert( parse_number( new StringIterator( ".10" ), &number ) && number == .10f );
assert( parse_number( new StringIterator( ".123" ), &number ) && number == .123f );
assert( parse_number( new StringIterator( "1.0" ), &number ) && number == 1.0f );
assert( parse_number( new StringIterator( "1.1" ), &number ) && number == 1.1f );
assert( parse_number( new StringIterator( "1.10" ), &number ) && number == 1.10f );
assert( parse_number( new StringIterator( "1.123" ), &number ) && number == 1.123f );
assert( parse_number( new StringIterator( "-1.0" ), &number ) && number == -1.0f );
assert( parse_number( new StringIterator( "-1.1" ), &number ) && number == -1.1f );
assert( parse_number( new StringIterator( "-1.10" ), &number ) && number == -1.10f );
assert( parse_number( new StringIterator( "-1.123" ), &number ) && number == -1.123f );
assert( parse_number( new StringIterator( "-.1" ), &number ) && number == -.1f );
assert( parse_number( new StringIterator( "-.10" ), &number ) && number == -.10f );
assert( parse_number( new StringIterator( "-.123" ), &number ) && number == -.123f );
assert( parse_number( new StringIterator( "+1.0" ), &number ) && number == 1.0f );
assert( parse_number( new StringIterator( "+1.1" ), &number ) && number == 1.1f );
assert( parse_number( new StringIterator( "+1.10" ), &number ) && number == 1.10f );
assert( parse_number( new StringIterator( "+1.123" ), &number ) && number == 1.123f );
assert( parse_number( new StringIterator( "+.1" ), &number ) && number == .1f );
assert( parse_number( new StringIterator( "+.10" ), &number ) && number == .10f );
assert( parse_number( new StringIterator( "+.123" ), &number ) && number == .123f );
assert( parse_number( new StringIterator( "10e3" ), &number ) && number == 10000.0f );
assert( parse_number( new StringIterator( "-3.4e-2" ), &number ) && number == -.034f );
assert( parse_number( new StringIterator( "12" ), &number ) && number == 12 );
assert( parse_number( new StringIterator( "4.01" ), &number ) && number == 4.01f );
assert( parse_number( new StringIterator( "-456.8" ), &number ) && number == -456.8f );
assert( parse_number( new StringIterator( "0.0" ), &number ) && number == 0.0f );
assert( parse_number( new StringIterator( "+0.0" ), &number ) && number == 0.0f );
assert( parse_number( new StringIterator( "-0.0" ), &number ) && number == 0.0f );
assert( parse_number( new StringIterator( ".60" ), &number ) && number == 0.60f );
assert( parse_number( new StringIterator( "10e3" ), &number ) && number == 10e3f );
assert( parse_number( new StringIterator( "-3.4e-2" ), &number ) && number == -3.4e-2f );
}
|
D
|
import std.stdio;
import std.range;
import Statistics;
import plt = matplotlibd.pyplot;
void main()
{
double[] time_series;
double[] time_series_estimated;
double[2] ols;
int n = 1000;
double[] t;
for (int i = 0; i<n; i++) {t ~= i;}
time_series = generate_autoregressive_process(0.1, 1.0, 1.0, n);
ols = compute_ordinary_least_squares(t, time_series);
for (int i = 0; i<n; i++) {time_series_estimated ~= ols[0] + ols[1]*i;}
plt.plot(t, time_series, "o", ["markersize": 0.5]);
plt.plot(t, time_series_estimated, "r-");
plt.legend();
plt.grid();
plt.savefig("Random Process.png");
plt.clear();
}
|
D
|
/Users/student/VGLogger/DerivedData/Build/Intermediates/VGLogger.build/Debug-iphonesimulator/VGLogger.build/Objects-normal/x86_64/WishlistDatabase.o : /Users/student/VGLogger/VGLogger/Download.swift /Users/student/VGLogger/VGLogger/Models/BarCodeDataSource.swift /Users/student/VGLogger/VGLogger/Models/VideoGameDataSource.swift /Users/student/VGLogger/VGLogger/Models/BarCode.swift /Users/student/VGLogger/VGLogger/Models/VideoGame.swift /Users/student/VGLogger/VGLogger/Models/popularGame.swift /Users/student/VGLogger/VGLogger/Wishlist/WishlistDatabase.swift /Users/student/VGLogger/VGLogger/AppDelegate.swift /Users/student/VGLogger/VGLogger/Scanner/BarCodeTableViewCell.swift /Users/student/VGLogger/VGLogger/Search/VideoGameTableViewCell.swift /Users/student/VGLogger/VGLogger/Search/FilterSideBarTableViewCell.swift /Users/student/VGLogger/VGLogger/Wishlist/WishlistTableViewCell.swift /Users/student/VGLogger/VGLogger/Homepage/FeedCollectionViewCell.swift /Users/student/VGLogger/VGLogger/Homepage/FeedViewController.swift /Users/student/VGLogger/VGLogger/Search/VideoGameDetailedViewController.swift /Users/student/VGLogger/VGLogger/ThirdViewController.swift /Users/student/VGLogger/VGLogger/Scanner/BarCodeViewController.swift /Users/student/VGLogger/VGLogger/Scanner/BarCodeTableViewController.swift /Users/student/VGLogger/VGLogger/Search/SearchTableViewController.swift /Users/student/VGLogger/VGLogger/Search/FilterSideBarTableViewController.swift /Users/student/VGLogger/VGLogger/Wishlist/WishlistTableViewController.swift /Users/student/VGLogger/VGLogger/Homepage/FeedTableViewCells.swift /Users/student/VGLogger/VGLogger/Wishlist/WishlistObject.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Modules/SwiftyJSON.swiftmodule/x86_64.swiftmodule /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Modules/Alamofire.swiftmodule/x86_64.swiftmodule /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SQLite.swift/SQLite.framework/Modules/SQLite.swiftmodule/x86_64.swiftmodule /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Hex/Hex.framework/Modules/Hex.swiftmodule/x86_64.swiftmodule /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/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/simd.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/AVFoundation.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/CoreAudio.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/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Headers/SwiftyJSON-umbrella.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Headers/Alamofire-umbrella.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SQLite.swift/SQLite.framework/Headers/SQLite.swift-umbrella.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Hex/Hex.framework/Headers/Hex-umbrella.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SQLite.swift/SQLite.framework/Headers/SQLite.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SQLite.swift/SQLite.framework/Headers/SQLite-Bridging.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Headers/SwiftyJSON-Swift.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Headers/Alamofire-Swift.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SQLite.swift/SQLite.framework/Headers/SQLite-Swift.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Hex/Hex.framework/Headers/Hex-Swift.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Hex/Hex.framework/Headers/Hex.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Modules/module.modulemap /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Modules/module.modulemap /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SQLite.swift/SQLite.framework/Modules/module.modulemap /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Hex/Hex.framework/Modules/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SafariServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.apinotes
/Users/student/VGLogger/DerivedData/Build/Intermediates/VGLogger.build/Debug-iphonesimulator/VGLogger.build/Objects-normal/x86_64/WishlistDatabase~partial.swiftmodule : /Users/student/VGLogger/VGLogger/Download.swift /Users/student/VGLogger/VGLogger/Models/BarCodeDataSource.swift /Users/student/VGLogger/VGLogger/Models/VideoGameDataSource.swift /Users/student/VGLogger/VGLogger/Models/BarCode.swift /Users/student/VGLogger/VGLogger/Models/VideoGame.swift /Users/student/VGLogger/VGLogger/Models/popularGame.swift /Users/student/VGLogger/VGLogger/Wishlist/WishlistDatabase.swift /Users/student/VGLogger/VGLogger/AppDelegate.swift /Users/student/VGLogger/VGLogger/Scanner/BarCodeTableViewCell.swift /Users/student/VGLogger/VGLogger/Search/VideoGameTableViewCell.swift /Users/student/VGLogger/VGLogger/Search/FilterSideBarTableViewCell.swift /Users/student/VGLogger/VGLogger/Wishlist/WishlistTableViewCell.swift /Users/student/VGLogger/VGLogger/Homepage/FeedCollectionViewCell.swift /Users/student/VGLogger/VGLogger/Homepage/FeedViewController.swift /Users/student/VGLogger/VGLogger/Search/VideoGameDetailedViewController.swift /Users/student/VGLogger/VGLogger/ThirdViewController.swift /Users/student/VGLogger/VGLogger/Scanner/BarCodeViewController.swift /Users/student/VGLogger/VGLogger/Scanner/BarCodeTableViewController.swift /Users/student/VGLogger/VGLogger/Search/SearchTableViewController.swift /Users/student/VGLogger/VGLogger/Search/FilterSideBarTableViewController.swift /Users/student/VGLogger/VGLogger/Wishlist/WishlistTableViewController.swift /Users/student/VGLogger/VGLogger/Homepage/FeedTableViewCells.swift /Users/student/VGLogger/VGLogger/Wishlist/WishlistObject.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Modules/SwiftyJSON.swiftmodule/x86_64.swiftmodule /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Modules/Alamofire.swiftmodule/x86_64.swiftmodule /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SQLite.swift/SQLite.framework/Modules/SQLite.swiftmodule/x86_64.swiftmodule /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Hex/Hex.framework/Modules/Hex.swiftmodule/x86_64.swiftmodule /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/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/simd.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/AVFoundation.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/CoreAudio.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/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Headers/SwiftyJSON-umbrella.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Headers/Alamofire-umbrella.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SQLite.swift/SQLite.framework/Headers/SQLite.swift-umbrella.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Hex/Hex.framework/Headers/Hex-umbrella.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SQLite.swift/SQLite.framework/Headers/SQLite.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SQLite.swift/SQLite.framework/Headers/SQLite-Bridging.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Headers/SwiftyJSON-Swift.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Headers/Alamofire-Swift.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SQLite.swift/SQLite.framework/Headers/SQLite-Swift.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Hex/Hex.framework/Headers/Hex-Swift.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Hex/Hex.framework/Headers/Hex.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Modules/module.modulemap /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Modules/module.modulemap /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SQLite.swift/SQLite.framework/Modules/module.modulemap /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Hex/Hex.framework/Modules/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SafariServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.apinotes
/Users/student/VGLogger/DerivedData/Build/Intermediates/VGLogger.build/Debug-iphonesimulator/VGLogger.build/Objects-normal/x86_64/WishlistDatabase~partial.swiftdoc : /Users/student/VGLogger/VGLogger/Download.swift /Users/student/VGLogger/VGLogger/Models/BarCodeDataSource.swift /Users/student/VGLogger/VGLogger/Models/VideoGameDataSource.swift /Users/student/VGLogger/VGLogger/Models/BarCode.swift /Users/student/VGLogger/VGLogger/Models/VideoGame.swift /Users/student/VGLogger/VGLogger/Models/popularGame.swift /Users/student/VGLogger/VGLogger/Wishlist/WishlistDatabase.swift /Users/student/VGLogger/VGLogger/AppDelegate.swift /Users/student/VGLogger/VGLogger/Scanner/BarCodeTableViewCell.swift /Users/student/VGLogger/VGLogger/Search/VideoGameTableViewCell.swift /Users/student/VGLogger/VGLogger/Search/FilterSideBarTableViewCell.swift /Users/student/VGLogger/VGLogger/Wishlist/WishlistTableViewCell.swift /Users/student/VGLogger/VGLogger/Homepage/FeedCollectionViewCell.swift /Users/student/VGLogger/VGLogger/Homepage/FeedViewController.swift /Users/student/VGLogger/VGLogger/Search/VideoGameDetailedViewController.swift /Users/student/VGLogger/VGLogger/ThirdViewController.swift /Users/student/VGLogger/VGLogger/Scanner/BarCodeViewController.swift /Users/student/VGLogger/VGLogger/Scanner/BarCodeTableViewController.swift /Users/student/VGLogger/VGLogger/Search/SearchTableViewController.swift /Users/student/VGLogger/VGLogger/Search/FilterSideBarTableViewController.swift /Users/student/VGLogger/VGLogger/Wishlist/WishlistTableViewController.swift /Users/student/VGLogger/VGLogger/Homepage/FeedTableViewCells.swift /Users/student/VGLogger/VGLogger/Wishlist/WishlistObject.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Modules/SwiftyJSON.swiftmodule/x86_64.swiftmodule /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Modules/Alamofire.swiftmodule/x86_64.swiftmodule /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SQLite.swift/SQLite.framework/Modules/SQLite.swiftmodule/x86_64.swiftmodule /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Hex/Hex.framework/Modules/Hex.swiftmodule/x86_64.swiftmodule /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/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/simd.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/AVFoundation.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/CoreAudio.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/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Headers/SwiftyJSON-umbrella.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Headers/Alamofire-umbrella.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SQLite.swift/SQLite.framework/Headers/SQLite.swift-umbrella.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Hex/Hex.framework/Headers/Hex-umbrella.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SQLite.swift/SQLite.framework/Headers/SQLite.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SQLite.swift/SQLite.framework/Headers/SQLite-Bridging.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Headers/SwiftyJSON-Swift.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Headers/Alamofire-Swift.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SQLite.swift/SQLite.framework/Headers/SQLite-Swift.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Hex/Hex.framework/Headers/Hex-Swift.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Hex/Hex.framework/Headers/Hex.h /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Modules/module.modulemap /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Modules/module.modulemap /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/SQLite.swift/SQLite.framework/Modules/module.modulemap /Users/student/VGLogger/DerivedData/Build/Products/Debug-iphonesimulator/Hex/Hex.framework/Modules/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SafariServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.apinotes
|
D
|
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/MDK/Templates/Inc/stm32f4xx_hal_conf.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/Development\ Studio\ Workspace/BaseProject_2020_08_04/RTE/RTE_Components.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f407xx.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/ARM/CMSIS/5.7.0/CMSIS/Core/Include/core_cm4.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/ARM/CMSIS/5.7.0/CMSIS/Core/Include/cmsis_version.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/ARM/CMSIS/5.7.0/CMSIS/Core/Include/cmsis_compiler.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/ARM/CMSIS/5.7.0/CMSIS/Core/Include/cmsis_armcc.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/ARM/CMSIS/5.7.0/CMSIS/Core/Include/mpu_armv7.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c_ex.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s_ex.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h
RTE/Device/STM32F407VGTx/stm32f4xx_hal_gpio.o: C:/Users/david.waldo/AppData/Local/Arm/Packs/Keil/STM32F4xx_DFP/2.14.0/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_usart.h
|
D
|
/Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Fluent.build/Schema/IdentifierType.swift.o : /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Utilities/UUID.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Database+Schema.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Blob.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Field.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/ComputedField.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/NodeUtilities/Method+Node.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/NodeUtilities/Filter+Node.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pagination/Query+Page.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pagination/Page.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/Storage.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/Timestampable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pagination/Paginatable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Database/Transactable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/SoftDeletable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/QueryRepresentable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Row/RowConvertible.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/Filter+Scope.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/IdentifierType.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Database/Database.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Aggregate.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/NodeUtilities/Scope+String.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/NodeUtilities/Relation+String.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/NodeUtilities/Comparison+String.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Log.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Chunk.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pivot/PivotProtocol.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Database/ThreadConnectionPool.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Relations/Children.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Join.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Preparation/Database+Preparation.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Preparation/Preparation.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Preparation/Migration.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Action.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Database/Connection.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/KeyNamingConvention.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/Comparison.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/Query+Group.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Builder.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Modifier.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/Query+Filter.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/Filter.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Database/Driver.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/SQLite/SQLiteDriver.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/SQL/SQLSerializer.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/SQL/GeneralSQLSerializer.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/SQLite/SQLiteSerializer.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Relations/RelationError.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pagination/PaginationError.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Preparation/PreparationError.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pivot/PivotError.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/QueryError.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/EntityError.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Creator.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Database/Executor.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Relations/Siblings.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Utilities/Exports.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Distinct.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Limit.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Relations/Parent.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pivot/Pivot.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pivot/DoublePivot.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Sort.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Row/RowContext.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Raw.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Row/Row.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Index.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/ForeignKey.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Query.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/Entity.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/Dirty.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/SQLite.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 /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.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/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/checkouts/sqlite.git--8232814251736334455/Sources/CSQLite/include/sqlite3.h /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/Fluent.build/IdentifierType~partial.swiftmodule : /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Utilities/UUID.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Database+Schema.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Blob.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Field.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/ComputedField.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/NodeUtilities/Method+Node.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/NodeUtilities/Filter+Node.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pagination/Query+Page.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pagination/Page.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/Storage.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/Timestampable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pagination/Paginatable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Database/Transactable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/SoftDeletable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/QueryRepresentable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Row/RowConvertible.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/Filter+Scope.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/IdentifierType.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Database/Database.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Aggregate.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/NodeUtilities/Scope+String.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/NodeUtilities/Relation+String.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/NodeUtilities/Comparison+String.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Log.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Chunk.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pivot/PivotProtocol.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Database/ThreadConnectionPool.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Relations/Children.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Join.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Preparation/Database+Preparation.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Preparation/Preparation.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Preparation/Migration.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Action.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Database/Connection.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/KeyNamingConvention.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/Comparison.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/Query+Group.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Builder.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Modifier.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/Query+Filter.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/Filter.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Database/Driver.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/SQLite/SQLiteDriver.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/SQL/SQLSerializer.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/SQL/GeneralSQLSerializer.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/SQLite/SQLiteSerializer.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Relations/RelationError.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pagination/PaginationError.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Preparation/PreparationError.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pivot/PivotError.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/QueryError.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/EntityError.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Creator.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Database/Executor.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Relations/Siblings.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Utilities/Exports.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Distinct.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Limit.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Relations/Parent.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pivot/Pivot.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pivot/DoublePivot.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Sort.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Row/RowContext.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Raw.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Row/Row.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Index.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/ForeignKey.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Query.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/Entity.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/Dirty.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/SQLite.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 /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.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/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/checkouts/sqlite.git--8232814251736334455/Sources/CSQLite/include/sqlite3.h /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/Fluent.build/IdentifierType~partial.swiftdoc : /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Utilities/UUID.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Database+Schema.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Blob.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Field.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/ComputedField.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/NodeUtilities/Method+Node.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/NodeUtilities/Filter+Node.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pagination/Query+Page.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pagination/Page.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/Storage.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/Timestampable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pagination/Paginatable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Database/Transactable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/SoftDeletable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/QueryRepresentable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Row/RowConvertible.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/Filter+Scope.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/IdentifierType.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Database/Database.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Aggregate.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/NodeUtilities/Scope+String.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/NodeUtilities/Relation+String.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/NodeUtilities/Comparison+String.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Log.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Chunk.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pivot/PivotProtocol.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Database/ThreadConnectionPool.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Relations/Children.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Join.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Preparation/Database+Preparation.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Preparation/Preparation.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Preparation/Migration.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Action.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Database/Connection.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/KeyNamingConvention.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/Comparison.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/Query+Group.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Builder.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Modifier.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/Query+Filter.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Filter/Filter.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Database/Driver.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/SQLite/SQLiteDriver.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/SQL/SQLSerializer.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/SQL/GeneralSQLSerializer.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/SQLite/SQLiteSerializer.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Relations/RelationError.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pagination/PaginationError.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Preparation/PreparationError.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pivot/PivotError.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/QueryError.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/EntityError.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Creator.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Database/Executor.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Relations/Siblings.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Utilities/Exports.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Distinct.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Limit.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Relations/Parent.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pivot/Pivot.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Pivot/DoublePivot.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Sort.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Row/RowContext.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Raw.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Row/Row.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/Index.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Schema/ForeignKey.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Query/Query.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/Entity.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/fluent.git-6251908308727715749/Sources/Fluent/Entity/Dirty.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/SQLite.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 /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.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/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/checkouts/sqlite.git--8232814251736334455/Sources/CSQLite/include/sqlite3.h /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
|
//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).
core.time is publically imported into std.datetime, it isn't necessary
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. 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). To print it, $(D toString) is
sufficient, but if using $(D toISOString), $(D toISOExtString), or
$(D toSimpleString), 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").
To remember which units are abbreviated and which aren't,
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).
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:
<a href="../intro-to-datetime.html">Introduction to std._datetime </a><br>
$(WEB en.wikipedia.org/wiki/ISO_8601, ISO 8601)<br>
$(WEB en.wikipedia.org/wiki/Tz_database,
Wikipedia entry on TZ Database)<br>
$(WEB en.wikipedia.org/wiki/List_of_tz_database_time_zones,
List of Time Zones)<br>
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;
import std.utf;
version(Windows)
{
import core.sys.windows.windows;
import std.c.windows.winsock;
import std.windows.registry;
}
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;
}
//Comment this out to disable std.datetime's unit tests.
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;
version(testStdDateTime) unittest
{
initializeTests();
}
//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.
version(testStdDateTime) 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. To get the first time point
in the range to match what the function generates, then 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. Using
$(D PopFirst.yes) would tell the function which returned the
range that $(D popFront) was to be called so that front would then be
an Easter - the next one generated by the function (which when
iterating forward would be the Easter following the original $(D front),
while when 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 is desired -
e.g. if 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 private constants.
//==============================================================================
/++
Array of integers representing the last days of each month in a year.
+/
private immutable int[13] lastDayNonLeap = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365];
/++
Array of integers representing the last days of each month in a leap year.
+/
private immutable int[13] lastDayLeap = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366];
/++
Array of the long names of each month.
+/
private immutable string[12] longMonthNames = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
];
/++
Array of the short (three letter) names of each month.
+/
private immutable string[12] shortMonthNames = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
];
//==============================================================================
// Section with other types.
//==============================================================================
/++
Exception type used by std.datetime. It's an alias to TimeException, which
is what core.time uses. Either can be caught without concern 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 fileTime;
GetSystemTimeAsFileTime(&fileTime);
return FILETIMEToStdTime(&fileTime);
}
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 to get the current time from the
system or doing anything that involves time zones. Unlike
$(D DateTime), the time zone is an integral part of $(D SysTime) (though for
local time applications, time zones can be ignored 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.
For calendar-based operations that don't
care about time zones, then $(D DateTime) would be the type to
use. For system time, use $(D SysTime).
$(D Clock.currTime) will return the current time as a $(D SysTime).
To convert a $(D SysTime) to a $(D Date) or $(D DateTime), simply cast
it. To convert a $(D Date) or $(D DateTime) to a
$(D SysTime), use $(D SysTime)'s constructor, and 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).
To not risk any conversion errors, keep times as
$(D SysTime)s. Aside from DST though, there shouldn't be any conversion
problems.
For using time zones other than local time or UTC, use
$(D PosixTimeZone) on Posix systems (or on Windows, if providing the TZ
Database files), and use $(D WindowsTimeZone) on Windows systems.
The time in $(D SysTime) is kept internally in hnsecs from midnight,
January 1st, 1 A.D. UTC. Conversion error cannot happen 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, see 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(dur!"minutes"(-60)), 36_000_000_000L);
test(DateTime(1, 1, 1, 0, 0, 0), new SimpleTimeZone(Duration.zero), 0);
test(DateTime(1, 1, 1, 0, 0, 0), new SimpleTimeZone(dur!"minutes"(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 SysTime rhs) const pure nothrow
{
return opEquals(rhs);
}
/// ditto
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(SysTime st,
immutable TimeZone tz1,
immutable TimeZone tz2)
{
auto st1 = st;
st1.timezone = tz1;
auto st2 = st;
st2.timezone = tz2;
_assertPred!("opCmp", "==")(st1, st2);
}
auto sts = array(map!SysTime(chain(testDateTimesBC, testDateTimesAD)));
foreach(st; sts)
foreach(tz1; testTZs)
foreach(tz2; testTZs)
testEqual(st, tz1, tz2);
static void testCmp(SysTime st1,
immutable TimeZone tz1,
SysTime st2,
immutable TimeZone tz2)
{
st1.timezone = tz1;
st2.timezone = tz2;
_assertPred!("opCmp", "<")(st1, st2);
_assertPred!("opCmp", ">")(st2, st1);
}
foreach(si, st1; sts)
foreach(st2; sts[si+1 .. $])
foreach(tz1; testTZs)
foreach(tz2; testTZs)
testCmp(st1, tz1, st2, 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
{
foreach(day; chain(testDays))
{
foreach(st; chain(testSysTimesBC, testSysTimesAD))
{
auto dt = cast(DateTime)st;
if(day > maxDay(dt.year, dt.month))
continue;
auto expected = SysTime(DateTime(dt.year, dt.month, day, dt.hour, dt.minute, dt.second),
st.fracSec,
st.timezone);
st.day = day;
assert(st == expected, format("[%s] [%s]", st, expected));
}
}
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);
auto expected = SysTime(DateTime(Date(year, month, max), tod), fs, tz);
st.day = max;
assert(st == expected, format("[%s] [%s]", st, expected));
}
}
}
}
}
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
{
foreach(hour; chain(testHours))
{
foreach(st; chain(testSysTimesBC, testSysTimesAD))
{
auto dt = cast(DateTime)st;
auto expected = SysTime(DateTime(dt.year, dt.month, dt.day, hour, dt.minute, dt.second),
st.fracSec,
st.timezone);
st.hour = hour;
assert(st == expected, format("[%s] [%s]", st, expected));
}
}
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
{
foreach(minute; testMinSecs)
{
foreach(st; chain(testSysTimesBC, testSysTimesAD))
{
auto dt = cast(DateTime)st;
auto expected = SysTime(DateTime(dt.year, dt.month, dt.day, dt.hour, minute, dt.second),
st.fracSec,
st.timezone);
st.minute = minute;
assert(st == expected, format("[%s] [%s]", st, expected));
}
}
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
{
foreach(second; testMinSecs)
{
foreach(st; chain(testSysTimesBC, testSysTimesAD))
{
auto dt = cast(DateTime)st;
auto expected = SysTime(DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, second),
st.fracSec,
st.timezone);
st.second = second;
assert(st == expected, format("[%s] [%s]", st, expected));
}
}
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
{
foreach(fracSec; testFracSecs)
{
foreach(st; chain(testSysTimesBC, testSysTimesAD))
{
auto dt = cast(DateTime)st;
auto expected = SysTime(DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second),
fracSec,
st.timezone);
st.fracSec = fracSec;
assert(st == expected, format("[%s] [%s]", st, expected));
}
}
auto st = testSysTimesAD[0];
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 what the offset from UTC is for this $(D SysTime).
It includes the DST offset in effect at that time (if any).
+/
@property Duration utcOffset() const nothrow
{
return _timezone.utcOffsetAt(_stdTime);
}
/++
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(dur!"minutes"(-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(dur!"minutes"(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. Rolling a $(D SysTime) 12 months
gets 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. For instance, rolling a $(D SysTime) one
year's worth of days gets 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.
To get the difference in years, subtract the year property
of two $(D SysTime)s. To get the difference in days or weeks,
subtract the $(D SysTime)s themselves and use the $(D Duration)
that results. Because converting between months and smaller
units requires a specific date (which $(D Duration)s don't have),
getting the difference in months requires 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;
long 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;
}
//Explicitly undocumented. Do not use. To be removed in March 2013.
deprecated("Please use daysInMonth instead.") @property ubyte endOfMonthDay() const nothrow
{
return Date(dayOfGregorianCal).daysInMonth;
}
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 = dur!"hnsecs"(adjustedTime - stdTime);
return format("%s%s%s",
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(dur!"minutes"(-360))).toISOString(),
"20121221T121212-06:00");
_assertPred!"=="(SysTime(DateTime(2012, 12, 21, 12, 12, 12),
new SimpleTimeZone(dur!"minutes"(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 = dur!"hnsecs"(adjustedTime - stdTime);
return format("%s%s%s",
dateTime.toISOExtString(),
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()).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(dur!"minutes"(-360))).toISOExtString(),
"2012-12-21T12:12:12-06:00");
_assertPred!"=="(SysTime(DateTime(2012, 12, 21, 12, 12, 12),
new SimpleTimeZone(dur!"minutes"(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 = dur!"hnsecs"(adjustedTime - stdTime);
return format("%s%s%s",
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(dur!"minutes"(-360))).toSimpleString(),
"2012-Dec-21 12:12:12-06:00");
_assertPred!"=="(SysTime(DateTime(2012, 12, 21, 12, 12, 12),
new SimpleTimeZone(dur!"minutes"(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
$(LREF SimpleTimeZone) which corresponds to the given offset from UTC is
used. To get the returned $(D SysTime) to be a particular time
zone, 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(dur!"hours"(-8))));
assert(SysTime.fromISOString("20100704T070612+8:00") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12),
new SimpleTimeZone(dur!"hours"(8))));
--------------------
+/
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(dur!"minutes"(-60))));
_assertPred!"=="(SysTime.fromISOString("20101222T172201-1"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(-60))));
_assertPred!"=="(SysTime.fromISOString("20101222T172201-1:30"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(-90))));
_assertPred!"=="(SysTime.fromISOString("20101222T172201-8:00"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(-480))));
_assertPred!"=="(SysTime.fromISOString("20101222T172201+1:00"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(60))));
_assertPred!"=="(SysTime.fromISOString("20101222T172201+1"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(60))));
_assertPred!"=="(SysTime.fromISOString("20101222T172201+1:30"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(90))));
_assertPred!"=="(SysTime.fromISOString("20101222T172201+8:00"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(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(dur!"minutes"(-60))));
_assertPred!"=="(SysTime.fromISOString("20101222T172201.45-1"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(4_500_000),
new SimpleTimeZone(dur!"minutes"(-60))));
_assertPred!"=="(SysTime.fromISOString("20101222T172201.1-1:30"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(1_000_000),
new SimpleTimeZone(dur!"minutes"(-90))));
_assertPred!"=="(SysTime.fromISOString("20101222T172201.55-8:00"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(5_500_000),
new SimpleTimeZone(dur!"minutes"(-480))));
_assertPred!"=="(SysTime.fromISOString("20101222T172201.1234567+1:00"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(1_234_567),
new SimpleTimeZone(dur!"minutes"(60))));
_assertPred!"=="(SysTime.fromISOString("20101222T172201.0+1"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(0),
new SimpleTimeZone(dur!"minutes"(60))));
_assertPred!"=="(SysTime.fromISOString("20101222T172201.0000000+1:30"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(0),
new SimpleTimeZone(dur!"minutes"(90))));
_assertPred!"=="(SysTime.fromISOString("20101222T172201.45+8:00"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), FracSec.from!"hnsecs"(4_500_000),
new SimpleTimeZone(dur!"minutes"(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(dur!"hours"(-8))));
assert(SysTime.fromISOString("20100704T070612+8:00") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12), new SimpleTimeZone(dur!"hours"(8))));
}
}
/++
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
$(LREF SimpleTimeZone) which corresponds to the given offset from UTC is
used. To get the returned $(D SysTime) to be a particular time
zone, 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(dur!"hours"(-8))));
assert(SysTime.fromISOExtString("2010-07-04T07:06:12+8:00") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12),
new SimpleTimeZone(dur!"hours"(8))));
--------------------
+/
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));
}
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(dur!"minutes"(-60))));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01-1"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(-60))));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01-1:30"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(-90))));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01-8:00"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(-480))));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01+1:00"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(60))));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01+1"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(60))));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01+1:30"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(90))));
_assertPred!"=="(SysTime.fromISOExtString("2010-12-22T17:22:01+8:00"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(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(dur!"minutes"(-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(dur!"minutes"(-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(dur!"minutes"(-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(dur!"minutes"(-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(dur!"minutes"(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(dur!"minutes"(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(dur!"minutes"(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(dur!"minutes"(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(dur!"hours"(-8))));
assert(SysTime.fromISOExtString("2010-07-04T07:06:12+8:00") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12), new SimpleTimeZone(dur!"hours"(8))));
}
}
/++
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
$(LREF SimpleTimeZone) which corresponds to the given offset from UTC is
used. To get the returned $(D SysTime) to be a particular time
zone, 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(dur!"hours"(-8))));
assert(SysTime.fromSimpleString("2010-Jul-04 07:06:12+8:00") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12),
new SimpleTimeZone(dur!"hours"(8))));
--------------------
+/
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(dur!"minutes"(-60))));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01-1"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(-60))));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01-1:30"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(-90))));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01-8:00"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(-480))));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01+1:00"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(60))));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01+1"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(60))));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01+1:30"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(90))));
_assertPred!"=="(SysTime.fromSimpleString("2010-Dec-22 17:22:01+8:00"),
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new SimpleTimeZone(dur!"minutes"(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(dur!"minutes"(-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(dur!"minutes"(-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(dur!"minutes"(-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(dur!"minutes"(-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(dur!"minutes"(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(dur!"minutes"(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(dur!"minutes"(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(dur!"minutes"(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(dur!"hours"(-8))));
assert(SysTime.fromSimpleString("2010-Jul-04 07:06:12+8:00") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12), new SimpleTimeZone(dur!"hours"(8))));
}
}
//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. Rolling a $(D Date) 12 months gets
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. For instance, rolling a $(D Date) one
year's worth of days gets 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.
To get the difference in years, subtract the year property
of two $(D SysTime)s. To get the difference in days or weeks,
subtract the $(D SysTime)s themselves and use the $(D Duration)
that results. Because converting between months and smaller
units requires a specific date (which $(D Duration)s don't have),
getting the difference in months requires 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
{
if (_month >= Month.jan && _month <= Month.dec)
{
immutable int[] lastDay = isLeapYear ? lastDayLeap : lastDayNonLeap;
auto monthIndex = _month - Month.jan;
return cast(ushort)(lastDay[monthIndex] + _day);
}
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
{
immutable int[] lastDay = isLeapYear ? lastDayLeap : lastDayNonLeap;
if(day <= 0 || day > (isLeapYear ? daysInLeapYear : daysInYear) )
throw new DateTimeException("Invalid day of the year.");
foreach (i; 1..lastDay.length)
{
if (day <= lastDay[i])
{
_month = cast(Month)(cast(int)Month.jan + i - 1);
_day = cast(ubyte)(day - lastDay[i - 1]);
return;
}
}
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);
}
//Explicitly undocumented. Do not use. To be removed in March 2013.
deprecated("Please use daysInMonth instead.") @property ubyte endOfMonthDay() const nothrow
{
return maxDay(_year, _month);
}
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.");
}
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));
}
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. For instance, rolling a $(D TimeOfDay)
one hours's worth of minutes gets 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.");
}
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));
}
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 an object
which holds both the date and the time. It is optimized for calendar-based
operations and has no concept of time zone. For an object which is
optimized for time operations based on the system time, 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. Rolling a $(D DateTime) 12 months
gets 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. For instance, rolling a $(D DateTime) one
year's worth of days gets 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.
To get the difference in years, subtract the year property
of two $(D SysTime)s. To get the difference in days or weeks,
subtract the $(D SysTime)s themselves and use the $(D Duration)
that results. Because converting between months and smaller
units requires a specific date (which $(D Duration)s don't have),
getting the difference in months requires 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;
}
//Explicitly undocumented. Do not use. To be removed in March 2013.
deprecated("Please use daysInMonth instead.") @property ubyte endOfMonthDay() const nothrow
{
return _date.daysInMonth;
}
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.");
}
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);
}
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 iteration 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," making them easily searchable.
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.
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 when creating a custom 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," making them easily searchable.
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.
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 for custom delegates.
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 = delegate (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 = delegate (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), because an interval
going from negative infinity to positive infinity
is not possible.
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), because an interval
going from negative infinity to positive infinity
is not possible.
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), because an interval
going from negative infinity to positive infinity
is not possible.
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), because an interval
going from negative infinity to positive infinity
is not possible.
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," to make them easily searchable.
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.
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 for custom delegates.
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 = delegate (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.
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), because an interval
going from negative infinity to positive infinity
is not possible.
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), because an interval
going from negative infinity to positive infinity
is not possible.
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), because an interval
going from negative infinity to positive infinity
is not possible.
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), because an interval
going from negative infinity to positive infinity
is not possible.
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," to make them easily searchable.
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.
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 for custom delegates.
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 = delegate (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 iteration 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 iteration over successive time points
which are in the same month but different years. For example,
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 iteration 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 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. For instance,
to iterate over all of the days in
the interval $(D Interval!Date), 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, to iterate 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. To iterate 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 iterating
forward and the generated time point is before $(D front), or if
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. For
instance, to iterate
over all of the days in the interval $(D PosInfInterval!Date), 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,
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. For
instance, to iterate
over all of the days in the interval $(D NegInfInterval!Date), 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,
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 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)<br>
$(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 what the offset from UTC is at the given std time.
It includes the DST offset in effect at that time (if any).
Params:
stdTime = The UTC time for which to get the offset from UTC for this
time zone.
+/
Duration utcOffsetAt(long stdTime) const nothrow
{
return dur!"hnsecs"(utcToTZ(stdTime) - stdTime);
}
/++
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. For
$(D PosixTimeZone) on Windows, 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). This function allows for
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)<br>
$(WEB en.wikipedia.org/wiki/List_of_tz_database_time_zones, List of
Time Zones)<br>
$(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 desired time zone
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 immutable(TimeZone) testTZ(string tzName,
string stdName,
string dstName,
Duration utcOffset,
Duration dstOffset,
bool north = true)
{
scope(failure) writefln("Failed time zone: %s", tzName);
immutable tz = TimeZone.getTimeZone(tzName);
immutable hasDST = dstOffset != dur!"hnsecs"(0);
version(Posix)
_assertPred!"=="(tz.name, tzName);
else version(Windows)
_assertPred!"=="(tz.name, stdName);
//_assertPred!"=="(tz.stdName, stdName); //Locale-dependent
//_assertPred!"=="(tz.dstName, dstName); //Locale-dependent
_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 - utcOffset, UTC());
auto dstUTC = SysTime(stdDate - utcOffset + dstOffset, UTC());
assert(!std.dstInEffect);
_assertPred!"=="(dst.dstInEffect, hasDST);
_assertPred!"=="(tz.utcOffsetAt(std.stdTime), utcOffset);
_assertPred!"=="(tz.utcOffsetAt(dst.stdTime), utcOffset + dstOffset);
_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_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); //Locale-dependent
//assert(leapTZ.dstName == dstName); //Locale-dependent
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")(25);
//_assertPred!"=="(leapSTD.adjTime - leapDiff, std.adjTime);
//_assertPred!"=="(leapDST.adjTime - leapDiff, dst.adjTime);
}
}
return tz;
}
auto dstSwitches = [/+America/Los_Angeles+/ tuple(DateTime(2012, 3, 11), DateTime(2012, 11, 4), 2, 2),
/+America/New_York+/ tuple(DateTime(2012, 3, 11), DateTime(2012, 11, 4), 2, 2),
///+America/Santiago+/ tuple(DateTime(2011, 8, 21), DateTime(2011, 5, 8), 0, 0),
/+Europe/London+/ tuple(DateTime(2012, 3, 25), DateTime(2012, 10, 28), 1, 2),
/+Europe/Paris+/ tuple(DateTime(2012, 3, 25), DateTime(2012, 10, 28), 2, 3),
/+Australia/Adelaide+/ tuple(DateTime(2012, 10, 7), DateTime(2012, 4, 1), 2, 3)];
version(Posix)
{
version(FreeBSD) enum utcZone = "Etc/UTC";
version(linux) enum utcZone = "UTC";
version(OSX) enum utcZone = "UTC";
auto tzs = [testTZ("America/Los_Angeles", "PST", "PDT", dur!"hours"(-8), dur!"hours"(1)),
testTZ("America/New_York", "EST", "EDT", dur!"hours"(-5), dur!"hours"(1)),
//testTZ("America/Santiago", "CLT", "CLST", dur!"hours"(-4), dur!"hours"(1), false),
testTZ("Europe/London", "GMT", "BST", dur!"hours"(0), dur!"hours"(1)),
testTZ("Europe/Paris", "CET", "CEST", dur!"hours"(1), dur!"hours"(1)),
//Per www.timeanddate.com, it should be "CST" and "CDT",
//but the OS insists that it's "CST" for both. We should
//probably figure out how to report an error in the TZ
//database and report it.
testTZ("Australia/Adelaide", "CST", "CST",
dur!"hours"(9) + dur!"minutes"(30), dur!"hours"(1), false)];
testTZ(utcZone, "UTC", "UTC", dur!"hours"(0), dur!"hours"(0));
assertThrown!DateTimeException(PosixTimeZone.getTimeZone("hello_world"));
}
else version(Windows)
{
auto tzs = [testTZ("America/Los_Angeles", "Pacific Standard Time",
"Pacific Daylight Time", dur!"hours"(-8), dur!"hours"(1)),
testTZ("America/New_York", "Eastern Standard Time",
"Eastern Daylight Time", dur!"hours"(-5), dur!"hours"(1)),
//testTZ("America/Santiago", "Pacific SA Standard Time",
//"Pacific SA Daylight Time", dur!"hours"(-4), dur!"hours"(1), false),
testTZ("Europe/London", "GMT Standard Time",
"GMT Daylight Time", dur!"hours"(0), dur!"hours"(1)),
testTZ("Europe/Paris", "Romance Standard Time",
"Romance Daylight Time", dur!"hours"(1), dur!"hours"(1)),
testTZ("Australia/Adelaide", "Cen. Australia Standard Time",
"Cen. Australia Daylight Time",
dur!"hours"(9) + dur!"minutes"(30), dur!"hours"(1), false)];
testTZ("Atlantic/Reykjavik", "Greenwich Standard Time",
"Greenwich Daylight Time", dur!"hours"(0), dur!"hours"(0));
assertThrown!DateTimeException(WindowsTimeZone.getTimeZone("hello_world"));
}
else
assert(0, "OS not supported.");
foreach(i; 0 .. tzs.length)
{
auto tz = tzs[i];
immutable spring = dstSwitches[i][2];
immutable fall = dstSwitches[i][3];
auto stdOffset = SysTime(dstSwitches[i][0] + dur!"days"(-1), tz).utcOffset;
auto dstOffset = stdOffset + dur!"hours"(1);
//Verify that creating a SysTime in the given time zone results
//in a SysTime with the correct std time during and surrounding
//a DST switch.
foreach(hour; -12 .. 13)
{
auto st = SysTime(dstSwitches[i][0] + dur!"hours"(hour), tz);
immutable targetHour = hour < 0 ? hour + 24 : hour;
static void testHour(SysTime st, int hour, string tzName, size_t line = __LINE__)
{
enforce(st.hour == hour,
new AssertError(format("[%s] [%s]: [%s] [%s]", st, tzName, st.hour, hour),
__FILE__, line));
}
void testOffset1(Duration offset, bool dstInEffect, size_t line = __LINE__)
{
AssertError msg(string tag)
{
return new AssertError(format("%s [%s] [%s]: [%s] [%s] [%s]",
tag, st, tz.name, st.utcOffset, stdOffset, dstOffset),
__FILE__, line);
}
enforce(st.dstInEffect == dstInEffect, msg("1"));
enforce(st.utcOffset == offset, msg("2"));
enforce((st + dur!"minutes"(1)).utcOffset == offset, msg("3"));
}
if(hour == spring)
{
testHour(st, spring + 1, tz.name);
testHour(st + dur!"minutes"(1), spring + 1, tz.name);
}
else
{
testHour(st, targetHour, tz.name);
testHour(st + dur!"minutes"(1), targetHour, tz.name);
}
if(hour < spring)
testOffset1(stdOffset, false);
else
testOffset1(dstOffset, true);
st = SysTime(dstSwitches[i][1] + dur!"hours"(hour), tz);
testHour(st, targetHour, tz.name);
//Verify that 01:00 is the first 01:00 (or whatever hour before the switch is).
if(hour == fall - 1)
testHour(st + dur!"hours"(1), targetHour, tz.name);
if(hour < fall)
testOffset1(dstOffset, true);
else
testOffset1(stdOffset, false);
}
//Verify that converting a time in UTC to a time in another
//time zone results in the correct time during and surrounding
//a DST switch.
bool first = true;
auto springSwitch = SysTime(dstSwitches[i][0] + dur!"hours"(spring), UTC()) - stdOffset;
auto fallSwitch = SysTime(dstSwitches[i][1] + dur!"hours"(fall), UTC()) - dstOffset;
//@@@BUG@@@ 3659 makes this necessary.
auto fallSwitchMinus1 = fallSwitch - dur!"hours"(1);
foreach(hour; -24 .. 25)
{
auto utc = SysTime(dstSwitches[i][0] + dur!"hours"(hour), UTC());
auto local = utc.toOtherTZ(tz);
void testOffset2(Duration offset, size_t line = __LINE__)
{
AssertError msg(string tag)
{
return new AssertError(format("%s [%s] [%s]: [%s] [%s]", tag, hour, tz.name, utc, local),
__FILE__, line);
}
enforce((utc + offset).hour == local.hour, msg("1"));
enforce((utc + offset + dur!"minutes"(1)).hour == local.hour, msg("2"));
}
if(utc < springSwitch)
testOffset2(stdOffset);
else
testOffset2(dstOffset);
utc = SysTime(dstSwitches[i][1] + dur!"hours"(hour), UTC());
local = utc.toOtherTZ(tz);
if(utc == fallSwitch || utc == fallSwitchMinus1)
{
if(first)
{
testOffset2(dstOffset);
first = false;
}
else
testOffset2(stdOffset);
}
else if(utc > fallSwitch)
testOffset2(stdOffset);
else
testOffset2(dstOffset);
}
}
}
/++
Returns a list of the names of the time zones installed on the system.
Providing a sub-name narrows down the list of time zones (which
can number in the thousands). For example,
passing in "America" as the sub-name returns only the time zones which
begin with "America".
On Windows, this function will convert the Windows time zone names to
the corresponding TZ Database names with
$(D windowsTZNameToTZDatabaseName). To get the actual Windows time
zone names, use $(D WindowsTimeZone.getInstalledTZNames) directly.
Params:
subName = The first part of the time zones desired.
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
{
alias pure nothrow immutable(LocalTime) function() FuncType;
return (cast(FuncType)&singleton)();
}
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)<br>
$(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);
}
}
/++
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);
}
}
/++
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);
immutable past = unixTime - cast(time_t)convert!("days", "seconds")(1);
tm* timeInfo = localtime(past < unixTime ? &past : &unixTime);
immutable pastOffset = timeInfo.tm_gmtoff;
immutable future = unixTime + cast(time_t)convert!("days", "seconds")(1);
timeInfo = localtime(future > unixTime ? &future : &unixTime);
immutable futureOffset = timeInfo.tm_gmtoff;
if(pastOffset == futureOffset)
return adjTime - convert!("seconds", "hnsecs")(pastOffset);
if(pastOffset < futureOffset)
unixTime -= cast(time_t)convert!("hours", "seconds")(1);
unixTime -= pastOffset;
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)
{
assert(LocalTime().tzToUTC(LocalTime().utcToTZ(0)) == 0);
assert(LocalTime().utcToTZ(LocalTime().tzToUTC(0)) == 0);
_assertPred!"=="(LocalTime().tzToUTC(LocalTime().utcToTZ(0)), 0);
_assertPred!"=="(LocalTime().utcToTZ(LocalTime().tzToUTC(0)), 0);
version(Posix)
{
scope(exit) clearTZEnvVar();
auto tzInfos = [tuple("America/Los_Angeles", DateTime(2012, 3, 11), DateTime(2012, 11, 4), 2, 2),
tuple("America/New_York", DateTime(2012, 3, 11), DateTime(2012, 11, 4), 2, 2),
//tuple("America/Santiago", DateTime(2011, 8, 21), DateTime(2011, 5, 8), 0, 0),
tuple("Atlantic/Azores", DateTime(2011, 3, 27), DateTime(2011, 10, 30), 0, 1),
tuple("Europe/London", DateTime(2012, 3, 25), DateTime(2012, 10, 28), 1, 2),
tuple("Europe/Paris", DateTime(2012, 3, 25), DateTime(2012, 10, 28), 2, 3),
tuple("Australia/Adelaide", DateTime(2012, 10, 7), DateTime(2012, 4, 1), 2, 3)];
foreach(i; 0 .. tzInfos.length)
{
auto tzName = tzInfos[i][0];
setTZEnvVar(tzName);
immutable spring = tzInfos[i][3];
immutable fall = tzInfos[i][4];
auto stdOffset = SysTime(tzInfos[i][1] + dur!"hours"(-12)).utcOffset;
auto dstOffset = stdOffset + dur!"hours"(1);
//Verify that creating a SysTime in the given time zone results
//in a SysTime with the correct std time during and surrounding
//a DST switch.
foreach(hour; -12 .. 13)
{
auto st = SysTime(tzInfos[i][1] + dur!"hours"(hour));
immutable targetHour = hour < 0 ? hour + 24 : hour;
static void testHour(SysTime st, int hour, string tzName, size_t line = __LINE__)
{
enforce(st.hour == hour,
new AssertError(format("[%s] [%s]: [%s] [%s]", st, tzName, st.hour, hour),
__FILE__, line));
}
void testOffset1(Duration offset, bool dstInEffect, size_t line = __LINE__)
{
AssertError msg(string tag)
{
return new AssertError(format("%s [%s] [%s]: [%s] [%s] [%s]",
tag, st, tzName, st.utcOffset, stdOffset, dstOffset),
__FILE__, line);
}
enforce(st.dstInEffect == dstInEffect, msg("1"));
enforce(st.utcOffset == offset, msg("2"));
enforce((st + dur!"minutes"(1)).utcOffset == offset, msg("3"));
}
if(hour == spring)
{
testHour(st, spring + 1, tzName);
testHour(st + dur!"minutes"(1), spring + 1, tzName);
}
else
{
testHour(st, targetHour, tzName);
testHour(st + dur!"minutes"(1), targetHour, tzName);
}
if(hour < spring)
testOffset1(stdOffset, false);
else
testOffset1(dstOffset, true);
st = SysTime(tzInfos[i][2] + dur!"hours"(hour));
testHour(st, targetHour, tzName);
//Verify that 01:00 is the first 01:00 (or whatever hour before the switch is).
if(hour == fall - 1)
testHour(st + dur!"hours"(1), targetHour, tzName);
if(hour < fall)
testOffset1(dstOffset, true);
else
testOffset1(stdOffset, false);
}
//Verify that converting a time in UTC to a time in another
//time zone results in the correct time during and surrounding
//a DST switch.
bool first = true;
auto springSwitch = SysTime(tzInfos[i][1] + dur!"hours"(spring), UTC()) - stdOffset;
auto fallSwitch = SysTime(tzInfos[i][2] + dur!"hours"(fall), UTC()) - dstOffset;
//@@@BUG@@@ 3659 makes this necessary.
auto fallSwitchMinus1 = fallSwitch - dur!"hours"(1);
foreach(hour; -24 .. 25)
{
auto utc = SysTime(tzInfos[i][1] + dur!"hours"(hour), UTC());
auto local = utc.toLocalTime();
void testOffset2(Duration offset, size_t line = __LINE__)
{
AssertError msg(string tag)
{
return new AssertError(format("%s [%s] [%s]: [%s] [%s]", tag, hour, tzName, utc, local),
__FILE__, line);
}
enforce((utc + offset).hour == local.hour, msg("1"));
enforce((utc + offset + dur!"minutes"(1)).hour == local.hour, msg("2"));
}
if(utc < springSwitch)
testOffset2(stdOffset);
else
testOffset2(dstOffset);
utc = SysTime(tzInfos[i][2] + dur!"hours"(hour), UTC());
local = utc.toLocalTime();
if(utc == fallSwitch || utc == fallSwitchMinus1)
{
if(first)
{
testOffset2(dstOffset);
first = false;
}
else
testOffset2(stdOffset);
}
else if(utc > fallSwitch)
testOffset2(stdOffset);
else
testOffset2(dstOffset);
}
}
}
}
}
private:
this() immutable
{
super("", "", "");
tzset();
}
static shared LocalTime _localTime;
static bool _initialized;
static immutable(LocalTime) singleton()
{
//TODO Make this use double-checked locking once shared has been fixed
//to use memory fences properly.
if(!_initialized)
{
synchronized
{
if(!_localTime)
_localTime = cast(shared LocalTime)new immutable(LocalTime)();
}
_initialized = true;
}
return cast(immutable LocalTime)_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
{
alias pure nothrow immutable(UTC) function() FuncType;
return (cast(FuncType)&singleton)();
}
/++
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);
}
}
}
/++
Returns a $(CXREF time, Duration) of 0.
Params:
stdTime = The UTC time for which to get the offset from UTC for this
time zone.
+/
override Duration utcOffsetAt(long stdTime) const nothrow
{
return dur!"hnsecs"(0);
}
private:
this() immutable pure
{
super("UTC", "UTC", "UTC");
}
static shared UTC _utc;
static bool _initialized;
static immutable(UTC) singleton()
{
//TODO Make this use double-checked locking once shared has been fixed
//to use memory fences properly.
if(!_initialized)
{
synchronized
{
if(!_utc)
_utc = cast(shared UTC)new immutable(UTC)();
}
_initialized = true;
}
return cast(immutable UTC)_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 + _utcOffset.total!"hnsecs";
}
version(testStdDateTime) unittest
{
auto west = new SimpleTimeZone(dur!"hours"(-8));
auto east = new SimpleTimeZone(dur!"hours"(8));
assert(west.utcToTZ(0) == -288_000_000_000L);
assert(east.utcToTZ(0) == 288_000_000_000L);
assert(west.utcToTZ(54_321_234_567_890L) == 54_033_234_567_890L);
const cstz = west;
static assert(__traits(compiles, west.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 - _utcOffset.total!"hnsecs";
}
version(testStdDateTime) unittest
{
auto west = new SimpleTimeZone(dur!"hours"(-8));
auto east = new SimpleTimeZone(dur!"hours"(8));
assert(west.tzToUTC(-288_000_000_000L) == 0);
assert(east.tzToUTC(288_000_000_000L) == 0);
assert(west.tzToUTC(54_033_234_567_890L) == 54_321_234_567_890L);
const cstz = west;
static assert(__traits(compiles, west.tzToUTC(20005)));
static assert(__traits(compiles, cstz.tzToUTC(20005)));
}
/++
Returns utcOffset as a $(CXREF time, Duration).
Params:
stdTime = The UTC time for which to get the offset from UTC for this
time zone.
+/
override Duration utcOffsetAt(long stdTime) const nothrow
{
return _utcOffset;
}
/++
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(Duration utcOffset, string stdName = "") immutable
{
//FIXME This probably needs to be changed to something like (-12 - 13).
enforceEx!DateTimeException(abs(utcOffset) < dur!"minutes"(1440),
"Offset from UTC must be within range (-24:00 - 24:00).");
super("", stdName, "");
this._utcOffset = utcOffset;
}
/++ Ditto +/
this(int utcOffset, string stdName = "") immutable
{
this(dur!"minutes"(utcOffset), stdName);
}
version(testStdDateTime) unittest
{
foreach(stz; [new SimpleTimeZone(dur!"hours"(-8), "PST"),
new SimpleTimeZone(-8 * 60, "PST")])
{
assert(stz.name == "");
assert(stz.stdName == "PST");
assert(stz.dstName == "");
assert(stz.utcOffset == -8 * 60);
}
}
/++
The number of minutes the offset from UTC is (negative is west of UTC,
positive is east).
+/
@property int utcOffset() @safe const pure nothrow
{
return cast(int)_utcOffset.total!"minutes";
}
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(Duration utcOffset)
{
immutable absOffset = abs(utcOffset);
enforceEx!DateTimeException(absOffset < dur!"minutes"(1440),
"Offset from UTC must be within range (-24:00 - 24:00).");
if(utcOffset < Duration.zero)
return format("-%02d:%02d", absOffset.hours, absOffset.minutes);
return format("+%02d:%02d", absOffset.hours, absOffset.minutes);
}
version(testStdDateTime) unittest
{
static string testSTZInvalid(Duration offset)
{
return SimpleTimeZone.toISOString(offset);
}
assertThrown!DateTimeException(testSTZInvalid(dur!"minutes"(1440)));
assertThrown!DateTimeException(testSTZInvalid(dur!"minutes"(-1440)));
assert(toISOString(dur!"minutes"(0)) == "+00:00");
assert(toISOString(dur!"minutes"(1)) == "+00:01");
assert(toISOString(dur!"minutes"(10)) == "+00:10");
assert(toISOString(dur!"minutes"(59)) == "+00:59");
assert(toISOString(dur!"minutes"(60)) == "+01:00");
assert(toISOString(dur!"minutes"(90)) == "+01:30");
assert(toISOString(dur!"minutes"(120)) == "+02:00");
assert(toISOString(dur!"minutes"(480)) == "+08:00");
assert(toISOString(dur!"minutes"(1439)) == "+23:59");
assert(toISOString(dur!"minutes"(-1)) == "-00:01");
assert(toISOString(dur!"minutes"(-10)) == "-00:10");
assert(toISOString(dur!"minutes"(-59)) == "-00:59");
assert(toISOString(dur!"minutes"(-60)) == "-01:00");
assert(toISOString(dur!"minutes"(-90)) == "-01:30");
assert(toISOString(dur!"minutes"(-120)) == "-02:00");
assert(toISOString(dur!"minutes"(-480)) == "-08:00");
assert(toISOString(dur!"minutes"(-1439)) == "-23:59");
}
/+
Takes a time zone as a string with an offset from UTC and returns a
$(LREF 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 * (dur!"hours"(hours) + dur!"minutes"(minutes)));
}
version(testStdDateTime) unittest
{
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"));
assert(SimpleTimeZone.fromISOString("+00:00").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(0))).utcOffset);
assert(SimpleTimeZone.fromISOString("+00:01").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(1))).utcOffset);
assert(SimpleTimeZone.fromISOString("+00:10").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(10))).utcOffset);
assert(SimpleTimeZone.fromISOString("+00:59").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(59))).utcOffset);
assert(SimpleTimeZone.fromISOString("+01:00").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(60))).utcOffset);
assert(SimpleTimeZone.fromISOString("+01:30").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(90))).utcOffset);
assert(SimpleTimeZone.fromISOString("+02:00").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(120))).utcOffset);
assert(SimpleTimeZone.fromISOString("+08:00").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(480))).utcOffset);
assert(SimpleTimeZone.fromISOString("+23:59").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(1439))).utcOffset);
assert(SimpleTimeZone.fromISOString("-00:01").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(-1))).utcOffset);
assert(SimpleTimeZone.fromISOString("-00:10").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(-10))).utcOffset);
assert(SimpleTimeZone.fromISOString("-00:59").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(-59))).utcOffset);
assert(SimpleTimeZone.fromISOString("-01:00").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(-60))).utcOffset);
assert(SimpleTimeZone.fromISOString("-01:30").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(-90))).utcOffset);
assert(SimpleTimeZone.fromISOString("-02:00").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(-120))).utcOffset);
assert(SimpleTimeZone.fromISOString("-08:00").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(-480))).utcOffset);
assert(SimpleTimeZone.fromISOString("-23:59").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(-1439))).utcOffset);
assert(SimpleTimeZone.fromISOString("+0").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(0))).utcOffset);
assert(SimpleTimeZone.fromISOString("+1").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(60))).utcOffset);
assert(SimpleTimeZone.fromISOString("+2").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(120))).utcOffset);
assert(SimpleTimeZone.fromISOString("+23").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(1380))).utcOffset);
assert(SimpleTimeZone.fromISOString("+2").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(120))).utcOffset);
assert(SimpleTimeZone.fromISOString("+0").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(0))).utcOffset);
assert(SimpleTimeZone.fromISOString("+1").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(60))).utcOffset);
assert(SimpleTimeZone.fromISOString("+2").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(120))).utcOffset);
assert(SimpleTimeZone.fromISOString("+23").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(1380))).utcOffset);
assert(SimpleTimeZone.fromISOString("+1:00").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(60))).utcOffset);
assert(SimpleTimeZone.fromISOString("+1:01").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(61))).utcOffset);
assert(SimpleTimeZone.fromISOString("-0").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(0))).utcOffset);
assert(SimpleTimeZone.fromISOString("-1").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(-60))).utcOffset);
assert(SimpleTimeZone.fromISOString("-2").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(-120))).utcOffset);
assert(SimpleTimeZone.fromISOString("-23").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(-1380))).utcOffset);
assert(SimpleTimeZone.fromISOString("-1:00").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(-60))).utcOffset);
assert(SimpleTimeZone.fromISOString("-1:01").utcOffset ==
(new SimpleTimeZone(dur!"minutes"(-61))).utcOffset);
}
//Test that converting from an ISO string to a SimpleTimeZone to an ISO String works properly.
version(testStdDateTime) unittest
{
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(dur!"minutes"(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);
}
immutable Duration _utcOffset;
}
/++
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. To use the TZ Database,
use $(LREF PosixTimeZone) (which reads its information from the TZ Database
files on disk) on Windows by providing the TZ Database files and telling
$(D PosixTimeZone.getTimeZone) where the directory holding them is.
To get a $(D PosixTimeZone), either call $(D PosixTimeZone.getTimeZone)
(which allows specifying the location the time zone files) or call
$(D TimeZone.getTimeZone) (which will give 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 the only way to get a time zone which
takes leap seconds into account is to 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 www.iana.org/time-zones, Home of the TZ Database files)<br>
$(WEB en.wikipedia.org/wiki/Tz_database, Wikipedia entry on TZ Database)<br>
$(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);
immutable found = countUntil!"b < a.timeT"(cast(Transition[])_transitions, unixTime);
if(found == -1)
return _transitions.back.ttInfo.isDST;
immutable transition = found == 0 ? _transitions[0] : _transitions[found - 1];
return transition.ttInfo.isDST;
}
catch(Exception e)
assert(0, format("Unexpected 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);
immutable found = countUntil!"b < a.timeT"(cast(Transition[])_transitions, unixTime);
if(found == -1)
return stdTime + convert!("seconds", "hnsecs")(_transitions.back.ttInfo.utcOffset + leapSecs);
immutable transition = found == 0 ? _transitions[0] : _transitions[found - 1];
return stdTime + convert!("seconds", "hnsecs")(transition.ttInfo.utcOffset + leapSecs);
}
catch(Exception e)
assert(0, format("Unexpected 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);
time_t unixTime = stdTimeToUnixTime(adjTime);
immutable past = unixTime - convert!("days", "seconds")(1);
immutable future = unixTime + convert!("days", "seconds")(1);
immutable pastFound = countUntil!"b < a.timeT"(cast(Transition[])_transitions, past);
if(pastFound == -1)
return adjTime - convert!("seconds", "hnsecs")(_transitions.back.ttInfo.utcOffset + leapSecs);
immutable futureFound = countUntil!"b < a.timeT"(cast(Transition[])_transitions[pastFound .. $], future);
immutable pastTrans = pastFound == 0 ? _transitions[0] : _transitions[pastFound - 1];
if(futureFound == 0)
return adjTime - convert!("seconds", "hnsecs")(pastTrans.ttInfo.utcOffset + leapSecs);
immutable futureTrans = futureFound == -1 ? _transitions.back
: _transitions[pastFound + futureFound - 1];
immutable pastOffset = pastTrans.ttInfo.utcOffset;
if(pastOffset < futureTrans.ttInfo.utcOffset)
unixTime -= convert!("hours", "seconds")(1);
immutable found = countUntil!"b < a.timeT"(cast(Transition[])_transitions[pastFound .. $],
unixTime - pastOffset);
if(found == -1)
return adjTime - convert!("seconds", "hnsecs")(_transitions.back.ttInfo.utcOffset + leapSecs);
immutable transition = found == 0 ? pastTrans : _transitions[pastFound + found - 1];
return adjTime - convert!("seconds", "hnsecs")(transition.ttInfo.utcOffset + leapSecs);
}
catch(Exception e)
assert(0, format("Unexpected 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)<br>
$(WEB en.wikipedia.org/wiki/List_of_tz_database_time_zones, List of
Time Zones)
Params:
name = The TZ Database name of the desired time zone
tzDatabaseDir = The directory where the TZ Database files are
located. Because these files are not located on
Windows systems, provide them
and give their location here 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), "/", dirSeparator);
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.
Providing a sub-name narrows down the list of time zones (which
can number in the thousands). For example,
passing in "America" as the sub-name returns only the time zones which
begin with "America".
Params:
subName = The first part of the desired time zones.
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), "/", dirSeparator);
if(!tzDatabaseDir.endsWith(dirSeparator))
tzDatabaseDir ~= dirSeparator;
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);
return bigEndianToNative!T(cast(ubyte[T.sizeof])buff);
}
/+
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;
immutable found = countUntil!"b < a.timeT"(cast(LeapSecond[])_leapSeconds, unixTime);
if(found == -1)
return _leapSeconds.back.total;
immutable 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. To use the TZ Database, use
$(LREF PosixTimeZone) (which reads its information from the TZ Database
files on disk) on Windows by providing the TZ Database files and telling
$(D PosixTimeZone.getTimeZone) where the directory holding them is.
The TZ Database files and Windows' time zone information frequently
do not match. Windows has many errors with regards to when DST switches
occur (especially for historical dates). Also, the TZ Database files
include far more time zones than Windows does. So, for accurate
time zone information, use the TZ Database files with
$(LREF PosixTimeZone) rather than $(D WindowsTimeZone). However, because
$(D WindowsTimeZone) uses Windows system calls to deal with the time,
it's far more likely to match the behavior of other Windows programs.
Be aware of the differences when selecting a method.
$(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 a $(LREF PosixTimeZone) on Posix systems and a
$(D WindowsTimeZone) on Windows systems).
See_Also:
$(WEB www.iana.org/time-zones, Home of the TZ Database files)
+/
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)<br>
$(WEB en.wikipedia.org/wiki/List_of_tz_database_time_zones, List
of Time Zones)
Params:
name = The TZ Database name of the desired time zone.
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)
{
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)
{
scope baseKey = Registry.localMachine.getKey(`Software\Microsoft\Windows NT\CurrentVersion\Time Zones`);
foreach (tzKeyName; baseKey.keyNames)
{
if (tzKeyName != name)
continue;
scope tzKey = baseKey.getKey(tzKeyName);
scope stdVal = tzKey.getValue("Std");
auto stdName = stdVal.value_SZ;
scope dstVal = tzKey.getValue("Dlt");
auto dstName = dstVal.value_SZ;
scope tziVal = tzKey.getValue("TZI");
auto binVal = tziVal.value_BINARY;
assert(binVal.length == REG_TZI_FORMAT.sizeof);
auto tziFmt = cast(REG_TZI_FORMAT*)binVal.ptr;
TIME_ZONE_INFORMATION tzInfo;
auto wstdName = toUTF16(stdName);
auto wdstName = toUTF16(dstName);
auto wstdNameLen = wstdName.length > 32 ? 32 : wstdName.length;
auto wdstNameLen = wdstName.length > 32 ? 32 : wdstName.length;
tzInfo.Bias = tziFmt.Bias;
tzInfo.StandardName[0 .. wstdNameLen] = wstdName[0 .. wstdNameLen];
tzInfo.StandardName[wstdNameLen .. $] = '\0';
tzInfo.StandardDate = tziFmt.StandardDate;
tzInfo.StandardBias = tziFmt.StandardBias;
tzInfo.DaylightName[0 .. wdstNameLen] = wdstName[0 .. wdstNameLen];
tzInfo.DaylightName[wdstNameLen .. $] = '\0';
tzInfo.DaylightDate = tziFmt.DaylightDate;
tzInfo.DaylightBias = tziFmt.DaylightBias;
return new WindowsTimeZone(name, tzInfo);
}
throw new DateTimeException(format("Failed to find time zone: %s", name));
}
static string[] getInstalledTZNames()
{
auto timezones = appender!(string[])();
scope baseKey = Registry.localMachine.getKey(`Software\Microsoft\Windows NT\CurrentVersion\Time Zones`);
foreach (tzKeyName; baseKey.keyNames)
{
timezones.put(tzKeyName);
}
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 = TzSpecificLocalTimeToSystemTime(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 = -tzInfo.Bias - diff.total!"minutes";
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)
isDST = false;
else if(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.)
Sets 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 started
with, in a few case, it'll 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)
{
//Most of these come from the link in the documentation, but a few have
//been added because they were found in the Windows registry.
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/Bahia": return "Bahia 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";
//This should probably be Turkey Standard Time, but GTB Standard Time
//has been around longer and therefore will work on more systems.
case "Europe/Istanbul": return "GTB Standard Time";
case "Europe/Kaliningrad": return "Kaliningrad 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)
{
//Most of these come from the link in the documentation, but a few have
//been added because they were found in the Windows registry.
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 "Bahia Standard Time": return "America/Bahia";
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 "Kaliningrad Standard Time": return "Europe/Kaliningrad";
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 "Turkey Standard Time": return "Europe/Istanbul";
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;
// To know the number of seconds,
// use properties of TickDuration.
// (seconds, msecs, usecs, 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;
// To get the number of seconds,
// use properties of TickDuration.
// (seconds, msecs, usecs, 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 StopWatch rhs) const pure nothrow
{
return opEquals(rhs);
}
/// ditto
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);
_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);
}
/++
Set the amount of time which has been measured since the stop watch was
started.
+/
void setMeasured(TickDuration d)
{
reset();
_timeMeasured = d;
}
version(testStdDateTime) @safe unittest
{
StopWatch sw;
TickDuration t0;
t0.length = 100;
sw.setMeasured(t0);
auto t1 = sw.peek();
assert(t0 == t1);
}
/++
Confirm whether this stopwatch is measuring time.
+/
bool running() @property const pure nothrow
{
return _flagStarted;
}
version(testStdDateTime) @safe unittest
{
StopWatch sw1;
assert(!sw1.running);
sw1.start();
assert(sw1.running);
sw1.stop();
assert(!sw1.running);
StopWatch sw2 = AutoStart.yes;
assert(sw2.running);
sw2.stop();
assert(!sw2.running);
sw2.start();
assert(sw2.running);
}
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);
writefln("Milliseconds to call fun[0] n times: %s", r[0].to!("msecs", int));
--------------------
+/
TickDuration[lengthof!(fun)()] benchmark(fun...)(uint n)
{
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;
}
//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);
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);
}
--------------------
+/
ComparingBenchmarkResult comparingBenchmark(alias baseFunc,
alias targetFunc,
int times = 0xfff)()
{
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
}
//Bug# 8450
version(testStdDateTime) unittest
{
@safe void safeFunc() {}
@trusted void trustFunc() {}
@system void sysFunc() {}
auto safeResult = comparingBenchmark!((){safeFunc();}, (){safeFunc();})();
auto trustResult = comparingBenchmark!((){trustFunc();}, (){trustFunc();})();
auto sysResult = comparingBenchmark!((){sysFunc();}, (){sysFunc();})();
auto mixedResult1 = comparingBenchmark!((){safeFunc();}, (){trustFunc();})();
auto mixedResult2 = comparingBenchmark!((){trustFunc();}, (){sysFunc();})();
auto mixedResult3 = comparingBenchmark!((){safeFunc();}, (){sysFunc();})();
}
//==============================================================================
// Section with public helper functions and templates.
//==============================================================================
/++
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. If on Windows and using the
standard C functions or Win32 API functions which take a $(D time_t),
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 to get the $(D SYSTEMTIME) 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 the number of hnsecs since midnight,
January 1st, 1 A.D.
Params:
ft = The $(D FILETIME) struct to convert.
Throws:
$(D DateTimeException) if the given $(D FILETIME) cannot be
represented as the return value.
+/
long FILETIMEToStdTime(const FILETIME* ft);
/++
$(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).
+/
SysTime FILETIMEToSysTime(const FILETIME* ft, immutable TimeZone tz = LocalTime());
/++
$(BLUE This function is Windows-Only.)
Converts a number of hnsecs since midnight, January 1st, 1 A.D. to a
$(D FILETIME) struct.
Params:
sysTime = The $(D SysTime) to convert.
Throws:
$(D DateTimeException) if the given value will not fit in a
$(D FILETIME).
+/
FILETIME stdTimeToFILETIME(long stdTime);
/++
$(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);
}
}
private enum hnsecsFrom1601 = 504_911_232_000_000_000L;
long FILETIMEToStdTime(const FILETIME* ft)
{
ULARGE_INTEGER ul;
ul.HighPart = ft.dwHighDateTime;
ul.LowPart = ft.dwLowDateTime;
ulong tempHNSecs = ul.QuadPart;
if(tempHNSecs > long.max - hnsecsFrom1601)
throw new DateTimeException("The given FILETIME cannot be represented as a stdTime value.");
return cast(long)tempHNSecs + hnsecsFrom1601;
}
SysTime FILETIMEToSysTime(const FILETIME* ft, immutable TimeZone tz = LocalTime())
{
auto sysTime = SysTime(FILETIMEToStdTime(ft), 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 stdTimeToFILETIME(long stdTime)
{
if(stdTime < hnsecsFrom1601)
throw new DateTimeException("The given stdTime value cannot be represented as a FILETIME.");
ULARGE_INTEGER ul;
ul.QuadPart = cast(ulong)stdTime - hnsecsFrom1601;
FILETIME ft;
ft.dwHighDateTime = ul.HighPart;
ft.dwLowDateTime = ul.LowPart;
return ft;
}
FILETIME SysTimeToFILETIME(SysTime sysTime)
{
return stdTimeToFILETIME(sysTime.stdTime);
}
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.
+/
alias 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 = countUntil(tstrings, lhs);
immutable indexOfRHS = 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 = countUntil(tstrings, lhs);
immutable indexOfRHS = 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 time, 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!((){StopWatch sw; unaryFun!func(sw.peek());}))
{
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!((){StopWatch sw; unaryFun!func(sw.peek());}))
{
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.
}
+/
}
//Bug# 8450
version(testStdDateTime) unittest
{
@safe void safeFunc() {}
@trusted void trustFunc() {}
@system void sysFunc() {}
auto safeResult = measureTime!((a){safeFunc();})();
auto trustResult = measureTime!((a){trustFunc();})();
auto sysResult = measureTime!((a){sysFunc();})();
}
//==============================================================================
// 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 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:
$(LREF 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:
$(LREF 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 (month < Month.jan || month > Month.dec)
{
throw new DateTimeException("Invalid month: " ~ numToString(month));
}
if(useLongName == true)
{
return longMonthNames[month - Month.jan];
}
else
{
return shortMonthNames[month - Month.jan];
}
}
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[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[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 = is(typeof(
{
auto d = dur!"days"(5);
auto td = TickDuration.from!"hnsecs"(5);
alias U = Unqual!T;
static assert(is(typeof(U.init += d) == U));
static assert(is(typeof(U.init -= d) == U));
static assert(is(typeof(U.init += td) == U));
static assert(is(typeof(U.init -= td) == U));
}));
}
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))];
void initializeTests()
{
immutable lt = LocalTime().utcToTZ(0);
currLocalDiffFromUTC = dur!"hnsecs"(lt);
immutable otherTZ = lt < 0 ? TimeZone.getTimeZone("Australia/Sydney")
: TimeZone.getTimeZone("America/Denver");
immutable ot = otherTZ.utcToTZ(0);
auto diffs = [0, lt, ot];
auto diffAA = [0 : Rebindable!(immutable TimeZone)(UTC()),
lt : Rebindable!(immutable TimeZone)(LocalTime()),
ot : Rebindable!(immutable TimeZone)(otherTZ)];
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!`);
}
}
unittest
{
/* Issue 6642 */
static assert(!hasUnsharedAliasing!Date);
static assert(!hasUnsharedAliasing!TimeOfDay);
static assert(!hasUnsharedAliasing!DateTime);
static assert(!hasUnsharedAliasing!SysTime);
}
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 .. $]);
}
}
|
D
|
/Volumes/IDrive/rCore-Tutorial/os/target/debug/deps/unicode_xid-899c582110bef5e7.rmeta: /Users/apple/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/unicode-xid-0.2.1/src/lib.rs /Users/apple/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/unicode-xid-0.2.1/src/tables.rs
/Volumes/IDrive/rCore-Tutorial/os/target/debug/deps/libunicode_xid-899c582110bef5e7.rlib: /Users/apple/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/unicode-xid-0.2.1/src/lib.rs /Users/apple/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/unicode-xid-0.2.1/src/tables.rs
/Volumes/IDrive/rCore-Tutorial/os/target/debug/deps/unicode_xid-899c582110bef5e7.d: /Users/apple/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/unicode-xid-0.2.1/src/lib.rs /Users/apple/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/unicode-xid-0.2.1/src/tables.rs
/Users/apple/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/unicode-xid-0.2.1/src/lib.rs:
/Users/apple/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/unicode-xid-0.2.1/src/tables.rs:
|
D
|
/*
* Copyright (c) 2017-2018 sel-project
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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 AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
/**
* Copyright: 2017-2018 sel-project
* License: MIT
* Authors: Kripth
* Source: $(HTTP github.com/sel-project/selery/source/selery/block/farming.d, selery/block/farming.d)
*/
module selery.block.farming;
import std.random : dice, uniform, randomShuffle;
import selery.about : block_t, item_t;
import selery.block.block : Block, Update;
import selery.block.blocks : Blocks;
import selery.block.solid;
import selery.entity.entity : Entity;
import selery.item.item : Item;
import selery.item.items : Items;
import selery.item.slot : Slot;
import selery.item.tool : Tools;
import selery.math.vector : BlockPosition;
import selery.player.player : Player;
import selery.world.world : World;
static import sul.blocks;
class FertileTerrainBlock(bool hydrated) : MineableBlock {
private block_t wetter, dryer;
public this(sul.blocks.Block data, block_t wetter, block_t dryer) {
super(data, MiningTool(false, Tools.shovel, Tools.wood), Drop(Items.dirt, 1));
this.wetter = wetter;
this.dryer = dryer;
}
public final override pure nothrow @property @safe @nogc bool doRandomTick() {
return true;
}
public override void onRandomTick(World world, BlockPosition position) {
static if(hydrated) {
//TODO check if the water still there, otherwise convert to dryer
} else {
//TODO check if this block could be hydrated and convert to wetter, otherwise convert to dryer (if not 0)
}
}
/**
* Searches for water in the section.
* Returns: true if water was found, false otherwise
*/
/*protected @property bool searchWater() {
foreach(uint x ; 0..this.section.opDollar!0) {
foreach(uint y ; 0..this.section.opDollar!1) {
foreach(uint z ; 0..this.section.opDollar!2) {
Block b;
if((b = this.section[x, y, z]) !is null && b == Blocks.WATER) {
this.water = new BlockPosition(x, y, z);
return true;
}
}
}
}
return false;
}*/
public override void onUpdated(World world, BlockPosition position, Update update) {
Block up = world[position + [0, 1, 0]];
if(up.solid) world[position] = Blocks.dirt;
//TODO moved by piston
//TODO stepped
}
}
class FarmingBlock : MineableBlock {
public this(sul.blocks.Block data, Drop[] drops) {
super(data, MiningTool.init, drops);
}
public override void onUpdated(World world, BlockPosition position, Update update) {
if(world[position - [0, 1, 0]] != Blocks.farmland) {
world.drop(this, position);
world[position] = Blocks.air;
}
}
}
class GrowingFarmingBlock : FarmingBlock {
public this(sul.blocks.Block data, Drop[] drops) {
super(data, drops);
}
public override pure nothrow @property @safe @nogc bool doRandomTick() {
return true;
}
public override void onRandomTick(World world, BlockPosition position) {
immutable float p = world[position - [0, 1, 0]] != Blocks.farmland7 ? .125 : .25;
if(dice(world.random, 1f - p, p)) {
this.grow(world, position);
}
}
public abstract void grow(World, BlockPosition);
}
class StageCropBlock : GrowingFarmingBlock {
private block_t next;
public this(sul.blocks.Block data, Drop[] drops, block_t next) {
super(data, drops);
this.next = 0;
}
public this(sul.blocks.Block data, block_t next, Drop[] drops=[]) {
this(data, drops, next);
}
public override void grow(World world, BlockPosition position) {
world[position] = this.next;
}
}
class FruitCropBlock(bool isArray) : GrowingFarmingBlock {
static if(isArray) {
alias grow_t = block_t[4];
} else {
alias grow_t = block_t;
}
private grow_t growTo;
public this(sul.blocks.Block data, Drop[] drops, grow_t growTo) {
super(data, drops);
}
public this(sul.blocks.Block data, grow_t growTo, Drop[] drops=[]) {
this(data, drops, growTo);
}
public override void grow(World world, BlockPosition position) {
//search for a place to grow
BlockPosition[] positions = [position + [1, 0, 0], position + [0, 0, 1], position - [1, 0, 0], position - [0, 0, 1]];
randomShuffle(positions, world.random);
foreach(BlockPosition pos ; positions) {
if(world[pos] == Blocks.air) {
Block s = world[pos - [0, 1, 0]];
if(s == Blocks.dirts) {
static if(isArray) {
ubyte face;
if(position.x == pos.x) {
if(position.z > pos.z) face = Facing.north;
else face = Facing.south;
} else {
if(position.x > pos.x) face = Facing.west;
else face = Facing.east;
}
world[pos] = this.growTo[face];
} else {
world[pos] = this.growTo;
}
break;
}
}
}
}
}
class ChanceCropBlock : StageCropBlock {
private ubyte a, b;
public this(sul.blocks.Block data, Drop[] drops, block_t next, ubyte a, ubyte b) {
super(data, drops, next);
this.a = a;
this.b = b;
}
public this(sul.blocks.Block data, block_t next, Drop[] drops, ubyte a, ubyte b) {
this(data, drops, next, a, b);
}
public override void onRandomTick(World world, BlockPosition position) {
if(uniform(0, this.b, world.random) < this.a) {
//TODO call this.grow ?
super.onRandomTick(world, position);
}
}
}
//class StemBlock(bool isArray) : FruitCropBlock!isArray {
template StemBlock(T) {
class StemBlock : T {
private item_t drop;
public this(E...)(sul.blocks.Block data, item_t drop, E args) {
super(data, args);
this.drop = drop;
}
public override Slot[] drops(World world, Player player, Item item) {
immutable amount = dice(world.random, 100, 20, 4, 1);
if(amount) {
auto func = world.items.getConstructor(this.drop);
if(func !is null) {
Slot[] ret;
foreach(i ; 0..amount) {
ret ~= Slot(func(0), 1);
}
return ret;
}
}
return [];
}
}
}
//class GrowingBlock(sul.blocks.Block sb, block_t next, block_t[] compare, size_t height, bool waterNeeded, block_t[] requiredBlock, Drop drops) : MineableBlock!(sb, MiningTool.init, drops) {
class GrowingBlock(bool needsWater) : MineableBlock {
private block_t next;
private block_t[] compare, requiredBlock;
private size_t height;
public this(sul.blocks.Block data, Drop[] drops, block_t next, block_t[] compare, block_t[] requiredBlock, size_t height) {
super(data, MiningTool.init, drops);
this.next = next;
this.compare = compare;
this.requiredBlock = requiredBlock;
this.height = height;
}
public override void onRandomTick(World world, BlockPosition position) {
//TODO check if there's water around
if(this.next == 0) { //TODO do this check when constructed
@property bool tooHigh() {
size_t h = 1;
auto pos = position - [0, 1, 0];
while(world[pos] == compare && ++h < this.height) pos -= [0, 1, 0];
return h >= this.height;
}
auto up = position + [0, 1, 0];
if(world[up] == Blocks.air && !tooHigh) {
world[up] = this.compare[0];
}
} else {
world[position] = this.next;
}
}
public override void onUpdated(World world, BlockPosition position, Update update) {
auto down = world[position - [0, 1, 0]];
if(down != this.compare && (down != this.requiredBlock || !this.searchWater(world, position))) {
world.drop(this, position);
world[position] = Blocks.air;
}
}
private bool searchWater(World world, BlockPosition position) {
static if(needsWater) {
foreach(p ; [[0, -1, 1], [1, -1, 0], [0, -1, -1], [-1, -1, 0]]) {
if(world[position + p] == Blocks.water) return true;
}
return false;
} else {
return true;
}
}
}
class SugarCanesBlock : GrowingBlock!true {
public this(sul.blocks.Block data, block_t next) {
super(data, [Drop(Items.sugarCanes, 1)], next, Blocks.sugarCanes, [Blocks.sand, Blocks.redSand, Blocks.dirt, Blocks.coarseDirt, Blocks.podzol, Blocks.grass], 3);
}
}
class CactusBlock : GrowingBlock!false {
public this(sul.blocks.Block data, block_t next) {
super(data, [Drop(Items.cactus, 1)], next, Blocks.cactus, [Blocks.sand, Blocks.redSand], 3);
}
//TODO do cactus damage on step and on contact
}
class NetherCropBlock : MineableBlock {
public this(sul.blocks.Block data, Drop drop) {
super(data, MiningTool.init, drop);
}
public override void onUpdated(World world, BlockPosition position, Update update) {
auto pos = position - [0, 1, 0];
if(world[pos] != Blocks.soulSand) {
world.drop(this, position);
world[pos] = Blocks.air;
}
}
}
class StageNetherCropBlock : NetherCropBlock {
private block_t next;
public this(sul.blocks.Block data, block_t next, Drop drop) {
super(data, drop);
this.next = next;
}
public override pure nothrow @property @safe @nogc bool doRandomTick() {
return true;
}
public override void onRandomTick(World world, BlockPosition position) {
world[position] = this.next;
}
}
class BeansBlock : MineableBlock {
private BlockPosition facing;
public this(sul.blocks.Block data, MiningTool miningTool, Drop drop, ubyte facing) {
super(data, miningTool, [drop]);
if(facing == Facing.north) {
this.facing = BlockPosition(0, 0, 1);
} else if(facing == Facing.south) {
this.facing = BlockPosition(0, 0, -1);
} else if(facing == Facing.west) {
this.facing = BlockPosition(1, 0, 0);
} else {
this.facing = BlockPosition(-1, 0, 0);
}
}
public override void onUpdated(World world, BlockPosition position, Update update) {
//TODO verify facing
auto attached = position + this.facing;
if(world[attached] != Blocks.jungleWood) {
world.drop(this, position);
world[attached] = Blocks.air;
}
}
}
class GrowingBeansBlock : BeansBlock {
private block_t next;
public this(sul.blocks.Block data, MiningTool miningTool, Drop drop, ubyte facing, block_t next) {
super(data, miningTool, drop, facing);
}
public override pure nothrow @property @safe @nogc bool doRandomTick() {
return true;
}
public override void onRandomTick(World world, BlockPosition position) {
world[position] = this.next; // every random tick?
}
}
|
D
|
/*
Boost Software License - Version 1.0 - August 17th, 2003
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 derelict.freeglut.functions;
// Callbacks used as parameters to some of the functions below.
extern(C)
{
alias nothrow void function(int) da_intCallback;
alias nothrow void function(int,int) da_2intCallback;
alias nothrow void function(int,int,int) da_3intCallback;
alias nothrow void function(int,int,int,int) da_4intCallback;
alias nothrow void function(int,int,int,int,int) da_5intCallback;
alias nothrow void function() da_voidCallback;
alias nothrow void function(ubyte,int,int) da_keyboardCallback;
alias nothrow void function(uint,int,int,int) da_joytstickCallback;
alias nothrow void function(const(char)*,void*) da_printCallback;
}
extern(System)
{
// From freeglut_std.h
alias nothrow void function(int*,char**) da_glutInit;
alias nothrow void function(int,int) da_glutInitWindowPosition;
alias nothrow void function(int,int) da_glutInitWindowSize;
alias nothrow void function(uint) da_glutInitDisplayMode;
alias nothrow void function(const(char)*) da_glutInitDisplayString;
alias nothrow void function() da_glutMainLoop;
alias nothrow int function(const(char)*) da_glutCreateWindow;
alias nothrow int function(int,int,int,int,int) da_glutCreateSubWindow;
alias nothrow void function(int) da_glutDestroyWindow;
alias nothrow void function(int) da_glutSetWindow;
alias nothrow int function() da_glutGetWindow;
alias nothrow void function(const(char)*) da_glutSetWindowTitle;
alias nothrow void function(const(char)*) da_glutSetIconTitle;
alias nothrow void function(int,int) da_glutReshapeWindow;
alias nothrow void function(int,int) da_glutPositionWindow;
alias nothrow void function() da_glutShowWindow;
alias nothrow void function() da_glutHideWindow;
alias nothrow void function() da_glutIconifyWindow;
alias nothrow void function() da_glutPushWindow;
alias nothrow void function() da_glutPopWindow;
alias nothrow void function() da_glutFullScreen;
alias nothrow void function(int) da_glutPostWindowRedisplay;
alias nothrow void function() da_glutPostRedisplay;
alias nothrow void function() da_glutSwapBuffers;
alias nothrow void function(int,int) da_glutWarpPointer;
alias nothrow void function(int) da_glutSetCursor;
alias nothrow void function() da_glutEstablishOverlay;
alias nothrow void function() da_glutRemoveOverlay;
alias nothrow void function(uint) da_glutUseLayer;
alias nothrow void function() da_glutPostOverlayRedisplay;
alias nothrow void function(int) da_glutPostWindowOverlayRedisplay;
alias nothrow void function() da_glutShowOverlay;
alias nothrow void function() da_glutHideOverlay;
alias nothrow int function(da_intCallback) da_glutCreateMenu;
alias nothrow void function(int) da_glutDestroyMenu;
alias nothrow int function() da_glutGetMenu;
alias nothrow void function(int) da_glutSetMenu;
alias nothrow void function(const(char)*,int) da_glutAddMenuEntry;
alias nothrow void function(const(char)*,int) da_glutAddSubMenu;
alias nothrow void function(int,const(char)*,int) da_glutChangeToMenuEntry;
alias nothrow void function(int,const(char)*,int) da_glutChangeToSubMenu;
alias nothrow void function(int) da_glutRemoveMenuItem;
alias nothrow void function(int) da_glutAttachMenu;
alias nothrow void function(int) da_glutDetachMenu;
alias nothrow void function(uint,da_intCallback,int) da_glutTimerFunc;
alias nothrow void function(da_voidCallback) da_glutIdleFunc;
alias nothrow void function(da_keyboardCallback) da_glutKeyboardFunc;
alias nothrow void function(da_3intCallback) da_glutSpecialFunc;
alias nothrow void function(da_2intCallback) da_glutReshapeFunc;
alias nothrow void function(da_intCallback) da_glutVisibilityFunc;
alias nothrow void function(da_voidCallback) da_glutDisplayFunc;
alias nothrow void function(da_4intCallback) da_glutMouseFunc;
alias nothrow void function(da_2intCallback) da_glutMotionFunc;
alias nothrow void function(da_2intCallback) da_glutPassiveMotionFunc;
alias nothrow void function(da_intCallback) da_glutEntryFunc;
alias nothrow void function(da_keyboardCallback) da_glutKeyboardUpFunc;
alias nothrow void function(da_3intCallback) da_glutSpecialUpFunc;
alias nothrow void function(da_joytstickCallback) da_glutJoystickFunc;
alias nothrow void function(da_intCallback) da_glutMenuStateFunc;
alias nothrow void function(da_3intCallback) da_glutMenuStatusFunc;
alias nothrow void function(da_voidCallback) da_glutOverlayDisplayFunc;
alias nothrow void function(da_intCallback) da_glutWindowStatusFunc;
alias nothrow void function(da_3intCallback) da_glutSpaceballMotionFunc;
alias nothrow void function(da_3intCallback) da_glutSpaceballRotateFunc;
alias nothrow void function(da_2intCallback) da_glutSpaceballButtonFunc;
alias nothrow void function(da_2intCallback) da_glutButtonBoxFunc;
alias nothrow void function(da_2intCallback) da_glutDialsFunc;
alias nothrow void function(da_2intCallback) da_glutTabletMotionFunc;
alias nothrow void function(da_4intCallback) da_glutTabletButtonFunc;
alias nothrow int function(uint) da_glutGet;
alias nothrow int function(uint) da_glutDeviceGet;
alias nothrow int function() da_glutGetModifiers;
alias nothrow int function(uint) da_glutLayerGet;
alias nothrow void function(void*,int) da_glutBitmapCharacter;
alias nothrow int function(void*,int) da_glutBitmapWidth;
alias nothrow void function(void*,int) da_glutStrokeCharacter;
alias nothrow int function(void*,int) da_glutStrokeWidth;
alias nothrow int function(void*, const(char)*) da_glutBitmapLength;
alias nothrow int function(void*,const(char)*) da_glutStrokeLength;
alias nothrow void function(double) da_glutWireCube;
alias nothrow void function(double) da_glutSolidCube;
alias nothrow void function(double,int,int) da_glutWireSphere;
alias nothrow void function(double,int,int) da_glutSolidSphere;
alias nothrow void function(double,double,int,int) da_glutWireCone;
alias nothrow void function(double,double,int,int) da_glutSolidCone;
alias nothrow void function(double,double,int,int) da_glutWireTorus;
alias nothrow void function(double,double,int,int) da_glutSolidTorus;
alias nothrow void function() da_glutWireDodecahedron;
alias nothrow void function() da_glutSolidDodecahedron;
alias nothrow void function() da_glutWireOctahedron;
alias nothrow void function() da_glutSolidOctahedron;
alias nothrow void function() da_glutWireTetrahedron;
alias nothrow void function() da_glutSolidTetrahedron;
alias nothrow void function() da_glutWireIcosahedron;
alias nothrow void function() da_glutSolidIcosahedron;
alias nothrow void function(double) da_glutWireTeapot;
alias nothrow void function(double) da_glutSolidTeapot;
alias nothrow void function(const(char)*) da_glutGameModeString;
alias nothrow int function() da_glutEnterGameMode;
alias nothrow void function() da_glutLeaveGameMode;
alias nothrow int function(uint) da_glutGameModeGet;
alias nothrow int function(uint) da_glutVideoResizeGet;
alias nothrow void function() da_glutSetupVideoResizing;
alias nothrow void function() da_glutStopVideoResizing;
alias nothrow void function(int,int,int,int) da_glutVideoResize;
alias nothrow void function(int,int,int,int) da_glutVideoPan;
alias nothrow void function(int,float,float,float) da_glutSetColor;
alias nothrow float function(int,int) da_glutGetColor;
alias nothrow void function(int) da_glutCopyColormap;
alias nothrow void function(int) da_glutIgnoreKeyRepeat;
alias nothrow void function(int) da_glutSetKeyRepeat;
alias nothrow void function() da_glutForceJoystickFunc;
alias nothrow int function(const(char)*) da_glutExtensionSupported;
alias nothrow void function() da_glutReportErrors;
// From freeglut_ext.h
alias nothrow void function() da_glutMainLoopEvent;
alias nothrow void function() da_glutLeaveMainLoop;
alias nothrow void function() da_glutExit;
alias nothrow void function() da_glutFullScreenToggle;
alias nothrow void function() da_glutLeaveFullScreen;
alias nothrow void function(da_4intCallback) da_glutMouseWheelFunc;
alias nothrow void function(da_voidCallback) da_glutCloseFunc;
alias nothrow void function(da_voidCallback) da_glutWMCloseFunc;
alias nothrow void function(da_voidCallback) da_glutMenuDestroyFunc;
alias nothrow void function(uint,int) da_glutSetOption;
alias nothrow int* function(uint,int*) da_glutGetModeValues;
alias nothrow void* function() da_glutGetWindowData;
alias nothrow void function(void*) da_glutSetWindowData;
alias nothrow void* function() da_glutGetMenuData;
alias nothrow void function(void*) da_glutSetMenuData;
alias nothrow int function(void*) da_glutBitmapHeight;
alias nothrow float function(void*) da_glutStrokeHeight;
alias nothrow void function(void*,const(char)*) da_glutBitmapString;
alias nothrow void function(void*,const(char)*) da_glutStrokeString;
alias nothrow void function() da_glutWireRhombicDodecahedron;
alias nothrow void function() da_glutSolidRhombicDodecahedron;
alias nothrow void function(int,double[3],double) da_glutWireSierpinskiSponge;
alias nothrow void function(int,double[3],double) da_glutSolidSierpinskiSponge;
alias nothrow void function(double,double,int,int) da_glutWireCylinder;
alias nothrow void function(double,double,int,int) da_glutSolidCylinder;
alias nothrow void* function(const(char)*) da_glutGetProcAddress;
alias nothrow void function(da_2intCallback) da_glutMultiEntryFunc;
alias nothrow void function(da_5intCallback) da_glutMultiButtonFunc;
alias nothrow void function(da_3intCallback) da_glutMultiMotionFunc;
alias nothrow void function(da_3intCallback) da_glutMultiPassiveFunc;
alias nothrow void function(int,int) da_glutInitContextVersion;
alias nothrow void function(int) da_glutInitContextFlags;
alias nothrow void function(int) da_glutInitContextProfile;
alias nothrow void function(da_printCallback) da_glutInitErrorFunc;
alias nothrow void function(da_printCallback) da_glutInitWarningFunc;
}
__gshared
{
da_glutInit glutInit;
da_glutInitWindowPosition glutInitWindowPosition;
da_glutInitWindowSize glutInitWindowSize;
da_glutInitDisplayMode glutInitDisplayMode;
da_glutInitDisplayString glutInitDisplayString;
da_glutMainLoop glutMainLoop;
da_glutCreateWindow glutCreateWindow;
da_glutCreateSubWindow glutCreateSubWindow;
da_glutDestroyWindow glutDestroyWindow;
da_glutSetWindow glutSetWindow;
da_glutGetWindow glutGetWindow;
da_glutSetWindowTitle glutSetWindowTitle;
da_glutSetIconTitle glutSetIconTitle;
da_glutReshapeWindow glutReshapeWindow;
da_glutPositionWindow glutPositionWindow;
da_glutShowWindow glutShowWindow;
da_glutHideWindow glutHideWindow;
da_glutIconifyWindow glutIconifyWindow;
da_glutPushWindow glutPushWindow;
da_glutPopWindow glutPopWindow;
da_glutFullScreen glutFullScreen;
da_glutPostWindowRedisplay glutPostWindowRedisplay;
da_glutPostRedisplay glutPostRedisplay;
da_glutSwapBuffers glutSwapBuffers;
da_glutWarpPointer glutWarpPointer;
da_glutSetCursor glutSetCursor;
da_glutEstablishOverlay glutEstablishOverlay;
da_glutRemoveOverlay glutRemoveOverlay;
da_glutUseLayer glutUseLayer;
da_glutPostOverlayRedisplay glutPostOverlayRedisplay;
da_glutPostWindowOverlayRedisplay glutPostWindowOverlayRedisplay;
da_glutShowOverlay glutShowOverlay;
da_glutHideOverlay glutHideOverlay;
da_glutCreateMenu glutCreateMenu;
da_glutDestroyMenu glutDestroyMenu;
da_glutGetMenu glutGetMenu;
da_glutSetMenu glutSetMenu;
da_glutAddMenuEntry glutAddMenuEntry;
da_glutAddSubMenu glutAddSubMenu;
da_glutChangeToMenuEntry glutChangeToMenuEntry;
da_glutChangeToSubMenu glutChangeToSubMenu;
da_glutRemoveMenuItem glutRemoveMenuItem;
da_glutAttachMenu glutAttachMenu;
da_glutDetachMenu glutDetachMenu;
da_glutTimerFunc glutTimerFunc;
da_glutIdleFunc glutIdleFunc;
da_glutKeyboardFunc glutKeyboardFunc;
da_glutSpecialFunc glutSpecialFunc;
da_glutReshapeFunc glutReshapeFunc;
da_glutVisibilityFunc glutVisibilityFunc;
da_glutDisplayFunc glutDisplayFunc;
da_glutMouseFunc glutMouseFunc;
da_glutMotionFunc glutMotionFunc;
da_glutPassiveMotionFunc glutPassiveMotionFunc;
da_glutEntryFunc glutEntryFunc;
da_glutKeyboardUpFunc glutKeyboardUpFunc;
da_glutSpecialUpFunc glutSpecialUpFunc;
da_glutJoystickFunc glutJoystickFunc;
da_glutMenuStateFunc glutMenuStateFunc;
da_glutMenuStatusFunc glutMenuStatusFunc;
da_glutOverlayDisplayFunc glutOverlayDisplayFunc;
da_glutWindowStatusFunc glutWindowStatusFunc;
da_glutSpaceballMotionFunc glutSpaceballMotionFunc;
da_glutSpaceballRotateFunc glutSpaceballRotateFunc;
da_glutSpaceballButtonFunc glutSpaceballButtonFunc;
da_glutButtonBoxFunc glutButtonBoxFunc;
da_glutDialsFunc glutDialsFunc;
da_glutTabletMotionFunc glutTabletMotionFunc;
da_glutTabletButtonFunc glutTabletButtonFunc;
da_glutGet glutGet;
da_glutDeviceGet glutDeviceGet;
da_glutGetModifiers glutGetModifiers;
da_glutLayerGet glutLayerGet;
da_glutBitmapCharacter glutBitmapCharacter;
da_glutBitmapWidth glutBitmapWidth;
da_glutStrokeCharacter glutStrokeCharacter;
da_glutStrokeWidth glutStrokeWidth;
da_glutBitmapLength glutBitmapLength;
da_glutStrokeLength glutStrokeLength;
da_glutWireCube glutWireCube;
da_glutSolidCube glutSolidCube;
da_glutWireSphere glutWireSphere;
da_glutSolidSphere glutSolidSphere;
da_glutWireCone glutWireCone;
da_glutSolidCone glutSolidCone;
da_glutWireTorus glutWireTorus;
da_glutSolidTorus glutSolidTorus;
da_glutWireDodecahedron glutWireDodecahedron;
da_glutSolidDodecahedron glutSolidDodecahedron;
da_glutWireOctahedron glutWireOctahedron;
da_glutSolidOctahedron glutSolidOctahedron;
da_glutWireTetrahedron glutWireTetrahedron;
da_glutSolidTetrahedron glutSolidTetrahedron;
da_glutWireIcosahedron glutWireIcosahedron;
da_glutSolidIcosahedron glutSolidIcosahedron;
da_glutWireTeapot glutWireTeapot;
da_glutSolidTeapot glutSolidTeapot;
da_glutGameModeString glutGameModeString;
da_glutEnterGameMode glutEnterGameMode;
da_glutLeaveGameMode glutLeaveGameMode;
da_glutGameModeGet glutGameModeGet;
da_glutVideoResizeGet glutVideoResizeGet;
da_glutSetupVideoResizing glutSetupVideoResizing;
da_glutStopVideoResizing glutStopVideoResizing;
da_glutVideoResize glutVideoResize;
da_glutVideoPan glutVideoPan;
da_glutSetColor glutSetColor;
da_glutGetColor glutGetColor;
da_glutCopyColormap glutCopyColormap;
da_glutIgnoreKeyRepeat glutIgnoreKeyRepeat;
da_glutSetKeyRepeat glutSetKeyRepeat;
da_glutForceJoystickFunc glutForceJoystickFunc;
da_glutExtensionSupported glutExtensionSupported;
da_glutReportErrors glutReportErrors;
da_glutMainLoopEvent glutMainLoopEvent;
da_glutLeaveMainLoop glutLeaveMainLoop;
da_glutExit glutExit;
da_glutFullScreenToggle glutFullScreenToggle;
da_glutLeaveFullScreen glutLeaveFullScreen;
da_glutMouseWheelFunc glutMouseWheelFunc;
da_glutCloseFunc glutCloseFunc;
da_glutWMCloseFunc glutWMCloseFunc;
da_glutMenuDestroyFunc glutMenuDestroyFunc;
da_glutSetOption glutSetOption;
da_glutGetModeValues glutGetModeValues;
da_glutGetWindowData glutGetWindowData;
da_glutSetWindowData glutSetWindowData;
da_glutGetMenuData glutGetMenuData;
da_glutSetMenuData glutSetMenuData;
da_glutBitmapHeight glutBitmapHeight;
da_glutStrokeHeight glutStrokeHeight;
da_glutBitmapString glutBitmapString;
da_glutStrokeString glutStrokeString;
da_glutWireRhombicDodecahedron glutWireRhombicDodecahedron;
da_glutSolidRhombicDodecahedron glutSolidRhombicDodecahedron;
da_glutWireSierpinskiSponge glutWireSierpinskiSponge;
da_glutSolidSierpinskiSponge glutSolidSierpinskiSponge;
da_glutWireCylinder glutWireCylinder;
da_glutSolidCylinder glutSolidCylinder;
da_glutGetProcAddress glutGetProcAddress;
da_glutMultiEntryFunc glutMultiEntryFunc;
da_glutMultiButtonFunc glutMultiButtonFunc;
da_glutMultiMotionFunc glutMultiMotionFunc;
da_glutMultiPassiveFunc glutMultiPassiveFunc;
da_glutInitContextVersion glutInitContextVersion;
da_glutInitContextFlags glutInitContextFlags;
da_glutInitContextProfile glutInitContextProfile;
da_glutInitErrorFunc glutInitErrorFunc;
da_glutInitWarningFunc glutInitWarningFunc;
}
|
D
|
/Users/phungdu/Documents/code/vapor/TILApp/Build/Intermediates/TILApp.build/Debug/SQL.build/Objects-normal/x86_64/SQLQueryBuilder.o : /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLBind.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLJoinMethod.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLTable.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLCreateTable.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDropTable.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLAlterTable.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLSerializable.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDataType.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLUpdate.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDelete.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLLiteral.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLBoolLiteral.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDefaultLiteral.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLTableConstraintAlgorithm.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLColumnConstraintAlgorithm.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLJoin.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLExpression.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLSelectExpression.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLCollation.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLForeignKeyAction.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLConnection.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDirection.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLFunction.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLColumnDefinition.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLCreateTableBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDropTableBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLAlterTableBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLPredicateBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLUpdateBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDeleteBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLColumnBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLPredicateGroupBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLSelectBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLInsertBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLRawBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLCreateIndexBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLQueryBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLQueryEncoder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLQueryFetcher.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLIndexModifier.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLIdentifier.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLTableIdentifier.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLColumnIdentifier.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLError.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLBinaryOperator.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/Exports.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLSelect.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDistinct.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLFunctionArgument.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLTableConstraint.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLColumnConstraint.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLInsert.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLCreateIndex.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDropIndex.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLGroupBy.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLOrderBy.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLForeignKey.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLPrimaryKey.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLQuery.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/NIO.framework/Modules/NIO.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/Async.framework/Modules/Async.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/Service.framework/Modules/Service.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/Core.framework/Modules/Core.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/Debugging.framework/Modules/Debugging.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/COperatingSystem.framework/Modules/COperatingSystem.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/NIOConcurrencyHelpers.framework/Modules/NIOConcurrencyHelpers.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/Bits.framework/Modules/Bits.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/NIOFoundationCompat.framework/Modules/NIOFoundationCompat.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/DatabaseKit.framework/Modules/DatabaseKit.swiftmodule/x86_64.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/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 /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/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOAtomics.framework/Headers/cpp_magic.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOLinux.framework/Headers/ifaddrs-android.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIODarwin.framework/Headers/CNIODarwin.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOAtomics.framework/Headers/CNIOAtomics.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOLinux.framework/Headers/CNIOLinux.h /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/swift-nio-zlib-support.git--5226887469817572071/module.modulemap /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIODarwin.framework/Modules/module.modulemap /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOAtomics.framework/Modules/module.modulemap /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOLinux.framework/Modules/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/phungdu/Documents/code/vapor/TILApp/Build/Intermediates/TILApp.build/Debug/SQL.build/Objects-normal/x86_64/SQLQueryBuilder~partial.swiftmodule : /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLBind.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLJoinMethod.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLTable.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLCreateTable.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDropTable.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLAlterTable.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLSerializable.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDataType.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLUpdate.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDelete.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLLiteral.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLBoolLiteral.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDefaultLiteral.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLTableConstraintAlgorithm.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLColumnConstraintAlgorithm.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLJoin.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLExpression.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLSelectExpression.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLCollation.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLForeignKeyAction.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLConnection.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDirection.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLFunction.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLColumnDefinition.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLCreateTableBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDropTableBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLAlterTableBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLPredicateBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLUpdateBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDeleteBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLColumnBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLPredicateGroupBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLSelectBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLInsertBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLRawBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLCreateIndexBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLQueryBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLQueryEncoder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLQueryFetcher.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLIndexModifier.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLIdentifier.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLTableIdentifier.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLColumnIdentifier.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLError.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLBinaryOperator.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/Exports.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLSelect.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDistinct.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLFunctionArgument.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLTableConstraint.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLColumnConstraint.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLInsert.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLCreateIndex.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDropIndex.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLGroupBy.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLOrderBy.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLForeignKey.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLPrimaryKey.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLQuery.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/NIO.framework/Modules/NIO.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/Async.framework/Modules/Async.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/Service.framework/Modules/Service.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/Core.framework/Modules/Core.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/Debugging.framework/Modules/Debugging.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/COperatingSystem.framework/Modules/COperatingSystem.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/NIOConcurrencyHelpers.framework/Modules/NIOConcurrencyHelpers.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/Bits.framework/Modules/Bits.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/NIOFoundationCompat.framework/Modules/NIOFoundationCompat.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/DatabaseKit.framework/Modules/DatabaseKit.swiftmodule/x86_64.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/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 /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/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOAtomics.framework/Headers/cpp_magic.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOLinux.framework/Headers/ifaddrs-android.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIODarwin.framework/Headers/CNIODarwin.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOAtomics.framework/Headers/CNIOAtomics.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOLinux.framework/Headers/CNIOLinux.h /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/swift-nio-zlib-support.git--5226887469817572071/module.modulemap /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIODarwin.framework/Modules/module.modulemap /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOAtomics.framework/Modules/module.modulemap /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOLinux.framework/Modules/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/phungdu/Documents/code/vapor/TILApp/Build/Intermediates/TILApp.build/Debug/SQL.build/Objects-normal/x86_64/SQLQueryBuilder~partial.swiftdoc : /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLBind.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLJoinMethod.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLTable.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLCreateTable.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDropTable.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLAlterTable.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLSerializable.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDataType.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLUpdate.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDelete.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLLiteral.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLBoolLiteral.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDefaultLiteral.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLTableConstraintAlgorithm.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLColumnConstraintAlgorithm.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLJoin.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLExpression.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLSelectExpression.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLCollation.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLForeignKeyAction.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLConnection.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDirection.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLFunction.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLColumnDefinition.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLCreateTableBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDropTableBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLAlterTableBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLPredicateBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLUpdateBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDeleteBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLColumnBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLPredicateGroupBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLSelectBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLInsertBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLRawBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLCreateIndexBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLQueryBuilder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLQueryEncoder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLQueryFetcher.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLIndexModifier.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLIdentifier.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLTableIdentifier.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLColumnIdentifier.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLError.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLBinaryOperator.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/Exports.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLSelect.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDistinct.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLFunctionArgument.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLTableConstraint.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLColumnConstraint.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLInsert.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLCreateIndex.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLDropIndex.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLGroupBy.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLOrderBy.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLForeignKey.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLPrimaryKey.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/sql.git-6484346812122690078/Sources/SQL/SQLQuery.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/NIO.framework/Modules/NIO.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/Async.framework/Modules/Async.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/Service.framework/Modules/Service.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/Core.framework/Modules/Core.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/Debugging.framework/Modules/Debugging.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/COperatingSystem.framework/Modules/COperatingSystem.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/NIOConcurrencyHelpers.framework/Modules/NIOConcurrencyHelpers.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/Bits.framework/Modules/Bits.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/NIOFoundationCompat.framework/Modules/NIOFoundationCompat.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/DatabaseKit.framework/Modules/DatabaseKit.swiftmodule/x86_64.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/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 /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/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOAtomics.framework/Headers/cpp_magic.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOLinux.framework/Headers/ifaddrs-android.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIODarwin.framework/Headers/CNIODarwin.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOAtomics.framework/Headers/CNIOAtomics.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOLinux.framework/Headers/CNIOLinux.h /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/swift-nio-zlib-support.git--5226887469817572071/module.modulemap /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIODarwin.framework/Modules/module.modulemap /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOAtomics.framework/Modules/module.modulemap /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOLinux.framework/Modules/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
|
D
|
// cl4d - a D wrapper for the Derelict OpenCL binding
// written in the D programming language
//
// Copyright: Andreas Hollandt 2009 - 2011,
// MeinMein 2013-2014.
// License: Boost License 1.0
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Authors: Andreas Hollandt,
// Gerbrand Kamphuis (meinmein.com).
module cl4d.kernel;
import derelict.opencl.cl;
import cl4d.commandqueue;
import cl4d.context;
import cl4d.device;
import cl4d.error;
import cl4d.memory;
import cl4d.program;
import cl4d.sampler;
import cl4d.wrapper;
import std.string : toStringz;
import std.traits;
//! used in setArg to specify the size in bytes of the buffer that must be allocated for a kernel __local argument
struct LocalArgSize
{
size_t size;
alias size this;
}
//! NDRange struct
// TODO: more dimensions needed? => CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS
struct NDRange
{
size_t[3] sizes;
//!
this(size_t x, size_t y = 0, size_t z = 0)
{
sizes[0] = x;
sizes[1] = y;
sizes[2] = z;
}
//! returns a pointer to the sizes array
@property const ptr()
{
// TODO: any better way to make a NullRange return null?
if (dimensions == 0)
return cast(const(size_t)*) null;
else
return &sizes[0];
}
//! returns number of work dimensions
@property cl_uint dimensions() const
{
return sizes[2] != 0 ? 3 : (sizes[1] != 0 ? 2 : (sizes[0] != 0 ? 1 : 0));
}
}
//! null for NDRange
__gshared immutable NDRange NullRange;
static this()
{
NullRange = NDRange();
}
//! collection of several devices
alias CLObjectCollection!CLKernel CLKernels;
/**
* Kernel objects can only be created once you have a program object with a valid program source
* or binary loaded into the program object and the program executable has been successfully built
* for one or more devices associated with program. No changes to the program executable are
* allowed while there are kernel objects associated with a program object.
*/
struct CLKernel
{
mixin(CLWrapper("cl_kernel", "clGetKernelInfo"));
public:
/**
* create a kernel object
*
* Params:
* program = a program object with a successfully built executable
* kernelName = a function name in the program declared with the __kernel qualifier
*/
this(CLProgram program, string kernelName)
{
cl_errcode res;
this(clCreateKernel(program.cptr, toStringz(kernelName), &res));
mixin(exceptionHandling(
["CL_INVALID_PROGRAM", "program is not a valid program object"],
["CL_INVALID_PROGRAM_EXECUTABLE", "there is no successfully built executable for program"],
["CL_INVALID_KERNEL_NAME", "kernelName is not found in program"],
["CL_INVALID_KERNEL_DEFINITION", "the function definition for __kernel function given by kernelName such as the number of arguments, the argument types are not the same for all devices for which the program executable has been built"],
["CL_INVALID_VALUE", "kernelName is NULL"],
["CL_OUT_OF_RESOURCES", ""],
["CL_OUT_OF_HOST_MEMORY", ""]
));
}
/**
* A shorthand function for setting all the arguments for a kernel
*/
void setArgs(ArgTypes...)(ArgTypes args)
in
{
assert(args.length == numArgs);
}
body
{
foreach(uint idx, arg; args)
setArg(idx, arg);
}
/**
* set the argument value for a specific argument of a kernel
*
* Params:
* idx = indices go from 0 for the leftmost argument to n - 1
* arg = the argument to be set
*/
void setArg(ArgType)(cl_uint idx, ArgType arg)
{
static if (is(ArgType : CLMemory) || is(ArgType == CLSampler))
{
auto tmp = arg.cptr;
setArgx(idx, arg.cptr.sizeof, &tmp);
}
//else static if (is(ArgType : CLObject)) // FIXME ..CLObject does not exist
// static assert(0, "can't set " ~ ArgType.stringof ~ " as a kernel argument!");
else static if (is(ArgType == LocalArgSize))
setArgx(idx, arg.size, null); // it's a __local parameter, so just set its size
else static if (is(ArgType U : U*))
{
if (arg is null)
setArgx(idx, 0, null); // a null value will be used as the value for the argument declared as a pointer to __global or __constant memory in the kernel
else
assert(0, "arbitrary pointers can't be passed to kernels");
}
else static if (std.traits.isNumeric!ArgType)
setArgx(idx, arg.sizeof, &arg);
else
static assert(0, "type " ~ ArgType.stringof ~ " isn't handled in CLKernel.setArg yet");
}
/*
* set the argument value for a specific argument of a kernel
*
* Params:
* idx = indices go from 0 for the leftmost argument to n - 1
* value= see specs pp. 127f
*/
private void setArgx(cl_uint idx, size_t size, const void* value)
{
// clSetKernelArg is safe to call from any host thread, and is safe to call re-entrantly so long as concurrent calls operate on different cl_kernel objects
// the behavior of the cl_kernel object is undefined if clSetKernelArg is called from multiple host threads on the same cl_kernel object at the same time
// TODO: thus, if multiple CLKernel objects wrap the same cl_kernel one, this still makes problems
cl_errcode res;
// TODO:
/* synchronized(this) */ res = clSetKernelArg(_object, idx, size, value);
mixin(exceptionHandling(
["CL_INVALID_KERNEL", ""],
["CL_INVALID_ARG_INDEX", ""],
["CL_INVALID_ARG_VALUE", ""],
["CL_INVALID_MEM_OBJECT", "argument declared to be a memory object when the specified value is not a valid memory object"],
["CL_INVALID_SAMPLER", "argument declared to be of type sampler_t when the specified arg_value is not a valid sampler object"],
["CL_INVALID_ARG_SIZE", "arg_size does not match the size of the data type for an argument that is not a memory object or if the argument is a memory object and arg_size != cl_mem.sizeof or if arg_size is zero and the argument is declared with the __local qualifier or if the argument is a sampler and arg_size != cl_sampler.sizeof"],
["CL_OUT_OF_RESOURCES", ""],
["CL_OUT_OF_HOST_MEMORY", ""]
));
}
//! bind this kernel to a command queue and specific NDRanges
CLKernelFunctor bind(CLCommandQueue queue, const ref NDRange global, const ref NDRange local = NullRange, const ref NDRange offset = NullRange)
{
return new CLKernelFunctor(this, queue, global, local, offset);
}
@property
{
/// Return the kernel function name
string kernelName()
{
return getStringInfo(CL_KERNEL_FUNCTION_NAME);
}
/// Return the number of arguments to kernel
cl_uint numArgs()
{
return this.getInfo!(cl_uint)(CL_KERNEL_NUM_ARGS);
}
/// Return the context associated with kernel
CLContext context()
{
return CLContext(this.getInfo!(cl_context)(CL_KERNEL_CONTEXT));
}
//! Return the program object associated with kernel
CLProgram program()
{
return CLProgram(this.getInfo!(cl_program)(CL_KERNEL_PROGRAM));
}
} // of @property
/**
* This provides a mechanism for the application to query the maximum
* work-group size that can be used to execute a kernel on a specific device
* given by device. The OpenCL implementation uses the resource requirements of the kernel (register
* usage etc.) to determine what this workgroup size should be.
*/
size_t workGroupSize(CLDevice device)
{
return getInfo2!(size_t, clGetKernelWorkGroupInfo)(device.cptr, CL_KERNEL_WORK_GROUP_SIZE);
}
/**
* Returns the work-group size specified by the __attribute__((reqd_work_group_size(X, Y, Z))) qualifier.
* Refer to section 6.8.2.
* If the work-group size is not specified using the above attribute qualifier (0, 0, 0) is returned
*/
size_t[3] compileWorkGroupSize(CLDevice device)
{
return getInfo2!(size_t[3], clGetKernelWorkGroupInfo)(device.cptr, CL_KERNEL_COMPILE_WORK_GROUP_SIZE);
}
/**
* Returns the amount of local memory in bytes being used by a kernel. This includes local memory that may be
* needed by an implementation to execute the kernel, variables declared inside the kernel with the __local address
* qualifier and local memory to be allocated for arguments to the kernel declared as pointers with the __local
* address qualifier and whose size is specified with clSetKernelArg. If the local memory size, for any pointer
* argument to the kernel declared with the __local address qualifier, is not specified, its size is assumed to be 0.
*/
cl_ulong localMemSize(CLDevice device)
{
return getInfo2!(cl_ulong, clGetKernelWorkGroupInfo)(device.cptr, CL_KERNEL_LOCAL_MEM_SIZE);
}
/**
* Returns the preferred multiple of workgroup size for launch. This is a performance hint. Specifying a workgroup
* size that is not a multiple of the value returned by this query as the value of the local work size argument to
* clEnqueueNDRangeKernel will not fail to enqueue the kernel for execution unless the work-group size specified is
* larger than the device maximum.
*/
size_t preferredWorkGroupSizeMultiple(CLDevice device)
{
return getInfo2!(size_t, clGetKernelWorkGroupInfo)(device.cptr, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE);
}
/**
* Returns the minimum amount of private memory, in bytes, used by each workitem in the kernel. This value may
* include any private memory needed by an implementation to execute the kernel, including that used by the language
* built-ins and variable declared inside the kernel with the __private qualifier.
*/
cl_ulong privateMemSize(CLDevice device)
{
return getInfo2!(cl_ulong, clGetKernelWorkGroupInfo)(device.cptr, CL_KERNEL_PRIVATE_MEM_SIZE);
}
}
final class CLKernelFunctor
{
private:
CLKernel _kernel;
CLCommandQueue _commandqueue;
NDRange _offset;
NDRange _global;
NDRange _local;
public:
this(CLKernel kernel, CLCommandQueue commandqueue, const ref NDRange global, const ref NDRange local = NullRange, const ref NDRange offset = NullRange)
{
_kernel = kernel;
_commandqueue = commandqueue;
_offset = offset;
_global = global;
_local = local;
}
CLEvent opCall(T...)(T args)
{
_kernel.setArgs(args);
return _commandqueue.enqueueNDRangeKernel(_kernel, _global, _local, _offset);
}
}
|
D
|
<?xml version="1.0" encoding="ASCII"?>
<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="model.notation#_T9SUgMhlEeKp1oANwQY0Gg"/>
</availablePage>
</pageList>
<sashModel currentSelection="//@sashModel/@windows.0/@children.0">
<windows>
<children xsi:type="di:TabFolder">
<children>
<emfPageIdentifier href="model.notation#_T9SUgMhlEeKp1oANwQY0Gg"/>
</children>
</children>
</windows>
</sashModel>
</di:SashWindowsMngr>
|
D
|
/**
* Authors: Frank Benoit <keinfarbton@googlemail.com>
*/
module dwt.dwthelper.FileInputStream;
import dwt.dwthelper.utils;
import dwt.dwthelper.File;
import dwt.dwthelper.InputStream;
import TangoFile = tango.io.device.File;
import tango.core.Exception;
import tango.text.convert.Format;
public class FileInputStream : dwt.dwthelper.InputStream.InputStream {
alias dwt.dwthelper.InputStream.InputStream.read read;
private TangoFile.File conduit;
private ubyte[] buffer;
private int buf_pos;
private int buf_size;
private const int BUFFER_SIZE = 0x10000;
private bool eof;
public this ( String name ){
conduit = new TangoFile.File( name );
buffer = new ubyte[]( BUFFER_SIZE );
}
public this ( dwt.dwthelper.File.File file ){
implMissing( __FILE__, __LINE__ );
conduit = new TangoFile.File( file.getAbsolutePath(), TangoFile.File.ReadExisting );
buffer = new ubyte[]( BUFFER_SIZE );
}
public override int read(){
if( eof ){
return -1;
}
try{
if( buf_pos == buf_size ){
buf_pos = 0;
buf_size = conduit.input.read( buffer );
}
if( buf_size <= 0 ){
eof = true;
return -1;
}
assert( buf_pos < BUFFER_SIZE, Format( "{0} {1}", buf_pos, buf_size ) );
assert( buf_size <= BUFFER_SIZE );
int res = cast(int) buffer[ buf_pos ];
buf_pos++;
return res;
}
catch( IOException e ){
eof = true;
return -1;
}
}
public long skip( long n ){
implMissing( __FILE__, __LINE__ );
return 0L;
}
public int available(){
implMissing( __FILE__, __LINE__ );
return 0;
}
public override void close(){
conduit.close();
}
}
|
D
|
/*
* $Id: crystal.d,v 1.2 2005/07/17 11:02:45 kenta Exp $
*
* Copyright 2005 Kenta Cho. Some rights reserved.
*/
module abagames.gr.crystal;
private import std.math;
private import bindbc.opengl;
private import abagames.util.actor;
private import abagames.util.vector;
private import abagames.gr.ship;
private import abagames.gr.screen;
private import abagames.gr.shape;
/**
* Bonus crystals.
*/
public class Crystal: Actor {
private:
static const int COUNT = 60;
static const int PULLIN_COUNT = cast(int) (COUNT * 0.8f);
static CrystalShape _shape;
Ship ship;
Vector pos;
Vector vel;
int cnt;
invariant {
assert(pos.x < 15 && pos.x > -15);
assert(pos.y < 30 && pos.y > -30);
assert(vel.x < 10 && vel.x > -10);
assert(vel.y < 10 && vel.y > -10);
}
public static void init() {
_shape = new CrystalShape;
}
public static void close() {
_shape.close();
}
public this() {
pos = new Vector;
vel = new Vector;
}
public override void init(Object[] args) {
ship = cast(Ship) args[0];
}
public void set(Vector p) {
pos.x = p.x;
pos.y = p.y;
cnt = COUNT;
vel.x = 0;
vel.y = 0.1f;
exists = true;
}
public override void move() {
cnt--;
float dist = pos.dist(ship.midstPos);
if (dist < 0.1f)
dist = 0.1f;
if (cnt < PULLIN_COUNT) {
vel.x += (ship.midstPos.x - pos.x) / dist * 0.07f;
vel.y += (ship.midstPos.y - pos.y) / dist * 0.07f;
if (cnt < 0 || dist < 2) {
exists = false;
return;
}
}
vel *= 0.95f;
pos += vel;
}
public override void draw() {
float r = 0.25f;
float d = cnt * 0.1f;
if (cnt > PULLIN_COUNT)
r *= (cast(float) (COUNT - cnt)) / (COUNT - PULLIN_COUNT);
for (int i = 0; i < 4; i++) {
glPushMatrix();
glTranslatef(pos.x + sin(d) * r, pos.y + cos(d) * r, 0);
_shape.draw();
glPopMatrix();
d += PI / 2;
}
}
}
public class CrystalPool: ActorPool!(Crystal) {
public this(int n, Object[] args) {
super(n, args);
}
}
|
D
|
module a;
void test()
{
}
|
D
|
module yu.tools.serialize.write;
import std.bitmanip;
import yu.tools.serialize.types;
import yu.tools.serialize.status;
import yu.tools.serialize.exception;
import yu.traits;
import yu.tools.buffer;
import yu.memory.allocator;
struct WriteStream
{
@disable this();
@disable this(this);
this(IWriteBuffer buffer)
{
_buffer = buffer;
}
~this()
{
StatusNode * node = _status.pop();
while(node){
yDel(node);
node = _status.pop();
}
}
@property buffer(){return _buffer;}
void write(X)(X value) if(isBasicSupport!(X).isNum)
{
doIsArray(dtTypes!X);
ubyte[X.sizeof] data = nativeToBigEndian!X(value);
append(data);
}
void write(X)(X value) if(isBasicSupport!(X).isChar)
{
doIsArray(dtTypes!X);
append(cast(ubyte)value);
}
void write(X:bool)(X value)
{
doIsArray(dtTypes!X);
ubyte a = value ? 0x01 : 0x00;
append(a);
}
void write(X:DateTime)(ref X value)
{
doIsArray(dtTypes!X);
ubyte[2] data;
data = nativeToBigEndian!short(value.year());
append(data);
append(value.month());
append(value.day());
append(value.hour());
append(value.minute());
append(value.second());
}
void write(X:Date)(ref X value)
{
doIsArray(dtTypes!X);
ubyte[2] data;
data = nativeToBigEndian!short(value.year());
append(data);
append(value.month());
append(value.day());
}
void write(X:Time)(ref X value)
{
doIsArray(dtTypes!X);
append(value.hour);
append(value.minute);
append(value.second);
ubyte[2] data;
data = nativeToBigEndian!ushort(value.msecond);
append(data);
}
void write(X:char[])(ref X value)
{
writeRawArray(Types.Char,cast(ubyte[])value);
}
void write(X:byte[])(ref X value)
{
writeRawArray(Types.Byte,cast(ubyte[])value);
}
void write(X:ubyte[])(ref X value)
{
writeRawArray(Types.UByte,value);
}
void write(X: string)(ref X value)
{
writeRawArray(Types.Char,cast(ubyte[])value);
}
void write(X)(ref X value) if(isArray!(X) && isBasicSupport!(X).isBSupport && !isStruct!X)
{
startArray!(ForeachType!X)();
scope(success)endArray();
foreach(ref v ; value)
{
write(v);
}
}
void startArray(X)() if(isBasicSupport!(X).isBSupport)
{
Types ty = dtTypes!X;
StatusNode * state = yNew!StatusNode();
state.state = Status.InArray;
state.type = ty;
_status.push(state);
append(Types.Array);
append(ty);
state.begin = _buffer.length;
ubyte[4] data;
append(data);
}
void endArray()
{
StatusNode * state = _status.pop();
if(state is null || state.state != Status.InArray)
throw new WriteException("not in Array!!!");
scope(exit)yDel(state);
ubyte[4] data = nativeToBigEndian!uint(state.len);
//_data[state.begin..(state.begin + 4)] = data; //写入数组长度
_buffer.set(state.begin, data[]);
//append(data[]);
append(Types.End);
StatusNode * state2 = _status.front();
if(state2 !is null && state2.state == Status.InArray)
{
if(state2.type == Types.Array) {
state2.len ++;
}
}
}
void startStruct()
{
StatusNode * state = yNew!StatusNode();
state.state = Status.InStruct;
state.type = Types.Struct;
_status.push(state);
append(Types.Struct);
}
void endStruct()
{
StatusNode * state = _status.pop();
if(state is null || state.state != Status.InStruct)
throw new WriteException("not in struct!!!");
scope(exit)yDel(state);
append(Types.End);
StatusNode * state2 = _status.front();
if(state2 !is null && state2.state == Status.InArray)
{
if(state2.type == Types.Struct) {
state2.len ++;
}
}
}
pragma(inline) void append(ubyte value)
{
ubyte * ptr = &value;
_buffer.write(ptr[0..1]);
}
pragma(inline) void append(in ubyte[] value)
{
_buffer.write(value);
}
private:
//pragma(inline, true)
void writeRawArray(Types ty, ubyte[] data)
{
append(Types.Array);
append(ty);
uint leng = cast(uint)data.length;
ubyte[4] dt = nativeToBigEndian!uint(leng);
append(dt[]);
append(data);
append(Types.End);
}
//pragma(inline, true)
void doIsArray(Types ty)
{
StatusNode * state = _status.front();
if(state !is null && state.state == Status.InArray)
{
if(state.type == ty) {
state.len ++;
}else {
endArray();
append(ty);
}
}else{
append(ty);
}
}
private:
IWriteBuffer _buffer;
StatusStack _status;
}
|
D
|
// Written in the D programming language.
/**
Functions and types that manipulate built-in arrays and associative arrays.
This module provides all kinds of functions to create, manipulate or convert arrays:
$(SCRIPT inhibitQuickIndex = 1;)
$(BOOKTABLE ,
$(TR $(TH Function Name) $(TH Description)
)
$(TR $(TD $(LREF _array))
$(TD Returns a copy of the input in a newly allocated dynamic _array.
))
$(TR $(TD $(LREF appender))
$(TD Returns a new $(LREF Appender) or $(LREF RefAppender) initialized with a given _array.
))
$(TR $(TD $(LREF assocArray))
$(TD Returns a newly allocated associative _array from a range of key/value tuples.
))
$(TR $(TD $(LREF byPair))
$(TD Construct a range iterating over an associative _array by key/value tuples.
))
$(TR $(TD $(LREF insertInPlace))
$(TD Inserts into an existing _array at a given position.
))
$(TR $(TD $(LREF join))
$(TD Concatenates a range of ranges into one _array.
))
$(TR $(TD $(LREF minimallyInitializedArray))
$(TD Returns a new _array of type `T`.
))
$(TR $(TD $(LREF replace))
$(TD Returns a new _array with all occurrences of a certain subrange replaced.
))
$(TR $(TD $(LREF replaceFirst))
$(TD Returns a new _array with the first occurrence of a certain subrange replaced.
))
$(TR $(TD $(LREF replaceInPlace))
$(TD Replaces all occurrences of a certain subrange and puts the result into a given _array.
))
$(TR $(TD $(LREF replaceInto))
$(TD Replaces all occurrences of a certain subrange and puts the result into an output range.
))
$(TR $(TD $(LREF replaceLast))
$(TD Returns a new _array with the last occurrence of a certain subrange replaced.
))
$(TR $(TD $(LREF replaceSlice))
$(TD Returns a new _array with a given slice replaced.
))
$(TR $(TD $(LREF replicate))
$(TD Creates a new _array out of several copies of an input _array or range.
))
$(TR $(TD $(LREF sameHead))
$(TD Checks if the initial segments of two arrays refer to the same
place in memory.
))
$(TR $(TD $(LREF sameTail))
$(TD Checks if the final segments of two arrays refer to the same place
in memory.
))
$(TR $(TD $(LREF split))
$(TD Eagerly split a range or string into an _array.
))
$(TR $(TD $(LREF uninitializedArray))
$(TD Returns a new _array of type `T` without initializing its elements.
))
)
Copyright: Copyright Andrei Alexandrescu 2008- and Jonathan M Davis 2011-.
License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(HTTP erdani.org, Andrei Alexandrescu) and
$(HTTP jmdavisprog.com, Jonathan M Davis)
Source: $(PHOBOSSRC std/_array.d)
*/
module std.array;
import std.functional;
import std.meta;
import std.traits;
import std.range.primitives;
public import std.range.primitives : save, empty, popFront, popBack, front, back;
/**
* Allocates an array and initializes it with copies of the elements
* of range `r`.
*
* Narrow strings are handled as a special case in an overload.
*
* Params:
* r = range (or aggregate with `opApply` function) whose elements are copied into the allocated array
* Returns:
* allocated and initialized array
*/
ForeachType!Range[] array(Range)(Range r)
if (isIterable!Range && !isNarrowString!Range && !isInfinite!Range)
{
if (__ctfe)
{
// Compile-time version to avoid memcpy calls.
// Also used to infer attributes of array().
typeof(return) result;
foreach (e; r)
result ~= e;
return result;
}
alias E = ForeachType!Range;
static if (hasLength!Range)
{
auto length = r.length;
if (length == 0)
return null;
import std.conv : emplaceRef;
auto result = (() @trusted => uninitializedArray!(Unqual!E[])(length))();
// Every element of the uninitialized array must be initialized
size_t i;
foreach (e; r)
{
emplaceRef!E(result[i], e);
++i;
}
return (() @trusted => cast(E[]) result)();
}
else
{
auto a = appender!(E[])();
foreach (e; r)
{
a.put(e);
}
return a.data;
}
}
/// ditto
ForeachType!(PointerTarget!Range)[] array(Range)(Range r)
if (isPointer!Range && isIterable!(PointerTarget!Range) && !isNarrowString!Range && !isInfinite!Range)
{
return array(*r);
}
///
@safe pure nothrow unittest
{
auto a = array([1, 2, 3, 4, 5][]);
assert(a == [ 1, 2, 3, 4, 5 ]);
}
@safe pure nothrow unittest
{
import std.algorithm.comparison : equal;
struct Foo
{
int a;
}
auto a = array([Foo(1), Foo(2), Foo(3), Foo(4), Foo(5)][]);
assert(equal(a, [Foo(1), Foo(2), Foo(3), Foo(4), Foo(5)]));
}
@safe pure nothrow unittest
{
struct MyRange
{
enum front = 123;
enum empty = true;
void popFront() {}
}
auto arr = (new MyRange).array;
assert(arr.empty);
}
@system pure nothrow unittest
{
immutable int[] a = [1, 2, 3, 4];
auto b = (&a).array;
assert(b == a);
}
@safe unittest
{
import std.algorithm.comparison : equal;
struct Foo
{
int a;
void opAssign(Foo)
{
assert(0);
}
auto opEquals(Foo foo)
{
return a == foo.a;
}
}
auto a = array([Foo(1), Foo(2), Foo(3), Foo(4), Foo(5)][]);
assert(equal(a, [Foo(1), Foo(2), Foo(3), Foo(4), Foo(5)]));
}
@safe unittest
{
// Issue 12315
static struct Bug12315 { immutable int i; }
enum bug12315 = [Bug12315(123456789)].array();
static assert(bug12315[0].i == 123456789);
}
@safe unittest
{
import std.range;
static struct S{int* p;}
auto a = array(immutable(S).init.repeat(5));
assert(a.length == 5);
}
/**
Convert a narrow string to an array type that fully supports random access.
This is handled as a special case and always returns an array of `dchar`
Params:
str = `isNarrowString` to be converted to an array of `dchar`
Returns:
a `dchar[]`, `const(dchar)[]`, or `immutable(dchar)[]` depending on the constness of
the input.
*/
ElementType!String[] array(String)(scope String str)
if (isNarrowString!String)
{
import std.utf : toUTF32;
auto temp = str.toUTF32;
/* Unsafe cast. Allowed because toUTF32 makes a new array
and copies all the elements.
*/
return () @trusted { return cast(ElementType!String[]) temp; } ();
}
///
@safe unittest
{
import std.range.primitives : isRandomAccessRange;
assert("Hello D".array == "Hello D"d);
static assert(isRandomAccessRange!string == false);
assert("Hello D"w.array == "Hello D"d);
static assert(isRandomAccessRange!dstring == true);
}
@safe unittest
{
import std.conv : to;
static struct TestArray { int x; string toString() @safe { return to!string(x); } }
static struct OpAssign
{
uint num;
this(uint num) { this.num = num; }
// Templating opAssign to make sure the bugs with opAssign being
// templated are fixed.
void opAssign(T)(T rhs) { this.num = rhs.num; }
}
static struct OpApply
{
int opApply(scope int delegate(ref int) @safe dg)
{
int res;
foreach (i; 0 .. 10)
{
res = dg(i);
if (res) break;
}
return res;
}
}
auto a = array([1, 2, 3, 4, 5][]);
assert(a == [ 1, 2, 3, 4, 5 ]);
auto b = array([TestArray(1), TestArray(2)][]);
assert(b == [TestArray(1), TestArray(2)]);
class C
{
int x;
this(int y) { x = y; }
override string toString() const @safe { return to!string(x); }
}
auto c = array([new C(1), new C(2)][]);
assert(c[0].x == 1);
assert(c[1].x == 2);
auto d = array([1.0, 2.2, 3][]);
assert(is(typeof(d) == double[]));
assert(d == [1.0, 2.2, 3]);
auto e = [OpAssign(1), OpAssign(2)];
auto f = array(e);
assert(e == f);
assert(array(OpApply.init) == [0,1,2,3,4,5,6,7,8,9]);
assert(array("ABC") == "ABC"d);
assert(array("ABC".dup) == "ABC"d.dup);
}
//Bug# 8233
@safe unittest
{
assert(array("hello world"d) == "hello world"d);
immutable a = [1, 2, 3, 4, 5];
assert(array(a) == a);
const b = a;
assert(array(b) == a);
//To verify that the opAssign branch doesn't get screwed up by using Unqual.
//EDIT: array no longer calls opAssign.
struct S
{
ref S opAssign(S)(const ref S rhs)
{
assert(0);
}
int i;
}
static foreach (T; AliasSeq!(S, const S, immutable S))
{{
auto arr = [T(1), T(2), T(3), T(4)];
assert(array(arr) == arr);
}}
}
@safe unittest
{
//9824
static struct S
{
@disable void opAssign(S);
int i;
}
auto arr = [S(0), S(1), S(2)];
arr.array();
}
// Bugzilla 10220
@safe unittest
{
import std.algorithm.comparison : equal;
import std.exception;
import std.range : repeat;
static struct S
{
int val;
@disable this();
this(int v) { val = v; }
}
assertCTFEable!(
{
auto r = S(1).repeat(2).array();
assert(equal(r, [S(1), S(1)]));
});
}
@safe unittest
{
//Turn down infinity:
static assert(!is(typeof(
repeat(1).array()
)));
}
/**
Returns a newly allocated associative _array from a range of key/value tuples.
Params:
r = An $(REF_ALTTEXT input range, isInputRange, std,range,primitives)
of tuples of keys and values.
Returns: A newly allocated associative array out of elements of the input
range, which must be a range of tuples (Key, Value). Returns a null associative
array reference when given an empty range.
Duplicates: Associative arrays have unique keys. If r contains duplicate keys,
then the result will contain the value of the last pair for that key in r.
See_Also: $(REF Tuple, std,typecons), $(REF zip, std,range)
*/
auto assocArray(Range)(Range r)
if (isInputRange!Range)
{
import std.typecons : isTuple;
alias E = ElementType!Range;
static assert(isTuple!E, "assocArray: argument must be a range of tuples");
static assert(E.length == 2, "assocArray: tuple dimension must be 2");
alias KeyType = E.Types[0];
alias ValueType = E.Types[1];
static assert(isMutable!ValueType, "assocArray: value type must be mutable");
ValueType[KeyType] aa;
foreach (t; r)
aa[t[0]] = t[1];
return aa;
}
///
@safe pure /*nothrow*/ unittest
{
import std.range;
import std.typecons;
auto a = assocArray(zip([0, 1, 2], ["a", "b", "c"])); // aka zipMap
assert(is(typeof(a) == string[int]));
assert(a == [0:"a", 1:"b", 2:"c"]);
auto b = assocArray([ tuple("foo", "bar"), tuple("baz", "quux") ]);
assert(is(typeof(b) == string[string]));
assert(b == ["foo":"bar", "baz":"quux"]);
}
// @@@11053@@@ - Cannot be version(unittest) - recursive instantiation error
@safe unittest
{
import std.typecons;
static assert(!__traits(compiles, [ tuple("foo", "bar", "baz") ].assocArray()));
static assert(!__traits(compiles, [ tuple("foo") ].assocArray()));
assert([ tuple("foo", "bar") ].assocArray() == ["foo": "bar"]);
}
// Issue 13909
@safe unittest
{
import std.typecons;
auto a = [tuple!(const string, string)("foo", "bar")];
auto b = [tuple!(string, const string)("foo", "bar")];
assert(a == b);
assert(assocArray(a) == [cast(const(string)) "foo": "bar"]);
static assert(!__traits(compiles, assocArray(b)));
}
/**
Construct a range iterating over an associative array by key/value tuples.
Params:
aa = The associative array to iterate over.
Returns: A $(REF_ALTTEXT forward range, isForwardRange, std,range,primitives)
of Tuple's of key and value pairs from the given associative array. The members
of each pair can be accessed by name (`.key` and `.value`). or by integer
index (0 and 1 respectively).
*/
auto byPair(AA)(AA aa)
if (isAssociativeArray!AA)
{
import std.algorithm.iteration : map;
import std.typecons : tuple;
return aa.byKeyValue
.map!(pair => tuple!("key", "value")(pair.key, pair.value));
}
///
@safe unittest
{
import std.algorithm.sorting : sort;
import std.typecons : tuple, Tuple;
auto aa = ["a": 1, "b": 2, "c": 3];
Tuple!(string, int)[] pairs;
// Iteration over key/value pairs.
foreach (pair; aa.byPair)
{
if (pair.key == "b")
pairs ~= tuple("B", pair.value);
else
pairs ~= pair;
}
// Iteration order is implementation-dependent, so we should sort it to get
// a fixed order.
pairs.sort();
assert(pairs == [
tuple("B", 2),
tuple("a", 1),
tuple("c", 3)
]);
}
@safe unittest
{
import std.typecons : tuple, Tuple;
import std.meta : AliasSeq;
auto aa = ["a":2];
auto pairs = aa.byPair();
alias PT = typeof(pairs.front);
static assert(is(PT : Tuple!(string,int)));
static assert(PT.fieldNames == AliasSeq!("key", "value"));
static assert(isForwardRange!(typeof(pairs)));
assert(!pairs.empty);
assert(pairs.front == tuple("a", 2));
auto savedPairs = pairs.save;
pairs.popFront();
assert(pairs.empty);
assert(!savedPairs.empty);
assert(savedPairs.front == tuple("a", 2));
}
// Issue 17711
@safe unittest
{
const(int[string]) aa = [ "abc": 123 ];
// Ensure that byKeyValue is usable with a const AA.
auto kv = aa.byKeyValue;
assert(!kv.empty);
assert(kv.front.key == "abc" && kv.front.value == 123);
kv.popFront();
assert(kv.empty);
// Ensure byPair is instantiable with const AA.
auto r = aa.byPair;
static assert(isInputRange!(typeof(r)));
assert(!r.empty && r.front[0] == "abc" && r.front[1] == 123);
r.popFront();
assert(r.empty);
}
private template blockAttribute(T)
{
import core.memory;
static if (hasIndirections!(T) || is(T == void))
{
enum blockAttribute = 0;
}
else
{
enum blockAttribute = GC.BlkAttr.NO_SCAN;
}
}
@safe unittest
{
import core.memory : UGC = GC;
static assert(!(blockAttribute!void & UGC.BlkAttr.NO_SCAN));
}
// Returns the number of dimensions in an array T.
private template nDimensions(T)
{
static if (isArray!T)
{
enum nDimensions = 1 + nDimensions!(typeof(T.init[0]));
}
else
{
enum nDimensions = 0;
}
}
@safe unittest
{
static assert(nDimensions!(uint[]) == 1);
static assert(nDimensions!(float[][]) == 2);
}
/++
Returns a new array of type `T` allocated on the garbage collected heap
without initializing its elements. This can be a useful optimization if every
element will be immediately initialized. `T` may be a multidimensional
array. In this case sizes may be specified for any number of dimensions from 0
to the number in `T`.
uninitializedArray is `nothrow` and weakly `pure`.
uninitializedArray is `@system` if the uninitialized element type has pointers.
Params:
T = The type of the resulting array elements
sizes = The length dimension(s) of the resulting array
Returns:
An array of `T` with `I.length` dimensions.
+/
auto uninitializedArray(T, I...)(I sizes) nothrow @system
if (isDynamicArray!T && allSatisfy!(isIntegral, I) && hasIndirections!(ElementEncodingType!T))
{
enum isSize_t(E) = is (E : size_t);
alias toSize_t(E) = size_t;
static assert(allSatisfy!(isSize_t, I),
"Argument types in "~I.stringof~" are not all convertible to size_t: "
~Filter!(templateNot!(isSize_t), I).stringof);
//Eagerlly transform non-size_t into size_t to avoid template bloat
alias ST = staticMap!(toSize_t, I);
return arrayAllocImpl!(false, T, ST)(sizes);
}
/// ditto
auto uninitializedArray(T, I...)(I sizes) nothrow @trusted
if (isDynamicArray!T && allSatisfy!(isIntegral, I) && !hasIndirections!(ElementEncodingType!T))
{
enum isSize_t(E) = is (E : size_t);
alias toSize_t(E) = size_t;
static assert(allSatisfy!(isSize_t, I),
"Argument types in "~I.stringof~" are not all convertible to size_t: "
~Filter!(templateNot!(isSize_t), I).stringof);
//Eagerlly transform non-size_t into size_t to avoid template bloat
alias ST = staticMap!(toSize_t, I);
return arrayAllocImpl!(false, T, ST)(sizes);
}
///
@system nothrow pure unittest
{
double[] arr = uninitializedArray!(double[])(100);
assert(arr.length == 100);
double[][] matrix = uninitializedArray!(double[][])(42, 31);
assert(matrix.length == 42);
assert(matrix[0].length == 31);
char*[] ptrs = uninitializedArray!(char*[])(100);
assert(ptrs.length == 100);
}
/++
Returns a new array of type `T` allocated on the garbage collected heap.
Partial initialization is done for types with indirections, for preservation
of memory safety. Note that elements will only be initialized to 0, but not
necessarily the element type's `.init`.
minimallyInitializedArray is `nothrow` and weakly `pure`.
Params:
T = The type of the array elements
sizes = The length dimension(s) of the resulting array
Returns:
An array of `T` with `I.length` dimensions.
+/
auto minimallyInitializedArray(T, I...)(I sizes) nothrow @trusted
if (isDynamicArray!T && allSatisfy!(isIntegral, I))
{
enum isSize_t(E) = is (E : size_t);
alias toSize_t(E) = size_t;
static assert(allSatisfy!(isSize_t, I),
"Argument types in "~I.stringof~" are not all convertible to size_t: "
~Filter!(templateNot!(isSize_t), I).stringof);
//Eagerlly transform non-size_t into size_t to avoid template bloat
alias ST = staticMap!(toSize_t, I);
return arrayAllocImpl!(true, T, ST)(sizes);
}
///
@safe pure nothrow unittest
{
import std.algorithm.comparison : equal;
import std.range : repeat;
auto arr = minimallyInitializedArray!(int[])(42);
assert(arr.length == 42);
// Elements aren't necessarily initialized to 0
assert(!arr.equal(0.repeat(42)));
}
@safe pure nothrow unittest
{
cast(void) minimallyInitializedArray!(int[][][][][])();
double[] arr = minimallyInitializedArray!(double[])(100);
assert(arr.length == 100);
double[][] matrix = minimallyInitializedArray!(double[][])(42);
assert(matrix.length == 42);
foreach (elem; matrix)
{
assert(elem.ptr is null);
}
}
private auto arrayAllocImpl(bool minimallyInitialized, T, I...)(I sizes) nothrow
{
static assert(I.length <= nDimensions!T,
I.length.stringof~"dimensions specified for a "~nDimensions!T.stringof~" dimensional array.");
alias E = ElementEncodingType!T;
E[] ret;
static if (I.length != 0)
{
static assert(is(I[0] == size_t));
alias size = sizes[0];
}
static if (I.length == 1)
{
if (__ctfe)
{
static if (__traits(compiles, new E[](size)))
ret = new E[](size);
else static if (__traits(compiles, ret ~= E.init))
{
try
{
//Issue: if E has an impure postblit, then all of arrayAllocImpl
//Will be impure, even during non CTFE.
foreach (i; 0 .. size)
ret ~= E.init;
}
catch (Exception e)
throw new Error(e.msg);
}
else
assert(0, "No postblit nor default init on " ~ E.stringof ~
": At least one is required for CTFE.");
}
else
{
import core.memory : GC;
import core.stdc.string : memset;
import core.checkedint : mulu;
bool overflow;
const nbytes = mulu(size, E.sizeof, overflow);
if (overflow) assert(0);
auto ptr = cast(E*) GC.malloc(nbytes, blockAttribute!E);
static if (minimallyInitialized && hasIndirections!E)
memset(ptr, 0, nbytes);
ret = ptr[0 .. size];
}
}
else static if (I.length > 1)
{
ret = arrayAllocImpl!(false, E[])(size);
foreach (ref elem; ret)
elem = arrayAllocImpl!(minimallyInitialized, E)(sizes[1..$]);
}
return ret;
}
@safe nothrow pure unittest
{
auto s1 = uninitializedArray!(int[])();
auto s2 = minimallyInitializedArray!(int[])();
assert(s1.length == 0);
assert(s2.length == 0);
}
@safe nothrow pure unittest //@@@9803@@@
{
auto a = minimallyInitializedArray!(int*[])(1);
assert(a[0] == null);
auto b = minimallyInitializedArray!(int[][])(1);
assert(b[0].empty);
auto c = minimallyInitializedArray!(int*[][])(1, 1);
assert(c[0][0] == null);
}
@safe unittest //@@@10637@@@
{
static struct S
{
static struct I{int i; alias i this;}
int* p;
this() @disable;
this(int i)
{
p = &(new I(i)).i;
}
this(this)
{
p = &(new I(*p)).i;
}
~this()
{
assert(p != null);
}
}
auto a = minimallyInitializedArray!(S[])(1);
assert(a[0].p == null);
enum b = minimallyInitializedArray!(S[])(1);
assert(b[0].p == null);
}
@safe nothrow unittest
{
static struct S1
{
this() @disable;
this(this) @disable;
}
auto a1 = minimallyInitializedArray!(S1[][])(2, 2);
assert(a1);
static struct S2
{
this() @disable;
//this(this) @disable;
}
auto a2 = minimallyInitializedArray!(S2[][])(2, 2);
assert(a2);
enum b2 = minimallyInitializedArray!(S2[][])(2, 2);
assert(b2);
static struct S3
{
//this() @disable;
this(this) @disable;
}
auto a3 = minimallyInitializedArray!(S3[][])(2, 2);
assert(a3);
enum b3 = minimallyInitializedArray!(S3[][])(2, 2);
assert(b3);
}
/++
Returns the overlapping portion, if any, of two arrays. Unlike `equal`,
`overlap` only compares the pointers and lengths in the
ranges, not the values referred by them. If `r1` and `r2` have an
overlapping slice, returns that slice. Otherwise, returns the null
slice.
Params:
a = The first array to compare
b = The second array to compare
Returns:
The overlapping portion of the two arrays.
+/
CommonType!(T[], U[]) overlap(T, U)(T[] a, U[] b) @trusted
if (is(typeof(a.ptr < b.ptr) == bool))
{
import std.algorithm.comparison : min;
auto end = min(a.ptr + a.length, b.ptr + b.length);
// CTFE requires pairing pointer comparisons, which forces a
// slightly inefficient implementation.
if (a.ptr <= b.ptr && b.ptr < a.ptr + a.length)
{
return b.ptr[0 .. end - b.ptr];
}
if (b.ptr <= a.ptr && a.ptr < b.ptr + b.length)
{
return a.ptr[0 .. end - a.ptr];
}
return null;
}
///
@safe pure nothrow unittest
{
int[] a = [ 10, 11, 12, 13, 14 ];
int[] b = a[1 .. 3];
assert(overlap(a, b) == [ 11, 12 ]);
b = b.dup;
// overlap disappears even though the content is the same
assert(overlap(a, b).empty);
static test()() @nogc
{
auto a = "It's three o'clock"d;
auto b = a[5 .. 10];
return b.overlap(a);
}
//works at compile-time
static assert(test == "three"d);
}
@safe nothrow unittest
{
static void test(L, R)(L l, R r)
{
assert(overlap(l, r) == [ 100, 12 ]);
assert(overlap(l, l[0 .. 2]) is l[0 .. 2]);
assert(overlap(l, l[3 .. 5]) is l[3 .. 5]);
assert(overlap(l[0 .. 2], l) is l[0 .. 2]);
assert(overlap(l[3 .. 5], l) is l[3 .. 5]);
}
int[] a = [ 10, 11, 12, 13, 14 ];
int[] b = a[1 .. 3];
a[1] = 100;
immutable int[] c = a.idup;
immutable int[] d = c[1 .. 3];
test(a, b);
assert(overlap(a, b.dup).empty);
test(c, d);
assert(overlap(c, d.idup).empty);
}
@safe pure nothrow unittest // bugzilla 9836
{
// range primitives for array should work with alias this types
struct Wrapper
{
int[] data;
alias data this;
@property Wrapper save() { return this; }
}
auto w = Wrapper([1,2,3,4]);
std.array.popFront(w); // should work
static assert(isInputRange!Wrapper);
static assert(isForwardRange!Wrapper);
static assert(isBidirectionalRange!Wrapper);
static assert(isRandomAccessRange!Wrapper);
}
private void copyBackwards(T)(T[] src, T[] dest)
{
import core.stdc.string : memmove;
assert(src.length == dest.length);
if (!__ctfe || hasElaborateCopyConstructor!T)
{
/* insertInPlace relies on dest being uninitialized, so no postblits allowed,
* as this is a MOVE that overwrites the destination, not a COPY.
* BUG: insertInPlace will not work with ctfe and postblits
*/
memmove(dest.ptr, src.ptr, src.length * T.sizeof);
}
else
{
immutable len = src.length;
for (size_t i = len; i-- > 0;)
{
dest[i] = src[i];
}
}
}
/++
Inserts `stuff` (which must be an input range or any number of
implicitly convertible items) in `array` at position `pos`.
Params:
array = The array that `stuff` will be inserted into.
pos = The position in `array` to insert the `stuff`.
stuff = An $(REF_ALTTEXT input range, isInputRange, std,range,primitives),
or any number of implicitly convertible items to insert into `array`.
+/
void insertInPlace(T, U...)(ref T[] array, size_t pos, U stuff)
if (!isSomeString!(T[])
&& allSatisfy!(isInputRangeOrConvertible!T, U) && U.length > 0)
{
static if (allSatisfy!(isInputRangeWithLengthOrConvertible!T, U))
{
import std.conv : emplaceRef;
immutable oldLen = array.length;
size_t to_insert = 0;
foreach (i, E; U)
{
static if (is(E : T)) //a single convertible value, not a range
to_insert += 1;
else
to_insert += stuff[i].length;
}
if (to_insert)
{
array.length += to_insert;
// Takes arguments array, pos, stuff
// Spread apart array[] at pos by moving elements
(() @trusted { copyBackwards(array[pos .. oldLen], array[pos+to_insert..$]); })();
// Initialize array[pos .. pos+to_insert] with stuff[]
auto j = 0;
foreach (i, E; U)
{
static if (is(E : T))
{
emplaceRef!T(array[pos + j++], stuff[i]);
}
else
{
foreach (v; stuff[i])
{
emplaceRef!T(array[pos + j++], v);
}
}
}
}
}
else
{
// stuff has some InputRanges in it that don't have length
// assume that stuff to be inserted is typically shorter
// then the array that can be arbitrary big
// TODO: needs a better implementation as there is no need to build an _array_
// a singly-linked list of memory blocks (rope, etc.) will do
auto app = appender!(T[])();
foreach (i, E; U)
app.put(stuff[i]);
insertInPlace(array, pos, app.data);
}
}
/// Ditto
void insertInPlace(T, U...)(ref T[] array, size_t pos, U stuff)
if (isSomeString!(T[]) && allSatisfy!(isCharOrStringOrDcharRange, U))
{
static if (is(Unqual!T == T)
&& allSatisfy!(isInputRangeWithLengthOrConvertible!dchar, U))
{
import std.utf : codeLength;
// mutable, can do in place
//helper function: re-encode dchar to Ts and store at *ptr
static T* putDChar(T* ptr, dchar ch)
{
static if (is(T == dchar))
{
*ptr++ = ch;
return ptr;
}
else
{
import std.utf : encode;
T[dchar.sizeof/T.sizeof] buf;
immutable len = encode(buf, ch);
final switch (len)
{
static if (T.sizeof == char.sizeof)
{
case 4:
ptr[3] = buf[3];
goto case;
case 3:
ptr[2] = buf[2];
goto case;
}
case 2:
ptr[1] = buf[1];
goto case;
case 1:
ptr[0] = buf[0];
}
ptr += len;
return ptr;
}
}
size_t to_insert = 0;
//count up the number of *codeunits* to insert
foreach (i, E; U)
to_insert += codeLength!T(stuff[i]);
array.length += to_insert;
@trusted static void moveToRight(T[] arr, size_t gap)
{
static assert(!hasElaborateCopyConstructor!T);
import core.stdc.string : memmove;
if (__ctfe)
{
for (size_t i = arr.length - gap; i; --i)
arr[gap + i - 1] = arr[i - 1];
}
else
memmove(arr.ptr + gap, arr.ptr, (arr.length - gap) * T.sizeof);
}
moveToRight(array[pos .. $], to_insert);
auto ptr = array.ptr + pos;
foreach (i, E; U)
{
static if (is(E : dchar))
{
ptr = putDChar(ptr, stuff[i]);
}
else
{
foreach (dchar ch; stuff[i])
ptr = putDChar(ptr, ch);
}
}
assert(ptr == array.ptr + pos + to_insert, "(ptr == array.ptr + pos + to_insert) is false");
}
else
{
// immutable/const, just construct a new array
auto app = appender!(T[])();
app.put(array[0 .. pos]);
foreach (i, E; U)
app.put(stuff[i]);
app.put(array[pos..$]);
array = app.data;
}
}
///
@safe pure unittest
{
int[] a = [ 1, 2, 3, 4 ];
a.insertInPlace(2, [ 1, 2 ]);
assert(a == [ 1, 2, 1, 2, 3, 4 ]);
a.insertInPlace(3, 10u, 11);
assert(a == [ 1, 2, 1, 10, 11, 2, 3, 4]);
}
//constraint helpers
private template isInputRangeWithLengthOrConvertible(E)
{
template isInputRangeWithLengthOrConvertible(R)
{
//hasLength not defined for char[], wchar[] and dchar[]
enum isInputRangeWithLengthOrConvertible =
(isInputRange!R && is(typeof(R.init.length))
&& is(ElementType!R : E)) || is(R : E);
}
}
//ditto
private template isCharOrStringOrDcharRange(T)
{
enum isCharOrStringOrDcharRange = isSomeString!T || isSomeChar!T ||
(isInputRange!T && is(ElementType!T : dchar));
}
//ditto
private template isInputRangeOrConvertible(E)
{
template isInputRangeOrConvertible(R)
{
enum isInputRangeOrConvertible =
(isInputRange!R && is(ElementType!R : E)) || is(R : E);
}
}
@system unittest
{
// @system due to insertInPlace
import core.exception;
import std.algorithm.comparison : equal;
import std.algorithm.iteration : filter;
import std.conv : to;
import std.exception;
bool test(T, U, V)(T orig, size_t pos, U toInsert, V result)
{
{
static if (is(T == typeof(T.init.dup)))
auto a = orig.dup;
else
auto a = orig.idup;
a.insertInPlace(pos, toInsert);
if (!equal(a, result))
return false;
}
static if (isInputRange!U)
{
orig.insertInPlace(pos, filter!"true"(toInsert));
return equal(orig, result);
}
else
return true;
}
assert(test([1, 2, 3, 4], 0, [6, 7], [6, 7, 1, 2, 3, 4]));
assert(test([1, 2, 3, 4], 2, [8, 9], [1, 2, 8, 9, 3, 4]));
assert(test([1, 2, 3, 4], 4, [10, 11], [1, 2, 3, 4, 10, 11]));
assert(test([1, 2, 3, 4], 0, 22, [22, 1, 2, 3, 4]));
assert(test([1, 2, 3, 4], 2, 23, [1, 2, 23, 3, 4]));
assert(test([1, 2, 3, 4], 4, 24, [1, 2, 3, 4, 24]));
void testStr(T, U)(string file = __FILE__, size_t line = __LINE__)
{
auto l = to!T("hello");
auto r = to!U(" વિશ્વ");
enforce(test(l, 0, r, " વિશ્વhello"),
new AssertError("testStr failure 1", file, line));
enforce(test(l, 3, r, "hel વિશ્વlo"),
new AssertError("testStr failure 2", file, line));
enforce(test(l, l.length, r, "hello વિશ્વ"),
new AssertError("testStr failure 3", file, line));
}
static foreach (T; AliasSeq!(char, wchar, dchar,
immutable(char), immutable(wchar), immutable(dchar)))
{
static foreach (U; AliasSeq!(char, wchar, dchar,
immutable(char), immutable(wchar), immutable(dchar)))
{
testStr!(T[], U[])();
}
}
// variadic version
bool testVar(T, U...)(T orig, size_t pos, U args)
{
static if (is(T == typeof(T.init.dup)))
auto a = orig.dup;
else
auto a = orig.idup;
auto result = args[$-1];
a.insertInPlace(pos, args[0..$-1]);
if (!equal(a, result))
return false;
return true;
}
assert(testVar([1, 2, 3, 4], 0, 6, 7u, [6, 7, 1, 2, 3, 4]));
assert(testVar([1L, 2, 3, 4], 2, 8, 9L, [1, 2, 8, 9, 3, 4]));
assert(testVar([1L, 2, 3, 4], 4, 10L, 11, [1, 2, 3, 4, 10, 11]));
assert(testVar([1L, 2, 3, 4], 4, [10, 11], 40L, 42L,
[1, 2, 3, 4, 10, 11, 40, 42]));
assert(testVar([1L, 2, 3, 4], 4, 10, 11, [40L, 42],
[1, 2, 3, 4, 10, 11, 40, 42]));
assert(testVar("t".idup, 1, 'e', 's', 't', "test"));
assert(testVar("!!"w.idup, 1, "\u00e9ll\u00f4", 'x', "TTT"w, 'y',
"!\u00e9ll\u00f4xTTTy!"));
assert(testVar("flipflop"d.idup, 4, '_',
"xyz"w, '\U00010143', '_', "abc"d, "__",
"flip_xyz\U00010143_abc__flop"));
}
@system unittest
{
import std.algorithm.comparison : equal;
// insertInPlace interop with postblit
static struct Int
{
int* payload;
this(int k)
{
payload = new int;
*payload = k;
}
this(this)
{
int* np = new int;
*np = *payload;
payload = np;
}
~this()
{
if (payload)
*payload = 0; //'destroy' it
}
@property int getPayload(){ return *payload; }
alias getPayload this;
}
Int[] arr = [Int(1), Int(4), Int(5)];
assert(arr[0] == 1);
insertInPlace(arr, 1, Int(2), Int(3));
assert(equal(arr, [1, 2, 3, 4, 5])); //check it works with postblit
}
@safe unittest
{
import std.exception;
assertCTFEable!(
{
int[] a = [1, 2];
a.insertInPlace(2, 3);
a.insertInPlace(0, -1, 0);
return a == [-1, 0, 1, 2, 3];
});
}
@system unittest // bugzilla 6874
{
import core.memory;
// allocate some space
byte[] a;
a.length = 1;
// fill it
a.length = a.capacity;
// write beyond
byte[] b = a[$ .. $];
b.insertInPlace(0, a);
// make sure that reallocation has happened
assert(GC.addrOf(&b[0]) == GC.addrOf(&b[$-1]));
}
/++
Returns whether the `front`s of `lhs` and `rhs` both refer to the
same place in memory, making one of the arrays a slice of the other which
starts at index `0`.
Params:
lhs = the first array to compare
rhs = the second array to compare
Returns:
`true` if $(D lhs.ptr == rhs.ptr), `false` otherwise.
+/
@safe
pure nothrow bool sameHead(T)(in T[] lhs, in T[] rhs)
{
return lhs.ptr == rhs.ptr;
}
///
@safe pure nothrow unittest
{
auto a = [1, 2, 3, 4, 5];
auto b = a[0 .. 2];
assert(a.sameHead(b));
}
/++
Returns whether the `back`s of `lhs` and `rhs` both refer to the
same place in memory, making one of the arrays a slice of the other which
end at index `$`.
Params:
lhs = the first array to compare
rhs = the second array to compare
Returns:
`true` if both arrays are the same length and $(D lhs.ptr == rhs.ptr),
`false` otherwise.
+/
@trusted
pure nothrow bool sameTail(T)(in T[] lhs, in T[] rhs)
{
return lhs.ptr + lhs.length == rhs.ptr + rhs.length;
}
///
@safe pure nothrow unittest
{
auto a = [1, 2, 3, 4, 5];
auto b = a[3..$];
assert(a.sameTail(b));
}
@safe pure nothrow unittest
{
static foreach (T; AliasSeq!(int[], const(int)[], immutable(int)[], const int[], immutable int[]))
{{
T a = [1, 2, 3, 4, 5];
T b = a;
T c = a[1 .. $];
T d = a[0 .. 1];
T e = null;
assert(sameHead(a, a));
assert(sameHead(a, b));
assert(!sameHead(a, c));
assert(sameHead(a, d));
assert(!sameHead(a, e));
assert(sameTail(a, a));
assert(sameTail(a, b));
assert(sameTail(a, c));
assert(!sameTail(a, d));
assert(!sameTail(a, e));
//verifies R-value compatibilty
assert(a.sameHead(a[0 .. 0]));
assert(a.sameTail(a[$ .. $]));
}}
}
/**
Params:
s = an $(REF_ALTTEXT input range, isInputRange, std,range,primitives)
or a dynamic array
n = number of times to repeat `s`
Returns:
An array that consists of `s` repeated `n` times. This function allocates, fills, and
returns a new array.
See_Also:
For a lazy version, refer to $(REF repeat, std,range).
*/
ElementEncodingType!S[] replicate(S)(S s, size_t n)
if (isDynamicArray!S)
{
alias RetType = ElementEncodingType!S[];
// Optimization for return join(std.range.repeat(s, n));
if (n == 0)
return RetType.init;
if (n == 1)
return cast(RetType) s;
auto r = new Unqual!(typeof(s[0]))[n * s.length];
if (s.length == 1)
r[] = s[0];
else
{
immutable len = s.length, nlen = n * len;
for (size_t i = 0; i < nlen; i += len)
{
r[i .. i + len] = s[];
}
}
return r;
}
/// ditto
ElementType!S[] replicate(S)(S s, size_t n)
if (isInputRange!S && !isDynamicArray!S)
{
import std.range : repeat;
return join(std.range.repeat(s, n));
}
///
@safe unittest
{
auto a = "abc";
auto s = replicate(a, 3);
assert(s == "abcabcabc");
auto b = [1, 2, 3];
auto c = replicate(b, 3);
assert(c == [1, 2, 3, 1, 2, 3, 1, 2, 3]);
auto d = replicate(b, 0);
assert(d == []);
}
@safe unittest
{
import std.conv : to;
static foreach (S; AliasSeq!(string, wstring, dstring, char[], wchar[], dchar[]))
{{
immutable S t = "abc";
assert(replicate(to!S("1234"), 0) is null);
assert(replicate(to!S("1234"), 0) is null);
assert(replicate(to!S("1234"), 1) == "1234");
assert(replicate(to!S("1234"), 2) == "12341234");
assert(replicate(to!S("1"), 4) == "1111");
assert(replicate(t, 3) == "abcabcabc");
assert(replicate(cast(S) null, 4) is null);
}}
}
/++
Eagerly splits `range` into an array, using `sep` as the delimiter.
When no delimiter is provided, strings are split into an array of words,
using whitespace as delimiter.
Runs of whitespace are merged together (no empty words are produced).
The `range` must be a $(REF_ALTTEXT forward range, isForwardRange, std,range,primitives).
The separator can be a value of the same type as the elements in `range`
or it can be another forward `range`.
Params:
s = the string to split by word if no separator is given
range = the range to split
sep = a value of the same type as the elements of `range` or another
isTerminator = a predicate that splits the range when it returns `true`.
Returns:
An array containing the divided parts of `range` (or the words of `s`).
See_Also:
$(REF splitter, std,algorithm,iteration) for a lazy version without allocating memory.
$(REF splitter, std,regex) for a version that splits using a regular
expression defined separator.
+/
S[] split(S)(S s) @safe pure
if (isSomeString!S)
{
size_t istart;
bool inword = false;
auto result = appender!(S[]);
foreach (i, dchar c ; s)
{
import std.uni : isWhite;
if (isWhite(c))
{
if (inword)
{
put(result, s[istart .. i]);
inword = false;
}
}
else
{
if (!inword)
{
istart = i;
inword = true;
}
}
}
if (inword)
put(result, s[istart .. $]);
return result.data;
}
///
@safe unittest
{
import std.uni : isWhite;
assert("Learning,D,is,fun".split(",") == ["Learning", "D", "is", "fun"]);
assert("Learning D is fun".split!isWhite == ["Learning", "D", "is", "fun"]);
assert("Learning D is fun".split(" D ") == ["Learning", "is fun"]);
}
///
@safe unittest
{
string str = "Hello World!";
assert(str.split == ["Hello", "World!"]);
string str2 = "Hello\t\tWorld\t!";
assert(str2.split == ["Hello", "World", "!"]);
}
@safe unittest
{
import std.conv : to;
import std.format;
import std.typecons;
static auto makeEntry(S)(string l, string[] r)
{return tuple(l.to!S(), r.to!(S[])());}
static foreach (S; AliasSeq!(string, wstring, dstring,))
{{
auto entries =
[
makeEntry!S("", []),
makeEntry!S(" ", []),
makeEntry!S("hello", ["hello"]),
makeEntry!S(" hello ", ["hello"]),
makeEntry!S(" h e l l o ", ["h", "e", "l", "l", "o"]),
makeEntry!S("peter\t\npaul\rjerry", ["peter", "paul", "jerry"]),
makeEntry!S(" \t\npeter paul\tjerry \n", ["peter", "paul", "jerry"]),
makeEntry!S("\u2000日\u202F本\u205F語\u3000", ["日", "本", "語"]),
makeEntry!S(" 哈・郎博尔德} ___一个", ["哈・郎博尔德}", "___一个"])
];
foreach (entry; entries)
assert(entry[0].split() == entry[1], format("got: %s, expected: %s.", entry[0].split(), entry[1]));
}}
//Just to test that an immutable is split-able
immutable string s = " \t\npeter paul\tjerry \n";
assert(split(s) == ["peter", "paul", "jerry"]);
}
@safe unittest //purity, ctfe ...
{
import std.exception;
void dg() @safe pure {
assert(split("hello world"c) == ["hello"c, "world"c]);
assert(split("hello world"w) == ["hello"w, "world"w]);
assert(split("hello world"d) == ["hello"d, "world"d]);
}
dg();
assertCTFEable!dg;
}
///
@safe unittest
{
assert(split("hello world") == ["hello","world"]);
assert(split("192.168.0.1", ".") == ["192", "168", "0", "1"]);
auto a = split([1, 2, 3, 4, 5, 1, 2, 3, 4, 5], [2, 3]);
assert(a == [[1], [4, 5, 1], [4, 5]]);
}
///ditto
auto split(Range, Separator)(Range range, Separator sep)
if (isForwardRange!Range && (
is(typeof(ElementType!Range.init == Separator.init)) ||
is(typeof(ElementType!Range.init == ElementType!Separator.init)) && isForwardRange!Separator
))
{
import std.algorithm.iteration : splitter;
return range.splitter(sep).array;
}
///ditto
auto split(alias isTerminator, Range)(Range range)
if (isForwardRange!Range && is(typeof(unaryFun!isTerminator(range.front))))
{
import std.algorithm.iteration : splitter;
return range.splitter!isTerminator.array;
}
@safe unittest
{
import std.algorithm.comparison : cmp;
import std.conv;
static foreach (S; AliasSeq!(string, wstring, dstring,
immutable(string), immutable(wstring), immutable(dstring),
char[], wchar[], dchar[],
const(char)[], const(wchar)[], const(dchar)[],
const(char[]), immutable(char[])))
{{
S s = to!S(",peter,paul,jerry,");
auto words = split(s, ",");
assert(words.length == 5, text(words.length));
assert(cmp(words[0], "") == 0);
assert(cmp(words[1], "peter") == 0);
assert(cmp(words[2], "paul") == 0);
assert(cmp(words[3], "jerry") == 0);
assert(cmp(words[4], "") == 0);
auto s1 = s[0 .. s.length - 1]; // lop off trailing ','
words = split(s1, ",");
assert(words.length == 4);
assert(cmp(words[3], "jerry") == 0);
auto s2 = s1[1 .. s1.length]; // lop off leading ','
words = split(s2, ",");
assert(words.length == 3);
assert(cmp(words[0], "peter") == 0);
auto s3 = to!S(",,peter,,paul,,jerry,,");
words = split(s3, ",,");
assert(words.length == 5);
assert(cmp(words[0], "") == 0);
assert(cmp(words[1], "peter") == 0);
assert(cmp(words[2], "paul") == 0);
assert(cmp(words[3], "jerry") == 0);
assert(cmp(words[4], "") == 0);
auto s4 = s3[0 .. s3.length - 2]; // lop off trailing ',,'
words = split(s4, ",,");
assert(words.length == 4);
assert(cmp(words[3], "jerry") == 0);
auto s5 = s4[2 .. s4.length]; // lop off leading ',,'
words = split(s5, ",,");
assert(words.length == 3);
assert(cmp(words[0], "peter") == 0);
}}
}
/+
Conservative heuristic to determine if a range can be iterated cheaply.
Used by `join` in decision to do an extra iteration of the range to
compute the resultant length. If iteration is not cheap then precomputing
length could be more expensive than using `Appender`.
For now, we only assume arrays are cheap to iterate.
+/
private enum bool hasCheapIteration(R) = isArray!R;
/++
Eagerly concatenates all of the ranges in `ror` together (with the GC)
into one array using `sep` as the separator if present.
Params:
ror = An $(REF_ALTTEXT input range, isInputRange, std,range,primitives)
of input ranges
sep = An input range, or a single element, to join the ranges on
Returns:
An array of elements
See_Also:
For a lazy version, see $(REF joiner, std,algorithm,iteration)
+/
ElementEncodingType!(ElementType!RoR)[] join(RoR, R)(RoR ror, scope R sep)
if (isInputRange!RoR &&
isInputRange!(Unqual!(ElementType!RoR)) &&
isInputRange!R &&
is(Unqual!(ElementType!(ElementType!RoR)) == Unqual!(ElementType!R)))
{
alias RetType = typeof(return);
alias RetTypeElement = Unqual!(ElementEncodingType!RetType);
alias RoRElem = ElementType!RoR;
if (ror.empty)
return RetType.init;
// Constraint only requires input range for sep.
// This converts sep to an array (forward range) if it isn't one,
// and makes sure it has the same string encoding for string types.
static if (isSomeString!RetType &&
!is(RetTypeElement == Unqual!(ElementEncodingType!R)))
{
import std.conv : to;
auto sepArr = to!RetType(sep);
}
else static if (!isArray!R)
auto sepArr = array(sep);
else
alias sepArr = sep;
static if (hasCheapIteration!RoR && (hasLength!RoRElem || isNarrowString!RoRElem))
{
import std.conv : emplaceRef;
size_t length; // length of result array
size_t rorLength; // length of range ror
foreach (r; ror.save)
{
length += r.length;
++rorLength;
}
if (!rorLength)
return null;
length += (rorLength - 1) * sepArr.length;
auto result = (() @trusted => uninitializedArray!(RetTypeElement[])(length))();
size_t len;
foreach (e; ror.front)
emplaceRef(result[len++], e);
ror.popFront();
foreach (r; ror)
{
foreach (e; sepArr)
emplaceRef(result[len++], e);
foreach (e; r)
emplaceRef(result[len++], e);
}
assert(len == result.length);
return (() @trusted => cast(RetType) result)();
}
else
{
auto result = appender!RetType();
put(result, ror.front);
ror.popFront();
for (; !ror.empty; ror.popFront())
{
put(result, sep);
put(result, ror.front);
}
return result.data;
}
}
@safe unittest // Issue 14230
{
string[] ary = ["","aa","bb","cc"]; // leaded by _empty_ element
assert(ary.join(" @") == " @aa @bb @cc"); // OK in 2.067b1 and olders
}
/// Ditto
ElementEncodingType!(ElementType!RoR)[] join(RoR, E)(RoR ror, scope E sep)
if (isInputRange!RoR &&
isInputRange!(Unqual!(ElementType!RoR)) &&
is(E : ElementType!(ElementType!RoR)))
{
alias RetType = typeof(return);
alias RetTypeElement = Unqual!(ElementEncodingType!RetType);
alias RoRElem = ElementType!RoR;
if (ror.empty)
return RetType.init;
static if (hasCheapIteration!RoR && (hasLength!RoRElem || isNarrowString!RoRElem))
{
static if (isSomeChar!E && isSomeChar!RetTypeElement && E.sizeof > RetTypeElement.sizeof)
{
import std.utf : encode;
RetTypeElement[4 / RetTypeElement.sizeof] encodeSpace;
immutable size_t sepArrLength = encode(encodeSpace, sep);
return join(ror, encodeSpace[0 .. sepArrLength]);
}
else
{
import std.conv : emplaceRef;
size_t length;
size_t rorLength;
foreach (r; ror.save)
{
length += r.length;
++rorLength;
}
if (!rorLength)
return null;
length += rorLength - 1;
auto result = uninitializedArray!(RetTypeElement[])(length);
size_t len;
foreach (e; ror.front)
emplaceRef(result[len++], e);
ror.popFront();
foreach (r; ror)
{
emplaceRef(result[len++], sep);
foreach (e; r)
emplaceRef(result[len++], e);
}
assert(len == result.length);
return (() @trusted => cast(RetType) result)();
}
}
else
{
auto result = appender!RetType();
put(result, ror.front);
ror.popFront();
for (; !ror.empty; ror.popFront())
{
put(result, sep);
put(result, ror.front);
}
return result.data;
}
}
@safe unittest // Issue 10895
{
class A
{
string name;
alias name this;
this(string name) { this.name = name; }
}
auto a = [new A(`foo`)];
assert(a[0].length == 3);
auto temp = join(a, " ");
assert(a[0].length == 3);
assert(temp.length == 3);
}
@safe unittest // Issue 14230
{
string[] ary = ["","aa","bb","cc"];
assert(ary.join('@') == "@aa@bb@cc");
}
/// Ditto
ElementEncodingType!(ElementType!RoR)[] join(RoR)(RoR ror)
if (isInputRange!RoR &&
isInputRange!(Unqual!(ElementType!RoR)))
{
alias RetType = typeof(return);
alias RetTypeElement = Unqual!(ElementEncodingType!RetType);
alias RoRElem = ElementType!RoR;
if (ror.empty)
return RetType.init;
static if (hasCheapIteration!RoR && (hasLength!RoRElem || isNarrowString!RoRElem))
{
import std.conv : emplaceRef;
size_t length;
foreach (r; ror.save)
length += r.length;
auto result = (() @trusted => uninitializedArray!(RetTypeElement[])(length))();
size_t len;
foreach (r; ror)
foreach (e; r)
emplaceRef(result[len++], e);
assert(len == result.length);
return (() @trusted => cast(RetType) result)();
}
else
{
auto result = appender!RetType();
for (; !ror.empty; ror.popFront())
put(result, ror.front);
return result.data;
}
}
///
@safe pure nothrow unittest
{
assert(join(["hello", "silly", "world"], " ") == "hello silly world");
assert(join(["hello", "silly", "world"]) == "hellosillyworld");
assert(join([[1, 2, 3], [4, 5]], [72, 73]) == [1, 2, 3, 72, 73, 4, 5]);
assert(join([[1, 2, 3], [4, 5]]) == [1, 2, 3, 4, 5]);
const string[] arr = ["apple", "banana"];
assert(arr.join(",") == "apple,banana");
assert(arr.join() == "applebanana");
}
@safe pure unittest
{
import std.conv : to;
static foreach (T; AliasSeq!(string,wstring,dstring))
{{
auto arr2 = "Здравствуй Мир Unicode".to!(T);
auto arr = ["Здравствуй", "Мир", "Unicode"].to!(T[]);
assert(join(arr) == "ЗдравствуйМирUnicode");
static foreach (S; AliasSeq!(char,wchar,dchar))
{{
auto jarr = arr.join(to!S(' '));
static assert(is(typeof(jarr) == T));
assert(jarr == arr2);
}}
static foreach (S; AliasSeq!(string,wstring,dstring))
{{
auto jarr = arr.join(to!S(" "));
static assert(is(typeof(jarr) == T));
assert(jarr == arr2);
}}
}}
static foreach (T; AliasSeq!(string,wstring,dstring))
{{
auto arr2 = "Здравствуй\u047CМир\u047CUnicode".to!(T);
auto arr = ["Здравствуй", "Мир", "Unicode"].to!(T[]);
static foreach (S; AliasSeq!(wchar,dchar))
{{
auto jarr = arr.join(to!S('\u047C'));
static assert(is(typeof(jarr) == T));
assert(jarr == arr2);
}}
}}
const string[] arr = ["apple", "banana"];
assert(arr.join(',') == "apple,banana");
}
@safe unittest
{
import std.algorithm;
import std.conv : to;
import std.range;
static foreach (R; AliasSeq!(string, wstring, dstring))
{{
R word1 = "日本語";
R word2 = "paul";
R word3 = "jerry";
R[] words = [word1, word2, word3];
auto filteredWord1 = filter!"true"(word1);
auto filteredLenWord1 = takeExactly(filteredWord1, word1.walkLength());
auto filteredWord2 = filter!"true"(word2);
auto filteredLenWord2 = takeExactly(filteredWord2, word2.walkLength());
auto filteredWord3 = filter!"true"(word3);
auto filteredLenWord3 = takeExactly(filteredWord3, word3.walkLength());
auto filteredWordsArr = [filteredWord1, filteredWord2, filteredWord3];
auto filteredLenWordsArr = [filteredLenWord1, filteredLenWord2, filteredLenWord3];
auto filteredWords = filter!"true"(filteredWordsArr);
static foreach (S; AliasSeq!(string, wstring, dstring))
{{
assert(join(filteredWords, to!S(", ")) == "日本語, paul, jerry");
assert(join(filteredWords, to!(ElementType!S)(',')) == "日本語,paul,jerry");
assert(join(filteredWordsArr, to!(ElementType!(S))(',')) == "日本語,paul,jerry");
assert(join(filteredWordsArr, to!S(", ")) == "日本語, paul, jerry");
assert(join(filteredWordsArr, to!(ElementType!(S))(',')) == "日本語,paul,jerry");
assert(join(filteredLenWordsArr, to!S(", ")) == "日本語, paul, jerry");
assert(join(filter!"true"(words), to!S(", ")) == "日本語, paul, jerry");
assert(join(words, to!S(", ")) == "日本語, paul, jerry");
assert(join(filteredWords, to!S("")) == "日本語pauljerry");
assert(join(filteredWordsArr, to!S("")) == "日本語pauljerry");
assert(join(filteredLenWordsArr, to!S("")) == "日本語pauljerry");
assert(join(filter!"true"(words), to!S("")) == "日本語pauljerry");
assert(join(words, to!S("")) == "日本語pauljerry");
assert(join(filter!"true"([word1]), to!S(", ")) == "日本語");
assert(join([filteredWord1], to!S(", ")) == "日本語");
assert(join([filteredLenWord1], to!S(", ")) == "日本語");
assert(join(filter!"true"([filteredWord1]), to!S(", ")) == "日本語");
assert(join([word1], to!S(", ")) == "日本語");
assert(join(filteredWords, to!S(word1)) == "日本語日本語paul日本語jerry");
assert(join(filteredWordsArr, to!S(word1)) == "日本語日本語paul日本語jerry");
assert(join(filteredLenWordsArr, to!S(word1)) == "日本語日本語paul日本語jerry");
assert(join(filter!"true"(words), to!S(word1)) == "日本語日本語paul日本語jerry");
assert(join(words, to!S(word1)) == "日本語日本語paul日本語jerry");
auto filterComma = filter!"true"(to!S(", "));
assert(join(filteredWords, filterComma) == "日本語, paul, jerry");
assert(join(filteredWordsArr, filterComma) == "日本語, paul, jerry");
assert(join(filteredLenWordsArr, filterComma) == "日本語, paul, jerry");
assert(join(filter!"true"(words), filterComma) == "日本語, paul, jerry");
assert(join(words, filterComma) == "日本語, paul, jerry");
}}
assert(join(filteredWords) == "日本語pauljerry");
assert(join(filteredWordsArr) == "日本語pauljerry");
assert(join(filteredLenWordsArr) == "日本語pauljerry");
assert(join(filter!"true"(words)) == "日本語pauljerry");
assert(join(words) == "日本語pauljerry");
assert(join(filteredWords, filter!"true"(", ")) == "日本語, paul, jerry");
assert(join(filteredWordsArr, filter!"true"(", ")) == "日本語, paul, jerry");
assert(join(filteredLenWordsArr, filter!"true"(", ")) == "日本語, paul, jerry");
assert(join(filter!"true"(words), filter!"true"(", ")) == "日本語, paul, jerry");
assert(join(words, filter!"true"(", ")) == "日本語, paul, jerry");
assert(join(filter!"true"(cast(typeof(filteredWordsArr))[]), ", ").empty);
assert(join(cast(typeof(filteredWordsArr))[], ", ").empty);
assert(join(cast(typeof(filteredLenWordsArr))[], ", ").empty);
assert(join(filter!"true"(cast(R[])[]), ", ").empty);
assert(join(cast(R[])[], ", ").empty);
assert(join(filter!"true"(cast(typeof(filteredWordsArr))[])).empty);
assert(join(cast(typeof(filteredWordsArr))[]).empty);
assert(join(cast(typeof(filteredLenWordsArr))[]).empty);
assert(join(filter!"true"(cast(R[])[])).empty);
assert(join(cast(R[])[]).empty);
}}
assert(join([[1, 2], [41, 42]], [5, 6]) == [1, 2, 5, 6, 41, 42]);
assert(join([[1, 2], [41, 42]], cast(int[])[]) == [1, 2, 41, 42]);
assert(join([[1, 2]], [5, 6]) == [1, 2]);
assert(join(cast(int[][])[], [5, 6]).empty);
assert(join([[1, 2], [41, 42]]) == [1, 2, 41, 42]);
assert(join(cast(int[][])[]).empty);
alias f = filter!"true";
assert(join([[1, 2], [41, 42]], [5, 6]) == [1, 2, 5, 6, 41, 42]);
assert(join(f([[1, 2], [41, 42]]), [5, 6]) == [1, 2, 5, 6, 41, 42]);
assert(join([f([1, 2]), f([41, 42])], [5, 6]) == [1, 2, 5, 6, 41, 42]);
assert(join(f([f([1, 2]), f([41, 42])]), [5, 6]) == [1, 2, 5, 6, 41, 42]);
assert(join([[1, 2], [41, 42]], f([5, 6])) == [1, 2, 5, 6, 41, 42]);
assert(join(f([[1, 2], [41, 42]]), f([5, 6])) == [1, 2, 5, 6, 41, 42]);
assert(join([f([1, 2]), f([41, 42])], f([5, 6])) == [1, 2, 5, 6, 41, 42]);
assert(join(f([f([1, 2]), f([41, 42])]), f([5, 6])) == [1, 2, 5, 6, 41, 42]);
}
// Issue 10683
@safe unittest
{
import std.range : join;
import std.typecons : tuple;
assert([[tuple(1)]].join == [tuple(1)]);
assert([[tuple("x")]].join == [tuple("x")]);
}
// Issue 13877
@safe unittest
{
// Test that the range is iterated only once.
import std.algorithm.iteration : map;
int c = 0;
auto j1 = [1, 2, 3].map!(_ => [c++]).join;
assert(c == 3);
assert(j1 == [0, 1, 2]);
c = 0;
auto j2 = [1, 2, 3].map!(_ => [c++]).join(9);
assert(c == 3);
assert(j2 == [0, 9, 1, 9, 2]);
c = 0;
auto j3 = [1, 2, 3].map!(_ => [c++]).join([9]);
assert(c == 3);
assert(j3 == [0, 9, 1, 9, 2]);
}
/++
Replace occurrences of `from` with `to` in `subject` in a new array.
Params:
subject = the array to scan
from = the item to replace
to = the item to replace all instances of `from` with
Returns:
A new array without changing the contents of `subject`, or the original
array if no match is found.
See_Also:
$(REF substitute, std,algorithm,iteration) for a lazy replace.
+/
E[] replace(E, R1, R2)(E[] subject, R1 from, R2 to)
if (isDynamicArray!(E[]) && isForwardRange!R1 && isForwardRange!R2
&& (hasLength!R2 || isSomeString!R2))
{
import std.algorithm.searching : find;
import std.range : dropOne;
if (from.empty) return subject;
auto balance = find(subject, from.save);
if (balance.empty)
return subject;
auto app = appender!(E[])();
app.put(subject[0 .. subject.length - balance.length]);
app.put(to.save);
// replacing an element in an array is different to a range replacement
static if (is(Unqual!E : Unqual!R1))
replaceInto(app, balance.dropOne, from, to);
else
replaceInto(app, balance[from.length .. $], from, to);
return app.data;
}
///
@safe unittest
{
assert("Hello Wörld".replace("o Wö", "o Wo") == "Hello World");
assert("Hello Wörld".replace("l", "h") == "Hehho Wörhd");
}
@safe unittest
{
assert([1, 2, 3, 4, 2].replace([2], [5]) == [1, 5, 3, 4, 5]);
assert([3, 3, 3].replace([3], [0]) == [0, 0, 0]);
assert([3, 3, 4, 3].replace([3, 3], [1, 1, 1]) == [1, 1, 1, 4, 3]);
}
// https://issues.dlang.org/show_bug.cgi?id=18215
@safe unittest
{
auto arr = ["aaa.dd", "b"];
arr = arr.replace("aaa.dd", ".");
assert(arr == [".", "b"]);
arr = ["_", "_", "aaa.dd", "b", "c", "aaa.dd", "e"];
arr = arr.replace("aaa.dd", ".");
assert(arr == ["_", "_", ".", "b", "c", ".", "e"]);
}
// https://issues.dlang.org/show_bug.cgi?id=18215
@safe unittest
{
assert([[0], [1, 2], [0], [3]].replace([0], [4]) == [[4], [1, 2], [4], [3]]);
assert([[0], [1, 2], [0], [3], [1, 2]]
.replace([1, 2], [0]) == [[0], [0], [0], [3], [0]]);
assert([[0], [1, 2], [0], [3], [1, 2], [0], [1, 2]]
.replace([[0], [1, 2]], [[4]]) == [[4], [0], [3], [1, 2], [4]]);
}
/++
Replace occurrences of `from` with `to` in `subject` and output the result into
`sink`.
Params:
sink = an $(REF_ALTTEXT output range, isOutputRange, std,range,primitives)
subject = the array to scan
from = the item to replace
to = the item to replace all instances of `from` with
See_Also:
$(REF substitute, std,algorithm,iteration) for a lazy replace.
+/
void replaceInto(E, Sink, R1, R2)(Sink sink, E[] subject, R1 from, R2 to)
if (isOutputRange!(Sink, E) && isDynamicArray!(E[])
&& isForwardRange!R1 && isForwardRange!R2
&& (hasLength!R2 || isSomeString!R2))
{
import std.algorithm.searching : find;
import std.range : dropOne;
if (from.empty)
{
sink.put(subject);
return;
}
for (;;)
{
auto balance = find(subject, from.save);
if (balance.empty)
{
sink.put(subject);
break;
}
sink.put(subject[0 .. subject.length - balance.length]);
sink.put(to.save);
// replacing an element in an array is different to a range replacement
static if (is(Unqual!E : Unqual!R1))
subject = balance.dropOne;
else
subject = balance[from.length .. $];
}
}
///
@safe unittest
{
auto arr = [1, 2, 3, 4, 5];
auto from = [2, 3];
auto to = [4, 6];
auto sink = appender!(int[])();
replaceInto(sink, arr, from, to);
assert(sink.data == [1, 4, 6, 4, 5]);
}
@safe unittest
{
import std.algorithm.comparison : cmp;
import std.conv : to;
static foreach (S; AliasSeq!(string, wstring, dstring, char[], wchar[], dchar[]))
{
static foreach (T; AliasSeq!(string, wstring, dstring, char[], wchar[], dchar[]))
{{
auto s = to!S("This is a foo foo list");
auto from = to!T("foo");
auto into = to!S("silly");
S r;
int i;
r = replace(s, from, into);
i = cmp(r, "This is a silly silly list");
assert(i == 0);
r = replace(s, to!S(""), into);
i = cmp(r, "This is a foo foo list");
assert(i == 0);
assert(replace(r, to!S("won't find this"), to!S("whatever")) is r);
}}
}
immutable s = "This is a foo foo list";
assert(replace(s, "foo", "silly") == "This is a silly silly list");
}
@safe unittest
{
import std.algorithm.searching : skipOver;
import std.conv : to;
struct CheckOutput(C)
{
C[] desired;
this(C[] arr){ desired = arr; }
void put(C[] part){ assert(skipOver(desired, part)); }
}
static foreach (S; AliasSeq!(string, wstring, dstring, char[], wchar[], dchar[]))
{{
alias Char = ElementEncodingType!S;
S s = to!S("yet another dummy text, yet another ...");
S from = to!S("yet another");
S into = to!S("some");
replaceInto(CheckOutput!(Char)(to!S("some dummy text, some ..."))
, s, from, into);
}}
}
/++
Replaces elements from `array` with indices ranging from `from`
(inclusive) to `to` (exclusive) with the range `stuff`.
Params:
subject = the array to scan
from = the starting index
to = the ending index
stuff = the items to replace in-between `from` and `to`
Returns:
A new array without changing the contents of `subject`.
See_Also:
$(REF substitute, std,algorithm,iteration) for a lazy replace.
+/
T[] replace(T, Range)(T[] subject, size_t from, size_t to, Range stuff)
if (isInputRange!Range &&
(is(ElementType!Range : T) ||
isSomeString!(T[]) && is(ElementType!Range : dchar)))
{
static if (hasLength!Range && is(ElementEncodingType!Range : T))
{
import std.algorithm.mutation : copy;
assert(from <= to);
immutable sliceLen = to - from;
auto retval = new Unqual!(T)[](subject.length - sliceLen + stuff.length);
retval[0 .. from] = subject[0 .. from];
if (!stuff.empty)
copy(stuff, retval[from .. from + stuff.length]);
retval[from + stuff.length .. $] = subject[to .. $];
static if (is(T == const) || is(T == immutable))
{
return () @trusted { return cast(T[]) retval; } ();
}
else
{
return cast(T[]) retval;
}
}
else
{
auto app = appender!(T[])();
app.put(subject[0 .. from]);
app.put(stuff);
app.put(subject[to .. $]);
return app.data;
}
}
///
@safe unittest
{
auto a = [ 1, 2, 3, 4 ];
auto b = a.replace(1, 3, [ 9, 9, 9 ]);
assert(a == [ 1, 2, 3, 4 ]);
assert(b == [ 1, 9, 9, 9, 4 ]);
}
@system unittest
{
import core.exception;
import std.algorithm.iteration : filter;
import std.conv : to;
import std.exception;
auto a = [ 1, 2, 3, 4 ];
assert(replace(a, 0, 0, [5, 6, 7]) == [5, 6, 7, 1, 2, 3, 4]);
assert(replace(a, 0, 2, cast(int[])[]) == [3, 4]);
assert(replace(a, 0, 4, [5, 6, 7]) == [5, 6, 7]);
assert(replace(a, 0, 2, [5, 6, 7]) == [5, 6, 7, 3, 4]);
assert(replace(a, 2, 4, [5, 6, 7]) == [1, 2, 5, 6, 7]);
assert(replace(a, 0, 0, filter!"true"([5, 6, 7])) == [5, 6, 7, 1, 2, 3, 4]);
assert(replace(a, 0, 2, filter!"true"(cast(int[])[])) == [3, 4]);
assert(replace(a, 0, 4, filter!"true"([5, 6, 7])) == [5, 6, 7]);
assert(replace(a, 0, 2, filter!"true"([5, 6, 7])) == [5, 6, 7, 3, 4]);
assert(replace(a, 2, 4, filter!"true"([5, 6, 7])) == [1, 2, 5, 6, 7]);
assert(a == [ 1, 2, 3, 4 ]);
void testStr(T, U)(string file = __FILE__, size_t line = __LINE__)
{
auto l = to!T("hello");
auto r = to!U(" world");
enforce(replace(l, 0, 0, r) == " worldhello",
new AssertError("testStr failure 1", file, line));
enforce(replace(l, 0, 3, r) == " worldlo",
new AssertError("testStr failure 2", file, line));
enforce(replace(l, 3, l.length, r) == "hel world",
new AssertError("testStr failure 3", file, line));
enforce(replace(l, 0, l.length, r) == " world",
new AssertError("testStr failure 4", file, line));
enforce(replace(l, l.length, l.length, r) == "hello world",
new AssertError("testStr failure 5", file, line));
}
testStr!(string, string)();
testStr!(string, wstring)();
testStr!(string, dstring)();
testStr!(wstring, string)();
testStr!(wstring, wstring)();
testStr!(wstring, dstring)();
testStr!(dstring, string)();
testStr!(dstring, wstring)();
testStr!(dstring, dstring)();
enum s = "0123456789";
enum w = "⁰¹²³⁴⁵⁶⁷⁸⁹"w;
enum d = "⁰¹²³⁴⁵⁶⁷⁸⁹"d;
assert(replace(s, 0, 0, "***") == "***0123456789");
assert(replace(s, 10, 10, "***") == "0123456789***");
assert(replace(s, 3, 8, "1012") == "012101289");
assert(replace(s, 0, 5, "43210") == "4321056789");
assert(replace(s, 5, 10, "43210") == "0123443210");
assert(replace(w, 0, 0, "***"w) == "***⁰¹²³⁴⁵⁶⁷⁸⁹"w);
assert(replace(w, 10, 10, "***"w) == "⁰¹²³⁴⁵⁶⁷⁸⁹***"w);
assert(replace(w, 3, 8, "¹⁰¹²"w) == "⁰¹²¹⁰¹²⁸⁹"w);
assert(replace(w, 0, 5, "⁴³²¹⁰"w) == "⁴³²¹⁰⁵⁶⁷⁸⁹"w);
assert(replace(w, 5, 10, "⁴³²¹⁰"w) == "⁰¹²³⁴⁴³²¹⁰"w);
assert(replace(d, 0, 0, "***"d) == "***⁰¹²³⁴⁵⁶⁷⁸⁹"d);
assert(replace(d, 10, 10, "***"d) == "⁰¹²³⁴⁵⁶⁷⁸⁹***"d);
assert(replace(d, 3, 8, "¹⁰¹²"d) == "⁰¹²¹⁰¹²⁸⁹"d);
assert(replace(d, 0, 5, "⁴³²¹⁰"d) == "⁴³²¹⁰⁵⁶⁷⁸⁹"d);
assert(replace(d, 5, 10, "⁴³²¹⁰"d) == "⁰¹²³⁴⁴³²¹⁰"d);
}
// Issue 18166
@safe pure unittest
{
auto str = replace("aaaaa"d, 1, 4, "***"d);
assert(str == "a***a");
}
/++
Replaces elements from `array` with indices ranging from `from`
(inclusive) to `to` (exclusive) with the range `stuff`. Expands or
shrinks the array as needed.
Params:
array = the _array to scan
from = the starting index
to = the ending index
stuff = the items to replace in-between `from` and `to`
+/
void replaceInPlace(T, Range)(ref T[] array, size_t from, size_t to, Range stuff)
if (is(typeof(replace(array, from, to, stuff))))
{
static if (isDynamicArray!Range &&
is(Unqual!(ElementEncodingType!Range) == T) &&
!isNarrowString!(T[]))
{
// optimized for homogeneous arrays that can be overwritten.
import std.algorithm.mutation : remove;
import std.typecons : tuple;
if (overlap(array, stuff).length)
{
// use slower/conservative method
array = array[0 .. from] ~ stuff ~ array[to .. $];
}
else if (stuff.length <= to - from)
{
// replacement reduces length
immutable stuffEnd = from + stuff.length;
array[from .. stuffEnd] = stuff[];
if (stuffEnd < to)
array = remove(array, tuple(stuffEnd, to));
}
else
{
// replacement increases length
// @@@TODO@@@: optimize this
immutable replaceLen = to - from;
array[from .. to] = stuff[0 .. replaceLen];
insertInPlace(array, to, stuff[replaceLen .. $]);
}
}
else
{
// default implementation, just do what replace does.
array = replace(array, from, to, stuff);
}
}
///
@safe unittest
{
int[] a = [1, 4, 5];
replaceInPlace(a, 1u, 2u, [2, 3, 4]);
assert(a == [1, 2, 3, 4, 5]);
replaceInPlace(a, 1u, 2u, cast(int[])[]);
assert(a == [1, 3, 4, 5]);
replaceInPlace(a, 1u, 3u, a[2 .. 4]);
assert(a == [1, 4, 5, 5]);
}
@safe unittest
{
// Bug# 12889
int[1][] arr = [[0], [1], [2], [3], [4], [5], [6]];
int[1][] stuff = [[0], [1]];
replaceInPlace(arr, 4, 6, stuff);
assert(arr == [[0], [1], [2], [3], [0], [1], [6]]);
}
@system unittest
{
// Bug# 14925
char[] a = "mon texte 1".dup;
char[] b = "abc".dup;
replaceInPlace(a, 4, 9, b);
assert(a == "mon abc 1");
// ensure we can replace in place with different encodings
string unicoded = "\U00010437";
string unicodedLong = "\U00010437aaaaa";
string base = "abcXXXxyz";
string result = "abc\U00010437xyz";
string resultLong = "abc\U00010437aaaaaxyz";
size_t repstart = 3;
size_t repend = 3 + 3;
void testStringReplaceInPlace(T, U)()
{
import std.algorithm.comparison : equal;
import std.conv;
auto a = unicoded.to!(U[]);
auto b = unicodedLong.to!(U[]);
auto test = base.to!(T[]);
test.replaceInPlace(repstart, repend, a);
assert(equal(test, result), "Failed for types " ~ T.stringof ~ " and " ~ U.stringof);
test = base.to!(T[]);
test.replaceInPlace(repstart, repend, b);
assert(equal(test, resultLong), "Failed for types " ~ T.stringof ~ " and " ~ U.stringof);
}
import std.meta : AliasSeq;
alias allChars = AliasSeq!(char, immutable(char), const(char),
wchar, immutable(wchar), const(wchar),
dchar, immutable(dchar), const(dchar));
foreach (T; allChars)
foreach (U; allChars)
testStringReplaceInPlace!(T, U)();
void testInout(inout(int)[] a)
{
// will be transferred to the 'replace' function
replaceInPlace(a, 1, 2, [1,2,3]);
}
}
@safe unittest
{
// the constraint for the first overload used to match this, which wouldn't compile.
import std.algorithm.comparison : equal;
long[] a = [1L, 2, 3];
int[] b = [4, 5, 6];
a.replaceInPlace(1, 2, b);
assert(equal(a, [1L, 4, 5, 6, 3]));
}
@system unittest
{
import core.exception;
import std.algorithm.comparison : equal;
import std.algorithm.iteration : filter;
import std.conv : to;
import std.exception;
bool test(T, U, V)(T orig, size_t from, size_t to, U toReplace, V result)
{
{
static if (is(T == typeof(T.init.dup)))
auto a = orig.dup;
else
auto a = orig.idup;
a.replaceInPlace(from, to, toReplace);
if (!equal(a, result))
return false;
}
static if (isInputRange!U)
{
orig.replaceInPlace(from, to, filter!"true"(toReplace));
return equal(orig, result);
}
else
return true;
}
assert(test([1, 2, 3, 4], 0, 0, [5, 6, 7], [5, 6, 7, 1, 2, 3, 4]));
assert(test([1, 2, 3, 4], 0, 2, cast(int[])[], [3, 4]));
assert(test([1, 2, 3, 4], 0, 4, [5, 6, 7], [5, 6, 7]));
assert(test([1, 2, 3, 4], 0, 2, [5, 6, 7], [5, 6, 7, 3, 4]));
assert(test([1, 2, 3, 4], 2, 4, [5, 6, 7], [1, 2, 5, 6, 7]));
assert(test([1, 2, 3, 4], 0, 0, filter!"true"([5, 6, 7]), [5, 6, 7, 1, 2, 3, 4]));
assert(test([1, 2, 3, 4], 0, 2, filter!"true"(cast(int[])[]), [3, 4]));
assert(test([1, 2, 3, 4], 0, 4, filter!"true"([5, 6, 7]), [5, 6, 7]));
assert(test([1, 2, 3, 4], 0, 2, filter!"true"([5, 6, 7]), [5, 6, 7, 3, 4]));
assert(test([1, 2, 3, 4], 2, 4, filter!"true"([5, 6, 7]), [1, 2, 5, 6, 7]));
void testStr(T, U)(string file = __FILE__, size_t line = __LINE__)
{
auto l = to!T("hello");
auto r = to!U(" world");
enforce(test(l, 0, 0, r, " worldhello"),
new AssertError("testStr failure 1", file, line));
enforce(test(l, 0, 3, r, " worldlo"),
new AssertError("testStr failure 2", file, line));
enforce(test(l, 3, l.length, r, "hel world"),
new AssertError("testStr failure 3", file, line));
enforce(test(l, 0, l.length, r, " world"),
new AssertError("testStr failure 4", file, line));
enforce(test(l, l.length, l.length, r, "hello world"),
new AssertError("testStr failure 5", file, line));
}
testStr!(string, string)();
testStr!(string, wstring)();
testStr!(string, dstring)();
testStr!(wstring, string)();
testStr!(wstring, wstring)();
testStr!(wstring, dstring)();
testStr!(dstring, string)();
testStr!(dstring, wstring)();
testStr!(dstring, dstring)();
}
/++
Replaces the first occurrence of `from` with `to` in `subject`.
Params:
subject = the array to scan
from = the item to replace
to = the item to replace `from` with
Returns:
A new array without changing the contents of `subject`, or the original
array if no match is found.
+/
E[] replaceFirst(E, R1, R2)(E[] subject, R1 from, R2 to)
if (isDynamicArray!(E[]) &&
isForwardRange!R1 && is(typeof(appender!(E[])().put(from[0 .. 1]))) &&
isForwardRange!R2 && is(typeof(appender!(E[])().put(to[0 .. 1]))))
{
if (from.empty) return subject;
static if (isSomeString!(E[]))
{
import std.string : indexOf;
immutable idx = subject.indexOf(from);
}
else
{
import std.algorithm.searching : countUntil;
immutable idx = subject.countUntil(from);
}
if (idx == -1)
return subject;
auto app = appender!(E[])();
app.put(subject[0 .. idx]);
app.put(to);
static if (isSomeString!(E[]) && isSomeString!R1)
{
import std.utf : codeLength;
immutable fromLength = codeLength!(Unqual!E, R1)(from);
}
else
immutable fromLength = from.length;
app.put(subject[idx + fromLength .. $]);
return app.data;
}
///
@safe unittest
{
auto a = [1, 2, 2, 3, 4, 5];
auto b = a.replaceFirst([2], [1337]);
assert(b == [1, 1337, 2, 3, 4, 5]);
auto s = "This is a foo foo list";
auto r = s.replaceFirst("foo", "silly");
assert(r == "This is a silly foo list");
}
@safe unittest
{
import std.algorithm.comparison : cmp;
import std.conv : to;
static foreach (S; AliasSeq!(string, wstring, dstring, char[], wchar[], dchar[],
const(char[]), immutable(char[])))
{
static foreach (T; AliasSeq!(string, wstring, dstring, char[], wchar[], dchar[],
const(char[]), immutable(char[])))
{{
auto s = to!S("This is a foo foo list");
auto s2 = to!S("Thüs is a ßöö foo list");
auto from = to!T("foo");
auto from2 = to!T("ßöö");
auto into = to!T("silly");
auto into2 = to!T("sälly");
S r1 = replaceFirst(s, from, into);
assert(cmp(r1, "This is a silly foo list") == 0);
S r11 = replaceFirst(s2, from2, into2);
assert(cmp(r11, "Thüs is a sälly foo list") == 0,
to!string(r11) ~ " : " ~ S.stringof ~ " " ~ T.stringof);
S r2 = replaceFirst(r1, from, into);
assert(cmp(r2, "This is a silly silly list") == 0);
S r3 = replaceFirst(s, to!T(""), into);
assert(cmp(r3, "This is a foo foo list") == 0);
assert(replaceFirst(r3, to!T("won't find"), to!T("whatever")) is r3);
}}
}
}
//Bug# 8187
@safe unittest
{
auto res = ["a", "a"];
assert(replace(res, "a", "b") == ["b", "b"]);
assert(replaceFirst(res, "a", "b") == ["b", "a"]);
}
/++
Replaces the last occurrence of `from` with `to` in `subject`.
Params:
subject = the array to scan
from = the item to replace
to = the item to replace `from` with
Returns:
A new array without changing the contents of `subject`, or the original
array if no match is found.
+/
E[] replaceLast(E, R1, R2)(E[] subject, R1 from , R2 to)
if (isDynamicArray!(E[]) &&
isForwardRange!R1 && is(typeof(appender!(E[])().put(from[0 .. 1]))) &&
isForwardRange!R2 && is(typeof(appender!(E[])().put(to[0 .. 1]))))
{
import std.range : retro;
if (from.empty) return subject;
static if (isSomeString!(E[]))
{
import std.string : lastIndexOf;
auto idx = subject.lastIndexOf(from);
}
else
{
import std.algorithm.searching : countUntil;
auto idx = retro(subject).countUntil(retro(from));
}
if (idx == -1)
return subject;
static if (isSomeString!(E[]) && isSomeString!R1)
{
import std.utf : codeLength;
auto fromLength = codeLength!(Unqual!E, R1)(from);
}
else
auto fromLength = from.length;
auto app = appender!(E[])();
static if (isSomeString!(E[]))
app.put(subject[0 .. idx]);
else
app.put(subject[0 .. $ - idx - fromLength]);
app.put(to);
static if (isSomeString!(E[]))
app.put(subject[idx+fromLength .. $]);
else
app.put(subject[$ - idx .. $]);
return app.data;
}
///
@safe unittest
{
auto a = [1, 2, 2, 3, 4, 5];
auto b = a.replaceLast([2], [1337]);
assert(b == [1, 2, 1337, 3, 4, 5]);
auto s = "This is a foo foo list";
auto r = s.replaceLast("foo", "silly");
assert(r == "This is a foo silly list", r);
}
@safe unittest
{
import std.algorithm.comparison : cmp;
import std.conv : to;
static foreach (S; AliasSeq!(string, wstring, dstring, char[], wchar[], dchar[],
const(char[]), immutable(char[])))
{
static foreach (T; AliasSeq!(string, wstring, dstring, char[], wchar[], dchar[],
const(char[]), immutable(char[])))
{{
auto s = to!S("This is a foo foo list");
auto s2 = to!S("Thüs is a ßöö ßöö list");
auto from = to!T("foo");
auto from2 = to!T("ßöö");
auto into = to!T("silly");
auto into2 = to!T("sälly");
S r1 = replaceLast(s, from, into);
assert(cmp(r1, "This is a foo silly list") == 0, to!string(r1));
S r11 = replaceLast(s2, from2, into2);
assert(cmp(r11, "Thüs is a ßöö sälly list") == 0,
to!string(r11) ~ " : " ~ S.stringof ~ " " ~ T.stringof);
S r2 = replaceLast(r1, from, into);
assert(cmp(r2, "This is a silly silly list") == 0);
S r3 = replaceLast(s, to!T(""), into);
assert(cmp(r3, "This is a foo foo list") == 0);
assert(replaceLast(r3, to!T("won't find"), to!T("whatever")) is r3);
}}
}
}
/++
Creates a new array such that the items in `slice` are replaced with the
items in `replacement`. `slice` and `replacement` do not need to be the
same length. The result will grow or shrink based on the items given.
Params:
s = the base of the new array
slice = the slice of `s` to be replaced
replacement = the items to replace `slice` with
Returns:
A new array that is `s` with `slice` replaced by
`replacement[]`.
See_Also:
$(REF substitute, std,algorithm,iteration) for a lazy replace.
+/
inout(T)[] replaceSlice(T)(inout(T)[] s, in T[] slice, in T[] replacement)
in
{
// Verify that slice[] really is a slice of s[]
assert(overlap(s, slice) is slice);
}
do
{
auto result = new T[s.length - slice.length + replacement.length];
immutable so = &slice[0] - &s[0];
result[0 .. so] = s[0 .. so];
result[so .. so + replacement.length] = replacement[];
result[so + replacement.length .. result.length] =
s[so + slice.length .. s.length];
return () @trusted inout {
return cast(inout(T)[]) result;
}();
}
///
@safe unittest
{
auto a = [1, 2, 3, 4, 5];
auto b = replaceSlice(a, a[1 .. 4], [0, 0, 0]);
assert(b == [1, 0, 0, 0, 5]);
}
@safe unittest
{
import std.algorithm.comparison : cmp;
string s = "hello";
string slice = s[2 .. 4];
auto r = replaceSlice(s, slice, "bar");
int i;
i = cmp(r, "hebaro");
assert(i == 0);
}
/**
Implements an output range that appends data to an array. This is
recommended over $(D array ~= data) when appending many elements because it is more
efficient. `Appender` maintains its own array metadata locally, so it can avoid
global locking for each append where $(LREF capacity) is non-zero.
Params:
A = the array type to simulate.
See_Also: $(LREF appender)
*/
struct Appender(A)
if (isDynamicArray!A)
{
import core.memory : GC;
import std.format : FormatSpec;
private alias T = ElementEncodingType!A;
private struct Data
{
size_t capacity;
Unqual!T[] arr;
bool canExtend = false;
}
private Data* _data;
/**
* Constructs an `Appender` with a given array. Note that this does not copy the
* data. If the array has a larger capacity as determined by `arr.capacity`,
* it will be used by the appender. After initializing an appender on an array,
* appending to the original array will reallocate.
*/
this(A arr) @trusted pure nothrow
{
// initialize to a given array.
_data = new Data;
_data.arr = cast(Unqual!T[]) arr; //trusted
if (__ctfe)
return;
// We want to use up as much of the block the array is in as possible.
// if we consume all the block that we can, then array appending is
// safe WRT built-in append, and we can use the entire block.
// We only do this for mutable types that can be extended.
static if (isMutable!T && is(typeof(arr.length = size_t.max)))
{
immutable cap = arr.capacity; //trusted
// Replace with "GC.setAttr( Not Appendable )" once pure (and fixed)
if (cap > arr.length)
arr.length = cap;
}
_data.capacity = arr.length;
}
/**
* Reserve at least newCapacity elements for appending. Note that more elements
* may be reserved than requested. If `newCapacity <= capacity`, then nothing is
* done.
*
* Params:
* newCapacity = the capacity the `Appender` should have
*/
void reserve(size_t newCapacity) @safe pure nothrow
{
if (_data)
{
if (newCapacity > _data.capacity)
ensureAddable(newCapacity - _data.arr.length);
}
else
{
ensureAddable(newCapacity);
}
}
/**
* Returns: the capacity of the array (the maximum number of elements the
* managed array can accommodate before triggering a reallocation). If any
* appending will reallocate, `0` will be returned.
*/
@property size_t capacity() const @safe pure nothrow
{
return _data ? _data.capacity : 0;
}
/**
* Returns: The managed array.
*/
@property inout(ElementEncodingType!A)[] data() inout @trusted pure nothrow
{
/* @trusted operation:
* casting Unqual!T[] to inout(T)[]
*/
return cast(typeof(return))(_data ? _data.arr : null);
}
// ensure we can add nelems elements, resizing as necessary
private void ensureAddable(size_t nelems) @trusted pure nothrow
{
if (!_data)
_data = new Data;
immutable len = _data.arr.length;
immutable reqlen = len + nelems;
if (_data.capacity >= reqlen)
return;
// need to increase capacity
if (__ctfe)
{
static if (__traits(compiles, new Unqual!T[1]))
{
_data.arr.length = reqlen;
}
else
{
// avoid restriction of @disable this()
_data.arr = _data.arr[0 .. _data.capacity];
foreach (i; _data.capacity .. reqlen)
_data.arr ~= Unqual!T.init;
}
_data.arr = _data.arr[0 .. len];
_data.capacity = reqlen;
}
else
{
// Time to reallocate.
// We need to almost duplicate what's in druntime, except we
// have better access to the capacity field.
auto newlen = appenderNewCapacity!(T.sizeof)(_data.capacity, reqlen);
// first, try extending the current block
if (_data.canExtend)
{
immutable u = GC.extend(_data.arr.ptr, nelems * T.sizeof, (newlen - len) * T.sizeof);
if (u)
{
// extend worked, update the capacity
_data.capacity = u / T.sizeof;
return;
}
}
// didn't work, must reallocate
import core.checkedint : mulu;
bool overflow;
const nbytes = mulu(newlen, T.sizeof, overflow);
if (overflow) assert(0);
auto bi = GC.qalloc(nbytes, blockAttribute!T);
_data.capacity = bi.size / T.sizeof;
import core.stdc.string : memcpy;
if (len)
memcpy(bi.base, _data.arr.ptr, len * T.sizeof);
_data.arr = (cast(Unqual!T*) bi.base)[0 .. len];
_data.canExtend = true;
// leave the old data, for safety reasons
}
}
private template canPutItem(U)
{
enum bool canPutItem =
isImplicitlyConvertible!(U, T) ||
isSomeChar!T && isSomeChar!U;
}
private template canPutConstRange(Range)
{
enum bool canPutConstRange =
isInputRange!(Unqual!Range) &&
!isInputRange!Range &&
is(typeof(Appender.init.put(Range.init.front)));
}
private template canPutRange(Range)
{
enum bool canPutRange =
isInputRange!Range &&
is(typeof(Appender.init.put(Range.init.front)));
}
/**
* Appends `item` to the managed array. Performs encoding for
* `char` types if `A` is a differently typed `char` array.
*
* Params:
* item = the single item to append
*/
void put(U)(U item) if (canPutItem!U)
{
static if (isSomeChar!T && isSomeChar!U && T.sizeof < U.sizeof)
{
/* may throwable operation:
* - std.utf.encode
*/
// must do some transcoding around here
import std.utf : encode;
Unqual!T[T.sizeof == 1 ? 4 : 2] encoded;
auto len = encode(encoded, item);
put(encoded[0 .. len]);
}
else
{
import std.conv : emplaceRef;
ensureAddable(1);
immutable len = _data.arr.length;
auto bigData = (() @trusted => _data.arr.ptr[0 .. len + 1])();
emplaceRef!(Unqual!T)(bigData[len], cast(Unqual!T) item);
//We do this at the end, in case of exceptions
_data.arr = bigData;
}
}
// Const fixing hack.
void put(Range)(Range items) if (canPutConstRange!Range)
{
alias p = put!(Unqual!Range);
p(items);
}
/**
* Appends an entire range to the managed array. Performs encoding for
* `char` elements if `A` is a differently typed `char` array.
*
* Params:
* items = the range of items to append
*/
void put(Range)(Range items) if (canPutRange!Range)
{
// note, we disable this branch for appending one type of char to
// another because we can't trust the length portion.
static if (!(isSomeChar!T && isSomeChar!(ElementType!Range) &&
!is(immutable Range == immutable T[])) &&
is(typeof(items.length) == size_t))
{
// optimization -- if this type is something other than a string,
// and we are adding exactly one element, call the version for one
// element.
static if (!isSomeChar!T)
{
if (items.length == 1)
{
put(items.front);
return;
}
}
// make sure we have enough space, then add the items
@trusted auto bigDataFun(size_t extra)
{
ensureAddable(extra);
return _data.arr.ptr[0 .. _data.arr.length + extra];
}
auto bigData = bigDataFun(items.length);
immutable len = _data.arr.length;
immutable newlen = bigData.length;
alias UT = Unqual!T;
static if (is(typeof(_data.arr[] = items[])) &&
!hasElaborateAssign!UT && isAssignable!(UT, ElementEncodingType!Range))
{
bigData[len .. newlen] = items[];
}
else
{
import std.conv : emplaceRef;
foreach (ref it ; bigData[len .. newlen])
{
emplaceRef!T(it, items.front);
items.popFront();
}
}
//We do this at the end, in case of exceptions
_data.arr = bigData;
}
else
{
//pragma(msg, Range.stringof);
// Generic input range
for (; !items.empty; items.popFront())
{
put(items.front);
}
}
}
/**
* Appends `rhs` to the managed array.
* Params:
* op = the assignment operator `~`
* rhs = Element or range.
*/
void opOpAssign(string op : "~", U)(U rhs)
if (__traits(compiles, put(rhs)))
{
put(rhs);
}
// only allow overwriting data on non-immutable and non-const data
static if (isMutable!T)
{
/**
* Clears the managed array. This allows the elements of the array to be reused
* for appending.
*
* Note: clear is disabled for immutable or const element types, due to the
* possibility that `Appender` might overwrite immutable data.
*/
void clear() @trusted pure nothrow
{
if (_data)
{
_data.arr = _data.arr.ptr[0 .. 0];
}
}
/**
* Shrinks the managed array to the given length.
*
* Throws: `Exception` if newlength is greater than the current array length.
* Note: shrinkTo is disabled for immutable or const element types.
*/
void shrinkTo(size_t newlength) @trusted pure
{
import std.exception : enforce;
if (_data)
{
enforce(newlength <= _data.arr.length, "Attempting to shrink Appender with newlength > length");
_data.arr = _data.arr.ptr[0 .. newlength];
}
else
enforce(newlength == 0, "Attempting to shrink empty Appender with non-zero newlength");
}
}
/**
* Gives a string in the form of `Appender!(A)(data)`.
*
* Params:
* w = A `char` accepting
* $(REF_ALTTEXT output range, isOutputRange, std, range, primitives).
* fmt = A $(REF FormatSpec, std, format) which controls how the array
* is formatted.
* Returns:
* A `string` if `writer` is not set; `void` otherwise.
*/
string toString() const
{
import std.format : singleSpec;
auto app = appender!string();
auto spec = singleSpec("%s");
// different reserve lengths because each element in a
// non-string-like array uses two extra characters for `, `.
static if (isSomeString!A)
{
app.reserve(_data.arr.length + 25);
}
else
{
// Multiplying by three is a very conservative estimate of
// length, as it assumes each element is only one char
app.reserve((_data.arr.length * 3) + 25);
}
toString(app, spec);
return app.data;
}
/// ditto
void toString(Writer)(ref Writer w, const ref FormatSpec!char fmt) const
if (isOutputRange!(Writer, char))
{
import std.format : formatValue;
import std.range.primitives : put;
put(w, Unqual!(typeof(this)).stringof);
put(w, '(');
formatValue(w, data, fmt);
put(w, ')');
}
// @@@DEPRECATED_2.089@@@
deprecated("To be removed after 2.089. Please use the output range overload.")
void toString(Writer)(scope Writer w)
if (isCallable!Writer)
{
import std.format : formattedWrite;
w.formattedWrite(typeof(this).stringof ~ "(%s)", data);
}
}
///
@safe unittest
{
auto app = appender!string();
string b = "abcdefg";
foreach (char c; b)
app.put(c);
assert(app.data == "abcdefg");
int[] a = [ 1, 2 ];
auto app2 = appender(a);
app2.put(3);
app2.put([ 4, 5, 6 ]);
assert(app2.data == [ 1, 2, 3, 4, 5, 6 ]);
}
@safe pure unittest
{
import std.format : format, singleSpec;
auto app = appender!(int[])();
app.put(1);
app.put(2);
app.put(3);
assert("%s".format(app) == "Appender!(int[])(%s)".format([1,2,3]));
auto app2 = appender!string();
auto spec = singleSpec("%s");
app.toString(app2, spec);
assert(app2.data == "Appender!(int[])([1, 2, 3])");
auto app3 = appender!string();
spec = singleSpec("%(%04d, %)");
app.toString(app3, spec);
assert(app3.data == "Appender!(int[])(0001, 0002, 0003)");
}
@safe unittest // issue 17251
{
static struct R
{
int front() const { return 0; }
bool empty() const { return true; }
void popFront() {}
}
auto app = appender!(R[]);
const(R)[1] r;
app.put(r[0]);
app.put(r[]);
}
//Calculates an efficient growth scheme based on the old capacity
//of data, and the minimum requested capacity.
//arg curLen: The current length
//arg reqLen: The length as requested by the user
//ret sugLen: A suggested growth.
private size_t appenderNewCapacity(size_t TSizeOf)(size_t curLen, size_t reqLen) @safe pure nothrow
{
import core.bitop : bsr;
import std.algorithm.comparison : max;
if (curLen == 0)
return max(reqLen,8);
ulong mult = 100 + (1000UL) / (bsr(curLen * TSizeOf) + 1);
// limit to doubling the length, we don't want to grow too much
if (mult > 200)
mult = 200;
auto sugLen = cast(size_t)((curLen * mult + 99) / 100);
return max(reqLen, sugLen);
}
/**
* A version of $(LREF Appender) that can update an array in-place.
* It forwards all calls to an underlying appender implementation.
* Any calls made to the appender also update the pointer to the
* original array passed in.
*
* Tip: Use the `arrayPtr` overload of $(LREF appender) for construction with type-inference.
*
* Params:
* A = The array type to simulate
*/
struct RefAppender(A)
if (isDynamicArray!A)
{
private
{
Appender!A impl;
A* arr;
}
/**
* Constructs a `RefAppender` with a given array reference. This does not copy the
* data. If the array has a larger capacity as determined by `arr.capacity`, it
* will be used by the appender.
*
* Note: Do not use built-in appending (i.e. `~=`) on the original array
* until you are done with the appender, because subsequent calls to the appender
* will reallocate the array data without those appends.
*
* Params:
* arr = Pointer to an array. Must not be _null.
*/
this(A* arr)
{
impl = Appender!A(*arr);
this.arr = arr;
}
/** Wraps remaining `Appender` methods such as $(LREF put).
* Params:
* fn = Method name to call.
* args = Arguments to pass to the method.
*/
void opDispatch(string fn, Args...)(Args args)
if (__traits(compiles, (Appender!A a) => mixin("a." ~ fn ~ "(args)")))
{
// we do it this way because we can't cache a void return
scope(exit) *this.arr = impl.data;
mixin("return impl." ~ fn ~ "(args);");
}
/**
* Appends `rhs` to the managed array.
* Params:
* rhs = Element or range.
*/
void opOpAssign(string op : "~", U)(U rhs)
if (__traits(compiles, (Appender!A a){ a.put(rhs); }))
{
scope(exit) *this.arr = impl.data;
impl.put(rhs);
}
/**
* Returns the capacity of the array (the maximum number of elements the
* managed array can accommodate before triggering a reallocation). If any
* appending will reallocate, `capacity` returns `0`.
*/
@property size_t capacity() const
{
return impl.capacity;
}
/**
* Returns the managed array.
*/
@property inout(ElementEncodingType!A)[] data() inout
{
return impl.data;
}
}
///
@system pure nothrow
unittest
{
int[] a = [1, 2];
auto app2 = appender(&a);
assert(app2.data == [1, 2]);
assert(a == [1, 2]);
app2 ~= 3;
app2 ~= [4, 5, 6];
assert(app2.data == [1, 2, 3, 4, 5, 6]);
assert(a == [1, 2, 3, 4, 5, 6]);
app2.reserve(5);
assert(app2.capacity >= 5);
}
/++
Convenience function that returns an $(LREF Appender) instance,
optionally initialized with `array`.
+/
Appender!A appender(A)()
if (isDynamicArray!A)
{
return Appender!A(null);
}
/// ditto
Appender!(E[]) appender(A : E[], E)(auto ref A array)
{
static assert(!isStaticArray!A || __traits(isRef, array),
"Cannot create Appender from an rvalue static array");
return Appender!(E[])(array);
}
@safe pure nothrow unittest
{
import std.exception;
{
auto app = appender!(char[])();
string b = "abcdefg";
foreach (char c; b) app.put(c);
assert(app.data == "abcdefg");
}
{
auto app = appender!(char[])();
string b = "abcdefg";
foreach (char c; b) app ~= c;
assert(app.data == "abcdefg");
}
{
int[] a = [ 1, 2 ];
auto app2 = appender(a);
assert(app2.data == [ 1, 2 ]);
app2.put(3);
app2.put([ 4, 5, 6 ][]);
assert(app2.data == [ 1, 2, 3, 4, 5, 6 ]);
app2.put([ 7 ]);
assert(app2.data == [ 1, 2, 3, 4, 5, 6, 7 ]);
}
int[] a = [ 1, 2 ];
auto app2 = appender(a);
assert(app2.data == [ 1, 2 ]);
app2 ~= 3;
app2 ~= [ 4, 5, 6 ][];
assert(app2.data == [ 1, 2, 3, 4, 5, 6 ]);
app2 ~= [ 7 ];
assert(app2.data == [ 1, 2, 3, 4, 5, 6, 7 ]);
app2.reserve(5);
assert(app2.capacity >= 5);
try // shrinkTo may throw
{
app2.shrinkTo(3);
}
catch (Exception) assert(0);
assert(app2.data == [ 1, 2, 3 ]);
assertThrown(app2.shrinkTo(5));
const app3 = app2;
assert(app3.capacity >= 3);
assert(app3.data == [1, 2, 3]);
auto app4 = appender([]);
try // shrinkTo may throw
{
app4.shrinkTo(0);
}
catch (Exception) assert(0);
// Issue 5663 & 9725 tests
static foreach (S; AliasSeq!(char[], const(char)[], string))
{
{
Appender!S app5663i;
assertNotThrown(app5663i.put("\xE3"));
assert(app5663i.data == "\xE3");
Appender!S app5663c;
assertNotThrown(app5663c.put(cast(const(char)[])"\xE3"));
assert(app5663c.data == "\xE3");
Appender!S app5663m;
assertNotThrown(app5663m.put("\xE3".dup));
assert(app5663m.data == "\xE3");
}
// ditto for ~=
{
Appender!S app5663i;
assertNotThrown(app5663i ~= "\xE3");
assert(app5663i.data == "\xE3");
Appender!S app5663c;
assertNotThrown(app5663c ~= cast(const(char)[])"\xE3");
assert(app5663c.data == "\xE3");
Appender!S app5663m;
assertNotThrown(app5663m ~= "\xE3".dup);
assert(app5663m.data == "\xE3");
}
}
static struct S10122
{
int val;
@disable this();
this(int v) @safe pure nothrow { val = v; }
}
assertCTFEable!(
{
auto w = appender!(S10122[])();
w.put(S10122(1));
assert(w.data.length == 1 && w.data[0].val == 1);
});
}
///
@safe pure nothrow
unittest
{
auto w = appender!string;
// pre-allocate space for at least 10 elements (this avoids costly reallocations)
w.reserve(10);
assert(w.capacity >= 10);
w.put('a'); // single elements
w.put("bc"); // multiple elements
// use the append syntax
w ~= 'd';
w ~= "ef";
assert(w.data == "abcdef");
}
@safe pure nothrow unittest
{
{
auto w = appender!string();
w.reserve(4);
cast(void) w.capacity;
cast(void) w.data;
try
{
wchar wc = 'a';
dchar dc = 'a';
w.put(wc); // decoding may throw
w.put(dc); // decoding may throw
}
catch (Exception) assert(0);
}
{
auto w = appender!(int[])();
w.reserve(4);
cast(void) w.capacity;
cast(void) w.data;
w.put(10);
w.put([10]);
w.clear();
try
{
w.shrinkTo(0);
}
catch (Exception) assert(0);
struct N
{
int payload;
alias payload this;
}
w.put(N(1));
w.put([N(2)]);
struct S(T)
{
@property bool empty() { return true; }
@property T front() { return T.init; }
void popFront() {}
}
S!int r;
w.put(r);
}
}
@safe unittest
{
import std.algorithm;
import std.typecons;
//10690
[tuple(1)].filter!(t => true).array; // No error
[tuple("A")].filter!(t => true).array; // error
}
@safe unittest
{
import std.range;
//Coverage for put(Range)
struct S1
{
}
struct S2
{
void opAssign(S2){}
}
auto a1 = Appender!(S1[])();
auto a2 = Appender!(S2[])();
auto au1 = Appender!(const(S1)[])();
a1.put(S1().repeat().take(10));
a2.put(S2().repeat().take(10));
auto sc1 = const(S1)();
au1.put(sc1.repeat().take(10));
}
@system unittest
{
import std.range;
struct S2
{
void opAssign(S2){}
}
auto au2 = Appender!(const(S2)[])();
auto sc2 = const(S2)();
au2.put(sc2.repeat().take(10));
}
@system unittest
{
struct S
{
int* p;
}
auto a0 = Appender!(S[])();
auto a1 = Appender!(const(S)[])();
auto a2 = Appender!(immutable(S)[])();
auto s0 = S(null);
auto s1 = const(S)(null);
auto s2 = immutable(S)(null);
a1.put(s0);
a1.put(s1);
a1.put(s2);
a1.put([s0]);
a1.put([s1]);
a1.put([s2]);
a0.put(s0);
static assert(!is(typeof(a0.put(a1))));
static assert(!is(typeof(a0.put(a2))));
a0.put([s0]);
static assert(!is(typeof(a0.put([a1]))));
static assert(!is(typeof(a0.put([a2]))));
static assert(!is(typeof(a2.put(a0))));
static assert(!is(typeof(a2.put(a1))));
a2.put(s2);
static assert(!is(typeof(a2.put([a0]))));
static assert(!is(typeof(a2.put([a1]))));
a2.put([s2]);
}
@safe unittest
{
//9528
const(E)[] fastCopy(E)(E[] src) {
auto app = appender!(const(E)[])();
foreach (i, e; src)
app.put(e);
return app.data;
}
class C {}
struct S { const(C) c; }
S[] s = [ S(new C) ];
auto t = fastCopy(s); // Does not compile
assert(t.length == 1);
}
@safe unittest
{
import std.algorithm.iteration : map;
//10753
struct Foo {
immutable dchar d;
}
struct Bar {
immutable int x;
}
"12".map!Foo.array;
[1, 2].map!Bar.array;
}
@safe unittest
{
import std.algorithm.comparison : equal;
//New appender signature tests
alias mutARR = int[];
alias conARR = const(int)[];
alias immARR = immutable(int)[];
mutARR mut;
conARR con;
immARR imm;
auto app1 = Appender!mutARR(mut); //Always worked. Should work. Should not create a warning.
app1.put(7);
assert(equal(app1.data, [7]));
static assert(!is(typeof(Appender!mutARR(con)))); //Never worked. Should not work.
static assert(!is(typeof(Appender!mutARR(imm)))); //Never worked. Should not work.
auto app2 = Appender!conARR(mut); //Always worked. Should work. Should not create a warning.
app2.put(7);
assert(equal(app2.data, [7]));
auto app3 = Appender!conARR(con); //Didn't work. Now works. Should not create a warning.
app3.put(7);
assert(equal(app3.data, [7]));
auto app4 = Appender!conARR(imm); //Didn't work. Now works. Should not create a warning.
app4.put(7);
assert(equal(app4.data, [7]));
//{auto app = Appender!immARR(mut);} //Worked. Will cease to work. Creates warning.
//static assert(!is(typeof(Appender!immARR(mut)))); //Worked. Will cease to work. Uncomment me after full deprecation.
static assert(!is(typeof(Appender!immARR(con)))); //Never worked. Should not work.
auto app5 = Appender!immARR(imm); //Didn't work. Now works. Should not create a warning.
app5.put(7);
assert(equal(app5.data, [7]));
//Deprecated. Please uncomment and make sure this doesn't work:
//char[] cc;
//static assert(!is(typeof(Appender!string(cc))));
//This should always work:
auto app6 = appender!string(null);
assert(app6.data == null);
auto app7 = appender!(const(char)[])(null);
assert(app7.data == null);
auto app8 = appender!(char[])(null);
assert(app8.data == null);
}
@safe unittest //Test large allocations (for GC.extend)
{
import std.algorithm.comparison : equal;
import std.range;
Appender!(char[]) app;
app.reserve(1); //cover reserve on non-initialized
foreach (_; 0 .. 100_000)
app.put('a');
assert(equal(app.data, 'a'.repeat(100_000)));
}
@safe unittest
{
auto reference = new ubyte[](2048 + 1); //a number big enough to have a full page (EG: the GC extends)
auto arr = reference.dup;
auto app = appender(arr[0 .. 0]);
app.reserve(1); //This should not trigger a call to extend
app.put(ubyte(1)); //Don't clobber arr
assert(reference[] == arr[]);
}
@safe unittest // clear method is supported only for mutable element types
{
Appender!string app;
app.put("foo");
static assert(!__traits(compiles, app.clear()));
assert(app.data == "foo");
}
@safe unittest
{
static struct D//dynamic
{
int[] i;
alias i this;
}
static struct S//static
{
int[5] i;
alias i this;
}
static assert(!is(Appender!(char[5])));
static assert(!is(Appender!D));
static assert(!is(Appender!S));
enum int[5] a = [];
int[5] b;
D d;
S s;
int[5] foo(){return a;}
static assert(!is(typeof(appender(a))));
static assert( is(typeof(appender(b))));
static assert( is(typeof(appender(d))));
static assert( is(typeof(appender(s))));
static assert(!is(typeof(appender(foo()))));
}
@system unittest
{
// Issue 13077
static class A {}
// reduced case
auto w = appender!(shared(A)[])();
w.put(new shared A());
// original case
import std.range;
InputRange!(shared A) foo()
{
return [new shared A].inputRangeObject;
}
auto res = foo.array;
assert(res.length == 1);
}
/++
Convenience function that returns a $(LREF RefAppender) instance initialized
with `arrayPtr`. Don't use null for the array pointer, use the other
version of `appender` instead.
+/
RefAppender!(E[]) appender(P : E[]*, E)(P arrayPtr)
{
return RefAppender!(E[])(arrayPtr);
}
///
@system pure nothrow
unittest
{
int[] a = [1, 2];
auto app2 = appender(&a);
assert(app2.data == [1, 2]);
assert(a == [1, 2]);
app2 ~= 3;
app2 ~= [4, 5, 6];
assert(app2.data == [1, 2, 3, 4, 5, 6]);
assert(a == [1, 2, 3, 4, 5, 6]);
app2.reserve(5);
assert(app2.capacity >= 5);
}
@system unittest
{
import std.exception;
{
auto arr = new char[0];
auto app = appender(&arr);
string b = "abcdefg";
foreach (char c; b) app.put(c);
assert(app.data == "abcdefg");
assert(arr == "abcdefg");
}
{
auto arr = new char[0];
auto app = appender(&arr);
string b = "abcdefg";
foreach (char c; b) app ~= c;
assert(app.data == "abcdefg");
assert(arr == "abcdefg");
}
{
int[] a = [ 1, 2 ];
auto app2 = appender(&a);
assert(app2.data == [ 1, 2 ]);
assert(a == [ 1, 2 ]);
app2.put(3);
app2.put([ 4, 5, 6 ][]);
assert(app2.data == [ 1, 2, 3, 4, 5, 6 ]);
assert(a == [ 1, 2, 3, 4, 5, 6 ]);
}
int[] a = [ 1, 2 ];
auto app2 = appender(&a);
assert(app2.data == [ 1, 2 ]);
assert(a == [ 1, 2 ]);
app2 ~= 3;
app2 ~= [ 4, 5, 6 ][];
assert(app2.data == [ 1, 2, 3, 4, 5, 6 ]);
assert(a == [ 1, 2, 3, 4, 5, 6 ]);
app2.reserve(5);
assert(app2.capacity >= 5);
try // shrinkTo may throw
{
app2.shrinkTo(3);
}
catch (Exception) assert(0);
assert(app2.data == [ 1, 2, 3 ]);
assertThrown(app2.shrinkTo(5));
const app3 = app2;
assert(app3.capacity >= 3);
assert(app3.data == [1, 2, 3]);
}
@safe unittest // issue 14605
{
static assert(isOutputRange!(Appender!(int[]), int));
static assert(isOutputRange!(RefAppender!(int[]), int));
}
@safe unittest
{
Appender!(int[]) app;
short[] range = [1, 2, 3];
app.put(range);
assert(app.data == [1, 2, 3]);
}
@safe unittest
{
string s = "hello".idup;
char[] a = "hello".dup;
auto appS = appender(s);
auto appA = appender(a);
put(appS, 'w');
put(appA, 'w');
s ~= 'a'; //Clobbers here?
a ~= 'a'; //Clobbers here?
assert(appS.data == "hellow");
assert(appA.data == "hellow");
}
|
D
|
func void B_OpenGateOrcTown ()
{
Wld_SendTrigger ("ORCTOWN_MOVER_01_SCRIPT");
Wld_SendTrigger ("ORCTOWN_MOVER_02_SCRIPT");
Wld_SendTrigger ("ORCTOWN_MOVER_03_SCRIPT");
//Wld_SendTrigger ("ORCTOWN_MOVER_04_SCRIPT"); // otwarcie tego wywala gre
Wld_SendTrigger ("ORCTOWN_MOVER_05_SCRIPT");
Wld_SendTrigger ("ORCTOWN_MOVER_06_SCRIPT");
Wld_SendTrigger ("ORCTOWN_MOVER_07_SCRIPT");
};
|
D
|
module ast.vardecl_expr;
import ast.scopes, ast.namespace, ast.casting, ast.base, ast.types, ast.parse, ast.vardecl, ast.tuples,
ast.assign, ast.aggregate, ast.c_bind, ast.pointer, ast.aliasing, ast.arrays, ast.dg;
Object gotVarDeclExpr(ref string text, ParseCb cont, ParseCb rest) {
auto t2 = text;
string name;
IType type;
{
string t3 = t2;
if (t3.accept("("[]) && t3.accept(")"[])) /* THIS IS NOT A GOOD THING THIS IS BAD AND WRONG */
return null; // whew.
}
if (parsingCHeader() || !namespace().get!(ScopeLike)) return null;
bool isRefDecl, isScopeDecl;
if (!t2.accept("auto"[])) {
if (t2.accept("scope")) isScopeDecl = true;
if (t2.accept("ref")) isRefDecl = true;
if (!rest(t2, "type"[], &type) && !isRefDecl && !isScopeDecl) return null;
}
if (t2.accept(":"[])) return null; // cast
bool completeDeclaration(Statement* st, Expr* ex) {
bool dontInit;
Expr initval;
if (t2.accept("="[])) {
if (t2.accept("void"[])) {
dontInit = true;
if (!type) text.failparse("uninitialized variables must have type");
} else {
IType[] its;
if (!rest(t2, "tree.expr"[], &initval)
|| type && !gotImplicitCast(initval, type, (IType it) {
its ~= it;
return test(type == it);
}))
t2.failparse("Could not parse variable initializer; tried "[], its);
}
} else {
if (!type) {
t2.setError("Auto vardecl exprs must be initialized. "[]);
return false;
}
if (t2.acceptLeftArrow()) return false; // don't collide with iterator declaration
}
Variable var;
if (isRefDecl) {
if (!initval)
text.failparse("ref declaration must have initializer");
auto lv = fastcast!(LValue)(initval);
if (!lv)
text.failparse("initializer of a ref decl must be referentiable");
initval = fastalloc!(RefExpr)(lv);
if (type && type != initval.valueType())
text.failparse("Type mismatch: declared ", type, " but got ", initval.valueType());
type = initval.valueType();
var = fastalloc!(Variable)(type, framelength(), cast(string) null);
} else {
if (!type) {
if (!initval) text.failparse("internal compiler bug - no init no type");
type = initval.valueType();
if (!initval) text.failparse("internal compiler bug - no init no type even now");
}
var = fastalloc!(Variable)(type, framelength(), name);
}
if (fastcast!(Void) (resolveType(type))) {
text.failparse("Cannot declare variable of type "[], type, " which is void"[]);
}
auto sc = namespace().get!(Scope);
if (!sc) {
t2.failparse("There is a lack of a scope here; trying to define "[], name);
}
try {
sc.add(var);
} catch (AlreadyDefinedException ex) {
t2.failparse(ex);
}
if (isRefDecl) {
auto ea = fastalloc!(LValueAlias)(fastalloc!(DerefExpr)(var), name);
sc.add(ea);
*ex = ea;
} else {
*ex = var;
}
if (isScopeDecl) {
auto thing = *ex;
auto vt = resolveType(thing.valueType());
if (fastcast!(Array) (vt) || fastcast!(ExtArray) (vt) || showsAnySignOfHaving(thing, "free")) {
sc.addGuard(iparse!(Statement, "scope_guard", "tree.stmt")
(`thing.free;`, "thing", thing));
} else if (fastcast!(Delegate) (vt)) {
sc.addGuard(iparse!(Statement, "scope_guard", "tree.stmt")
(`dupvfree thing.data;`, "thing", thing));
} else {
sc.addGuard(iparse!(Statement, "scope_guard", "tree.stmt")
(`mem.free thing;`, "thing", thing));
}
}
auto vd = fastalloc!(VarDecl)(var);
vd.configPosition(text);
sc.addStatement(vd);
if (initval) {
if (!dontInit)
*st = fastalloc!(Assignment)(var, initval);
} else {
vd.initInit;
}
return true;
}
Statement setVar;
Expr res;
auto t3 = t2;
if (t2.gotIdentifier(name)) {
if (!completeDeclaration(&setVar, &res)) return null;
} else if (t3.accept("=")) { // scope = foo syntax to create an unnamed variable
name = getAnonvarId();
if (!completeDeclaration(&setVar, &res))
t2.failparse("could not complete anonymous variable declaration");
} else if (t2.accept("("[])) {
bool firstTime = true;
bool wasAuto = !type;
Statement[] stmts; Expr[] exprs;
while (true) {
if (t2.accept(")"[])) break;
if (firstTime) firstTime = false;
else {
if (!t2.accept(","[])) { t2.setError("Comma expected"[]); return null; }
}
if (!t2.gotIdentifier(name)) t2.failparse("Identifier expected"[]);
Statement st; Expr ex;
if (!completeDeclaration(&st, &ex)) t2.failparse("Declaration completion expected"[]);
exprs ~= ex;
if (st) stmts ~= st;
if (wasAuto) type = null;
}
if (stmts) setVar = fastalloc!(AggrStatement)(stmts);
res = mkTupleExpr(exprs);
} else return null;
text = t2;
if (setVar) return fastalloc!(StatementAndExpr)(setVar, res);
else return fastcast!(Object) (res);
}
mixin DefaultParser!(gotVarDeclExpr, "tree.expr.vardecl", "28", null, true, true);
|
D
|
a pale cane syrup
writing or music that is excessively sweet and sentimental
|
D
|
void main() {
auto N = ri;
if(N >= 123) writeln(N-1);
else writeln(N);
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;
T readAs(T)() if (isBasicType!T) {
return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
return readln.split.to!T;
}
T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
auto res = new T[][](height, width);
foreach(i; 0..height) {
res[i] = readAs!(T[]);
}
return res;
}
T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
auto res = new T[][](height, width);
foreach(i; 0..height) {
auto s = rs;
foreach(j; 0..width) res[i][j] = s[j].to!T;
}
return res;
}
int ri() {
return readAs!int;
}
double rd() {
return readAs!double;
}
string rs() {
return readln.chomp;
}
|
D
|
import std.complex, std.stdio;
//module mandelbrot;
void mandelbrot(real c_re, real c_im) {
auto z = complex(0, 0);
immutable c = complex(c_re, c_im);
uint n = 0;
immutable MAX_ITER = 80;
immutable zabs = abs(z);
while(zabs <= 2 && n < MAX_ITER ) {
z = z*z + c;
n += 1;
}
write(zabs < 2 ? '#' : '.');
//return n;
}
//void main() {
//// write(complex(1,1), " ", mandelbrot(1,1));
// for(real i = -10.0; i <= 10.0; i += 1) {
// for(real j = -10.0; j <= 10.0; j += 1) {
// auto c = complex(i / 10, j / 10);
// write(c, " ", mandelbrot(c.re, c.im), "\n");
// }
// }
//}
|
D
|
/**
* Droits d’auteur: Enalye
* Licence: Zlib
* Auteur: Enalye
*/
module grimoire.stdlib.hashmap;
import std.typecons : Tuple, tuple;
import std.conv : to;
import grimoire.assembly, grimoire.compiler, grimoire.runtime;
import grimoire.stdlib.util;
import grimoire.stdlib.pair;
/// HashMap
private final class HashMap {
/// Payload
GrValue[string] data;
/// Ctor
this(GrString[] keys, GrValue[] values) {
for (size_t i; i < keys.length; ++i) {
data[keys[i].str] = values[i];
}
}
/// Ditto
this() {
}
this(HashMap hashmap) {
data = hashmap.data.dup;
}
}
/// Iterator
private final class HashMapIterator {
Tuple!(string, GrValue)[] pairs;
size_t index;
}
void grLoadStdLibHashMap(GrLibDefinition library) {
library.setModule(["std", "hashmap"]);
library.setModuleInfo(GrLocale.fr_FR, "Dictionnaire associant des valeurs par clés.");
library.setModuleInfo(GrLocale.en_US, "Dictionary that associates values by keys.");
library.setDescription(GrLocale.fr_FR, "Dictionnaire associant des valeurs par clés.");
library.setDescription(GrLocale.en_US, "Dictionary that associates values by keys.");
GrType mapType = library.addNative("HashMap", ["T"]);
library.setDescription(GrLocale.fr_FR, "Itère sur les éléments d’une hashmap.");
library.setDescription(GrLocale.en_US, "Iterate on the elements of a hashmap.");
GrType iteratorType = library.addNative("HashMapIterator", ["T"]);
GrType pairType = grGetNativeType("Pair", [grString, grAny("T")]);
library.addConstructor(&_new, mapType);
library.addConstructor(&_newByList, mapType, [
grPure(grList(grString)), grPure(grList(grAny("T")))
]);
library.addConstructor(&_newByPairs, mapType, [grPure(grList(pairType))]);
library.setParameters(GrLocale.fr_FR, ["self"]);
library.setParameters(GrLocale.en_US, ["self"]);
library.setDescription(GrLocale.fr_FR, "Returne une copie de la hashmap.");
library.setDescription(GrLocale.fr_FR, "Returns a copy of the hashmap.");
library.addFunction(&_copy, "copy", [grPure(mapType)], [mapType]);
library.setDescription(GrLocale.fr_FR, "Returne le nombre d’élements dans la hashmap.");
library.setDescription(GrLocale.en_US, "Returns the number of elements in the hashmap.");
library.addFunction(&_size, "size", [grPure(mapType)], [grInt]);
library.setDescription(GrLocale.fr_FR, "Renvoie `true` si la hashmap ne contient rien.");
library.setDescription(GrLocale.en_US, "Returns `true` if the hashmap contains nothing.");
library.addFunction(&_isEmpty, "isEmpty", [grPure(mapType)], [grBool]);
library.setDescription(GrLocale.fr_FR, "Vide la hashmap.");
library.setDescription(GrLocale.en_US, "Clear the hashmap.");
library.addFunction(&_clear, "clear", [mapType], [mapType]);
library.setDescription(GrLocale.fr_FR,
"Ajoute la nouvelle valeur à la clé correspondante dans la hashmap.");
library.setDescription(GrLocale.en_US,
"Add the new value to the corresponding key in the hashmap.");
library.setParameters(GrLocale.fr_FR, ["self", "key", "value"]);
library.setParameters(GrLocale.en_US, ["self", "key", "value"]);
library.addFunction(&_set, "set", [mapType, grPure(grString), grAny("T")]);
library.setDescription(GrLocale.fr_FR,
"Returne la valeur associée avec `key`.\nSi cette valeur n’existe pas, retourne `null<T>`.");
library.setDescription(GrLocale.en_US,
"Return the value associated with `key`.\nIf the value doesn't exist, returns `null<T>`.");
library.setParameters(GrLocale.fr_FR, ["self", "key"]);
library.setParameters(GrLocale.en_US, ["self", "key"]);
library.addFunction(&_get, "get", [grPure(mapType), grString], [
grOptional(grAny("T"))
]);
library.setDescription(GrLocale.fr_FR,
"Returne la valeur associée avec `key`.\nSi cette valeur n’existe pas, retourne `def`.");
library.setDescription(GrLocale.en_US,
"Return the value associated with `key`.\nIf the value doesn't exist, returns `def`.");
library.setParameters(GrLocale.fr_FR, ["self", "key", "def"]);
library.setParameters(GrLocale.en_US, ["self", "key", "def"]);
library.addFunction(&_getOr, "getOr", [
grPure(mapType), grString, grAny("T")
], [grAny("T")]);
library.setParameters(GrLocale.fr_FR, ["self", "key"]);
library.setParameters(GrLocale.en_US, ["self", "key"]);
library.setDescription(GrLocale.fr_FR, "Renvoie `true` si la clé existe dans la hashmap.");
library.setDescription(GrLocale.en_US, "Returns `true` if the key exists inside the hashmap.");
library.addFunction(&_contains, "contains", [grPure(mapType), grString], [
grBool
]);
library.setDescription(GrLocale.fr_FR, "Retire l’entrée `key` de la hashmap.");
library.setDescription(GrLocale.en_US, "Delete the entry `key` from the hashmap.");
library.addFunction(&_remove, "remove", [mapType, grPure(grString)]);
library.setParameters(GrLocale.fr_FR, ["self"]);
library.setParameters(GrLocale.en_US, ["self"]);
library.setDescription(GrLocale.fr_FR, "Returne la liste de toutes les clés.");
library.setDescription(GrLocale.en_US, "Returns the list of all keys.");
library.addFunction(&_byKeys, "byKeys", [grPure(mapType)], [
grList(grString)
]);
library.setDescription(GrLocale.fr_FR, "Returne la liste de toutes les valeurs.");
library.setDescription(GrLocale.en_US, "Returns the list of all values.");
library.addFunction(&_byValues, "byValues", [grPure(mapType)], [
grList(grAny("T"))
]);
library.setDescription(GrLocale.fr_FR,
"Returne un itérateur permettant d’itérer sur chaque paire de clés/valeurs.");
library.setDescription(GrLocale.en_US,
"Returns an iterator that iterate through each key/value pairs.");
library.addFunction(&_each, "each", [grPure(mapType)], [iteratorType]);
library.setDescription(GrLocale.fr_FR, "Avance l’itérateur à l’élément suivant.");
library.setDescription(GrLocale.en_US, "Advance the iterator to the next element.");
library.setParameters(GrLocale.fr_FR, ["itérateur"]);
library.setParameters(GrLocale.en_US, ["iterator"]);
library.addFunction(&_next, "next", [iteratorType], [grOptional(pairType)]);
GrType boolHashMap = grGetNativeType("HashMap", [grBool]);
GrType intHashMap = grGetNativeType("HashMap", [grInt]);
GrType floatHashMap = grGetNativeType("HashMap", [grFloat]);
GrType stringHashMap = grGetNativeType("HashMap", [grString]);
library.setDescription(GrLocale.fr_FR, "Affiche le contenu d’hashmap.");
library.setDescription(GrLocale.en_US, "Display the content of hashmap.");
library.setParameters(GrLocale.fr_FR, ["self"]);
library.setParameters(GrLocale.en_US, ["self"]);
library.addFunction(&_print_!"bool", "print", [grPure(boolHashMap)]);
library.addFunction(&_print_!"int", "print", [grPure(intHashMap)]);
library.addFunction(&_print_!"float", "print", [grPure(floatHashMap)]);
library.addFunction(&_print_!"string", "print", [grPure(stringHashMap)]);
}
private void _new(GrCall call) {
HashMap hashmap = new HashMap;
call.setNative(hashmap);
}
private void _newByList(GrCall call) {
HashMap hashmap = new HashMap(call.getList(0).getStrings(), call.getList(1).getValues());
call.setNative(hashmap);
}
private void _newByPairs(GrCall call) {
HashMap hashmap = new HashMap;
GrPair[] pairs = call.getList(0).getNatives!GrPair();
for (size_t i; i < pairs.length; ++i) {
hashmap.data[pairs[i].key.getString().str] = pairs[i].value;
}
call.setNative(hashmap);
}
private void _copy(GrCall call) {
HashMap hashmap = call.getNative!HashMap(0);
call.setNative!HashMap(new HashMap(hashmap));
}
private void _size(GrCall call) {
HashMap hashmap = call.getNative!HashMap(0);
call.setInt(cast(GrInt) hashmap.data.length);
}
private void _isEmpty(GrCall call) {
const HashMap hashmap = call.getNative!HashMap(0);
call.setBool(hashmap.data.length == 0);
}
private void _clear(GrCall call) {
HashMap hashmap = call.getNative!HashMap(0);
hashmap.data.clear();
call.setNative!HashMap(hashmap);
}
private void _set(GrCall call) {
HashMap hashmap = call.getNative!(HashMap)(0);
hashmap.data[call.getString(1).str] = call.getValue(2);
}
private void _get(GrCall call) {
HashMap hashmap = call.getNative!(HashMap)(0);
auto p = call.getString(1).str in hashmap.data;
if (p is null) {
call.setNull();
return;
}
call.setValue(*p);
}
private void _getOr(GrCall call) {
HashMap hashmap = call.getNative!(HashMap)(0);
auto p = call.getString(1).str in hashmap.data;
call.setValue(p ? *p : call.getValue(2));
}
private void _contains(GrCall call) {
HashMap hashmap = call.getNative!(HashMap)(0);
call.setBool((call.getString(1).str in hashmap.data) !is null);
}
private void _remove(GrCall call) {
HashMap hashmap = call.getNative!(HashMap)(0);
hashmap.data.remove(call.getString(1).str);
}
private void _byKeys(GrCall call) {
HashMap hashmap = call.getNative!(HashMap)(0);
GrValue[] ary;
foreach (string key; hashmap.data.keys) {
ary ~= GrValue(key);
}
call.setList(ary);
}
private void _byValues(GrCall call) {
HashMap hashmap = call.getNative!(HashMap)(0);
GrValue[] ary;
ary = hashmap.data.values;
call.setList(ary);
}
private void _each(GrCall call) {
HashMap hashmap = call.getNative!(HashMap)(0);
HashMapIterator iter = new HashMapIterator;
foreach (pair; hashmap.data.byKeyValue()) {
iter.pairs ~= tuple(pair.key, pair.value);
}
call.setNative(iter);
}
private void _next(GrCall call) {
HashMapIterator iter = call.getNative!HashMapIterator(0);
if (iter.index >= iter.pairs.length) {
call.setNull();
return;
}
GrPair pair = new GrPair;
pair.key = GrValue(iter.pairs[iter.index][0]);
pair.value = iter.pairs[iter.index][1];
call.setNative(pair);
iter.index++;
}
private void _print_(string T)(GrCall call) {
HashMap hashmap = call.getNative!HashMap(0);
string result = "{";
bool isFirst = true;
foreach (key, value; hashmap.data) {
if (isFirst) {
isFirst = false;
}
else {
result ~= ", ";
}
result ~= "\"" ~ key ~ "\"=>";
static if (T == "bool")
result ~= to!string(value.getBool());
else static if (T == "int")
result ~= to!string(value.getInt());
else static if (T == "float")
result ~= to!string(value.getFloat());
else static if (T == "string")
result ~= "\"" ~ value.getString().str ~ "\"";
else
static assert(false);
}
result ~= "}";
grPrint(result);
}
|
D
|
/Users/cansoykarafakili/Desktop/Hello/build/Intermediates/Hello.build/Debug/Bits.build/Objects-normal/x86_64/Byte+PatternMatching.o : /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Bytes+Base64.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Byte+Convenience.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Data+BytesConvertible.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/String+BytesConvertible.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/UnsignedInteger+BytesConvertible.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/BytesConvertible.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Byte+PatternMatching.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/UnsignedInteger+Shifting.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Byte+Random.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Base64Encoder.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/HexEncoder.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Aliases.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/ByteSequence+Conversions.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Byte+UTF8Numbers.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Byte+ControlCharacters.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Operators.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Byte+Alphabet.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Bytes+Percent.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Bytes+Hex.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 /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 /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 /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/cansoykarafakili/Desktop/Hello/build/Intermediates/Hello.build/Debug/Bits.build/Objects-normal/x86_64/Byte+PatternMatching~partial.swiftmodule : /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Bytes+Base64.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Byte+Convenience.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Data+BytesConvertible.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/String+BytesConvertible.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/UnsignedInteger+BytesConvertible.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/BytesConvertible.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Byte+PatternMatching.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/UnsignedInteger+Shifting.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Byte+Random.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Base64Encoder.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/HexEncoder.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Aliases.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/ByteSequence+Conversions.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Byte+UTF8Numbers.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Byte+ControlCharacters.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Operators.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Byte+Alphabet.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Bytes+Percent.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Bytes+Hex.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 /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 /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 /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/cansoykarafakili/Desktop/Hello/build/Intermediates/Hello.build/Debug/Bits.build/Objects-normal/x86_64/Byte+PatternMatching~partial.swiftdoc : /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Bytes+Base64.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Byte+Convenience.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Data+BytesConvertible.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/String+BytesConvertible.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/UnsignedInteger+BytesConvertible.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/BytesConvertible.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Byte+PatternMatching.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/UnsignedInteger+Shifting.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Byte+Random.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Base64Encoder.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/HexEncoder.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Aliases.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/ByteSequence+Conversions.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Byte+UTF8Numbers.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Byte+ControlCharacters.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Operators.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Byte+Alphabet.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Bytes+Percent.swift /Users/cansoykarafakili/Desktop/Hello/.build/checkouts/bits.git-9196587591774126515/Sources/Bits/Bytes+Hex.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 /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 /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 /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/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/MySQL.build/Bind.swift.o : /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Bind+Node.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Bind.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Binds.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Connection.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Database.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Error.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Field+Variant.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Field.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Fields.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/MySQL+Date.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/MySQL+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/Darwin.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/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/JSON.swiftmodule /Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/Jay.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/MySQL.build/Bind~partial.swiftmodule : /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Bind+Node.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Bind.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Binds.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Connection.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Database.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Error.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Field+Variant.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Field.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Fields.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/MySQL+Date.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/MySQL+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/Darwin.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/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/JSON.swiftmodule /Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/Jay.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/MySQL.build/Bind~partial.swiftdoc : /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Bind+Node.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Bind.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Binds.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Connection.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Database.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Error.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Field+Variant.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Field.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/Fields.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/MySQL+Date.swift /Users/okasho/serverProject/tryswift/get_and_post/swift/Packages/MySQL-1.1.2/Sources/MySQL/MySQL+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/Darwin.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/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/JSON.swiftmodule /Users/okasho/serverProject/tryswift/get_and_post/swift/.build/debug/Jay.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
|
///Shamelessly copied from:
///http://dvbmonkey.wordpress.com/2009/03/02/an-open-mpi-master-servant-example/
///If it destroys your system, blame that dude ^^
import std.stdio;
import std.array;
import std.algorithm;
import std.string;
import mpi;
//#include <unistd.h>
int main(string[] args)
{ //Converts D-style args to C-style.
//pretty decent, since MPI will pass this along to the other processes
int argc = args.length;
const char** argv = array(map!toStringz(args)).ptr;
int numprocs, rank, namelen;
char processor_name[MPI_MAX_PROCESSOR_NAME];
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Get_processor_name(processor_name.ptr, &namelen);
if (rank == 0)
{
printf("[%02d/%02d %s]: I am the master\n", rank, numprocs, processor_name.ptr );
// Tell the servants to do something
} else
{
printf("[%02d/%02d %s]: I am a servant\n", rank, numprocs, processor_name.ptr );
// Wait for something to do
}
return MPI_Finalize();
}
|
D
|
/Users/petercernak/vapor/TILApp/Build/Intermediates.noindex/TILApp.build/Debug/TemplateKit.build/Objects-normal/x86_64/PlaintextRenderer.o : /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Data/TemplateData.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateEmbed.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Deprecated.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateSource.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Data/TemplateDataStorage.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Pipeline/ASTCache.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Data/TemplateDataRepresentable.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Utilities/HTMLEscape.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateSyntaxType.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Uppercase.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Lowercase.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Capitalize.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateTag.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateConditional.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateCustom.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateExpression.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Var.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Data/TemplateDataEncoder.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateIdentifier.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Pipeline/TemplateByteScanner.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Pipeline/TemplateRenderer.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/TagRenderer.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Pipeline/PlaintextRenderer.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/ViewRenderer.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Pipeline/TemplateParser.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Pipeline/TemplateSerializer.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Utilities/TemplateError.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateIterator.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Contains.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Utilities/Exports.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/DateFormat.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateConstant.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Comment.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Print.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Count.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateDataContext.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/TagContext.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Raw.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateRaw.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/View.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateSyntax.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Users/petercernak/vapor/TILApp/Build/Products/Debug/NIO.framework/Modules/NIO.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/Async.framework/Modules/Async.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/Service.framework/Modules/Service.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/Core.framework/Modules/Core.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/Debugging.framework/Modules/Debugging.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/COperatingSystem.framework/Modules/COperatingSystem.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/NIOConcurrencyHelpers.framework/Modules/NIOConcurrencyHelpers.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/Bits.framework/Modules/Bits.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/NIOFoundationCompat.framework/Modules/NIOFoundationCompat.swiftmodule/x86_64.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/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 /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/petercernak/vapor/TILApp/.build/checkouts/swift-nio.git--2128188973977302459/Sources/CNIOAtomics/include/cpp_magic.h /Users/petercernak/vapor/TILApp/.build/checkouts/swift-nio.git--2128188973977302459/Sources/CNIODarwin/include/c_nio_darwin.h /Users/petercernak/vapor/TILApp/.build/checkouts/swift-nio.git--2128188973977302459/Sources/CNIOAtomics/include/c-atomics.h /Users/petercernak/vapor/TILApp/.build/checkouts/swift-nio.git--2128188973977302459/Sources/CNIOLinux/include/c_nio_linux.h /Users/petercernak/vapor/TILApp/TILApp.xcodeproj/GeneratedModuleMap/CNIOSHA1/module.modulemap /Users/petercernak/vapor/TILApp/.build/checkouts/swift-nio-zlib-support.git--6538424668019974428/module.modulemap /Users/petercernak/vapor/TILApp/TILApp.xcodeproj/GeneratedModuleMap/CNIODarwin/module.modulemap /Users/petercernak/vapor/TILApp/TILApp.xcodeproj/GeneratedModuleMap/CNIOAtomics/module.modulemap /Users/petercernak/vapor/TILApp/TILApp.xcodeproj/GeneratedModuleMap/CNIOLinux/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/petercernak/vapor/TILApp/Build/Intermediates.noindex/TILApp.build/Debug/TemplateKit.build/Objects-normal/x86_64/PlaintextRenderer~partial.swiftmodule : /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Data/TemplateData.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateEmbed.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Deprecated.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateSource.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Data/TemplateDataStorage.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Pipeline/ASTCache.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Data/TemplateDataRepresentable.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Utilities/HTMLEscape.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateSyntaxType.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Uppercase.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Lowercase.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Capitalize.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateTag.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateConditional.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateCustom.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateExpression.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Var.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Data/TemplateDataEncoder.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateIdentifier.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Pipeline/TemplateByteScanner.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Pipeline/TemplateRenderer.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/TagRenderer.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Pipeline/PlaintextRenderer.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/ViewRenderer.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Pipeline/TemplateParser.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Pipeline/TemplateSerializer.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Utilities/TemplateError.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateIterator.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Contains.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Utilities/Exports.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/DateFormat.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateConstant.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Comment.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Print.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Count.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateDataContext.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/TagContext.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Raw.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateRaw.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/View.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateSyntax.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Users/petercernak/vapor/TILApp/Build/Products/Debug/NIO.framework/Modules/NIO.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/Async.framework/Modules/Async.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/Service.framework/Modules/Service.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/Core.framework/Modules/Core.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/Debugging.framework/Modules/Debugging.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/COperatingSystem.framework/Modules/COperatingSystem.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/NIOConcurrencyHelpers.framework/Modules/NIOConcurrencyHelpers.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/Bits.framework/Modules/Bits.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/NIOFoundationCompat.framework/Modules/NIOFoundationCompat.swiftmodule/x86_64.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/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 /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/petercernak/vapor/TILApp/.build/checkouts/swift-nio.git--2128188973977302459/Sources/CNIOAtomics/include/cpp_magic.h /Users/petercernak/vapor/TILApp/.build/checkouts/swift-nio.git--2128188973977302459/Sources/CNIODarwin/include/c_nio_darwin.h /Users/petercernak/vapor/TILApp/.build/checkouts/swift-nio.git--2128188973977302459/Sources/CNIOAtomics/include/c-atomics.h /Users/petercernak/vapor/TILApp/.build/checkouts/swift-nio.git--2128188973977302459/Sources/CNIOLinux/include/c_nio_linux.h /Users/petercernak/vapor/TILApp/TILApp.xcodeproj/GeneratedModuleMap/CNIOSHA1/module.modulemap /Users/petercernak/vapor/TILApp/.build/checkouts/swift-nio-zlib-support.git--6538424668019974428/module.modulemap /Users/petercernak/vapor/TILApp/TILApp.xcodeproj/GeneratedModuleMap/CNIODarwin/module.modulemap /Users/petercernak/vapor/TILApp/TILApp.xcodeproj/GeneratedModuleMap/CNIOAtomics/module.modulemap /Users/petercernak/vapor/TILApp/TILApp.xcodeproj/GeneratedModuleMap/CNIOLinux/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/petercernak/vapor/TILApp/Build/Intermediates.noindex/TILApp.build/Debug/TemplateKit.build/Objects-normal/x86_64/PlaintextRenderer~partial.swiftdoc : /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Data/TemplateData.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateEmbed.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Deprecated.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateSource.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Data/TemplateDataStorage.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Pipeline/ASTCache.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Data/TemplateDataRepresentable.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Utilities/HTMLEscape.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateSyntaxType.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Uppercase.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Lowercase.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Capitalize.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateTag.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateConditional.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateCustom.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateExpression.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Var.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Data/TemplateDataEncoder.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateIdentifier.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Pipeline/TemplateByteScanner.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Pipeline/TemplateRenderer.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/TagRenderer.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Pipeline/PlaintextRenderer.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/ViewRenderer.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Pipeline/TemplateParser.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Pipeline/TemplateSerializer.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Utilities/TemplateError.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateIterator.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Contains.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Utilities/Exports.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/DateFormat.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateConstant.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Comment.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Print.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Count.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateDataContext.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/TagContext.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/Tag/Raw.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateRaw.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/View.swift /Users/petercernak/vapor/TILApp/.build/checkouts/template-kit.git-9048208343057795534/Sources/TemplateKit/AST/TemplateSyntax.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Users/petercernak/vapor/TILApp/Build/Products/Debug/NIO.framework/Modules/NIO.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/Async.framework/Modules/Async.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/Service.framework/Modules/Service.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/Core.framework/Modules/Core.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/Debugging.framework/Modules/Debugging.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/COperatingSystem.framework/Modules/COperatingSystem.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/NIOConcurrencyHelpers.framework/Modules/NIOConcurrencyHelpers.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/Bits.framework/Modules/Bits.swiftmodule/x86_64.swiftmodule /Users/petercernak/vapor/TILApp/Build/Products/Debug/NIOFoundationCompat.framework/Modules/NIOFoundationCompat.swiftmodule/x86_64.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/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 /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/petercernak/vapor/TILApp/.build/checkouts/swift-nio.git--2128188973977302459/Sources/CNIOAtomics/include/cpp_magic.h /Users/petercernak/vapor/TILApp/.build/checkouts/swift-nio.git--2128188973977302459/Sources/CNIODarwin/include/c_nio_darwin.h /Users/petercernak/vapor/TILApp/.build/checkouts/swift-nio.git--2128188973977302459/Sources/CNIOAtomics/include/c-atomics.h /Users/petercernak/vapor/TILApp/.build/checkouts/swift-nio.git--2128188973977302459/Sources/CNIOLinux/include/c_nio_linux.h /Users/petercernak/vapor/TILApp/TILApp.xcodeproj/GeneratedModuleMap/CNIOSHA1/module.modulemap /Users/petercernak/vapor/TILApp/.build/checkouts/swift-nio-zlib-support.git--6538424668019974428/module.modulemap /Users/petercernak/vapor/TILApp/TILApp.xcodeproj/GeneratedModuleMap/CNIODarwin/module.modulemap /Users/petercernak/vapor/TILApp/TILApp.xcodeproj/GeneratedModuleMap/CNIOAtomics/module.modulemap /Users/petercernak/vapor/TILApp/TILApp.xcodeproj/GeneratedModuleMap/CNIOLinux/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
|
D
|
/**
* Compiler implementation of the
* $(LINK2 http://www.dlang.org, D programming language).
*
* Manage the memory allocated on the runtime stack to save Common Subexpressions (CSE).
*
* Copyright: Copyright (C) 1985-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/cgcse.d, backend/cgcse.d)
* Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/backend/cgcse.d
*/
module dmd.backend.cgcse;
version (SCPP)
version = COMPILE;
version (MARS)
version = COMPILE;
version (COMPILE)
{
import core.stdc.stdio;
import core.stdc.stdlib;
import core.stdc.string;
import dmd.backend.cc;
import dmd.backend.cdef;
import dmd.backend.code;
import dmd.backend.code_x86;
import dmd.backend.el;
import dmd.backend.global;
import dmd.backend.ty;
import dmd.backend.barray;
extern (C++):
nothrow:
@safe:
/****************************
* Table of common subexpressions stored on the stack.
* csextab[] array of info on saved CSEs
* CSEpe pointer to saved elem
* CSEregm mask of register that was saved (so for multi-
* register variables we know which part we have)
*/
enum CSEload = 1; // set if the CSE was ever loaded
enum CSEsimple = 2; // CSE can be regenerated easily
struct CSE
{
elem* e; // pointer to elem
code csimple; // if CSEsimple, this is the code to regenerate it
regm_t regm; // mask of register stored there
int slot; // slot number
ubyte flags; // flag bytes
nothrow:
/************************
* Initialize at function entry.
*/
@trusted
static void initialize()
{
csextab.setLength(64); // reserve some space
}
/************************
* Start for generating code for this function.
* After ending generation, call finish().
*/
@trusted
static void start()
{
csextab.setLength(0); // no entries in table yet
slotSize = REGSIZE;
alignment_ = REGSIZE;
}
/*******************************
* Create and add a new CSE entry.
* Returns:
* pointer to created entry
*/
@trusted
static CSE* add()
{
foreach (ref cse; csextab)
{
if (cse.e == null) // can share with previously used one
{
cse.flags &= CSEload;
return &cse;
}
}
// create new one
const slot = cast(int)csextab.length;
CSE cse;
cse.slot = slot;
csextab.push(cse);
return &csextab[slot];
}
/********************************
* Update slot size and alignment to worst case.
*
* A bit wasteful of stack space.
* Params: e = elem with a size and an alignment
*/
@trusted
static void updateSizeAndAlign(elem* e)
{
if (I16)
return;
const sz = tysize(e.Ety);
if (slotSize < sz)
slotSize = sz;
const alignsize = el_alignsize(e);
static if (0)
printf("set slot size = %d, sz = %d, al = %d, ty = x%x, %s\n",
slotSize, cast(int)sz, cast(int)alignsize,
cast(int)tybasic(e.Ety), funcsym_p.Sident.ptr);
if (alignsize >= 16 && TARGET_STACKALIGN >= 16)
{
alignment_ = alignsize;
STACKALIGN = alignsize;
enforcealign = true;
}
}
/****
* Get range of all CSEs filtered by matching `e`,
* starting with most recent.
* Params: e = elem to match
* Returns:
* input range
*/
@trusted
static auto filter(const elem* e)
{
struct Range
{
const elem* e;
int i;
nothrow:
bool empty()
{
while (i)
{
if (csextab[i - 1].e == e)
return false;
--i;
}
return true;
}
ref CSE front() { return csextab[i - 1]; }
void popFront() { --i; }
}
return Range(e, cast(int)csextab.length);
}
/*********************
* Remove instances of `e` from CSE table.
* Params: e = elem to remove
*/
@trusted
static void remove(const elem* e)
{
foreach (ref cse; csextab[])
{
if (cse.e == e)
cse.e = null;
}
}
/************************
* Create mask of registers from CSEs that refer to `e`.
* Params: e = elem to match
* Returns:
* mask
*/
@trusted
static regm_t mask(const elem* e)
{
regm_t result = 0;
foreach (ref cse; csextab[])
{
if (cse.e)
elem_debug(cse.e);
if (cse.e == e)
result |= cse.regm;
}
return result;
}
/***
* Finish generating code for this function.
*
* Get rid of unused cse temporaries by shrinking the array.
* References: loaded()
*/
@trusted
static void finish()
{
while (csextab.length != 0 && (csextab[csextab.length - 1].flags & CSEload) == 0)
csextab.setLength(csextab.length - 1);
}
/**** The rest of the functions can be called only after finish() ****/
/******************
* Returns:
* total size used by CSE's
*/
@trusted
static uint size()
{
return cast(uint)csextab.length * CSE.slotSize;
}
/*********************
* Returns:
* alignment needed for CSE region of the stack
*/
@trusted
static uint alignment()
{
return alignment_;
}
/// Returns: offset of slot i from start of CSE region
@trusted
static uint offset(int i)
{
return i * slotSize;
}
/// Returns: true if CSE was ever loaded
@trusted
static bool loaded(int i)
{
return i < csextab.length && // array could be shrunk for non-CSEload entries
(csextab[i].flags & CSEload);
}
private:
__gshared:
Barray!CSE csextab; // CSE table (allocated for each function)
uint slotSize; // size of each slot in table
uint alignment_; // alignment for the table
}
/********************
* The above implementation of CSE is inefficient:
* 1. the optimization to not store CSE's that are never reloaded is based on the slot number,
* not the CSE. This means that when a slot is shared among multiple CSEs, it is treated
* as "reloaded" even if only one of the CSEs in that slot is reloaded.
* 2. updateSizeAndAlign should only be run when reloading when (1) is fixed.
* 3. all slots are aligned to worst case alignment of any slot.
* 4. unused slots still get memory allocated to them if they aren't at the end of the
* slot table.
*
* The slot number should be unique to each CSE, and allocation of actual slots should be
* done after the code is generated, not during generation.
*/
}
|
D
|
something that can be used as an official medium of payment
someone who waits on or tends to or attends to the needs of another
a formal proposal to buy at a specified price
car attached to a locomotive to carry fuel and water
a boat for communication between ship and shore
ship that usually provides supplies to other ships
offer or present for acceptance
propose a payment
make a tender of
make tender or more tender as by marinating, pounding, or applying a tenderizer
given to sympathy or gentleness or sentimentality
hurting
young and immature
having or displaying warmth or affection
easy to cut or chew
physically untoughened
(used of boats) inclined to heel over easily under sail
(of plants) not hardy
|
D
|
/**
Copyright 2018 Mark Fisher
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
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 AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
**/
module dxx.example.basic.app;
private import ctini.ctini;
private import aermicioi.aedi;
private import std.stdio;
private import std.experimental.logger;
private import std.conv;
private import std.string;
private import std.file;
private import dxx.app;
private import dxx.util;
enum CFG = DXXConfig ~ IniConfig!"basic.ini";
mixin __Text!(CFG.basic.lang);
class Example {
};
alias BasicParam = Tuple!(
string,"name",
uint,"age",
Tuple!(
// PluginDef[string],"plugins"
//PluginDef, "plugin"
Tuple!(
string,"pluginDirs"
),"config",
Tuple!(
string,"name"
),"workspace",
Tuple!(
string,"name",
string,"path",
string,"pluginVersion"
),"plugin",
),"dxx"
);
/*
@component
class BasicComponents : RuntimeComponents!BasicParam {
override void registerAppDependencies(InjectionContainer injector) {
debug {
sharedLog.info("BasicComponents registerAppDependencies()");
}
}
shared static this() {
new BasicComponents;
}
mixin registerComponent!BasicComponents;
};
*/
mixin registerComponent!(PlatformRuntime!BasicParam);
auto loadPlugin(PluginDef def) {
auto paths = getInjectorProperty!string(CFG.keys.pluginDirs);
foreach(path;paths.split(':')) {
if(PluginLoader.pluginFileName(def.name,path).exists) {
MsgLog.info("Load: "~def.name);
auto l = resolveInjector!PluginLoader();
assert(l);
l.load(def.name,path);
return l;
}
}
return null;
}
int main(string[] args) {
//scope(exit)terminateInjector;
//auto m = new BasicComponents;
debug {
sharedLog.info("basic main");
}
MsgLog.info(MsgText!(CFG.basicMessages.MSG_APP_BANNER));
// MsgLog.info("name = " ~ getInjectorProperty!string("name"));
// MsgLog.info("age = " ~ (getInjectorProperty!uint("age")).to!string);
//string n = getInjectorProperty!string("name");
//string n = Properties.__("name");
string n = (getInjectorProperty!string("name"));
MsgLog.info("name = " ~ n);
//sharedLog.info("name = " ~ getInjectorProperty!string("name"));
//auto age = (getInjectorProperty!uint("age"));
//MsgLog.info("age = " ~ age.to!string);
/*version(Posix) {
l.load("examples/plugin/bin/libdxx_plugin.so");
} else version(Windows) {
l.load("examples/plugin/bin/dxx_plugin.dll");
} else {
// ...
}*/
//MsgLog.info(CFG.keys.pluginDirs ~ " = " ~ paths);
/*auto plugin = "dxx_plugin";
foreach(p;paths.split(',')) {
MsgLog.info("Path: " ~ p);
if(PluginLoader.pluginFileName(plugin,p).exists) {
MsgLog.info("Load: dxx_plugin");
l.load(plugin,p);
break;
}
}*/
//auto plugins = getInjectorProperty!(PluginDef[])("dxx.plugins");
//auto plugin = getInjectorProperty!(PluginDef)("dxx.plugin");
//auto plugin=Tuple!(string,"name")("dxx_plugin");
//MsgLog.info("plugin = " ~ plugin.name);
PluginDef def;
def.name = getInjectorProperty!(string)("dxx.plugin.name");
auto plugin = def.loadPlugin();
//foreach(plugin;plugins) {
//}
assert(plugin);
plugin.update;
scope(exit)destroy(plugin);
//destroy(l);
MsgLog.info("Done.");
return 0;
}
|
D
|
INSTANCE Mod_7022_BDT_Oschust_MT (Npc_Default)
{
// ------ NSC ------
name = "Oschust";
guild = GIL_OUT;
id = 7022;
voice = 4;
flags = 2;
npctype = NPCTYPE_MAIN;
level = 30;
// ------ AIVARS ------
aivar[AIV_ToughGuy] = TRUE;
// ------ Attribute ------
attribute[ATR_HITPOINTS_MAX] = 80;
attribute[ATR_HITPOINTS] = 80;
attribute[ATR_STRENGTH] = 20;
// ------ Kampf-Taktik ------
fight_tactic = FAI_HUMAN_NORMAL;
// ------ Equippte Waffen ------
EquipItem (self, ItMw_1h_Vlk_Dagger);
// ------ Inventory ------
CreateInvItems (self, ItMi_Sulfur, 3);
CreateInvItems (self, ItMi_Alchemy_Alcohol_01, 2);
CreateInvItems (self, ItMi_SilverRing, 1);
CreateInvItems (self, ItMi_GoldRing, 2);
CreateInvItems (self, ItMi_GoldNugget_Addon, 5);
CreateInvItems (self, ItMw_2H_Axe_L_01, 1);
// ------ visuals ------
B_SetNpcVisual (self, MALE, "Hum_Head_Psionic", Face_N_Weak_BaalNetbek, BodyTex_N, ITAR_BDT_M_01);
Mdl_SetModelFatness (self, 1);
//Mdl_ApplyOverlayMds (self, "Humans_Tired.mds");
// ------ NSC-relevante Talente vergeben ------
B_GiveNpcTalents (self);
// ------ Kampf-Talente ------
B_SetFightSkills (self, 50);
// ------ TA anmelden ------
daily_routine = Rtn_Start_7022;
};
FUNC VOID Rtn_Start_7022 ()
{
TA_Potion_Alchemy (07,00,09,00,"HOEHLE_34");
TA_Smith_Fire (09,00,10,00,"HOEHLE_33");
TA_Smith_Anvil (10,00,11,00,"HOEHLE_33");
TA_Smith_Cool (11,00,12,00,"HOEHLE_33");
TA_Smith_Sharp (12,00,13,00,"HOEHLE_33");
TA_Potion_Alchemy (13,00,15,00,"HOEHLE_34");
TA_Smith_Fire (15,00,16,00,"HOEHLE_33");
TA_Smith_Anvil (16,00,17,00,"HOEHLE_33");
TA_Smith_Cool (17,00,18,00,"HOEHLE_33");
TA_Smith_Sharp (18,00,19,00,"HOEHLE_33");
TA_Potion_Alchemy (19,00,21,00,"HOEHLE_34");
TA_Sleep (21,00,07,00,"HOEHLE_24");
};
FUNC VOID Rtn_Tot_7022 ()
{
TA_Drained (08,00,20,00,"TOT");
TA_Drained (20,00,08,00,"TOT");
};
|
D
|
/// Authors: Aziz Köksal, Jari-Matti Mäkelä
/// License: GPL3
/// $(Maturity average)
module cmd.DDocXML;
import cmd.Highlight,
cmd.DDocEmitter;
import drc.doc.Macro;
import drc.ast.Declarations;
import drc.semantic.Module;
import common;
/// Traverses the syntax tree and writes DDoc макрос в a ткст буфер.
class РЯРЭмиттерДДок : ЭмиттерДДок
{
/// Constructs a РЯРЭмиттерДДок object.
this(Модуль модуль, ТаблицаМакросов мтаблица, бул включатьНедокументированное,
ПодсветчикСем псвСем)
{
super(модуль, мтаблица, включатьНедокументированное, псвСем);
}
alias Декларация D;
override:
D посети(ДекларацияФункции d)
{
if (!ddoc(d))
return d;
auto тип = textSpan(d.типВозврата.типОснова.начало, d.типВозврата.конец);
DECL({
пиши("function, ");
пиши("$(TYPE ");
пиши("$(RETURNS ", escape(тип), ")");
writeTemplateParams();
writeParams(d.парамы);
пиши(")");
SYMBOL(d.имя.ткт, "function", d);
}, d);
DESC();
return d;
}
D посети(ДекларацияПеременных d)
{
if (!ddoc(d))
return d;
сим[] тип = "auto";
if (d.узелТипа)
тип = textSpan(d.узелТипа.типОснова.начало, d.узелТипа.конец);
foreach (имя; d.имена)
DECL({ пиши("переменная, "); пиши("$(TYPE ", escape(тип), ")");
SYMBOL(имя.ткт, "переменная", d);
}, d);
DESC();
return d;
}
}
|
D
|
; Copyright (C) 2008 The Android Open Source Project
;
; 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.
.source T_iget_boolean_15.java
.class public dot.junit.opcodes.iget_boolean.d.T_iget_boolean_15
.super java/lang/Object
.field public i1 S
.method public <init>()V
.limit regs 1
invoke-direct {v0}, java/lang/Object/<init>()V
return-void
.end method
.method public run()V
.limit regs 3
iget-boolean v0, v2, dot.junit.opcodes.iget_boolean.d.T_iget_boolean_15.i1 S
return-void
.end method
|
D
|
the use of speech for informal exchange of views or ideas or information etc.
|
D
|
/**
HTML character entity escaping - taken from the vibe.d project.
TODO: Make things @safe once Appender is.
Copyright: © 2012-2014 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 diet.internal.html;
import std.array;
import std.conv;
import std.range;
/** Returns the HTML escaped version of a given string.
*/
string htmlEscape(R)(R str)
if (isInputRange!R)
{
if (__ctfe) { // appender is a performance/memory hog in ctfe
StringAppender dst;
filterHTMLEscape(dst, str);
return dst.data;
} else {
auto dst = appender!string();
filterHTMLEscape(dst, str);
return dst.data;
}
}
///
unittest {
assert(htmlEscape(`"Hello", <World>!`) == `"Hello", <World>!`);
}
/** Writes the HTML escaped version of a given string to an output range.
*/
void filterHTMLEscape(R, S)(ref R dst, S str, HTMLEscapeFlags flags = HTMLEscapeFlags.escapeNewline)
if (isOutputRange!(R, dchar) && isInputRange!S)
{
for (;!str.empty;str.popFront())
filterHTMLEscape(dst, str.front, flags);
}
/** Returns the HTML escaped version of a given string (also escapes double quotes).
*/
string htmlAttribEscape(R)(R str)
if (isInputRange!R)
{
if (__ctfe) { // appender is a performance/memory hog in ctfe
StringAppender dst;
filterHTMLAttribEscape(dst, str);
return dst.data;
} else {
auto dst = appender!string();
filterHTMLAttribEscape(dst, str);
return dst.data;
}
}
///
unittest {
assert(htmlAttribEscape(`"Hello", <World>!`) == `"Hello", <World>!`);
}
/** Writes the HTML escaped version of a given string to an output range (also escapes double quotes).
*/
void filterHTMLAttribEscape(R, S)(ref R dst, S str)
if (isOutputRange!(R, dchar) && isInputRange!S)
{
for (; !str.empty; str.popFront())
filterHTMLEscape(dst, str.front, HTMLEscapeFlags.escapeNewline|HTMLEscapeFlags.escapeQuotes);
}
/** Returns the HTML escaped version of a given string (escapes every character).
*/
string htmlAllEscape(R)(R str)
if (isInputRange!R)
{
if (__ctfe) { // appender is a performance/memory hog in ctfe
StringAppender dst;
filterHTMLAllEscape(dst, str);
return dst.data;
} else {
auto dst = appender!string();
filterHTMLAllEscape(dst, str);
return dst.data;
}
}
///
unittest {
assert(htmlAllEscape("Hello!") == "Hello!");
}
/** Writes the HTML escaped version of a given string to an output range (escapes every character).
*/
void filterHTMLAllEscape(R, S)(ref R dst, S str)
if (isOutputRange!(R, dchar) && isInputRange!S)
{
for (; !str.empty; str.popFront()) {
dst.put("&#");
dst.put(to!string(cast(uint)str.front));
dst.put(';');
}
}
/**
Minimally escapes a text so that no HTML tags appear in it.
*/
string htmlEscapeMin(R)(R str)
if (isInputRange!R)
{
auto dst = appender!string();
for (; !str.empty; str.popFront())
filterHTMLEscape(dst, str.front, HTMLEscapeFlags.escapeMinimal);
return dst.data();
}
void htmlEscape(R, T)(ref R dst, T val)
{
import std.format : formattedWrite;
auto r = HTMLEscapeOutputRange!R(dst, HTMLEscapeFlags.defaults);
() @trusted { return &r; } ().formattedWrite("%s", val);
}
@safe unittest {
static struct R { @safe @nogc nothrow: void put(char) {} void put(dchar) {} void put(in char[]) {}}
R r;
r.htmlEscape("foo");
r.htmlEscape(12);
r.htmlEscape(12.4);
}
void htmlAttribEscape(R, T)(ref R dst, T val)
{
import std.format : formattedWrite;
auto r = HTMLEscapeOutputRange!R(dst, HTMLEscapeFlags.attribute);
() @trusted { return &r; } ().formattedWrite("%s", val);
}
/**
Writes the HTML escaped version of a character to an output range.
*/
void filterHTMLEscape(R)(ref R dst, dchar ch, HTMLEscapeFlags flags = HTMLEscapeFlags.escapeNewline )
{
switch (ch) {
default:
if (flags & HTMLEscapeFlags.escapeUnknown) {
dst.put("&#");
dst.put(to!string(cast(uint)ch));
dst.put(';');
} else dst.put(ch);
break;
case '"':
if (flags & HTMLEscapeFlags.escapeQuotes) dst.put(""");
else dst.put('"');
break;
case '\'':
if (flags & HTMLEscapeFlags.escapeQuotes) dst.put("'");
else dst.put('\'');
break;
case '\r', '\n':
if (flags & HTMLEscapeFlags.escapeNewline) {
dst.put("&#");
dst.put(to!string(cast(uint)ch));
dst.put(';');
} else dst.put(ch);
break;
case 'a': .. case 'z': goto case;
case 'A': .. case 'Z': goto case;
case '0': .. case '9': goto case;
case ' ', '\t', '-', '_', '.', ':', ',', ';',
'#', '+', '*', '?', '=', '(', ')', '/', '!',
'%' , '{', '}', '[', ']', '`', '´', '$', '^', '~':
dst.put(cast(char)ch);
break;
case '<': dst.put("<"); break;
case '>': dst.put(">"); break;
case '&': dst.put("&"); break;
}
}
enum HTMLEscapeFlags {
escapeMinimal = 0,
escapeQuotes = 1<<0,
escapeNewline = 1<<1,
escapeUnknown = 1<<2,
defaults = escapeNewline,
attribute = escapeNewline|escapeQuotes
}
private struct HTMLEscapeOutputRange(R)
{
R* dst;
HTMLEscapeFlags flags;
char[4] u8seq;
uint u8seqfill;
this(ref R dst, HTMLEscapeFlags flags)
@safe nothrow @nogc {
() @trusted { this.dst = &dst; } ();
this.flags = flags;
}
@disable this(this);
void put(char ch)
{
import std.utf : stride;
assert(u8seqfill < u8seq.length);
u8seq[u8seqfill++] = ch;
if (u8seqfill >= 4 || stride(u8seq) <= u8seqfill) {
char[] str = u8seq[0 .. u8seqfill];
put(u8seq[0 .. u8seqfill]);
u8seqfill = 0;
}
}
void put(dchar ch) { filterHTMLEscape(*dst, ch, flags); }
void put(in char[] str) { foreach (dchar ch; str) put(ch); }
static assert(isOutputRange!(HTMLEscapeOutputRange, char));
}
unittest { // issue #36
auto dst = appender!string();
auto rng = HTMLEscapeOutputRange!(typeof(dst))(dst, HTMLEscapeFlags.attribute);
rng.put("foo\"bar");
assert(dst.data == "foo"bar");
}
private struct StringAppender {
string data;
@safe:
void put(string s) { data ~= s; }
void put(char ch) { data ~= ch; }
void put(dchar ch) {
import std.utf;
char[4] dst;
data ~= dst[0 .. encode(dst, ch)];
}
}
|
D
|
/Users/oyo02699/apps/easycrm/easycrm-api/target/rls/debug/deps/safemem-9d8792bf48449649.rmeta: /Users/oyo02699/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/safemem-0.3.3/src/lib.rs
/Users/oyo02699/apps/easycrm/easycrm-api/target/rls/debug/deps/safemem-9d8792bf48449649.d: /Users/oyo02699/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/safemem-0.3.3/src/lib.rs
/Users/oyo02699/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/safemem-0.3.3/src/lib.rs:
|
D
|
module safearg.main;
import std.algorithm;
import std.array;
import std.conv;
import std.getopt;
import std.process;
import std.range;
import std.stdio;
import std.traits;
import scriptlike.fail;
import safearg.packageVersion;
immutable helpBanner =
`safeArg `~packageVersion~`: <https://github.com/Abscissa/safeArg>
Built on `~packageTimestamp~`
-----------------------------------------------------
Takes a null-delimited list of args on stdin, and passes them as command line
arguments to any program you choose.
This is more secure, less error-prone, and more portable than using the shell's
command substitution or otherwise relying on the shell to parse args.
USAGE:
safearg [options] program_to_run [initial-arguments] < INPUT
INPUT:
A null-delimited (by default) list of command line arguments to app.
EXAMPLE:
printf 'mid1\0mid2' | safearg --post=end1 --post=end2 program_to_run first
The above (effectively) runs:
program_to_run first mid1 mid2 end1 end2
EXAMPLE:
printf 'middle 1\0middle 2' | safearg --post=end printf '[%s]\n' first
The above (effectively) runs:
printf '[%s]\n' 'middle 1' 'middle 2' end
And outputs:
[first]
[middle 1]
[middle 2]
[end]
OPTIONS:`;
bool useNewlineDelim = false;
string alternateDelim = null;
string[] postArgs = null;
bool verbose = false;
// Returns: Should program execution continue?
bool doGetOpt(ref string[] args)
{
immutable usageHint = "For usage, run: safearg --help";
bool showVersion;
try
{
auto helpInfo = args.getopt(
std.getopt.config.stopOnFirstNonOption,
"n|newline", `Use \n and \r\n newlines as delimiter instead of \0`, &useNewlineDelim,
"delim", `Use alternate character as delimiter instead of \0 (ex: --delim=,)`, &alternateDelim,
"p|post", `Extra "post"-args to be added at the end of the command line.`, &postArgs,
"v|verbose", "Echo the generated command to stdout before running.", &verbose,
"version", "Show safearg's version number and exit", &showVersion,
);
if(helpInfo.helpWanted)
{
defaultGetoptPrinter(helpBanner, helpInfo.options);
return false;
}
}
catch(GetOptException e)
fail(e.msg ~ "\n" ~ usageHint);
if(showVersion)
{
writeln(packageVersion);
return false;
}
if(alternateDelim.length > 1)
fail("Value for --delim=VALUE must be only byte\n" ~ usageHint);
if(useNewlineDelim && alternateDelim)
fail("Cannot use both --newline and --delim=VALUE\n" ~ usageHint);
if(args.length < 2)
fail("Missing program to run\n" ~ usageHint);
return true;
}
version(unittest) void main() {} else
int main(string[] args)
{
// Handle our own args
if(!doGetOpt(args))
return 0;
// Parse input
string[] outArgs;
auto inputRange = stdin.byChunk(1024).joiner();
if(useNewlineDelim)
outArgs = parseNewlineDelimited(inputRange);
else if(alternateDelim)
outArgs = parseDelimited(inputRange, cast(const(ubyte)) alternateDelim[0]);
else
outArgs = parseNullDelimited(inputRange);
// Build and echo command
string[] cmd = args[1..$] ~ outArgs ~ postArgs;
if(verbose)
stdout.rawWrite(escapeShellCommand(cmd)~"\n");
// Invoke command
try
return spawnProcess(cmd).wait();
catch(ProcessException e)
{
fail(e.msg);
assert(0);
}
}
string[] parseNullDelimited(T)(T inputRange)
if(isInputRange!T && is(ElementType!T == ubyte))
{
return parseDelimited(inputRange, cast(const(ubyte)) '\0');
}
string[] parseNewlineDelimited(T)(T inputRange)
if(isInputRange!T && is(ElementType!T == ubyte))
{
return parseDelimited(inputRange, cast(const(ubyte)) '\n', true, cast(const(ubyte)) '\r');
}
string[] parseDelimited(T)(T inputRange, const ubyte delim, bool useLookBehind=false, const ubyte lookBehind=ubyte.init)
if(isInputRange!T && is(ElementType!T == ubyte))
{
string[] result;
ubyte prevByte;
size_t length = 0;
auto buf = appender!(ubyte[])();
foreach(dataByte; inputRange)
{
length++;
//writeln(cast(char)dataByte);
if(dataByte == delim)
{
auto str = cast(string) buf.data.idup;
if(useLookBehind && length > 1 && prevByte == lookBehind)
str = str[0..$-1];
result ~= str;
buf.clear();
length = 0;
}
else
buf.put(dataByte);
prevByte = dataByte;
}
result ~= cast(string) buf.data.idup;
//writeln("--------------------");
//foreach(elem; result)
// writeln(cast(string)elem);
return result;
}
unittest
{
auto convert(string str)
{
return cast(ubyte[]) str.dup;
}
writeln("Testing parseNullDelimited");
assert(
parseNullDelimited( convert("abc\0'hello world'\0def\0\0_123") ) ==
["abc", "'hello world'", "def", "", "_123"]
);
assert(
parseNullDelimited( convert("\0'hello world'\0") ) ==
["", "'hello world'", ""]
);
assert(parseNullDelimited( convert("\0") ) == ["", ""]);
assert(parseNullDelimited( convert("a") ) == ["a"]);
assert(parseNullDelimited( convert("") ) == [""]);
writeln("Testing parseNewlineDelimited");
assert(
parseNewlineDelimited(convert("abc\n'hello world'\r\ndef\r\n\r\n123\n\n456") ) ==
["abc", "'hello world'", "def", "", "123", "", "456"]
);
assert(
parseNewlineDelimited( convert("\n'hello world'\r\n") ) ==
["", "'hello world'", ""]
);
assert(
parseNewlineDelimited( convert("\r\n'hello world'\n") ) ==
["", "'hello world'", ""]
);
assert(parseNewlineDelimited( convert("\n") ) == ["", ""]);
assert(parseNewlineDelimited( convert("\r\n") ) == ["", ""]);
assert(parseNewlineDelimited( convert("a") ) == ["a"]);
assert(parseNewlineDelimited( convert("") ) == [""]);
assert(parseNewlineDelimited( convert("abc\rdef") ) == ["abc\rdef"]);
}
|
D
|
/**
* Treap container for internal usage.
*
* Copyright: Copyright Digital Mars 2014 - 2014.
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
*/
module rt.util.container.treap;
static import common = rt.util.container.common;
import rt.util.random;
import rt.qsort;
struct Treap(E)
{
nothrow:
static struct Node
{
Node* left, right;
E element;
uint priority;
}
@disable this(this);
~this()
{
removeAll();
}
void initialize()
{
rand48.defaultSeed();
}
void insert(E element) @nogc
{
root = insert(root, element);
}
void remove(E element)
{
remove(&root, element);
}
int opApply(scope int delegate(ref E) nothrow dg)
{
return (cast(const)&this).opApply((ref const E e) => dg(*cast(E*)&e));
}
int opApply(scope int delegate(ref const E) nothrow dg) const
{
return opApplyHelper(root, dg);
}
version(unittest)
bool opEquals(E[] elements)
{
size_t i;
foreach (e; this)
{
if (i >= elements.length)
return false;
if (e != elements[i++])
return false;
}
return i == elements.length;
}
void removeAll()
{
removeAll(root);
root = null;
}
version(unittest)
bool valid()
{
return valid(root);
}
version(none)
uint height()
{
static uint height(Node* node)
{
if (!node)
return 0;
auto left = height(node.left);
auto right = height(node.right);
return 1 + (left > right ? left : right);
}
return height(root);
}
version(none)
size_t count()
{
static size_t count(Node* node)
{
if (!node)
return 0;
return count(node.left) + count(node.right) + 1;
}
return count(root);
}
private:
Node* root;
Rand48 rand48;
Node* allocNode(E element) @nogc
{
Node* node = cast(Node*)common.xmalloc(Node.sizeof);
node.left = node.right = null;
node.priority = rand48();
node.element = element;
return node;
}
Node* insert(Node* node, E element) @nogc
{
if (!node)
return allocNode(element);
else if (element < node.element)
{
node.left = insert(node.left, element);
if (node.left.priority < node.priority)
node = rotateR(node);
}
else if (element > node.element)
{
node.right = insert(node.right, element);
if (node.right.priority < node.priority)
node = rotateL(node);
}
else
{} // ignore duplicate
return node;
}
static:
void freeNode(Node* node)
{
common.free(node);
}
Node* rotateL(Node* root)
{
auto pivot = root.right;
root.right = pivot.left;
pivot.left = root;
return pivot;
}
Node* rotateR(Node* root)
{
auto pivot = root.left;
root.left = pivot.right;
pivot.right = root;
return pivot;
}
void remove(Node** ppnode, E element)
{
Node* node = *ppnode;
if (!node)
return; // element not in treap
if (element < node.element)
{
remove(&node.left, element);
}
else if (element > node.element)
{
remove(&node.right, element);
}
else
{
while (node.left && node.right)
{
if (node.left.priority < node.right.priority)
{
*ppnode = rotateR(node);
ppnode = &(*ppnode).right;
}
else
{
*ppnode = rotateL(node);
ppnode = &(*ppnode).left;
}
}
if (!node.left)
*ppnode = node.right;
else
*ppnode = node.left;
freeNode(node);
}
}
void removeAll(Node* node)
{
if (!node)
return;
removeAll(node.left);
removeAll(node.right);
freeNode(node);
}
int opApplyHelper(const Node* node, scope int delegate(ref const E) nothrow dg)
{
if (!node)
return 0;
int result = opApplyHelper(node.left, dg);
if (result)
return result;
result = dg(node.element);
if (result)
return result;
return opApplyHelper(node.right, dg);
}
version(unittest)
bool valid(Node* node)
{
if (!node)
return true;
if (node.left)
{
if (node.left.priority < node.priority)
return false;
if (node.left.element > node.element)
return false;
}
if (node.right)
{
if (node.right.priority < node.priority)
return false;
if (node.right.element < node.element)
return false;
}
return valid(node.left) && valid(node.right);
}
}
unittest
{
// randomized unittest for randomized data structure
import /*cstdlib = */core.stdc.stdlib : rand, srand;
import /*ctime = */core.stdc.time : time;
enum OP { add, remove }
enum initialSize = 1000;
enum randOps = 1000;
Treap!uint treap;
OP[] ops;
uint[] opdata;
treap.initialize();
srand(cast(uint)time(null));
uint[] data;
initialLoop:
foreach (i; 0 .. initialSize)
{
data ~= rand();
treap.insert(data[$-1]);
foreach (e; data[0..$-1])
if (e == data[$-1])
{
data = data[0..$-1];
continue initialLoop;
}
}
_adSort(*cast(void[]*)&data, typeid(data[0]));
assert(treap == data);
assert(treap.valid());
for (int i = randOps; i > 0; --i)
{
ops ~= cast(OP)(rand() < uint.max / 2 ? OP.add: OP.remove);
opdata ~= rand();
}
foreach (op; ops)
{
if (op == OP.add)
{
treap.insert(opdata[0]);
size_t i;
for (i = 0; i < data.length; ++i)
if (data[i] >= opdata[0])
break;
if (i == data.length || data[i] != opdata[0])
{ // not a duplicate
data.length++;
uint tmp = opdata[0];
for (; i < data.length; ++i)
{
uint tmp2 = data[i];
data[i] = tmp;
tmp = tmp2;
}
}
}
else if (!data.length) // nothing to remove
{
opdata = opdata[1..$];
continue;
}
else
{
uint tmp = data[opdata[0]%data.length];
treap.remove(tmp);
size_t i;
for (i = 0; data[i] < tmp; ++i)
{}
for (; i < data.length-1; ++i)
data[i] = data[i+1];
data.length--;
}
assert(treap.valid());
assert(treap == data);
opdata = opdata[1..$];
}
treap.removeAll();
data.length = 0;
assert(treap == data);
}
|
D
|
instance DIA_DRAGON_UNDEAD_EXIT(C_INFO)
{
npc = dragon_undead;
nr = 999;
condition = dia_dragon_undead_exit_condition;
information = dia_dragon_undead_exit_info;
permanent = TRUE;
description = DIALOG_ENDE;
};
func int dia_dragon_undead_exit_condition()
{
if(DRAGONTALK_EXIT_FREE == TRUE)
{
return TRUE;
};
};
func void dia_dragon_undead_exit_info()
{
AI_StopProcessInfos(self);
DRAGONTALK_EXIT_FREE = FALSE;
self.flags = 0;
};
instance DIA_DRAGON_UNDEAD_HELLO(C_INFO)
{
npc = dragon_undead;
nr = 5;
condition = dia_dragon_undead_hello_condition;
information = dia_dragon_undead_hello_info;
important = TRUE;
};
func int dia_dragon_undead_hello_condition()
{
if(Npc_HasItems(other,itmi_innoseye_mis) >= 1)
{
return TRUE;
};
};
func void dia_dragon_undead_hello_info()
{
AI_Output(self,other,"DIA_Dragon_Undead_Hello_20_00"); //Тебе все-таки удалось найти меня. Я долго ждал твоего прихода.
AI_Output(other,self,"DIA_Dragon_Undead_Hello_15_01"); //Да ладно. Не ври, что ты все это планировал.
AI_Output(self,other,"DIA_Dragon_Undead_Hello_20_02"); //(громко смеется) Что ты знаешь о моих намерениях?
AI_Output(self,other,"DIA_Dragon_Undead_Hello_20_03"); //Разве я не послал к тебе Ищущих, чтобы навести тебя на мой след?
AI_Output(self,other,"DIA_Dragon_Undead_Hello_20_04"); //Разве я не оставлял знаки о моем присутствии, столь явные, что ты не мог не заметить их?
if((hero.guild == GIL_DJG) && (DRAGONEGGCOUNTER >= 7))
{
AI_Output(self,other,"DIA_Dragon_Undead_Hello_20_05"); //А разве драконьи яйца, из которых сделаны твои доспехи, не помогли тебе добраться до меня?
};
if(hero.guild == GIL_PAL)
{
AI_Output(self,other,"DIA_Dragon_Undead_Hello_20_06"); //Разве обращенные паладины были недостаточной причиной для тебя, чтобы искать силу, управляющую ими?
};
if(hero.guild == GIL_KDF)
{
AI_Output(self,other,"DIA_Dragon_Undead_Hello_20_07"); //Разве одержимые из твоего племени были недостаточной причиной для тебя, чтобы искать силу, управляющую ими?
};
AI_Output(self,other,"DIA_Dragon_Undead_Hello_20_08"); //Как бы ты не изворачивался, ты не можешь поспорить со всем этим.
Info_AddChoice(dia_dragon_undead_hello,"Хватит болтать.",dia_dragon_undead_hello_attack);
Info_AddChoice(dia_dragon_undead_hello,"По чьему повелению ты ведешь своих прихвостней на войну против человечества?",dia_dragon_undead_hello_auftraggeber);
Info_AddChoice(dia_dragon_undead_hello,"Зачем ты здесь?",dia_dragon_undead_hello_warum);
Info_AddChoice(dia_dragon_undead_hello,"Кто ты?",dia_dragon_undead_hello_wer);
b_logentry(TOPIC_HALLENVONIRDORATH,"Сейчас мой враг - дракон-нежить. Я должен убить его, прежде сем смогу покинуть этот проклятый остров.");
};
func void dia_dragon_undead_hello_wer()
{
AI_Output(other,self,"DIA_Dragon_Undead_Hello_wer_15_00"); //Кто ты?
AI_Output(self,other,"DIA_Dragon_Undead_Hello_wer_20_01"); //(смеется) Ты еще не устал задавать этот вопрос? Поищи внутри себя, глупец. Ты поймешь, кто я.
AI_Output(self,other,"DIA_Dragon_Undead_Hello_wer_20_02"); //У меня нет имени. Так же, как нет имени и у тебя.
AI_Output(self,other,"DIA_Dragon_Undead_Hello_wer_20_03"); //Моим создателем мне дана божественная сила. Также как ты владеешь силой, данной тебе твоим богом.
AI_Output(self,other,"DIA_Dragon_Undead_Hello_wer_20_04"); //Моя судьба - уничтожение этого мира.
if((hero.guild == GIL_MIL) || (hero.guild == GIL_PAL))
{
AI_Output(self,other,"DIA_Dragon_Undead_Hello_wer_20_05"); //Так же, как твоя судьба определяется прямотой и добродетелями паладина.
};
if((hero.guild == GIL_SLD) || (hero.guild == GIL_DJG))
{
AI_Output(self,other,"DIA_Dragon_Undead_Hello_wer_20_06"); //Так же, как твоя рука несет смерть определенным созданиям, охотник на драконов.
};
if(hero.guild == GIL_KDF)
{
AI_Output(self,other,"DIA_Dragon_Undead_Hello_wer_20_07"); //Так же, как твоя судьба - проповедовать веру в Инноса, Маг Огня.
};
AI_Output(self,other,"DIA_Dragon_Undead_Hello_wer_20_08"); //Разве ты не ощущаешь связь, которая соединяет нас? Да. Ты знаешь кто я.
AI_Output(other,self,"DIA_Dragon_Undead_Hello_wer_15_09"); //(смущенно) Нет. Этого не может быть. Ксардас всегда говорил...
AI_Output(self,other,"DIA_Dragon_Undead_Hello_wer_20_10"); //Ксардас слаб, и не представляет угрозы для меня. Ты один достоин противостоять мне.
AI_Output(self,other,"DIA_Dragon_Undead_Hello_wer_20_11"); //Так предопределено. Пришло время принять свою судьбу.
};
func void dia_dragon_undead_hello_warum()
{
AI_Output(other,self,"DIA_Dragon_Undead_Hello_warum_15_00"); //Зачем ты здесь?
AI_Output(self,other,"DIA_Dragon_Undead_Hello_warum_20_01"); //Божественность, дарованная мне, вдохновляет меня погрузить этот мир в море жестокости.
AI_Output(self,other,"DIA_Dragon_Undead_Hello_warum_20_02"); //Только когда последний оплот праведности падет, смогу я, наконец, найти покой.
};
func void dia_dragon_undead_hello_auftraggeber()
{
AI_Output(other,self,"DIA_Dragon_Undead_Hello_Auftraggeber_15_00"); //По чьему повелению ты ведешь своих прихвостней на войну против человечества?
AI_Output(self,other,"DIA_Dragon_Undead_Hello_Auftraggeber_20_01"); //Мой хозяин - Владыка Ночи. Ты знаешь его. Ты можешь слышать его зов.
AI_Output(self,other,"DIA_Dragon_Undead_Hello_Auftraggeber_20_03"); //Мои армии поднимутся из-под земли с его именем на устах и накроют этот мир покровом тьмы.
};
func void dia_dragon_undead_hello_attack()
{
AI_Output(other,self,"DIA_Dragon_Undead_Hello_attack_15_00"); //Хватит болтать. Я загоню тебя обратно под камень, из-под которого ты вылез, монстр.
AI_Output(self,other,"DIA_Dragon_Undead_Hello_attack_20_01"); //(смеется) Ты еще не готов победить меня. Какое-то мгновение отделяет меня от достижения моей цели.
AI_Output(self,other,"DIA_Dragon_Undead_Hello_attack_20_02"); //Твои кости помогут мне выпустить ветра смерти в этот мир.
Npc_RemoveInvItems(other,itmi_innoseye_mis,1);
CreateInvItems(other,itmi_innoseye_discharged_mis,1);
AI_StopProcessInfos(self);
DRAGONTALK_EXIT_FREE = FALSE;
self.flags = 0;
};
|
D
|
instance PAL_200_Hagen(Npc_Default)
{
name[0] = "Лорд Хаген";
guild = GIL_PAL;
id = 200;
voice = 4;
flags = 0;
npcType = npctype_main;
aivar[93] = TRUE;
aivar[AIV_MM_RestEnd] = TRUE;
aivar[AIV_ToughGuy] = TRUE;
aivar[AIV_ToughGuyNewsOverride] = TRUE;
aivar[AIV_IGNORE_Murder] = TRUE;
aivar[AIV_IGNORE_Theft] = TRUE;
aivar[AIV_IGNORE_Sheepkiller] = TRUE;
B_SetAttributesToChapter(self,6);
fight_tactic = FAI_HUMAN_MASTER;
EquipItem(self,ItMw_2H_Blessed_03_Hagen);
CreateInvItems(self,itke_hagen_secretkey,1);
B_CreateAmbientInv(self);
B_SetNpcVisual(self,MALE,"Hum_Head_Fighter",Face_N_Tough_Okyl,BodyTex_N,itar_pal_h_v2_NPC);
Mdl_SetModelFatness(self,1.5);
Mdl_ApplyOverlayMds(self,"Humans_Militia.mds");
B_GiveNpcTalents(self);
B_SetFightSkills(self,100);
daily_routine = Rtn_Start_200;
};
func void Rtn_Start_200()
{
TA_Stand_ArmsCrossed(8,0,15,0,"NW_CITY_HAGEN");
TA_Smalltalk(15,0,18,0,"NW_CITY_HAGEN");
TA_Stand_ArmsCrossed(18,0,20,0,"NW_CITY_HAGEN");
TA_Sit_Throne(20,0,8,0,"NW_CITYHALL_PRIVATE_THRONE");
};
func void Rtn_ShipFree_200()
{
TA_Stand_Guarding(8,0,23,0,"NW_CITY_UPTOWNPARADE_HAGEN");
TA_Stand_Guarding(23,0,8,0,"NW_CITY_UPTOWNPARADE_HAGEN");
};
func void rtn_tot_200()
{
TA_Stand_WP(8,0,20,0,"TOT");
TA_Stand_WP(20,0,8,0,"TOT");
};
func void rtn_campon_200()
{
TA_Stand_Guarding(9,0,23,0,"NW_BIGFARM_SOVET_HAGEN");
TA_Sit_Throne(23,0,9,0,"NW_BIGFARM_CAMPON_HAGEN");
};
func void rtn_inbattle_200()
{
ta_bigfight(8,0,22,0,"NW_BIGFIGHT_HAGEN");
ta_bigfight(22,0,8,0,"NW_BIGFIGHT_HAGEN");
};
func void rtn_fleefrombattle_200()
{
TA_FleeToWp(8,0,22,0,"NW_BIGFARM_PATH_04");
TA_FleeToWp(22,0,8,0,"NW_BIGFARM_PATH_04");
};
|
D
|
<?xml version="1.0" encoding="ASCII"?>
<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="CU.notation#_Z_9KAEvCEeS1u7YNhmeRGw"/>
</availablePage>
<availablePage>
<emfPageIdentifier href="CU.notation#_c41-QUxoEeSqzdXgGf3wTg"/>
</availablePage>
<availablePage>
<emfPageIdentifier href="CU.notation#_8unsIVtSEeS_R9WagCsW3g"/>
</availablePage>
<availablePage>
<emfPageIdentifier href="CU.notation#_K1ttMFtUEeS_R9WagCsW3g"/>
</availablePage>
<availablePage>
<emfPageIdentifier href="CU.notation#_3m84oFtbEeS_R9WagCsW3g"/>
</availablePage>
<availablePage>
<emfPageIdentifier href="CU.notation#_Ln5MgFteEeS_R9WagCsW3g"/>
</availablePage>
<availablePage>
<emfPageIdentifier href="CU.notation#_5RX4MGDvEeSfPtr3YUt7vQ"/>
</availablePage>
</pageList>
<sashModel currentSelection="//@sashModel/@windows.0/@children.0">
<windows>
<children xsi:type="di:TabFolder">
<children>
<emfPageIdentifier href="CU.notation#_c41-QUxoEeSqzdXgGf3wTg"/>
</children>
<children>
<emfPageIdentifier href="CU.notation#_8unsIVtSEeS_R9WagCsW3g"/>
</children>
<children>
<emfPageIdentifier href="CU.notation#_K1ttMFtUEeS_R9WagCsW3g"/>
</children>
<children>
<emfPageIdentifier href="CU.notation#_3m84oFtbEeS_R9WagCsW3g"/>
</children>
<children>
<emfPageIdentifier href="CU.notation#_Ln5MgFteEeS_R9WagCsW3g"/>
</children>
<children>
<emfPageIdentifier href="CU.notation#_5RX4MGDvEeSfPtr3YUt7vQ"/>
</children>
</children>
</windows>
</sashModel>
</di:SashWindowsMngr>
|
D
|
/Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/SQLite.build/SQL/SQLiteBind.swift.o : /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Row/SQLiteData.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteGeneric.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Utilities/Deprecated.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteBind.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Database/SQLiteStorage.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteCreateTable.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteTable.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteAlterTable.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteDataTypeStaticRepresentable.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteQueryExpressionRepresentable.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Row/SQLiteDataConvertible.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Row/SQLiteDataType.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Database/SQLiteDatabase.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Database/DatabaseIdentifier+SQLite.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteBoolLiteral.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteDefaultLiteral.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Row/SQLiteColumn.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteCollation.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Database/SQLiteConnection.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteFunction.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteAlterTableBuilder.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Codable/SQLiteDataDecoder.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Codable/SQLiteRowDecoder.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Codable/SQLiteDataEncoder.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Utilities/SQLiteError.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Utilities/Exports.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Database/SQLiteStatement.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteDropIndex.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLitePrimaryKey.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteQuery.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/SQL.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/Async.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Service.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 /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 /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/DatabaseKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /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 /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/SQLite.build/SQLiteBind~partial.swiftmodule : /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Row/SQLiteData.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteGeneric.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Utilities/Deprecated.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteBind.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Database/SQLiteStorage.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteCreateTable.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteTable.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteAlterTable.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteDataTypeStaticRepresentable.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteQueryExpressionRepresentable.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Row/SQLiteDataConvertible.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Row/SQLiteDataType.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Database/SQLiteDatabase.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Database/DatabaseIdentifier+SQLite.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteBoolLiteral.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteDefaultLiteral.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Row/SQLiteColumn.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteCollation.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Database/SQLiteConnection.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteFunction.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteAlterTableBuilder.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Codable/SQLiteDataDecoder.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Codable/SQLiteRowDecoder.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Codable/SQLiteDataEncoder.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Utilities/SQLiteError.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Utilities/Exports.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Database/SQLiteStatement.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteDropIndex.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLitePrimaryKey.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteQuery.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/SQL.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/Async.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Service.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 /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 /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/DatabaseKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /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 /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/SQLite.build/SQLiteBind~partial.swiftdoc : /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Row/SQLiteData.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteGeneric.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Utilities/Deprecated.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteBind.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Database/SQLiteStorage.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteCreateTable.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteTable.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteAlterTable.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteDataTypeStaticRepresentable.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteQueryExpressionRepresentable.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Row/SQLiteDataConvertible.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Row/SQLiteDataType.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Database/SQLiteDatabase.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Database/DatabaseIdentifier+SQLite.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteBoolLiteral.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteDefaultLiteral.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Row/SQLiteColumn.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteCollation.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Database/SQLiteConnection.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteFunction.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteAlterTableBuilder.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Codable/SQLiteDataDecoder.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Codable/SQLiteRowDecoder.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Codable/SQLiteDataEncoder.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Utilities/SQLiteError.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Utilities/Exports.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/Database/SQLiteStatement.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteDropIndex.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLitePrimaryKey.swift /Users/Khanh/vapor/TILApp/.build/checkouts/sqlite.git--8232814251736334455/Sources/SQLite/SQL/SQLiteQuery.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/SQL.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/Async.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Service.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 /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 /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/DatabaseKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /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 /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/karankhatter/Documents/lpglf16/DerivedData/carpoolApp_v1.0/Build/Intermediates/carpoolApp_v1.0.build/Debug-iphonesimulator/carpoolApp_v1.0.build/Objects-normal/x86_64/ContainerConfirmReservationViewController.o : /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/LoginViewController.swift /Users/karankhatter/Documents/lpglf16/ConfirmReservationViewController.swift /Users/karankhatter/Documents/lpglf16/ContainerAboutUsViewController.swift /Users/karankhatter/Documents/lpglf16/UserInformation.swift /Users/karankhatter/Documents/lpglf16/StartReservationViewController.swift /Users/karankhatter/Documents/lpglf16/BecomeCaddyViewController.swift /Users/karankhatter/Documents/lpglf16/UpcomingReservationsViewController.swift /Users/karankhatter/Documents/lpglf16/SidebarMenuViewController.swift /Users/karankhatter/Documents/lpglf16/ChangeEmailViewController.swift /Users/karankhatter/Documents/lpglf16/InviteViewController.swift /Users/karankhatter/Documents/lpglf16/ContainerConfirmReservationViewController.swift /Users/karankhatter/Documents/lpglf16/ChangePasswordViewController.swift /Users/karankhatter/Documents/lpglf16/ChooseServiceLevelSegmentedControl.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/AppDelegate.swift /Users/karankhatter/Documents/lpglf16/AboutUsViewController.swift /Users/karankhatter/Documents/lpglf16/HelpViewController.swift /Users/karankhatter/Documents/lpglf16/PrivacySettingsViewController.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/AvailableCaddiesCell.swift /Users/karankhatter/Documents/lpglf16/ChangePhoneViewController.swift /Users/karankhatter/Documents/lpglf16/ProfileSegmentedControl.swift /Users/karankhatter/Documents/lpglf16/CaddyHistoryViewController.swift /Users/karankhatter/Documents/lpglf16/UltravisualLayout.swift /Users/karankhatter/Documents/lpglf16/SettingsViewController.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/ContainerCaddiesAvailableViewController.swift /Users/karankhatter/Documents/lpglf16/NotificationsSettingsViewController.swift /Users/karankhatter/Documents/lpglf16/HelpAndSupportViewController.swift /Users/karankhatter/Documents/lpglf16/ProfileViewController.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/Session.swift /Users/karankhatter/Documents/lpglf16/StartReservationContainerViewController.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/Caddies.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/UIImage+Decompression.swift /Users/karankhatter/Documents/lpglf16/NotificationsViewController.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/LandingPageViewController.swift /Users/karankhatter/Documents/lpglf16/CaddiesAvailableViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/carpoolApp_v1.0-Bridging-Header.h /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/SWRevealViewController.h /Users/karankhatter/Documents/lpglf16/Pods/Firebase/Headers/module.modulemap /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/Foundation.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/Dispatch.swiftmodule /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/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIROptions.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRConfiguration.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRApp.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalyticsConfiguration.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRUserPropertyNames.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRParameterNames.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIREventNames.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalytics.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalytics+AppDelegate.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FirebaseAnalytics.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Modules/module.modulemap /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRUserInfo.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRUser.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRAuthCredential.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRAuthErrors.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRAuth.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRTwitterAuthProvider.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRGoogleAuthProvider.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRGitHubAuthProvider.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRFacebookAuthProvider.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIREmailPasswordAuthProvider.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FirebaseAuth.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Modules/module.modulemap /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRServerValue.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRTransactionResult.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRMutableData.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRDataSnapshot.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRDataEventType.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRDatabaseQuery.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRDatabaseReference.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRDatabase.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FirebaseDatabase.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Modules/module.modulemap /Users/karankhatter/Documents/lpglf16/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Headers/FIRInstanceID.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Headers/FirebaseInstanceID.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Modules/module.modulemap /Users/karankhatter/Documents/lpglf16/Pods/Firebase/Headers/Firebase.h
/Users/karankhatter/Documents/lpglf16/DerivedData/carpoolApp_v1.0/Build/Intermediates/carpoolApp_v1.0.build/Debug-iphonesimulator/carpoolApp_v1.0.build/Objects-normal/x86_64/ContainerConfirmReservationViewController~partial.swiftmodule : /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/LoginViewController.swift /Users/karankhatter/Documents/lpglf16/ConfirmReservationViewController.swift /Users/karankhatter/Documents/lpglf16/ContainerAboutUsViewController.swift /Users/karankhatter/Documents/lpglf16/UserInformation.swift /Users/karankhatter/Documents/lpglf16/StartReservationViewController.swift /Users/karankhatter/Documents/lpglf16/BecomeCaddyViewController.swift /Users/karankhatter/Documents/lpglf16/UpcomingReservationsViewController.swift /Users/karankhatter/Documents/lpglf16/SidebarMenuViewController.swift /Users/karankhatter/Documents/lpglf16/ChangeEmailViewController.swift /Users/karankhatter/Documents/lpglf16/InviteViewController.swift /Users/karankhatter/Documents/lpglf16/ContainerConfirmReservationViewController.swift /Users/karankhatter/Documents/lpglf16/ChangePasswordViewController.swift /Users/karankhatter/Documents/lpglf16/ChooseServiceLevelSegmentedControl.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/AppDelegate.swift /Users/karankhatter/Documents/lpglf16/AboutUsViewController.swift /Users/karankhatter/Documents/lpglf16/HelpViewController.swift /Users/karankhatter/Documents/lpglf16/PrivacySettingsViewController.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/AvailableCaddiesCell.swift /Users/karankhatter/Documents/lpglf16/ChangePhoneViewController.swift /Users/karankhatter/Documents/lpglf16/ProfileSegmentedControl.swift /Users/karankhatter/Documents/lpglf16/CaddyHistoryViewController.swift /Users/karankhatter/Documents/lpglf16/UltravisualLayout.swift /Users/karankhatter/Documents/lpglf16/SettingsViewController.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/ContainerCaddiesAvailableViewController.swift /Users/karankhatter/Documents/lpglf16/NotificationsSettingsViewController.swift /Users/karankhatter/Documents/lpglf16/HelpAndSupportViewController.swift /Users/karankhatter/Documents/lpglf16/ProfileViewController.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/Session.swift /Users/karankhatter/Documents/lpglf16/StartReservationContainerViewController.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/Caddies.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/UIImage+Decompression.swift /Users/karankhatter/Documents/lpglf16/NotificationsViewController.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/LandingPageViewController.swift /Users/karankhatter/Documents/lpglf16/CaddiesAvailableViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/carpoolApp_v1.0-Bridging-Header.h /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/SWRevealViewController.h /Users/karankhatter/Documents/lpglf16/Pods/Firebase/Headers/module.modulemap /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/Foundation.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/Dispatch.swiftmodule /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/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIROptions.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRConfiguration.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRApp.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalyticsConfiguration.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRUserPropertyNames.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRParameterNames.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIREventNames.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalytics.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalytics+AppDelegate.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FirebaseAnalytics.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Modules/module.modulemap /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRUserInfo.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRUser.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRAuthCredential.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRAuthErrors.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRAuth.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRTwitterAuthProvider.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRGoogleAuthProvider.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRGitHubAuthProvider.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRFacebookAuthProvider.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIREmailPasswordAuthProvider.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FirebaseAuth.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Modules/module.modulemap /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRServerValue.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRTransactionResult.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRMutableData.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRDataSnapshot.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRDataEventType.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRDatabaseQuery.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRDatabaseReference.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRDatabase.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FirebaseDatabase.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Modules/module.modulemap /Users/karankhatter/Documents/lpglf16/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Headers/FIRInstanceID.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Headers/FirebaseInstanceID.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Modules/module.modulemap /Users/karankhatter/Documents/lpglf16/Pods/Firebase/Headers/Firebase.h
/Users/karankhatter/Documents/lpglf16/DerivedData/carpoolApp_v1.0/Build/Intermediates/carpoolApp_v1.0.build/Debug-iphonesimulator/carpoolApp_v1.0.build/Objects-normal/x86_64/ContainerConfirmReservationViewController~partial.swiftdoc : /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/LoginViewController.swift /Users/karankhatter/Documents/lpglf16/ConfirmReservationViewController.swift /Users/karankhatter/Documents/lpglf16/ContainerAboutUsViewController.swift /Users/karankhatter/Documents/lpglf16/UserInformation.swift /Users/karankhatter/Documents/lpglf16/StartReservationViewController.swift /Users/karankhatter/Documents/lpglf16/BecomeCaddyViewController.swift /Users/karankhatter/Documents/lpglf16/UpcomingReservationsViewController.swift /Users/karankhatter/Documents/lpglf16/SidebarMenuViewController.swift /Users/karankhatter/Documents/lpglf16/ChangeEmailViewController.swift /Users/karankhatter/Documents/lpglf16/InviteViewController.swift /Users/karankhatter/Documents/lpglf16/ContainerConfirmReservationViewController.swift /Users/karankhatter/Documents/lpglf16/ChangePasswordViewController.swift /Users/karankhatter/Documents/lpglf16/ChooseServiceLevelSegmentedControl.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/AppDelegate.swift /Users/karankhatter/Documents/lpglf16/AboutUsViewController.swift /Users/karankhatter/Documents/lpglf16/HelpViewController.swift /Users/karankhatter/Documents/lpglf16/PrivacySettingsViewController.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/AvailableCaddiesCell.swift /Users/karankhatter/Documents/lpglf16/ChangePhoneViewController.swift /Users/karankhatter/Documents/lpglf16/ProfileSegmentedControl.swift /Users/karankhatter/Documents/lpglf16/CaddyHistoryViewController.swift /Users/karankhatter/Documents/lpglf16/UltravisualLayout.swift /Users/karankhatter/Documents/lpglf16/SettingsViewController.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/ContainerCaddiesAvailableViewController.swift /Users/karankhatter/Documents/lpglf16/NotificationsSettingsViewController.swift /Users/karankhatter/Documents/lpglf16/HelpAndSupportViewController.swift /Users/karankhatter/Documents/lpglf16/ProfileViewController.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/Session.swift /Users/karankhatter/Documents/lpglf16/StartReservationContainerViewController.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/Caddies.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/UIImage+Decompression.swift /Users/karankhatter/Documents/lpglf16/NotificationsViewController.swift /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/LandingPageViewController.swift /Users/karankhatter/Documents/lpglf16/CaddiesAvailableViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/carpoolApp_v1.0-Bridging-Header.h /Users/karankhatter/Documents/lpglf16/carpoolApp_v1.0/SWRevealViewController.h /Users/karankhatter/Documents/lpglf16/Pods/Firebase/Headers/module.modulemap /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/Foundation.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/Dispatch.swiftmodule /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/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIROptions.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRConfiguration.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRApp.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalyticsConfiguration.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRUserPropertyNames.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRParameterNames.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIREventNames.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalytics.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalytics+AppDelegate.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FirebaseAnalytics.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Modules/module.modulemap /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRUserInfo.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRUser.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRAuthCredential.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRAuthErrors.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRAuth.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRTwitterAuthProvider.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRGoogleAuthProvider.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRGitHubAuthProvider.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIRFacebookAuthProvider.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FIREmailPasswordAuthProvider.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers/FirebaseAuth.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Modules/module.modulemap /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRServerValue.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRTransactionResult.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRMutableData.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRDataSnapshot.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRDataEventType.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRDatabaseQuery.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRDatabaseReference.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FIRDatabase.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers/FirebaseDatabase.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Modules/module.modulemap /Users/karankhatter/Documents/lpglf16/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Headers/FIRInstanceID.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Headers/FirebaseInstanceID.h /Users/karankhatter/Documents/lpglf16/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Modules/module.modulemap /Users/karankhatter/Documents/lpglf16/Pods/Firebase/Headers/Firebase.h
|
D
|
/Users/mprechner/vapor-demo/HelloWorld/.build/debug/Core.build/Portal.swift.o : /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Array.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Bool+String.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Box.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Collection+Safe.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Dispatch.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/DispatchTime+Utilities.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Equatable.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Extractable.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/FileProtocol.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Lock.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/PercentEncoding.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Portal.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Result.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/RFC1123.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Semaphore.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Sequence.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/StaticDataBuffer.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Strand.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/String+CaseInsensitiveCompare.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/String.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/UnsignedInteger.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/Base64Encoder.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/Byte+Random.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/Byte.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/ByteAliases.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/Bytes+Base64.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/Bytes.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/BytesConvertible.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/BytesSlice+PatternMatching.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/Dispatch.swiftmodule /Users/mprechner/vapor-demo/HelloWorld/.build/debug/CLibreSSL.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.apinotesc /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/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/mprechner/vapor-demo/HelloWorld/.build/debug/libc.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/CoreGraphics.apinotesc /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/CoreText.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.apinotesc
/Users/mprechner/vapor-demo/HelloWorld/.build/debug/Core.build/Portal~partial.swiftmodule : /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Array.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Bool+String.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Box.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Collection+Safe.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Dispatch.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/DispatchTime+Utilities.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Equatable.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Extractable.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/FileProtocol.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Lock.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/PercentEncoding.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Portal.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Result.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/RFC1123.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Semaphore.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Sequence.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/StaticDataBuffer.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Strand.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/String+CaseInsensitiveCompare.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/String.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/UnsignedInteger.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/Base64Encoder.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/Byte+Random.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/Byte.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/ByteAliases.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/Bytes+Base64.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/Bytes.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/BytesConvertible.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/BytesSlice+PatternMatching.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/Dispatch.swiftmodule /Users/mprechner/vapor-demo/HelloWorld/.build/debug/CLibreSSL.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.apinotesc /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/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/mprechner/vapor-demo/HelloWorld/.build/debug/libc.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/CoreGraphics.apinotesc /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/CoreText.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.apinotesc
/Users/mprechner/vapor-demo/HelloWorld/.build/debug/Core.build/Portal~partial.swiftdoc : /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Array.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Bool+String.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Box.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Collection+Safe.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Dispatch.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/DispatchTime+Utilities.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Equatable.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Extractable.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/FileProtocol.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Lock.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/PercentEncoding.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Portal.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Result.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/RFC1123.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Semaphore.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Sequence.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/StaticDataBuffer.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Strand.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/String+CaseInsensitiveCompare.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/String.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/UnsignedInteger.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/Base64Encoder.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/Byte+Random.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/Byte.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/ByteAliases.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/Bytes+Base64.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/Bytes.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/BytesConvertible.swift /Users/mprechner/vapor-demo/HelloWorld/.build/checkouts/core.git-9210800844849382486/Sources/Core/Byte/BytesSlice+PatternMatching.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/Dispatch.swiftmodule /Users/mprechner/vapor-demo/HelloWorld/.build/debug/CLibreSSL.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.apinotesc /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/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/mprechner/vapor-demo/HelloWorld/.build/debug/libc.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/CoreGraphics.apinotesc /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/CoreText.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.apinotesc
|
D
|
// SPDX-License-Identifier: MIT
//
// Copyright The SCons Foundation
int main() {
return 0;
}
|
D
|
INSTANCE Info_Mod_Malik_Aufgabe (C_INFO)
{
npc = Mod_7123_ASS_Malik_NW;
nr = 1;
condition = Info_Mod_Malik_Aufgabe_Condition;
information = Info_Mod_Malik_Aufgabe_Info;
permanent = 0;
important = 1;
};
FUNC INT Info_Mod_Malik_Aufgabe_Condition()
{
if (Npc_KnowsInfo(hero, Info_Mod_Masut_Jack))
{
return 1;
};
};
FUNC VOID Info_Mod_Malik_Aufgabe_Info()
{
AI_Output(self, hero, "Info_Mod_Malik_Aufgabe_13_00"); //Aha, der Neue! Auf Stimmenfang, höre ich.
AI_Output(hero, self, "Info_Mod_Malik_Aufgabe_15_01"); //Du sagst es. Was kostet deine?
AI_Output(self, hero, "Info_Mod_Malik_Aufgabe_13_02"); //Eine Gefälligkeit. Nur eine kleine Gefälligkeit.
AI_Output(hero, self, "Info_Mod_Malik_Aufgabe_15_03"); //Und die wäre?
AI_Output(self, hero, "Info_Mod_Malik_Aufgabe_13_04"); //Man wird alt. Man schläft schlecht auf den harten Betten. Ich brauche was Weiches unter den Kopf.
AI_Output(hero, self, "Info_Mod_Malik_Aufgabe_15_05"); //Wie wäre es mit einem Fell vom Schaf?
AI_Output(self, hero, "Info_Mod_Malik_Aufgabe_13_06"); //Nein, nein. Das wird hart und stinkt. Was warmes, weiches, sauberes soll es schon sein.
AI_Output(hero, self, "Info_Mod_Malik_Aufgabe_15_07"); //Dann werde ich mal die Händler abklappern.
AI_Output(self, hero, "Info_Mod_Malik_Aufgabe_13_08"); //Am Besten die in Khorata. Die sollen doch so fortschrittlich sein, sagt man.
AI_Output(hero, self, "Info_Mod_Malik_Aufgabe_15_09"); //Gute Idee. Bis später.
Log_CreateTopic (TOPIC_MOD_ASS_KISSEN, LOG_MISSION);
B_SetTopicStatus (TOPIC_MOD_ASS_KISSEN, LOG_RUNNING);
B_LogEntry (TOPIC_MOD_ASS_KISSEN, "Was Weiches für den Kopf! Was es alles gibt. Ich denke, ich frage erst mal Matteo, der ist wohl der beste Händler im Ort. Ansonsten werde ich mich in Khorata umsehen müssen.");
};
INSTANCE Info_Mod_Malik_Kissen (C_INFO)
{
npc = Mod_7123_ASS_Malik_NW;
nr = 1;
condition = Info_Mod_Malik_Kissen_Condition;
information = Info_Mod_Malik_Kissen_Info;
permanent = 0;
important = 0;
description = "Hier, dein Weiches für den Kopf.";
};
FUNC INT Info_Mod_Malik_Kissen_Condition()
{
if (Npc_KnowsInfo(hero, Info_Mod_Malik_Aufgabe))
&& (Npc_HasItems(hero, ItMi_Kissen) == 1)
{
return 1;
};
};
FUNC VOID Info_Mod_Malik_Kissen_Info()
{
AI_Output(hero, self, "Info_Mod_Malik_Kissen_15_00"); //Hier, dein Weiches für den Kopf.
B_GiveInvItems (hero, self, ItMi_Kissen, 1);
AI_Output(self, hero, "Info_Mod_Malik_Kissen_13_01"); //Was ist denn das? Ein lila Viereck.
AI_Output(hero, self, "Info_Mod_Malik_Kissen_15_02"); //Leg dich hin und mach es unter deinen Kopf.
AI_GotoWP (self, "WP_ASSASSINE_31");
AI_UseMob (self, "BEDHIGH", 1);
AI_UseMob (self, "BEDHIGH", -1);
AI_GotoNpc (self, hero);
AI_Output(hero, self, "Info_Mod_Malik_Kissen_15_03"); //Und? Zufrieden?
AI_Output(self, hero, "Info_Mod_Malik_Kissen_13_04"); //Bei allen Geistern. Wunderbar weich und riecht gut. Bin mehr als zufrieden.
AI_Output(hero, self, "Info_Mod_Malik_Kissen_15_05"); //Dann habe ich deine Stimme?
AI_Output(self, hero, "Info_Mod_Malik_Kissen_13_06"); //Aber ja. Ich würde dir sogar zwei geben, wenn's möglich wäre. Aber jetzt lass mich schlafen.
AI_Output(self, hero, "Info_Mod_Malik_Kissen_13_07"); //Ach ja, eines noch. Sinbad sucht dich.
B_LogEntry (TOPIC_MOD_ASS_KRIEGER, "Malik war sehr zufrieden. Seine Stimme ist mir sicher. Soll nun zu Sinbad.");
B_SetTopicStatus (TOPIC_MOD_ASS_KISSEN, LOG_SUCCESS);
B_GivePlayerXP (200);
AI_StopProcessInfos (self);
B_StartOtherRoutine (self, "SLEEP");
};
INSTANCE Info_Mod_Malik_Pickpocket (C_INFO)
{
npc = Mod_7123_ASS_Malik_NW;
nr = 1;
condition = Info_Mod_Malik_Pickpocket_Condition;
information = Info_Mod_Malik_Pickpocket_Info;
permanent = 1;
important = 0;
description = Pickpocket_120;
};
FUNC INT Info_Mod_Malik_Pickpocket_Condition()
{
C_Beklauen (117, ItMi_Gold, 40);
};
FUNC VOID Info_Mod_Malik_Pickpocket_Info()
{
Info_ClearChoices (Info_Mod_Malik_Pickpocket);
Info_AddChoice (Info_Mod_Malik_Pickpocket, DIALOG_BACK, Info_Mod_Malik_Pickpocket_BACK);
Info_AddChoice (Info_Mod_Malik_Pickpocket, DIALOG_PICKPOCKET, Info_Mod_Malik_Pickpocket_DoIt);
};
FUNC VOID Info_Mod_Malik_Pickpocket_BACK()
{
Info_ClearChoices (Info_Mod_Malik_Pickpocket);
};
FUNC VOID Info_Mod_Malik_Pickpocket_DoIt()
{
if (B_Beklauen() == TRUE)
{
Info_ClearChoices (Info_Mod_Malik_Pickpocket);
}
else
{
Info_ClearChoices (Info_Mod_Malik_Pickpocket);
Info_AddChoice (Info_Mod_Malik_Pickpocket, DIALOG_PP_BESCHIMPFEN, Info_Mod_Malik_Pickpocket_Beschimpfen);
Info_AddChoice (Info_Mod_Malik_Pickpocket, DIALOG_PP_BESTECHUNG, Info_Mod_Malik_Pickpocket_Bestechung);
Info_AddChoice (Info_Mod_Malik_Pickpocket, DIALOG_PP_HERAUSREDEN, Info_Mod_Malik_Pickpocket_Herausreden);
};
};
FUNC VOID Info_Mod_Malik_Pickpocket_Beschimpfen()
{
B_Say (hero, self, "$PICKPOCKET_BESCHIMPFEN");
B_Say (self, hero, "$DIRTYTHIEF");
Info_ClearChoices (Info_Mod_Malik_Pickpocket);
AI_StopProcessInfos (self);
B_Attack (self, hero, AR_Theft, 1);
};
FUNC VOID Info_Mod_Malik_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_Malik_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_Malik_Pickpocket);
AI_StopProcessInfos (self);
};
};
FUNC VOID Info_Mod_Malik_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_Malik_Pickpocket);
}
else
{
B_Say (self, hero, "$PICKPOCKET_HERAUSREDEN_02");
};
};
INSTANCE Info_Mod_Malik_EXIT (C_INFO)
{
npc = Mod_7123_ASS_Malik_NW;
nr = 1;
condition = Info_Mod_Malik_EXIT_Condition;
information = Info_Mod_Malik_EXIT_Info;
permanent = 1;
important = 0;
description = DIALOG_ENDE;
};
FUNC INT Info_Mod_Malik_EXIT_Condition()
{
return 1;
};
FUNC VOID Info_Mod_Malik_EXIT_Info()
{
AI_StopProcessInfos (self);
};
|
D
|
import std.stdio;
import std.container;
import std.conv;
import std.algorithm;
import std.range;
import std.array;
import std.format;
import std.datetime;
import std.uni;
import std.typecons;
import std.math;
struct Node
{
int payload;
Node *next;
Node *prev;
}
int main(string[] args)
{
auto input = readln.split.array;
auto n = input[0].to!int;
auto m = input[6].to!int;
auto curr_node = new Node;
curr_node.payload = 0;
curr_node.next = curr_node;
curr_node.prev = curr_node;
int curr_player = 0;
auto scores = new long[n];
for (int i = 1; i <= m; i++)
{
if (i % 23 != 0)
{
curr_node = curr_node.next;
auto node = new Node;
node.payload = i;
node.prev = curr_node;
node.next = curr_node.next;
curr_node.next = node;
node.next.prev = node;
curr_node = curr_node.next;
}
else
{
scores[curr_player] += i;
for (int j = 0; j < 7; j++)
curr_node = curr_node.prev;
scores[curr_player] += curr_node.payload;
curr_node.prev.next = curr_node.next;
curr_node.next.prev = curr_node.prev;
curr_node = curr_node.next;
}
curr_player = (curr_player + 1) % n;
}
scores.maxElement.writeln;
return 0;
}
|
D
|
instance PC_Itemfeller(Npc_Default)
{
name[0] = "Мистер Вещь";
npcType = NPCTYPE_MAIN;
guild = GIL_NONE;
level = 30;
voice = 15;
id = 0;
attribute[ATR_STRENGTH] = 100;
attribute[ATR_DEXTERITY] = 100;
attribute[ATR_MANA_MAX] = 400;
attribute[ATR_MANA] = 400;
attribute[ATR_HITPOINTS_MAX] = 400;
attribute[ATR_HITPOINTS] = 400;
exp = B_GetCurrentLevelExp(self);
exp_next = B_GetNextLevelExp(self);
B_SetNpcVisual(self,MALE,"Hum_Head_Pony",Face_N_Player,BodyTex_Player_G1,ITAR_PAL_H);
Npc_SetTalentSkill(self,NPC_TALENT_MAGE,6);
Npc_SetTalentSkill(self,NPC_TALENT_PICKLOCK,1);
Npc_SetTalentSkill(self,NPC_TALENT_SNEAK,1);
Npc_SetTalentSkill(self,NPC_TALENT_ACROBAT,0);
Npc_SetTalentSkill(self,NPC_TALENT_PICKPOCKET,1);
Npc_SetTalentSkill(self,NPC_TALENT_SMITH,1);
Npc_SetTalentSkill(self,NPC_TALENT_RUNES,1);
Npc_SetTalentSkill(self,NPC_TALENT_ALCHEMY,1);
Npc_SetTalentSkill(self,NPC_TALENT_TAKEANIMALFUR,1);
PLAYER_TALENT_ALCHEMY[POTION_Health_01] = TRUE;
PLAYER_TALENT_ALCHEMY[POTION_Health_02] = TRUE;
PLAYER_TALENT_ALCHEMY[POTION_Health_03] = TRUE;
PLAYER_TALENT_ALCHEMY[POTION_Mana_01] = TRUE;
PLAYER_TALENT_ALCHEMY[POTION_Mana_02] = TRUE;
PLAYER_TALENT_ALCHEMY[POTION_Mana_03] = TRUE;
PLAYER_TALENT_ALCHEMY[POTION_Speed] = TRUE;
PLAYER_TALENT_ALCHEMY[POTION_Perm_STR] = TRUE;
PLAYER_TALENT_ALCHEMY[POTION_Perm_DEX] = TRUE;
PLAYER_TALENT_ALCHEMY[POTION_Perm_Mana] = TRUE;
PLAYER_TALENT_ALCHEMY[POTION_Perm_Health] = TRUE;
PLAYER_TALENT_SMITH[WEAPON_Common] = TRUE;
PLAYER_TALENT_SMITH[WEAPON_1H_Special_01] = TRUE;
PLAYER_TALENT_SMITH[WEAPON_2H_Special_01] = TRUE;
PLAYER_TALENT_SMITH[WEAPON_1H_Special_02] = TRUE;
PLAYER_TALENT_SMITH[WEAPON_2H_Special_02] = TRUE;
PLAYER_TALENT_SMITH[WEAPON_1H_Special_03] = TRUE;
PLAYER_TALENT_SMITH[WEAPON_2H_Special_03] = TRUE;
PLAYER_TALENT_SMITH[WEAPON_1H_Special_04] = TRUE;
PLAYER_TALENT_SMITH[WEAPON_2H_Special_04] = TRUE;
PLAYER_TALENT_TAKEANIMALTROPHY[TROPHY_Teeth] = TRUE;
PLAYER_TALENT_TAKEANIMALTROPHY[TROPHY_Claws] = TRUE;
PLAYER_TALENT_TAKEANIMALTROPHY[TROPHY_Fur] = TRUE;
PLAYER_TALENT_TAKEANIMALTROPHY[TROPHY_Heart] = TRUE;
PLAYER_TALENT_TAKEANIMALTROPHY[TROPHY_ShadowHorn] = TRUE;
PLAYER_TALENT_TAKEANIMALTROPHY[TROPHY_FireTongue] = TRUE;
PLAYER_TALENT_TAKEANIMALTROPHY[TROPHY_BFWing] = TRUE;
PLAYER_TALENT_TAKEANIMALTROPHY[TROPHY_BFSting] = TRUE;
PLAYER_TALENT_TAKEANIMALTROPHY[TROPHY_Mandibles] = TRUE;
PLAYER_TALENT_TAKEANIMALTROPHY[TROPHY_CrawlerPlate] = TRUE;
PLAYER_TALENT_TAKEANIMALTROPHY[TROPHY_DrgSnapperHorn] = TRUE;
PLAYER_TALENT_TAKEANIMALTROPHY[TROPHY_DragonScale] = TRUE;
PLAYER_TALENT_TAKEANIMALTROPHY[TROPHY_DragonBlood] = TRUE;
PLAYER_TALENT_RUNES[SPL_Light] = TRUE;
PLAYER_TALENT_RUNES[SPL_Firebolt] = TRUE;
PLAYER_TALENT_RUNES[SPL_Icebolt] = TRUE;
PLAYER_TALENT_RUNES[SPL_LightHeal] = TRUE;
PLAYER_TALENT_RUNES[SPL_SummonGoblinSkeleton] = TRUE;
PLAYER_TALENT_RUNES[SPL_InstantFireball] = TRUE;
PLAYER_TALENT_RUNES[SPL_Zap] = TRUE;
PLAYER_TALENT_RUNES[SPL_SummonWolf] = TRUE;
PLAYER_TALENT_RUNES[SPL_WindFist] = TRUE;
PLAYER_TALENT_RUNES[SPL_Sleep] = TRUE;
PLAYER_TALENT_RUNES[SPL_MediumHeal] = TRUE;
PLAYER_TALENT_RUNES[SPL_LightningFlash] = TRUE;
PLAYER_TALENT_RUNES[SPL_ChargeFireball] = TRUE;
PLAYER_TALENT_RUNES[SPL_SummonSkeleton] = TRUE;
PLAYER_TALENT_RUNES[SPL_Fear] = TRUE;
PLAYER_TALENT_RUNES[SPL_IceCube] = TRUE;
PLAYER_TALENT_RUNES[SPL_ChargeZap] = TRUE;
PLAYER_TALENT_RUNES[SPL_SummonGolem] = TRUE;
PLAYER_TALENT_RUNES[SPL_DestroyUndead] = TRUE;
PLAYER_TALENT_RUNES[SPL_Pyrokinesis] = TRUE;
PLAYER_TALENT_RUNES[SPL_Firestorm] = TRUE;
PLAYER_TALENT_RUNES[SPL_IceWave] = TRUE;
PLAYER_TALENT_RUNES[SPL_SummonDemon] = TRUE;
PLAYER_TALENT_RUNES[SPL_FullHeal] = TRUE;
PLAYER_TALENT_RUNES[SPL_Firerain] = TRUE;
PLAYER_TALENT_RUNES[SPL_BreathOfDeath] = TRUE;
PLAYER_TALENT_RUNES[SPL_MassDeath] = TRUE;
PLAYER_TALENT_RUNES[SPL_ArmyOfDarkness] = TRUE;
PLAYER_TALENT_RUNES[SPL_Shrink] = TRUE;
B_SetFightSkills(self,100);
CreateInvItems(self,ItMw_1h_Vlk_Dagger,1);
CreateInvItems(self,ItMw_1H_Mace_L_01,1);
CreateInvItems(self,ItMw_1h_Bau_Axe,1);
CreateInvItems(self,ItMw_1h_Vlk_Mace,1);
CreateInvItems(self,ItMw_1H_Mace_L_03,1);
CreateInvItems(self,ItMw_1h_Bau_Mace,1);
CreateInvItems(self,ItMw_1h_Vlk_Axe,1);
CreateInvItems(self,ItMw_1H_Mace_L_04,1);
CreateInvItems(self,ItMw_ShortSword1,1);
CreateInvItems(self,ItMw_Nagelknueppel,1);
CreateInvItems(self,ItMw_1H_Sword_L_03,1);
CreateInvItems(self,ItMw_ShortSword2,1);
CreateInvItems(self,ItMw_Sense,1);
CreateInvItems(self,ItMw_BattleSense,1);
CreateInvItems(self,ItMw_1h_Vlk_Sword,1);
CreateInvItems(self,ItMw_1h_Nov_Mace,1);
CreateInvItems(self,ItMw_2h_Bau_Axe,1);
CreateInvItems(self,ItMw_2H_Axe_L_01,1);
CreateInvItems(self,ItMw_1h_MISC_Sword,1);
CreateInvItems(self,ItMw_1h_Misc_Axe,1);
CreateInvItems(self,ItMw_2H_Sword_M_01,1);
CreateInvItems(self,ItMw_1h_Mil_Sword,1);
CreateInvItems(self,ItMw_1h_Sld_Axe,1);
CreateInvItems(self,ItMw_1h_Sld_Sword,1);
CreateInvItems(self,ItMw_2h_Sld_Axe,1);
CreateInvItems(self,ItMw_2h_Sld_Sword,1);
CreateInvItems(self,ItMw_1h_Pal_Sword,1);
CreateInvItems(self,ItMw_2h_Pal_Sword,1);
CreateInvItems(self,ItMw_2H_OrcAxe_01,1);
CreateInvItems(self,ItMw_2H_OrcAxe_02,1);
CreateInvItems(self,ItMw_2H_OrcAxe_03,1);
CreateInvItems(self,ItMw_2H_OrcAxe_04,1);
CreateInvItems(self,ItMw_2H_OrcMace_01,1);
CreateInvItems(self,ItMw_2H_OrcSword_01,1);
CreateInvItems(self,ItMw_2H_OrcSword_02,1);
CreateInvItems(self,ItMw_ShortSword3,1);
CreateInvItems(self,ItMw_Nagelkeule,1);
CreateInvItems(self,ItMw_ShortSword4,1);
CreateInvItems(self,ItMw_Kriegskeule,1);
CreateInvItems(self,ItMw_Richtstab,1);
CreateInvItems(self,ItMw_ShortSword5,1);
CreateInvItems(self,ItMw_Kriegshammer1,1);
CreateInvItems(self,ItMw_Hellebarde,1);
CreateInvItems(self,ItMw_Nagelkeule2,1);
CreateInvItems(self,ItMw_Schiffsaxt,1);
CreateInvItems(self,ItMw_Piratensaebel,1);
CreateInvItems(self,ItMw_Schwert,1);
CreateInvItems(self,ItMw_Stabkeule,1);
CreateInvItems(self,ItMw_Zweihaender1,1);
CreateInvItems(self,ItMw_Steinbrecher,1);
CreateInvItems(self,ItMw_Spicker,1);
CreateInvItems(self,ItMw_Streitaxt1,1);
CreateInvItems(self,ItMw_Schwert1,1);
CreateInvItems(self,ItMw_Schwert2,1);
CreateInvItems(self,ItMw_Doppelaxt,1);
CreateInvItems(self,ItMw_Bartaxt,1);
CreateInvItems(self,ItMw_Morgenstern,1);
CreateInvItems(self,ItMw_Schwert3,1);
CreateInvItems(self,ItMw_Schwert4,1);
CreateInvItems(self,ItMw_Rapier,1);
CreateInvItems(self,ItMw_Rubinklinge,1);
CreateInvItems(self,ItMw_Streitkolben,1);
CreateInvItems(self,ItMw_Zweihaender2,1);
CreateInvItems(self,ItMw_Runenschwert,1);
CreateInvItems(self,ItMw_Rabenschnabel,1);
CreateInvItems(self,ItMw_Schwert5,1);
CreateInvItems(self,ItMw_Inquisitor,1);
CreateInvItems(self,ItMw_Streitaxt2,1);
CreateInvItems(self,ItMw_Zweihaender3,1);
CreateInvItems(self,ItMw_ElBastardo,1);
CreateInvItems(self,ItMw_Kriegshammer2,1);
CreateInvItems(self,ItMw_Meisterdegen,1);
CreateInvItems(self,ItMw_Folteraxt,1);
CreateInvItems(self,ItMw_Orkschlaechter,1);
CreateInvItems(self,ItMw_Zweihaender4,1);
CreateInvItems(self,ItMw_Schlachtaxt,1);
CreateInvItems(self,ItMw_Krummschwert,1);
CreateInvItems(self,ItMw_Barbarenstreitaxt,1);
CreateInvItems(self,ItMw_Sturmbringer,1);
CreateInvItems(self,ItMw_Berserkeraxt,1);
CreateInvItems(self,ItMw_Drachenschneide,1);
CreateInvItems(self,ItMw_1H_Common_01,1);
CreateInvItems(self,ItMw_1H_Special_01,1);
CreateInvItems(self,ItMw_2H_Special_01,1);
CreateInvItems(self,ItMw_1H_Special_02,1);
CreateInvItems(self,ItMw_2H_Special_02,1);
CreateInvItems(self,ItMw_1H_Special_03,1);
CreateInvItems(self,ItMw_2H_Special_03,1);
CreateInvItems(self,ItMw_1H_Special_04,1);
CreateInvItems(self,ItMw_2H_Special_04,1);
CreateInvItems(self,ItMw_1H_Blessed_01,1);
CreateInvItems(self,ItMw_1H_Blessed_02,1);
CreateInvItems(self,ItMw_1H_Blessed_03,1);
CreateInvItems(self,ItMw_2H_Blessed_01,1);
CreateInvItems(self,ItMw_2H_Blessed_02,1);
CreateInvItems(self,ItMw_2H_Blessed_03,1);
CreateInvItems(self,ITAR_Governor,1);
CreateInvItems(self,ITAR_Smith,1);
CreateInvItems(self,ITAR_Barkeeper,1);
CreateInvItems(self,ITAR_Judge,1);
CreateInvItems(self,ITAR_Vlk_L,1);
CreateInvItems(self,ITAR_Vlk_M,1);
CreateInvItems(self,ITAR_Vlk_H,1);
CreateInvItems(self,ITAR_VlkBabe_L,1);
CreateInvItems(self,ITAR_VlkBabe_M,1);
CreateInvItems(self,ITAR_VlkBabe_H,1);
CreateInvItems(self,ITAR_MIL_L,1);
CreateInvItems(self,ITAR_MIL_M,1);
CreateInvItems(self,ITAR_PAL_M,1);
CreateInvItems(self,ITAR_PAL_H,1);
CreateInvItems(self,ITAR_Bau_L,1);
CreateInvItems(self,ITAR_Bau_M,1);
CreateInvItems(self,ITAR_BauBabe_L,1);
CreateInvItems(self,ITAR_BauBabe_M,1);
CreateInvItems(self,ITAR_SLD_L,1);
CreateInvItems(self,ITAR_SLD_M,1);
CreateInvItems(self,ITAR_SLD_H,1);
CreateInvItems(self,ITAR_DJG_L,1);
CreateInvItems(self,ITAR_DJG_M,1);
CreateInvItems(self,ITAR_DJG_H,1);
CreateInvItems(self,ITAR_DJG_Crawler,1);
// CreateInvItems(self,ITAR_DJG_Babe,1);
CreateInvItems(self,ITAR_NOV_L,1);
CreateInvItems(self,ITAR_KDF_L,1);
CreateInvItems(self,ITAR_KDF_H,1);
CreateInvItems(self,ITAR_Leather_L,1);
CreateInvItems(self,ITAR_BDT_M,1);
CreateInvItems(self,ITAR_BDT_H,1);
CreateInvItems(self,ITAR_Xardas,1);
CreateInvItems(self,ITAR_PSI_M,1);
CreateInvItems(self,ITAR_PSI_H,1);
CreateInvItems(self,ITAR_Diego,1);
CreateInvItems(self,ITAR_CorAngar,1);
CreateInvItems(self,ITAR_KDW_H,1);
CreateInvItems(self,ITAR_Dementor,1);
CreateInvItems(self,ITAR_Prisoner,1);
CreateInvItems(self,ItRu_PalLight,1);
CreateInvItems(self,ItRu_PalHeal_01,1);
CreateInvItems(self,ItRu_PalHolyBolt,1);
CreateInvItems(self,ItRu_PalHeal_02,1);
CreateInvItems(self,ItRu_PalRepelEvil,1);
CreateInvItems(self,ItRu_PalHeal_03,1);
CreateInvItems(self,ItRu_PalDestroyEvil,1);
CreateInvItems(self,ItRu_PalTeleportSecret,1);
CreateInvItems(self,ItRu_TeleportSeaport,1);
CreateInvItems(self,ItRu_TeleportMonastery,1);
CreateInvItems(self,ItRu_TeleportFarm,1);
CreateInvItems(self,ItRu_TeleportXardas,1);
CreateInvItems(self,ItRu_TeleportPassNW,1);
CreateInvItems(self,ItRu_TeleportPassOW,1);
CreateInvItems(self,ItRu_TeleportOC,1);
CreateInvItems(self,ItRu_TeleportTaverne,1);
CreateInvItems(self,ItRu_TeleportRitual,1);
CreateInvItems(self,ItRu_Light,1);
CreateInvItems(self,ItRu_FireBolt,1);
CreateInvItems(self,ItRu_Zap,1);
CreateInvItems(self,ItRu_LightHeal,1);
CreateInvItems(self,ItRu_SumGobSkel,1);
CreateInvItems(self,ItRu_InstantFireball,1);
CreateInvItems(self,ItRu_Icebolt,1);
CreateInvItems(self,ItRu_SumWolf,1);
CreateInvItems(self,ItRu_Windfist,1);
CreateInvItems(self,ItRu_Sleep,1);
CreateInvItems(self,ItRu_MediumHeal,1);
CreateInvItems(self,ItRu_LightningFlash,1);
CreateInvItems(self,ItRu_ChargeFireball,1);
CreateInvItems(self,ItRu_SumSkel,1);
CreateInvItems(self,ItRu_Fear,1);
CreateInvItems(self,ItRu_IceCube,1);
CreateInvItems(self,ItRu_ThunderBall,1);
CreateInvItems(self,ItRu_SumGol,1);
CreateInvItems(self,ItRu_HarmUndead,1);
CreateInvItems(self,ItRu_Pyrokinesis,1);
CreateInvItems(self,ItRu_Firestorm,1);
CreateInvItems(self,ItRu_IceWave,1);
CreateInvItems(self,ItRu_SumDemon,1);
CreateInvItems(self,ItRu_FullHeal,1);
CreateInvItems(self,ItRu_Firerain,1);
CreateInvItems(self,ItRu_BreathOfDeath,1);
CreateInvItems(self,ItRu_MassDeath,1);
CreateInvItems(self,ItRu_MasterOfDisaster,1);
CreateInvItems(self,ItRu_ArmyOfDarkness,1);
CreateInvItems(self,ItRu_Shrink,1);
CreateInvItems(self,ItSc_PalLight,10);
CreateInvItems(self,ItSc_PalHeal_01,10);
CreateInvItems(self,ItSc_PalHolyBolt,10);
CreateInvItems(self,ItSc_PalHeal_02,10);
CreateInvItems(self,ItSc_PalRepelEvil,10);
CreateInvItems(self,ItSc_PalHeal_03,10);
CreateInvItems(self,ItSc_PalDestroyEvil,10);
CreateInvItems(self,ItSc_Charm,10);
CreateInvItems(self,ItSc_Light,10);
CreateInvItems(self,ItSc_Firebolt,10);
CreateInvItems(self,ItSc_Icebolt,10);
CreateInvItems(self,ItSc_LightHeal,10);
CreateInvItems(self,ItSc_SumGobSkel,10);
CreateInvItems(self,ItSc_InstantFireball,10);
CreateInvItems(self,ItSc_Zap,10);
CreateInvItems(self,ItSc_SumWolf,10);
CreateInvItems(self,ItSc_Windfist,10);
CreateInvItems(self,ItSc_Sleep,10);
CreateInvItems(self,ItSc_MediumHeal,10);
CreateInvItems(self,ItSc_LightningFlash,10);
CreateInvItems(self,ItSc_ChargeFireBall,10);
CreateInvItems(self,ItSc_SumSkel,10);
CreateInvItems(self,ItSc_Fear,10);
CreateInvItems(self,ItSc_IceCube,10);
CreateInvItems(self,ItSc_ThunderBall,10);
CreateInvItems(self,ItSc_SumGol,10);
CreateInvItems(self,ItSc_HarmUndead,10);
CreateInvItems(self,ItSc_Pyrokinesis,10);
CreateInvItems(self,ItSc_Firestorm,10);
CreateInvItems(self,ItSc_IceWave,10);
CreateInvItems(self,ItSc_SumDemon,10);
CreateInvItems(self,ItSc_FullHeal,10);
CreateInvItems(self,ItSc_Firerain,10);
CreateInvItems(self,ItSc_BreathOfDeath,10);
CreateInvItems(self,ItSc_MassDeath,10);
CreateInvItems(self,ItSc_ArmyOfDarkness,10);
CreateInvItems(self,ItSc_Shrink,10);
CreateInvItems(self,ItSc_TrfSheep,10);
CreateInvItems(self,ItSc_TrfScavenger,10);
CreateInvItems(self,ItSc_TrfGiantRat,10);
CreateInvItems(self,ItSc_TrfGiantBug,10);
CreateInvItems(self,ItSc_TrfWolf,10);
CreateInvItems(self,ItSc_TrfWaran,10);
CreateInvItems(self,ItSc_TrfSnapper,10);
CreateInvItems(self,ItSc_TrfWarg,10);
CreateInvItems(self,ItSc_TrfFireWaran,10);
CreateInvItems(self,ItSc_TrfLurker,10);
CreateInvItems(self,ItSc_TrfShadowbeast,10);
CreateInvItems(self,ItSc_TrfDragonSnapper,10);
CreateInvItems(self,ItFo_Apple,10);
CreateInvItems(self,ItFo_Cheese,10);
CreateInvItems(self,ItFo_Bacon,10);
CreateInvItems(self,ItFo_Bread,10);
CreateInvItems(self,ItFo_Fish,10);
CreateInvItems(self,ItFoMuttonRaw,10);
CreateInvItems(self,ItFoMutton,10);
CreateInvItems(self,ItFo_Stew,10);
CreateInvItems(self,ItFo_FishSoup,10);
CreateInvItems(self,ItFo_Sausage,10);
CreateInvItems(self,ItFo_Honey,10);
CreateInvItems(self,ItFo_Water,10);
CreateInvItems(self,ItFo_Beer,10);
CreateInvItems(self,ItFo_Booze,10);
CreateInvItems(self,ItFo_Wine,10);
CreateInvItems(self,ItFo_Milk,10);
CreateInvItems(self,ItFo_XPStew,10);
CreateInvItems(self,ItFo_CoragonsBeer,10);
CreateInvItems(self,ItPl_Weed,10);
CreateInvItems(self,ItPl_Beet,10);
CreateInvItems(self,ItPl_SwampHerb,10);
CreateInvItems(self,ItPl_Mana_Herb_01,10);
CreateInvItems(self,ItPl_Mana_Herb_02,10);
CreateInvItems(self,ItPl_Mana_Herb_03,10);
CreateInvItems(self,ItPl_Health_Herb_01,10);
CreateInvItems(self,ItPl_Health_Herb_02,10);
CreateInvItems(self,ItPl_Health_Herb_03,10);
CreateInvItems(self,ItPl_Dex_Herb_01,10);
CreateInvItems(self,ItPl_Strength_Herb_01,10);
CreateInvItems(self,ItPl_Speed_Herb_01,10);
CreateInvItems(self,ItPl_Mushroom_01,10);
CreateInvItems(self,ItPl_Mushroom_02,10);
CreateInvItems(self,ItPl_Forestberry,10);
CreateInvItems(self,ItPl_Blueplant,10);
CreateInvItems(self,ItPl_Planeberry,10);
CreateInvItems(self,ItPl_Temp_Herb,10);
CreateInvItems(self,ItPl_Perm_Herb,10);
// CreateInvItems(self,ItKe_Key_01,1);
// CreateInvItems(self,ItKe_Key_02,1);
// CreateInvItems(self,ItKe_Key_03,1);
CreateInvItems(self,ItKe_Lockpick,1);
CreateInvItems(self,ItKe_City_Tower_01,1);
CreateInvItems(self,ItKe_City_Tower_02,1);
CreateInvItems(self,ItKe_City_Tower_03,1);
CreateInvItems(self,ItKe_City_Tower_04,1);
CreateInvItems(self,ItKe_City_Tower_05,1);
CreateInvItems(self,ItKe_City_Tower_06,1);
CreateInvItems(self,ItLsTorch,50);
CreateInvItems(self,ItLsTorchFirespit,10);
CreateInvItems(self,ItMi_Stomper,10);
CreateInvItems(self,ItMi_RuneBlank,10);
CreateInvItems(self,ItMi_Pliers,10);
CreateInvItems(self,ItMi_Flask,10);
CreateInvItems(self,ItMi_Hammer,10);
CreateInvItems(self,ItMi_Scoop,10);
CreateInvItems(self,ItMi_Pan,10);
CreateInvItems(self,ItMi_PanFull,10);
CreateInvItems(self,ItMi_Saw,10);
CreateInvItems(self,ItMiSwordraw,10);
CreateInvItems(self,ItMiSwordrawhot,10);
CreateInvItems(self,ItMiSwordbladehot,10);
CreateInvItems(self,ItMiSwordblade,10);
CreateInvItems(self,ItMi_Rake,10);
CreateInvItems(self,ItMi_Broom,10);
CreateInvItems(self,ItMi_Lute,10);
CreateInvItems(self,ItMi_Brush,10);
CreateInvItems(self,ItMi_Joint,10);
// CreateInvItems(self,ItMi_Packet,10);
CreateInvItems(self,ItMi_Pocket,10);
CreateInvItems(self,ItMi_Nugget,10);
CreateInvItems(self,ItMi_Gold,1000);
CreateInvItems(self,ItMi_OldCoin,10);
CreateInvItems(self,ItMi_GoldCandleHolder,10);
CreateInvItems(self,ItMi_GoldNecklace,10);
CreateInvItems(self,ItMi_SilverRing,10);
CreateInvItems(self,ItMi_SilverCup,10);
CreateInvItems(self,ItMi_SilverPlate,10);
CreateInvItems(self,ItMi_GoldPlate,10);
CreateInvItems(self,ItMi_GoldCup,10);
CreateInvItems(self,ItMi_BloodCup_MIS,10);
CreateInvItems(self,ItMi_GoldRing,10);
CreateInvItems(self,ItMi_SilverChalice,10);
CreateInvItems(self,ItMi_JeweleryChest,10);
CreateInvItems(self,ItMi_GoldChalice,10);
CreateInvItems(self,ItMi_GoldChest,10);
CreateInvItems(self,ItMi_InnosStatue,10);
CreateInvItems(self,ItMi_Sextant,10);
CreateInvItems(self,ItMi_SilverCandleHolder,10);
CreateInvItems(self,ItMi_SilverNecklace,10);
CreateInvItems(self,ItMi_Sulfur,10);
CreateInvItems(self,ItMi_Quartz,10);
CreateInvItems(self,ItMi_Pitch,10);
CreateInvItems(self,ItMi_Rockcrystal,10);
CreateInvItems(self,ItMi_Aquamarine,10);
CreateInvItems(self,ItMi_HolyWater,10);
CreateInvItems(self,ItMi_Coal,10);
CreateInvItems(self,ItMi_DarkPearl,10);
CreateInvItems(self,ItMi_ApfelTabak,10);
CreateInvItems(self,ItMi_PilzTabak,10);
CreateInvItems(self,ItMi_DoppelTabak,10);
CreateInvItems(self,ItMi_Honigtabak,10);
CreateInvItems(self,ItMi_SumpfTabak,10);
CreateInvItems(self,ItRw_Mil_Crossbow,1);
CreateInvItems(self,ItRw_Sld_Bow,1);
CreateInvItems(self,ItRw_Bow_L_01,1);
CreateInvItems(self,ItRw_Bow_L_02,1);
CreateInvItems(self,ItRw_Bow_L_03,1);
CreateInvItems(self,ItRw_Bow_L_04,1);
CreateInvItems(self,ItRw_Bow_M_01,1);
CreateInvItems(self,ItRw_Bow_M_02,1);
CreateInvItems(self,ItRw_Bow_M_03,1);
CreateInvItems(self,ItRw_Bow_M_04,1);
CreateInvItems(self,ItRw_Bow_H_01,1);
CreateInvItems(self,ItRw_Bow_H_02,1);
CreateInvItems(self,ItRw_Bow_H_03,1);
CreateInvItems(self,ItRw_Bow_H_04,1);
CreateInvItems(self,ItRw_Crossbow_L_01,1);
CreateInvItems(self,ItRw_Crossbow_L_02,1);
CreateInvItems(self,ItRw_Crossbow_M_01,1);
CreateInvItems(self,ItRw_Crossbow_M_02,1);
CreateInvItems(self,ItRw_Crossbow_H_01,1);
CreateInvItems(self,ItRw_Crossbow_H_02,1);
CreateInvItems(self,ItRw_Arrow,1000);
CreateInvItems(self,ItRw_Bolt,1000);
// CreateInvItems(self,StandardBrief,1);
// CreateInvItems(self,StandardBuch,1);
CreateInvItems(self,ItWr_Map_NewWorld,1);
CreateInvItems(self,ItWr_Map_NewWorld_City,1);
CreateInvItems(self,ItWr_Map_OldWorld,1);
CreateInvItems(self,ItWr_EinhandBuch,1);
CreateInvItems(self,ItWr_ZweihandBuch,1);
CreateInvItems(self,ItSe_ErzFisch,1);
CreateInvItems(self,ItSe_GoldFisch,1);
CreateInvItems(self,ItSe_RingFisch,1);
CreateInvItems(self,ItSe_LockpickFisch,1);
CreateInvItems(self,ItSe_GoldPocket25,1);
CreateInvItems(self,ItSe_GoldPocket50,1);
CreateInvItems(self,ItSe_GoldPocket100,1);
CreateInvItems(self,ItAm_Dex_01,1);
CreateInvItems(self,ItAm_Strg_01,1);
CreateInvItems(self,ItAm_Hp_01,1);
CreateInvItems(self,ItAm_Mana_01,1);
CreateInvItems(self,ItAm_Dex_Strg_01,1);
CreateInvItems(self,ItAm_Hp_Mana_01,1);
CreateInvItems(self,ItAm_Prot_Fire_01,1);
CreateInvItems(self,ItAm_Prot_Mage_01,1);
CreateInvItems(self,ItAm_Prot_Edge_01,1);
CreateInvItems(self,ItAm_Prot_Point_01,1);
CreateInvItems(self,ItAm_Prot_Total_01,1);
CreateInvItems(self,ItRi_Dex_01,1);
CreateInvItems(self,ItRi_Dex_02,1);
CreateInvItems(self,ItRi_HP_01,1);
CreateInvItems(self,ItRi_HP_02,1);
CreateInvItems(self,ItRi_Str_01,1);
CreateInvItems(self,ItRi_Str_02,1);
CreateInvItems(self,ItRi_Mana_01,1);
CreateInvItems(self,ItRi_Mana_02,1);
CreateInvItems(self,ItRi_Dex_Strg_01,1);
CreateInvItems(self,ItRi_Hp_Mana_01,1);
CreateInvItems(self,ItRi_Prot_Fire_01,1);
CreateInvItems(self,ItRi_Prot_Fire_02,1);
CreateInvItems(self,ItRi_Prot_Edge_01,1);
CreateInvItems(self,ItRi_Prot_Edge_02,1);
CreateInvItems(self,ItRi_Prot_Mage_01,1);
CreateInvItems(self,ItRi_Prot_Mage_02,1);
CreateInvItems(self,ItRi_Prot_Point_01,1);
CreateInvItems(self,ItRi_Prot_Point_02,1);
CreateInvItems(self,ItRi_Prot_Total_01,1);
CreateInvItems(self,ItRi_Prot_Total_02,1);
CreateInvItems(self,ItPo_Mana_01,10);
CreateInvItems(self,ItPo_Mana_02,10);
CreateInvItems(self,ItPo_Mana_03,10);
CreateInvItems(self,ItPo_Health_01,10);
CreateInvItems(self,ItPo_Health_02,10);
CreateInvItems(self,ItPo_Health_03,10);
CreateInvItems(self,ItPo_Perm_STR,10);
CreateInvItems(self,ItPo_Perm_DEX,10);
CreateInvItems(self,ItPo_Perm_Health,10);
CreateInvItems(self,ItPo_Perm_Mana,10);
CreateInvItems(self,ItPo_Speed,10);
CreateInvItems(self,ItPo_MegaDrink,10);
CreateInvItems(self,ItPo_Perm_LittleMana,10);
CreateInvItems(self,ItPo_Perm_MushroomMana,10);
CreateInvItems(self,ItPo_Perm_AppleSTR,10);
CreateInvItems(self,ItAt_Meatbugflesh,10);
CreateInvItems(self,ItAt_SheepFur,10);
CreateInvItems(self,ItAt_WolfFur,10);
CreateInvItems(self,ItAt_BugMandibles,10);
CreateInvItems(self,ItAt_Claw,10);
CreateInvItems(self,ItAt_LurkerClaw,10);
CreateInvItems(self,ItAt_Teeth,10);
CreateInvItems(self,ItAt_CrawlerMandibles,10);
CreateInvItems(self,ItAt_Wing,10);
CreateInvItems(self,ItAt_Sting,10);
CreateInvItems(self,ItAt_LurkerSkin,10);
CreateInvItems(self,ItAt_WargFur,10);
CreateInvItems(self,ItAt_DrgSnapperHorn,10);
CreateInvItems(self,ItAt_CrawlerPlate,10);
CreateInvItems(self,ItAt_ShadowFur,10);
CreateInvItems(self,ItAt_SharkSkin,10);
CreateInvItems(self,ItAt_TrollFur,10);
CreateInvItems(self,ItAt_TrollBlackFur,10);
CreateInvItems(self,ItAt_WaranFiretongue,10);
CreateInvItems(self,ItAt_ShadowHorn,10);
CreateInvItems(self,ItAt_SharkTeeth,10);
CreateInvItems(self,ItAt_TrollTooth,10);
CreateInvItems(self,ItAt_GoblinBone,10);
CreateInvItems(self,ItAt_SkeletonBone,10);
CreateInvItems(self,ItAt_DemonHeart,10);
CreateInvItems(self,ItAt_StoneGolemHeart,1);
CreateInvItems(self,ItAt_FireGolemHeart,1);
CreateInvItems(self,ItAt_IceGolemHeart,1);
CreateInvItems(self,ItAt_UndeadDragonSoulStone,1);
CreateInvItems(self,ItAt_IcedragonHeart,1);
CreateInvItems(self,ItAt_RockdragonHeart,1);
CreateInvItems(self,ItAt_SwampdragonHeart,1);
CreateInvItems(self,ItAt_FiredragonHeart,1);
CreateInvItems(self,ItAt_DragonBlood,10);
CreateInvItems(self,ItAt_DragonScale,10);
CreateInvItems(self,Fakescroll,1);
CreateInvItems(self,ItKe_Xardas,1);
CreateInvItems(self,ItWr_Canthars_KomproBrief_MIS,1);
CreateInvItems(self,ItMw_2h_Rod,1);
CreateInvItems(self,ItMi_CoragonsSilber,1);
CreateInvItems(self,ItMi_TheklasPaket,1);
CreateInvItems(self,ItMi_MariasGoldPlate,1);
CreateInvItems(self,ItRi_Prot_Edge_01_Valentino,1);
CreateInvItems(self,ItKe_Dexter,1);
CreateInvItems(self,ItWr_Kraeuterliste,1);
CreateInvItems(self,ItWr_ManaRezept,1);
CreateInvItems(self,ItWr_Passierschein,1);
CreateInvItems(self,ItMi_HerbPaket,1);
CreateInvItems(self,ItKe_Storage,1);
CreateInvItems(self,ItFo_SmellyFish,1);
CreateInvItems(self,ItFo_HalvorFish_MIS,1);
CreateInvItems(self,ItWr_HalvorMessage,1);
CreateInvItems(self,ItMw_AlriksSword_Mis,1);
CreateInvItems(self,ItWr_VatrasMessage,1);
CreateInvItems(self,ItWr_VatrasMessage_Open,1);
// CreateInvItems(self,ItKe_Hotel,1);
CreateInvItems(self,ItKe_ThiefGuildKey_MIS,1);
CreateInvItems(self,ItKe_ThiefGuildKey_Hotel_MIS,1);
CreateInvItems(self,ItKe_Innos_MIS,1);
CreateInvItems(self,ItKe_KlosterSchatz,1);
CreateInvItems(self,ItKe_KlosterStore,1);
CreateInvItems(self,ItKe_KDFPlayer,1);
CreateInvItems(self,ItKe_KlosterBibliothek,1);
CreateInvItems(self,ItFo_Schafswurst,1);
CreateInvItems(self,Holy_Hammer_MIS,1);
CreateInvItems(self,ItKe_MagicChest,1);
CreateInvItems(self,ItWr_Passage_MIS,1);
CreateInvItems(self,ItWr_BanditLetter_MIS,1);
CreateInvItems(self,ItWr_Poster_MIS,1);
CreateInvItems(self,ItKe_Bandit,1);
CreateInvItems(self,ItMi_BaltramPaket,1);
CreateInvItems(self,ItRw_Bow_L_03_MIS,1);
CreateInvItems(self,ItRi_Prot_Point_01_MIS,1);
CreateInvItems(self,ItMi_EddasStatue,1);
CreateInvItems(self,ItKe_EVT_CRYPT_01,1);
CreateInvItems(self,ItKe_EVT_CRYPT_02,1);
CreateInvItems(self,ItKe_EVT_CRYPT_03,1);
CreateInvItems(self,ITAR_PAL_Skel,1);
CreateInvItems(self,ItKe_Valentino,1);
CreateInvItems(self,ItKe_Buerger,1);
CreateInvItems(self,ItKe_Richter,1);
CreateInvItems(self,ItKe_Salandril,1);
CreateInvItems(self,ItKe_PaladinTruhe,1);
CreateInvItems(self,ItKe_ThiefTreasure,1);
CreateInvItems(self,ItKe_Fingers,1);
CreateInvItems(self,ItWr_Schuldenbuch,1);
CreateInvItems(self,ItPl_Sagitta_Herb_MIS,1);
CreateInvItems(self,ItKe_Orlan_HotelZimmer,1);
CreateInvItems(self,ItRw_DragomirsArmbrust_MIS,1);
CreateInvItems(self,ItMi_StoneOfKnowlegde_MIS,1);
CreateInvItems(self,ItRu_TeleportOWDemonTower,1);
CreateInvItems(self,ItWr_PaladinLetter_MIS,1);
CreateInvItems(self,ItWr_LetterForGorn_MIS,1);
CreateInvItems(self,ItKe_PrisonKey_MIS,1);
CreateInvItems(self,ItKe_OC_Store,1);
CreateInvItems(self,ITKE_ErzBaronFlur,1);
CreateInvItems(self,ITKE_ErzBaronRaum,1);
CreateInvItems(self,ItMi_GornsTreasure_MIS,1);
CreateInvItems(self,ItWr_Silvestro_MIS,1);
CreateInvItems(self,ItAt_ClawLeader,1);
CreateInvItems(self,ItSe_Olav,1);
// CreateInvItems(self,ItMi_GoldPlate_MIS,1);
CreateInvItems(self,ItKe_Pass_MIS,1);
CreateInvItems(self,ItKe_Bromor,1);
CreateInvItems(self,ItKe_Rune_MIS,1);
CreateInvItems(self,ItWr_Bloody_MIS,1);
CreateInvItems(self,ItWr_Pfandbrief_MIS,1);
CreateInvItems(self,ItWr_Map_OldWorld_Oremines_MIS,1);
CreateInvItems(self,ItWr_Map_OldWorld_Oremines_Small_MIS,1);
CreateInvItems(self,ItWr_Manowar,1);
CreateInvItems(self,ItWr_KDWLetter,1);
CreateInvItems(self,ItWr_GilbertLetter,1);
CreateInvItems(self,ItMi_InnosEye_MIS,1);
CreateInvItems(self,ItMi_InnosEye_Discharged_Mis,1);
CreateInvItems(self,ItMi_InnosEye_Broken_Mis,1);
CreateInvItems(self,ItWr_PermissionToWearInnosEye_MIS,1);
CreateInvItems(self,ItWr_XardasBookForPyrokar_Mis,1);
CreateInvItems(self,ItKe_CHEST_SEKOB_XARDASBOOK_MIS,1);
CreateInvItems(self,ItWr_CorneliusTagebuch_Mis,1);
CreateInvItems(self,ITWR_DementorObsessionBook_MIS,1);
CreateInvItems(self,ItWr_PyrokarsObsessionList,1);
CreateInvItems(self,ItPo_HealHilda_MIS,1);
CreateInvItems(self,ItMw_MalethsGehstock_MIS,1);
CreateInvItems(self,ItMi_MalethsBanditGold,1);
CreateInvItems(self,ItMi_Moleratlubric_MIS,1);
CreateInvItems(self,ItWr_BabosLetter_MIS,1);
CreateInvItems(self,ItWr_BabosPinUp_MIS,1);
CreateInvItems(self,ItWr_BabosDocs_MIS,1);
CreateInvItems(self,ItKe_IgarazChest_Mis,1);
CreateInvItems(self,ItWr_Astronomy_Mis,1);
CreateInvItems(self,ItPo_HealObsession_MIS,1);
CreateInvItems(self,ItSe_Golemchest_Mis,1);
CreateInvItems(self,ItWr_ShatteredGolem_MIS,1);
CreateInvItems(self,ItWr_DiegosLetter_MIS,1);
CreateInvItems(self,ItSe_DiegosTreasure_Mis,1);
CreateInvItems(self,ItMi_UltharsHolyWater_Mis,1);
CreateInvItems(self,ItWr_MinenAnteil_Mis,1);
CreateInvItems(self,ItAm_Prot_BlackEye_Mis,1);
CreateInvItems(self,ItMi_KarrasBlessedStone_Mis,1);
CreateInvItems(self,ItWr_RichterKomproBrief_MIS,1);
CreateInvItems(self,ItWr_MorgahardTip,1);
CreateInvItems(self,ItWr_Map_Shrine_MIS,1);
CreateInvItems(self,ItWr_VinosKellergeister_Mis,1);
CreateInvItems(self,ItAm_Mana_Angar_MIS,1);
CreateInvItems(self,ItMW_1H_FerrosSword_Mis,1);
CreateInvItems(self,ItMi_KerolothsGeldbeutel_MIS,1);
CreateInvItems(self,ItMi_KerolothsGeldbeutelLeer_MIS,1);
CreateInvItems(self,ItRw_SengrathsArmbrust_MIS,1);
CreateInvItems(self,ItAt_TalbinsLurkerSkin,1);
CreateInvItems(self,ItAt_DragonEgg_MIS,1);
CreateInvItems(self,ItRi_OrcEliteRing,1);
CreateInvItems(self,ItPo_DragonEggDrinkNeoras_MIS,1);
CreateInvItems(self,ItWr_Map_Orcelite_MIS,1);
CreateInvItems(self,ItWr_Map_Caves_MIS,1);
CreateInvItems(self,ItWr_XardasLetterToOpenBook_MIS,1);
CreateInvItems(self,ItKe_MonastarySecretLibrary_Mis,1);
CreateInvItems(self,ItWr_HallsofIrdorath_Mis,1);
CreateInvItems(self,ItWr_HallsofIrdorath_Open_Mis,1);
CreateInvItems(self,ItWr_XardasSeamapBook_Mis,1);
CreateInvItems(self,ItWr_Seamap_Irdorath,1);
CreateInvItems(self,ITWr_ForgedShipLetter_MIS,1);
CreateInvItems(self,ItKe_OC_MainGate_MIS,1);
CreateInvItems(self,ItKe_Ship_Levelchange_MIS,1);
CreateInvItems(self,ItPo_PotionOfDeath_01_Mis,1);
CreateInvItems(self,ItPo_PotionOfDeath_02_Mis,1);
CreateInvItems(self,ItAm_AmulettOfDeath_Mis,1);
CreateInvItems(self,ItPo_HealRandolph_MIS,1);
CreateInvItems(self,ItSe_XardasNotfallBeutel_MIS,1);
CreateInvItems(self,ItWr_XardasErmahnungFuerIdioten_MIS,1);
CreateInvItems(self,ItWr_Krypta_Garon,1);
CreateInvItems(self,ItKe_OrkKnastDI_MIS,1);
CreateInvItems(self,ItKe_EVT_UNDEAD_01,1);
CreateInvItems(self,ItKe_EVT_UNDEAD_02,1);
CreateInvItems(self,ItKe_LastDoorToUndeadDrgDI_MIS,1);
CreateInvItems(self,ItWr_LastDoorToUndeadDrgDI_MIS,1);
CreateInvItems(self,ItKe_ChestMasterDementor_MIS,1);
CreateInvItems(self,ItWr_Rezept_MegaDrink_MIS,1);
CreateInvItems(self,ItWr_Diary_BlackNovice_MIS,1);
CreateInvItems(self,ItWr_ZugBruecke_MIS,1);
CreateInvItems(self,ItMi_PowerEye,1);
};
|
D
|
reprehensible acquisitiveness
extreme greed for material wealth
|
D
|
/Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Blog.build/BlogTheme/Nodes/Node+Sidebar.swift.o : /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Head.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Grid.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Page.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Theme+Blog.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/SocialMediaLink.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/main.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Icon.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Sidebar.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Header.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Footer.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/BlogDateFormatter.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Posts.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+PageContent.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+PostExcerpt.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+TagList.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Post.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/BlogHTMLFactory.swift /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Codextended.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Splash.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Publish.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Ink.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/SplashPublishPlugin.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Sweep.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Files.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/CoreData.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreImage.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/QuartzCore.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/Metal.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/CoreLocation.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/CloudKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/AppKit.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/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Plot.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/ShellOut.swiftmodule /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/dyld.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Codextended.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/PublishCLICore.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Splash.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Publish.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Ink.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/SplashPublishPlugin.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Sweep.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Files.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Plot.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/ShellOut.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/compact_unwind_encoding.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreData.framework/Headers/CoreData.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.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/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreLocation.framework/Headers/CoreLocation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CloudKit.framework/Headers/CloudKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/AppKit.framework/Headers/AppKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Blog.build/BlogTheme/Nodes/Node+Sidebar~partial.swiftmodule : /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Head.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Grid.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Page.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Theme+Blog.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/SocialMediaLink.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/main.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Icon.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Sidebar.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Header.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Footer.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/BlogDateFormatter.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Posts.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+PageContent.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+PostExcerpt.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+TagList.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Post.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/BlogHTMLFactory.swift /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Codextended.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Splash.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Publish.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Ink.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/SplashPublishPlugin.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Sweep.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Files.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/CoreData.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreImage.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/QuartzCore.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/Metal.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/CoreLocation.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/CloudKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/AppKit.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/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Plot.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/ShellOut.swiftmodule /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/dyld.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Codextended.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/PublishCLICore.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Splash.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Publish.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Ink.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/SplashPublishPlugin.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Sweep.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Files.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Plot.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/ShellOut.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/compact_unwind_encoding.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreData.framework/Headers/CoreData.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.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/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreLocation.framework/Headers/CoreLocation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CloudKit.framework/Headers/CloudKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/AppKit.framework/Headers/AppKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Blog.build/BlogTheme/Nodes/Node+Sidebar~partial.swiftdoc : /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Head.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Grid.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Page.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Theme+Blog.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/SocialMediaLink.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/main.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Icon.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Sidebar.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Header.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Footer.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/BlogDateFormatter.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Posts.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+PageContent.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+PostExcerpt.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+TagList.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Post.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/BlogHTMLFactory.swift /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Codextended.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Splash.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Publish.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Ink.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/SplashPublishPlugin.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Sweep.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Files.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/CoreData.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreImage.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/QuartzCore.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/Metal.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/CoreLocation.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/CloudKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/AppKit.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/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Plot.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/ShellOut.swiftmodule /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/dyld.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Codextended.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/PublishCLICore.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Splash.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Publish.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Ink.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/SplashPublishPlugin.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Sweep.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Files.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Plot.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/ShellOut.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/compact_unwind_encoding.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreData.framework/Headers/CoreData.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.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/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreLocation.framework/Headers/CoreLocation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CloudKit.framework/Headers/CloudKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/AppKit.framework/Headers/AppKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Blog.build/BlogTheme/Nodes/Node+Sidebar~partial.swiftsourceinfo : /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Head.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Grid.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Page.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Theme+Blog.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/SocialMediaLink.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/main.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Icon.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Sidebar.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Header.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Footer.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/BlogDateFormatter.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Posts.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+PageContent.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+PostExcerpt.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+TagList.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/Nodes/Node+Post.swift /Users/lucasfarah/Documents/lucasfarah.github.io/Sources/Blog/BlogTheme/BlogHTMLFactory.swift /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Codextended.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Splash.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Publish.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Ink.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/SplashPublishPlugin.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Sweep.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Files.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/CoreData.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreImage.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/QuartzCore.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/Metal.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/CoreLocation.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/CloudKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/AppKit.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/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Plot.swiftmodule /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/ShellOut.swiftmodule /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/dyld.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Codextended.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/PublishCLICore.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Splash.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Publish.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Ink.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/SplashPublishPlugin.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Sweep.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Files.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/Plot.build/module.modulemap /Users/lucasfarah/Documents/lucasfarah.github.io/.build/x86_64-apple-macosx/debug/ShellOut.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/compact_unwind_encoding.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreData.framework/Headers/CoreData.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.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/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreLocation.framework/Headers/CoreLocation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CloudKit.framework/Headers/CloudKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/AppKit.framework/Headers/AppKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
|
D
|
module progress.counter;
import progress;
import std.algorithm : min;
import std.conv : to;
class Counter : Infinite
{
this()
{
this.hide_cursor = true;
super();
}
override void force_update()
{
this.write(this.index.to!string);
}
}
class Countdown : Progress
{
this()
{
this.hide_cursor = true;
super();
}
override void force_update()
{
this.write(this.remaining.to!string);
}
}
class Stack : Progress
{
string[] phases;
this()
{
this.hide_cursor = true;
this.phases = [" ", "▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"];
super();
}
override void force_update()
{
size_t nphases = this.phases.length;
size_t index = min(nphases - 1, cast(size_t)(this.progress * nphases));
this.write(this.phases[index]);
}
}
class Pie : Stack
{
this()
{
super();
this.phases = ["○", "◔", "◑", "◕", "●"];
}
}
|
D
|
/Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/Core.build/MediaType.swift.o : /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Data+Base64URL.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/NestedData.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Thread+Async.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Deprecated.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/CodableReflection/ReflectionDecodable.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/CodableReflection/Decodable+Reflectable.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Reflectable.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/LosslessDataConvertible.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/File.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/MediaType.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/OptionalType.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Process+Execute.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/HeaderValue.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/DirectoryConfig.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/CaseInsensitiveString.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Future+Unwrap.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/FutureEncoder.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/CoreError.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/String+Utilities.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/DataCoders.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/CodableReflection/ReflectionDecoders.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Exports.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Data+Hex.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/BasicKey.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/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.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/user/Documents/RiseTimeAssets/server/.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/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.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/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.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/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/Core.build/MediaType~partial.swiftmodule : /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Data+Base64URL.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/NestedData.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Thread+Async.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Deprecated.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/CodableReflection/ReflectionDecodable.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/CodableReflection/Decodable+Reflectable.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Reflectable.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/LosslessDataConvertible.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/File.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/MediaType.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/OptionalType.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Process+Execute.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/HeaderValue.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/DirectoryConfig.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/CaseInsensitiveString.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Future+Unwrap.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/FutureEncoder.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/CoreError.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/String+Utilities.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/DataCoders.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/CodableReflection/ReflectionDecoders.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Exports.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Data+Hex.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/BasicKey.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/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.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/user/Documents/RiseTimeAssets/server/.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/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.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/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.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/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/Core.build/MediaType~partial.swiftdoc : /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Data+Base64URL.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/NestedData.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Thread+Async.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Deprecated.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/CodableReflection/ReflectionDecodable.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/CodableReflection/Decodable+Reflectable.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Reflectable.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/LosslessDataConvertible.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/File.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/MediaType.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/OptionalType.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Process+Execute.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/HeaderValue.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/DirectoryConfig.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/CaseInsensitiveString.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Future+Unwrap.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/FutureEncoder.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/CoreError.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/String+Utilities.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/DataCoders.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/CodableReflection/ReflectionDecoders.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Exports.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/Data+Hex.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Core/BasicKey.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/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.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/user/Documents/RiseTimeAssets/server/.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/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.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/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.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
|
module cp.tests.common;
import core.thread : Fiber;
import std.algorithm : countUntil;
import std.exception: enforce;
import std.string: strip;
import cp.kernel;
import cp.communicationchannel;
enum FiberStrategy {none, callOnFlush, yieldOnFlush}
class DummyFile
{
private string _buffer;
private Fiber _fiber;
private FiberStrategy _fiberStrategy;
this(Fiber fiber, FiberStrategy fiberStrategy)
{
_fiber = fiber;
_fiberStrategy = fiberStrategy;
}
@property size_t size()
{
return _buffer.length;
}
string readln()
{
auto p = _buffer.countUntil("\n");
enforce(p != -1, "Buffer is empty");
string result = _buffer[0..p + 1];
_buffer = _buffer[p + 1..$];
return result;
}
void write(string s)
{
_buffer = _buffer ~ s;
}
void writeln(string s)
{
write(s ~ "\n");
}
void flush()
{
switch (_fiberStrategy)
{
case FiberStrategy.callOnFlush:
_fiber.call();
break;
case FiberStrategy.yieldOnFlush:
_fiber.yield();
break;
default:
}
}
char[] rawRead(char[] buffer)
{
char[] result = new char[](buffer.length);
result = _buffer.dup;
if (buffer.length > _buffer.length)
{
_buffer = "";
}
else
{
_buffer = _buffer[buffer.length..$];
}
return result;
}
}
alias TestDelegate = void delegate (DummyFile i, DummyFile o, DummyFile e);
void executeTestcase(string puzzleName, string testcase, TestDelegate testDelegate)
{
class DummyCommunicationChannel : IfCommunicationChannel
{
private Fiber _fiber;
private DummyFile _i;
private DummyFile _o;
private DummyFile _e;
void openChannel()
{
_fiber = new Fiber(delegate void() {
testDelegate(_i, _o, _e);
});
_i = new DummyFile(_fiber, FiberStrategy.callOnFlush);
_o = new DummyFile(_fiber, FiberStrategy.yieldOnFlush);
_e = new DummyFile(_fiber, FiberStrategy.none);
}
void sentData(string data)
{
_i.write(data);
}
void flush()
{
_i.flush();
//_fiber.call();
}
string receiveData()
{
if (_o.size == 0)
{
return "";
}
else
{
auto buffer = new char[1024];
string result;
do
{
auto data = _o.rawRead(buffer);
result ~= data.idup.strip;
} while (_o.size > 0);
return result;
}
}
string receiveDebug()
{
return "";
}
void closeChannel()
{
}
}
auto kernel = Kernel.create();
kernel.session.logger.setDebug(true);
auto dummyChannel = new DummyCommunicationChannel();
kernel.puzzleRuntime.playPuzzle(puzzleName, [testcase], dummyChannel);
}
|
D
|
/Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Command.build/Utilities/CommandError.swift.o : /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Command/Command.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Base/CommandRunnable.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Run/Output+Autocomplete.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Config/CommandConfig.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Base/CommandOption.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Run/Console+Run.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Run/Output+Help.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Group/CommandGroup.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Group/BasicCommandGroup.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Utilities/CommandError.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Config/Commands.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Utilities/Utilities.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Utilities/Exports.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Command/CommandArgument.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Run/CommandInput.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Run/CommandContext.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/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Service.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Console.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Logging.swiftmodule /Users/nice/HelloWord/.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/nice/HelloWord/.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/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/nice/HelloWord/.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/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIOAtomics/include/cpp_magic.h /Users/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIODarwin/include/c_nio_darwin.h /Users/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIOAtomics/include/c-atomics.h /Users/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIOLinux/include/c_nio_linux.h /Users/nice/HelloWord/.build/checkouts/swift-nio-zlib-support.git--6556802241718767980/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CCryptoOpenSSL.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Command.build/CommandError~partial.swiftmodule : /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Command/Command.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Base/CommandRunnable.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Run/Output+Autocomplete.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Config/CommandConfig.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Base/CommandOption.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Run/Console+Run.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Run/Output+Help.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Group/CommandGroup.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Group/BasicCommandGroup.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Utilities/CommandError.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Config/Commands.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Utilities/Utilities.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Utilities/Exports.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Command/CommandArgument.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Run/CommandInput.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Run/CommandContext.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/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Service.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Console.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Logging.swiftmodule /Users/nice/HelloWord/.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/nice/HelloWord/.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/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/nice/HelloWord/.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/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIOAtomics/include/cpp_magic.h /Users/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIODarwin/include/c_nio_darwin.h /Users/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIOAtomics/include/c-atomics.h /Users/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIOLinux/include/c_nio_linux.h /Users/nice/HelloWord/.build/checkouts/swift-nio-zlib-support.git--6556802241718767980/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CCryptoOpenSSL.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Command.build/CommandError~partial.swiftdoc : /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Command/Command.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Base/CommandRunnable.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Run/Output+Autocomplete.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Config/CommandConfig.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Base/CommandOption.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Run/Console+Run.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Run/Output+Help.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Group/CommandGroup.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Group/BasicCommandGroup.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Utilities/CommandError.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Config/Commands.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Utilities/Utilities.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Utilities/Exports.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Command/CommandArgument.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Run/CommandInput.swift /Users/nice/HelloWord/.build/checkouts/console.git-2755603573940926646/Sources/Command/Run/CommandContext.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/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Service.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Console.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Logging.swiftmodule /Users/nice/HelloWord/.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/nice/HelloWord/.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/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/nice/HelloWord/.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/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIOAtomics/include/cpp_magic.h /Users/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIODarwin/include/c_nio_darwin.h /Users/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIOAtomics/include/c-atomics.h /Users/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIOLinux/include/c_nio_linux.h /Users/nice/HelloWord/.build/checkouts/swift-nio-zlib-support.git--6556802241718767980/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CCryptoOpenSSL.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
|
D
|
/**
* Describes a back-end compiler and implements compiler-specific actions.
*
* Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/compiler.d, _compiler.d)
* Documentation: https://dlang.org/phobos/dmd_compiler.html
* Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/compiler.d
*/
module dmd.compiler;
import core.stdc.string;
import dmd.astcodegen;
import dmd.astenums;
import dmd.arraytypes;
import dmd.dmodule;
import dmd.dscope;
import dmd.dsymbolsem;
import dmd.errors;
import dmd.expression;
import dmd.globals;
import dmd.id;
import dmd.identifier;
import dmd.mtype;
import dmd.parse;
import dmd.root.array;
import dmd.root.ctfloat;
import dmd.semantic2;
import dmd.semantic3;
import dmd.tokens;
import dmd.statement;
version (DMDLIB)
{
version = CallbackAPI;
}
extern (C++) __gshared
{
bool includeImports = false;
// array of module patterns used to include/exclude imported modules
Array!(const(char)*) includeModulePatterns;
Modules compiledImports;
}
/**
* A data structure that describes a back-end compiler and implements
* compiler-specific actions.
*/
extern (C++) struct Compiler
{
/******************************
* Encode the given expression, which is assumed to be an rvalue literal
* as another type for use in CTFE.
* This corresponds roughly to the idiom *(Type *)&e.
*/
extern (C++) static Expression paintAsType(UnionExp* pue, Expression e, Type type)
{
union U
{
int int32value;
long int64value;
float float32value;
double float64value;
}
U u = void;
assert(e.type.size() == type.size());
switch (e.type.ty)
{
case Tint32:
case Tuns32:
u.int32value = cast(int) e.toInteger();
break;
case Tint64:
case Tuns64:
u.int64value = cast(long) e.toInteger();
break;
case Tfloat32:
u.float32value = cast(float) e.toReal();
break;
case Tfloat64:
u.float64value = cast(double) e.toReal();
break;
case Tfloat80:
assert(e.type.size() == 8); // 64-bit target `real`
goto case Tfloat64;
default:
assert(0, "Unsupported source type");
}
real_t r = void;
switch (type.ty)
{
case Tint32:
case Tuns32:
emplaceExp!(IntegerExp)(pue, e.loc, u.int32value, type);
break;
case Tint64:
case Tuns64:
emplaceExp!(IntegerExp)(pue, e.loc, u.int64value, type);
break;
case Tfloat32:
r = u.float32value;
emplaceExp!(RealExp)(pue, e.loc, r, type);
break;
case Tfloat64:
r = u.float64value;
emplaceExp!(RealExp)(pue, e.loc, r, type);
break;
case Tfloat80:
assert(type.size() == 8); // 64-bit target `real`
goto case Tfloat64;
default:
assert(0, "Unsupported target type");
}
return pue.exp();
}
/******************************
* For the given module, perform any post parsing analysis.
* Certain compiler backends (ie: GDC) have special placeholder
* modules whose source are empty, but code gets injected
* immediately after loading.
*/
extern (C++) static void onParseModule(Module m)
{
}
/**
* A callback function that is called once an imported module is
* parsed. If the callback returns true, then it tells the
* frontend that the driver intends on compiling the import.
*/
extern(C++) static bool onImport(Module m)
{
if (includeImports && m.filetype == FileType.d)
{
if (includeImportedModuleCheck(ModuleComponentRange(
m.md ? m.md.packages : [], m.ident, m.isPackageFile)))
{
if (global.params.verbose)
message("compileimport (%s)", m.srcfile.toChars);
compiledImports.push(m);
return true; // this import will be compiled
}
}
return false; // this import will not be compiled
}
version (CallbackAPI)
{
alias OnStatementSemanticStart = void function(Statement, Scope*);
alias OnStatementSemanticDone = void function(Statement, Scope*);
/**
* Used to insert functionality before the start of the
* semantic analysis of a statement when importing DMD as a library
*/
__gshared OnStatementSemanticStart onStatementSemanticStart
= function void(Statement s, Scope *sc) {};
/**
* Used to insert functionality after the end of the
* semantic analysis of a statement when importing DMD as a library
*/
__gshared OnStatementSemanticDone onStatementSemanticDone
= function void(Statement s, Scope *sc) {};
}
}
/******************************
* Private helpers for Compiler::onImport.
*/
// A range of component identifiers for a module
private struct ModuleComponentRange
{
Identifier[] packages;
Identifier name;
bool isPackageFile;
size_t index;
@property auto totalLength() const { return packages.length + 1 + (isPackageFile ? 1 : 0); }
@property auto empty() { return index >= totalLength(); }
@property auto front() const
{
if (index < packages.length)
return packages[index];
if (index == packages.length)
return name;
else
return Identifier.idPool("package");
}
void popFront() { index++; }
}
/*
* Determines if the given module should be included in the compilation.
* Returns:
* True if the given module should be included in the compilation.
*/
private bool includeImportedModuleCheck(ModuleComponentRange components)
in { assert(includeImports); }
do
{
createMatchNodes();
size_t nodeIndex = 0;
while (nodeIndex < matchNodes.length)
{
//printf("matcher ");printMatcher(nodeIndex);printf("\n");
auto info = matchNodes[nodeIndex++];
if (info.depth <= components.totalLength())
{
size_t nodeOffset = 0;
for (auto range = components;;range.popFront())
{
if (range.empty || nodeOffset >= info.depth)
{
// MATCH
return !info.isExclude;
}
if (!(range.front is matchNodes[nodeIndex + nodeOffset].id))
{
break;
}
nodeOffset++;
}
}
nodeIndex += info.depth;
}
assert(nodeIndex == matchNodes.length, "code bug");
return includeByDefault;
}
// Matching module names is done with an array of matcher nodes.
// The nodes are sorted by "component depth" from largest to smallest
// so that the first match is always the longest (best) match.
private struct MatcherNode
{
union
{
struct
{
ushort depth;
bool isExclude;
}
Identifier id;
}
this(Identifier id) { this.id = id; }
this(bool isExclude, ushort depth)
{
this.depth = depth;
this.isExclude = isExclude;
}
}
/*
* $(D includeByDefault) determines whether to include/exclude modules when they don't
* match any pattern. This setting changes depending on if the user provided any "inclusive" module
* patterns. When a single "inclusive" module pattern is given, it likely means the user only
* intends to include modules they've "included", however, if no module patterns are given or they
* are all "exclusive", then it is likely they intend to include everything except modules
* that have been excluded. i.e.
* ---
* -i=-foo // include everything except modules that match "foo*"
* -i=foo // only include modules that match "foo*" (exclude everything else)
* ---
* Note that this default behavior can be overriden using the '.' module pattern. i.e.
* ---
* -i=-foo,-. // this excludes everything
* -i=foo,. // this includes everything except the default exclusions (-std,-core,-etc.-object)
* ---
*/
private __gshared bool includeByDefault = true;
private __gshared Array!MatcherNode matchNodes;
/*
* Creates the global list of match nodes used to match module names
* given strings provided by the -i commmand line option.
*/
private void createMatchNodes()
{
static size_t findSortedIndexToAddForDepth(size_t depth)
{
size_t index = 0;
while (index < matchNodes.length)
{
auto info = matchNodes[index];
if (depth > info.depth)
break;
index += 1 + info.depth;
}
return index;
}
if (matchNodes.length == 0)
{
foreach (modulePattern; includeModulePatterns)
{
auto depth = parseModulePatternDepth(modulePattern[0 .. strlen(modulePattern)]);
auto entryIndex = findSortedIndexToAddForDepth(depth);
matchNodes.split(entryIndex, depth + 1);
parseModulePattern(modulePattern, &matchNodes[entryIndex], depth);
// if at least 1 "include pattern" is given, then it is assumed the
// user only wants to include modules that were explicitly given, which
// changes the default behavior from inclusion to exclusion.
if (includeByDefault && !matchNodes[entryIndex].isExclude)
{
//printf("Matcher: found 'include pattern', switching default behavior to exclusion\n");
includeByDefault = false;
}
}
// Add the default 1 depth matchers
MatcherNode[8] defaultDepth1MatchNodes = [
MatcherNode(true, 1), MatcherNode(Id.std),
MatcherNode(true, 1), MatcherNode(Id.core),
MatcherNode(true, 1), MatcherNode(Id.etc),
MatcherNode(true, 1), MatcherNode(Id.object),
];
{
auto index = findSortedIndexToAddForDepth(1);
matchNodes.split(index, defaultDepth1MatchNodes.length);
auto slice = matchNodes[];
slice[index .. index + defaultDepth1MatchNodes.length] = defaultDepth1MatchNodes[];
}
}
}
/*
* Determines the depth of the given module pattern.
* Params:
* modulePattern = The module pattern to determine the depth of.
* Returns:
* The component depth of the given module pattern.
*/
pure @safe
private ushort parseModulePatternDepth(const char[] modulePattern)
{
const length = modulePattern.length;
size_t i = (length && modulePattern[0] == '-'); // skip past leading '-'
// handle special case
if (i + 1 == length && modulePattern[i] == '.')
return 0;
int depth = 1;
foreach (c; modulePattern[i .. length])
depth += c == '.';
return cast(ushort)depth;
}
unittest
{
assert(".".parseModulePatternDepth == 0);
assert("-.".parseModulePatternDepth == 0);
assert("abc".parseModulePatternDepth == 1);
assert("-abc".parseModulePatternDepth == 1);
assert("abc.foo".parseModulePatternDepth == 2);
assert("-abc.foo".parseModulePatternDepth == 2);
}
/*
* Parses a 'module pattern', which is the "include import" components
* given on the command line, i.e. "-i=<module_pattern>,<module_pattern>,...".
* Params:
* modulePattern = The module pattern to parse.
* dst = the data structure to save the parsed module pattern to.
* depth = the depth of the module pattern previously retrieved from $(D parseModulePatternDepth).
*/
private void parseModulePattern(const(char)* modulePattern, MatcherNode* dst, ushort depth)
{
bool isExclude = false;
if (modulePattern[0] == '-')
{
isExclude = true;
modulePattern++;
}
*dst = MatcherNode(isExclude, depth);
dst++;
// Create and add identifiers for each component in the modulePattern
if (depth > 0)
{
auto idStart = modulePattern;
auto lastNode = dst + depth - 1;
for (; dst < lastNode; dst++)
{
for (;; modulePattern++)
{
if (*modulePattern == '.')
{
assert(modulePattern > idStart, "empty module pattern");
*dst = MatcherNode(Identifier.idPool(idStart[0 .. modulePattern - idStart]));
modulePattern++;
idStart = modulePattern;
break;
}
}
}
for (;; modulePattern++)
{
if (*modulePattern == '\0')
{
assert(modulePattern > idStart, "empty module pattern");
*lastNode = MatcherNode(Identifier.idPool(idStart[0 .. modulePattern - idStart]));
break;
}
}
}
}
|
D
|
module android.java.org.xml.sax.EntityResolver;
public import android.java.org.xml.sax.EntityResolver_d_interface;
import arsd.jni : ImportExportImpl;
mixin ImportExportImpl!EntityResolver;
import import1 = android.java.java.lang.Class;
import import0 = android.java.org.xml.sax.InputSource;
|
D
|
import std.conv, std.getopt, std.stdio;
import thrift.codegen.processor;
import thrift.server.thriftserver;
import LoadHandler;
void main(string[] args)
{
string serviceName = "";
string port = "1234";
string num_threads = "0";
string num_io_threads = "1";
try {
getopt(
args,
"name", &serviceName,
"port", &port,
"num_threads", &num_threads,
"num_io_threads", &num_io_threads);
} catch(Exception e) {
writeln(
"Usage: ThriftServer --name=N --port=P --num_threads=N --num_io_threads=N");
return;
}
auto processor = new TServiceProcessor!LoadTest(new LoadHandler());
auto server = new CppServer(processor, to!ushort(port));
server.serve();
}
|
D
|
module menu.lobby.lobby;
import std.algorithm;
import std.conv;
import std.file;
import std.format;
import std.range;
import file.option;
import file.language;
import game.harvest;
import gui;
import hardware.mouse;
import hardware.sound;
import level.level;
import menu.lobby.connect;
import menu.lobby.lists;
import menu.preview;
import menu.browser.frommain;
import menu.browser.network;
import net.client;
import net.iclient;
import net.permu;
import net.structs; // Profile
import net.versioning;
class Lobby : Window {
private:
bool _gotoGame;
bool _gotoMainMenu;
TextButton _buttonExit;
ConnectionPicker _connections;
RichClient _netClient;
Console _console;
PeerList _peerList;
ColorSelector _colorSelector;
RoomList _roomList;
Preview _preview;
Label _levelTitle;
BrowserCalledFromMainMenu _browser;
TextButton _chooseLevel;
TextButton _declareReady;
Texttype _chat;
// Rule: A GUI element is either in exactly one of these, or in none.
// _showWhenConnected is shown at the union of times when _showDuringLobby
// and _showDuringGameRoom. Due to the rule, it nonetheless shouldn't
// have anything that's in one of the other two.
Element[] _showWhenDisconnected;
Element[] _showWhenConnected;
Element[] _showDuringLobby;
Element[] _showDuringGameRoom;
public:
// Create Lobby that is not connected
this() {
super(new Geom(0, 0, gui.screenXlg, gui.screenYlg),
Lang.winLobbyTitle.transl);
commonConstructor();
showOrHideGuiBasedOnConnection();
}
// Create Lobby after finishing a game
this(RichClient aRichClient, Harvest harvest)
in { assert(aRichClient, "RichClient should exist after a netgame"); }
body {
super(new Geom(0, 0, gui.screenXlg, gui.screenYlg),
Lang.winLobbyTitle.transl);
commonConstructor();
aRichClient.console = _console;
// Game's RichClient will always return to use here, usually still
// connected. Sometimes, the connection dropped, then we get an
// unconnected RichClient -- we don't want this in _netClient.
if (aRichClient.connected) {
_netClient = aRichClient;
setOurEventHandlers();
_preview.level = _netClient.level;
_chat.text = _netClient.unsentChat;
_netClient.unsentChat = "";
_chat.on = _chat.text != "";
refreshPeerList();
}
harvest.replay.saveAsAutoReplay(harvest.level);
// Later, the Lobby should draw nice stats from the harvest.
showOrHideGuiBasedOnConnection();
}
@property gotoMainMenu() const { return _gotoMainMenu; }
@property gotoGame() const { return _gotoGame && _netClient; }
auto loseOwnershipOfRichClient()
{
assert (_netClient, "shouldn't lose ownership of null client");
auto ret = _netClient;
nullOurEventHandlers();
_netClient = null;
_gotoGame = false;
_chat.on = false;
ret.unsentChat = _chat.text;
return ret;
}
void disconnect()
{
if (offline)
return;
if (_console)
_console.add(connected ? Lang.netChatYouLoggedOut.transl
: Lang.netChatStartCancel.transl);
_netClient.disconnectAndDispose();
_netClient = null;
}
protected:
// Do this even with a level browser in focus
override void workSelf()
{
if (_browser && (_browser.gotoGame || _browser.gotoMainMenu)) {
assert (_netClient);
if (_browser.gotoGame)
_netClient.selectLevel(_browser.fileRecent.readIntoVoidArray);
destroyBrowser();
}
if (_netClient)
_netClient.calc();
}
// Do this only when there is no level browser
override void calcSelf()
{
showOrHideGuiBasedOnConnection();
handleRightClick();
if (! _netClient)
return;
scope (success)
showOrHideGuiBasedOnConnection();
if (_colorSelector.execute) {
// The color selector doesn't return execute == true when you
// click the button that's already on.
if (_colorSelector.observing)
_netClient.ourFeeling = Profile.Feeling.observing;
else {
_netClient.ourStyle = _colorSelector.style;
file.option.networkLastStyle = _colorSelector.style;
}
}
if (_roomList.executeExistingRoom)
_netClient.gotoExistingRoom(_roomList.executeExistingRoomID);
else if (_roomList.executeNewRoom)
_netClient.createRoom();
if (_declareReady.execute) {
assert (_netClient, "declare ready without net client running");
assert (_netClient.mayWeDeclareReady, "declare ready disallowed");
if (_declareReady.on) {
_declareReady.on = false;
_netClient.ourFeeling = Profile.Feeling.thinking;
}
else {
_declareReady.on = true;
_netClient.ourFeeling = Profile.Feeling.ready;
}
}
}
private:
void commonConstructor()
{
_buttonExit = new TextButton(new Geom(20, 20, 120, 20, From.BOT_RIG),
Lang.commonBack.transl);
_buttonExit.hotkey = file.option.keyMenuExit;
_buttonExit.onExecute = &this.onExitButtonExecute;
addChild(_buttonExit);
_console = new LobbyConsole(new Geom(0, 60, xlg-40, 160, From.BOTTOM));
addChild(_console);
_connections = new ConnectionPicker(new Geom(0, 40, 320,180,From.TOP));
_connections.onExecute = &this.acceptConnection;
_showWhenDisconnected ~= _connections;
_peerList = new PeerList(new Geom(20, 40, 120, 20*8));
_showWhenConnected ~= _peerList;
_colorSelector = new ColorSelector(new Geom(160, 40, 40, 20*8));
_showWhenConnected ~= _colorSelector;
_roomList = new RoomList(new Geom(20, 40, 300, 20*8, From.TOP_RIGHT));
_showDuringLobby ~= _roomList;
_preview = new Preview(new Geom(_roomList.geom));
_showDuringGameRoom ~= _preview;
enum midButtonsY = 60+20*8;
_chooseLevel = new TextButton(new Geom(20, midButtonsY, 120, 20,
From.TOP_RIGHT), Lang.winLobbySelectLevel.transl);
_chooseLevel.onExecute = ()
{
assert (! _browser);
_browser = new BrowserNetwork();
addFocus(_browser);
};
_chooseLevel.hotkey = keyMenuEdit;
_showDuringGameRoom ~= _chooseLevel;
_levelTitle = new Label(new Geom(30 + _chooseLevel.xlg,
midButtonsY, 300, 20, From.TOP_RIGHT));
_levelTitle.undrawBeforeDraw = true;
_showDuringGameRoom ~= _levelTitle;
_declareReady = new TextButton(new Geom(20, midButtonsY,
_peerList.xlg, 20), Lang.winLobbyReady.transl);
_declareReady.hotkey = keyMenuOkay;
addChild(_declareReady);
// See showOrHideGuiBasedOnConnection for particular showing/hiding,
// because _declareReady isn't in any of the _showXyz arrays
enum chatLabelXl = 50;
_chat = new Texttype(new Geom(20 + chatLabelXl, 20,
gui.screenXlg - _buttonExit.xlg - chatLabelXl - 60,
20, From.BOT_LEF));
_chat.allowScrolling = true;
_chat.onEnter = ()
{
if (_chat.text == "")
return;
assert (connected);
_netClient.sendChatMessage(_chat.text);
_chat.text = "";
};
_chat.onEsc = () { _chat.text = ""; };
_chat.hotkey = file.option.keyChat;
_showWhenConnected ~= _chat;
_showWhenConnected ~= new Label(new Geom(20, 20, chatLabelXl,
20, From.BOT_LEF), Lang.winLobbyChat.transl);
foreach (e; chain(_showWhenDisconnected, _showWhenConnected,
_showDuringLobby, _showDuringGameRoom))
addChild(e);
}
bool connected() const { return _netClient && _netClient.connected; }
bool connecting() const { return _netClient && _netClient.connecting; }
bool offline() const { return ! connected && ! connecting; }
bool inLobby() const { return connected && _netClient.ourProfile.room ==0;}
void showOrHideGuiBasedOnConnection()
{
_showWhenDisconnected.each!(e => e.shown = offline);
_showWhenConnected .each!(e => e.shown = connected);
_showDuringLobby .each!(e => e.shown = connected && inLobby);
_showDuringGameRoom .each!(e => e.shown = connected && ! inLobby);
_buttonExit.text = inLobby ? Lang.winLobbyDisconnect.transl
: connected ? Lang.winLobbyRoomLeave.transl
: connecting ? Lang.commonCancel.transl
: Lang.commonBack.transl;
if (! connected || inLobby)
// See also refreshPeerList for visibility of this button
_declareReady.shown = false;
}
void acceptConnection(INetClient cli, NetClientCfg cfgThatWasUsed)
{
_netClient = new RichClient(cli, _console);
setOurEventHandlers();
_console.add("Lix %s, enet %s. %s %s:%d...".format(gameVersion,
_netClient.enetLinkedVersion, Lang.netChatStartClient.transl,
cfgThatWasUsed.hostname, cfgThatWasUsed.port));
}
// This is dubious. Nepster suggests that we shouldn't treat RMB special
// ever, because it should be remappable.
void handleRightClick()
{
if (! hardware.mouse.mouseClickRight)
return;
if (offline)
_gotoMainMenu = true;
else if (connecting)
disconnect();
}
void onExitButtonExecute()
{
if (connected && ! inLobby) {
_netClient.gotoExistingRoom(Room(0));
_preview.level = null;
_levelTitle.text = "";
}
else {
if (offline)
_gotoMainMenu = true;
disconnect();
}
}
void refreshPeerList()
{
_peerList.recreateButtonsFor(_netClient.profilesInOurRoom.values);
_colorSelector.style = _netClient.ourProfile.style;
if (_netClient.ourProfile.feeling == Profile.Feeling.observing)
_colorSelector.setObserving();
_declareReady.shown = _netClient.mayWeDeclareReady;
_declareReady.on = _netClient.ourProfile.feeling
== Profile.Feeling.ready;
}
void destroyBrowser()
{
if (! _browser)
return;
rmFocus(_browser);
destroy(_browser);
_browser = null;
}
// Keep this the last private function in this class, it's so long
void setOurEventHandlers()
{
assert (_netClient);
// We don't print anything on connecting. Entering the lobby will
// generate a message anyway, including an update to the peer list.
_netClient.onConnect = null;
_netClient.onCannotConnect = () { _netClient = null; };
_netClient.onConnectionLost = () { _netClient = null; };
_netClient.onPeerDisconnect = (string name) { refreshPeerList(); };
_netClient.onPeerJoinsRoom = (const(Profile*) profile)
{
refreshPeerList();
playLoud(Sound.JOIN);
};
_netClient.onPeerLeavesRoomTo = (string name, Room toRoom)
{
refreshPeerList();
// If we're in the lobby, we'll get another packet with the
// new possible rooms.
};
_netClient.onPeerChangesProfile = (const(Profile*))
{
refreshPeerList();
};
_netClient.onWeChangeRoom = (Room toRoom)
{
refreshPeerList();
// We will later get a packet that tells us the rooms in the lobby.
// Until then, don't show anything in this list. If we're not
// in the lobby, the room list shouldn't even be shown anyway.
_roomList.clearButtons();
};
_netClient.onListOfExistingRooms = (const(Room[]) rooms,
const(Profile[]) profiles
) {
_roomList.recreateButtonsFor(rooms, profiles);
};
_netClient.onLevelSelect = (string senderName, const(ubyte[]) data)
{
refreshPeerList();
_preview.level = _netClient.level;
_levelTitle.text = _netClient.level.name;
_console.add(Lang.netChatLevelChange.translf(
senderName, _netClient.level.name));
playLoud(Sound.pageTurn);
};
_netClient.onGameStart = (Permu permu)
{
refreshPeerList();
destroyBrowser(); // Observers got stuck in their browser otherwise
_console.add(Lang.netGameHowToChat.translf(keyChat.nameLong));
_gotoGame = true;
};
}
void nullOurEventHandlers()
{
assert (_netClient, "null only when we own a netClient");
_netClient.onConnect = null;
_netClient.onCannotConnect = null;
_netClient.onConnectionLost = null;
_netClient.onPeerDisconnect = null;
_netClient.onPeerJoinsRoom = null;
_netClient.onPeerLeavesRoomTo = null;
_netClient.onPeerChangesProfile = null;
_netClient.onWeChangeRoom = null;
_netClient.onListOfExistingRooms = null;
_netClient.onLevelSelect = null;
_netClient.onGameStart = null;
}
}
|
D
|
/Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/DerivedData/ParserKanna/Build/Intermediates/Pods.build/Debug-iphonesimulator/Kanna.build/Objects-normal/x86_64/libxmlParserOption.o : /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Kanna/Source/CSS.swift /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Kanna/Source/Kanna.swift /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Kanna/Source/libxml/libxmlHTMLDocument.swift /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Kanna/Source/libxml/libxmlHTMLNode.swift /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Kanna/Source/libxml/libxmlParserOption.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Kanna/Modules/module.modulemap /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Target\ Support\ Files/Kanna/Kanna-umbrella.h /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/DerivedData/ParserKanna/Build/Intermediates/Pods.build/Debug-iphonesimulator/Kanna.build/unextended-module.modulemap /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/Foundation.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/Dispatch.swiftmodule /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/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule
/Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/DerivedData/ParserKanna/Build/Intermediates/Pods.build/Debug-iphonesimulator/Kanna.build/Objects-normal/x86_64/libxmlParserOption~partial.swiftmodule : /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Kanna/Source/CSS.swift /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Kanna/Source/Kanna.swift /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Kanna/Source/libxml/libxmlHTMLDocument.swift /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Kanna/Source/libxml/libxmlHTMLNode.swift /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Kanna/Source/libxml/libxmlParserOption.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Kanna/Modules/module.modulemap /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Target\ Support\ Files/Kanna/Kanna-umbrella.h /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/DerivedData/ParserKanna/Build/Intermediates/Pods.build/Debug-iphonesimulator/Kanna.build/unextended-module.modulemap /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/Foundation.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/Dispatch.swiftmodule /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/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule
/Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/DerivedData/ParserKanna/Build/Intermediates/Pods.build/Debug-iphonesimulator/Kanna.build/Objects-normal/x86_64/libxmlParserOption~partial.swiftdoc : /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Kanna/Source/CSS.swift /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Kanna/Source/Kanna.swift /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Kanna/Source/libxml/libxmlHTMLDocument.swift /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Kanna/Source/libxml/libxmlHTMLNode.swift /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Kanna/Source/libxml/libxmlParserOption.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Kanna/Modules/module.modulemap /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/Pods/Target\ Support\ Files/Kanna/Kanna-umbrella.h /Users/nikolay/Documents/FolderWorkObjective-C/Parsers/ParserKanna/DerivedData/ParserKanna/Build/Intermediates/Pods.build/Debug-iphonesimulator/Kanna.build/unextended-module.modulemap /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/Foundation.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/Dispatch.swiftmodule /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/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule
|
D
|
/*
* This file is part of serpent.
*
* Copyright © 2019-2020 Lispy Snake, Ltd.
*
* 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 serpent.ecs.view;
public import serpent.ecs.component;
public import serpent.ecs.entity;
public import serpent.ecs.entitymanager;
public import serpent.ecs.policy;
/**
* A view controls access to the underlying EntityManager and ensures
* we remain as thread-safe as possible.
*/
final struct View(T : DataPolicy)
{
private:
EntityManager _manager;
package:
this(EntityManager ent)
{
this._manager = ent;
}
public:
@disable this();
static if (is(T : ReadOnly))
{
/* READ-ONLY APIs */
/**
* Return data for the given entity ID
*/
pragma(inline, true) final const(C*) data(C)(EntityID id) @safe
{
return _manager.dataRO!C(id);
}
/**
* Iterate all entities with the matching components
*/
pragma(inline, true) final auto withComponents(C...)() @safe
{
return _manager.withComponentsRO!C;
}
/**
* Iterate all entities with matching components in
* chunked ranges.
*/
pragma(inline, true) final auto withComponentsChunked(C...)() @safe
{
return _manager.withComponentsChunkedRO!C;
}
}
else
{
/* READ-WRITE APIs */
/**
* Request data for an entity that was created before this
* frame tick.
*/
pragma(inline, true) final C* data(C)(EntityID id) @safe
{
return _manager.dataRW!C(id);
}
/**
* Request a new entity construction to happen immediately.
* This is a blocking call as an entity identifier needs
* to be allocated.
*/
pragma(inline, true) final EntityID createEntity() @safe
{
return _manager.create();
}
/**
* Immediately create a new entity with the given components. Note it
* is not possible to use this in conjunction with the deferred APIs
*
* Care should be taken when used with threading.
*
* If creating entities in dense loops + threading, then the create()
* function should be used instead in conjunction with addComponentDeferred
*/
pragma(inline, true) final EntityID createEntityWithComponents(C...)() @safe
{
return _manager.createWithComponents!C();
}
/**
* Immediately add a component to the entity. Care must be taken
* when used with threading.
*/
pragma(inline, true) final C* addComponent(C)(EntityID id) @safe
{
return addComponent!C(id, C.init);
}
/**
* Immediately add component to entity by value. Care must be taken
* when used with threading.
*/
pragma(inline, true) final C* addComponent(C)(EntityID id, C datum) @safe
{
return addComponent!C(id, datum);
}
/**
* Immediately add component to entity by reference. Care must be taken
* when used with threading.
*/
pragma(inline, true) final C* addComponent(C)(EntityID id, ref C datum) @safe
{
return _manager.addComponent!C(id, datum);
}
/**
* Schedule addition of a component to the entity
*/
pragma(inline, true) final void addComponentDeferred(C)(EntityID) @safe
{
addComponentDeferred!C(id, C.init);
}
/**
* Schedule addition of component to entity by value
*/
pragma(inline, true) final void addComponentDeferred(C)(EntityID id, C datum) @safe
{
addComponentDeferred!C(id, datum);
}
/**
* Schedule addition of component to entity by reference
*/
pragma(inline, true) final void addComponentDeferred(C)(EntityID id, ref C datum) @safe
{
_manager.stageComponentAssignment!C(id, datum);
}
/**
* Immediately remove the of component. Care must be taken
* when used with threading.
*/
pragma(inline, true) final void removeComponent(C)(EntityID id) @safe
{
_manager.removeComponent!C(id);
}
/**
* Schedule removal of the component from the entity.
*/
pragma(inline, true) final void removeComponentDeferred(C)(EntityID id) @safe
{
_manager.pushComponentRemoval(ComponentRemoval.fromComponent!C(id));
}
/**
* Schedule killing of the entity
*/
pragma(inline, true) final void killEntity(EntityID id) @safe
{
_manager.kill(id);
}
/**
* Iterate all entities with the matching components
*/
pragma(inline, true) final auto withComponents(C...)() @safe
{
return _manager.withComponentsRW!C;
}
/**
* Iterate all entities with matching components in
* chunked ranges.
*/
pragma(inline, true) final auto withComponentsChunked(C...)() @safe
{
return _manager.withComponentsChunkedRW!C;
}
}
/**
* Returns true if we have the given component
*/
pragma(inline, true) final bool hasComponent(C)(EntityID id) @safe
{
return _manager.hasComponent!C(id);
}
}
/**
* A ComponentRemoval is created by the view to push removals back
* to the engine to process.
*/
final package struct ComponentRemoval
{
EntityID entityID;
ulong componentID;
this(EntityID entityID, ulong componentID) @trusted nothrow
{
this.entityID = entityID;
this.componentID = componentID;
}
/**
* Create a new ComponentRemoval request for the given component static type
*/
package final static ComponentRemoval fromComponent(C)(EntityID id) @trusted nothrow
{
static assert(isValidComponent!C);
return ComponentRemoval(id, getComponentID!C);
}
};
|
D
|
/**
Ported from Microsoft's Excel SDK MemoryManager.cpp by Laeeth Isharc. See Excel SDK for copyright
The memory manager class is an update to the memory manager
in the previous release of the framework. This class provides
each thread with an array of bytes to use as temporary memory.
The size of the array, and the methods for dealing with the
memory explicitly, is in the class MemoryPool.
MemoryManager handles assigning of threads to pools, and the
creation of new pools when a thread asks for memory the first
time. Using a singleton class, the manager provides an interface
to C code into the manager. The number of unique pools starts
as TotalMemoryPools, defined in MemoryManager.h. When a new thread
needs a pool, and the current set of pools are all assigned,
the number of pools increases by a factor of two.
*/
module d_excelsdk.xlld.memorymanager;
import std.c.windows.windows;
import xlcall;
import xlcallcpp;
import std.experimental.allocator
import std.c.windows.windows;
//
// Total amount of memory to allocate for all temporary XLOPERs
//
enum MEMORYSIZE=10240;
enum MaxMemorySize=100*1024*1024;
MemoryPool excelCallPool;
static this()
{
excelCallPool.start();
}
static ~this()
{
excelCallPool.dispose();
}
struct MemoryPool
{
DWORD m_dwOwner=cast(DWORD)-1; // ID of ownning thread
ubyte[] data;
size_t curPos=0;
ubyte[MEMORYSIZE] m_rgchMemBlock; // Memory for temporary XLOPERs
size_t m_ichOffsetMemBlock=0; // Offset of next memory block to allocate
void start()
{
if (data.length==0)
data=theAllocator.makeArray!(ubyte)(MEMORYSIZE);
curSize=0;
}
// An empty destructor - see reasoning below
//
void dispose()
{
if(data.length>0)
theAllocator.dispose(data);
data.length=0;
curPos=0;
}
ubyte[] allocate(size_t numBytes)
{
ubyte[] lpMemory;
if (numBytes<=0)
return null;
if (curSize + numBytes > data.length)
{
auto newAllocationSize=min(MaxMemorySize,data.length*2);
if (newAllocationSize<=data.length)
return null;
theAllocator.expandArray(data,newAllocationSize,0);
}
lpMemory = data[curPos..curPos+numBytes];
curPos+=numBytes;
return lpMemory;
}
}
// Frees all the temporary memory by setting the index for available memory back to the beginning
void freeAll()
{
curPos = 0;
}
}
LPXLOPER12 get_DLL_name_2(int calculation_trigger)
{
static XLOPER12 xRtnValue; // Not thread-safe
Excel12(xlfGetName, &xRtnValue, 0);
// If xlfGetName failed, xRtnValue will be #VALUE!
if(xRtnValue.xltype != xltypeStr)
return &xRtnValue;
// Make a copy of the DLL path and file name.
wchar_t *leader = L"The full pathname for this DLL is ";
size_t leader_len = wcslen(leader);
size_t dllname_len = xRtnValue.val.str[0];
size_t msg_len = leader_len + dllname_len;
wchar_t *msg_text = (wchar_t *)malloc(msg_len + 1);
wcsncpy_s(msg_text + 1, leader, leader_len);
wcsncpy_s(msg_text + 1 + leader_len, xRtnValue.val.str + 1,
dllname_len);
msg_text[0] = msg_len;
// Now the original string has been copied Excel can free it.
Excel12(xlFree, 0, 1, &xRtnValue);
// Now reuse the XLOPER12 for the new string.
xRtnValue.val.str = msg_text;
// Tell Excel to call back into the DLL to free the string
// memory after it has copied out the return value.
xRtnValue.xltype = xltypeStr | xlbitDLLFree;
return &xRtnValue;
}
void WINAPI xlAutoFree12(LPXLOPER12 arg)
{
if (arg.xltype & xlbitDLLFree)
freeXLOper(arg);
}
|
D
|
import std.stdio;
import data;
import restriction;
void main()
{
writeln("LINQ - Restriction Operators");
writeln("\nNumbers < 5:");
foreach (n; linq1())
writeln(n);
writeln("\nSold out products: ");
foreach (p; linq2())
writefln("%s is sold out!", p.productName);
writeln("\nIn-stock products that cost more than 3.00:");
foreach (s; linq3())
writefln("%s is in stock and costs more than %.2f.", s.productName, s.unitPrice);
writeln("\nCustomers from Washington and their orders:");
foreach (c; linq4())
{
writefln("Customer %s: %s", c.customerID, c.companyName);
foreach (order; c.orders)
{
writefln("Order %s: %s", order.orderID, order.orderDate);
}
}
writeln("\nShort digits:");
foreach (d; linq5())
writefln("The word %s is shorter than it's value", d);
}
|
D
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.