code
stringlengths 3
10M
| language
stringclasses 31
values |
|---|---|
/*
* Copyright (C) 2015 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.
*/
package androidx.leanback.widget;
import static androidx.leanback.widget.ItemAlignmentFacet.ITEM_ALIGN_OFFSET_PERCENT_DISABLED;
import static androidx.recyclerview.widget.RecyclerView.HORIZONTAL;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewGroup;
import androidx.leanback.widget.GridLayoutManager.LayoutParams;
/**
* Helper class to handle ItemAlignmentFacet in a grid view.
*/
class ItemAlignmentFacetHelper {
private static Rect sRect = new Rect();
/**
* get alignment position relative to optical left/top of itemView.
*/
static int getAlignmentPosition(View itemView, ItemAlignmentFacet.ItemAlignmentDef facet,
int orientation) {
LayoutParams p = (LayoutParams) itemView.getLayoutParams();
View view = itemView;
if (facet.mViewId != 0) {
view = itemView.findViewById(facet.mViewId);
if (view == null) {
view = itemView;
}
}
int alignPos = facet.mOffset;
if (orientation == HORIZONTAL) {
if (itemView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
alignPos = (view == itemView ? p.getOpticalWidth(view)
: view.getWidth()) - alignPos;
if (facet.mOffsetWithPadding) {
if (facet.mOffsetPercent == 0f) {
alignPos -= view.getPaddingRight();
} else if (facet.mOffsetPercent == 100f) {
alignPos += view.getPaddingLeft();
}
}
if (facet.mOffsetPercent != ITEM_ALIGN_OFFSET_PERCENT_DISABLED) {
alignPos -= (int) (((view == itemView ? p.getOpticalWidth(view)
: view.getWidth()) * facet.mOffsetPercent) / 100f);
}
if (itemView != view) {
sRect.right = alignPos;
((ViewGroup) itemView).offsetDescendantRectToMyCoords(view, sRect);
alignPos = sRect.right + p.getOpticalRightInset();
}
} else {
if (facet.mOffsetWithPadding) {
if (facet.mOffsetPercent == 0f) {
alignPos += view.getPaddingLeft();
} else if (facet.mOffsetPercent == 100f) {
alignPos -= view.getPaddingRight();
}
}
if (facet.mOffsetPercent != ITEM_ALIGN_OFFSET_PERCENT_DISABLED) {
alignPos += (int) (((view == itemView ? p.getOpticalWidth(view)
: view.getWidth()) * facet.mOffsetPercent) / 100f);
}
if (itemView != view) {
sRect.left = alignPos;
((ViewGroup) itemView).offsetDescendantRectToMyCoords(view, sRect);
alignPos = sRect.left - p.getOpticalLeftInset();
}
}
} else {
if (facet.mOffsetWithPadding) {
if (facet.mOffsetPercent == 0f) {
alignPos += view.getPaddingTop();
} else if (facet.mOffsetPercent == 100f) {
alignPos -= view.getPaddingBottom();
}
}
if (facet.mOffsetPercent != ITEM_ALIGN_OFFSET_PERCENT_DISABLED) {
alignPos += (int) (((view == itemView ? p.getOpticalHeight(view) : view.getHeight())
* facet.mOffsetPercent) / 100f);
}
if (itemView != view) {
sRect.top = alignPos;
((ViewGroup) itemView).offsetDescendantRectToMyCoords(view, sRect);
alignPos = sRect.top - p.getOpticalTopInset();
}
if (facet.isAlignedToTextViewBaseLine()) {
alignPos += view.getBaseline();
}
}
return alignPos;
}
private ItemAlignmentFacetHelper() {
}
}
|
D
|
/Users/alejandroaas/Documents/CMPSC475A/CampusWalk/Build/Intermediates.noindex/SwiftMigration/CampusWalk/Intermediates.noindex/CampusWalk.build/Debug-iphonesimulator/CampusWalk.build/Objects-normal/x86_64/UIImage\ Extension.o : /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/AppDelegate.swift /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/CampusMapModel.swift /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/BuildingTableViewCell.swift /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/UIImage\ Extension.swift /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/StringExtension.swift /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/BuldingsTableViewController.swift /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/MapViewController.swift /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreLocation.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/MapKit.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule
/Users/alejandroaas/Documents/CMPSC475A/CampusWalk/Build/Intermediates.noindex/SwiftMigration/CampusWalk/Intermediates.noindex/CampusWalk.build/Debug-iphonesimulator/CampusWalk.build/Objects-normal/x86_64/UIImage\ Extension~partial.swiftmodule : /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/AppDelegate.swift /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/CampusMapModel.swift /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/BuildingTableViewCell.swift /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/UIImage\ Extension.swift /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/StringExtension.swift /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/BuldingsTableViewController.swift /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/MapViewController.swift /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreLocation.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/MapKit.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule
/Users/alejandroaas/Documents/CMPSC475A/CampusWalk/Build/Intermediates.noindex/SwiftMigration/CampusWalk/Intermediates.noindex/CampusWalk.build/Debug-iphonesimulator/CampusWalk.build/Objects-normal/x86_64/UIImage\ Extension~partial.swiftdoc : /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/AppDelegate.swift /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/CampusMapModel.swift /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/BuildingTableViewCell.swift /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/UIImage\ Extension.swift /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/StringExtension.swift /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/BuldingsTableViewController.swift /Users/alejandroaas/Documents/CMPSC475A/CampusWalk/CampusWalk/MapViewController.swift /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreLocation.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/MapKit.swiftmodule /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule
|
D
|
/home/liyun/clink/zkp_test/ckb-zkp/target/debug/deps/libproc_macro_hack-c1676d6a9a122dc7.so: /home/liyun/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro-hack-0.5.19/src/lib.rs /home/liyun/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro-hack-0.5.19/src/quote.rs /home/liyun/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro-hack-0.5.19/src/error.rs /home/liyun/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro-hack-0.5.19/src/iter.rs /home/liyun/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro-hack-0.5.19/src/parse.rs
/home/liyun/clink/zkp_test/ckb-zkp/target/debug/deps/proc_macro_hack-c1676d6a9a122dc7.d: /home/liyun/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro-hack-0.5.19/src/lib.rs /home/liyun/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro-hack-0.5.19/src/quote.rs /home/liyun/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro-hack-0.5.19/src/error.rs /home/liyun/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro-hack-0.5.19/src/iter.rs /home/liyun/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro-hack-0.5.19/src/parse.rs
/home/liyun/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro-hack-0.5.19/src/lib.rs:
/home/liyun/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro-hack-0.5.19/src/quote.rs:
/home/liyun/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro-hack-0.5.19/src/error.rs:
/home/liyun/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro-hack-0.5.19/src/iter.rs:
/home/liyun/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro-hack-0.5.19/src/parse.rs:
|
D
|
/**
* Utility code for path finding
*
* License:
* D version of code is under MIT. The original is under Apache 2.0.
*
* The MIT License (MIT)
*
* Copyright (c) 2014 Devisualization (Richard Andrew Cattermole)
*
* 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.
*
* See_Also:
* http://www.redblobgames.com/pathfinding/a-star/implementation.html
*/
module devisualization.util.algorithms.pathfinding.defs;
deprecated("Killing"):
version(unittest) {
struct XY {
int x;
int y;
}
T from_id_width(T)(T v, T width) pure { return XY(id % width, id / width); }
enum XY[] DIAGRAM1_WALLS = [21,22,51,52,81,82,93,94,111,112,123,124,133,134,141,142,153,154,163,164,171,172,173,174,175,183,184,193,194,201,202,203,204,205,213,214,223,224,243,244,253,254,273,274,283,284,303,304,313,314,333,334,343,344,373,374,403,404,433,434].from_id_width;
GridWithWeights!(XY, int) diagram4() {
GridWithWeights!(XY, int) ret = GridWithWeights(10, 10);
ret.walls = [XY(1, 7), XY(1, 8), XY(2, 7), XY(2, 8), XY(3, 7), XY(3, 8)];
ret.weights = [(3, 4), (3, 5), (4, 1), (4, 2),
(4, 3), (4, 4), (4, 5), (4, 6),
(4, 7), (4, 8), (5, 1), (5, 2),
(5, 3), (5, 4), (5, 5), (5, 6),
(5, 7), (5, 8), (6, 2), (6, 3),
(6, 4), (6, 5), (6, 6), (6, 7),
(7, 3), (7, 4), (7, 5)];
return ret;
}
}
/**
* Does the type have:
* - x
* - y
* - x and y being both the same type
* - Ability to be initiated like a struct (think opCall for classes)
*
* Params:
* T = The type
*
* Returns:
* If the value is compliant
*/
bool hasXYPoints(T)() {
return __traits(hasMember, T, "x") && __traits(hasMember, T, "y") &&
is(typeof(T.x) == typeof(T.y)) &&
__traits(compiles, { T v = T(typeof(T.x).init, typeof(T.y).init); });
}
/**
* The distance between two points
* Type of parameters must abide by hasXYPoints
*
* Params:
* a = The first position
* b = The second position
*
* Returns:
* The distance
*
* See_Also:
* hasXYPoints
*/
T heuristic(T, U = typeof(T.x))(T a, T b) if (hasXYPoints!T) {
import std.math : abs;
return cast(U)(abs(a.x - b.x) + abs(a.y - b.y));
}
/**
* Turns the output from a search algorithm into a set path
*
* Params:
* came_from = The positions between start and end
* start = Starting position to go to
* goal = The end position
*
* Returns:
* A path from a position to another
*
* See_Also:
* dijkstra_search, a_star_search, breadth_first_search
*/
T[] reconstruct_path(T)(T[] came_from, T start, T goal) {
T current = goal;
T[] path = [current];
while (current != start) {
current = came_from[current];
path ~= current;
}
return path;
}
/**
* A simple graph structure
*/
struct Graph(T=string) {
private {
T[][T] edges_;
}
@property {
/**
* Get the edges this graph has
*
* Returns:
* The edges of the graph
*/
T[][T] edges() { return edges_; }
/**
* Set the edges this graph has
*
* Params:
* value = The new edges of the graph
*/
void edges(T[][T] value) { edges_ = value; }
}
/**
* Get a set edge, neighbors
*
* Params:
* The id of the edge
*
* Returns:
* The neighbor edges or null if id doesn't exist
*/
T[] neighbors(T id) { return edges_.get(id, null); }
}
/**
* A 2d grid that is rectangle in nature
*
* Params:
* T = A point type with x and y fields
* U = The type of x and y
*/
struct SquareGrid(T, U = typeof(T.x)) if (hasXYPoints!T) {
Graph this_;
alias this_ this;
private {
U width_;
U height_;
T[] walls_;
}
/**
* Creates the grid given the size
*
* Params:
* width = Width of the grid
* height = Height of the grid
*/
this(U width, U height) {
width_ = width;
height_ = height;
}
/**
* Is a given position within the grid
*
* Params:
* id = The position
*
* Returns:
* If the position is within the grid
*/
bool in_bounds(T id) {
return 0 <= id.x && id.x < width_ &&
0 <= id.y && id.y < height_;
}
/**
* Is a given position blocked by a wall
*
* Params:
* id = The position
*
* Returns:
* If the position is blocked by a wall
*/
bool passable(T id) {
import std.algorithm : canFind;
return walls_.canFind(id);
}
/**
* Get a set edge, neighbors
*
* Params:
* id = The id of the edge
*
* Returns:
* The neighbor edges or null if id doesn't exist
*/
string[] neighbors(T id) {
import std.algorithm : reverse, filter, moveAll;
T[] results = [T(id.x + 1, id.y), T(id.x, id.y - 1), T(id.x - 1, id.y), T(id.x, id.y + y)];
if ((id.x + id.y) % 2 == 0)
results = results.reverse;
filter!`in_bounds(a) && passable(a)`(results).moveAll(results);
return results;
}
}
/**
* A grid that has weighting per node
*
* Params:
* T = A point type with x and y fields
* U = The type of x and y
*/
struct GridWithWeights(T, U = ubyte, V = typeof(T.x)) {
SquareGrid!(T, V) this_;
alias this_ this;
private {
U[T] weights_;
}
/**
* Gets the weighting for an item
*
* Params:
* a = Previous position
* b = Current position
* default_ = Default value to return. Default: 1
*/
U cost(T a, T b, U default_ = 1) {
return weights_.get(b, default_);
}
}
/**
* A simple wrap around a DList
*
* See_Also:
* std.algorithm.DList
*/
struct Queue(T) {
DList!T this_;
alias this_ this;
/**
* Adds an item to the queue
*
* Params:
* x = The value to add
*/
void put(T x) { this_ ~= x; }
/**
* Gets the front item (FIFO) of the queue
*
* Returns:
* The first item in queue
*/
T get() {
T ret = this_.opSlice().front;
this_.opSlice().popFront;
return ret;
}
}
/**
* A wrapper around BinaryHeap
* Sorts a set of items based upon a priority
*
* Params:
* T = The queue item type
* U = The priority type
*
* See_Also:
* std.collections.binaryheap.BinaryHeap
*/
struct PriorityQueue(T, U=ubyte) {
struct PriorityQueueItem {
T item;
U priority;
}
BinaryHeap!(PriorityQueueItem, `a.priority < b.priority`) elements;
alias elements this;
/**
* Adds an item to the queue
*
* Params:
* item = The value to add
* priority = The priority of the item
*/
void put(T item, U priority) { elements ~= PriorityQueueItem(item, priority); }
/**
* Gets the front item (FIFO) of the queue
*
* Returns:
* The first item in queue sorted based upon the priority
*/
U get() {
T ret = this_.opSlice().front;
this_.opSlice().popFront;
return ret;
}
}
|
D
|
a fastener that is inserted into holes in two adjacent pieces and holds them together
|
D
|
/home/naufil/Desktop/rust/3june/todocopy/target/debug/deps/libfutures_cpupool-b20a20556fa39ba5.rlib: /home/naufil/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-cpupool-0.1.8/src/lib.rs
/home/naufil/Desktop/rust/3june/todocopy/target/debug/deps/futures_cpupool-b20a20556fa39ba5.d: /home/naufil/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-cpupool-0.1.8/src/lib.rs
/home/naufil/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-cpupool-0.1.8/src/lib.rs:
|
D
|
module reversineer;
public import reversineer.integers;
public import reversineer.io;
public import reversineer.strings;
public import reversineer.structure;
|
D
|
class A {
int counter;
void init() {
counter = 0;
}
A a(A a1) {
Print("entering method a of A");
a1.counter = a1.counter + 1;
return this;
}
A b(A a1) {
Print("entering method b of A");
a1.counter = a1.counter * 2;
return this;
}
void print() {
Print("Value of counter is: ", counter);
}
}
int main() {
A a;
a = new A;
a.init();
a.b(a.a(a.b(a.a(a))));
a.print();
}
|
D
|
/Users/mu/Hello/.build/x86_64-apple-macosx/debug/Fluent.build/Join/QueryBuilder+Join.swift.o : /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/ID.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/SchemaSupporting+CRUD.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/Model+CRUD.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+CRUD.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Utilities/Deprecated.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Service/MigrateCommand.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Service/RevertCommand.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Decode.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Range.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/SoftDeletable.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Aggregate.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/MigrationConfig.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/SchemaSupporting.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Join/JoinSupporting.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/MigrationSupporting.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Transaction/TransactionSupporting.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Query/QuerySupporting.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/MigrationLog.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Model.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/Model.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/AnyModel.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Relations/Children.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Join/QueryBuilder+Join.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/SchemaSupporting+Migration.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/Migration.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/AnyMigration.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Run.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Service/FluentProvider.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/SchemaBuilder.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/SchemaUpdater.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Filter.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Utilities/FluentError.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/SchemaCreator.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/DatabasesConfig+References.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Relations/Siblings.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/Migrations.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/AnyMigrations.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Operators.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Utilities/Exports.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Relations/Parent.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Service/CommandConfig+Fluent.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Cache/KeyedCacheSupporting+Fluent.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Database/DatabaseConnection+Fluent.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/ModelEvent.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/Pivot.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Sort.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Cache/CacheEntry.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Query/FluentProperty.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Async.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Command.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Service.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Console.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Core.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Logging.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/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/mu/Hello/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Bits.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/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/mu/Hello/.build/x86_64-apple-macosx/debug/DatabaseKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/mu/Hello/.build/checkouts/swift-nio-zlib-support/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/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.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/mu/Hello/.build/x86_64-apple-macosx/debug/Fluent.build/Join/QueryBuilder+Join~partial.swiftmodule : /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/ID.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/SchemaSupporting+CRUD.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/Model+CRUD.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+CRUD.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Utilities/Deprecated.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Service/MigrateCommand.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Service/RevertCommand.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Decode.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Range.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/SoftDeletable.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Aggregate.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/MigrationConfig.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/SchemaSupporting.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Join/JoinSupporting.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/MigrationSupporting.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Transaction/TransactionSupporting.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Query/QuerySupporting.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/MigrationLog.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Model.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/Model.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/AnyModel.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Relations/Children.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Join/QueryBuilder+Join.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/SchemaSupporting+Migration.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/Migration.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/AnyMigration.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Run.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Service/FluentProvider.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/SchemaBuilder.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/SchemaUpdater.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Filter.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Utilities/FluentError.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/SchemaCreator.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/DatabasesConfig+References.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Relations/Siblings.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/Migrations.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/AnyMigrations.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Operators.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Utilities/Exports.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Relations/Parent.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Service/CommandConfig+Fluent.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Cache/KeyedCacheSupporting+Fluent.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Database/DatabaseConnection+Fluent.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/ModelEvent.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/Pivot.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Sort.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Cache/CacheEntry.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Query/FluentProperty.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Async.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Command.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Service.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Console.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Core.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Logging.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/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/mu/Hello/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Bits.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/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/mu/Hello/.build/x86_64-apple-macosx/debug/DatabaseKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/mu/Hello/.build/checkouts/swift-nio-zlib-support/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/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.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/mu/Hello/.build/x86_64-apple-macosx/debug/Fluent.build/Join/QueryBuilder+Join~partial.swiftdoc : /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/ID.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/SchemaSupporting+CRUD.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/Model+CRUD.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+CRUD.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Utilities/Deprecated.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Service/MigrateCommand.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Service/RevertCommand.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Decode.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Range.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/SoftDeletable.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Aggregate.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/MigrationConfig.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/SchemaSupporting.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Join/JoinSupporting.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/MigrationSupporting.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Transaction/TransactionSupporting.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Query/QuerySupporting.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/MigrationLog.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Model.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/Model.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/AnyModel.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Relations/Children.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Join/QueryBuilder+Join.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/SchemaSupporting+Migration.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/Migration.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/AnyMigration.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Run.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Service/FluentProvider.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/SchemaBuilder.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/SchemaUpdater.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Filter.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Utilities/FluentError.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/SchemaCreator.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Schema/DatabasesConfig+References.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Relations/Siblings.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/Migrations.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Migration/AnyMigrations.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Operators.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Utilities/Exports.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Relations/Parent.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Service/CommandConfig+Fluent.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Cache/KeyedCacheSupporting+Fluent.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Database/DatabaseConnection+Fluent.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/ModelEvent.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Model/Pivot.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/QueryBuilder/QueryBuilder+Sort.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Cache/CacheEntry.swift /Users/mu/Hello/.build/checkouts/fluent/Sources/Fluent/Query/FluentProperty.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Async.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Command.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Service.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Console.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Core.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Logging.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/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/mu/Hello/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Bits.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/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/mu/Hello/.build/x86_64-apple-macosx/debug/DatabaseKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/mu/Hello/.build/checkouts/swift-nio-zlib-support/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/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.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
|
/*
* This file is part of gtkD.
*
* gtkD is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* gtkD 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with gtkD; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage
/*
* Conversion parameters:
* inFile =
* outPack = gtk
* outFile = MainWindow
* strct =
* realStrct=
* ctorStrct=
* clss =
* interf =
* class Code: Yes
* interface Code: No
* template for:
* extend =
* implements:
* prefixes:
* omit structs:
* omit prefixes:
* omit code:
* omit signals:
* imports:
* - gtkD.gtk.Widget
* - gtkD.gtk.Window
* - gtkD.gtk.Main
* - gtkD.gdk.Event
* structWrap:
* module aliases:
* local aliases:
* overrides:
*/
module gtkD.gtk.MainWindow;
public import gtkD.gtkc.gtktypes;
private import gtkD.gtkc.gtk;
private import gtkD.glib.ConstructionException;
private import gtkD.gtk.Widget;
private import gtkD.gtk.Window;
private import gtkD.gtk.Main;
private import gtkD.gdk.Event;
/**
* A top Level window that will stop the main event cycle when it's closed.
* Closing the last of the windows of class "MainWindow" will end the application.
*/
public class MainWindow : Window
{
private static int countTotalMainWindows = 0;
/**
* Creates a new MainWindow with a title
*/
public this(string title)
{
super(title);
countTotalMainWindows++;
//printf("MainWindows.this count = %d\n", countTotalMainWindows);
addOnDelete(&windowDelete);
}
/**
* Executed when the user tries to close the window
* Returns: true to refuse to close the window
*/
protected bool windowDelete(Event event, Widget widget)
{
--countTotalMainWindows;
//printf("MainWindows.windowDelete count = %d\n", countTotalMainWindows);
if ( exit(0, false) || countTotalMainWindows==0 )
{
Main.quit();
return false;
}
return false;
}
/**
* Allows the application to close and decide if it can exit
* Params:
* code = the code reason to exit
* force = if true the application must expect to be closed even against it's will
* Returns: false to refuse to exit
*/
protected bool exit(int code, bool force)
{
return force;
}
}
/**
*/
|
D
|
# FIXED
Application/util.obj: C:/ti/simplelink/ble_cc26xx_2_01_01_44627/Projects/ble/common/cc26xx/util.c
Application/util.obj: C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/stdbool.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/std.h
Application/util.obj: C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/stdarg.h
Application/util.obj: C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/stddef.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/targets/arm/elf/std.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/targets/arm/elf/M3.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/targets/std.h
Application/util.obj: C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/stdint.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/xdc.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types__prologue.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/package.defs.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types__epilogue.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/package/package.defs.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert__prologue.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Main.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IHeap.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error__prologue.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Main.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error__epilogue.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Memory.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IHeap.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/Memory_HeapProxy.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IHeap.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IGateProvider.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/Main_Module_GateProxy.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IGateProvider.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags__prologue.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Main.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags__epilogue.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert__epilogue.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log__prologue.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Main.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Text.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log__epilogue.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/ITimer.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/package/package.defs.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Swi.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/package/Clock_TimerProxy.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/ITimer.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/package/Clock_TimerProxy.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Semaphore.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Task.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Task__prologue.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IHeap.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/ITaskSupport.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/package/Task_SupportProxy.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/ITaskSupport.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Task__epilogue.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Event.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Event__prologue.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Task.h
Application/util.obj: C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Event__epilogue.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h
Application/util.obj: C:/ti/simplelink/ble_cc26xx_2_01_01_44627/Components/icall/include/ICall.h
Application/util.obj: C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/stdlib.h
Application/util.obj: C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/linkage.h
Application/util.obj: C:/ti/simplelink/ble_cc26xx_2_01_01_44627/Components/ble/include/bcomdef.h
Application/util.obj: C:/ti/simplelink/ble_cc26xx_2_01_01_44627/Components/osal/include/comdef.h
Application/util.obj: C:/ti/simplelink/ble_cc26xx_2_01_01_44627/Components/hal/target/CC2650TIRTOS/hal_types.h
Application/util.obj: C:/ti/simplelink/ble_cc26xx_2_01_01_44627/Components/hal/target/CC2650TIRTOS/../_common/cc26xx/_hal_types.h
Application/util.obj: C:/ti/simplelink/ble_cc26xx_2_01_01_44627/Components/hal/include/hal_defs.h
Application/util.obj: C:/ti/simplelink/ble_cc26xx_2_01_01_44627/Projects/ble/common/cc26xx/util.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h
Application/util.obj: C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Semaphore.h
C:/ti/simplelink/ble_cc26xx_2_01_01_44627/Projects/ble/common/cc26xx/util.c:
C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/stdbool.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/std.h:
C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/stdarg.h:
C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/stddef.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/targets/arm/elf/std.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/targets/arm/elf/M3.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/targets/std.h:
C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/stdint.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/xdc.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types__prologue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/package.defs.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types__epilogue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/package/package.defs.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert__prologue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Main.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IHeap.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error__prologue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Main.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error__epilogue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Memory.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IHeap.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/Memory_HeapProxy.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IHeap.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IGateProvider.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/package/Main_Module_GateProxy.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IGateProvider.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags__prologue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Main.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags__epilogue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert__epilogue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log__prologue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Main.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Text.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log__epilogue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/ITimer.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/package/package.defs.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Swi.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/package/Clock_TimerProxy.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/ITimer.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/package/Clock_TimerProxy.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Semaphore.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Task.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Task__prologue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IHeap.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/ITaskSupport.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Error.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/package/Task_SupportProxy.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/interfaces/ITaskSupport.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Task__epilogue.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Event.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Types.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IInstance.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Event__prologue.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Assert.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Diags.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/Log.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Task.h:
C:/ti/xdctools_3_31_01_33_core/packages/xdc/runtime/IModule.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Event__epilogue.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h:
C:/ti/simplelink/ble_cc26xx_2_01_01_44627/Components/icall/include/ICall.h:
C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/stdlib.h:
C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/linkage.h:
C:/ti/simplelink/ble_cc26xx_2_01_01_44627/Components/ble/include/bcomdef.h:
C:/ti/simplelink/ble_cc26xx_2_01_01_44627/Components/osal/include/comdef.h:
C:/ti/simplelink/ble_cc26xx_2_01_01_44627/Components/hal/target/CC2650TIRTOS/hal_types.h:
C:/ti/simplelink/ble_cc26xx_2_01_01_44627/Components/hal/target/CC2650TIRTOS/../_common/cc26xx/_hal_types.h:
C:/ti/simplelink/ble_cc26xx_2_01_01_44627/Components/hal/include/hal_defs.h:
C:/ti/simplelink/ble_cc26xx_2_01_01_44627/Projects/ble/common/cc26xx/util.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Clock.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Queue.h:
C:/ti/tirtos_simplelink_2_13_00_06/products/bios_6_42_00_08/packages/ti/sysbios/knl/Semaphore.h:
|
D
|
var int AntiPaladinTalkcount;
func void B_AssignORC_AntiPaladinTalk(var C_Npc Antipaladin)
{
if(hero.guild == GIL_PAL)
{
if(AntiPaladinTalkcount == 0)
{
AI_Output(self,other,"DIA_ORC_AntiPaladin_18_01"); //KHROKGNAR! Pán říkal že velký paladin pďijde! Pán mít pravdu! Pán mít vždy pravdu!
AI_Output(self,other,"DIA_ORC_AntiPaladin_18_02"); //My vůdci hrdých skřetích armád přicházet zničit paladiny!
AI_Output(self,other,"DIA_ORC_AntiPaladin_18_03"); //My zabít Hagen a jeho paladiny! Ani ti nepomoci jim!
B_GivePlayerXP(XP_Ambient);
}
else if(AntiPaladinTalkcount == 1)
{
AI_Output(self,other,"DIA_ORC_AntiPaladin_18_04"); //Pán říká my přinést mu hlavu velký paladin. Nyní ty zemřít. KHROKGNAR!
}
else if(AntiPaladinTalkcount == 2)
{
AI_Output(self,other,"DIA_ORC_AntiPaladin_18_05"); //Vůdci jdou zabít tě, válečník.
}
else
{
AI_Output(self,other,"DIA_ORC_AntiPaladin_18_06"); //KHROKGNAR! My zabít tě velký paladin.
};
}
else
{
AI_Output(self,other,"DIA_Orc_8215_Kan_PreHello_01_03"); //DABAP KAHAR ROG GAK KHA BAK.
};
AntiPaladinTalkcount = AntiPaladinTalkcount + 1;
TalkedTo_AntiPaladin = TRUE;
Antipaladin.aivar[AIV_EnemyOverride] = FALSE;
AI_StopProcessInfos(Antipaladin);
Npc_SetRefuseTalk(Antipaladin,20);
};
|
D
|
import std.range;
import std.traits;
struct BinaryReader {
ref read(E)(E e) {
readWriteVariable!true(e, e);
}
void readWriteVariable(bool isRead, T, P)(T data, P parent) {
enum varStruct = is(T == struct);
static if(varStruct) {
alias mArr = TypeTuple!(__traits(allMembers, T));
foreach(it; mArr) {
static if(mixin(`__traits(compiles, &data.` ~ it ~ `)`) == false)
enum vValid = false;
else
enum vValid = mixin(`is(FunctionTypeOf!(T.` ~ it ~ `) == function) == false`);
static if(vValid) {
mixin(`alias R = typeof(T.` ~ it ~ `);`);
R tmp;
readWriteVariable!isRead(tmp, parent);
}
}
} static if(isBasicType!(ElementType!T) == false)
foreach(it; data)
readWriteVariable!isRead(it, parent);
}
}
auto binaryReaderBuf(T)(T ) {
return BinaryReader();
}
void binaryRead(E, T)(E var, T data) { binaryReaderBuf(data).read!()(var); }
|
D
|
instance Mod_1098_BAU_Bauer_MT (Npc_Default)
{
//-------- primary data --------
name = name_Bauer;
npctype = NPCTYPE_MT_REISBAUER;
guild = GIL_MIL;
level = 2;
voice = 4;
id = 1098;
//-------- abilities --------
attribute[ATR_STRENGTH] = 13;
attribute[ATR_DEXTERITY] = 10;
attribute[ATR_MANA_MAX] = 0;
attribute[ATR_MANA] = 0;
attribute[ATR_HITPOINTS_MAX]= 64;
attribute[ATR_HITPOINTS] = 64;
//-------- visuals --------
// animations
Mdl_SetVisual (self,"HUMANS.MDS");
Mdl_ApplyOverlayMds (self,"Humans_Tired.mds");
// body mesh ,bdytex,skin,head mesh ,headtex2,teethtex,ruestung
Mdl_SetVisualBody (self,"hum_body_Naked0",2,2,"Hum_Head_Bald",45 , 2, DEFAULT);
Mdl_SetModelFatness(self,0);
fight_tactic = FAI_HUMAN_COWARD;
//-------- Talente --------
//-------- inventory --------
//-------------Daily Routine-------------
daily_routine = Rtn_start_1098;
};
FUNC VOID Rtn_start_1098 ()
{
TA_Smalltalk (08,00,20,00,"OW_PATH_069");
TA_Smalltalk (20,00,08,00,"OW_PATH_069");
};
|
D
|
/*
DISABLED: dragonflybsd freebsd linux osx win32
TEST_OUTPUT:
---
Error: cannot mix `core.std.stdlib.alloca()` and exception handling in `_Dmain()`
---
*/
import core.stdc.stdlib : alloca;
import core.stdc.stdio;
struct TheStruct
{
~this()
{
printf("dtor()\n");
}
}
void bar()
{
printf("bar()\n");
}
void main()
{
auto s = TheStruct();
bar();
auto a = alloca(16);
printf("test()\n");
}
|
D
|
/Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/DerivedData/mealify/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Alamofire.o : /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/MultipartFormData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Timeline.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Alamofire.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Response.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/TaskDelegate.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/SessionDelegate.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/ParameterEncoding.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Validation.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/ResponseSerialization.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/SessionManager.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/NetworkReachabilityManager.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/AFError.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Notifications.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Result.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Request.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/ServerTrustPolicy.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Target\ Support\ Files/Alamofire/Alamofire-umbrella.h /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/DerivedData/mealify/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/unextended-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/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
/Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/DerivedData/mealify/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Alamofire~partial.swiftmodule : /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/MultipartFormData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Timeline.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Alamofire.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Response.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/TaskDelegate.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/SessionDelegate.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/ParameterEncoding.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Validation.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/ResponseSerialization.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/SessionManager.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/NetworkReachabilityManager.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/AFError.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Notifications.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Result.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Request.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/ServerTrustPolicy.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Target\ Support\ Files/Alamofire/Alamofire-umbrella.h /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/DerivedData/mealify/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/unextended-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/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
/Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/DerivedData/mealify/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Alamofire~partial.swiftdoc : /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/MultipartFormData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Timeline.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Alamofire.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Response.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/TaskDelegate.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/SessionDelegate.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/ParameterEncoding.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Validation.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/ResponseSerialization.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/SessionManager.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/NetworkReachabilityManager.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/AFError.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Notifications.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Result.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/Request.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Alamofire/Source/ServerTrustPolicy.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Target\ Support\ Files/Alamofire/Alamofire-umbrella.h /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/DerivedData/mealify/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/unextended-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/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
|
D
|
// ubyte
module typeinfo.ti_ubyte;
class TypeInfo_h : TypeInfo
{
size_t tsize()
{
return ubyte.sizeof;
}
int compare(void *p1, void *p2)
{
if(*cast(ubyte*)p1 < *cast(ubyte*)p2)
return -1;
else if(*cast(ubyte*)p1 > *cast(ubyte*)p2)
return 1;
return 0;
}
}
class TypeInfo_b : TypeInfo_h
{
}
|
D
|
module sb.image_loaders.stb_imageloader;
import std.string: fromStringz;
import std.exception: enforce;
import std.format: format;
import std.typecons: RefCounted;
private extern(C) ubyte* stbi_load_from_memory (const(ubyte*), int, int*, int*, int*, int);
private extern(C) const(char)* stbi_failure_reason ();
private extern(C) void stbi_image_free (void*);
struct STB_Texture {
string filename; // metadata
size_t width, height, size, componentDepth;
ubyte[] data;
this (string filename, ubyte[] data, int w, int h, int d) {
this.filename = filename;
this.data = data;
this.width = cast(typeof(width))w;
this.height = cast(typeof(height))h;
this.size = width * height;
this.componentDepth = cast(typeof(componentDepth))d;
}
}
public STB_Texture stb_loadImage (string filename, ubyte[] data, uint componentDepth = 0) {
int w, h, d;
auto ptr = stbi_load_from_memory(data.ptr, cast(int)data.length, &w, &h, &d, cast(int)componentDepth);
enforce(ptr && w * h != 0, format("Could not load '%s': %s", filename, stbi_failure_reason().fromStringz));
auto texData = ptr[0 .. w * h];
stbi_image_free(ptr);
return STB_Texture(filename, texData, w, h, d);
}
|
D
|
/*******************************************************************************
* Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Port to the D programming language:
* Frank Benoit <benoit@tionex.de>
*******************************************************************************/
module org.eclipse.swt.events.TypedEvent;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.swt.internal.SWTEventObject;
import java.lang.all;
/**
* This is the super class for all typed event classes provided
* by SWT. Typed events contain particular information which is
* applicable to the event occurrence.
*
* @see org.eclipse.swt.widgets.Event
* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
*/
public class TypedEvent : SWTEventObject {
/**
* the display where the event occurred
*
* @since 2.0
*/
public Display display;
/**
* the widget that issued the event
*/
public Widget widget;
/**
* the time that the event occurred.
*
* NOTE: This field is an unsigned integer and should
* be AND'ed with 0xFFFFFFFFL so that it can be treated
* as a signed long.
*/
public int time;
/**
* a field for application use
*/
public Object data;
//static const long serialVersionUID = 3257285846578377524L;
/**
* Constructs a new instance of this class.
*
* @param object the object that fired the event
*/
public this(Object object) {
super(object);
}
/**
* Constructs a new instance of this class based on the
* information in the argument.
*
* @param e the low level event to initialize the receiver with
*/
public this(Event e) {
super(e.widget);
this.display = e.display;
this.widget = e.widget;
this.time = e.time;
this.data = e.data;
}
/**
* Returns the name of the event. This is the name of
* the class without the module name.
*
* @return the name of the event
*/
String getName () {
String string = this.classinfo.name;
int index = string.lastIndexOf ('.');
if (index is -1) return string;
return string.substring (index + 1, string.length ());
}
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the event
*/
public override String toString() {
String str_widget = widget is null ? "null" : widget.toString;
String str_data = data is null ? "null" : data.toString;
return Format( "{}{{{} time={} data={}}", getName(), str_widget, time, str_data );
}
}
|
D
|
/Users/kidboy/Programming/github.com/learn_programming/rust/guessing_game/target/rls/debug/deps/guessing_game-341a7884e2b9aec9.rmeta: src/main.rs
/Users/kidboy/Programming/github.com/learn_programming/rust/guessing_game/target/rls/debug/deps/guessing_game-341a7884e2b9aec9.d: src/main.rs
src/main.rs:
|
D
|
/Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/GraphQL.build/Language/Visitor.swift.o : /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/GraphQL.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/AST.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/TypeFromAST.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/ValueFromAST.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Schema.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/Find.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Source.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/Keyable.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/FieldsOnCorrectTypeRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/PossibleFragmentSpreadsRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/NoUnusedVariablesRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/KnownArgumentNamesRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/ScalarLeafsRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/ProvidedNonNullArgumentsRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/AssertValidName.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Validate.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Execution/Execute.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/IsValidValue.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/ASTFromValue.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/IsNullish.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Location.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Instrumentation/Instrumentation.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/MapSerialization.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/AnySerialization.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Introspection.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Definition.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/TypeInfo.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/Map.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/KeyMap.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/Unwrap.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/Number.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/MapCoder.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/AnyCoder.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Instrumentation/DispatchQueueInstrumentationWrapper.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Parser.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Lexer.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Error/GraphQLError.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Error/LocatedError.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Error/SyntaxError.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Visitor.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Kinds.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/PersistedQueries/PersistedQueries.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/SpecifiedRules.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Execution/Values.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Directives.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/NIO+Extensions.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Extensions/Codable+Extensions.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Scalars.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/TypeComparators.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/SuggestionList.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/QuotedOrList.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Runtime.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/CRuntime/Sources/CRuntime/CRuntime.h /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/dyld.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOHTTP1.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOHTTP2.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/_Vapor3.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOHPACK.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentSQL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/GraphQL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOSSL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOBoringSSL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CCryptoBoringSSL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CJWTKitBoringSSL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FCM.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/BSON.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FineJSON.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIO.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MySQLNIO.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SQLiteNIO.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/PostgresNIO.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOTLS.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/APNS.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/JWT.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOExtrasZlib.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Backtrace.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CBacktrace.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ProtocolConformance.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Runtime.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/OpenCombine.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ProtocolType.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MongoKittenCore.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MongoCore.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/WebSocketInfrastructure.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ApodiniDatabase.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ProtobufferCoding.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Logging.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Casting.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/OpenCombineDispatch.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Apodini.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SQLKitBenchmark.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentBenchmark.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/COperatingSystem.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MongoKitten.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOHTTPCompression.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/OpenCombineFoundation.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SwifCron.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Crypto.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/_MongoKittenCrypto.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CURLParser.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/RichJSONParser.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CMultipartParser.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentMySQLDriver.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentSQLiteDriver.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentMongoDriver.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentPostgresDriver.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Vapor.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/XCTVapor.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/AssociatedTypeRequirementsVisitor.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOExtras.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Jobs.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Metrics.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CoreMetrics.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOTransportServices.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOTestUtils.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Yams.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/_NIO1APIShims.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOBoringSSLShims.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CCryptoBoringSSLShims.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Notifications.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/COpenCombineHelpers.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ValuePointers.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOWebSocket.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/APNSwift.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/OpenAPIKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SQLKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MySQLKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/JWTKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/AsyncKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ConsoleKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SQLiteKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/RoutingKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/PostgresKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/WebSocketKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MultipartKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/AsyncHTTPClient.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/DNSClient.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MongoClient.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Fluent.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/XCTFluent.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CContext.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Meow.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/swift-nio/Sources/CNIOWindows/include/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/CRuntime/Sources/CRuntime/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/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.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/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/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/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/GraphQL.build/Language/Visitor~partial.swiftmodule : /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/GraphQL.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/AST.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/TypeFromAST.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/ValueFromAST.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Schema.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/Find.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Source.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/Keyable.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/FieldsOnCorrectTypeRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/PossibleFragmentSpreadsRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/NoUnusedVariablesRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/KnownArgumentNamesRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/ScalarLeafsRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/ProvidedNonNullArgumentsRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/AssertValidName.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Validate.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Execution/Execute.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/IsValidValue.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/ASTFromValue.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/IsNullish.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Location.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Instrumentation/Instrumentation.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/MapSerialization.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/AnySerialization.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Introspection.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Definition.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/TypeInfo.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/Map.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/KeyMap.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/Unwrap.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/Number.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/MapCoder.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/AnyCoder.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Instrumentation/DispatchQueueInstrumentationWrapper.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Parser.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Lexer.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Error/GraphQLError.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Error/LocatedError.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Error/SyntaxError.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Visitor.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Kinds.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/PersistedQueries/PersistedQueries.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/SpecifiedRules.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Execution/Values.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Directives.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/NIO+Extensions.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Extensions/Codable+Extensions.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Scalars.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/TypeComparators.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/SuggestionList.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/QuotedOrList.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Runtime.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/CRuntime/Sources/CRuntime/CRuntime.h /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/dyld.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOHTTP1.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOHTTP2.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/_Vapor3.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOHPACK.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentSQL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/GraphQL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOSSL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOBoringSSL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CCryptoBoringSSL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CJWTKitBoringSSL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FCM.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/BSON.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FineJSON.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIO.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MySQLNIO.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SQLiteNIO.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/PostgresNIO.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOTLS.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/APNS.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/JWT.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOExtrasZlib.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Backtrace.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CBacktrace.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ProtocolConformance.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Runtime.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/OpenCombine.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ProtocolType.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MongoKittenCore.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MongoCore.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/WebSocketInfrastructure.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ApodiniDatabase.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ProtobufferCoding.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Logging.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Casting.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/OpenCombineDispatch.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Apodini.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SQLKitBenchmark.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentBenchmark.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/COperatingSystem.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MongoKitten.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOHTTPCompression.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/OpenCombineFoundation.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SwifCron.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Crypto.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/_MongoKittenCrypto.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CURLParser.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/RichJSONParser.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CMultipartParser.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentMySQLDriver.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentSQLiteDriver.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentMongoDriver.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentPostgresDriver.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Vapor.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/XCTVapor.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/AssociatedTypeRequirementsVisitor.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOExtras.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Jobs.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Metrics.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CoreMetrics.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOTransportServices.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOTestUtils.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Yams.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/_NIO1APIShims.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOBoringSSLShims.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CCryptoBoringSSLShims.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Notifications.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/COpenCombineHelpers.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ValuePointers.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOWebSocket.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/APNSwift.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/OpenAPIKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SQLKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MySQLKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/JWTKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/AsyncKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ConsoleKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SQLiteKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/RoutingKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/PostgresKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/WebSocketKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MultipartKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/AsyncHTTPClient.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/DNSClient.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MongoClient.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Fluent.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/XCTFluent.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CContext.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Meow.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/swift-nio/Sources/CNIOWindows/include/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/CRuntime/Sources/CRuntime/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/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.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/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/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/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/GraphQL.build/Language/Visitor~partial.swiftdoc : /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/GraphQL.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/AST.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/TypeFromAST.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/ValueFromAST.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Schema.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/Find.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Source.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/Keyable.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/FieldsOnCorrectTypeRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/PossibleFragmentSpreadsRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/NoUnusedVariablesRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/KnownArgumentNamesRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/ScalarLeafsRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/ProvidedNonNullArgumentsRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/AssertValidName.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Validate.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Execution/Execute.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/IsValidValue.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/ASTFromValue.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/IsNullish.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Location.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Instrumentation/Instrumentation.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/MapSerialization.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/AnySerialization.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Introspection.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Definition.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/TypeInfo.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/Map.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/KeyMap.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/Unwrap.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/Number.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/MapCoder.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/AnyCoder.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Instrumentation/DispatchQueueInstrumentationWrapper.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Parser.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Lexer.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Error/GraphQLError.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Error/LocatedError.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Error/SyntaxError.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Visitor.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Kinds.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/PersistedQueries/PersistedQueries.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/SpecifiedRules.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Execution/Values.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Directives.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/NIO+Extensions.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Extensions/Codable+Extensions.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Scalars.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/TypeComparators.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/SuggestionList.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/QuotedOrList.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Runtime.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/CRuntime/Sources/CRuntime/CRuntime.h /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/dyld.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOHTTP1.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOHTTP2.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/_Vapor3.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOHPACK.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentSQL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/GraphQL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOSSL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOBoringSSL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CCryptoBoringSSL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CJWTKitBoringSSL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FCM.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/BSON.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FineJSON.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIO.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MySQLNIO.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SQLiteNIO.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/PostgresNIO.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOTLS.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/APNS.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/JWT.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOExtrasZlib.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Backtrace.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CBacktrace.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ProtocolConformance.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Runtime.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/OpenCombine.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ProtocolType.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MongoKittenCore.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MongoCore.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/WebSocketInfrastructure.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ApodiniDatabase.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ProtobufferCoding.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Logging.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Casting.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/OpenCombineDispatch.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Apodini.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SQLKitBenchmark.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentBenchmark.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/COperatingSystem.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MongoKitten.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOHTTPCompression.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/OpenCombineFoundation.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SwifCron.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Crypto.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/_MongoKittenCrypto.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CURLParser.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/RichJSONParser.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CMultipartParser.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentMySQLDriver.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentSQLiteDriver.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentMongoDriver.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentPostgresDriver.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Vapor.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/XCTVapor.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/AssociatedTypeRequirementsVisitor.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOExtras.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Jobs.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Metrics.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CoreMetrics.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOTransportServices.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOTestUtils.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Yams.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/_NIO1APIShims.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOBoringSSLShims.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CCryptoBoringSSLShims.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Notifications.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/COpenCombineHelpers.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ValuePointers.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOWebSocket.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/APNSwift.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/OpenAPIKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SQLKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MySQLKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/JWTKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/AsyncKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ConsoleKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SQLiteKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/RoutingKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/PostgresKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/WebSocketKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MultipartKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/AsyncHTTPClient.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/DNSClient.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MongoClient.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Fluent.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/XCTFluent.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CContext.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Meow.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/swift-nio/Sources/CNIOWindows/include/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/CRuntime/Sources/CRuntime/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/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.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/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/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/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/GraphQL.build/Language/Visitor~partial.swiftsourceinfo : /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/GraphQL.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/AST.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/TypeFromAST.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/ValueFromAST.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Schema.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/Find.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Source.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/Keyable.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/FieldsOnCorrectTypeRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/PossibleFragmentSpreadsRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/NoUnusedVariablesRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/KnownArgumentNamesRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/ScalarLeafsRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Rules/ProvidedNonNullArgumentsRule.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/AssertValidName.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/Validate.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Execution/Execute.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/IsValidValue.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/ASTFromValue.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/IsNullish.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Location.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Instrumentation/Instrumentation.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/MapSerialization.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/AnySerialization.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Introspection.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Definition.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/TypeInfo.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/Map.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/KeyMap.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/Unwrap.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/Number.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/MapCoder.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Map/AnyCoder.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Instrumentation/DispatchQueueInstrumentationWrapper.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Parser.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Lexer.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Error/GraphQLError.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Error/LocatedError.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Error/SyntaxError.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Visitor.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Language/Kinds.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/PersistedQueries/PersistedQueries.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Validation/SpecifiedRules.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Execution/Values.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Directives.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/NIO+Extensions.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Extensions/Codable+Extensions.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Type/Scalars.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/Utilities/TypeComparators.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/SuggestionList.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/GraphQL/Sources/GraphQL/SwiftUtilities/QuotedOrList.swift /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Runtime.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/CRuntime/Sources/CRuntime/CRuntime.h /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/dyld.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOHTTP1.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOHTTP2.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/_Vapor3.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOHPACK.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentSQL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/GraphQL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOSSL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOBoringSSL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CCryptoBoringSSL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CJWTKitBoringSSL.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FCM.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/BSON.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FineJSON.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIO.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MySQLNIO.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SQLiteNIO.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/PostgresNIO.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOTLS.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/APNS.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/JWT.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOExtrasZlib.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Backtrace.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CBacktrace.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ProtocolConformance.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Runtime.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/OpenCombine.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ProtocolType.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MongoKittenCore.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MongoCore.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/WebSocketInfrastructure.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ApodiniDatabase.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ProtobufferCoding.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Logging.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Casting.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/OpenCombineDispatch.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Apodini.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SQLKitBenchmark.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentBenchmark.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/COperatingSystem.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MongoKitten.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOHTTPCompression.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/OpenCombineFoundation.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SwifCron.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Crypto.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/_MongoKittenCrypto.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CURLParser.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/RichJSONParser.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CMultipartParser.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentMySQLDriver.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentSQLiteDriver.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentMongoDriver.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentPostgresDriver.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Vapor.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/XCTVapor.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/AssociatedTypeRequirementsVisitor.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOExtras.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Jobs.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Metrics.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CoreMetrics.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOTransportServices.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOTestUtils.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Yams.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/_NIO1APIShims.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOBoringSSLShims.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CCryptoBoringSSLShims.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Notifications.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/COpenCombineHelpers.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ValuePointers.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/NIOWebSocket.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/APNSwift.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/OpenAPIKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SQLKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MySQLKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/JWTKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/AsyncKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/ConsoleKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/SQLiteKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/RoutingKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/PostgresKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/WebSocketKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/FluentKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MultipartKit.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/AsyncHTTPClient.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/DNSClient.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/MongoClient.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Fluent.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/XCTFluent.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CContext.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/Meow.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/swift-nio/Sources/CNIOWindows/include/module.modulemap /Users/sadikekinozbay/Documents/TUM/WS-2/Swift/Apodini-Example-Project/.build/checkouts/CRuntime/Sources/CRuntime/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/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.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/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/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
|
someone who drives a taxi for a living
|
D
|
/**
* Control the various text mode attributes, such as color, when writing text
* to the console.
*
* 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/console.d, _console.d)
* Documentation: https://dlang.org/phobos/dmd_console.html
* Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/console.d
*/
module dmd.console;
import core.stdc.stdio;
version (Windows)
{
import core.sys.windows.winbase;
import core.sys.windows.wincon;
import core.sys.windows.windef;
private extern (C) int isatty(int) @trusted @nogc nothrow;
}
else version (Posix)
{
import core.sys.posix.unistd;
}
else
{
static assert(0);
}
enum Color : int
{
black = 0,
red = 1,
green = 2,
blue = 4,
yellow = red | green,
magenta = red | blue,
cyan = green | blue,
lightGray = red | green | blue,
bright = 8,
darkGray = bright | black,
brightRed = bright | red,
brightGreen = bright | green,
brightBlue = bright | blue,
brightYellow = bright | yellow,
brightMagenta = bright | magenta,
brightCyan = bright | cyan,
white = bright | lightGray,
}
interface Console
{
nothrow:
@property FILE* fp();
/**
* Turn on/off intensity.
* Params:
* bright = turn it on
*/
void setColorBright(bool bright);
/**
* Set color and intensity.
* Params:
* color = the color
*/
void setColor(Color color);
/**
* Reset console attributes to what they were
* when create() was called.
*/
void resetColor();
}
version (Windows)
private final class WindowsConsole : Console
{
nothrow:
private:
CONSOLE_SCREEN_BUFFER_INFO sbi;
HANDLE handle;
FILE* _fp;
static HANDLE getStdHandle(FILE *fp)
{
/* Determine if stream fp is a console
*/
version (CRuntime_DigitalMars)
{
if (!isatty(fp._file))
return null;
}
else version (CRuntime_Microsoft)
{
if (!isatty(fileno(fp)))
return null;
}
else
{
static assert(0, "Unsupported Windows runtime.");
}
if (fp == stdout)
return GetStdHandle(STD_OUTPUT_HANDLE);
else if (fp == stderr)
return GetStdHandle(STD_ERROR_HANDLE);
else
return null;
}
public:
@property FILE* fp() { return _fp; }
static WindowsConsole create(FILE* fp)
{
auto h = getStdHandle(fp);
if (h is null)
return null;
CONSOLE_SCREEN_BUFFER_INFO sbi;
if (GetConsoleScreenBufferInfo(h, &sbi) == 0) // get initial state of console
return null;
auto c = new WindowsConsole();
c._fp = fp;
c.handle = h;
c.sbi = sbi;
return c;
}
void setColorBright(bool bright)
{
SetConsoleTextAttribute(handle, sbi.wAttributes | (bright ? FOREGROUND_INTENSITY : 0));
}
void setColor(Color color)
{
enum FOREGROUND_WHITE = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
WORD attr = sbi.wAttributes;
attr = (attr & ~(FOREGROUND_WHITE | FOREGROUND_INTENSITY)) |
((color & Color.red) ? FOREGROUND_RED : 0) |
((color & Color.green) ? FOREGROUND_GREEN : 0) |
((color & Color.blue) ? FOREGROUND_BLUE : 0) |
((color & Color.bright) ? FOREGROUND_INTENSITY : 0);
SetConsoleTextAttribute(handle, attr);
}
void resetColor()
{
SetConsoleTextAttribute(handle, sbi.wAttributes);
}
}
/* Uses the ANSI escape codes.
* https://en.wikipedia.org/wiki/ANSI_escape_code
* Foreground colors: 30..37
* Background colors: 40..47
* Attributes:
* 0: reset all attributes
* 1: high intensity
* 2: low intensity
* 3: italic
* 4: single line underscore
* 5: slow blink
* 6: fast blink
* 7: reverse video
* 8: hidden
*/
private final class ANSIConsole : Console
{
nothrow:
private:
FILE* _fp;
public:
this(FILE* fp) { _fp = fp; }
@property FILE* fp() { return _fp; }
void setColorBright(bool bright)
{
fprintf(_fp, "\033[%dm", bright);
}
void setColor(Color color)
{
fprintf(_fp, "\033[%d;%dm", color & Color.bright ? 1 : 0, 30 + (color & ~Color.bright));
}
void resetColor()
{
fputs("\033[m", _fp);
}
}
/**
Tries to detect whether DMD has been invoked from a terminal.
Returns: `true` if a terminal has been detected, `false` otherwise
*/
bool detectTerminal() nothrow
{
version (Posix)
{
import core.stdc.stdlib : getenv;
const(char)* term = getenv("TERM");
import core.stdc.string : strcmp;
return isatty(STDERR_FILENO) && term && term[0] && strcmp(term, "dumb") != 0;
}
else version (Windows)
{
auto h = WindowsConsole.getStdHandle(stderr);
if (h is null)
return false;
CONSOLE_SCREEN_BUFFER_INFO sbi;
return GetConsoleScreenBufferInfo(h, &sbi) != 0;
}
}
/**
* Creates an instance of Console connected to stream fp.
* Params:
* fp = io stream
* Returns:
* reference to created Console
*/
Console createConsole(FILE* fp) nothrow
{
version (Windows)
{
if (auto c = WindowsConsole.create(fp))
return c;
}
return new ANSIConsole(fp);
}
|
D
|
/Users/nabil/Downloads/AlbumsMnager/Build/Intermediates/Pods.build/Debug-iphonesimulator/NVActivityIndicatorView.build/Objects-normal/x86_64/NVActivityIndicatorAnimationBallZigZag.o : /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulseSync.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScalePulseOutRapid.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScale.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScale.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Presenter/NVActivityIndicatorViewable.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleMultiple.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleRippleMultiple.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotateMultiple.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleRipple.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorShape.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallRotateChase.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulseRise.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallGridPulse.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotatePulse.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulse.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorAnimationDelegate.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallRotate.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotate.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallZigZag.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallTrianglePath.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBlank.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationPacman.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationSemiCircleSpin.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationSquareSpin.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationTriangleSkewSpin.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationCubeTransition.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineSpinFadeLoader.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallSpinFadeLoader.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Presenter/NVActivityIndicatorPresenter.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationAudioEqualizer.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallGridBeat.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallBeat.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallZigZagDeflect.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationOrbit.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScalePulseOut.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/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/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/nabil/Downloads/AlbumsMnager/Pods/Target\ Support\ Files/NVActivityIndicatorView/NVActivityIndicatorView-umbrella.h /Users/nabil/Downloads/AlbumsMnager/Build/Intermediates/Pods.build/Debug-iphonesimulator/NVActivityIndicatorView.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
/Users/nabil/Downloads/AlbumsMnager/Build/Intermediates/Pods.build/Debug-iphonesimulator/NVActivityIndicatorView.build/Objects-normal/x86_64/NVActivityIndicatorAnimationBallZigZag~partial.swiftmodule : /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulseSync.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScalePulseOutRapid.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScale.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScale.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Presenter/NVActivityIndicatorViewable.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleMultiple.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleRippleMultiple.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotateMultiple.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleRipple.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorShape.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallRotateChase.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulseRise.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallGridPulse.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotatePulse.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulse.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorAnimationDelegate.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallRotate.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotate.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallZigZag.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallTrianglePath.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBlank.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationPacman.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationSemiCircleSpin.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationSquareSpin.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationTriangleSkewSpin.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationCubeTransition.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineSpinFadeLoader.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallSpinFadeLoader.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Presenter/NVActivityIndicatorPresenter.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationAudioEqualizer.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallGridBeat.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallBeat.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallZigZagDeflect.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationOrbit.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScalePulseOut.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/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/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/nabil/Downloads/AlbumsMnager/Pods/Target\ Support\ Files/NVActivityIndicatorView/NVActivityIndicatorView-umbrella.h /Users/nabil/Downloads/AlbumsMnager/Build/Intermediates/Pods.build/Debug-iphonesimulator/NVActivityIndicatorView.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
/Users/nabil/Downloads/AlbumsMnager/Build/Intermediates/Pods.build/Debug-iphonesimulator/NVActivityIndicatorView.build/Objects-normal/x86_64/NVActivityIndicatorAnimationBallZigZag~partial.swiftdoc : /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulseSync.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScalePulseOutRapid.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScale.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScale.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Presenter/NVActivityIndicatorViewable.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleMultiple.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleRippleMultiple.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotateMultiple.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleRipple.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorShape.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallRotateChase.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulseRise.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallGridPulse.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotatePulse.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulse.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorAnimationDelegate.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallRotate.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotate.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallZigZag.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallTrianglePath.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBlank.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationPacman.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationSemiCircleSpin.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationSquareSpin.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationTriangleSkewSpin.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationCubeTransition.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineSpinFadeLoader.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallSpinFadeLoader.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Presenter/NVActivityIndicatorPresenter.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationAudioEqualizer.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallGridBeat.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallBeat.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallZigZagDeflect.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationOrbit.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScalePulseOut.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView.swift /Users/nabil/Downloads/AlbumsMnager/Pods/NVActivityIndicatorView/NVActivityIndicatorView/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/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/nabil/Downloads/AlbumsMnager/Pods/Target\ Support\ Files/NVActivityIndicatorView/NVActivityIndicatorView-umbrella.h /Users/nabil/Downloads/AlbumsMnager/Build/Intermediates/Pods.build/Debug-iphonesimulator/NVActivityIndicatorView.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
|
D
|
module android.java.android.renderscript.Sampler_Builder;
public import android.java.android.renderscript.Sampler_Builder_d_interface;
import arsd.jni : ImportExportImpl;
mixin ImportExportImpl!Sampler_Builder;
import import3 = android.java.java.lang.Class;
import import2 = android.java.android.renderscript.Sampler;
|
D
|
module d9cc.irdump;
import d9cc.genir, d9cc.parse;
import std.format, std.stdio;
private int regno(Reg r) {
if (r is null) {
return 0;
}
if (r.rn != -1) {
return r.rn;
}
return r.vn;
}
private string tostr_call(IR ir) {
string sb;
sb ~= "r%d = %s(".format(regno(ir.r0), ir.name);
foreach (i; 0 .. ir.nargs) {
if (i != 0) {
sb ~= ", ";
}
sb ~= "r%d".format(regno(ir.args[i]));
}
sb ~= ")";
return sb;
}
private string tostr(IR ir) {
int r0 = regno(ir.r0);
int r1 = regno(ir.r1);
int r2 = regno(ir.r2);
switch (ir.op) {
case IROpcode.ADD:
return "r%d = r%d + r%d".format(r0, r1, r2);
case IROpcode.CALL:
return tostr_call(ir);
case IROpcode.DIV:
return "r%d = r%d / r%d".format(r0, r1, r2);
case IROpcode.IMM:
return "r%d = %d".format(r0, ir.imm);
case IROpcode.JMP:
if (ir.bbarg) {
return "JMP .L%d (r%d)".format(ir.bb1.label, regno(ir.bbarg));
}
return "JMP .L%d".format(ir.bb1.label);
case IROpcode.LABEL_ADDR:
return "r%d = .L%d".format(r0, ir.label);
case IROpcode.EQ:
return "r%d = r%d == r%d".format(r0, r1, r2);
case IROpcode.NE:
return "r%d = r%d != r%d".format(r0, r1, r2);
case IROpcode.LE:
return "r%d = r%d <= r%d".format(r0, r1, r2);
case IROpcode.LT:
return "r%d = r%d < r%d".format(r0, r1, r2);
case IROpcode.AND:
return "r%d = r%d & r%d".format(r0, r1, r2);
case IROpcode.OR:
return "r%d = r%d | r%d".format(r0, r1, r2);
case IROpcode.XOR:
return "r%d = r%d ^ r%d".format(r0, r1, r2);
case IROpcode.SHL:
return "r%d = r%d << r%d".format(r0, r1, r2);
case IROpcode.SHR:
return "r%d = r%d >> r%d".format(r0, r1, r2);
case IROpcode.LOAD:
return "LOAD%d r%d, r%d".format(ir.size, r0, r2);
case IROpcode.LOAD_SPILL:
return "LOAD_SPILL r%d, %d".format(r0, ir.imm);
case IROpcode.MOD:
return "r%d = r%d %% r%d".format(r0, r1, r2);
case IROpcode.MOV:
return "r%d = r%d".format(r0, r2);
case IROpcode.MUL:
return "r%d = r%d * r%d".format(r0, r1, r2);
case IROpcode.NOP:
return "NOP";
case IROpcode.RETURN:
return "RET r%d".format(r2);
case IROpcode.STORE:
return "STORE%d r%d, r%d".format(ir.size, r1, r2);
case IROpcode.STORE_ARG:
return "STORE_ARG%d %d %s (%d)".format(ir.size,
ir.imm, ir.var.name, ir.var.offset);
case IROpcode.STORE_SPILL:
return "STORE_SPILL r%d, %d".format(r1, ir.imm);
case IROpcode.SUB:
return "r%d = r%d - r%d".format(r0, r1, r2);
case IROpcode.BPREL:
return "BPREL r%d %s (%d)".format(r0, ir.var.name, ir.var.offset);
case IROpcode.BR:
return "BR r%d .L%d .L%d".format(r2, ir.bb1.label, ir.bb2.label);
default:
assert(0 && "unknown op");
}
}
private void print_rel(string name, BB[] v) {
if (v.length == 0) {
return;
}
stderr.writef(" %s=", name);
foreach (i, bb; v) {
if (i > 0) {
stderr.writef(",");
}
stderr.writef(".L%d", bb.label);
}
}
private void print_regs(string name, Reg[] v) {
if (v.length == 0) {
return;
}
stderr.writef(" %s=", name);
foreach (i, r; v) {
if (i > 0) {
stderr.writef(",");
}
stderr.writef("r%d", regno(r));
}
}
private void print_bb(BB bb) {
if (bb.param) {
stderr.writef(".L%d(r%d)", bb.label, regno(bb.param));
} else {
stderr.writef(".L%d", bb.label);
}
print_rel("pred", bb.pred);
print_rel("succ", bb.succ);
print_regs("defs", bb.def_regs);
print_regs("in", bb.in_regs);
print_regs("out", bb.out_regs);
stderr.writef("\n");
}
void dump_ir(Function[] irv) {
foreach (fn; irv) {
stderr.writef("%s:\n", fn.name);
foreach (bb; fn.bbs) {
print_bb(bb);
foreach (ir; bb.ir) {
stderr.writef("\t%s\n", tostr(ir));
}
}
}
}
|
D
|
/Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/PostgreSQL.build/Codable/PostgreSQLRowDecoder.swift.o : /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+0.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+UUID.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/ChannelPipeline+PostgreSQL.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+Data.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+BackendKeyData.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLGeneric.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLBind.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Column/PostgreSQLDataTypeCode.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+FormatCode.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+PasswordMessage.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+StartupMessage.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+TableNameCache.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLTable.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLAlterTable.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLDataTypeStaticRepresentable.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLDataConvertible.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLQuery+DataType.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Database/PostgreSQLDatabase.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+NotificationResponse.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+ErrorResponse.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+SSLSupportResponse.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+Close.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+Date.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+Authenticate.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Database/PostgreSQLDatabaseConfig.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+TransportConfig.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+String.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLBoolLiteral.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+Bool.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+NotifyAndListen.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Column/PostgreSQLColumn.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+Polygon.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLCollation.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLFunction.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+ParameterDescription.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+RowDescription.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Utilities/PostgreSQLProvider.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Codable/PostgreSQLDataDecoder.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Pipeline/PostgreSQLMessageDecoder.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Codable/PostgreSQLRowDecoder.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Pipeline/PostgreSQLMessageEncoder.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Codable/PostgreSQLValueEncoder.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+FixedWidthInteger.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Database/PostgreSQLLogger.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Utilities/PostgreSQLError.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLBinaryOperator.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Utilities/Utilities.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+ServerAddress.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Utilities/Exports.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+ParameterStatus.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLResultFormat.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+Connect.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLDefault.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+Point.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+BinaryFloatingPoint.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLInsert.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLUpsert.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+BindRequest.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+DescribeRequest.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+ParseRequest.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+ExecuteRequest.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+AuthenticationRequest.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+SSLSupportRequest.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+DataRow.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLDropIndex.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLPrimaryKey.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+Query.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+Query.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLQuery.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+SimpleQuery.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+ReadyForQuery.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/SQL.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/NIOOpenSSL.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/NIOTLS.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/Async.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/Service.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/Core.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/COperatingSystem.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/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 /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/Crypto.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/Bits.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/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/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/DatabaseKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /usr/local/Cellar/libressl/2.9.2/include/openssl/asn1.h /usr/local/Cellar/libressl/2.9.2/include/openssl/tls1.h /usr/local/Cellar/libressl/2.9.2/include/openssl/dtls1.h /usr/local/Cellar/libressl/2.9.2/include/openssl/pkcs12.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ssl2.h /usr/local/Cellar/libressl/2.9.2/include/openssl/pem2.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ssl23.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ssl3.h /usr/local/Cellar/libressl/2.9.2/include/openssl/x509v3.h /usr/local/Cellar/libressl/2.9.2/include/openssl/md5.h /usr/local/Cellar/libressl/2.9.2/include/openssl/pkcs7.h /usr/local/Cellar/libressl/2.9.2/include/openssl/x509.h /usr/local/Cellar/libressl/2.9.2/include/openssl/sha.h /usr/local/Cellar/libressl/2.9.2/include/openssl/dsa.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ecdsa.h /usr/local/Cellar/libressl/2.9.2/include/openssl/rsa.h /usr/local/Cellar/libressl/2.9.2/include/openssl/obj_mac.h /usr/local/Cellar/libressl/2.9.2/include/openssl/hmac.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ec.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /usr/local/Cellar/libressl/2.9.2/include/openssl/rand.h /usr/local/Cellar/libressl/2.9.2/include/openssl/conf.h /usr/local/Cellar/libressl/2.9.2/include/openssl/opensslconf.h /usr/local/Cellar/libressl/2.9.2/include/openssl/dh.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ecdh.h /usr/local/Cellar/libressl/2.9.2/include/openssl/lhash.h /usr/local/Cellar/libressl/2.9.2/include/openssl/stack.h /usr/local/Cellar/libressl/2.9.2/include/openssl/safestack.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ssl.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio-ssl/Sources/CNIOOpenSSL/include/c_nio_openssl.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/crypto/Sources/CCryptoOpenSSL/include/c_crypto_openssl.h /usr/local/Cellar/libressl/2.9.2/include/openssl/pem.h /usr/local/Cellar/libressl/2.9.2/include/openssl/bn.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /usr/local/Cellar/libressl/2.9.2/include/openssl/bio.h /usr/local/Cellar/libressl/2.9.2/include/openssl/crypto.h /usr/local/Cellar/libressl/2.9.2/include/openssl/srtp.h /usr/local/Cellar/libressl/2.9.2/include/openssl/evp.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/2.9.2/include/openssl/buffer.h /usr/local/Cellar/libressl/2.9.2/include/openssl/err.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /usr/local/Cellar/libressl/2.9.2/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/2.9.2/include/openssl/objects.h /usr/local/Cellar/libressl/2.9.2/include/openssl/opensslv.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /usr/local/Cellar/libressl/2.9.2/include/openssl/x509_vfy.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/crypto/Sources/CBase32/include/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/crypto/Sources/CBcrypt/include/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio-zlib-support/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio-ssl-support/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/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.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/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/PostgreSQL.build/Codable/PostgreSQLRowDecoder~partial.swiftmodule : /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+0.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+UUID.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/ChannelPipeline+PostgreSQL.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+Data.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+BackendKeyData.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLGeneric.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLBind.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Column/PostgreSQLDataTypeCode.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+FormatCode.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+PasswordMessage.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+StartupMessage.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+TableNameCache.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLTable.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLAlterTable.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLDataTypeStaticRepresentable.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLDataConvertible.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLQuery+DataType.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Database/PostgreSQLDatabase.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+NotificationResponse.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+ErrorResponse.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+SSLSupportResponse.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+Close.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+Date.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+Authenticate.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Database/PostgreSQLDatabaseConfig.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+TransportConfig.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+String.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLBoolLiteral.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+Bool.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+NotifyAndListen.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Column/PostgreSQLColumn.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+Polygon.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLCollation.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLFunction.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+ParameterDescription.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+RowDescription.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Utilities/PostgreSQLProvider.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Codable/PostgreSQLDataDecoder.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Pipeline/PostgreSQLMessageDecoder.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Codable/PostgreSQLRowDecoder.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Pipeline/PostgreSQLMessageEncoder.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Codable/PostgreSQLValueEncoder.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+FixedWidthInteger.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Database/PostgreSQLLogger.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Utilities/PostgreSQLError.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLBinaryOperator.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Utilities/Utilities.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+ServerAddress.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Utilities/Exports.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+ParameterStatus.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLResultFormat.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+Connect.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLDefault.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+Point.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+BinaryFloatingPoint.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLInsert.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLUpsert.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+BindRequest.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+DescribeRequest.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+ParseRequest.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+ExecuteRequest.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+AuthenticationRequest.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+SSLSupportRequest.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+DataRow.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLDropIndex.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLPrimaryKey.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+Query.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+Query.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLQuery.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+SimpleQuery.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+ReadyForQuery.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/SQL.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/NIOOpenSSL.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/NIOTLS.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/Async.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/Service.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/Core.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/COperatingSystem.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/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 /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/Crypto.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/Bits.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/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/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/DatabaseKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /usr/local/Cellar/libressl/2.9.2/include/openssl/asn1.h /usr/local/Cellar/libressl/2.9.2/include/openssl/tls1.h /usr/local/Cellar/libressl/2.9.2/include/openssl/dtls1.h /usr/local/Cellar/libressl/2.9.2/include/openssl/pkcs12.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ssl2.h /usr/local/Cellar/libressl/2.9.2/include/openssl/pem2.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ssl23.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ssl3.h /usr/local/Cellar/libressl/2.9.2/include/openssl/x509v3.h /usr/local/Cellar/libressl/2.9.2/include/openssl/md5.h /usr/local/Cellar/libressl/2.9.2/include/openssl/pkcs7.h /usr/local/Cellar/libressl/2.9.2/include/openssl/x509.h /usr/local/Cellar/libressl/2.9.2/include/openssl/sha.h /usr/local/Cellar/libressl/2.9.2/include/openssl/dsa.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ecdsa.h /usr/local/Cellar/libressl/2.9.2/include/openssl/rsa.h /usr/local/Cellar/libressl/2.9.2/include/openssl/obj_mac.h /usr/local/Cellar/libressl/2.9.2/include/openssl/hmac.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ec.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /usr/local/Cellar/libressl/2.9.2/include/openssl/rand.h /usr/local/Cellar/libressl/2.9.2/include/openssl/conf.h /usr/local/Cellar/libressl/2.9.2/include/openssl/opensslconf.h /usr/local/Cellar/libressl/2.9.2/include/openssl/dh.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ecdh.h /usr/local/Cellar/libressl/2.9.2/include/openssl/lhash.h /usr/local/Cellar/libressl/2.9.2/include/openssl/stack.h /usr/local/Cellar/libressl/2.9.2/include/openssl/safestack.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ssl.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio-ssl/Sources/CNIOOpenSSL/include/c_nio_openssl.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/crypto/Sources/CCryptoOpenSSL/include/c_crypto_openssl.h /usr/local/Cellar/libressl/2.9.2/include/openssl/pem.h /usr/local/Cellar/libressl/2.9.2/include/openssl/bn.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /usr/local/Cellar/libressl/2.9.2/include/openssl/bio.h /usr/local/Cellar/libressl/2.9.2/include/openssl/crypto.h /usr/local/Cellar/libressl/2.9.2/include/openssl/srtp.h /usr/local/Cellar/libressl/2.9.2/include/openssl/evp.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/2.9.2/include/openssl/buffer.h /usr/local/Cellar/libressl/2.9.2/include/openssl/err.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /usr/local/Cellar/libressl/2.9.2/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/2.9.2/include/openssl/objects.h /usr/local/Cellar/libressl/2.9.2/include/openssl/opensslv.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /usr/local/Cellar/libressl/2.9.2/include/openssl/x509_vfy.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/crypto/Sources/CBase32/include/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/crypto/Sources/CBcrypt/include/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio-zlib-support/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio-ssl-support/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/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.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/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/PostgreSQL.build/Codable/PostgreSQLRowDecoder~partial.swiftdoc : /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+0.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+UUID.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/ChannelPipeline+PostgreSQL.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+Data.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+BackendKeyData.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLGeneric.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLBind.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Column/PostgreSQLDataTypeCode.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+FormatCode.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+PasswordMessage.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+StartupMessage.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+TableNameCache.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLTable.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLAlterTable.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLDataTypeStaticRepresentable.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLDataConvertible.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLQuery+DataType.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Database/PostgreSQLDatabase.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+NotificationResponse.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+ErrorResponse.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+SSLSupportResponse.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+Close.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+Date.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+Authenticate.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Database/PostgreSQLDatabaseConfig.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+TransportConfig.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+String.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLBoolLiteral.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+Bool.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+NotifyAndListen.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Column/PostgreSQLColumn.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+Polygon.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLCollation.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLFunction.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+ParameterDescription.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+RowDescription.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Utilities/PostgreSQLProvider.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Codable/PostgreSQLDataDecoder.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Pipeline/PostgreSQLMessageDecoder.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Codable/PostgreSQLRowDecoder.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Pipeline/PostgreSQLMessageEncoder.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Codable/PostgreSQLValueEncoder.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+FixedWidthInteger.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Database/PostgreSQLLogger.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Utilities/PostgreSQLError.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLBinaryOperator.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Utilities/Utilities.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+ServerAddress.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Utilities/Exports.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+ParameterStatus.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLResultFormat.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+Connect.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLDefault.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+Point.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Data/PostgreSQLData+BinaryFloatingPoint.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLInsert.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLUpsert.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+BindRequest.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+DescribeRequest.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+ParseRequest.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+ExecuteRequest.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+AuthenticationRequest.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+SSLSupportRequest.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+DataRow.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLDropIndex.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLPrimaryKey.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+Query.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+Query.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/SQL/PostgreSQLQuery.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Connection/PostgreSQLConnection+SimpleQuery.swift /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/postgresql/Sources/PostgreSQL/Message/PostgreSQLMessage+ReadyForQuery.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/SQL.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/NIOOpenSSL.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/NIOTLS.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/Async.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/Service.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/Core.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/COperatingSystem.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/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 /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/Crypto.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/Bits.swiftmodule /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/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/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/DatabaseKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /usr/local/Cellar/libressl/2.9.2/include/openssl/asn1.h /usr/local/Cellar/libressl/2.9.2/include/openssl/tls1.h /usr/local/Cellar/libressl/2.9.2/include/openssl/dtls1.h /usr/local/Cellar/libressl/2.9.2/include/openssl/pkcs12.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ssl2.h /usr/local/Cellar/libressl/2.9.2/include/openssl/pem2.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ssl23.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ssl3.h /usr/local/Cellar/libressl/2.9.2/include/openssl/x509v3.h /usr/local/Cellar/libressl/2.9.2/include/openssl/md5.h /usr/local/Cellar/libressl/2.9.2/include/openssl/pkcs7.h /usr/local/Cellar/libressl/2.9.2/include/openssl/x509.h /usr/local/Cellar/libressl/2.9.2/include/openssl/sha.h /usr/local/Cellar/libressl/2.9.2/include/openssl/dsa.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ecdsa.h /usr/local/Cellar/libressl/2.9.2/include/openssl/rsa.h /usr/local/Cellar/libressl/2.9.2/include/openssl/obj_mac.h /usr/local/Cellar/libressl/2.9.2/include/openssl/hmac.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ec.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /usr/local/Cellar/libressl/2.9.2/include/openssl/rand.h /usr/local/Cellar/libressl/2.9.2/include/openssl/conf.h /usr/local/Cellar/libressl/2.9.2/include/openssl/opensslconf.h /usr/local/Cellar/libressl/2.9.2/include/openssl/dh.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ecdh.h /usr/local/Cellar/libressl/2.9.2/include/openssl/lhash.h /usr/local/Cellar/libressl/2.9.2/include/openssl/stack.h /usr/local/Cellar/libressl/2.9.2/include/openssl/safestack.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ssl.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio-ssl/Sources/CNIOOpenSSL/include/c_nio_openssl.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/crypto/Sources/CCryptoOpenSSL/include/c_crypto_openssl.h /usr/local/Cellar/libressl/2.9.2/include/openssl/pem.h /usr/local/Cellar/libressl/2.9.2/include/openssl/bn.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /usr/local/Cellar/libressl/2.9.2/include/openssl/bio.h /usr/local/Cellar/libressl/2.9.2/include/openssl/crypto.h /usr/local/Cellar/libressl/2.9.2/include/openssl/srtp.h /usr/local/Cellar/libressl/2.9.2/include/openssl/evp.h /usr/local/Cellar/libressl/2.9.2/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/2.9.2/include/openssl/buffer.h /usr/local/Cellar/libressl/2.9.2/include/openssl/err.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /usr/local/Cellar/libressl/2.9.2/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/2.9.2/include/openssl/objects.h /usr/local/Cellar/libressl/2.9.2/include/openssl/opensslv.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /usr/local/Cellar/libressl/2.9.2/include/openssl/x509_vfy.h /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/crypto/Sources/CBase32/include/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/crypto/Sources/CBcrypt/include/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio-zlib-support/module.modulemap /Users/Jorge/Desktop/Projects/Web/Swift/kisiBootcamp/.build/checkouts/swift-nio-ssl-support/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/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.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
|
/*
* gdipluseffects.d
*
* This module implements GdiPlusEffects.h for D. The original copyright
* info is given below.
*
* Author: Dave Wilkinson
* Originated: November 25th, 2009
*
*/
module binding.win32.gdipluseffects;
import binding.win32.windef;
import binding.win32.winbase;
import binding.win32.winnt;
import binding.win32.guiddef;
import binding.win32.gdiplusmem;
import binding.win32.gdiplustypes;
import binding.win32.gdiplusenums;
import binding.win32.gdipluspixelformats;
import binding.win32.gdipluscolor;
import binding.win32.gdipluscolormatrix;
/**************************************************************************
*
* Copyright (c) 2001 Microsoft Corporation
*
* Module Name:
*
* Gdiplus effect objects.
*
* Created:
*
* 05/29/2001 asecchia
* Created it.
*
**************************************************************************/
extern(System):
version(GDIPLUS6) {
//-----------------------------------------------------------------------------
// GDI+ effect GUIDs
//-----------------------------------------------------------------------------
// {633C80A4-1843-482b-9EF2-BE2834C5FDD4}
const GUID BlurEffectGuid =
{ 0x633c80a4, 0x1843, 0x482b, [ 0x9e, 0xf2, 0xbe, 0x28, 0x34, 0xc5, 0xfd, 0xd4 ] };
// {63CBF3EE-C526-402c-8F71-62C540BF5142}
const GUID SharpenEffectGuid =
{ 0x63cbf3ee, 0xc526, 0x402c, [ 0x8f, 0x71, 0x62, 0xc5, 0x40, 0xbf, 0x51, 0x42 ] };
// {718F2615-7933-40e3-A511-5F68FE14DD74}
const GUID ColorMatrixEffectGuid =
{ 0x718f2615, 0x7933, 0x40e3, [ 0xa5, 0x11, 0x5f, 0x68, 0xfe, 0x14, 0xdd, 0x74 ] };
// {A7CE72A9-0F7F-40d7-B3CC-D0C02D5C3212}
const GUID ColorLUTEffectGuid =
{ 0xa7ce72a9, 0xf7f, 0x40d7, [ 0xb3, 0xcc, 0xd0, 0xc0, 0x2d, 0x5c, 0x32, 0x12 ] };
// {D3A1DBE1-8EC4-4c17-9F4C-EA97AD1C343D}
const GUID BrightnessContrastEffectGuid =
{ 0xd3a1dbe1, 0x8ec4, 0x4c17, [ 0x9f, 0x4c, 0xea, 0x97, 0xad, 0x1c, 0x34, 0x3d ] };
// {8B2DD6C3-EB07-4d87-A5F0-7108E26A9C5F}
const GUID HueSaturationLightnessEffectGuid =
{ 0x8b2dd6c3, 0xeb07, 0x4d87, [ 0xa5, 0xf0, 0x71, 0x8, 0xe2, 0x6a, 0x9c, 0x5f ] };
// {99C354EC-2A31-4f3a-8C34-17A803B33A25}
const GUID LevelsEffectGuid =
{ 0x99c354ec, 0x2a31, 0x4f3a, [ 0x8c, 0x34, 0x17, 0xa8, 0x3, 0xb3, 0x3a, 0x25 ] };
// {1077AF00-2848-4441-9489-44AD4C2D7A2C}
const GUID TintEffectGuid =
{ 0x1077af00, 0x2848, 0x4441, [ 0x94, 0x89, 0x44, 0xad, 0x4c, 0x2d, 0x7a, 0x2c ] };
// {537E597D-251E-48da-9664-29CA496B70F8}
const GUID ColorBalanceEffectGuid =
{ 0x537e597d, 0x251e, 0x48da, [ 0x96, 0x64, 0x29, 0xca, 0x49, 0x6b, 0x70, 0xf8 ] };
// {74D29D05-69A4-4266-9549-3CC52836B632}
const GUID RedEyeCorrectionEffectGuid =
{ 0x74d29d05, 0x69a4, 0x4266, [ 0x95, 0x49, 0x3c, 0xc5, 0x28, 0x36, 0xb6, 0x32 ] };
// {DD6A0022-58E4-4a67-9D9B-D48EB881A53D}
const GUID ColorCurveEffectGuid =
{ 0xdd6a0022, 0x58e4, 0x4a67, [ 0x9d, 0x9b, 0xd4, 0x8e, 0xb8, 0x81, 0xa5, 0x3d ] };
//-----------------------------------------------------------------------------
struct SharpenParams {
float radius;
float amount;
}
struct BlurParams {
float radius;
BOOL expandEdge;
}
struct BrightnessContrastParams {
INT brightnessLevel;
INT contrastLevel;
}
struct RedEyeCorrectionParams {
UINT numberOfAreas;
RECT *areas;
}
struct HueSaturationLightnessParams {
INT hueLevel;
INT saturationLevel;
INT lightnessLevel;
}
struct TintParams {
INT hue;
INT amount;
}
struct LevelsParams {
INT highlight;
INT midtone;
INT shadow;
}
struct ColorBalanceParams {
INT cyanRed;
INT magentaGreen;
INT yellowBlue;
}
struct ColorLUTParams {
// look up tables for each color channel.
ColorChannelLUT lutB;
ColorChannelLUT lutG;
ColorChannelLUT lutR;
ColorChannelLUT lutA;
}
enum CurveAdjustments {
AdjustExposure,
AdjustDensity,
AdjustContrast,
AdjustHighlight,
AdjustShadow,
AdjustMidtone,
AdjustWhiteSaturation,
AdjustBlackSaturation
}
enum CurveChannel {
CurveChannelAll,
CurveChannelRed,
CurveChannelGreen,
CurveChannelBlue
}
struct ColorCurveParams {
CurveAdjustments adjustment;
CurveChannel channel;
INT adjustValue;
}
struct CGpEffect;
Status GdipCreateEffect(GUID guid, CGpEffect **effect);
Status GdipDeleteEffect(CGpEffect *effect);
Status GdipGetEffectParameterSize(CGpEffect *effect, UINT *size);
Status GdipSetEffectParameters(CGpEffect *effect, VOID *params, UINT size);
Status GdipGetEffectParameters(CGpEffect *effect, UINT *size, VOID *params);
class Effect {
~this() {
// pvData is allocated by ApplyEffect. Return the pointer so that
// it can be freed by the appropriate memory manager.
GdipFree(auxData);
// Release the native Effect.
GdipDeleteEffect(nativeEffect);
}
INT GetAuxDataSize() {
return auxDataSize;
}
VOID *GetAuxData() {
return auxData;
}
VOID UseAuxData(BOOL useAuxDataFlag) {
useAuxData = useAuxDataFlag;
}
Status GetParameterSize(UINT *size) {
return GdipGetEffectParameterSize(nativeEffect, size);
}
protected:
Status SetParameters(void* params, UINT size) {
return GdipSetEffectParameters(nativeEffect, params, size);
}
Status GetParameters(UINT* size, void* params) {
return GdipGetEffectParameters(nativeEffect, size, params);
}
// protected data members.
package CGpEffect *nativeEffect = null;
package INT auxDataSize = 0;
package VOID *auxData = null;
package BOOL useAuxData = FALSE;
}
// Blur
class Blur : Effect {
// constructors cannot return an error code.
this() {
GdipCreateEffect(BlurEffectGuid, &nativeEffect);
}
Status SetParameters(BlurParams *parameters) {
UINT size = BlurParams.sizeof;
return Effect.SetParameters(cast(void*)parameters, size);
}
Status GetParameters(UINT *size, BlurParams *parameters) {
return Effect.GetParameters(size, cast(VOID*)parameters);
}
}
// Sharpen
class Sharpen : Effect {
this() {
GdipCreateEffect(SharpenEffectGuid, &nativeEffect);
}
Status SetParameters(SharpenParams *parameters) {
UINT size = SharpenParams.sizeof;
return Effect.SetParameters(parameters, size);
}
Status GetParameters(UINT *size, SharpenParams *parameters) {
return Effect.GetParameters(size, cast(VOID*)parameters);
}
}
// RedEye Correction
class RedEyeCorrection : Effect {
// constructors cannot return an error code.
this() {
GdipCreateEffect(RedEyeCorrectionEffectGuid, &nativeEffect);
}
Status SetParameters(RedEyeCorrectionParams *parameters) {
Status status = Status.InvalidParameter;
if (parameters) {
RedEyeCorrectionParams *inputParam =
cast(RedEyeCorrectionParams*)parameters;
UINT size = RedEyeCorrectionParams.sizeof +
inputParam.numberOfAreas * RECT.sizeof;
status = Effect.SetParameters(parameters, size);
}
return status;
}
Status GetParameters(UINT *size, RedEyeCorrectionParams *parameters) {
return Effect.GetParameters(size,cast(VOID*)parameters);
}
}
// Brightness/Contrast
class BrightnessContrast : Effect {
this() {
GdipCreateEffect(BrightnessContrastEffectGuid, &nativeEffect);
}
Status SetParameters(BrightnessContrastParams *parameters) {
UINT size = BrightnessContrastParams.sizeof;
return Effect.SetParameters(cast(VOID*)parameters, size);
}
Status GetParameters(UINT *size, BrightnessContrastParams *parameters) {
return Effect.GetParameters(size, cast(VOID*)parameters);
}
}
// Hue/Saturation/Lightness
class HueSaturationLightness : Effect {
this() {
GdipCreateEffect(HueSaturationLightnessEffectGuid, &nativeEffect);
}
Status SetParameters(HueSaturationLightnessParams *parameters) {
UINT size = HueSaturationLightnessParams.sizeof;
return Effect.SetParameters(cast(VOID*)parameters, size);
}
Status GetParameters(UINT *size, HueSaturationLightnessParams *parameters) {
return Effect.GetParameters(size, cast(VOID*)parameters);
}
}
// Highlight/Midtone/Shadow curves
class Levels : Effect {
this() {
GdipCreateEffect(LevelsEffectGuid, &nativeEffect);
}
Status SetParameters(LevelsParams *parameters) {
UINT size = LevelsParams.sizeof;
return Effect.SetParameters(cast(VOID*)parameters, size);
}
Status GetParameters(UINT *size, LevelsParams *parameters) {
return Effect.GetParameters(size, cast(VOID*)parameters);
}
}
// Tint
class Tint : Effect {
this() {
GdipCreateEffect(TintEffectGuid, &nativeEffect);
}
Status SetParameters(TintParams *parameters) {
UINT size = TintParams.sizeof;
return Effect.SetParameters(cast(VOID*)parameters, size);
}
Status GetParameters(UINT *size, TintParams *parameters) {
return Effect.GetParameters(size, cast(VOID*)parameters);
}
}
// ColorBalance
class ColorBalance : Effect {
this() {
GdipCreateEffect(ColorBalanceEffectGuid, &nativeEffect);
}
Status SetParameters(ColorBalanceParams *parameters) {
UINT size = ColorBalanceParams.sizeof;
return Effect.SetParameters(cast(VOID*)parameters, size);
}
Status GetParameters(UINT *size, ColorBalanceParams *parameters) {
return Effect.GetParameters(size, cast(VOID*)parameters);
}
}
// ColorMatrix
class ColorMatrixEffect : Effect {
this() {
GdipCreateEffect(ColorMatrixEffectGuid, &nativeEffect);
}
Status SetParameters(ColorMatrix *matrix) {
UINT size = ColorMatrix.sizeof;
return Effect.SetParameters(matrix, size);
}
Status GetParameters(UINT *size, ColorMatrix *matrix) {
return Effect.GetParameters(size, cast(VOID*)matrix);
}
}
// ColorLUT
class ColorLUT : Effect {
this() {
GdipCreateEffect(ColorLUTEffectGuid, &nativeEffect);
}
Status SetParameters(ColorLUTParams *lut) {
UINT size = ColorLUTParams.sizeof;
return Effect.SetParameters(lut, size);
}
Status GetParameters(UINT *size, ColorLUTParams *lut) {
return Effect.GetParameters(size, cast(VOID*)lut);
}
}
// Color Curve
class ColorCurve : Effect {
this() {
GdipCreateEffect(ColorCurveEffectGuid, &nativeEffect);
}
Status SetParameters(ColorCurveParams *parameters) {
UINT size = ColorCurveParams.sizeof;
return Effect.SetParameters(cast(VOID*)parameters, size);
}
Status GetParameters(UINT *size, ColorCurveParams *parameters) {
return Effect.GetParameters(size, cast(VOID*)parameters);
}
}
}
|
D
|
module UnrealScript.UTGame.UTMutator_Arena;
import ScriptClasses;
import UnrealScript.Helpers;
import UnrealScript.Engine.Pawn;
import UnrealScript.Engine.Actor;
import UnrealScript.UTGame.UTMutator;
extern(C++) interface UTMutator_Arena : UTMutator
{
public extern(D):
private static __gshared ScriptClass mStaticClass;
@property final static ScriptClass StaticClass() { mixin(MGSCC("Class UTGame.UTMutator_Arena")); }
private static __gshared UTMutator_Arena mDefaultProperties;
@property final static UTMutator_Arena DefaultProperties() { mixin(MGDPC("UTMutator_Arena", "UTMutator_Arena UTGame.Default__UTMutator_Arena")); }
static struct Functions
{
private static __gshared
{
ScriptFunction mPostBeginPlay;
ScriptFunction mCheckReplacement;
ScriptFunction mModifyPlayer;
}
public @property static final
{
ScriptFunction PostBeginPlay() { mixin(MGF("mPostBeginPlay", "Function UTGame.UTMutator_Arena.PostBeginPlay")); }
ScriptFunction CheckReplacement() { mixin(MGF("mCheckReplacement", "Function UTGame.UTMutator_Arena.CheckReplacement")); }
ScriptFunction ModifyPlayer() { mixin(MGF("mModifyPlayer", "Function UTGame.UTMutator_Arena.ModifyPlayer")); }
}
}
@property final auto ref ScriptString ArenaWeaponClassPath() { mixin(MGPC("ScriptString", 496)); }
final:
void PostBeginPlay()
{
(cast(ScriptObject)this).ProcessEvent(Functions.PostBeginPlay, cast(void*)0, cast(void*)0);
}
bool CheckReplacement(Actor Other)
{
ubyte params[8];
params[] = 0;
*cast(Actor*)params.ptr = Other;
(cast(ScriptObject)this).ProcessEvent(Functions.CheckReplacement, params.ptr, cast(void*)0);
return *cast(bool*)¶ms[4];
}
void ModifyPlayer(Pawn Other)
{
ubyte params[4];
params[] = 0;
*cast(Pawn*)params.ptr = Other;
(cast(ScriptObject)this).ProcessEvent(Functions.ModifyPlayer, params.ptr, cast(void*)0);
}
}
|
D
|
import dshell;
int main()
{
version (Windows) if (Vars.MODEL == "32") // Avoid optlink
return DISABLED;
version (Posix) if (Vars.PIC_FLAG == "") // Segfaults without PIC
return DISABLED;
Vars.set(`SRC`, `$EXTRA_FILES/dll`);
Vars.set(`EXE_NAME`, `$OUTPUT_BASE/testdll$EXE`);
Vars.set(`DLL`, `$OUTPUT_BASE/mydll$SOEXT`);
version (Windows)
{
enum dllExtra = `$SRC/dllmain.d`;
enum mainExtra = `$OUTPUT_BASE/mydll$LIBEXT`;
}
else
{
enum dllExtra = `$PIC_FLAG`;
enum mainExtra = `$PIC_FLAG -L-L$OUTPUT_BASE -L$DLL`;
}
run(`$DMD -m$MODEL -shared -od=$OUTPUT_BASE -of=$DLL $SRC/mydll.d ` ~ dllExtra);
run(`$DMD -m$MODEL -I$SRC -od=$OUTPUT_BASE -of=$EXE_NAME $SRC/testdll.d ` ~ mainExtra);
run(`$EXE_NAME`, stdout, stderr, [`LD_LIBRARY_PATH`: Vars.OUTPUT_BASE]);
return 0;
}
|
D
|
/**
* Copyright: Copyright (C) Thomas Dixon 2008. Все права защищены.
* License: BSD стиль: $(LICENSE)
* Authors: Thomas Dixon
*/
module util.cipher.RC6;
private import util.cipher.Cipher;
/**
* Implementation of the RC6-32/20/b cipher designed by
* Ron Rivest et al. of RSA Security.
*
* It should be noted that this algorithm is very similar в_ RC5.
* Currently there are no plans в_ implement RC5, but should that change
* in the future, it may be wise в_ rewrite Всё RC5 и RC6 в_ use some
* kind of template or основа class.
*
* This algorithm is patented и trademarked.
*
* References: http://people.csail.mit.edu/rivest/Rc6.pdf
*/
class RC6 : ШифрБлок
{
private
{
static const бцел ROUNDS = 20,
BLOCK_SIZE = 16,
// Magic constants for a 32 bit word размер
P = 0xb7e15163,
Q = 0x9e3779b9;
бцел[] S;
ббайт[] workingKey;
}
final override ткст имя()
{
return "RC6";
}
final override бцел размерБлока()
{
return BLOCK_SIZE;
}
final проц init(бул зашифруй, СимметричныйКлюч keyParams)
{
_encrypt = зашифруй;
бцел длин = keyParams.ключ.length;
if (длин != 16 && длин != 24 && длин != 32)
не_годится(имя()~": Неверный ключ length (требует 16/24/32 байты)");
S = new бцел[2*ROUNDS+4];
workingKey = keyParams.ключ;
установи(workingKey);
_initialized = да;
}
final override бцел обнови(проц[] input_, проц[] output_)
{
if (!_initialized)
не_годится(имя()~": Шифр not инициализован");
ббайт[] ввод = cast(ббайт[]) input_,
вывод = cast(ббайт[]) output_;
if (ввод.length < BLOCK_SIZE)
не_годится(имя()~": Ввод буфер too крат");
if (вывод.length < BLOCK_SIZE)
не_годится(имя()~": Вывод буфер too крат");
бцел A = БайтКонвертер.ЛитлЭндиан.в_!(бцел)(ввод[0..4]),
B = БайтКонвертер.ЛитлЭндиан.в_!(бцел)(ввод[4..8]),
C = БайтКонвертер.ЛитлЭндиан.в_!(бцел)(ввод[8..12]),
D = БайтКонвертер.ЛитлЭндиан.в_!(бцел)(ввод[12..16]),
t,
u;
if (_encrypt)
{
B += S[0];
D += S[1];
for (цел i = 1; i <= ROUNDS; i++)
{
t = Побитно.вращайВлево(B*((B<<1)+1), 5u);
u = Побитно.вращайВлево(D*((D<<1)+1), 5u);
A = Побитно.вращайВлево(A^t, u) + S[i<<1];
C = Побитно.вращайВлево(C^u, t) + S[(i<<1)+1];
t = A;
A = B;
B = C;
C = D;
D = t;
}
A += S[2*ROUNDS+2];
C += S[2*ROUNDS+3];
}
else
{
C -= S[2*ROUNDS+3];
A -= S[2*ROUNDS+2];
for (цел i = ROUNDS; i >= 1; i--)
{
t = D;
D = C;
C = B;
B = A;
A = t;
u = Побитно.вращайВлево(D*((D<<1)+1), 5u);
t = Побитно.вращайВлево(B*((B<<1)+1), 5u);
C = Побитно.вращайВправо(C-S[(i<<1)+1], t) ^ u;
A = Побитно.вращайВправо(A-S[i<<1], u) ^ t;
}
D -= S[1];
B -= S[0];
}
вывод[0..4] = БайтКонвертер.ЛитлЭндиан.из_!(бцел)(A);
вывод[4..8] = БайтКонвертер.ЛитлЭндиан.из_!(бцел)(B);
вывод[8..12] = БайтКонвертер.ЛитлЭндиан.из_!(бцел)(C);
вывод[12..16] = БайтКонвертер.ЛитлЭндиан.из_!(бцел)(D);
return BLOCK_SIZE;
}
final override проц сбрось()
{
установи(workingKey);
}
private проц установи(ббайт[] ключ)
{
бцел c = ключ.length/4;
бцел[] L = new бцел[c];
for (цел i = 0, j = 0; i < c; i++, j+=4)
L[i] = БайтКонвертер.ЛитлЭндиан.в_!(бцел)(ключ[j..j+цел.sizeof]);
S[0] = P;
for (цел i = 1; i <= 2*ROUNDS+3; i++)
S[i] = S[i-1] + Q;
бцел A, B, i, j, v = 3*(2*ROUNDS+4); // Relying on ints initializing в_ 0
for (цел s = 1; s <= v; s++)
{
A = S[i] = Побитно.вращайВлево(S[i]+A+B, 3u);
B = L[j] = Побитно.вращайВлево(L[j]+A+B, A+B);
i = (i + 1) % (2*ROUNDS+4);
j = (j + 1) % c;
}
}
/** Some RC6 тест vectors из_ the spec. */
debug (UnitTest)
{
unittest
{
static ткст[] test_keys = [
"00000000000000000000000000000000",
"0123456789abcdef0112233445566778",
"00000000000000000000000000000000"~
"0000000000000000",
"0123456789abcdef0112233445566778"~
"899aabbccddeeff0",
"00000000000000000000000000000000"~
"00000000000000000000000000000000",
"0123456789abcdef0112233445566778"~
"899aabbccddeeff01032547698badcfe"
];
static ткст[] test_plaintexts = [
"00000000000000000000000000000000",
"02132435465768798a9bacbdcedfe0f1",
"00000000000000000000000000000000",
"02132435465768798a9bacbdcedfe0f1",
"00000000000000000000000000000000",
"02132435465768798a9bacbdcedfe0f1"
];
static ткст[] test_ciphertexts = [
"8fc3a53656b1f778c129df4e9848a41e",
"524e192f4715c6231f51f6367ea43f18",
"6cd61bcb190b30384e8a3f168690ae82",
"688329d019e505041e52e92af95291d4",
"8f5fbd0510d15fa893fa3fda6e857ec2",
"c8241816f0d7e48920ad16a1674e5d48"
];
RC6 t = new RC6();
foreach (бцел i, ткст test_key; test_keys)
{
ббайт[] буфер = new ббайт[t.размерБлока];
ткст результат;
СимметричныйКлюч ключ = new СимметричныйКлюч(БайтКонвертер.hexDecode(test_key));
// Encryption
t.init(да, ключ);
t.обнови(БайтКонвертер.hexDecode(test_plaintexts[i]), буфер);
результат = БайтКонвертер.hexEncode(буфер);
assert(результат == test_ciphertexts[i],
t.имя~": ("~результат~") != ("~test_ciphertexts[i]~")");
// Decryption
t.init(нет, ключ);
t.обнови(БайтКонвертер.hexDecode(test_ciphertexts[i]), буфер);
результат = БайтКонвертер.hexEncode(буфер);
assert(результат == test_plaintexts[i],
t.имя~": ("~результат~") != ("~test_plaintexts[i]~")");
}
}
}
}
|
D
|
/**
Written in the D programming language.
Main entry point for command-line version of Dabble.
Copyright: Copyright Callum Anderson 2013
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: Callum Anderson
**/
module dabble.main;
import dabble.repl;
void main(char[][] args)
{
scope(exit) { onExit(); }
parseArgs(args[1..$]);
import dabble.testing;
//testAll();
loop();
}
void parseArgs(char[][] args)
{
import std.string : toLower;
import std.stdio: writeln;
foreach(uint i,arg; args)
{
switch(arg.toLower())
{
case "-i" :
writeln("Would include ",args[i+1]);
/* dabble.repl.addStaticModule (args[i+1]) */
break;
case "--noconsole": dabble.repl.consoleSession = false; break;
case "--showtimes": addDebugLevel(Debug.times); break;
case "--parseonly": addDebugLevel(Debug.parseOnly); break;
default: writeln("Unrecognized argument: ", arg); break;
}
}
}
|
D
|
module Player;
import std.typecons;
import std.math;
import std.algorithm;
import std.stdio;
import Vec3;
public enum FacingDirection
{
North = 0, East, South, West
}
public enum Weapon
{
Sword
}
public class Player
{
public Weapon GetWeapon() const { return Weapon.Sword; }
public void TeleportTo( int[] position )
{
levelPosition = position;
}
public void WalkForward()
{
if (facingDirection == FacingDirection.North)
{
--levelPosition[ 1 ];
}
else if (facingDirection == FacingDirection.South)
{
++levelPosition[ 1 ];
}
else if (facingDirection == FacingDirection.East)
{
++levelPosition[ 0 ];
}
else if (facingDirection == FacingDirection.West)
{
--levelPosition[ 0 ];
}
writeln("player pos: ", levelPosition[ 0 ], ", ", levelPosition[ 1 ] );
}
public void WalkBackward()
{
if (facingDirection == FacingDirection.North)
{
++levelPosition[ 1 ];
}
else if (facingDirection == FacingDirection.South)
{
--levelPosition[ 1 ];
}
else if (facingDirection == FacingDirection.East)
{
--levelPosition[ 0 ];
}
else if (facingDirection == FacingDirection.West)
{
++levelPosition[ 0 ];
}
writeln("player pos: ", levelPosition[ 0 ], ", ", levelPosition[ 1 ] );
}
public void TurnRight()
{
facingDirection = cast(FacingDirection)((cast(int)facingDirection + 1) % 4);
}
public void TurnLeft()
{
final switch (facingDirection)
{
case FacingDirection.North: facingDirection = FacingDirection.West; break;
case FacingDirection.South: facingDirection = FacingDirection.East; break;
case FacingDirection.East: facingDirection = FacingDirection.North; break;
case FacingDirection.West: facingDirection = FacingDirection.South; break;
}
}
public int[] GetLevelPosition()
{
return levelPosition;
}
public Tuple!(int, int) GetForwardPosition()
{
final switch (facingDirection)
{
case FacingDirection.North: return tuple( levelPosition[ 0 ], levelPosition[ 1 ] - 1 );
case FacingDirection.South: return tuple( levelPosition[ 0 ], levelPosition[ 1 ] + 1);
case FacingDirection.East: return tuple( levelPosition[ 0 ] + 1, levelPosition[ 1 ] );
case FacingDirection.West: return tuple( levelPosition[ 0 ] - 1, levelPosition[ 1 ] );
}
}
public Tuple!(int, int) GetBackwardPosition()
{
final switch (facingDirection)
{
case FacingDirection.North: return tuple( levelPosition[ 0 ], levelPosition[ 1 ] + 1 );
case FacingDirection.South: return tuple( levelPosition[ 0 ], levelPosition[ 1 ] - 1 );
case FacingDirection.East: return tuple( levelPosition[ 0 ] - 1, levelPosition[ 1 ] );
case FacingDirection.West: return tuple( levelPosition[ 0 ] + 1, levelPosition[ 1 ] );
}
}
public Vec3.Vec3 GetWorldPosition() const
{
return Vec3.Vec3( levelPosition[ 0 ] * 20, 0, levelPosition[ 1 ] * 20 );
}
public Vec3.Vec3 GetWorldDirection() const
{
final switch (facingDirection)
{
case FacingDirection.South: return Vec3.Vec3( 0, 0, -1 );
case FacingDirection.North: return Vec3.Vec3( 0, 0, 1 );
case FacingDirection.East: return Vec3.Vec3( -1, 0, 0 );
case FacingDirection.West: return Vec3.Vec3( 1, 0, 0 );
}
}
public FacingDirection GetFacingDirection() const
{
return facingDirection;
}
public int GetHealth() const
{
return health;
}
public int GetMaxHealth() const
{
return healthMax;
}
public bool HasMaxHealth() const
{
return health == healthMax;
}
public void EatFood( int healthGain )
{
health = min( health + healthGain, healthMax );
}
private int[ 2 ] levelPosition = [ 1, 1 ];
private FacingDirection facingDirection = FacingDirection.South;
private int health = 1;
private int healthMax = 2;
}
|
D
|
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*/
/* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.sys.ipc;
private import core.sys.posix.config;
public import core.sys.posix.sys.types; // for uid_t, gid_t, mode_t, key_t
version (Posix):
extern (C) nothrow @nogc:
//
// XOpen (XSI)
//
/*
struct ipc_perm
{
uid_t uid;
gid_t gid;
uid_t cuid;
gid_t cgid;
mode_t mode;
}
IPC_CREAT
IPC_EXCL
IPC_NOWAIT
IPC_PRIVATE
IPC_RMID
IPC_SET
IPC_STAT
key_t ftok(in char*, int);
*/
version( linux )
{
struct ipc_perm
{
key_t __key;
uid_t uid;
gid_t gid;
uid_t cuid;
gid_t cgid;
ushort mode;
ushort __pad1;
ushort __seq;
ushort __pad2;
c_ulong __unused1;
c_ulong __unused2;
}
enum IPC_CREAT = 0x0200; // 01000
enum IPC_EXCL = 0x0400; // 02000
enum IPC_NOWAIT = 0x0800; // 04000
enum key_t IPC_PRIVATE = 0;
enum IPC_RMID = 0;
enum IPC_SET = 1;
enum IPC_STAT = 2;
key_t ftok(in char*, int);
}
else version( OSX )
{
}
else version( FreeBSD )
{
struct ipc_perm_old // <= FreeBSD7
{
ushort cuid;
ushort cguid;
ushort uid;
ushort gid;
ushort mode;
ushort seq;
key_t key;
}
struct ipc_perm
{
uid_t cuid;
gid_t cgid;
uid_t uid;
gid_t gid;
mode_t mode;
ushort seq;
key_t key;
}
enum IPC_CREAT = 0x0200; // 01000
enum IPC_EXCL = 0x0400; // 02000
enum IPC_NOWAIT = 0x0800; // 04000
enum key_t IPC_PRIVATE = 0;
enum IPC_RMID = 0;
enum IPC_SET = 1;
enum IPC_STAT = 2;
key_t ftok(in char*, int);
}
else version( Android )
{
version (X86)
{
struct ipc_perm
{
key_t key;
ushort uid;
ushort gid;
ushort cuid;
ushort cgid;
mode_t mode;
ushort seq;
}
}
else
{
static assert(false, "Architecture not supported.");
}
enum IPC_CREAT = 0x0200; // 01000
enum IPC_EXCL = 0x0400; // 02000
enum IPC_NOWAIT = 0x0800; // 04000
enum key_t IPC_PRIVATE = 0;
enum IPC_RMID = 0;
enum IPC_SET = 1;
enum IPC_STAT = 2;
key_t ftok(in char*, int);
}
|
D
|
func void pc_sleep(var int t)
{
AI_StopProcessInfos(self);
PLAYER_MOBSI_PRODUCTION = MOBSI_NONE;
self.aivar[AIV_INVINCIBLE] = FALSE;
if(Wld_IsTime(0,0,t,0))
{
Wld_SetTime(t,0);
}
else
{
t = t + 24;
Wld_SetTime(t,0);
};
Wld_StopEffect("DEMENTOR_FX");
if(SC_ISOBSESSED == TRUE)
{
PrintScreen(PRINT_SLEEPOVEROBSESSED,-1,-1,FONT_SCREEN,3);
}
else
{
PrintScreen(PRINT_SLEEPOVER,-1,-1,FONT_SCREEN,3);
hero.attribute[ATR_HITPOINTS] = hero.attribute[ATR_HITPOINTS_MAX];
hero.attribute[ATR_MANA] = hero.attribute[ATR_MANA_MAX];
};
printglobals(PD_ITEM_MOBSI);
Npc_SendPassivePerc(hero,PERC_ASSESSENTERROOM,NULL,hero);
};
func void sleepabit_s1()
{
var C_NPC her;
var C_NPC rock;
her = Hlp_GetNpc(pc_hero);
rock = Hlp_GetNpc(pc_rockefeller);
if((Hlp_GetInstanceID(self) == Hlp_GetInstanceID(her)) || (Hlp_GetInstanceID(self) == Hlp_GetInstanceID(rock)))
{
self.aivar[AIV_INVINCIBLE] = TRUE;
PLAYER_MOBSI_PRODUCTION = MOBSI_SLEEPABIT;
AI_ProcessInfos(her);
if(SC_ISOBSESSED == TRUE)
{
Wld_PlayEffect("DEMENTOR_FX",hero,hero,0,0,0,FALSE);
};
};
};
instance PC_NOSLEEP(C_INFO)
{
npc = pc_hero;
nr = 999;
condition = pc_nosleep_condition;
information = pc_nosleep_info;
important = 0;
permanent = 1;
description = DIALOG_ENDE;
};
func int pc_nosleep_condition()
{
if(PLAYER_MOBSI_PRODUCTION == MOBSI_SLEEPABIT)
{
return 1;
};
};
func void pc_nosleep_info()
{
AI_StopProcessInfos(self);
Wld_StopEffect("DEMENTOR_FX");
self.aivar[AIV_INVINCIBLE] = FALSE;
PLAYER_MOBSI_PRODUCTION = MOBSI_NONE;
};
instance PC_SLEEPTIME_MORNING(C_INFO)
{
npc = pc_hero;
condition = pc_sleeptime_morning_condition;
information = pc_sleeptime_morning_info;
important = 0;
permanent = 1;
description = "Спать до следующего утра";
};
func int pc_sleeptime_morning_condition()
{
if(PLAYER_MOBSI_PRODUCTION == MOBSI_SLEEPABIT)
{
return 1;
};
};
func void pc_sleeptime_morning_info()
{
pc_sleep(8);
};
instance PC_SLEEPTIME_NOON(C_INFO)
{
npc = pc_hero;
condition = pc_sleeptime_noon_condition;
information = pc_sleeptime_noon_info;
important = 0;
permanent = 1;
description = "Спать до полудня";
};
func int pc_sleeptime_noon_condition()
{
if(PLAYER_MOBSI_PRODUCTION == MOBSI_SLEEPABIT)
{
return 1;
};
};
func void pc_sleeptime_noon_info()
{
pc_sleep(12);
};
instance PC_SLEEPTIME_EVENING(C_INFO)
{
npc = pc_hero;
condition = pc_sleeptime_evening_condition;
information = pc_sleeptime_evening_info;
important = 0;
permanent = 1;
description = "Спать до следующего вечера";
};
func int pc_sleeptime_evening_condition()
{
if(PLAYER_MOBSI_PRODUCTION == MOBSI_SLEEPABIT)
{
return 1;
};
};
func void pc_sleeptime_evening_info()
{
pc_sleep(20);
};
instance PC_SLEEPTIME_MIDNIGHT(C_INFO)
{
npc = pc_hero;
condition = pc_sleeptime_midnight_condition;
information = pc_sleeptime_midnight_info;
important = 0;
permanent = 1;
description = "Спать до полуночи";
};
func int pc_sleeptime_midnight_condition()
{
if(PLAYER_MOBSI_PRODUCTION == MOBSI_SLEEPABIT)
{
return 1;
};
};
func void pc_sleeptime_midnight_info()
{
pc_sleep(0);
};
|
D
|
/**
* Defines the static Input class, which is responsible for handling all keyboard/mouse/controller interactions.
*/
module dash.utility.input;
import dash.utility, dash.core, dash.graphics;
import yaml, gl3n.linalg;
import derelict.opengl3.gl3;
import std.typecons, std.conv, std.traits, std.uuid;
/**
* Manages all input events.
*/
final abstract class Input
{
static:
private:
struct Binding
{
public:
string name;
Keyboard.Buttons[] KeyboardButtons;
Mouse.Buttons[] MouseButtons;
//Mouse.Axes[] MouseAxes;
this( string bind )
{
name = bind;
}
}
Binding[string] inputBindings;
enum passThrough( string functionName, string args ) = q{
void $functionName( string inputName, void delegate( $args ) func )
{
if( auto binding = inputName in inputBindings )
{
foreach( key; binding.KeyboardButtons )
Keyboard.$functionName( key, cast(ParameterTypeTuple!(__traits(getMember, Keyboard, "$functionName"))[ 1 ])func );
foreach( mb; binding.MouseButtons )
Mouse.$functionName( mb, cast(ParameterTypeTuple!(__traits(getMember, Mouse, "$functionName"))[ 1 ])func );
}
else
{
throw new Exception( "Name " ~ inputName ~ " not bound." );
}
}
}.replaceMap( [ "$functionName": functionName, "$args": args ] );
public:
/**
* Processes Config/Input.yml and pulls input string bindings.
*/
void initialize()
{
auto bindings = Resources.InputBindings.loadYamlFile();
Keyboard.initialize();
Mouse.initialize();
foreach( string name, Node bind; bindings )
{
if( !bind.isMapping )
{
logWarning( "Unsupported input format for ", name, "." );
continue;
}
inputBindings[ name ] = Binding( name );
foreach( string type, Node value; bind )
{
enum parseType( string type ) = q{
case "$type":
if( value.isScalar )
{
try
{
inputBindings[ name ].$typeButtons ~= value.get!string.to!($type.Buttons);
}
catch( Exception e )
{
logFatal( "Failed to parse keybinding for input ", name, ": ", e.msg );
}
}
else if( value.isSequence )
{
foreach( Node element; value )
{
try
{
inputBindings[ name ].$typeButtons ~= element.get!string.to!($type.Buttons);
}
catch( Exception e )
{
logFatal( "Failed to parse keybinding for input ", name, ": ", e.msg );
}
}
}
else
{
logFatal( "Failed to parse $type binding for input ", name, ": Mappings not allowed." );
}
break;
}.replaceMap( [ "$type": type ] );
final switch( type )
{
mixin( parseType!q{Keyboard} );
mixin( parseType!q{Mouse} );
}
}
}
}
/**
* Updates the key states, and calls all key events.
*/
void update()
{
Keyboard.update();
Mouse.update();
}
/**
* Gets the state of a string-bound input.
*
* Params:
* input = The input to check for.
* checkPrevious = Whether or not to make sure the key was up last frame.
*/
T getState( T = bool )( string input, bool checkPrevious = false ) if( is( T == bool ) || is( T == float ) )
{
static if( is( T == bool ) )
{
if( auto binding = input in inputBindings )
{
foreach( key; binding.KeyboardButtons )
if( Keyboard.isButtonDown( key, checkPrevious ) )
return true;
foreach( mb; binding.MouseButtons )
if( Mouse.isButtonDown( mb, checkPrevious ) )
return true;
return false;
}
}
/*else static if( is( T == float ) )
{
if( input in Keyboard.axisBindings )
{
return Keyboard.getAxisState( input );
}
else if( input in Mouse.axisBindings )
{
return Mouse.getAxisState( input );
}
}*/
throw new Exception( "Input " ~ input ~ " not bound." );
}
/**
* Check if a given button is down.
*
* Params:
* buttonName = The name of the button to check.
* checkPrevious = Whether or not to make sure the button was down last frame.
*/
bool isButtonDown( string buttonName, bool checkPrevious = false )
{
if( auto binding = buttonName in inputBindings )
{
foreach( key; binding.KeyboardButtons )
if( Keyboard.isButtonDown( key, checkPrevious ) )
return true;
foreach( mb; binding.MouseButtons )
if( Mouse.isButtonDown( mb, checkPrevious ) )
return true;
}
return false;
}
/**
* Add an event to be fired when the given button changes.
*
* Params:
* inputName = The name of the input to add the event to.
* func = The function to call when the button state changes.
*/
mixin( passThrough!( "addButtonEvent", "uint, bool" ) );
/**
* Add a button event only when the button is down.
*/
mixin( passThrough!( "addButtonDownEvent", "uint" ) );
/**
* Add a button event only when the button is up.
*/
mixin( passThrough!( "addButtonUpEvent", "uint" ) );
/**
* Gets the position of the cursor.
*
* Returns: The position of the mouse cursor.
*/
vec2i mousePos()
{
version( Windows )
{
import dash.graphics;
import win32.windows;
POINT i;
GetCursorPos( &i );
ScreenToClient( Win32.get().hWnd, &i );
// Adjust for border
if( !Graphics.adapter.fullscreen )
{
i.x -= GetSystemMetrics( SM_CXBORDER );
i.y -= GetSystemMetrics( SM_CYBORDER );
}
return vec2i( i.x, Graphics.height - i.y );
}
else
{
return vec2i();
}
}
/**
* Gets the world position of the cursor in the active scene.
*
* Returns: The position of the mouse cursor in world space.
*/
vec3 mousePosView()
{
if( !DGame.instance.activeScene )
{
logWarning( "No active scene." );
return vec3( 0.0f, 0.0f, 0.0f );
}
auto scene = DGame.instance.activeScene;
if( !scene.camera )
{
logWarning( "No camera on active scene." );
return vec3( 0.0f, 0.0f, 0.0f );
}
vec2i mouse = mousePos();
float depth;
int x = mouse.x;
int y = mouse.y;
auto view = vec3( 0, 0, 0 );
if( x >= 0 && x <= Graphics.width && y >= 0 && y <= Graphics.height )
{
glBindFramebuffer( GL_FRAMEBUFFER, Graphics.deferredFrameBuffer );
glReadBuffer( GL_DEPTH_ATTACHMENT );
glReadPixels( x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
auto linearDepth = scene.camera.projectionConstants.x / ( scene.camera.projectionConstants.y - depth );
//Convert x and y to normalized device coords
float screenX = ( mouse.x / cast(float)Graphics.width ) * 2 - 1;
float screenY = -( ( mouse.y / cast(float)Graphics.height ) * 2 - 1 );
auto viewSpace = scene.camera.inversePerspectiveMatrix * vec4( screenX, screenY, 1.0f, 1.0f);
auto viewRay = vec3( viewSpace.xy * (1.0f / viewSpace.z), 1.0f);
view = viewRay * linearDepth;
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
}
return view;
}
/**
* Gets the world position of the cursor in the active scene.
*
* Returns: The position of the mouse cursor in world space.
*/
vec3 mousePosWorld()
{
return (DGame.instance.activeScene.camera.inverseViewMatrix * vec4( mousePosView(), 1.0f )).xyz;
}
/**
* Gets the world position of the cursor in the active scene.
*
* Returns: The GameObject located at the current mouse Position
*/
GameObject mouseObject()
{
if( !DGame.instance.activeScene )
{
logWarning( "No active scene." );
return null;
}
auto scene = DGame.instance.activeScene;
if( !scene.camera )
{
logWarning( "No camera on active scene." );
return null;
}
vec2i mouse = mousePos();
float fId;
if( mouse.x >= 0 && mouse.x <= Graphics.width && mouse.y >= 0 && mouse.y <= Graphics.height )
{
glBindFramebuffer( GL_FRAMEBUFFER, Graphics.deferredFrameBuffer );
glReadBuffer( GL_COLOR_ATTACHMENT1 );
glReadPixels( mouse.x, mouse.y, 1, 1, GL_ALPHA, GL_FLOAT, &fId);
uint id = cast(int)(fId);
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
if(id > 0)
{
import dash.utility.output;
logInfo( "Clicked object ID: ", id );
return scene[id];
}
}
return null;
}
}
alias Keyboard = InputSystem!( KeyboardButtons, void );
alias Mouse = InputSystem!( MouseButtons, MouseAxes );
private:
/**
* Defines a system of inputs, buttons, axes or both.
*
* Params:
* ButtonEnum = The enum of buttons for this system.
* AxisEnum = The enum of axes for this system.
*/
final abstract class InputSystem( ButtonEnum, AxisEnum )
{
static:
public:
/// Whether or not the system has buttons.
enum HasButtons = !is( ButtonEnum == void );
/// Whether or not the system has axes.
enum HasAxes = !is( AxisEnum == void );
private:
/**
* Initialize all states and events.
*/
void initialize()
{
static if( HasButtons )
{
buttonCurrent.reset();
buttonPrevious.reset();
buttonStaging.reset();
foreach( key; buttonEvents.keys )
buttonEvents.remove( key );
}
static if( HasAxes )
{
axisCurrent.reset();
axisStaging.reset();
foreach( key; axisEvents.keys )
axisEvents.remove( key );
}
}
/**
* Update all events and states.
*/
void update()
{
static if( HasButtons )
{
auto diffButtons = buttonStaging - buttonCurrent;
buttonPrevious = buttonCurrent;
buttonCurrent = buttonStaging;
foreach( state; diffButtons )
if( auto buttonEvent = state[ 0 ] in buttonEvents )
foreach( event; *buttonEvent )
event( state[ 0 ], state[ 1 ] );
}
static if( HasAxes )
{
auto diffAxis = axisStaging - axisCurrent;
axisCurrent = axisStaging;
foreach( state; diffAxis )
if( auto axisEvent = state[ 0 ] in axisEvents )
foreach( event; *axisEvent )
event( state[ 0 ], state[ 1 ] );
}
}
// If we have buttons
static if( HasButtons )
{
public:
/// The enum of buttons that the input system has.
alias Buttons = ButtonState.Inputs;
/// The type each button is stored as.
alias ButtonStorageType = bool;
/// A delegate that takes the changed button and the new state.
alias ButtonEvent = void delegate( Buttons, ButtonStorageType );
/// A delegate that takes the changed button.
alias ButtonStateEvent = void delegate( Buttons );
/**
* Check if a given button is down.
*
* Params:
* buttonCode = The button to check.
* checkPrevious = Whether or not to make sure the button was down last frame.
*
* Returns: The state of the button.
*/
ButtonStorageType getButtonState( Buttons buttonCode )
{
return buttonCurrent[ buttonCode ];
}
/**
* Check if a given button is down.
*
* Params:
* buttonCode = The code of the button to check.
* checkPrevious = Whether or not to make sure the button was down last frame.
*
* Returns: The state of the button.
*/
ButtonStorageType isButtonDown( Buttons buttonCode, bool checkPrevious = false )
{
return buttonCurrent[ buttonCode ] && ( !checkPrevious || !buttonPrevious[ buttonCode ] );
}
/**
* Check if a given button is up.
*
* Params:
* buttonCode = The code of the button to check.
* checkPrevious = Whether or not to make sure the button was up last frame.
*
* Returns: The state of the button.
*/
ButtonStorageType isButtonUp( Buttons buttonCode, bool checkPrevious = false )
{
return !buttonCurrent[ buttonCode ] && ( !checkPrevious || buttonPrevious[ buttonCode ] );
}
/**
* Add an event to be fired when the given button changes.
*
* Params:
* buttonCode = The code of the button to add the event to.
* func = The function to call when the button state changes.
*/
void addButtonEvent( Buttons buttonCode, ButtonEvent func )
{
buttonEvents[ buttonCode ] ~= func;
}
/**
* Add a button event only when the button is down.
*/
void addButtonDownEvent( Buttons buttonCode, ButtonStateEvent func )
{
addButtonEvent( buttonCode, ( Buttons buttonCode, ButtonStorageType newState ) { if( newState ) func( buttonCode ); } );
}
/**
* Add a button event only when the button is up.
*/
void addButtonUpEvent( Buttons buttonCode, ButtonStateEvent func )
{
addButtonEvent( buttonCode, ( Buttons buttonCode, ButtonStorageType newState ) { if( !newState ) func( buttonCode ); } );
}
/**
* Sets the state of the button to be assigned at the beginning of next frame.
* Should only be called from a window controller.
*/
void setButtonState( Buttons buttonCode, ButtonStorageType newState )
{
buttonStaging[ buttonCode ] = newState;
}
private:
/// The struct storing the state of the buttons.
alias ButtonState = State!( ButtonStorageType, ButtonEnum );
/// The state of the buttons as of the beginning of the current frame.
ButtonState buttonCurrent;
/// The state of the buttons for the last frame.
ButtonState buttonPrevious;
/// The state of the buttons that has not been applied yet.
ButtonState buttonStaging;
/// The events tied to the buttons of this system.
ButtonEvent[][ Buttons ] buttonEvents;
}
// If we have axes
static if( HasAxes )
{
public:
/// The enum of axes that the input system has.
alias Axes = AxisState.Inputs;
/// The type each axis is stored as.
alias AxisStorageType = float;
/// A delegate that takes the changed axis and the new state.
alias AxisEvent = void delegate( Axes, AxisStorageType );
/**
* Get the state of a given axis.
*
* Params:
* axis = The axis to get the state of.
*
* Returns: The state of the axis.
*/
AxisStorageType getAxisState( Axes axis )
{
return axisCurrent[ axis ];
}
/**
* Add an event to be fired when the given axis changes.
*
* Params:
* axis = The name of the input to add the event to.
* event = The event to trigger when the axis state changes.
*/
void addAxisEvent( Axes axis, AxisEvent event )
{
axisEvents[ axis ] ~= event;
}
/**
* Sets the state of the axis to be assigned at the beginning of next frame.
* Should only be called from a window controller.
*/
void setAxisState( Axes axisCode, AxisStorageType newState )
{
axisStaging[ axisCode ] = newState;
}
private:
/// The struct storing the state of the axes.
alias AxisState = State!( AxisStorageType, AxisEnum );
/// The state of the axes as of the beginning of the current frame.
AxisState axisCurrent;
/// The state of the axes that has not been applied yet.
AxisState axisStaging;
/// The events tied to the axes of this system.
AxisEvent[][ Axes ] axisEvents;
}
}
/**
* Represents the state of an input method (ie. keyboard, gamepad, etc.).
*
* Params:
* T = The type being stored (ie. bool for keys, floats for axes, etc.).
* totalSize = The number of inputs to store.
*/
struct State( T, InputEnum ) if( is( InputEnum == enum ) )
{
private:
enum totalSize = Inputs.END;
alias StorageType = T;
alias Inputs = InputEnum;
public:
T[ totalSize ] keys;
ref typeof(this) opAssign( const ref typeof(this) other )
{
for( uint ii = 0; ii < other.keys.length; ++ii )
keys[ ii ] = other.keys[ ii ];
return this;
}
T opIndex( size_t keyCode ) const
{
return keys[ keyCode ];
}
T opIndexAssign( T newValue, size_t keyCode )
{
if( keyCode < totalSize )
keys[ keyCode ] = newValue;
return newValue;
}
Tuple!( InputEnum, T )[] opBinary( string Op : "-" )( const ref typeof(this) other )
{
Tuple!( InputEnum, T )[] differences;
for( uint ii = 0; ii < keys.length; ++ii )
if( this[ ii ] != other[ ii ] )
differences ~= tuple( cast(InputEnum)ii, this[ ii ] );
return differences;
}
void reset()
{
for( uint ii = 0; ii < keys.length; ++ii )
keys[ ii ] = 0;
}
}
// Enums of inputs
enum MouseButtons
{
Left = 0x01, /// Left mouse button
Right = 0x02, /// Right mouse button
Middle = 0x04, /// Middle mouse button
X1 = 0x05, /// X1 mouse button
X2 = 0x06, /// X2 mouse button
END,
}
/// Axes of input for the mouse.
enum MouseAxes
{
ScrollWheel,
XPos,
YPos,
END,
}
/**
* Virtual key codes.
*
* From: http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
*/
enum KeyboardButtons: uint
{
Cancel = 0x03, /// Control-break
//Unused = 0x07,
Backspace = 0x08, /// Backspace key
Tab = 0x09, /// Tab key
//Reserved = 0x0A-0x0B,
Clear = 0x0C, /// Clear key
Return = 0x0D, /// Enter key
//Undefined = 0x0E-0x0F
Shift = 0x10, /// Shift key
Control = 0x11, /// Control key
Alt = 0x12, /// Menu/alt key
Pause = 0x13, /// Pause key
CapsLock = 0x14, /// Capital/Caps Lock key
//Who Cares = 0x15-0x1A,
Escape = 0x1B, /// Escape key
//Who Cares = 0x1C-0x1F
Space = 0x20, /// Space bar
PageUp = 0x21, /// Page Up/Prior key
PageDown = 0x22, /// Page Down/Next key
End = 0x23, /// End key
Home = 0x24, /// Home key
Left = 0x25, /// Left arrow key
Up = 0x26, /// Up arrow key
Right = 0x27, /// Right arrow key
Down = 0x28, /// Down arrow key
Select = 0x29, /// Select key
Print = 0x2A, /// Print key
Execute = 0x2B, /// Execute key
PrintScreen = 0x2C, /// Print Screen/Snapshot key
Insert = 0x2D, /// Insert key
Delete = 0x2E, /// Delete key
Help = 0x2F, /// Help key
Keyboard0 = 0x30, /// 0 key
Keyboard1 = 0x31, /// 1 key
Keyboard2 = 0x32, /// 2 key
Keyboard3 = 0x33, /// 3 key
Keyboard4 = 0x34, /// 4 key
Keyboard5 = 0x35, /// 5 key
Keyboard6 = 0x36, /// 6 key
Keyboard7 = 0x37, /// 7 key
Keyboard8 = 0x38, /// 8 key
Keyboard9 = 0x39, /// 9 key
//Unused = 0x3A-0x40
A = 0x41, /// A key
B = 0x42, /// B key
C = 0x43, /// C key
D = 0x44, /// D key
E = 0x45, /// E key
F = 0x46, /// F key
G = 0x47, /// G key
H = 0x48, /// H key
I = 0x49, /// I key
J = 0x4A, /// J key
K = 0x4B, /// K key
L = 0x4C, /// L key
M = 0x4D, /// M key
N = 0x4E, /// N key
O = 0x4F, /// O key
P = 0x50, /// P key
Q = 0x51, /// Q key
R = 0x52, /// R key
S = 0x53, /// S key
T = 0x54, /// T key
U = 0x55, /// U key
V = 0x56, /// V key
W = 0x57, /// W key
X = 0x58, /// X key
Y = 0x59, /// Y key
Z = 0x5A, /// Z key
WindowsLeft = 0x5B, /// Left windows key
WindowsRight= 0x5C, /// Right windows key
Apps = 0x5D, /// Applications key
//Reserved = 0x5E
Sleep = 0x5F, /// Sleep key
Numpad0 = 0x60, /// 0 key
Numpad1 = 0x61, /// 1 key
Numpad2 = 0x62, /// 2 key
Numpad3 = 0x63, /// 3 key
Numpad4 = 0x64, /// 4 key
Numpad5 = 0x65, /// 5 key
Numpad6 = 0x66, /// 6 key
Numpad7 = 0x67, /// 7 key
Numpad8 = 0x68, /// 8 key
Numpad9 = 0x69, /// 9 key
Multiply = 0x6A, /// Multiply key
Add = 0x6B, /// Addition key
Separator = 0x6C, /// Seperator key
Subtract = 0x6D, /// Subtraction key
Decimal = 0x6E, /// Decimal key
Divide = 0x6F, /// Division key
F1 = 0x70, /// Function 1 key
F2 = 0x71, /// Function 2 key
F3 = 0x72, /// Function 3 key
F4 = 0x73, /// Function 4 key
F5 = 0x74, /// Function 5 key
F6 = 0x75, /// Function 6 key
F7 = 0x76, /// Function 7 key
F8 = 0x77, /// Function 8 key
F9 = 0x78, /// Function 9 key
F10 = 0x79, /// Function 10 key
F11 = 0x7A, /// Function 11 key
F12 = 0x7B, /// Function 12 key
F13 = 0x7C, /// Function 13 key
F14 = 0x7D, /// Function 14 key
F15 = 0x7E, /// Function 15 key
F16 = 0x7F, /// Function 16 key
F17 = 0x80, /// Function 17 key
F18 = 0x81, /// Function 18 key
F19 = 0x82, /// Function 19 key
F20 = 0x83, /// Function 20 key
F21 = 0x84, /// Function 21 key
F22 = 0x85, /// Function 22 key
F23 = 0x86, /// Function 23 key
F24 = 0x87, /// Function 24 key
//Unused = 0x88-0x8F,
NumLock = 0x90, /// Num Lock key
ScrollLock = 0x91, /// Scroll Lock key
//OEM = 0x92-0x96,
//Unused = 0x97-0x9F,
ShiftLeft = 0xA0, /// Left shift key
ShiftRight = 0xA1, /// Right shift key
ControlLeft = 0xA2, /// Left control key
ControlRight= 0xA3, /// Right control key
AltLeft = 0xA4, /// Left Alt key
AltRight = 0xA5, /// Right Alt key
END,
}
unittest
{
import std.stdio;
writeln( "Dash Input isKeyUp unittest" );
Config.initialize();
Input.initialize();
Keyboard.setButtonState( Keyboard.Buttons.Space, true );
Keyboard.update();
Keyboard.setButtonState( Keyboard.Buttons.Space, false );
Keyboard.update();
assert( Keyboard.isButtonUp( Keyboard.Buttons.Space, true ) );
assert( Keyboard.isButtonUp( Keyboard.Buttons.Space, false ) );
Keyboard.update();
assert( !Keyboard.isButtonUp( Keyboard.Buttons.Space, true ) );
assert( Keyboard.isButtonUp( Keyboard.Buttons.Space, false ) );
}
unittest
{
import std.stdio;
writeln( "Dash Input addKeyEvent unittest" );
Config.initialize();
Input.initialize();
bool keyDown;
Keyboard.addButtonEvent( Keyboard.Buttons.Space, ( keyCode, newState )
{
keyDown = newState;
} );
Keyboard.setButtonState( Keyboard.Buttons.Space, true );
Input.update();
assert( keyDown );
Keyboard.setButtonState( Keyboard.Buttons.Space, false );
Input.update();
assert( !keyDown );
}
unittest
{
import std.stdio;
writeln( "Dash Input isKeyDown unittest" );
Config.initialize();
Input.initialize();
Keyboard.setButtonState( Keyboard.Buttons.Space, true );
Input.update();
assert( Keyboard.isButtonDown( Keyboard.Buttons.Space, true ) );
assert( Keyboard.isButtonDown( Keyboard.Buttons.Space, false ) );
Input.update();
assert( !Keyboard.isButtonDown( Keyboard.Buttons.Space, true ) );
assert( Keyboard.isButtonDown( Keyboard.Buttons.Space, false ) );
}
|
D
|
module UnrealScript.Engine.MaterialExpressionDepthBiasedAlpha;
import ScriptClasses;
import UnrealScript.Helpers;
import UnrealScript.Engine.MaterialExpression;
extern(C++) interface MaterialExpressionDepthBiasedAlpha : MaterialExpression
{
public extern(D):
private static __gshared ScriptClass mStaticClass;
@property final static ScriptClass StaticClass() { mixin(MGSCC("Class Engine.MaterialExpressionDepthBiasedAlpha")); }
private static __gshared MaterialExpressionDepthBiasedAlpha mDefaultProperties;
@property final static MaterialExpressionDepthBiasedAlpha DefaultProperties() { mixin(MGDPC("MaterialExpressionDepthBiasedAlpha", "MaterialExpressionDepthBiasedAlpha Engine.Default__MaterialExpressionDepthBiasedAlpha")); }
@property final
{
auto ref
{
MaterialExpression.ExpressionInput Bias() { mixin(MGPC("MaterialExpression.ExpressionInput", 144)); }
MaterialExpression.ExpressionInput Alpha() { mixin(MGPC("MaterialExpression.ExpressionInput", 116)); }
float BiasScale() { mixin(MGPC("float", 112)); }
}
bool bNormalize() { mixin(MGBPC(108, 0x1)); }
bool bNormalize(bool val) { mixin(MSBPC(108, 0x1)); }
}
}
|
D
|
#objdump: -s -j .text
#name: PowerPC .machine test
#notarget: *-*-pe *-*-winnt* *-*-cygwin*
.*
Contents of section \.text:
0000 (7c11eba6|a6eb117c) (7c100ba6|a60b107c) (4c000066|6600004c) (00000200|00020000) .*
0010 (44000002|02000044) (4c0000a4|a400004c) (7c000224|2402007c) (4e800020|2000804e) .*
0020 (7c11eba6|a6eb117c) .*
|
D
|
/**
* This is a low-level messaging API upon which more structured or restrictive
* APIs may be built. The general idea is that every messageable entity is
* represented by a common handle type called a Tid, which allows messages to
* be sent to logical threads that are executing in both the current process
* and in external processes using the same interface. This is an important
* aspect of scalability because it allows the components of a program to be
* spread across available resources with few to no changes to the actual
* implementation.
*
* A logical thread is an execution context that has its own stack and which
* runs asynchronously to other logical threads. These may be preemptively
* scheduled kernel threads, fibers (cooperative user-space threads), or some
* other concept with similar behavior.
*
* The type of concurrency used when logical threads are created is determined
* by the Scheduler selected at initialization time. The default behavior is
* currently to create a new kernel thread per call to spawn, but other
* schedulers are available that multiplex fibers across the main thread or
* use some combination of the two approaches.
*
* Synposis:
* ---
* import std.stdio;
* import std.concurrency;
*
* void spawnedFunc(Tid ownerTid)
* {
* // Receive a message from the owner thread.
* receive(
* (int i) { writeln("Received the number ", i);}
* );
*
* // Send a message back to the owner thread
* // indicating success.
* send(ownerTid, true);
* }
*
* void main()
* {
* // Start spawnedFunc in a new thread.
* auto childTid = spawn(&spawnedFunc, thisTid);
*
* // Send the number 42 to this new thread.
* send(childTid, 42);
*
* // Receive the result code.
* auto wasSuccessful = receiveOnly!(bool);
* assert(wasSuccessful);
* writeln("Successfully printed number.");
* }
* ---
*
* Copyright: Copyright Sean Kelly 2009 - 2014.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
* Authors: Sean Kelly, Alex Rønne Petersen
* Source: $(PHOBOSSRC std/_concurrency.d)
*/
/* Copyright Sean Kelly 2009 - 2014.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module std.concurrency;
public
{
import std.variant;
}
private
{
import core.thread;
import core.sync.mutex;
import core.sync.condition;
import std.algorithm;
import std.datetime;
import std.exception;
import std.range;
import std.string;
import std.traits;
import std.typecons;
import std.typetuple;
template hasLocalAliasing(T...)
{
static if( !T.length )
enum hasLocalAliasing = false;
else
enum hasLocalAliasing = (std.traits.hasLocalAliasing!(T[0]) && !is(T[0] == Tid)) ||
std.concurrency.hasLocalAliasing!(T[1 .. $]);
}
enum MsgType
{
standard,
priority,
linkDead,
}
struct Message
{
MsgType type;
Variant data;
this(T...)( MsgType t, T vals )
if( T.length < 1 )
{
static assert( false, "messages must contain at least one item" );
}
this(T...)( MsgType t, T vals )
if( T.length == 1 )
{
type = t;
data = vals[0];
}
this(T...)( MsgType t, T vals )
if( T.length > 1 )
{
type = t;
data = Tuple!(T)( vals );
}
@property auto convertsTo(T...)()
{
static if( T.length == 1 )
return is( T[0] == Variant ) ||
data.convertsTo!(T);
else
return data.convertsTo!(Tuple!(T));
}
@property auto get(T...)()
{
static if( T.length == 1 )
{
static if( is( T[0] == Variant ) )
return data;
else
return data.get!(T);
}
else
{
return data.get!(Tuple!(T));
}
}
auto map(Op)( Op op )
{
alias Args = ParameterTypeTuple!(Op);
static if( Args.length == 1 )
{
static if( is( Args[0] == Variant ) )
return op( data );
else
return op( data.get!(Args) );
}
else
{
return op( data.get!(Tuple!(Args)).expand );
}
}
}
void checkops(T...)( T ops )
{
foreach( i, t1; T )
{
static assert( isFunctionPointer!t1 || isDelegate!t1 );
alias a1 = ParameterTypeTuple!(t1);
alias r1 = ReturnType!(t1);
static if( i < T.length - 1 && is( r1 == void ) )
{
static assert( a1.length != 1 || !is( a1[0] == Variant ),
"function with arguments " ~ a1.stringof ~
" occludes successive function" );
foreach( t2; T[i+1 .. $] )
{
static assert( isFunctionPointer!t2 || isDelegate!t2 );
alias a2 = ParameterTypeTuple!(t2);
static assert( !is( a1 == a2 ),
"function with arguments " ~ a1.stringof ~
" occludes successive function" );
}
}
}
}
@property ref ThreadInfo thisInfo()
{
if( scheduler is null )
return ThreadInfo.thisInfo;
return scheduler.thisInfo;
}
}
static ~this()
{
thisInfo.cleanup();
}
//////////////////////////////////////////////////////////////////////////////
// Exceptions
//////////////////////////////////////////////////////////////////////////////
/**
* Thrown on calls to $(D receiveOnly) if a message other than the type
* the receiving thread expected is sent.
*/
class MessageMismatch : Exception
{
this( string msg = "Unexpected message type" )
{
super( msg );
}
}
/**
* Thrown on calls to $(D receive) if the thread that spawned the receiving
* thread has terminated and no more messages exist.
*/
class OwnerTerminated : Exception
{
this( Tid t, string msg = "Owner terminated" )
{
super( msg );
tid = t;
}
Tid tid;
}
/**
* Thrown if a linked thread has terminated.
*/
class LinkTerminated : Exception
{
this( Tid t, string msg = "Link terminated" )
{
super( msg );
tid = t;
}
Tid tid;
}
/**
* Thrown if a message was sent to a thread via
* $(XREF concurrency, prioritySend) and the receiver does not have a handler
* for a message of this type.
*/
class PriorityMessageException : Exception
{
this( Variant vals )
{
super( "Priority message" );
message = vals;
}
/**
* The message that was sent.
*/
Variant message;
}
/**
* Thrown on mailbox crowding if the mailbox is configured with
* $(D OnCrowding.throwException).
*/
class MailboxFull : Exception
{
this( Tid t, string msg = "Mailbox full" )
{
super( msg );
tid = t;
}
Tid tid;
}
/**
* Thrown when a Tid is missing, e.g. when $(D ownerTid) doesn't
* find an owner thread.
*/
class TidMissingException : Exception
{
this(string msg, string file = __FILE__, size_t line = __LINE__)
{
super(msg, file, line);
}
}
//////////////////////////////////////////////////////////////////////////////
// Thread ID
//////////////////////////////////////////////////////////////////////////////
/**
* An opaque type used to represent a logical thread.
*/
struct Tid
{
private:
this( MessageBox m )
{
mbox = m;
}
MessageBox mbox;
}
/**
* Returns the caller's Tid.
*/
@property Tid thisTid()
{
if( thisInfo.ident != Tid.init )
return thisInfo.ident;
thisInfo.ident = Tid( new MessageBox );
return thisInfo.ident;
}
/**
* Return the Tid of the thread which spawned the caller's thread.
*
* Throws: A $(D TidMissingException) exception if
* there is no owner thread.
*/
@property Tid ownerTid()
{
enforce!TidMissingException(thisInfo.owner.mbox !is null,
"Error: Thread has no owner thread.");
return thisInfo.owner;
}
unittest
{
static void fun()
{
string res = receiveOnly!string();
assert(res == "Main calling");
ownerTid.send("Child responding");
}
assertThrown!TidMissingException(ownerTid);
auto child = spawn(&fun);
child.send("Main calling");
string res = receiveOnly!string();
assert(res == "Child responding");
}
//////////////////////////////////////////////////////////////////////////////
// Thread Creation
//////////////////////////////////////////////////////////////////////////////
private template isSpawnable(F, T...)
{
template isParamsImplicitlyConvertible(F1, F2, int i=0)
{
alias param1 = ParameterTypeTuple!F1;
alias param2 = ParameterTypeTuple!F2;
static if (param1.length != param2.length)
enum isParamsImplicitlyConvertible = false;
else static if (param1.length == i)
enum isParamsImplicitlyConvertible = true;
else static if (isImplicitlyConvertible!(param2[i], param1[i]))
enum isParamsImplicitlyConvertible = isParamsImplicitlyConvertible!(F1, F2, i+1);
else
enum isParamsImplicitlyConvertible = false;
}
enum isSpawnable = isCallable!F
&& is(ReturnType!F == void)
&& isParamsImplicitlyConvertible!(F, void function(T))
&& ( isFunctionPointer!F
|| !hasUnsharedAliasing!F);
}
/**
* Starts fn(args) in a new logical thread.
*
* Executes the supplied function in a new logical thread represented by
* $(D Tid). The calling thread is designated as the owner of the new thread.
* When the owner thread terminates an $(D OwnerTerminated) message will be
* sent to the new thread, causing an $(D OwnerTerminated) exception to be
* thrown on $(D receive()).
*
* Params:
* fn = The function to execute.
* args = Arguments to the function.
*
* Returns:
* A Tid representing the new logical thread.
*
* Notes:
* $(D args) must not have unshared aliasing. In other words, all arguments
* to $(D fn) must either be $(D shared) or $(D immutable) or have no
* pointer indirection. This is necessary for enforcing isolation among
* threads.
*
* Example:
* ---
* import std.stdio, std.concurrency;
*
* void f1(string str)
* {
* writeln(str);
* }
*
* void f2(char[] str)
* {
* writeln(str);
* }
*
* void main()
* {
* auto str = "Hello, world";
*
* // Works: string is immutable.
* auto tid1 = spawn(&f1, str);
*
* // Fails: char[] has mutable aliasing.
* auto tid2 = spawn(&f2, str.dup);
* }
* ---
*/
Tid spawn(F, T...)( F fn, T args )
if ( isSpawnable!(F, T) )
{
static assert( !hasLocalAliasing!(T),
"Aliases to mutable thread-local data not allowed." );
return _spawn( false, fn, args );
}
/**
* Starts fn(args) in a logical thread and will receive a LinkTerminated
* message when the operation terminates.
*
* Executes the supplied function in a new logical thread represented by
* Tid. This new thread is linked to the calling thread so that if either
* it or the calling thread terminates a LinkTerminated message will be sent
* to the other, causing a LinkTerminated exception to be thrown on receive().
* The owner relationship from spawn() is preserved as well, so if the link
* between threads is broken, owner termination will still result in an
* OwnerTerminated exception to be thrown on receive().
*
* Params:
* fn = The function to execute.
* args = Arguments to the function.
*
* Returns:
* A Tid representing the new thread.
*/
Tid spawnLinked(F, T...)( F fn, T args )
if ( isSpawnable!(F, T) )
{
static assert( !hasLocalAliasing!(T),
"Aliases to mutable thread-local data not allowed." );
return _spawn( true, fn, args );
}
/*
*
*/
private Tid _spawn(F, T...)( bool linked, F fn, T args )
if ( isSpawnable!(F, T) )
{
// TODO: MessageList and &exec should be shared.
auto spawnTid = Tid( new MessageBox );
auto ownerTid = thisTid;
void exec()
{
thisInfo.ident = spawnTid;
thisInfo.owner = ownerTid;
fn( args );
}
// TODO: MessageList and &exec should be shared.
if( scheduler !is null )
scheduler.spawn( &exec );
else
{
auto t = new Thread( &exec );
t.start();
}
thisInfo.links[spawnTid] = linked;
return spawnTid;
}
unittest
{
void function() fn1;
void function(int) fn2;
static assert( __traits(compiles, spawn(fn1)));
static assert( __traits(compiles, spawn(fn2, 2)));
static assert(!__traits(compiles, spawn(fn1, 1)));
static assert(!__traits(compiles, spawn(fn2)));
void delegate(int) shared dg1;
shared(void delegate(int)) dg2;
shared(void delegate(long) shared) dg3;
shared(void delegate(real, int , long) shared) dg4;
void delegate(int) immutable dg5;
void delegate(int) dg6;
static assert( __traits(compiles, spawn(dg1, 1)));
static assert( __traits(compiles, spawn(dg2, 2)));
static assert( __traits(compiles, spawn(dg3, 3)));
static assert( __traits(compiles, spawn(dg4, 4, 4, 4)));
static assert( __traits(compiles, spawn(dg5, 5)));
static assert(!__traits(compiles, spawn(dg6, 6)));
auto callable1 = new class{ void opCall(int) shared {} };
auto callable2 = cast(shared)new class{ void opCall(int) shared {} };
auto callable3 = new class{ void opCall(int) immutable {} };
auto callable4 = cast(immutable)new class{ void opCall(int) immutable {} };
auto callable5 = new class{ void opCall(int) {} };
auto callable6 = cast(shared)new class{ void opCall(int) immutable {} };
auto callable7 = cast(immutable)new class{ void opCall(int) shared {} };
auto callable8 = cast(shared)new class{ void opCall(int) const shared {} };
auto callable9 = cast(const shared)new class{ void opCall(int) shared {} };
auto callable10 = cast(const shared)new class{ void opCall(int) const shared {} };
auto callable11 = cast(immutable)new class{ void opCall(int) const shared {} };
static assert(!__traits(compiles, spawn(callable1, 1)));
static assert( __traits(compiles, spawn(callable2, 2)));
static assert(!__traits(compiles, spawn(callable3, 3)));
static assert( __traits(compiles, spawn(callable4, 4)));
static assert(!__traits(compiles, spawn(callable5, 5)));
static assert(!__traits(compiles, spawn(callable6, 6)));
static assert(!__traits(compiles, spawn(callable7, 7)));
static assert( __traits(compiles, spawn(callable8, 8)));
static assert(!__traits(compiles, spawn(callable9, 9)));
static assert( __traits(compiles, spawn(callable10, 10)));
static assert( __traits(compiles, spawn(callable11, 11)));
}
//////////////////////////////////////////////////////////////////////////////
// Sending and Receiving Messages
//////////////////////////////////////////////////////////////////////////////
/**
* Places the values as a message at the back of tid's message queue.
*
* Sends the supplied value to the thread represented by tid. As with
* $(XREF concurrency, spawn), $(D T) must not have unshared aliasing.
*/
void send(T...)( Tid tid, T vals )
{
static assert( !hasLocalAliasing!(T),
"Aliases to mutable thread-local data not allowed." );
_send( tid, vals );
}
/**
* Places the values as a message on the front of tid's message queue.
*
* Send a message to $(D tid) but place it at the front of $(D tid)'s message
* queue instead of at the back. This function is typically used for
* out-of-band communication, to signal exceptional conditions, etc.
*/
void prioritySend(T...)( Tid tid, T vals )
{
static assert( !hasLocalAliasing!(T),
"Aliases to mutable thread-local data not allowed." );
_send( MsgType.priority, tid, vals );
}
/*
* ditto
*/
private void _send(T...)( Tid tid, T vals )
{
_send( MsgType.standard, tid, vals );
}
/*
* Implementation of send. This allows parameter checking to be different for
* both Tid.send() and .send().
*/
private void _send(T...)( MsgType type, Tid tid, T vals )
{
auto msg = Message( type, vals );
tid.mbox.put( msg );
}
/**
* Receives a message from another thread.
*
* Receive a message from another thread, or block if no messages of the
* specified types are available. This function works by pattern matching
* a message against a set of delegates and executing the first match found.
*
* If a delegate that accepts a $(XREF variant, Variant) is included as
* the last argument to $(D receive), it will match any message that was not
* matched by an earlier delegate. If more than one argument is sent,
* the $(D Variant) will contain a $(XREF typecons, Tuple) of all values
* sent.
*
* Example:
* ---
* import std.stdio;
* import std.variant;
* import std.concurrency;
*
* void spawnedFunction()
* {
* receive(
* (int i) { writeln("Received an int."); },
* (float f) { writeln("Received a float."); },
* (Variant v) { writeln("Received some other type."); }
* );
* }
*
* void main()
* {
* auto tid = spawn(&spawnedFunction);
* send(tid, 42);
* }
* ---
*/
void receive(T...)( T ops )
in
{
assert(thisInfo.ident.mbox !is null,
"Cannot receive a message until a thread was spawned "
"or thisTid was passed to a running thread.");
}
body
{
checkops( ops );
thisInfo.ident.mbox.get( ops );
}
unittest
{
assert( __traits( compiles,
{
receive( (Variant x) {} );
receive( (int x) {}, (Variant x) {} );
} ) );
assert( !__traits( compiles,
{
receive( (Variant x) {}, (int x) {} );
} ) );
assert( !__traits( compiles,
{
receive( (int x) {}, (int x) {} );
} ) );
}
// Make sure receive() works with free functions as well.
version (unittest)
{
private void receiveFunction(int x) {}
}
unittest
{
assert( __traits( compiles,
{
receive( &receiveFunction );
receive( &receiveFunction, (Variant x) {} );
} ) );
}
private template receiveOnlyRet(T...)
{
static if( T.length == 1 )
alias receiveOnlyRet = T[0];
else
alias receiveOnlyRet = Tuple!(T);
}
/**
* Receives only messages with arguments of types $(D T).
*
* Throws: $(D MessageMismatch) if a message of types other than $(D T)
* is received.
*
* Returns: The received message. If $(D T.length) is greater than one,
* the message will be packed into a $(XREF typecons, Tuple).
*
* Example:
* ---
* import std.concurrency;
*
* void spawnedFunc()
* {
* auto msg = receiveOnly!(int, string)();
* assert(msg[0] == 42);
* assert(msg[1] == "42");
* }
*
* void main()
* {
* auto tid = spawn(&spawnedFunc);
* send(tid, 42, "42");
* }
* ---
*/
receiveOnlyRet!(T) receiveOnly(T...)()
in
{
assert(thisInfo.ident.mbox !is null,
"Cannot receive a message until a thread was spawned "
"or thisTid was passed to a running thread.");
}
body
{
Tuple!(T) ret;
thisInfo.ident.mbox.get(
( T val )
{
static if( T.length )
ret.field = val;
},
( LinkTerminated e )
{
throw e;
},
( OwnerTerminated e )
{
throw e;
},
( Variant val )
{
static if (T.length > 1)
string exp = T.stringof;
else
string exp = T[0].stringof;
throw new MessageMismatch(
format("Unexpected message type: expected '%s', got '%s'",
exp, val.type.toString()));
} );
static if( T.length == 1 )
return ret[0];
else
return ret;
}
unittest
{
static void t1(Tid mainTid)
{
try
{
receiveOnly!string();
mainTid.send("");
}
catch (Throwable th)
{
mainTid.send(th.msg);
}
}
auto tid = spawn(&t1, thisTid);
tid.send(1);
string result = receiveOnly!string();
assert(result == "Unexpected message type: expected 'string', got 'int'");
}
/**
* Tries to receive but will give up if no matches arrive within duration.
*
* Same as $(D receive) except that rather than wait forever for a message,
* it waits until either it receives a message or the given
* $(CXREF time, Duration) has passed. It returns $(D true) if it received a
* message and $(D false) if it timed out waiting for one.
*/
bool receiveTimeout(T...)( Duration duration, T ops )
in
{
assert(thisInfo.ident.mbox !is null,
"Cannot receive a message until a thread was spawned "
"or thisTid was passed to a running thread.");
}
body
{
checkops( ops );
return thisInfo.ident.mbox.get( duration, ops );
}
unittest
{
assert( __traits( compiles,
{
receiveTimeout( msecs(0), (Variant x) {} );
receiveTimeout( msecs(0), (int x) {}, (Variant x) {} );
} ) );
assert( !__traits( compiles,
{
receiveTimeout( msecs(0), (Variant x) {}, (int x) {} );
} ) );
assert( !__traits( compiles,
{
receiveTimeout( msecs(0), (int x) {}, (int x) {} );
} ) );
assert( __traits( compiles,
{
receiveTimeout( msecs(10), (int x) {}, (Variant x) {} );
} ) );
}
//////////////////////////////////////////////////////////////////////////////
// MessageBox Limits
//////////////////////////////////////////////////////////////////////////////
/**
* These behaviors may be specified when a mailbox is full.
*/
enum OnCrowding
{
block, /// Wait until room is available.
throwException, /// Throw a MailboxFull exception.
ignore /// Abort the send and return.
}
private
{
bool onCrowdingBlock( Tid tid )
{
return true;
}
bool onCrowdingThrow( Tid tid )
{
throw new MailboxFull( tid );
}
bool onCrowdingIgnore( Tid tid )
{
return false;
}
}
/**
* Sets a maximum mailbox size.
*
* Sets a limit on the maximum number of user messages allowed in the mailbox.
* If this limit is reached, the caller attempting to add a new message will
* execute the behavior specified by doThis. If messages is zero, the mailbox
* is unbounded.
*
* Params:
* tid = The Tid of the thread for which this limit should be set.
* messages = The maximum number of messages or zero if no limit.
* doThis = The behavior executed when a message is sent to a full
* mailbox.
*/
void setMaxMailboxSize( Tid tid, size_t messages, OnCrowding doThis )
{
final switch( doThis )
{
case OnCrowding.block:
return tid.mbox.setMaxMsgs( messages, &onCrowdingBlock );
case OnCrowding.throwException:
return tid.mbox.setMaxMsgs( messages, &onCrowdingThrow );
case OnCrowding.ignore:
return tid.mbox.setMaxMsgs( messages, &onCrowdingIgnore );
}
}
/**
* Sets a maximum mailbox size.
*
* Sets a limit on the maximum number of user messages allowed in the mailbox.
* If this limit is reached, the caller attempting to add a new message will
* execute onCrowdingDoThis. If messages is zero, the mailbox is unbounded.
*
* Params:
* tid = The Tid of the thread for which this limit should be set.
* messages = The maximum number of messages or zero if no limit.
* onCrowdingDoThis = The routine called when a message is sent to a full
* mailbox.
*/
void setMaxMailboxSize( Tid tid, size_t messages, bool function(Tid) onCrowdingDoThis )
{
tid.mbox.setMaxMsgs( messages, onCrowdingDoThis );
}
//////////////////////////////////////////////////////////////////////////////
// Name Registration
//////////////////////////////////////////////////////////////////////////////
private
{
__gshared Tid[string] tidByName;
__gshared string[][Tid] namesByTid;
__gshared Mutex registryLock;
}
shared static this()
{
registryLock = new Mutex;
}
private void unregisterMe()
{
auto me = thisTid;
synchronized( registryLock )
{
if( auto allNames = me in namesByTid )
{
foreach( name; *allNames )
tidByName.remove( name );
namesByTid.remove( me );
}
}
}
/**
* Associates name with tid.
*
* Associates name with tid in a process-local map. When the thread
* represented by tid terminates, any names associated with it will be
* automatically unregistered.
*
* Params:
* name = The name to associate with tid.
* tid = The tid register by name.
*
* Returns:
* true if the name is available and tid is not known to represent a
* defunct thread.
*/
bool register( string name, Tid tid )
{
synchronized( registryLock )
{
if( name in tidByName )
return false;
if( tid.mbox.isClosed )
return false;
namesByTid[tid] ~= name;
tidByName[name] = tid;
return true;
}
}
/**
* Removes the registered name associated with a tid.
*
* Params:
* name = The name to unregister.
*
* Returns:
* true if the name is registered, false if not.
*/
bool unregister( string name )
{
synchronized( registryLock )
{
if( auto tid = name in tidByName )
{
auto allNames = *tid in namesByTid;
auto pos = countUntil( *allNames, name );
remove!(SwapStrategy.unstable)( *allNames, pos );
tidByName.remove( name );
return true;
}
return false;
}
}
/**
* Gets the Tid associated with name.
*
* Params:
* name = The name to locate within the registry.
*
* Returns:
* The associated Tid or Tid.init if name is not registered.
*/
Tid locate( string name )
{
synchronized( registryLock )
{
if( auto tid = name in tidByName )
return *tid;
return Tid.init;
}
}
//////////////////////////////////////////////////////////////////////////////
// Scheduler
//////////////////////////////////////////////////////////////////////////////
/**
* Encapsulates all implementation-level data needed for scheduling.
*
* When definining a Scheduler, an instance of this struct must be associated
* with each logical thread. It contains all implementation-level information
* needed by the internal API.
*/
struct ThreadInfo
{
Tid ident;
bool[Tid] links;
Tid owner;
/**
* Gets a thread-local instance of ThreadInfo.
*
* Gets a thread-local instance of ThreadInfo, which should be used as the
* default instance when info is requested for a thread not created by the
* Scheduler.
*/
static @property ref thisInfo()
{
static ThreadInfo val;
return val;
}
/**
* Cleans up this ThreadInfo.
*
* This must be called when a scheduled thread terminates. It tears down
* the messaging system for the thread and notifies interested parties of
* the thread's termination.
*/
void cleanup()
{
if( ident.mbox !is null )
ident.mbox.close();
foreach( tid; links.keys )
_send( MsgType.linkDead, tid, ident );
if( owner != Tid.init )
_send( MsgType.linkDead, owner, ident );
unregisterMe(); // clean up registry entries
}
}
/**
* A Scheduler controls how threading is performed by spawn.
*
* Implementing a Scheduler allows the concurrency mechanism used by this
* module to be customized according to different needs. By default, a call
* to spawn will create a new kernel thread that executes the supplied routine
* and terminates when finished. But it is possible to create Schedulers that
* reuse threads, that multiplex Fibers (coroutines) across a single thread,
* or any number of other approaches. By making the choice of Scheduler a
* user-level option, std.concurrency may be used for far more types of
* application than if this behavior were predefined.
*
* Example:
* ---
* import std.concurrency;
* import std.stdio;
*
* void main()
* {
* scheduler = new FiberScheduler;
* scheduler.start(
* {
* writeln("the rest of main goes here");
* });
* }
* ---
*
* Some schedulers have a dispatching loop that must run if they are to work
* properly, so for the sake of consistency, when using a scheduler, start()
* must be called within main(). This yields control to the scheduler and
* will ensure that any spawned threads are executed in an expected manner.
*/
interface Scheduler
{
/**
* Spawns the supplied op and starts the Scheduler.
*
* This is intended to be called at the start of the program to yield all
* scheduling to the active Scheduler instance. This is necessary for
* schedulers that explicitly dispatch threads rather than simply relying
* on the operating system to do so, and so start should always be called
* within main() to begin normal program execution.
*
* Params:
* op = A wrapper for whatever the main thread would have done in the
* absence of a custom scheduler. It will be automatically executed
* via a call to spawn by the Scheduler.
*/
void start( void delegate() op );
/**
* Assigns a logical thread to execute the supplied op.
*
* This routine is called by spawn. It is expected to instantiate a new
* logical thread and run the supplied operation. This thread must call
* thisInfo.cleanup() when the thread terminates if the scheduled thread
* is not a kernel thread--all kernel threads will have their ThreadInfo
* cleaned up automatically by a thread-local destructor.
*
* Params:
* op = The function to execute. This may be the actual function passed
* by the user to spawn itself, or may be a wrapper function.
*/
void spawn( void delegate() op );
/**
* Yields execution to another logical thread.
*
* This routine is called at various points within concurrency-aware APIs
* to provide a scheduler a chance to yield execution when using some sort
* of cooperative multithreading model. If this is not appropriate, such
* as when each logical thread is backed by a dedicated kernel thread,
* this routine may be a no-op.
*/
void yield();
/**
* Returns an appropriate ThreadInfo instance.
*
* Returns an instance of ThreadInfo specific to the logical thread that
* is calling this routine or, if the calling thread was not create by
* this scheduler, returns ThreadInfo.thisInfo instead.
*/
@property ref ThreadInfo thisInfo();
/**
* Creates a Condition varialbe analog for signaling.
*
* Creates a new Condition variable analog which is used to check for and
* to signal the addition of messages to a thread's message queue. Like
* yield, some schedulers may need to define custom behavior so that calls
* to Condition.wait() yield to another thread when no new messages are
* available instead of blocking.
*
* Params:
* m = The Mutex that will be associated with this condition. It will be
* locked prior to any operation on the condition, and so in some
* cases a Scheduler may need to hold this reference and unlock the
* mutex before yielding execution to another logical thread.
*/
Condition newCondition( Mutex m );
}
/**
* An example Scheduler using kernel threads.
*
* This is an example Scheduler that mirrors the default scheduling behavior
* of creating one kernel thread per call to spawn. It is fully functional
* and may be instantiated and used, but is not a necessary part of the
* default functioning of this module.
*/
class ThreadScheduler :
Scheduler
{
/**
* This simply runs op directly, since no real scheduling is needed by
* this approach.
*/
void start( void delegate() op )
{
op();
}
/**
* Creates a new kernel thread and assigns it to run the supplied op.
*/
void spawn( void delegate() op )
{
auto t = new Thread( op );
t.start();
}
/**
* This scheduler does no explicit multiplexing, so this is a no-op.
*/
void yield()
{
// no explicit yield needed
}
/**
* Returns ThreadInfo.thisInfo, since it is a thread-local instance of
* ThreadInfo, which is the correct behavior for this scheduler.
*/
@property ref ThreadInfo thisInfo()
{
return ThreadInfo.thisInfo;
}
/**
* Creates a new Condition variable. No custom behavior is needed here.
*/
Condition newCondition( Mutex m )
{
return new Condition( m );
}
}
/**
* An example Scheduler using Fibers.
*
* This is an example scheduler that creates a new Fiber per call to spawn
* and multiplexes the execution of all fibers within the main thread.
*/
class FiberScheduler :
Scheduler
{
/**
* This creates a new Fiber for the supplied op and then starts the
* dispatcher.
*/
void start( void delegate() op )
{
create( op );
dispatch();
}
/**
* This created a new Fiber for the supplied op and adds it to the
* dispatch list.
*/
void spawn( void delegate() op )
{
create( op );
yield();
}
/**
* If the caller is a scheduled Fiber, this yields execution to another
* scheduled Fiber.
*/
void yield()
{
// NOTE: It's possible that we should test whether the calling Fiber
// is an InfoFiber before yielding, but I think it's reasonable
// that any (non-Generator) fiber should yield here.
if(Fiber.getThis())
Fiber.yield();
}
/**
* Returns an appropriate ThreadInfo instance.
*
* Returns a ThreadInfo instance specific to the calling Fiber if the
* Fiber was created by this dispatcher, otherwise it returns
* ThreadInfo.thisInfo.
*/
@property ref ThreadInfo thisInfo()
{
auto f = cast(InfoFiber) Fiber.getThis();
if( f !is null )
return f.info;
return ThreadInfo.thisInfo;
}
/**
* Returns a Condition analog that yields when wait or notify is called.
*/
Condition newCondition( Mutex m )
{
return new FiberCondition( m );
}
private:
static class InfoFiber :
Fiber
{
ThreadInfo info;
this( void delegate() op )
{
super( op );
}
}
class FiberCondition :
Condition
{
this( Mutex m )
{
super(m);
notified = false;
}
override void wait()
{
switchContext();
}
override bool wait( Duration period )
{
scope(exit) notified = false;
for( auto limit = Clock.currSystemTick() + period;
!notified && !period.isNegative;
period = limit - Clock.currSystemTick() )
{
yield();
}
return notified;
}
override void notify()
{
notified = true;
switchContext();
}
override void notifyAll()
{
notified = true;
switchContext();
}
private:
final void switchContext()
{
mutex.unlock();
scope(exit) mutex.lock();
yield();
}
private bool notified;
}
private:
final void dispatch()
{
import std.algorithm : remove;
while( m_fibers.length > 0 )
{
auto t = m_fibers[m_pos].call( false );
if (t !is null && !(cast(OwnerTerminated) t))
throw t;
if( m_fibers[m_pos].state() == Fiber.State.TERM )
{
if( m_pos >= (m_fibers = remove( m_fibers, m_pos )).length )
m_pos = 0;
}
else if( m_pos++ >= m_fibers.length - 1 )
{
m_pos = 0;
}
}
}
final void create( void delegate() op )
{
void wrap()
{
scope(exit)
{
thisInfo.cleanup();
}
op();
}
m_fibers ~= new InfoFiber( &wrap );
}
private:
Fiber[] m_fibers;
size_t m_pos;
}
/**
* Sets the Scheduler behavior within the program.
*
* This variable sets the Scheduler behavior within this program. Typically,
* when setting a Scheduler, scheduler.start() should be called in main. This
* routine will not return until program execution is complete.
*/
__gshared Scheduler scheduler;
//////////////////////////////////////////////////////////////////////////////
// Generator
//////////////////////////////////////////////////////////////////////////////
/**
* If the caller is a Fiber and is not a Generator, this function will call
* scheduler.yield() or Fiber.yield(), as appropriate.
*/
void yield()
{
auto fiber = Fiber.getThis();
if (!(cast(IsGenerator) fiber))
{
if (scheduler is null)
{
if (fiber)
return Fiber.yield();
}
else scheduler.yield();
}
}
/// Used to determine whether a Generator is running.
private interface IsGenerator {}
/**
* A Generator is a Fiber that periodically returns values of type T to the
* caller via yield. This is represented as an InputRange.
*
* Example:
* ---
* import std.concurrency;
* import std.stdio;
*
*
* void main()
* {
* auto tid = spawn(
* {
* while (true)
* {
* writeln(receiveOnly!int());
* }
* });
*
* auto r = new Generator!int(
* {
* foreach (i; 1 .. 10)
* yield(i);
* });
*
* foreach (e; r)
* {
* tid.send(e);
* }
* }
* ---
*/
class Generator(T) :
Fiber, IsGenerator
{
/**
* Initializes a generator object which is associated with a static
* D function. The function will be called once to prepare the range
* for iteration.
*
* Params:
* fn = The fiber function.
*
* In:
* fn must not be null.
*/
this(void function() fn)
{
super(fn);
call();
}
/**
* Initializes a generator object which is associated with a static
* D function. The function will be called once to prepare the range
* for iteration.
*
* Params:
* fn = The fiber function.
* sz = The stack size for this fiber.
*
* In:
* fn must not be null.
*/
this(void function() fn, size_t sz)
{
super(fn, sz);
call();
}
/**
* Initializes a generator object which is associated with a dynamic
* D function. The function will be called once to prepare the range
* for iteration.
*
* Params:
* dg = The fiber function.
*
* In:
* dg must not be null.
*/
this(void delegate() dg)
{
super(dg);
call();
}
/**
* Initializes a generator object which is associated with a dynamic
* D function. The function will be called once to prepare the range
* for iteration.
*
* Params:
* dg = The fiber function.
* sz = The stack size for this fiber.
*
* In:
* dg must not be null.
*/
this(void delegate() dg, size_t sz)
{
super(dg, sz);
call();
}
/**
* Returns true if the generator is empty.
*/
final bool empty() @property
{
return m_value is null || state() == State.TERM;
}
/**
* Obtains the next value from the underlying function.
*/
final void popFront()
{
call();
}
/**
* Returns the most recently generated value.
*/
final T front() @property
{
return *m_value;
}
private:
T* m_value;
}
/**
* Yields a value of type T to the caller of the currently executing
* generator.
*
* Params:
* value = The value to yield.
*/
void yield(T)(ref T value)
{
Generator!T cur = cast(Generator!T) Fiber.getThis();
if (cur !is null && cur.state() == Fiber.State.EXEC)
{
cur.m_value = &value;
return Fiber.yield();
}
throw new Exception("yield(T) called with no active generator for the supplied type",
__FILE__, __LINE__);
}
/// ditto
void yield(T)(T value)
{
yield(value);
}
version (Win64) {
// fibers are broken on Win64
} else unittest {
import core.exception;
import std.exception;
static void testScheduler(Scheduler s)
{
scheduler = s;
scheduler.start(
{
auto tid = spawn(
{
int i;
try
{
for (i = 1; i < 10; i++)
{
assertNotThrown!AssertError(
assert(receiveOnly!int() == i));
}
}
catch (OwnerTerminated e)
{
}
// i will advance 1 past the last value expected
assert(i == 4);
});
auto r = new Generator!int(
{
assertThrown!Exception(yield(2.0));
yield(); // ensure this is a no-op
yield(1);
yield(); // also once something has been yielded
yield(2);
yield(3);
});
foreach (e; r)
{
tid.send(e);
}
});
scheduler = null;
}
testScheduler(new ThreadScheduler);
testScheduler(new FiberScheduler);
}
//////////////////////////////////////////////////////////////////////////////
// MessageBox Implementation
//////////////////////////////////////////////////////////////////////////////
private
{
/*
* A MessageBox is a message queue for one thread. Other threads may send
* messages to this owner by calling put(), and the owner receives them by
* calling get(). The put() call is therefore effectively shared and the
* get() call is effectively local. setMaxMsgs may be used by any thread
* to limit the size of the message queue.
*/
class MessageBox
{
this()
{
m_lock = new Mutex;
m_closed = false;
if( scheduler is null )
{
m_putMsg = new Condition( m_lock );
m_notFull = new Condition( m_lock );
}
else
{
m_putMsg = scheduler.newCondition( m_lock );
m_notFull = scheduler.newCondition( m_lock );
}
}
/*
*
*/
final @property bool isClosed() const
{
synchronized( m_lock )
{
return m_closed;
}
}
/*
* Sets a limit on the maximum number of user messages allowed in the
* mailbox. If this limit is reached, the caller attempting to add
* a new message will execute call. If num is zero, there is no limit
* on the message queue.
*
* Params:
* num = The maximum size of the queue or zero if the queue is
* unbounded.
* call = The routine to call when the queue is full.
*/
final void setMaxMsgs( size_t num, bool function(Tid) call )
{
synchronized( m_lock )
{
m_maxMsgs = num;
m_onMaxMsgs = call;
}
}
/*
* If maxMsgs is not set, the message is added to the queue and the
* owner is notified. If the queue is full, the message will still be
* accepted if it is a control message, otherwise onCrowdingDoThis is
* called. If the routine returns true, this call will block until
* the owner has made space available in the queue. If it returns
* false, this call will abort.
*
* Params:
* msg = The message to put in the queue.
*
* Throws:
* An exception if the queue is full and onCrowdingDoThis throws.
*/
final void put( ref Message msg )
{
synchronized( m_lock )
{
// TODO: Generate an error here if m_closed is true, or maybe
// put a message in the caller's queue?
if( !m_closed )
{
while( true )
{
if( isPriorityMsg( msg ) )
{
m_sharedPty.put( msg );
m_putMsg.notify();
return;
}
if( !mboxFull() || isControlMsg( msg ) )
{
m_sharedBox.put( msg );
m_putMsg.notify();
return;
}
if( m_onMaxMsgs !is null && !m_onMaxMsgs( thisTid ) )
{
return;
}
m_putQueue++;
m_notFull.wait();
m_putQueue--;
}
}
}
}
/*
* Matches ops against each message in turn until a match is found.
*
* Params:
* ops = The operations to match. Each may return a bool to indicate
* whether a message with a matching type is truly a match.
*
* Returns:
* true if a message was retrieved and false if not (such as if a
* timeout occurred).
*
* Throws:
* LinkTerminated if a linked thread terminated, or OwnerTerminated
* if the owner thread terminates and no existing messages match the
* supplied ops.
*/
final bool get(T...)( scope T vals )
{
static assert( T.length );
static if( isImplicitlyConvertible!(T[0], Duration) )
{
alias Ops = TypeTuple!(T[1 .. $]);
alias ops = vals[1 .. $];
assert( vals[0] >= msecs(0) );
enum timedWait = true;
Duration period = vals[0];
}
else
{
alias Ops = TypeTuple!(T);
alias ops = vals[0 .. $];
enum timedWait = false;
}
bool onStandardMsg( ref Message msg )
{
foreach( i, t; Ops )
{
alias Args = ParameterTypeTuple!(t);
auto op = ops[i];
if( msg.convertsTo!(Args) )
{
static if( is( ReturnType!(t) == bool ) )
{
return msg.map( op );
}
else
{
msg.map( op );
return true;
}
}
}
return false;
}
bool onLinkDeadMsg( ref Message msg )
{
assert( msg.convertsTo!(Tid) );
auto tid = msg.get!(Tid);
if( bool* depends = (tid in thisInfo.links) )
{
thisInfo.links.remove( tid );
// Give the owner relationship precedence.
if( *depends && tid != thisInfo.owner )
{
auto e = new LinkTerminated( tid );
auto m = Message( MsgType.standard, e );
if( onStandardMsg( m ) )
return true;
throw e;
}
}
if( tid == thisInfo.owner )
{
thisInfo.owner = Tid.init;
auto e = new OwnerTerminated( tid );
auto m = Message( MsgType.standard, e );
if( onStandardMsg( m ) )
return true;
throw e;
}
return false;
}
bool onControlMsg( ref Message msg )
{
switch( msg.type )
{
case MsgType.linkDead:
return onLinkDeadMsg( msg );
default:
return false;
}
}
bool scan( ref ListT list )
{
for( auto range = list[]; !range.empty; )
{
// Only the message handler will throw, so if this occurs
// we can be certain that the message was handled.
scope(failure) list.removeAt( range );
if( isControlMsg( range.front ) )
{
if( onControlMsg( range.front ) )
{
// Although the linkDead message is a control message,
// it can be handled by the user. Since the linkDead
// message throws if not handled, if we get here then
// it has been handled and we can return from receive.
// This is a weird special case that will have to be
// handled in a more general way if more are added.
if( !isLinkDeadMsg( range.front ) )
{
list.removeAt( range );
continue;
}
list.removeAt( range );
return true;
}
range.popFront();
continue;
}
else
{
if( onStandardMsg( range.front ) )
{
list.removeAt( range );
return true;
}
range.popFront();
continue;
}
}
return false;
}
bool pty( ref ListT list )
{
if( !list.empty )
{
auto range = list[];
if( onStandardMsg( range.front ) )
{
list.removeAt( range );
return true;
}
if( range.front.convertsTo!(Throwable) )
throw range.front.get!(Throwable);
else if( range.front.convertsTo!(shared(Throwable)) )
throw range.front.get!(shared(Throwable));
else throw new PriorityMessageException( range.front.data );
}
return false;
}
static if( timedWait )
{
auto limit = Clock.currSystemTick() + period;
}
while( true )
{
ListT arrived;
if( pty( m_localPty ) ||
scan( m_localBox ) )
{
return true;
}
yield();
synchronized( m_lock )
{
updateMsgCount();
while( m_sharedPty.empty && m_sharedBox.empty )
{
// NOTE: We're notifying all waiters here instead of just
// a few because the onCrowding behavior may have
// changed and we don't want to block sender threads
// unnecessarily if the new behavior is not to block.
// This will admittedly result in spurious wakeups
// in other situations, but what can you do?
if( m_putQueue && !mboxFull() )
m_notFull.notifyAll();
static if( timedWait )
{
if( period.isNegative || !m_putMsg.wait( period ) )
return false;
}
else
{
m_putMsg.wait();
}
}
m_localPty.put( m_sharedPty );
arrived.put( m_sharedBox );
}
if( m_localPty.empty )
{
scope(exit) m_localBox.put( arrived );
if( scan( arrived ) )
return true;
else
{
static if( timedWait )
{
period = limit - Clock.currSystemTick();
}
continue;
}
}
m_localBox.put( arrived );
pty( m_localPty );
return true;
}
}
/*
* Called on thread termination. This routine processes any remaining
* control messages, clears out message queues, and sets a flag to
* reject any future messages.
*/
final void close()
{
void onLinkDeadMsg( ref Message msg )
{
assert( msg.convertsTo!(Tid) );
auto tid = msg.get!(Tid);
thisInfo.links.remove( tid );
if( tid == thisInfo.owner )
thisInfo.owner = Tid.init;
}
void sweep( ref ListT list )
{
for( auto range = list[]; !range.empty; range.popFront() )
{
if( range.front.type == MsgType.linkDead )
onLinkDeadMsg( range.front );
}
}
ListT arrived;
sweep( m_localBox );
synchronized( m_lock )
{
arrived.put( m_sharedBox );
m_closed = true;
}
m_localBox.clear();
sweep( arrived );
}
private:
//////////////////////////////////////////////////////////////////////
// Routines involving shared data, m_lock must be held.
//////////////////////////////////////////////////////////////////////
bool mboxFull()
{
return m_maxMsgs &&
m_maxMsgs <= m_localMsgs + m_sharedBox.length;
}
void updateMsgCount()
{
m_localMsgs = m_localBox.length;
}
private:
//////////////////////////////////////////////////////////////////////
// Routines involving local data only, no lock needed.
//////////////////////////////////////////////////////////////////////
pure final bool isControlMsg( ref Message msg )
{
return msg.type != MsgType.standard &&
msg.type != MsgType.priority;
}
pure final bool isPriorityMsg( ref Message msg )
{
return msg.type == MsgType.priority;
}
pure final bool isLinkDeadMsg( ref Message msg )
{
return msg.type == MsgType.linkDead;
}
private:
//////////////////////////////////////////////////////////////////////
// Type declarations.
//////////////////////////////////////////////////////////////////////
alias OnMaxFn = bool function(Tid);
alias ListT = List!(Message);
private:
//////////////////////////////////////////////////////////////////////
// Local data, no lock needed.
//////////////////////////////////////////////////////////////////////
ListT m_localBox;
ListT m_localPty;
private:
//////////////////////////////////////////////////////////////////////
// Shared data, m_lock must be held on access.
//////////////////////////////////////////////////////////////////////
Mutex m_lock;
Condition m_putMsg;
Condition m_notFull;
size_t m_putQueue;
ListT m_sharedBox;
ListT m_sharedPty;
OnMaxFn m_onMaxMsgs;
size_t m_localMsgs;
size_t m_maxMsgs;
bool m_closed;
}
/*
*
*/
struct List(T)
{
struct Range
{
@property bool empty() const
{
return !m_prev.next;
}
@property ref T front()
{
enforce( m_prev.next );
return m_prev.next.val;
}
@property void front( T val )
{
enforce( m_prev.next );
m_prev.next.val = val;
}
void popFront()
{
enforce( m_prev.next );
m_prev = m_prev.next;
}
//T moveFront()
//{
// enforce( m_prev.next );
// return move( m_prev.next.val );
//}
private this( Node* p )
{
m_prev = p;
}
private Node* m_prev;
}
/*
*
*/
void put( T val )
{
put( new Node( val ) );
}
/*
*
*/
void put( ref List!(T) rhs )
{
if( !rhs.empty )
{
put( rhs.m_first );
while( m_last.next !is null )
{
m_last = m_last.next;
m_count++;
}
rhs.m_first = null;
rhs.m_last = null;
rhs.m_count = 0;
}
}
/*
*
*/
Range opSlice()
{
return Range( cast(Node*) &m_first );
}
/*
*
*/
void removeAt( Range r )
{
assert( m_count );
Node* n = r.m_prev;
enforce( n && n.next );
if( m_last is m_first )
m_last = null;
else if( m_last is n.next )
m_last = n;
Node* todelete = n.next;
n.next = n.next.next;
//delete todelete;
m_count--;
}
/*
*
*/
@property size_t length()
{
return m_count;
}
/*
*
*/
void clear()
{
m_first = m_last = null;
m_count = 0;
}
/*
*
*/
@property bool empty()
{
return m_first is null;
}
private:
struct Node
{
Node* next;
T val;
this( T v )
{
val = v;
}
}
/*
*
*/
void put( Node* n )
{
m_count++;
if( !empty )
{
m_last.next = n;
m_last = n;
return;
}
m_first = n;
m_last = n;
}
Node* m_first;
Node* m_last;
size_t m_count;
}
}
version( unittest )
{
import std.stdio;
void testfn( Tid tid )
{
receive( (float val) { assert(0); },
(int val, int val2)
{
assert( val == 42 && val2 == 86 );
} );
receive( (Tuple!(int, int) val)
{
assert( val[0] == 42 &&
val[1] == 86 );
} );
receive( (Variant val) {} );
receive( (string val)
{
if( "the quick brown fox" != val )
return false;
return true;
},
(string val)
{
assert( false );
} );
prioritySend( tid, "done" );
}
void runTest( Tid tid )
{
send( tid, 42, 86 );
send( tid, tuple(42, 86) );
send( tid, "hello", "there" );
send( tid, "the quick brown fox" );
receive( (string val) { assert(val == "done"); } );
}
void simpleTest()
{
auto tid = spawn( &testfn, thisTid );
runTest( tid );
// Run the test again with a limited mailbox size.
tid = spawn( &testfn, thisTid );
setMaxMailboxSize( tid, 2, OnCrowding.block );
runTest( tid );
}
unittest
{
simpleTest();
}
unittest
{
scheduler = new ThreadScheduler;
simpleTest();
scheduler = null;
}
}
|
D
|
void main() { runSolver(); }
void problem() {
auto N = scan!long;
auto Q = scan!long;
auto P = scan!long(2 * N - 2).chunks(2);
auto Queries = scan!long(2 * Q).chunks(2);
auto solve() {
auto pathes = new long[][](N + 1, 0);
foreach(p; P) {
pathes[p[0]] ~= p[1];
pathes[p[1]] ~= p[0];
}
auto ids = new long[](N + 1);
long id;
for(auto q = [1L]; !q.empty;) {
long[] nexts;
id++;
foreach(p; q) {
if (ids[p] != 0) continue;
ids[p] = id;
foreach(n; pathes[p]) {
if (ids[n] == 0) nexts ~= n;
}
}
q = nexts;
}
foreach(q; Queries) {
const f = ids[q[0]];
const t = ids[q[1]];
writeln((f % 2) == (t % 2) ? "Town" : "Road");
}
}
outputForAtCoder(&solve);
}
// ----------------------------------------------
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric, std.traits, std.functional, std.bigint, std.datetime.stopwatch, core.time, core.bitop;
T[][] combinations(T)(T[] s, in long m) { if (!m) return [[]]; if (s.empty) return []; return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(long n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");
Point invert(Point p) { return Point(p.y, p.x); }
long[] divisors(long n) { long[] ret; for (long i = 1; i * i <= n; i++) { if (n % i == 0) { ret ~= i; if (i * i != n) ret ~= n / i; } } return ret.sort.array; }
bool chmin(T)(ref T a, T b) { if (b < a) { a = b; return true; } else return false; }
bool chmax(T)(ref T a, T b) { if (b > a) { a = b; return true; } else return false; }
string charSort(alias S = "a < b")(string s) { return (cast(char[])((cast(byte[])s).sort!S.array)).to!string; }
ulong comb(ulong a, ulong b) { if (b == 0) {return 1;}else{return comb(a - 1, b - 1) * a / b;}}
string toAnswerString(R)(R r) { return r.map!"a.to!string".joiner(" ").array.to!string; }
void outputForAtCoder(T)(T delegate() fn) {
static if (is(T == float) || is(T == double) || is(T == real)) "%.16f".writefln(fn());
else static if (is(T == void)) fn();
else static if (is(T == string)) fn().writeln;
else static if (isInputRange!T) {
static if (!is(string == ElementType!T) && isInputRange!(ElementType!T)) foreach(r; fn()) r.toAnswerString.writeln;
else foreach(r; fn()) r.writeln;
}
else fn().writeln;
}
void runSolver() {
enum BORDER = "==================================";
debug { BORDER.writeln; while(true) { "<<< Process time: %s >>>".writefln(benchmark!problem(1)); BORDER.writeln; } }
else problem();
}
enum YESNO = [true: "Yes", false: "No"];
// -----------------------------------------------
|
D
|
// Written in the D programming language.
import std.stdio;
import std.c.stdlib;
enum CSI = "\033[";
enum RESET=CSI~"0m";
enum BOLD=CSI~"1m";
enum BLACK =CSI~"30m";
enum RED =CSI~"31m";
enum GREEN=CSI~"32m";
enum YELLOW=CSI~"33m";
enum BLUE=CSI~"34m";
enum MAGENTA=CSI~"35m";
enum CYAN=CSI~"36m";
enum WHITE=CSI~"37m";
version(linux){
private extern(C) size_t isatty(size_t desc);
private extern(C) int fileno(shared(_iobuf)*);
bool isATTy(ref File f){ // determine whether a given file is connected to a terminal
if(getenv("EMACS")) return false;
return cast(bool)isatty(fileno(f.getFP()));
}
int getTabSize(){
if(getenv("EMACS")) return 4;
return 8;
}
}else{
bool isATTY(ref File){return false;}
}
|
D
|
module android.java.android.net.wifi.aware.DiscoverySession;
public import android.java.android.net.wifi.aware.DiscoverySession_d_interface;
import arsd.jni : ImportExportImpl;
mixin ImportExportImpl!DiscoverySession;
import import2 = android.java.java.lang.Class;
import import1 = android.java.android.net.NetworkSpecifier;
|
D
|
/// Autogenerated by genflagdata.d on Sun Nov 8 01:21:25 2009.
module flagdata;
__gshared ubyte[][string] flagFiles;
void initFlagFiles()
{
flagFiles = [
"ad": cast(ubyte[])import("ad.png"),
"ae": cast(ubyte[])import("ae.png"),
"af": cast(ubyte[])import("af.png"),
"ag": cast(ubyte[])import("ag.png"),
"ai": cast(ubyte[])import("ai.png"),
"al": cast(ubyte[])import("al.png"),
"am": cast(ubyte[])import("am.png"),
"an": cast(ubyte[])import("an.png"),
"ao": cast(ubyte[])import("ao.png"),
"aq": cast(ubyte[])import("aq.png"),
"ar": cast(ubyte[])import("ar.png"),
"as": cast(ubyte[])import("as.png"),
"at": cast(ubyte[])import("at.png"),
"au": cast(ubyte[])import("au.png"),
"aw": cast(ubyte[])import("aw.png"),
"ax": cast(ubyte[])import("ax.png"),
"az": cast(ubyte[])import("az.png"),
"ba": cast(ubyte[])import("ba.png"),
"bb": cast(ubyte[])import("bb.png"),
"bd": cast(ubyte[])import("bd.png"),
"be": cast(ubyte[])import("be.png"),
"bf": cast(ubyte[])import("bf.png"),
"bg": cast(ubyte[])import("bg.png"),
"bh": cast(ubyte[])import("bh.png"),
"bi": cast(ubyte[])import("bi.png"),
"bj": cast(ubyte[])import("bj.png"),
"bm": cast(ubyte[])import("bm.png"),
"bn": cast(ubyte[])import("bn.png"),
"bo": cast(ubyte[])import("bo.png"),
"br": cast(ubyte[])import("br.png"),
"bs": cast(ubyte[])import("bs.png"),
"bt": cast(ubyte[])import("bt.png"),
"bv": cast(ubyte[])import("bv.png"),
"bw": cast(ubyte[])import("bw.png"),
"by": cast(ubyte[])import("by.png"),
"bz": cast(ubyte[])import("bz.png"),
"ca": cast(ubyte[])import("ca.png"),
"cd": cast(ubyte[])import("cd.png"),
"cf": cast(ubyte[])import("cf.png"),
"cg": cast(ubyte[])import("cg.png"),
"ch": cast(ubyte[])import("ch.png"),
"ci": cast(ubyte[])import("ci.png"),
"ck": cast(ubyte[])import("ck.png"),
"cl": cast(ubyte[])import("cl.png"),
"cm": cast(ubyte[])import("cm.png"),
"cn": cast(ubyte[])import("cn.png"),
"co": cast(ubyte[])import("co.png"),
"cr": cast(ubyte[])import("cr.png"),
"cs": cast(ubyte[])import("cs.png"),
"cu": cast(ubyte[])import("cu.png"),
"cv": cast(ubyte[])import("cv.png"),
"cy": cast(ubyte[])import("cy.png"),
"cz": cast(ubyte[])import("cz.png"),
"de": cast(ubyte[])import("de.png"),
"dj": cast(ubyte[])import("dj.png"),
"dk": cast(ubyte[])import("dk.png"),
"dm": cast(ubyte[])import("dm.png"),
"do": cast(ubyte[])import("do.png"),
"dz": cast(ubyte[])import("dz.png"),
"ec": cast(ubyte[])import("ec.png"),
"ee": cast(ubyte[])import("ee.png"),
"eg": cast(ubyte[])import("eg.png"),
"er": cast(ubyte[])import("er.png"),
"es": cast(ubyte[])import("es.png"),
"et": cast(ubyte[])import("et.png"),
"eu": cast(ubyte[])import("eu.png"),
"fi": cast(ubyte[])import("fi.png"),
"fj": cast(ubyte[])import("fj.png"),
"fk": cast(ubyte[])import("fk.png"),
"fm": cast(ubyte[])import("fm.png"),
"fo": cast(ubyte[])import("fo.png"),
"fr": cast(ubyte[])import("fr.png"),
"ga": cast(ubyte[])import("ga.png"),
"gb": cast(ubyte[])import("gb.png"),
"gd": cast(ubyte[])import("gd.png"),
"ge": cast(ubyte[])import("ge.png"),
"gf": cast(ubyte[])import("gf.png"),
"gh": cast(ubyte[])import("gh.png"),
"gi": cast(ubyte[])import("gi.png"),
"gl": cast(ubyte[])import("gl.png"),
"gm": cast(ubyte[])import("gm.png"),
"gn": cast(ubyte[])import("gn.png"),
"gp": cast(ubyte[])import("gp.png"),
"gq": cast(ubyte[])import("gq.png"),
"gr": cast(ubyte[])import("gr.png"),
"gt": cast(ubyte[])import("gt.png"),
"gu": cast(ubyte[])import("gu.png"),
"gw": cast(ubyte[])import("gw.png"),
"gy": cast(ubyte[])import("gy.png"),
"hk": cast(ubyte[])import("hk.png"),
"hm": cast(ubyte[])import("hm.png"),
"hn": cast(ubyte[])import("hn.png"),
"hr": cast(ubyte[])import("hr.png"),
"ht": cast(ubyte[])import("ht.png"),
"hu": cast(ubyte[])import("hu.png"),
"id": cast(ubyte[])import("id.png"),
"ie": cast(ubyte[])import("ie.png"),
"il": cast(ubyte[])import("il.png"),
"im": cast(ubyte[])import("im.png"),
"in": cast(ubyte[])import("in.png"),
"io": cast(ubyte[])import("io.png"),
"iq": cast(ubyte[])import("iq.png"),
"ir": cast(ubyte[])import("ir.png"),
"is": cast(ubyte[])import("is.png"),
"it": cast(ubyte[])import("it.png"),
"je": cast(ubyte[])import("je.png"),
"jm": cast(ubyte[])import("jm.png"),
"jo": cast(ubyte[])import("jo.png"),
"jp": cast(ubyte[])import("jp.png"),
"ke": cast(ubyte[])import("ke.png"),
"kg": cast(ubyte[])import("kg.png"),
"kh": cast(ubyte[])import("kh.png"),
"ki": cast(ubyte[])import("ki.png"),
"km": cast(ubyte[])import("km.png"),
"kn": cast(ubyte[])import("kn.png"),
"kp": cast(ubyte[])import("kp.png"),
"kr": cast(ubyte[])import("kr.png"),
"kw": cast(ubyte[])import("kw.png"),
"ky": cast(ubyte[])import("ky.png"),
"kz": cast(ubyte[])import("kz.png"),
"la": cast(ubyte[])import("la.png"),
"lb": cast(ubyte[])import("lb.png"),
"lc": cast(ubyte[])import("lc.png"),
"li": cast(ubyte[])import("li.png"),
"lk": cast(ubyte[])import("lk.png"),
"lr": cast(ubyte[])import("lr.png"),
"ls": cast(ubyte[])import("ls.png"),
"lt": cast(ubyte[])import("lt.png"),
"lu": cast(ubyte[])import("lu.png"),
"lv": cast(ubyte[])import("lv.png"),
"ly": cast(ubyte[])import("ly.png"),
"ma": cast(ubyte[])import("ma.png"),
"mc": cast(ubyte[])import("mc.png"),
"md": cast(ubyte[])import("md.png"),
"me": cast(ubyte[])import("me.png"),
"mg": cast(ubyte[])import("mg.png"),
"mh": cast(ubyte[])import("mh.png"),
"mk": cast(ubyte[])import("mk.png"),
"ml": cast(ubyte[])import("ml.png"),
"mm": cast(ubyte[])import("mm.png"),
"mn": cast(ubyte[])import("mn.png"),
"mo": cast(ubyte[])import("mo.png"),
"mp": cast(ubyte[])import("mp.png"),
"mq": cast(ubyte[])import("mq.png"),
"mr": cast(ubyte[])import("mr.png"),
"ms": cast(ubyte[])import("ms.png"),
"mt": cast(ubyte[])import("mt.png"),
"mu": cast(ubyte[])import("mu.png"),
"mv": cast(ubyte[])import("mv.png"),
"mw": cast(ubyte[])import("mw.png"),
"mx": cast(ubyte[])import("mx.png"),
"my": cast(ubyte[])import("my.png"),
"mz": cast(ubyte[])import("mz.png"),
"na": cast(ubyte[])import("na.png"),
"nc": cast(ubyte[])import("nc.png"),
"ne": cast(ubyte[])import("ne.png"),
"nf": cast(ubyte[])import("nf.png"),
"ng": cast(ubyte[])import("ng.png"),
"ni": cast(ubyte[])import("ni.png"),
"nl": cast(ubyte[])import("nl.png"),
"no": cast(ubyte[])import("no.png"),
"np": cast(ubyte[])import("np.png"),
"nr": cast(ubyte[])import("nr.png"),
"nu": cast(ubyte[])import("nu.png"),
"nz": cast(ubyte[])import("nz.png"),
"om": cast(ubyte[])import("om.png"),
"pa": cast(ubyte[])import("pa.png"),
"pe": cast(ubyte[])import("pe.png"),
"pf": cast(ubyte[])import("pf.png"),
"pg": cast(ubyte[])import("pg.png"),
"ph": cast(ubyte[])import("ph.png"),
"pk": cast(ubyte[])import("pk.png"),
"pl": cast(ubyte[])import("pl.png"),
"pm": cast(ubyte[])import("pm.png"),
"pr": cast(ubyte[])import("pr.png"),
"ps": cast(ubyte[])import("ps.png"),
"pt": cast(ubyte[])import("pt.png"),
"pw": cast(ubyte[])import("pw.png"),
"py": cast(ubyte[])import("py.png"),
"qa": cast(ubyte[])import("qa.png"),
"re": cast(ubyte[])import("re.png"),
"ro": cast(ubyte[])import("ro.png"),
"rs": cast(ubyte[])import("rs.png"),
"ru": cast(ubyte[])import("ru.png"),
"rw": cast(ubyte[])import("rw.png"),
"sa": cast(ubyte[])import("sa.png"),
"sb": cast(ubyte[])import("sb.png"),
"sc": cast(ubyte[])import("sc.png"),
"sd": cast(ubyte[])import("sd.png"),
"se": cast(ubyte[])import("se.png"),
"sg": cast(ubyte[])import("sg.png"),
"si": cast(ubyte[])import("si.png"),
"sk": cast(ubyte[])import("sk.png"),
"sl": cast(ubyte[])import("sl.png"),
"sm": cast(ubyte[])import("sm.png"),
"sn": cast(ubyte[])import("sn.png"),
"so": cast(ubyte[])import("so.png"),
"sr": cast(ubyte[])import("sr.png"),
"st": cast(ubyte[])import("st.png"),
"sv": cast(ubyte[])import("sv.png"),
"sy": cast(ubyte[])import("sy.png"),
"sz": cast(ubyte[])import("sz.png"),
"tc": cast(ubyte[])import("tc.png"),
"td": cast(ubyte[])import("td.png"),
"tf": cast(ubyte[])import("tf.png"),
"tg": cast(ubyte[])import("tg.png"),
"th": cast(ubyte[])import("th.png"),
"tj": cast(ubyte[])import("tj.png"),
"tk": cast(ubyte[])import("tk.png"),
"tm": cast(ubyte[])import("tm.png"),
"tn": cast(ubyte[])import("tn.png"),
"to": cast(ubyte[])import("to.png"),
"tp": cast(ubyte[])import("tp.png"),
"tr": cast(ubyte[])import("tr.png"),
"tt": cast(ubyte[])import("tt.png"),
"tv": cast(ubyte[])import("tv.png"),
"tw": cast(ubyte[])import("tw.png"),
"tz": cast(ubyte[])import("tz.png"),
"ua": cast(ubyte[])import("ua.png"),
"ug": cast(ubyte[])import("ug.png"),
"uk": cast(ubyte[])import("uk.png"),
"um": cast(ubyte[])import("um.png"),
"us": cast(ubyte[])import("us.png"),
"uy": cast(ubyte[])import("uy.png"),
"uz": cast(ubyte[])import("uz.png"),
"va": cast(ubyte[])import("va.png"),
"vc": cast(ubyte[])import("vc.png"),
"ve": cast(ubyte[])import("ve.png"),
"vg": cast(ubyte[])import("vg.png"),
"vi": cast(ubyte[])import("vi.png"),
"vn": cast(ubyte[])import("vn.png"),
"vu": cast(ubyte[])import("vu.png"),
"wf": cast(ubyte[])import("wf.png"),
"ws": cast(ubyte[])import("ws.png"),
"ye": cast(ubyte[])import("ye.png"),
"yt": cast(ubyte[])import("yt.png"),
"yu": cast(ubyte[])import("yu.png"),
"za": cast(ubyte[])import("za.png"),
"zm": cast(ubyte[])import("zm.png"),
"zr": cast(ubyte[])import("zr.png"),
"zw": cast(ubyte[])import("zw.png")
]; // 241 files
}
|
D
|
module android.java.android.media.session.MediaSession_Callback;
public import android.java.android.media.session.MediaSession_Callback_d_interface;
import arsd.jni : ImportExportImpl;
mixin ImportExportImpl!MediaSession_Callback;
import import5 = android.java.java.lang.Class;
|
D
|
a feeling of extreme pleasure or satisfaction
act of receiving pleasure from something
|
D
|
module harud.image;
import std.conv;
import harud.haruobject;
import harud.c;
import harud.types;
/**
Image class
*/
class Image: IHaruObject {
protected HPDF_Image _image;
this(HPDF_Image image) {
_image = image;
}
/**
* Gets the size of the image of an image object.
*
* Returns:
* When succeed, it returns a $(LINK2 harud/c/types/Point.html, Point) struct which includes the size of the image.
* Otherwise, it returns a $(LINK2 harud/c/types/Point.html, Point) struct whose value is (0, 0).
*/
@property Point size() {
return HPDF_Image_GetSize(this._image);
}
/**
* Gets the width of the image of an image object.
*
* Returns:
* When succeed, it returns the width of the image. Otherwise, it returns 0.
*/
@property uint width() {
return HPDF_Image_GetWidth(this._image);
}
/**
* Gets the height of the image of an image object.
*
* Returns:
* when succeed, it returns the height of the image. Otherwise, it returns 0.
*/
@property uint height() {
return HPDF_Image_GetHeight(this._image);
}
/**
* Gets the number of bits used to describe each color component.
*/
@property uint bitsPerComponent() {
return HPDF_Image_GetBitsPerComponent(this._image);
}
/**
* Gets the name of the image's color space.
*
* Returns:
* when getColorSpace() succeed, it returns the following values. Otherwise, it returns null.
* $(UL
* $(LI DeviceGray)
* $(LI DeviceRGB)
* $(LI DeviceCMYK)
* $(LI Indexed)
* )
*/
@property string colorSpace() {
return to!string(HPDF_Image_GetColorSpace(this._image));
}
/**
* Sets the transparent color of the image by the RGB range values.
*
* The color within the range is displayed as a transparent color. The Image must be RGB color space.
*
* Params:
* rmin = The lower limit of Red. It must be between 0 and 255.
* rmax = The upper limit of Red. It must be between 0 and 255.
* gmin = The lower limit of Green. It must be between 0 and 255.
* gmax = The upper limit of Green. It must be between 0 and 255.
* bmin = The lower limit of Blue. It must be between 0 and 255.
* bmax = The upper limit of Blue. It must be between 0 and 255.
*/
HPDF_STATUS setColorMask(uint rmin,
uint rmax,
uint gmin,
uint gmax,
uint bmin,
uint bmax)
in {
assert(rmin < 256, "rmin should less than 256");
assert(rmax < 256, "rmax should less than 256");
assert(gmin < 256, "gmin should less than 256");
assert(gmax < 256, "gmax should less than 256");
assert(bmin < 256, "bmin should less than 256");
assert(bmax < 256, "bmax should less than 256");
} body {
return HPDF_Image_SetColorMask(this._image,
rmin, rmax,
gmin, gmax,
bmin, bmax);
}
void setMaskImage(Image maskImage) {
HPDF_Image_SetMaskImage(this._image, maskImage.getHandle());
}
public HPDF_HANDLE getHandle() {
return _image;
}
}
|
D
|
/// Generate by tools
module com.googlecode.streamflyer.core.AfterModification;
import java.lang.exceptions;
public class AfterModification
{
public this()
{
implMissing();
}
}
|
D
|
module socks.socks5;
import std.socket : AddressFamily;
enum Socks5Version = 0x05;
enum AuthMethod: ubyte
{
NOAUTH = 0x00,
AUTH = 0x02,
NOTAVAILABLE = 0xFF
}
enum AuthStatus: ubyte
{
YES = 0x00,
NO = 0x01
}
enum RequestCmd: ubyte
{
CONNECT = 0x01,
BIND = 0x02,
UDPASSOCIATE = 0x03,
}
enum AddressType: ubyte
{
IPV4 = 0x01,
DOMAIN = 0x03,
IPV6 = 0x04,
}
enum ReplyCode: ubyte
{
SUCCEEDED = 0x00,
FAILURE = 0x01,
NOTALLOWED = 0x02,
NETWORK_UNREACHABLE = 0x03,
HOST_UNREACHABLE = 0x04,
CONNECTION_REFUSED = 0x05,
TTL_EXPIRED = 0x06,
CMD_NOTSUPPORTED = 0x07,
ADDR_NOTSUPPORTED = 0x08,
UNKNOWN = 0xff,
}
enum isSocksOptions(T) =
(is(T == Socks5Options));
struct Socks5Options
{
AuthMethod[] authMethods = [ AuthMethod.NOAUTH ];
string host;
ushort port;
string username;
string password;
bool resolveHost = true;
}
alias SocksTCPConnector = bool delegate(in string host, in ushort port);
alias SocksDataReader = void delegate(ubyte[] data);
alias SocksDataWriter = void delegate(in ubyte[]);
alias SocksHostnameResolver = string function(in string hostname);
struct Socks5
{
protected:
SocksTCPConnector connector;
SocksDataReader reader;
SocksDataWriter writer;
SocksHostnameResolver resolver;
ReplyCode _replyCode = ReplyCode.UNKNOWN;
public:
@nogc
this(SocksDataReader reader, SocksDataWriter writer, SocksTCPConnector connector = null, SocksHostnameResolver resolver = null)
{
this.connector = connector;
this.reader = reader;
this.writer = writer;
this.resolver = resolver;
}
bool connect(in Socks5Options options, string host, ushort port)
{
if (connector !is null) {
if (!connector(options.host, options.port)) {
_replyCode = ReplyCode.NETWORK_UNREACHABLE;
return false;
}
}
AuthMethod chosenMethod = handshake(options);
ReplyCode _replyCode = request(host, port, options.resolveHost);
return _replyCode == ReplyCode.SUCCEEDED;
}
@property
ReplyCode replyCode()
{
return _replyCode;
}
protected:
AuthMethod handshake(in Socks5Options options)
{
ubyte[] data = [Socks5Version, cast(ubyte)options.authMethods.length];
writer(data);
writer(cast(ubyte[])options.authMethods);
ubyte[2] answer;
reader(answer[]);
assert(answer[0] == Socks5Version,
"Error in reply from server. Protocol version must be 0x05 (see RFC 1928, chapter 3).");
return cast(AuthMethod)answer[1];
}
ReplyCode request(in string host, ushort port, bool resolveHostname)
{
Socks5RequestPacket packet;
ubyte[] data = [
Socks5Version, // SOCKS version
RequestCmd.CONNECT, // request command
0x00, // rsv
AddressType.IPV4 // address type
];
ubyte[] hostData;
IpAddress address;
if (resolveHostname && resolver !is null) {
address = IpAddress(resolver(host));
} else { // no neeed to resolve address
address = IpAddress(host);
}
if (address.isIp4) {
packet.setIp(address, port);
} else if (address.isIp6) {
packet.setIp(address, port);
} else {
packet.setDomain(host, port);
}
writer(packet[]);
ubyte[10] answer; // response packet size
reader(answer[]);
assert(answer[0] == Socks5Version,
"Error in reply from server: protocol version must be 0x05 (see RFC 1928, chapter 6).");
return cast(ReplyCode)answer[1];
}
}
protected:
struct Socks5RequestPacket
{
private:
@safe:
struct PacketData
{
ubyte socksVersion = Socks5Version; // SOCKS version
ubyte requestCommand = RequestCmd.CONNECT; // request command
ubyte rsv = 0x00; // rsv
ubyte addressType; // address type
char[1 + ubyte.max + ushort.sizeof] hostData;
}
union
{
PacketData packetData;
ubyte[PacketData.sizeof] buffer;
}
ushort hostDataLength;
public:
void setDomain(string domain, ushort port)
in
{
assert(domain.length <= ubyte.max);
}
do
{
packetData.addressType = AddressType.DOMAIN;
hostDataLength = 1 + cast(ubyte)domain.length + ushort.sizeof;
packetData.hostData[0] = cast(ubyte)(hostDataLength - 1 - ushort.sizeof);
packetData.hostData[1..hostDataLength-2] = domain;
setPort(port);
}
void setIp(IpAddress ipAddress, ushort port)
in
{
assert(ipAddress.isIp4 || ipAddress.isIp6);
}
do
{
import std.bitmanip : nativeToBigEndian;
if (ipAddress.isIp4) {
packetData.addressType = AddressType.IPV4;
hostDataLength = uint.sizeof + ushort.sizeof;
packetData.hostData[0..uint.sizeof] = cast(char[])ipAddress.ip4.nativeToBigEndian;
}
if (ipAddress.isIp6) {
packetData.addressType = AddressType.IPV6;
hostDataLength = 16 + ushort.sizeof;
packetData.hostData[0..16] = cast(char[])ipAddress.ip6; // TODO byte order?
}
setPort(port);
}
ubyte[] opSlice()
{
return buffer[0 .. 4 + hostDataLength];
}
protected:
void setPort(ushort port)
{
import std.bitmanip : nativeToBigEndian;
packetData.hostData[hostDataLength-2..hostDataLength] = cast(char[])port.nativeToBigEndian();
}
}
/**
* IP4 or IP6 address representation
*/
struct IpAddress
{
import std.socket : InternetAddress, Internet6Address, SocketException;
@safe:
this(string ipString)
{
_ip4address = InternetAddress.parse(ipString);
if (_ip4address != InternetAddress.ADDR_NONE) {
addressFamily = AddressFamily.INET;
return;
}
try {
ip6 = Internet6Address.parse(ipString);
return;
} catch (SocketException se) {
}
addressFamily = AddressFamily.UNSPEC;
}
AddressFamily addressFamily;
union
{
uint _ip4address;
ubyte[16] _ip6address;
}
@property
void ip4(uint value)
{
addressFamily = AddressFamily.INET;
_ip4address = value;
}
@property @safe
uint ip4()
{
return _ip4address;
}
@property
bool isIp4()
{
return addressFamily == AddressFamily.INET;
}
@property
void ip6(ubyte[16] value)
{
addressFamily = AddressFamily.INET6;
_ip6address = value;
}
@property @safe
ubyte[16] ip6()
{
return _ip6address;
}
@property
bool isIp6()
{
return addressFamily == AddressFamily.INET6;
}
}
unittest
{
auto ip = IpAddress("127.0.0.1");
assert(ip.isIp4);
assert(ip.ip4 == 2130706433);
import std.bigint;
ip = IpAddress("2001:0db8:85a3:0000:0000:8a2e:0370:7334");
assert(ip.isIp6);
auto ipInt = BigInt(0);
foreach (i; 0..ip.ip6.length) {
ipInt += BigInt(ip.ip6[i]) << 8*(15-i);
}
assert(ipInt == BigInt("42540766452641154071740215577757643572"));
}
|
D
|
/home/zzy/Project/os/target/riscv64imac-unknown-none-elf/debug/deps/log-38aca82dd190f1ca.rmeta: /home/zzy/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/log-0.4.8/src/lib.rs /home/zzy/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/log-0.4.8/src/macros.rs /home/zzy/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/log-0.4.8/src/serde.rs
/home/zzy/Project/os/target/riscv64imac-unknown-none-elf/debug/deps/liblog-38aca82dd190f1ca.rlib: /home/zzy/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/log-0.4.8/src/lib.rs /home/zzy/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/log-0.4.8/src/macros.rs /home/zzy/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/log-0.4.8/src/serde.rs
/home/zzy/Project/os/target/riscv64imac-unknown-none-elf/debug/deps/log-38aca82dd190f1ca.d: /home/zzy/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/log-0.4.8/src/lib.rs /home/zzy/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/log-0.4.8/src/macros.rs /home/zzy/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/log-0.4.8/src/serde.rs
/home/zzy/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/log-0.4.8/src/lib.rs:
/home/zzy/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/log-0.4.8/src/macros.rs:
/home/zzy/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/log-0.4.8/src/serde.rs:
|
D
|
// Written in the D programming language.
/**
* Templates with which to extract information about types and symbols at
* compile time.
*
* Macros:
* WIKI = Phobos/StdTraits
*
* Copyright: Copyright Digital Mars 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
* Authors: $(WEB digitalmars.com, Walter Bright),
* Tomasz Stachowiak ($(D isExpressionTuple)),
* $(WEB erdani.org, Andrei Alexandrescu),
* Shin Fujishiro,
* $(WEB octarineparrot.com, Robert Clipsham),
* $(WEB klickverbot.at, David Nadlinger),
* Kenji Hara
* Source: $(PHOBOSSRC std/_traits.d)
*/
/* Copyright Digital Mars 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module std.traits;
import std.algorithm;
import std.typetuple;
import std.typecons;
import core.vararg;
///////////////////////////////////////////////////////////////////////////////
// Functions
///////////////////////////////////////////////////////////////////////////////
// Petit demangler
// (this or similar thing will eventually go to std.demangle if necessary
// ctfe stuffs are available)
private
{
struct Demangle(T)
{
T value; // extracted information
string rest;
}
/* Demangles mstr as the storage class part of Argument. */
Demangle!uint demangleParameterStorageClass(string mstr)
{
uint pstc = 0; // parameter storage class
// Argument --> Argument2 | M Argument2
if (mstr.length > 0 && mstr[0] == 'M')
{
pstc |= ParameterStorageClass.scope_;
mstr = mstr[1 .. $];
}
// Argument2 --> Type | J Type | K Type | L Type
ParameterStorageClass stc2;
switch (mstr.length ? mstr[0] : char.init)
{
case 'J': stc2 = ParameterStorageClass.out_; break;
case 'K': stc2 = ParameterStorageClass.ref_; break;
case 'L': stc2 = ParameterStorageClass.lazy_; break;
default : break;
}
if (stc2 != ParameterStorageClass.init)
{
pstc |= stc2;
mstr = mstr[1 .. $];
}
return Demangle!uint(pstc, mstr);
}
/* Demangles mstr as FuncAttrs. */
Demangle!uint demangleFunctionAttributes(string mstr)
{
enum LOOKUP_ATTRIBUTE =
[
'a': FunctionAttribute.pure_,
'b': FunctionAttribute.nothrow_,
'c': FunctionAttribute.ref_,
'd': FunctionAttribute.property,
'e': FunctionAttribute.trusted,
'f': FunctionAttribute.safe
];
uint atts = 0;
// FuncAttrs --> FuncAttr | FuncAttr FuncAttrs
// FuncAttr --> empty | Na | Nb | Nc | Nd | Ne | Nf
while (mstr.length >= 2 && mstr[0] == 'N')
{
if (FunctionAttribute att = LOOKUP_ATTRIBUTE[ mstr[1] ])
{
atts |= att;
mstr = mstr[2 .. $];
}
else assert(0);
}
return Demangle!uint(atts, mstr);
}
alias TypeTuple!(byte, ubyte, short, ushort, int, uint, long, ulong) IntegralTypeList;
alias TypeTuple!(byte, short, int, long) SignedIntTypeList;
alias TypeTuple!(ubyte, ushort, uint, ulong) UnsignedIntTypeList;
alias TypeTuple!(float, double, real) FloatingPointTypeList;
alias TypeTuple!(ifloat, idouble, ireal) ImaginaryTypeList;
alias TypeTuple!(cfloat, cdouble, creal) ComplexTypeList;
alias TypeTuple!(IntegralTypeList, FloatingPointTypeList) NumericTypeList;
alias TypeTuple!(char, wchar, dchar) CharTypeList;
/* Get an expression typed as T, like T.init */
template defaultInit(T)
{
static if (!is(typeof({ T v = void; }))) // inout(U)
@property T defaultInit(T v = T.init);
else
@property T defaultInit();
}
}
version(unittest)
{
template MutableOf(T) { alias T MutableOf; }
template ConstOf(T) { alias const(T) ConstOf; }
template SharedOf(T) { alias shared(T) SharedOf; }
template SharedConstOf(T) { alias shared(const(T)) SharedConstOf; }
template ImmutableOf(T) { alias immutable(T) ImmutableOf; }
template WildOf(T) { alias inout(T) WildOf; }
template SharedWildOf(T) { alias shared(inout(T)) SharedWildOf; }
alias TypeTuple!(MutableOf, ConstOf, SharedOf, SharedConstOf, ImmutableOf) TypeQualifierList;
struct SubTypeOf(T)
{
T val;
alias val this;
}
}
/**
* Get the full package name for the given symbol.
* Example:
* ---
* import std.traits;
* static assert(packageName!(packageName) == "std");
* ---
*/
template packageName(alias T)
{
static if (T.stringof.length >= 9 && T.stringof[0..8] == "package ")
{
static if (is(typeof(__traits(parent, T))))
{
enum packageName = packageName!(__traits(parent, T)) ~ '.' ~ T.stringof[8..$];
}
else
{
enum packageName = T.stringof[8..$];
}
}
else static if (is(typeof(__traits(parent, T))))
alias packageName!(__traits(parent, T)) packageName;
else
static assert(false, T.stringof ~ " has no parent");
}
unittest
{
import etc.c.curl;
static assert(packageName!(packageName) == "std");
static assert(packageName!(curl_httppost) == "etc.c");
}
/**
* Get the module name (including package) for the given symbol.
* Example:
* ---
* import std.traits;
* static assert(moduleName!(moduleName) == "std.traits");
* ---
*/
template moduleName(alias T)
{
static if (T.stringof.length >= 9)
static assert(T.stringof[0..8] != "package ", "cannot get the module name for a package");
static if (T.stringof.length >= 8 && T.stringof[0..7] == "module ")
static if (__traits(compiles, packageName!(T)))
enum moduleName = packageName!(T) ~ '.' ~ T.stringof[7..$];
else
enum moduleName = T.stringof[7..$];
else
alias moduleName!(__traits(parent, T)) moduleName;
}
unittest
{
import etc.c.curl;
static assert(moduleName!(moduleName) == "std.traits");
static assert(moduleName!(curl_httppost) == "etc.c.curl");
}
/**
* Get the fully qualified name of a symbol.
* Example:
* ---
* import std.traits;
* static assert(fullyQualifiedName!(fullyQualifiedName) == "std.traits.fullyQualifiedName");
* ---
*/
template fullyQualifiedName(alias T)
{
static if (is(typeof(__traits(parent, T))))
{
static if (T.stringof.length >= 9 && T.stringof[0..8] == "package ")
{
enum fullyQualifiedName = fullyQualifiedName!(__traits(parent, T)) ~ '.' ~ T.stringof[8..$];
}
else static if (T.stringof.length >= 8 && T.stringof[0..7] == "module ")
{
enum fullyQualifiedName = fullyQualifiedName!(__traits(parent, T)) ~ '.' ~ T.stringof[7..$];
}
else static if (T.stringof.countUntil('(') == -1)
{
enum fullyQualifiedName = fullyQualifiedName!(__traits(parent, T)) ~ '.' ~ T.stringof;
}
else
enum fullyQualifiedName = fullyQualifiedName!(__traits(parent, T)) ~ '.' ~ T.stringof[0..T.stringof.countUntil('(')];
}
else
{
static if (T.stringof.length >= 9 && T.stringof[0..8] == "package ")
{
enum fullyQualifiedName = T.stringof[8..$];
}
else static if (T.stringof.length >= 8 && T.stringof[0..7] == "module ")
{
enum fullyQualifiedName = T.stringof[7..$];
}
else static if (T.stringof.countUntil('(') == -1)
{
enum fullyQualifiedName = T.stringof;
}
else
enum fullyQualifiedName = T.stringof[0..T.stringof.countUntil('(')];
}
}
unittest
{
import etc.c.curl;
static assert(fullyQualifiedName!(fullyQualifiedName) == "std.traits.fullyQualifiedName");
static assert(fullyQualifiedName!(curl_httppost) == "etc.c.curl.curl_httppost");
}
/***
* Get the type of the return value from a function,
* a pointer to function, a delegate, a struct
* with an opCall, a pointer to a struct with an opCall,
* or a class with an opCall.
* Example:
* ---
* import std.traits;
* int foo();
* ReturnType!(foo) x; // x is declared as int
* ---
*/
template ReturnType(func...)
if (func.length == 1 && isCallable!func)
{
static if (is(FunctionTypeOf!(func) R == return))
alias R ReturnType;
else
static assert(0, "argument has no return type");
}
unittest
{
struct G
{
int opCall (int i) { return 1;}
}
alias ReturnType!(G) ShouldBeInt;
static assert(is(ShouldBeInt == int));
G g;
static assert(is(ReturnType!(g) == int));
G* p;
alias ReturnType!(p) pg;
static assert(is(pg == int));
class C
{
int opCall (int i) { return 1;}
}
static assert(is(ReturnType!(C) == int));
C c;
static assert(is(ReturnType!(c) == int));
class Test
{
int prop() @property { return 0; }
}
alias ReturnType!(Test.prop) R_Test_prop;
static assert(is(R_Test_prop == int));
alias ReturnType!((int a) { return a; }) R_dglit;
static assert(is(R_dglit == int));
}
/***
Get, as a tuple, the types of the parameters to a function, a pointer
to function, a delegate, a struct with an $(D opCall), a pointer to a
struct with an $(D opCall), or a class with an $(D opCall).
Example:
---
import std.traits;
int foo(int, long);
void bar(ParameterTypeTuple!(foo)); // declares void bar(int, long);
void abc(ParameterTypeTuple!(foo)[1]); // declares void abc(long);
---
*/
template ParameterTypeTuple(func...)
if (func.length == 1 && isCallable!func)
{
static if (is(FunctionTypeOf!(func) P == function))
alias P ParameterTypeTuple;
else
static assert(0, "argument has no parameters");
}
unittest
{
int foo(int i, bool b) { return 0; }
static assert(is(ParameterTypeTuple!(foo) == TypeTuple!(int, bool)));
static assert(is(ParameterTypeTuple!(typeof(&foo)) == TypeTuple!(int, bool)));
struct S { real opCall(real r, int i) { return 0.0; } }
S s;
static assert(is(ParameterTypeTuple!(S) == TypeTuple!(real, int)));
static assert(is(ParameterTypeTuple!(S*) == TypeTuple!(real, int)));
static assert(is(ParameterTypeTuple!(s) == TypeTuple!(real, int)));
class Test
{
int prop() @property { return 0; }
}
alias ParameterTypeTuple!(Test.prop) P_Test_prop;
static assert(P_Test_prop.length == 0);
alias ParameterTypeTuple!((int a){}) P_dglit;
static assert(P_dglit.length == 1);
static assert(is(P_dglit[0] == int));
}
/**
Returns a tuple consisting of the storage classes of the parameters of a
function $(D func).
Example:
--------------------
alias ParameterStorageClass STC; // shorten the enum name
void func(ref int ctx, out real result, real param)
{
}
alias ParameterStorageClassTuple!(func) pstc;
static assert(pstc.length == 3); // three parameters
static assert(pstc[0] == STC.ref_);
static assert(pstc[1] == STC.out_);
static assert(pstc[2] == STC.none);
--------------------
*/
enum ParameterStorageClass : uint
{
/**
* These flags can be bitwise OR-ed together to represent complex storage
* class.
*/
none = 0, /// ditto
scope_ = 0b000_1, /// ditto
out_ = 0b001_0, /// ditto
ref_ = 0b010_0, /// ditto
lazy_ = 0b100_0, /// ditto
}
/// ditto
template ParameterStorageClassTuple(func...)
if (func.length == 1 && isCallable!func)
{
alias Unqual!(FunctionTypeOf!func) Func;
/*
* TypeFuncion:
* CallConvention FuncAttrs Arguments ArgClose Type
*/
alias ParameterTypeTuple!Func Params;
// chop off CallConvention and FuncAttrs
enum margs = demangleFunctionAttributes(mangledName!Func[1 .. $]).rest;
// demangle Arguments and store parameter storage classes in a tuple
template demangleNextParameter(string margs, size_t i = 0)
{
static if (i < Params.length)
{
enum demang = demangleParameterStorageClass(margs);
enum skip = mangledName!(Params[i]).length; // for bypassing Type
enum rest = demang.rest;
alias TypeTuple!(
demang.value + 0, // workaround: "not evaluatable at ..."
demangleNextParameter!(rest[skip .. $], i + 1)
) demangleNextParameter;
}
else // went thru all the parameters
{
alias TypeTuple!() demangleNextParameter;
}
}
alias demangleNextParameter!margs ParameterStorageClassTuple;
}
unittest
{
alias ParameterStorageClass STC;
void noparam() {}
static assert(ParameterStorageClassTuple!(noparam).length == 0);
void test(scope int, ref int, out int, lazy int, int) { }
alias ParameterStorageClassTuple!(test) test_pstc;
static assert(test_pstc.length == 5);
static assert(test_pstc[0] == STC.scope_);
static assert(test_pstc[1] == STC.ref_);
static assert(test_pstc[2] == STC.out_);
static assert(test_pstc[3] == STC.lazy_);
static assert(test_pstc[4] == STC.none);
interface Test
{
void test_const(int) const;
void test_sharedconst(int) shared const;
}
Test testi;
alias ParameterStorageClassTuple!(Test.test_const) test_const_pstc;
static assert(test_const_pstc.length == 1);
static assert(test_const_pstc[0] == STC.none);
alias ParameterStorageClassTuple!(testi.test_sharedconst) test_sharedconst_pstc;
static assert(test_sharedconst_pstc.length == 1);
static assert(test_sharedconst_pstc[0] == STC.none);
alias ParameterStorageClassTuple!((ref int a) {}) dglit_pstc;
static assert(dglit_pstc.length == 1);
static assert(dglit_pstc[0] == STC.ref_);
}
/*
Get, as a tuple, the identifiers of the parameters to a function symbol.
Example:
---
import std.traits;
int foo(int num, string name);
static assert([ParameterIdentifierTuple!foo] == ["num", "name"]);
---
*/
template ParameterIdentifierTuple(func...)
if (func.length == 1 && isCallable!func)
{
static if (is(typeof(func[0]) PT == __parameters))
{
template Get(size_t i)
{
enum get = (PT[i..i+1] args) => __traits(identifier, args[0]);
enum Get = get(PT[i].init);
}
}
else static if (is(FunctionTypeOf!func PT == __parameters))
{
template Get(size_t i)
{
enum Get = "";
}
}
else
static assert(0, func[0].stringof ~ "is not a function");
template Impl(size_t i = 0)
{
static if (i == PT.length)
alias TypeTuple!() Impl;
else
alias TypeTuple!(Get!(i), Impl!(i+1)) Impl;
}
alias Impl!() ParameterIdentifierTuple;
}
unittest
{
// Test for ddoc example
import std.traits;
int foo(int num, string name);
static assert([ParameterIdentifierTuple!foo] == ["num", "name"]);
}
unittest
{
alias ParameterIdentifierTuple PIT;
void bar(int num, string name, int[] array){}
static assert([PIT!bar] == ["num", "name", "array"]);
// might be changed in the future?
void function(int num, string name) fp;
static assert([PIT!fp] == ["", ""]);
// might be changed in the future?
void delegate(int num, string name, int[long] aa) dg;
static assert([PIT!dg] == ["", "", ""]);
/+
// depends on internal
void baw(int, string, int[]){}
static assert([PIT!baw] == ["_param_0", "_param_1", "_param_2"]);
// depends on internal
void baz(TypeTuple!(int, string, int[]) args){}
static assert([PIT!baz] == ["_param_0", "_param_1", "_param_2"]);
+/
}
/*
Get, as a tuple, the default value of the parameters to a function symbol.
If a parameter doesn't have the default value, $(D void) is returned instead.
Example:
---
import std.traits;
int foo(int num, string name = "hello", int[] arr = [1,2,3]);
static assert(is(ParameterDefaultValueTuple!foo[0] == void));
static assert( ParameterDefaultValueTuple!foo[1] == "hello");
static assert( ParameterDefaultValueTuple!foo[2] == [1,2,3]);
---
*/
template ParameterDefaultValueTuple(func...)
if (func.length == 1 && isCallable!func)
{
static if (is(typeof(func[0]) PT == __parameters))
{
template Get(size_t i)
{
enum get = (PT[i..i+1] args) => args[0];
static if (is(typeof(get())))
enum Get = get();
else
alias void Get;
// If default arg doesn't exist, returns void instead.
}
}
else static if (is(FunctionTypeOf!func PT == __parameters))
{
template Get(size_t i)
{
enum Get = "";
}
}
else
static assert(0, func[0].stringof ~ "is not a function");
template Impl(size_t i = 0)
{
static if (i == PT.length)
alias TypeTuple!() Impl;
else
alias TypeTuple!(Get!(i), Impl!(i+1)) Impl;
}
alias Impl!() ParameterDefaultValueTuple;
}
unittest
{
// Test for ddoc example
int foo(int num, string name = "hello", int[] arr = [1,2,3]);
static assert(is(ParameterDefaultValueTuple!foo[0] == void));
static assert( ParameterDefaultValueTuple!foo[1] == "hello");
static assert( ParameterDefaultValueTuple!foo[2] == [1,2,3]);
}
unittest
{
alias ParameterDefaultValueTuple PDVT;
void bar(int n = 1, string s = "hello"){}
static assert(PDVT!bar.length == 2);
static assert(PDVT!bar[0] == 1);
static assert(PDVT!bar[1] == "hello");
static assert(is(typeof(PDVT!bar) == typeof(TypeTuple!(1, "hello"))));
void baz(int x, int n = 1, string s = "hello"){}
static assert(PDVT!baz.length == 3);
static assert(is(PDVT!baz[0] == void));
static assert( PDVT!baz[1] == 1);
static assert( PDVT!baz[2] == "hello");
static assert(is(typeof(PDVT!baz) == typeof(TypeTuple!(void, 1, "hello"))));
struct Colour
{
ubyte a,r,g,b;
immutable Colour white = Colour(255,255,255,255);
}
void bug8106(Colour c = Colour.white){}
//pragma(msg, PDVT!bug8106);
static assert(PDVT!bug8106[0] == Colour.white);
}
/**
Returns the attributes attached to a function $(D func).
Example:
--------------------
alias FunctionAttribute FA; // shorten the enum name
real func(real x) pure nothrow @safe
{
return x;
}
static assert(functionAttributes!(func) & FA.pure_);
static assert(functionAttributes!(func) & FA.safe);
static assert(!(functionAttributes!(func) & FA.trusted)); // not @trusted
--------------------
*/
enum FunctionAttribute : uint
{
/**
* These flags can be bitwise OR-ed together to represent complex attribute.
*/
none = 0, /// ditto
pure_ = 0b00000001, /// ditto
nothrow_ = 0b00000010, /// ditto
ref_ = 0b00000100, /// ditto
property = 0b00001000, /// ditto
trusted = 0b00010000, /// ditto
safe = 0b00100000, /// ditto
}
/// ditto
template functionAttributes(func...)
if (func.length == 1 && isCallable!func)
{
alias Unqual!(FunctionTypeOf!func) Func;
enum uint functionAttributes =
demangleFunctionAttributes(mangledName!Func[1 .. $]).value;
}
unittest
{
alias FunctionAttribute FA;
interface Set
{
int pureF() pure;
int nothrowF() nothrow;
ref int refF();
int propertyF() @property;
int trustedF() @trusted;
int safeF() @safe;
}
static assert(functionAttributes!(Set.pureF) == FA.pure_);
static assert(functionAttributes!(Set.nothrowF) == FA.nothrow_);
static assert(functionAttributes!(Set.refF) == FA.ref_);
static assert(functionAttributes!(Set.propertyF) == FA.property);
static assert(functionAttributes!(Set.trustedF) == FA.trusted);
static assert(functionAttributes!(Set.safeF) == FA.safe);
static assert(!(functionAttributes!(Set.safeF) & FA.trusted));
int pure_nothrow() pure nothrow { return 0; }
static ref int static_ref_property() @property { return *(new int); }
ref int ref_property() @property { return *(new int); }
void safe_nothrow() @safe nothrow { }
static assert(functionAttributes!(pure_nothrow) == (FA.pure_ | FA.nothrow_));
static assert(functionAttributes!(static_ref_property) == (FA.ref_ | FA.property));
static assert(functionAttributes!(ref_property) == (FA.ref_ | FA.property));
static assert(functionAttributes!(safe_nothrow) == (FA.safe | FA.nothrow_));
interface Test2
{
int pure_const() pure const;
int pure_sharedconst() pure shared const;
}
static assert(functionAttributes!(Test2.pure_const) == FA.pure_);
static assert(functionAttributes!(Test2.pure_sharedconst) == FA.pure_);
static assert(functionAttributes!((int a) {}) == (FA.safe | FA.pure_ | FA.nothrow_));
}
/**
Checks the func that is @safe or @trusted
Example:
--------------------
@system int add(int a, int b) {return a+b;}
@safe int sub(int a, int b) {return a-b;}
@trusted int mul(int a, int b) {return a*b;}
static assert(!isSafe!(add));
static assert( isSafe!(sub));
static assert( isSafe!(mul));
--------------------
*/
template isSafe(alias func)
{
static if (is(typeof(func) == function))
{
enum isSafe = (functionAttributes!(func) == FunctionAttribute.safe
|| functionAttributes!(func) == FunctionAttribute.trusted);
}
else
{
@safe void dummySafeFunc()
{
alias ParameterTypeTuple!func Params;
static if (Params.length)
{
Params args;
func(args);
}
else
{
func();
}
}
enum isSafe = is(typeof(dummySafeFunc()));
}
}
@safe
unittest
{
interface Set
{
int systemF() @system;
int trustedF() @trusted;
int safeF() @safe;
}
static assert( isSafe!((int a){}));
static assert( isSafe!(Set.safeF));
static assert( isSafe!(Set.trustedF));
static assert(!isSafe!(Set.systemF));
}
/**
Checks the all functions are @safe or @trusted
Example:
--------------------
@system int add(int a, int b) {return a+b;}
@safe int sub(int a, int b) {return a-b;}
@trusted int mul(int a, int b) {return a*b;}
static assert(!areAllSafe!(add, sub));
static assert( areAllSafe!(sub, mul));
--------------------
*/
template areAllSafe(funcs...)
if (funcs.length > 0)
{
static if (funcs.length == 1)
{
enum areAllSafe = isSafe!(funcs[0]);
}
else static if (isSafe!(funcs[0]))
{
enum areAllSafe = areAllSafe!(funcs[1..$]);
}
else
{
enum areAllSafe = false;
}
}
@safe
unittest
{
interface Set
{
int systemF() @system;
int trustedF() @trusted;
int safeF() @safe;
}
static assert( areAllSafe!((int a){}, Set.safeF));
static assert(!areAllSafe!(Set.trustedF, Set.systemF));
}
/**
Checks the func that is @system
Example:
--------------------
@system int add(int a, int b) {return a+b;}
@safe int sub(int a, int b) {return a-b;}
@trusted int mul(int a, int b) {return a*b;}
static assert( isUnsafe!(add));
static assert(!isUnsafe!(sub));
static assert(!isUnsafe!(mul));
--------------------
*/
template isUnsafe(alias func)
{
enum isUnsafe = !isSafe!func;
}
@safe
unittest
{
interface Set
{
int systemF() @system;
int trustedF() @trusted;
int safeF() @safe;
}
static assert(!isUnsafe!((int a){}));
static assert(!isUnsafe!(Set.safeF));
static assert(!isUnsafe!(Set.trustedF));
static assert( isUnsafe!(Set.systemF));
}
/**
Returns the calling convention of function as a string.
Example:
--------------------
string a = functionLinkage!(writeln!(string, int));
assert(a == "D"); // extern(D)
auto fp = &printf;
string b = functionLinkage!(fp);
assert(b == "C"); // extern(C)
--------------------
*/
template functionLinkage(func...)
if (func.length == 1 && isCallable!func)
{
alias Unqual!(FunctionTypeOf!func) Func;
enum string functionLinkage =
[
'F': "D",
'U': "C",
'W': "Windows",
'V': "Pascal",
'R': "C++"
][ mangledName!Func[0] ];
}
unittest
{
extern(D) void Dfunc() {}
extern(C) void Cfunc() {}
static assert(functionLinkage!Dfunc == "D");
static assert(functionLinkage!Cfunc == "C");
interface Test
{
void const_func() const;
void sharedconst_func() shared const;
}
static assert(functionLinkage!(Test.const_func) == "D");
static assert(functionLinkage!(Test.sharedconst_func) == "D");
static assert(functionLinkage!((int a){}) == "D");
}
/**
Determines what kind of variadic parameters function has.
Example:
--------------------
void func() {}
static assert(variadicFunctionStyle!(func) == Variadic.no);
extern(C) int printf(in char*, ...);
static assert(variadicFunctionStyle!(printf) == Variadic.c);
--------------------
*/
enum Variadic
{
no, /// Function is not variadic.
c, /// Function is a _C-style variadic function.
/// Function is a _D-style variadic function, which uses
d, /// __argptr and __arguments.
typesafe, /// Function is a typesafe variadic function.
}
/// ditto
template variadicFunctionStyle(func...)
if (func.length == 1 && isCallable!func)
{
alias Unqual!(FunctionTypeOf!func) Func;
// TypeFuncion --> CallConvention FuncAttrs Arguments ArgClose Type
enum callconv = functionLinkage!Func;
enum mfunc = mangledName!Func;
enum mtype = mangledName!(ReturnType!Func);
static assert(mfunc[$ - mtype.length .. $] == mtype, mfunc ~ "|" ~ mtype);
enum argclose = mfunc[$ - mtype.length - 1];
static assert(argclose >= 'X' && argclose <= 'Z');
enum Variadic variadicFunctionStyle =
argclose == 'X' ? Variadic.typesafe :
argclose == 'Y' ? (callconv == "C") ? Variadic.c : Variadic.d :
Variadic.no; // 'Z'
}
unittest
{
extern(D) void novar() {}
extern(C) void cstyle(int, ...) {}
extern(D) void dstyle(...) {}
extern(D) void typesafe(int[]...) {}
static assert(variadicFunctionStyle!(novar) == Variadic.no);
static assert(variadicFunctionStyle!(cstyle) == Variadic.c);
static assert(variadicFunctionStyle!(dstyle) == Variadic.d);
static assert(variadicFunctionStyle!(typesafe) == Variadic.typesafe);
static assert(variadicFunctionStyle!((int[] a...) {}) == Variadic.typesafe);
}
/**
Get the function type from a callable object $(D func).
Using builtin $(D typeof) on a property function yields the types of the
property value, not of the property function itself. Still,
$(D FunctionTypeOf) is able to obtain function types of properties.
--------------------
class C
{
int value() @property;
}
static assert(is( typeof(C.value) == int ));
static assert(is( FunctionTypeOf!(C.value) == function ));
--------------------
Note:
Do not confuse function types with function pointer types; function types are
usually used for compile-time reflection purposes.
*/
template FunctionTypeOf(func...)
if (func.length == 1 && isCallable!func)
{
static if (is(typeof(& func[0]) Fsym : Fsym*) && is(Fsym == function) || is(typeof(& func[0]) Fsym == delegate))
{
alias Fsym FunctionTypeOf; // HIT: (nested) function symbol
}
else static if (is(typeof(& func[0].opCall) Fobj == delegate))
{
alias Fobj FunctionTypeOf; // HIT: callable object
}
else static if (is(typeof(& func[0].opCall) Ftyp : Ftyp*) && is(Ftyp == function))
{
alias Ftyp FunctionTypeOf; // HIT: callable type
}
else static if (is(func[0] T) || is(typeof(func[0]) T))
{
static if (is(T == function))
alias T FunctionTypeOf; // HIT: function
else static if (is(T Fptr : Fptr*) && is(Fptr == function))
alias Fptr FunctionTypeOf; // HIT: function pointer
else static if (is(T Fdlg == delegate))
alias Fdlg FunctionTypeOf; // HIT: delegate
else static assert(0);
}
else static assert(0);
}
unittest
{
int test(int a) { return 0; }
int propGet() @property { return 0; }
int propSet(int a) @property { return 0; }
int function(int) test_fp;
int delegate(int) test_dg;
static assert(is( typeof(test) == FunctionTypeOf!(typeof(test)) ));
static assert(is( typeof(test) == FunctionTypeOf!(test) ));
static assert(is( typeof(test) == FunctionTypeOf!(test_fp) ));
static assert(is( typeof(test) == FunctionTypeOf!(test_dg) ));
alias int GetterType() @property;
alias int SetterType(int) @property;
static assert(is( FunctionTypeOf!(propGet) == GetterType ));
static assert(is( FunctionTypeOf!(propSet) == SetterType ));
interface Prop { int prop() @property; }
Prop prop;
static assert(is( FunctionTypeOf!(Prop.prop) == GetterType ));
static assert(is( FunctionTypeOf!(prop.prop) == GetterType ));
class Callable { int opCall(int) { return 0; } }
auto call = new Callable;
static assert(is( FunctionTypeOf!(call) == typeof(test) ));
struct StaticCallable { static int opCall(int) { return 0; } }
StaticCallable stcall_val;
StaticCallable* stcall_ptr;
static assert(is( FunctionTypeOf!(stcall_val) == typeof(test) ));
static assert(is( FunctionTypeOf!(stcall_ptr) == typeof(test) ));
interface Overloads
{
void test(string);
real test(real);
int test();
int test() @property;
}
alias TypeTuple!(__traits(getVirtualFunctions, Overloads, "test")) ov;
alias FunctionTypeOf!(ov[0]) F_ov0;
alias FunctionTypeOf!(ov[1]) F_ov1;
alias FunctionTypeOf!(ov[2]) F_ov2;
alias FunctionTypeOf!(ov[3]) F_ov3;
static assert(is(F_ov0* == void function(string)));
static assert(is(F_ov1* == real function(real)));
static assert(is(F_ov2* == int function()));
static assert(is(F_ov3* == int function() @property));
alias FunctionTypeOf!((int a){ return a; }) F_dglit;
static assert(is(F_dglit* : int function(int)));
}
/**
* Constructs a new function or delegate type with the same basic signature
* as the given one, but different attributes (including linkage).
*
* This is especially useful for adding/removing attributes from/to types in
* generic code, where the actual type name cannot be spelt out.
*
* Params:
* T = The base type.
* linkage = The desired linkage of the result type.
* attrs = The desired $(LREF FunctionAttribute)s of the result type.
*
* Examples:
* ---
* template ExternC(T)
* if (isFunctionPointer!T || isDelegate!T || is(T == function))
* {
* alias SetFunctionAttributes!(T, "C", functionAttributes!T) ExternC;
* }
* ---
*
* ---
* auto assumePure(T)(T t)
* if (isFunctionPointer!T || isDelegate!T)
* {
* enum attrs = functionAttributes!T | FunctionAttribute.pure_;
* return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) t;
* }
* ---
*/
template SetFunctionAttributes(T, string linkage, uint attrs)
if (isFunctionPointer!T || isDelegate!T)
{
mixin({
static assert(!(attrs & FunctionAttribute.trusted) ||
!(attrs & FunctionAttribute.safe),
"Cannot have a function/delegate that is both trusted and safe.");
enum linkages = ["D", "C", "Windows", "Pascal", "C++", "System"];
static assert(canFind(linkages, linkage), "Invalid linkage '" ~
linkage ~ "', must be one of " ~ linkages.stringof ~ ".");
string result = "alias ";
static if (linkage != "D")
result ~= "extern(" ~ linkage ~ ") ";
static if (attrs & FunctionAttribute.ref_)
result ~= "ref ";
result ~= "ReturnType!T";
static if (isDelegate!T)
result ~= " delegate";
else
result ~= " function";
result ~= "(";
static if (ParameterTypeTuple!T.length > 0)
result ~= "ParameterTypeTuple!T";
enum varStyle = variadicFunctionStyle!T;
static if (varStyle == Variadic.c)
result ~= ", ...";
else static if (varStyle == Variadic.d)
result ~= "...";
else static if (varStyle == Variadic.typesafe)
result ~= "...";
result ~= ")";
static if (attrs & FunctionAttribute.pure_)
result ~= " pure";
static if (attrs & FunctionAttribute.nothrow_)
result ~= " nothrow";
static if (attrs & FunctionAttribute.property)
result ~= " @property";
static if (attrs & FunctionAttribute.trusted)
result ~= " @trusted";
static if (attrs & FunctionAttribute.safe)
result ~= " @safe";
result ~= " SetFunctionAttributes;";
return result;
}());
}
/// Ditto
template SetFunctionAttributes(T, string linkage, uint attrs)
if (is(T == function))
{
// To avoid a lot of syntactic headaches, we just use the above version to
// operate on the corresponding function pointer type and then remove the
// indirection again.
alias FunctionTypeOf!(SetFunctionAttributes!(T*, linkage, attrs))
SetFunctionAttributes;
}
version (unittest)
{
// Some function types to test.
int sc(scope int, ref int, out int, lazy int, int);
extern(System) int novar();
extern(C) int cstyle(int, ...);
extern(D) int dstyle(...);
extern(D) int typesafe(int[]...);
}
unittest
{
alias FunctionAttribute FA;
foreach (BaseT; TypeTuple!(typeof(&sc), typeof(&novar), typeof(&cstyle),
typeof(&dstyle), typeof(&typesafe)))
{
foreach (T; TypeTuple!(BaseT, FunctionTypeOf!BaseT))
{
enum linkage = functionLinkage!T;
enum attrs = functionAttributes!T;
static assert(is(SetFunctionAttributes!(T, linkage, attrs) == T),
"Identity check failed for: " ~ T.stringof);
// Check that all linkage types work (D-style variadics require D linkage).
static if (variadicFunctionStyle!T != Variadic.d)
{
foreach (newLinkage; TypeTuple!("D", "C", "Windows", "Pascal", "C++"))
{
alias SetFunctionAttributes!(T, newLinkage, attrs) New;
static assert(functionLinkage!New == newLinkage,
"Linkage test failed for: " ~ T.stringof ~ ", " ~ newLinkage ~
" (got " ~ New.stringof ~ ")");
}
}
// Add @safe.
alias SetFunctionAttributes!(T, functionLinkage!T, FA.safe) T1;
static assert(functionAttributes!T1 == FA.safe);
// Add all known attributes, excluding conflicting ones.
enum allAttrs = reduce!"a | b"([EnumMembers!FA]) & ~FA.safe & ~FA.property;
alias SetFunctionAttributes!(T1, functionLinkage!T, allAttrs) T2;
static assert(functionAttributes!T2 == allAttrs);
// Strip all attributes again.
alias SetFunctionAttributes!(T2, functionLinkage!T, FA.none) T3;
static assert(is(T3 == T));
}
}
}
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
// Aggregate Types
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
/***
* Get the types of the fields of a struct or class.
* This consists of the fields that take up memory space,
* excluding the hidden fields like the virtual function
* table pointer.
*/
template FieldTypeTuple(S)
{
static if (is(S == struct) || is(S == class) || is(S == union))
alias typeof(S.tupleof) FieldTypeTuple;
else
alias TypeTuple!(S) FieldTypeTuple;
//static assert(0, "argument is not struct or class");
}
// // FieldOffsetsTuple
// private template FieldOffsetsTupleImpl(size_t n, T...)
// {
// static if (T.length == 0)
// {
// alias TypeTuple!() Result;
// }
// else
// {
// //private alias FieldTypeTuple!(T[0]) Types;
// private enum size_t myOffset =
// ((n + T[0].alignof - 1) / T[0].alignof) * T[0].alignof;
// static if (is(T[0] == struct))
// {
// alias FieldTypeTuple!(T[0]) MyRep;
// alias FieldOffsetsTupleImpl!(myOffset, MyRep, T[1 .. $]).Result
// Result;
// }
// else
// {
// private enum size_t mySize = T[0].sizeof;
// alias TypeTuple!(myOffset) Head;
// static if (is(T == union))
// {
// alias FieldOffsetsTupleImpl!(myOffset, T[1 .. $]).Result
// Tail;
// }
// else
// {
// alias FieldOffsetsTupleImpl!(myOffset + mySize,
// T[1 .. $]).Result
// Tail;
// }
// alias TypeTuple!(Head, Tail) Result;
// }
// }
// }
// template FieldOffsetsTuple(T...)
// {
// alias FieldOffsetsTupleImpl!(0, T).Result FieldOffsetsTuple;
// }
// unittest
// {
// alias FieldOffsetsTuple!(int) T1;
// assert(T1.length == 1 && T1[0] == 0);
// //
// struct S2 { char a; int b; char c; double d; char e, f; }
// alias FieldOffsetsTuple!(S2) T2;
// //pragma(msg, T2);
// static assert(T2.length == 6
// && T2[0] == 0 && T2[1] == 4 && T2[2] == 8 && T2[3] == 16
// && T2[4] == 24&& T2[5] == 25);
// //
// class C { int a, b, c, d; }
// struct S3 { char a; C b; char c; }
// alias FieldOffsetsTuple!(S3) T3;
// //pragma(msg, T2);
// static assert(T3.length == 3
// && T3[0] == 0 && T3[1] == 4 && T3[2] == 8);
// //
// struct S4 { char a; union { int b; char c; } int d; }
// alias FieldOffsetsTuple!(S4) T4;
// //pragma(msg, FieldTypeTuple!(S4));
// static assert(T4.length == 4
// && T4[0] == 0 && T4[1] == 4 && T4[2] == 8);
// }
// /***
// Get the offsets of the fields of a struct or class.
// */
// template FieldOffsetsTuple(S)
// {
// static if (is(S == struct) || is(S == class))
// alias typeof(S.tupleof) FieldTypeTuple;
// else
// static assert(0, "argument is not struct or class");
// }
/***
Get the primitive types of the fields of a struct or class, in
topological order.
Example:
----
struct S1 { int a; float b; }
struct S2 { char[] a; union { S1 b; S1 * c; } }
alias RepresentationTypeTuple!(S2) R;
assert(R.length == 4
&& is(R[0] == char[]) && is(R[1] == int)
&& is(R[2] == float) && is(R[3] == S1*));
----
*/
template RepresentationTypeTuple(T)
{
template Impl(T...)
{
static if (T.length == 0)
{
alias TypeTuple!() Impl;
}
else
{
static if (is(T[0] R: Rebindable!R))
{
alias Impl!(Impl!R, T[1 .. $]) Impl;
}
else static if (is(T[0] == struct) || is(T[0] == union))
{
// @@@BUG@@@ this should work
// alias .RepresentationTypes!(T[0].tupleof)
// RepresentationTypes;
alias Impl!(FieldTypeTuple!(T[0]), T[1 .. $]) Impl;
}
else static if (is(T[0] U == typedef))
{
alias Impl!(FieldTypeTuple!(U), T[1 .. $]) Impl;
}
else
{
alias TypeTuple!(T[0], Impl!(T[1 .. $])) Impl;
}
}
}
static if (is(T == struct) || is(T == union) || is(T == class))
{
alias Impl!(FieldTypeTuple!T) RepresentationTypeTuple;
}
else static if (is(T U == typedef))
{
alias RepresentationTypeTuple!U RepresentationTypeTuple;
}
else
{
alias Impl!T RepresentationTypeTuple;
}
}
unittest
{
alias RepresentationTypeTuple!int S1;
static assert(is(S1 == TypeTuple!(int)));
struct S2 { int a; }
struct S3 { int a; char b; }
struct S4 { S1 a; int b; S3 c; }
static assert(is(RepresentationTypeTuple!S2 == TypeTuple!(int)));
static assert(is(RepresentationTypeTuple!S3 == TypeTuple!(int, char)));
static assert(is(RepresentationTypeTuple!S4 == TypeTuple!(int, int, int, char)));
struct S11 { int a; float b; }
struct S21 { char[] a; union { S11 b; S11 * c; } }
alias RepresentationTypeTuple!S21 R;
assert(R.length == 4
&& is(R[0] == char[]) && is(R[1] == int)
&& is(R[2] == float) && is(R[3] == S11*));
class C { int a; float b; }
alias RepresentationTypeTuple!C R1;
static assert(R1.length == 2 && is(R1[0] == int) && is(R1[1] == float));
/* Issue 6642 */
struct S5 { int a; Rebindable!(immutable Object) b; }
alias RepresentationTypeTuple!S5 R2;
static assert(R2.length == 2 && is(R2[0] == int) && is(R2[1] == immutable(Object)));
}
/*
RepresentationOffsets
*/
// private template Repeat(size_t n, T...)
// {
// static if (n == 0) alias TypeTuple!() Repeat;
// else alias TypeTuple!(T, Repeat!(n - 1, T)) Repeat;
// }
// template RepresentationOffsetsImpl(size_t n, T...)
// {
// static if (T.length == 0)
// {
// alias TypeTuple!() Result;
// }
// else
// {
// private enum size_t myOffset =
// ((n + T[0].alignof - 1) / T[0].alignof) * T[0].alignof;
// static if (!is(T[0] == union))
// {
// alias Repeat!(n, FieldTypeTuple!(T[0])).Result
// Head;
// }
// static if (is(T[0] == struct))
// {
// alias .RepresentationOffsetsImpl!(n, FieldTypeTuple!(T[0])).Result
// Head;
// }
// else
// {
// alias TypeTuple!(myOffset) Head;
// }
// alias TypeTuple!(Head,
// RepresentationOffsetsImpl!(
// myOffset + T[0].sizeof, T[1 .. $]).Result)
// Result;
// }
// }
// template RepresentationOffsets(T)
// {
// alias RepresentationOffsetsImpl!(0, T).Result
// RepresentationOffsets;
// }
// unittest
// {
// struct S1 { char c; int i; }
// alias RepresentationOffsets!(S1) Offsets;
// static assert(Offsets[0] == 0);
// //pragma(msg, Offsets[1]);
// static assert(Offsets[1] == 4);
// }
/*
Statically evaluates to $(D true) if and only if $(D T)'s
representation contains at least one field of pointer or array type.
Members of class types are not considered raw pointers. Pointers to
immutable objects are not considered raw aliasing.
Example:
---
// simple types
static assert(!hasRawAliasing!(int));
static assert( hasRawAliasing!(char*));
// references aren't raw pointers
static assert(!hasRawAliasing!(Object));
// built-in arrays do contain raw pointers
static assert( hasRawAliasing!(int[]));
// aggregate of simple types
struct S1 { int a; double b; }
static assert(!hasRawAliasing!(S1));
// indirect aggregation
struct S2 { S1 a; double b; }
static assert(!hasRawAliasing!(S2));
// struct with a pointer member
struct S3 { int a; double * b; }
static assert( hasRawAliasing!(S3));
// struct with an indirect pointer member
struct S4 { S3 a; double b; }
static assert( hasRawAliasing!(S4));
----
*/
private template hasRawAliasing(T...)
{
template Impl(T...)
{
static if (T.length == 0)
{
enum Impl = false;
}
else
{
static if (is(T[0] foo : U*, U) && !isFunctionPointer!(T[0]))
enum has = !is(U == immutable);
else static if (is(T[0] foo : U[], U) && !isStaticArray!(T[0]))
enum has = !is(U == immutable);
else static if (isAssociativeArray!(T[0]))
enum has = !is(T[0] == immutable);
else
enum has = false;
enum Impl = has || Impl!(T[1 .. $]);
}
}
enum hasRawAliasing = Impl!(RepresentationTypeTuple!T);
}
unittest
{
// simple types
static assert(!hasRawAliasing!(int));
static assert( hasRawAliasing!(char*));
// references aren't raw pointers
static assert(!hasRawAliasing!(Object));
static assert(!hasRawAliasing!(int));
struct S1 { int z; }
struct S2 { int* z; }
static assert(!hasRawAliasing!S1);
static assert( hasRawAliasing!S2);
struct S3 { int a; int* z; int c; }
struct S4 { int a; int z; int c; }
struct S5 { int a; Object z; int c; }
static assert( hasRawAliasing!S3);
static assert(!hasRawAliasing!S4);
static assert(!hasRawAliasing!S5);
union S6 { int a; int b; }
union S7 { int a; int * b; }
static assert(!hasRawAliasing!S6);
static assert( hasRawAliasing!S7);
//typedef int* S8;
//static assert(hasRawAliasing!S8);
enum S9 { a }
static assert(!hasRawAliasing!S9);
// indirect members
struct S10 { S7 a; int b; }
struct S11 { S6 a; int b; }
static assert( hasRawAliasing!S10);
static assert(!hasRawAliasing!S11);
static assert( hasRawAliasing!(int[string]));
static assert(!hasRawAliasing!(immutable(int[string])));
}
/*
Statically evaluates to $(D true) if and only if $(D T)'s
representation contains at least one non-shared field of pointer or
array type. Members of class types are not considered raw pointers.
Pointers to immutable objects are not considered raw aliasing.
Example:
---
// simple types
static assert(!hasRawLocalAliasing!(int));
static assert( hasRawLocalAliasing!(char*));
static assert(!hasRawLocalAliasing!(shared char*));
// references aren't raw pointers
static assert(!hasRawLocalAliasing!(Object));
// built-in arrays do contain raw pointers
static assert( hasRawLocalAliasing!(int[]));
static assert(!hasRawLocalAliasing!(shared int[]));
// aggregate of simple types
struct S1 { int a; double b; }
static assert(!hasRawLocalAliasing!(S1));
// indirect aggregation
struct S2 { S1 a; double b; }
static assert(!hasRawLocalAliasing!(S2));
// struct with a pointer member
struct S3 { int a; double * b; }
static assert( hasRawLocalAliasing!(S3));
struct S4 { int a; shared double * b; }
static assert( hasRawLocalAliasing!(S4));
// struct with an indirect pointer member
struct S5 { S3 a; double b; }
static assert( hasRawLocalAliasing!(S5));
struct S6 { S4 a; double b; }
static assert(!hasRawLocalAliasing!(S6));
----
*/
private template hasRawUnsharedAliasing(T...)
{
template Impl(T...)
{
static if (T.length == 0)
{
enum Impl = false;
}
else
{
static if (is(T[0] foo : U*, U) && !isFunctionPointer!(T[0]))
enum has = !is(U == immutable) && !is(U == shared);
else static if (is(T[0] foo : U[], U) && !isStaticArray!(T[0]))
enum has = !is(U == immutable) && !is(U == shared);
else static if (isAssociativeArray!(T[0]))
enum has = !is(T[0] == immutable) && !is(T[0] == shared);
else
enum has = false;
enum Impl = has || Impl!(T[1 .. $]);
}
}
enum hasRawUnsharedAliasing = Impl!(RepresentationTypeTuple!T);
}
unittest
{
// simple types
static assert(!hasRawUnsharedAliasing!(int));
static assert( hasRawUnsharedAliasing!(char*));
static assert(!hasRawUnsharedAliasing!(shared char*));
// references aren't raw pointers
static assert(!hasRawUnsharedAliasing!(Object));
static assert(!hasRawUnsharedAliasing!(int));
struct S1 { int z; }
struct S2 { int* z; }
static assert(!hasRawUnsharedAliasing!S1);
static assert( hasRawUnsharedAliasing!S2);
struct S3 { shared int* z; }
struct S4 { int a; int* z; int c; }
static assert(!hasRawUnsharedAliasing!S3);
static assert( hasRawUnsharedAliasing!S4);
struct S5 { int a; shared int* z; int c; }
struct S6 { int a; int z; int c; }
struct S7 { int a; Object z; int c; }
static assert(!hasRawUnsharedAliasing!S5);
static assert(!hasRawUnsharedAliasing!S6);
static assert(!hasRawUnsharedAliasing!S7);
union S8 { int a; int b; }
union S9 { int a; int* b; }
union S10 { int a; shared int* b; }
static assert(!hasRawUnsharedAliasing!S8);
static assert( hasRawUnsharedAliasing!S9);
static assert(!hasRawUnsharedAliasing!S10);
//typedef int* S11;
//typedef shared int* S12;
//static assert( hasRawUnsharedAliasing!S11);
//static assert( hasRawUnsharedAliasing!S12);
enum S13 { a }
static assert(!hasRawUnsharedAliasing!S13);
// indirect members
struct S14 { S9 a; int b; }
struct S15 { S10 a; int b; }
struct S16 { S6 a; int b; }
static assert( hasRawUnsharedAliasing!S14);
static assert(!hasRawUnsharedAliasing!S15);
static assert(!hasRawUnsharedAliasing!S16);
static assert( hasRawUnsharedAliasing!(int[string]));
static assert(!hasRawUnsharedAliasing!(shared(int[string])));
static assert(!hasRawUnsharedAliasing!(immutable(int[string])));
}
/*
Statically evaluates to $(D true) if and only if $(D T)'s
representation includes at least one non-immutable object reference.
*/
private template hasObjects(T...)
{
static if (T.length == 0)
{
enum hasObjects = false;
}
else static if (is(T[0] U == typedef))
{
enum hasObjects = hasObjects!(U, T[1 .. $]);
}
else static if (is(T[0] == struct))
{
enum hasObjects = hasObjects!(
RepresentationTypeTuple!(T[0]), T[1 .. $]);
}
else
{
enum hasObjects = ((is(T[0] == class) || is(T[0] == interface))
&& !is(T[0] == immutable)) || hasObjects!(T[1 .. $]);
}
}
/*
Statically evaluates to $(D true) if and only if $(D T)'s
representation includes at least one non-immutable non-shared object
reference.
*/
private template hasUnsharedObjects(T...)
{
static if (T.length == 0)
{
enum hasUnsharedObjects = false;
}
else static if (is(T[0] U == typedef))
{
enum hasUnsharedObjects = hasUnsharedObjects!(U, T[1 .. $]);
}
else static if (is(T[0] == struct))
{
enum hasUnsharedObjects = hasUnsharedObjects!(
RepresentationTypeTuple!(T[0]), T[1 .. $]);
}
else
{
enum hasUnsharedObjects = ((is(T[0] == class) || is(T[0] == interface)) &&
!is(T[0] == immutable) && !is(T[0] == shared)) ||
hasUnsharedObjects!(T[1 .. $]);
}
}
/**
Returns $(D true) if and only if $(D T)'s representation includes at
least one of the following: $(OL $(LI a raw pointer $(D U*) and $(D U)
is not immutable;) $(LI an array $(D U[]) and $(D U) is not
immutable;) $(LI a reference to a class or interface type $(D C) and $(D C) is
not immutable.) $(LI an associative array that is not immutable.)
$(LI a delegate.))
*/
template hasAliasing(T...)
{
enum hasAliasing = hasRawAliasing!(T) || hasObjects!(T) ||
anySatisfy!(isDelegate, T);
}
// Specialization to special-case std.typecons.Rebindable.
template hasAliasing(R : Rebindable!R)
{
enum hasAliasing = hasAliasing!R;
}
unittest
{
struct S1 { int a; Object b; }
struct S2 { string a; }
struct S3 { int a; immutable Object b; }
struct S4 { float[3] vals; }
static assert( hasAliasing!S1);
static assert(!hasAliasing!S2);
static assert(!hasAliasing!S3);
static assert(!hasAliasing!S4);
static assert( hasAliasing!(uint[uint]));
static assert(!hasAliasing!(immutable(uint[uint])));
static assert( hasAliasing!(void delegate()));
static assert(!hasAliasing!(void function()));
interface I;
static assert( hasAliasing!I);
static assert( hasAliasing!(Rebindable!(const Object)));
static assert(!hasAliasing!(Rebindable!(immutable Object)));
static assert( hasAliasing!(Rebindable!(shared Object)));
static assert( hasAliasing!(Rebindable!(Object)));
}
/**
Returns $(D true) if and only if $(D T)'s representation includes at
least one of the following: $(OL $(LI a raw pointer $(D U*);) $(LI an
array $(D U[]);) $(LI a reference to a class type $(D C).)
$(LI an associative array.) $(LI a delegate.))
*/
template hasIndirections(T)
{
template Impl(T...)
{
static if (!T.length)
{
enum Impl = false;
}
else static if(isFunctionPointer!(T[0]))
{
enum Impl = Impl!(T[1 .. $]);
}
else static if(isStaticArray!(T[0]))
{
static if (is(T[0] _ : void[N], size_t N))
enum Impl = true;
else
enum Impl = Impl!(T[1 .. $]) ||
Impl!(RepresentationTypeTuple!(typeof(T[0].init[0])));
}
else
{
enum Impl = isPointer!(T[0]) || isDynamicArray!(T[0]) ||
is (T[0] : const(Object)) || isAssociativeArray!(T[0]) ||
isDelegate!(T[0]) || is(T[0] == interface)
|| Impl!(T[1 .. $]);
}
}
enum hasIndirections = Impl!(RepresentationTypeTuple!T);
}
unittest
{
struct S1 { int a; Object b; }
struct S2 { string a; }
struct S3 { int a; immutable Object b; }
static assert( hasIndirections!S1);
static assert( hasIndirections!S2);
static assert( hasIndirections!S3);
static assert( hasIndirections!(int[string]));
static assert( hasIndirections!(void delegate()));
interface I;
static assert( hasIndirections!I);
static assert(!hasIndirections!(void function()));
static assert( hasIndirections!(void*[1]));
static assert(!hasIndirections!(byte[1]));
// void static array hides actual type of bits, so "may have indirections".
static assert( hasIndirections!(void[1]));
}
// These are for backwards compatibility, are intentionally lacking ddoc,
// and should eventually be deprecated.
alias hasUnsharedAliasing hasLocalAliasing;
alias hasRawUnsharedAliasing hasRawLocalAliasing;
alias hasUnsharedObjects hasLocalObjects;
/**
Returns $(D true) if and only if $(D T)'s representation includes at
least one of the following: $(OL $(LI a raw pointer $(D U*) and $(D U)
is not immutable or shared;) $(LI an array $(D U[]) and $(D U) is not
immutable or shared;) $(LI a reference to a class type $(D C) and
$(D C) is not immutable or shared.) $(LI an associative array that is not
immutable or shared.) $(LI a delegate that is not shared.))
*/
template hasUnsharedAliasing(T...)
{
static if (!T.length)
{
enum hasUnsharedAliasing = false;
}
else static if (is(T[0] R: Rebindable!R))
{
enum hasUnsharedAliasing = hasUnsharedAliasing!R;
}
else
{
template unsharedDelegate(T)
{
enum bool unsharedDelegate = isDelegate!T && !is(T == shared);
}
enum hasUnsharedAliasing =
hasRawUnsharedAliasing!(T[0]) ||
anySatisfy!(unsharedDelegate, T[0]) ||
hasUnsharedObjects!(T[0]) ||
hasUnsharedAliasing!(T[1..$]);
}
}
unittest
{
struct S1 { int a; Object b; }
struct S2 { string a; }
struct S3 { int a; immutable Object b; }
static assert( hasUnsharedAliasing!S1);
static assert(!hasUnsharedAliasing!S2);
static assert(!hasUnsharedAliasing!S3);
struct S4 { int a; shared Object b; }
struct S5 { char[] a; }
struct S6 { shared char[] b; }
struct S7 { float[3] vals; }
static assert(!hasUnsharedAliasing!S4);
static assert( hasUnsharedAliasing!S5);
static assert(!hasUnsharedAliasing!S6);
static assert(!hasUnsharedAliasing!S7);
/* Issue 6642 */
struct S8 { int a; Rebindable!(immutable Object) b; }
static assert(!hasUnsharedAliasing!S8);
static assert( hasUnsharedAliasing!(uint[uint]));
static assert( hasUnsharedAliasing!(void delegate()));
static assert(!hasUnsharedAliasing!(shared(void delegate())));
static assert(!hasUnsharedAliasing!(void function()));
interface I {}
static assert(hasUnsharedAliasing!I);
static assert( hasUnsharedAliasing!(Rebindable!(const Object)));
static assert(!hasUnsharedAliasing!(Rebindable!(immutable Object)));
static assert(!hasUnsharedAliasing!(Rebindable!(shared Object)));
static assert( hasUnsharedAliasing!(Rebindable!(Object)));
/* Issue 6979 */
static assert(!hasUnsharedAliasing!(int, shared(int)*));
static assert( hasUnsharedAliasing!(int, int*));
static assert( hasUnsharedAliasing!(int, const(int)[]));
static assert( hasUnsharedAliasing!(int, shared(int)*, Rebindable!(Object)));
static assert(!hasUnsharedAliasing!(shared(int)*, Rebindable!(shared Object)));
static assert(!hasUnsharedAliasing!());
}
/**
True if $(D S) or any type embedded directly in the representation of $(D S)
defines an elaborate copy constructor. Elaborate copy constructors are
introduced by defining $(D this(this)) for a $(D struct). (Non-struct types
never have elaborate copy constructors.)
*/
template hasElaborateCopyConstructor(S)
{
static if(!is(S == struct))
{
enum bool hasElaborateCopyConstructor = false;
}
else
{
enum hasElaborateCopyConstructor = is(typeof({
S s;
return &s.__postblit;
})) || anySatisfy!(.hasElaborateCopyConstructor, typeof(S.tupleof));
}
}
unittest
{
static assert(!hasElaborateCopyConstructor!int);
struct S1 { this(this) {} }
static assert( hasElaborateCopyConstructor!S1);
struct S2 { uint num; }
struct S3 { uint num; S1 s; }
static assert(!hasElaborateCopyConstructor!S2);
static assert( hasElaborateCopyConstructor!S3);
}
/**
True if $(D S) or any type directly embedded in the representation of $(D S)
defines an elaborate assignmentq. Elaborate assignments are introduced by
defining $(D opAssign(typeof(this))) or $(D opAssign(ref typeof(this)))
for a $(D struct). (Non-struct types never have elaborate assignments.)
*/
template hasElaborateAssign(S)
{
static if(!is(S == struct))
{
enum bool hasElaborateAssign = false;
}
else
{
enum hasElaborateAssign = is(typeof(S.init.opAssign(S.init))) ||
is(typeof(S.init.opAssign({ return S.init; }()))) ||
anySatisfy!(.hasElaborateAssign, typeof(S.tupleof));
}
}
unittest
{
static assert(!hasElaborateAssign!int);
struct S { void opAssign(S) {} }
static assert( hasElaborateAssign!S);
struct S1 { void opAssign(ref S1) {} }
struct S2 { void opAssign(S1) {} }
struct S3 { S s; }
static assert( hasElaborateAssign!S1);
static assert(!hasElaborateAssign!S2);
static assert( hasElaborateAssign!S3);
struct S4
{
void opAssign(U)(U u) {}
@disable void opAssign(U)(ref U u);
}
static assert( hasElaborateAssign!S4);
}
/**
True if $(D S) or any type directly embedded in the representation
of $(D S) defines an elaborate destructor. Elaborate destructors
are introduced by defining $(D ~this()) for a $(D
struct). (Non-struct types never have elaborate destructors, even
though classes may define $(D ~this()).)
*/
template hasElaborateDestructor(S)
{
static if(isStaticArray!S && S.length)
{
enum bool hasElaborateDestructor = hasElaborateDestructor!(typeof(S[0]));
}
else static if(is(S == struct))
{
enum hasElaborateDestructor = hasMember!(S, "__dtor")
|| anySatisfy!(.hasElaborateDestructor, typeof(S.tupleof));
}
else
{
enum bool hasElaborateDestructor = false;
}
}
unittest
{
static assert(!hasElaborateDestructor!int);
static struct S1 { }
static struct S2 { ~this() {} }
static struct S3 { S2 field; }
static struct S4 { S3[1] field; }
static struct S5 { S3[] field; }
static struct S6 { S3[0] field; }
static assert(!hasElaborateDestructor!S1);
static assert( hasElaborateDestructor!S2);
static assert( hasElaborateDestructor!S3);
static assert( hasElaborateDestructor!(S3[1]));
static assert(!hasElaborateDestructor!(S3[0]));
static assert( hasElaborateDestructor!S4);
static assert(!hasElaborateDestructor!S5);
static assert(!hasElaborateDestructor!S6);
}
template Identity(alias A) { alias A Identity; }
/**
Yields $(D true) if and only if $(D T) is an aggregate that defines
a symbol called $(D name).
*/
template hasMember(T, string name)
{
static if (is(T == struct) || is(T == class) || is(T == union) || is(T == interface))
{
enum bool hasMember =
staticIndexOf!(name, __traits(allMembers, T)) != -1 ||
__traits(compiles, { mixin("alias Identity!(T."~name~") Sym;"); });
}
else
{
enum bool hasMember = false;
}
}
unittest
{
//pragma(msg, __traits(allMembers, void delegate()));
static assert(!hasMember!(int, "blah"));
struct S1 { int blah; }
struct S2 { int blah(){ return 0; } }
class C1 { int blah; }
class C2 { int blah(){ return 0; } }
static assert(hasMember!(S1, "blah"));
static assert(hasMember!(S2, "blah"));
static assert(hasMember!(C1, "blah"));
static assert(hasMember!(C2, "blah"));
// 6973
import std.range;
static assert(isOutputRange!(OutputRange!int, int));
}
// Temporarily disabled until bug4617 is fixed.
version(none) unittest
{
// 8231
struct S {
int x;
void f(){}
void t()(){}
template T(){}
}
struct R1(T) {
T t;
alias t this;
}
struct R2(T) {
T t;
@property ref inout(T) payload() inout { return t; }
alias t this;
}
static assert(hasMember!(S, "x"));
static assert(hasMember!(S, "f"));
static assert(hasMember!(S, "t"));
static assert(hasMember!(S, "T"));
static assert(hasMember!(R1!S, "x"));
static assert(hasMember!(R1!S, "f"));
static assert(hasMember!(R1!S, "t"));
static assert(hasMember!(R1!S, "T"));
static assert(hasMember!(R2!S, "x"));
static assert(hasMember!(R2!S, "f"));
static assert(hasMember!(R2!S, "t"));
static assert(hasMember!(R2!S, "T"));
}
/**
Retrieves the members of an enumerated type $(D enum E).
Params:
E = An enumerated type. $(D E) may have duplicated values.
Returns:
Static tuple composed of the members of the enumerated type $(D E).
The members are arranged in the same order as declared in $(D E).
Note:
Returned values are strictly typed with $(D E). Thus, the following code
does not work without the explicit cast:
--------------------
enum E : int { a, b, c }
int[] abc = cast(int[]) [ EnumMembers!E ];
--------------------
Cast is not necessary if the type of the variable is inferred. See the
example below.
Examples:
Creating an array of enumerated values:
--------------------
enum Sqrts : real
{
one = 1,
two = 1.41421,
three = 1.73205,
}
auto sqrts = [ EnumMembers!Sqrts ];
assert(sqrts == [ Sqrts.one, Sqrts.two, Sqrts.three ]);
--------------------
A generic function $(D rank(v)) in the following example uses this
template for finding a member $(D e) in an enumerated type $(D E).
--------------------
// Returns i if e is the i-th enumerator of E.
size_t rank(E)(E e)
if (is(E == enum))
{
foreach (i, member; EnumMembers!E)
{
if (e == member)
return i;
}
assert(0, "Not an enum member");
}
enum Mode
{
read = 1,
write = 2,
map = 4,
}
assert(rank(Mode.read ) == 0);
assert(rank(Mode.write) == 1);
assert(rank(Mode.map ) == 2);
--------------------
*/
template EnumMembers(E)
if (is(E == enum))
{
// Supply the specified identifier to an constant value.
template WithIdentifier(string ident)
{
static if (ident == "Symbolize")
{
template Symbolize(alias value)
{
enum Symbolize = value;
}
}
else
{
mixin("template Symbolize(alias "~ ident ~")"
~"{"
~"alias "~ ident ~" Symbolize;"
~"}");
}
}
template EnumSpecificMembers(names...)
{
static if (names.length > 0)
{
alias TypeTuple!(
WithIdentifier!(names[0])
.Symbolize!(__traits(getMember, E, names[0])),
EnumSpecificMembers!(names[1 .. $])
) EnumSpecificMembers;
}
else
{
alias TypeTuple!() EnumSpecificMembers;
}
}
alias EnumSpecificMembers!(__traits(allMembers, E)) EnumMembers;
}
unittest
{
enum A { a }
static assert([ EnumMembers!A ] == [ A.a ]);
enum B { a, b, c, d, e }
static assert([ EnumMembers!B ] == [ B.a, B.b, B.c, B.d, B.e ]);
}
unittest // typed enums
{
enum A : string { a = "alpha", b = "beta" }
static assert([ EnumMembers!A ] == [ A.a, A.b ]);
static struct S
{
int value;
int opCmp(S rhs) const nothrow { return value - rhs.value; }
}
enum B : S { a = S(1), b = S(2), c = S(3) }
static assert([ EnumMembers!B ] == [ B.a, B.b, B.c ]);
}
unittest // duplicated values
{
enum A
{
a = 0, b = 0,
c = 1, d = 1, e
}
static assert([ EnumMembers!A ] == [ A.a, A.b, A.c, A.d, A.e ]);
}
unittest
{
enum E { member, a = 0, b = 0 }
static assert(__traits(identifier, EnumMembers!E[0]) == "member");
static assert(__traits(identifier, EnumMembers!E[1]) == "a");
static assert(__traits(identifier, EnumMembers!E[2]) == "b");
}
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
// Classes and Interfaces
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
/***
* Get a $(D_PARAM TypeTuple) of the base class and base interfaces of
* this class or interface. $(D_PARAM BaseTypeTuple!(Object)) returns
* the empty type tuple.
*
* Example:
* ---
* import std.traits, std.typetuple, std.stdio;
* interface I { }
* class A { }
* class B : A, I { }
*
* void main()
* {
* alias BaseTypeTuple!(B) TL;
* writeln(typeid(TL)); // prints: (A,I)
* }
* ---
*/
template BaseTypeTuple(A)
{
static if (is(A P == super))
alias P BaseTypeTuple;
else
static assert(0, "argument is not a class or interface");
}
unittest
{
interface I1 { }
interface I2 { }
interface I12 : I1, I2 { }
static assert(is(BaseTypeTuple!I12 == TypeTuple!(I1, I2)));
interface I3 : I1 { }
interface I123 : I1, I2, I3 { }
static assert(is(BaseTypeTuple!I123 == TypeTuple!(I1, I2, I3)));
}
unittest
{
interface I1 { }
interface I2 { }
class A { }
class C : A, I1, I2 { }
alias BaseTypeTuple!(C) TL;
assert(TL.length == 3);
assert(is (TL[0] == A));
assert(is (TL[1] == I1));
assert(is (TL[2] == I2));
assert(BaseTypeTuple!(Object).length == 0);
}
/**
* Get a $(D_PARAM TypeTuple) of $(I all) base classes of this class,
* in decreasing order. Interfaces are not included. $(D_PARAM
* BaseClassesTuple!(Object)) yields the empty type tuple.
*
* Example:
* ---
* import std.traits, std.typetuple, std.stdio;
* interface I { }
* class A { }
* class B : A, I { }
* class C : B { }
*
* void main()
* {
* alias BaseClassesTuple!(C) TL;
* writeln(typeid(TL)); // prints: (B,A,Object)
* }
* ---
*/
template BaseClassesTuple(T)
{
static if (is(T == Object))
{
alias TypeTuple!() BaseClassesTuple;
}
static if (is(BaseTypeTuple!(T)[0] == Object))
{
alias TypeTuple!(Object) BaseClassesTuple;
}
else
{
alias TypeTuple!(BaseTypeTuple!(T)[0],
BaseClassesTuple!(BaseTypeTuple!(T)[0]))
BaseClassesTuple;
}
}
/**
* Get a $(D_PARAM TypeTuple) of $(I all) interfaces directly or
* indirectly inherited by this class or interface. Interfaces do not
* repeat if multiply implemented. $(D_PARAM InterfacesTuple!(Object))
* yields the empty type tuple.
*
* Example:
* ---
* import std.traits, std.typetuple, std.stdio;
* interface I1 { }
* interface I2 { }
* class A : I1, I2 { }
* class B : A, I1 { }
* class C : B { }
*
* void main()
* {
* alias InterfacesTuple!(C) TL;
* writeln(typeid(TL)); // prints: (I1, I2)
* }
* ---
*/
template InterfacesTuple(T)
{
template Flatten(H, T...)
{
static if (T.length)
{
alias TypeTuple!(Flatten!H, Flatten!T) Flatten;
}
else
{
static if (is(H == interface))
alias TypeTuple!(H, InterfacesTuple!H) Flatten;
else
alias InterfacesTuple!H Flatten;
}
}
static if (is(T S == super) && S.length)
alias NoDuplicates!(Flatten!S) InterfacesTuple;
else
alias TypeTuple!() InterfacesTuple;
}
unittest
{
{
// doc example
interface I1 {}
interface I2 {}
class A : I1, I2 { }
class B : A, I1 { }
class C : B { }
alias InterfacesTuple!(C) TL;
static assert(is(TL[0] == I1) && is(TL[1] == I2));
}
{
interface Iaa {}
interface Iab {}
interface Iba {}
interface Ibb {}
interface Ia : Iaa, Iab {}
interface Ib : Iba, Ibb {}
interface I : Ia, Ib {}
interface J {}
class B2 : J {}
class C2 : B2, Ia, Ib {}
static assert(is(InterfacesTuple!(I) ==
TypeTuple!(Ia, Iaa, Iab, Ib, Iba, Ibb)));
static assert(is(InterfacesTuple!(C2) ==
TypeTuple!(J, Ia, Iaa, Iab, Ib, Iba, Ibb)));
}
}
/**
* Get a $(D_PARAM TypeTuple) of $(I all) base classes of $(D_PARAM
* T), in decreasing order, followed by $(D_PARAM T)'s
* interfaces. $(D_PARAM TransitiveBaseTypeTuple!(Object)) yields the
* empty type tuple.
*
* Example:
* ---
* import std.traits, std.typetuple, std.stdio;
* interface I { }
* class A { }
* class B : A, I { }
* class C : B { }
*
* void main()
* {
* alias TransitiveBaseTypeTuple!(C) TL;
* writeln(typeid(TL)); // prints: (B,A,Object,I)
* }
* ---
*/
template TransitiveBaseTypeTuple(T)
{
static if (is(T == Object))
alias TypeTuple!() TransitiveBaseTypeTuple;
else
alias TypeTuple!(BaseClassesTuple!T, InterfacesTuple!T)
TransitiveBaseTypeTuple;
}
unittest
{
interface J1 {}
interface J2 {}
class B1 {}
class B2 : B1, J1, J2 {}
class B3 : B2, J1 {}
alias TransitiveBaseTypeTuple!(B3) TL;
assert(TL.length == 5);
assert(is (TL[0] == B2));
assert(is (TL[1] == B1));
assert(is (TL[2] == Object));
assert(is (TL[3] == J1));
assert(is (TL[4] == J2));
assert(TransitiveBaseTypeTuple!(Object).length == 0);
}
/**
Returns a tuple of non-static functions with the name $(D name) declared in the
class or interface $(D C). Covariant duplicates are shrunk into the most
derived one.
Example:
--------------------
interface I { I foo(); }
class B
{
real foo(real v) { return v; }
}
class C : B, I
{
override C foo() { return this; } // covariant overriding of I.foo()
}
alias MemberFunctionsTuple!(C, "foo") foos;
static assert(foos.length == 2);
static assert(__traits(isSame, foos[0], C.foo));
static assert(__traits(isSame, foos[1], B.foo));
--------------------
*/
template MemberFunctionsTuple(C, string name)
if (is(C == class) || is(C == interface))
{
static if (__traits(hasMember, C, name))
{
/*
* First, collect all overloads in the class hierarchy.
*/
template CollectOverloads(Node)
{
static if (__traits(hasMember, Node, name) && __traits(compiles, __traits(getMember, Node, name)))
{
// Get all overloads in sight (not hidden).
alias TypeTuple!(__traits(getVirtualFunctions, Node, name)) inSight;
// And collect all overloads in ancestor classes to reveal hidden
// methods. The result may contain duplicates.
template walkThru(Parents...)
{
static if (Parents.length > 0)
alias TypeTuple!(
CollectOverloads!(Parents[0]),
walkThru!(Parents[1 .. $])
) walkThru;
else
alias TypeTuple!() walkThru;
}
static if (is(Node Parents == super))
alias TypeTuple!(inSight, walkThru!Parents) CollectOverloads;
else
alias TypeTuple!(inSight) CollectOverloads;
}
else
alias TypeTuple!() CollectOverloads; // no overloads in this hierarchy
}
// duplicates in this tuple will be removed by shrink()
alias CollectOverloads!C overloads;
// shrinkOne!args[0] = the most derived one in the covariant siblings of target
// shrinkOne!args[1..$] = non-covariant others
template shrinkOne(/+ alias target, rest... +/ args...)
{
alias args[0 .. 1] target; // prevent property functions from being evaluated
alias args[1 .. $] rest;
static if (rest.length > 0)
{
alias FunctionTypeOf!(target) Target;
alias FunctionTypeOf!(rest[0]) Rest0;
static if (isCovariantWith!(Target, Rest0))
// target overrides rest[0] -- erase rest[0].
alias shrinkOne!(target, rest[1 .. $]) shrinkOne;
else static if (isCovariantWith!(Rest0, Target))
// rest[0] overrides target -- erase target.
alias shrinkOne!(rest[0], rest[1 .. $]) shrinkOne;
else
// target and rest[0] are distinct.
alias TypeTuple!(
shrinkOne!(target, rest[1 .. $]),
rest[0] // keep
) shrinkOne;
}
else
alias TypeTuple!(target) shrinkOne; // done
}
/*
* Now shrink covariant overloads into one.
*/
template shrink(overloads...)
{
static if (overloads.length > 0)
{
alias shrinkOne!(overloads) temp;
alias TypeTuple!(temp[0], shrink!(temp[1 .. $])) shrink;
}
else
alias TypeTuple!() shrink; // done
}
// done.
alias shrink!overloads MemberFunctionsTuple;
}
else
alias TypeTuple!() MemberFunctionsTuple;
}
unittest
{
interface I { I test(); }
interface J : I { J test(); }
interface K { K test(int); }
class B : I, K
{
K test(int) { return this; }
B test() { return this; }
static void test(string) { }
}
class C : B, J
{
override C test() { return this; }
}
alias MemberFunctionsTuple!(C, "test") test;
static assert(test.length == 2);
static assert(is(FunctionTypeOf!(test[0]) == FunctionTypeOf!(C.test)));
static assert(is(FunctionTypeOf!(test[1]) == FunctionTypeOf!(K.test)));
alias MemberFunctionsTuple!(C, "noexist") noexist;
static assert(noexist.length == 0);
interface L { int prop() @property; }
alias MemberFunctionsTuple!(L, "prop") prop;
static assert(prop.length == 1);
interface Test_I
{
void foo();
void foo(int);
void foo(int, int);
}
interface Test : Test_I {}
alias MemberFunctionsTuple!(Test, "foo") Test_foo;
static assert(Test_foo.length == 3);
static assert(is(typeof(&Test_foo[0]) == void function()));
static assert(is(typeof(&Test_foo[2]) == void function(int)));
static assert(is(typeof(&Test_foo[1]) == void function(int, int)));
}
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
// Type Conversion
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
/**
Get the type that all types can be implicitly converted to. Useful
e.g. in figuring out an array type from a bunch of initializing
values. Returns $(D_PARAM void) if passed an empty list, or if the
types have no common type.
Example:
----
alias CommonType!(int, long, short) X;
assert(is(X == long));
alias CommonType!(int, char[], short) Y;
assert(is(Y == void));
----
*/
template CommonType(T...)
{
static if (!T.length)
{
alias void CommonType;
}
else static if (T.length == 1)
{
static if(is(typeof(T[0])))
{
alias typeof(T[0]) CommonType;
}
else
{
alias T[0] CommonType;
}
}
else static if (is(typeof(true ? T[0].init : T[1].init) U))
{
alias CommonType!(U, T[2 .. $]) CommonType;
}
else
alias void CommonType;
}
unittest
{
alias CommonType!(int, long, short) X;
static assert(is(X == long));
alias CommonType!(char[], int, long, short) Y;
static assert(is(Y == void), Y.stringof);
static assert(is(CommonType!(3) == int));
static assert(is(CommonType!(double, 4, float) == double));
static assert(is(CommonType!(string, char[]) == const(char)[]));
static assert(is(CommonType!(3, 3U) == uint));
}
/**
* Returns a tuple with all possible target types of an implicit
* conversion of a value of type $(D_PARAM T).
*
* Important note:
*
* The possible targets are computed more conservatively than the D
* 2.005 compiler does, eliminating all dangerous conversions. For
* example, $(D_PARAM ImplicitConversionTargets!(double)) does not
* include $(D_PARAM float).
*/
template ImplicitConversionTargets(T)
{
static if (is(T == bool))
alias TypeTuple!(byte, ubyte, short, ushort, int, uint, long, ulong,
float, double, real, char, wchar, dchar)
ImplicitConversionTargets;
else static if (is(T == byte))
alias TypeTuple!(short, ushort, int, uint, long, ulong,
float, double, real, char, wchar, dchar)
ImplicitConversionTargets;
else static if (is(T == ubyte))
alias TypeTuple!(short, ushort, int, uint, long, ulong,
float, double, real, char, wchar, dchar)
ImplicitConversionTargets;
else static if (is(T == short))
alias TypeTuple!(ushort, int, uint, long, ulong,
float, double, real)
ImplicitConversionTargets;
else static if (is(T == ushort))
alias TypeTuple!(int, uint, long, ulong, float, double, real)
ImplicitConversionTargets;
else static if (is(T == int))
alias TypeTuple!(long, ulong, float, double, real)
ImplicitConversionTargets;
else static if (is(T == uint))
alias TypeTuple!(long, ulong, float, double, real)
ImplicitConversionTargets;
else static if (is(T == long))
alias TypeTuple!(float, double, real)
ImplicitConversionTargets;
else static if (is(T == ulong))
alias TypeTuple!(float, double, real)
ImplicitConversionTargets;
else static if (is(T == float))
alias TypeTuple!(double, real)
ImplicitConversionTargets;
else static if (is(T == double))
alias TypeTuple!(real)
ImplicitConversionTargets;
else static if (is(T == char))
alias TypeTuple!(wchar, dchar, byte, ubyte, short, ushort,
int, uint, long, ulong, float, double, real)
ImplicitConversionTargets;
else static if (is(T == wchar))
alias TypeTuple!(wchar, dchar, short, ushort, int, uint, long, ulong,
float, double, real)
ImplicitConversionTargets;
else static if (is(T == dchar))
alias TypeTuple!(wchar, dchar, int, uint, long, ulong,
float, double, real)
ImplicitConversionTargets;
else static if (is(T : typeof(null)))
alias TypeTuple!(typeof(null)) ImplicitConversionTargets;
else static if(is(T : Object))
alias TransitiveBaseTypeTuple!(T) ImplicitConversionTargets;
// @@@BUG@@@ this should work
// else static if (isDynamicArray!T && !is(typeof(T.init[0]) == const))
// alias TypeTuple!(const(typeof(T.init[0]))[]) ImplicitConversionTargets;
else static if (is(T == char[]))
alias TypeTuple!(const(char)[]) ImplicitConversionTargets;
else static if (isDynamicArray!T && !is(typeof(T.init[0]) == const))
alias TypeTuple!(const(typeof(T.init[0]))[]) ImplicitConversionTargets;
else static if (is(T : void*))
alias TypeTuple!(void*) ImplicitConversionTargets;
else
alias TypeTuple!() ImplicitConversionTargets;
}
unittest
{
assert(is(ImplicitConversionTargets!(double)[0] == real));
}
/**
Is $(D From) implicitly convertible to $(D To)?
*/
template isImplicitlyConvertible(From, To)
{
enum bool isImplicitlyConvertible = is(typeof({
void fun(ref From v)
{
void gun(To) {}
gun(v);
}
}));
}
unittest
{
static assert( isImplicitlyConvertible!(immutable(char), char));
static assert( isImplicitlyConvertible!(const(char), char));
static assert( isImplicitlyConvertible!(char, wchar));
static assert(!isImplicitlyConvertible!(wchar, char));
// bug6197
static assert(!isImplicitlyConvertible!(const(ushort), ubyte));
static assert(!isImplicitlyConvertible!(const(uint), ubyte));
static assert(!isImplicitlyConvertible!(const(ulong), ubyte));
// from std.conv.implicitlyConverts
assert(!isImplicitlyConvertible!(const(char)[], string));
assert( isImplicitlyConvertible!(string, const(char)[]));
}
/**
Returns $(D true) iff a value of type $(D Rhs) can be assigned to a variable of
type $(D Lhs).
Examples:
---
static assert(isAssignable!(long, int));
static assert(!isAssignable!(int, long));
static assert( isAssignable!(const(char)[], string));
static assert(!isAssignable!(string, char[]));
---
*/
template isAssignable(Lhs, Rhs)
{
enum bool isAssignable = is(typeof({
Lhs l;
Rhs r;
l = r;
return l;
}));
}
unittest
{
static assert( isAssignable!(long, int));
static assert( isAssignable!(const(char)[], string));
static assert(!isAssignable!(int, long));
static assert(!isAssignable!(string, char[]));
}
/*
Works like $(D isImplicitlyConvertible), except this cares only about storage
classes of the arguments.
*/
private template isStorageClassImplicitlyConvertible(From, To)
{
enum isStorageClassImplicitlyConvertible = isImplicitlyConvertible!(
ModifyTypePreservingSTC!(Pointify, From),
ModifyTypePreservingSTC!(Pointify, To) );
}
private template Pointify(T) { alias void* Pointify; }
unittest
{
static assert( isStorageClassImplicitlyConvertible!( int, const int));
static assert( isStorageClassImplicitlyConvertible!(immutable int, const int));
static assert(!isStorageClassImplicitlyConvertible!(const int, int));
static assert(!isStorageClassImplicitlyConvertible!(const int, immutable int));
static assert(!isStorageClassImplicitlyConvertible!(int, shared int));
static assert(!isStorageClassImplicitlyConvertible!(shared int, int));
}
/**
Determines whether the function type $(D F) is covariant with $(D G), i.e.,
functions of the type $(D F) can override ones of the type $(D G).
Example:
--------------------
interface I { I clone(); }
interface J { J clone(); }
class C : I
{
override C clone() // covariant overriding of I.clone()
{
return new C;
}
}
// C.clone() can override I.clone(), indeed.
static assert(isCovariantWith!(typeof(C.clone), typeof(I.clone)));
// C.clone() can't override J.clone(); the return type C is not implicitly
// convertible to J.
static assert(isCovariantWith!(typeof(C.clone), typeof(J.clone)));
--------------------
*/
template isCovariantWith(F, G)
if (is(F == function) && is(G == function))
{
static if (is(F : G))
enum isCovariantWith = true;
else
{
alias F Upr;
alias G Lwr;
/*
* Check for calling convention: require exact match.
*/
template checkLinkage()
{
enum ok = functionLinkage!(Upr) == functionLinkage!(Lwr);
}
/*
* Check for variadic parameter: require exact match.
*/
template checkVariadicity()
{
enum ok = variadicFunctionStyle!(Upr) == variadicFunctionStyle!(Lwr);
}
/*
* Check for function storage class:
* - overrider can have narrower storage class than base
*/
template checkSTC()
{
// Note the order of arguments. The convertion order Lwr -> Upr is
// correct since Upr should be semantically 'narrower' than Lwr.
enum ok = isStorageClassImplicitlyConvertible!(Lwr, Upr);
}
/*
* Check for function attributes:
* - require exact match for ref and @property
* - overrider can add pure and nothrow, but can't remove them
* - @safe and @trusted are covariant with each other, unremovable
*/
template checkAttributes()
{
alias FunctionAttribute FA;
enum uprAtts = functionAttributes!(Upr);
enum lwrAtts = functionAttributes!(Lwr);
//
enum wantExact = FA.ref_ | FA.property;
enum safety = FA.safe | FA.trusted;
enum ok =
( (uprAtts & wantExact) == (lwrAtts & wantExact)) &&
( (uprAtts & FA.pure_ ) >= (lwrAtts & FA.pure_ )) &&
( (uprAtts & FA.nothrow_) >= (lwrAtts & FA.nothrow_)) &&
(!!(uprAtts & safety ) >= !!(lwrAtts & safety )) ;
}
/*
* Check for return type: usual implicit convertion.
*/
template checkReturnType()
{
enum ok = is(ReturnType!(Upr) : ReturnType!(Lwr));
}
/*
* Check for parameters:
* - require exact match for types (cf. bugzilla 3075)
* - require exact match for in, out, ref and lazy
* - overrider can add scope, but can't remove
*/
template checkParameters()
{
alias ParameterStorageClass STC;
alias ParameterTypeTuple!(Upr) UprParams;
alias ParameterTypeTuple!(Lwr) LwrParams;
alias ParameterStorageClassTuple!(Upr) UprPSTCs;
alias ParameterStorageClassTuple!(Lwr) LwrPSTCs;
//
template checkNext(size_t i)
{
static if (i < UprParams.length)
{
enum uprStc = UprPSTCs[i];
enum lwrStc = LwrPSTCs[i];
//
enum wantExact = STC.out_ | STC.ref_ | STC.lazy_;
enum ok =
((uprStc & wantExact ) == (lwrStc & wantExact )) &&
((uprStc & STC.scope_) >= (lwrStc & STC.scope_)) &&
checkNext!(i + 1).ok;
}
else
enum ok = true; // done
}
static if (UprParams.length == LwrParams.length)
enum ok = is(UprParams == LwrParams) && checkNext!(0).ok;
else
enum ok = false;
}
/* run all the checks */
enum isCovariantWith =
checkLinkage !().ok &&
checkVariadicity!().ok &&
checkSTC !().ok &&
checkAttributes !().ok &&
checkReturnType !().ok &&
checkParameters !().ok ;
}
}
version (unittest) private template isCovariantWith(alias f, alias g)
{
enum bool isCovariantWith = isCovariantWith!(typeof(f), typeof(g));
}
unittest
{
// covariant return type
interface I {}
interface J : I {}
interface BaseA { const(I) test(int); }
interface DerivA_1 : BaseA { override const(J) test(int); }
interface DerivA_2 : BaseA { override J test(int); }
static assert( isCovariantWith!(DerivA_1.test, BaseA.test));
static assert( isCovariantWith!(DerivA_2.test, BaseA.test));
static assert(!isCovariantWith!(BaseA.test, DerivA_1.test));
static assert(!isCovariantWith!(BaseA.test, DerivA_2.test));
static assert(isCovariantWith!(BaseA.test, BaseA.test));
static assert(isCovariantWith!(DerivA_1.test, DerivA_1.test));
static assert(isCovariantWith!(DerivA_2.test, DerivA_2.test));
// scope parameter
interface BaseB { void test( int, int); }
interface DerivB_1 : BaseB { override void test(scope int, int); }
interface DerivB_2 : BaseB { override void test( int, scope int); }
interface DerivB_3 : BaseB { override void test(scope int, scope int); }
static assert( isCovariantWith!(DerivB_1.test, BaseB.test));
static assert( isCovariantWith!(DerivB_2.test, BaseB.test));
static assert( isCovariantWith!(DerivB_3.test, BaseB.test));
static assert(!isCovariantWith!(BaseB.test, DerivB_1.test));
static assert(!isCovariantWith!(BaseB.test, DerivB_2.test));
static assert(!isCovariantWith!(BaseB.test, DerivB_3.test));
// function storage class
interface BaseC { void test() ; }
interface DerivC_1 : BaseC { override void test() const; }
static assert( isCovariantWith!(DerivC_1.test, BaseC.test));
static assert(!isCovariantWith!(BaseC.test, DerivC_1.test));
// increasing safety
interface BaseE { void test() ; }
interface DerivE_1 : BaseE { override void test() @safe ; }
interface DerivE_2 : BaseE { override void test() @trusted; }
static assert( isCovariantWith!(DerivE_1.test, BaseE.test));
static assert( isCovariantWith!(DerivE_2.test, BaseE.test));
static assert(!isCovariantWith!(BaseE.test, DerivE_1.test));
static assert(!isCovariantWith!(BaseE.test, DerivE_2.test));
// @safe and @trusted
interface BaseF
{
void test1() @safe;
void test2() @trusted;
}
interface DerivF : BaseF
{
override void test1() @trusted;
override void test2() @safe;
}
static assert( isCovariantWith!(DerivF.test1, BaseF.test1));
static assert( isCovariantWith!(DerivF.test2, BaseF.test2));
}
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
// SomethingTypeOf
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
/*
*/
template BooleanTypeOf(T) if (!is(T == enum))
{
inout(bool) idx( inout(bool) );
shared(inout bool) idx( shared(inout bool) );
immutable(bool) idy( immutable(bool) );
static if (is(typeof(idx(T.init)) X) && !isIntegral!T)
alias X BooleanTypeOf;
else static if (is(typeof(idy(T.init)) X) && is(Unqual!X == bool) && !isIntegral!T)
alias X BooleanTypeOf;
else
static assert(0, T.stringof~" is not boolean type");
}
unittest
{
// unexpected failure, maybe dmd type-merging bug
foreach (T; TypeTuple!(bool))
foreach (Q; TypeQualifierList)
{
static assert( is(Q!T == BooleanTypeOf!( Q!T )));
static assert( is(Q!T == BooleanTypeOf!( SubTypeOf!(Q!T) )));
}
foreach (T; TypeTuple!(void, NumericTypeList, ImaginaryTypeList, ComplexTypeList, CharTypeList))
foreach (Q; TypeQualifierList)
{
static assert(!is(BooleanTypeOf!( Q!T )), Q!T.stringof);
static assert(!is(BooleanTypeOf!( SubTypeOf!(Q!T) )));
}
}
/*
*/
template IntegralTypeOf(T) if (!is(T == enum))
{
inout( byte) idx( inout( byte) );
inout( ubyte) idx( inout( ubyte) );
inout( short) idx( inout( short) );
inout(ushort) idx( inout(ushort) );
inout( int) idx( inout( int) );
inout( uint) idx( inout( uint) );
inout( long) idx( inout( long) );
inout( ulong) idx( inout( ulong) );
shared(inout byte) idx( shared(inout byte) );
shared(inout ubyte) idx( shared(inout ubyte) );
shared(inout short) idx( shared(inout short) );
shared(inout ushort) idx( shared(inout ushort) );
shared(inout int) idx( shared(inout int) );
shared(inout uint) idx( shared(inout uint) );
shared(inout long) idx( shared(inout long) );
shared(inout ulong) idx( shared(inout ulong) );
immutable( char) idy( immutable( char) );
immutable( wchar) idy( immutable( wchar) );
immutable( dchar) idy( immutable( dchar) );
// Integrals and characers are impilcit convertible each other with value copy.
// Then adding exact overloads to detect it.
immutable( byte) idy( immutable( byte) );
immutable( ubyte) idy( immutable( ubyte) );
immutable( short) idy( immutable( short) );
immutable(ushort) idy( immutable(ushort) );
immutable( int) idy( immutable( int) );
immutable( uint) idy( immutable( uint) );
immutable( long) idy( immutable( long) );
immutable( ulong) idy( immutable( ulong) );
static if (is(typeof(idx(T.init)) X))
alias X IntegralTypeOf;
else static if (is(typeof(idy(T.init)) X) && staticIndexOf!(Unqual!X, IntegralTypeList) >= 0)
alias X IntegralTypeOf;
else
static assert(0, T.stringof~" is not an integral type");
}
unittest
{
foreach (T; IntegralTypeList)
foreach (Q; TypeQualifierList)
{
static assert( is(Q!T == IntegralTypeOf!( Q!T )));
static assert( is(Q!T == IntegralTypeOf!( SubTypeOf!(Q!T) )));
}
foreach (T; TypeTuple!(void, bool, FloatingPointTypeList, ImaginaryTypeList, ComplexTypeList, CharTypeList))
foreach (Q; TypeQualifierList)
{
static assert(!is(IntegralTypeOf!( Q!T )));
static assert(!is(IntegralTypeOf!( SubTypeOf!(Q!T) )));
}
}
/*
*/
template FloatingPointTypeOf(T) if (!is(T == enum))
{
inout( float) idx( inout( float) );
inout(double) idx( inout(double) );
inout( real) idx( inout( real) );
shared(inout float) idx( shared(inout float) );
shared(inout double) idx( shared(inout double) );
shared(inout real) idx( shared(inout real) );
immutable( float) idy( immutable( float) );
immutable(double) idy( immutable(double) );
immutable( real) idy( immutable( real) );
static if (is(typeof(idx(T.init)) X))
alias X FloatingPointTypeOf;
else static if (is(typeof(idy(T.init)) X))
alias X FloatingPointTypeOf;
else
static assert(0, T.stringof~" is not a floating point type");
}
unittest
{
foreach (T; FloatingPointTypeList)
foreach (Q; TypeQualifierList)
{
static assert( is(Q!T == FloatingPointTypeOf!( Q!T )));
static assert( is(Q!T == FloatingPointTypeOf!( SubTypeOf!(Q!T) )));
}
foreach (T; TypeTuple!(void, bool, IntegralTypeList, ImaginaryTypeList, ComplexTypeList, CharTypeList))
foreach (Q; TypeQualifierList)
{
static assert(!is(FloatingPointTypeOf!( Q!T )));
static assert(!is(FloatingPointTypeOf!( SubTypeOf!(Q!T) )));
}
}
/*
*/
template NumericTypeOf(T) if (!is(T == enum))
{
static if (is(IntegralTypeOf!T X))
alias X NumericTypeOf;
else static if (is(FloatingPointTypeOf!T X))
alias X NumericTypeOf;
else
static assert(0, T.stringof~" is not a numeric type");
}
unittest
{
foreach (T; TypeTuple!(IntegralTypeList, FloatingPointTypeList))
foreach (Q; TypeQualifierList)
{
static assert( is(Q!T == NumericTypeOf!( Q!T )));
static assert( is(Q!T == NumericTypeOf!( SubTypeOf!(Q!T) )));
}
foreach (T; TypeTuple!(void, bool, CharTypeList, ImaginaryTypeList, ComplexTypeList))
foreach (Q; TypeQualifierList)
{
static assert(!is(NumericTypeOf!( Q!T )));
static assert(!is(NumericTypeOf!( SubTypeOf!(Q!T) )));
}
}
/*
*/
template UnsignedTypeOf(T) if (!is(T == enum))
{
static if (is(IntegralTypeOf!T X) &&
staticIndexOf!(Unqual!X, UnsignedIntTypeList) >= 0)
alias X UnsignedTypeOf;
else
static assert(0, T.stringof~" is not an unsigned type.");
}
template SignedTypeOf(T) if (!is(T == enum))
{
static if (is(IntegralTypeOf!T X) &&
staticIndexOf!(Unqual!X, SignedIntTypeList) >= 0)
alias X SignedTypeOf;
else static if (is(FloatingPointTypeOf!T X))
alias X SignedTypeOf;
else
static assert(0, T.stringof~" is not an signed type.");
}
/*
*/
template CharTypeOf(T) if (!is(T == enum))
{
inout( char) idx( inout( char) );
inout(wchar) idx( inout(wchar) );
inout(dchar) idx( inout(dchar) );
shared(inout char) idx( shared(inout char) );
shared(inout wchar) idx( shared(inout wchar) );
shared(inout dchar) idx( shared(inout dchar) );
immutable( char) idy( immutable( char) );
immutable( wchar) idy( immutable( wchar) );
immutable( dchar) idy( immutable( dchar) );
// Integrals and characers are impilcit convertible each other with value copy.
// Then adding exact overloads to detect it.
immutable( byte) idy( immutable( byte) );
immutable( ubyte) idy( immutable( ubyte) );
immutable( short) idy( immutable( short) );
immutable(ushort) idy( immutable(ushort) );
immutable( int) idy( immutable( int) );
immutable( uint) idy( immutable( uint) );
immutable( long) idy( immutable( long) );
immutable( ulong) idy( immutable( ulong) );
static if (is(typeof(idx(T.init)) X))
alias X CharTypeOf;
else static if (is(typeof(idy(T.init)) X) && staticIndexOf!(Unqual!X, CharTypeList) >= 0)
alias X CharTypeOf;
else
static assert(0, T.stringof~" is not a character type");
}
unittest
{
foreach (T; CharTypeList)
foreach (Q; TypeQualifierList)
{
static assert( is(CharTypeOf!( Q!T )));
static assert( is(CharTypeOf!( SubTypeOf!(Q!T) )));
}
foreach (T; TypeTuple!(void, bool, NumericTypeList, ImaginaryTypeList, ComplexTypeList))
foreach (Q; TypeQualifierList)
{
static assert(!is(CharTypeOf!( Q!T )));
static assert(!is(CharTypeOf!( SubTypeOf!(Q!T) )));
}
foreach (T; TypeTuple!(string, wstring, dstring, char[4]))
foreach (Q; TypeQualifierList)
{
static assert(!is(CharTypeOf!( Q!T )));
static assert(!is(CharTypeOf!( SubTypeOf!(Q!T) )));
}
}
/*
*/
template StaticArrayTypeOf(T) if (!is(T == enum))
{
inout(U[n]) idx(U, size_t n)( inout(U[n]) );
static if (is(typeof(idx(defaultInit!T)) X))
alias X StaticArrayTypeOf;
else
static assert(0, T.stringof~" is not a static array type");
}
unittest
{
foreach (T; TypeTuple!(bool, NumericTypeList, ImaginaryTypeList, ComplexTypeList))
foreach (Q; TypeTuple!(TypeQualifierList, WildOf, SharedWildOf))
{
static assert(is( Q!( T[1] ) == StaticArrayTypeOf!( Q!( T[1] ) ) ));
foreach (P; TypeQualifierList)
{ // SubTypeOf cannot have inout type
static assert(is( Q!(P!(T[1])) == StaticArrayTypeOf!( Q!(SubTypeOf!(P!(T[1]))) ) ));
}
}
foreach (T; TypeTuple!(void))
foreach (Q; TypeTuple!(TypeQualifierList))
{
static assert(is( StaticArrayTypeOf!( Q!(void[1]) ) == Q!(void[1]) ));
}
}
/*
*/
template DynamicArrayTypeOf(T) if (!is(T == enum))
{
inout(U[]) idx(U)( inout(U[]) );
static if (is(typeof(idx(defaultInit!T)) X))
{
alias typeof(defaultInit!T[0]) E;
E[] idy( E[] );
const(E[]) idy( const(E[]) );
inout(E[]) idy( inout(E[]) );
shared( E[]) idy( shared( E[]) );
shared(const E[]) idy( shared(const E[]) );
shared(inout E[]) idy( shared(inout E[]) );
immutable(E[]) idy( immutable(E[]) );
alias typeof(idy(defaultInit!T)) DynamicArrayTypeOf;
}
else
static assert(0, T.stringof~" is not a dynamic array");
}
unittest
{
foreach (T; TypeTuple!(/*void, */bool, NumericTypeList, ImaginaryTypeList, ComplexTypeList))
foreach (Q; TypeTuple!(TypeQualifierList, WildOf, SharedWildOf))
{
static assert(is( Q!(T)[] == DynamicArrayTypeOf!( Q!(T)[] ) ));
static assert(is( Q!(T[]) == DynamicArrayTypeOf!( Q!(T[]) ) ));
foreach (P; TypeTuple!(MutableOf, ConstOf, ImmutableOf))
{
static assert(is( Q!(P!(T)[]) == DynamicArrayTypeOf!( Q!(SubTypeOf!(P!(T)[])) ) ));
static assert(is( Q!(P!(T[])) == DynamicArrayTypeOf!( Q!(SubTypeOf!(P!(T[]))) ) ));
}
}
}
/*
*/
template ArrayTypeOf(T) if (!is(T == enum))
{
static if (is(StaticArrayTypeOf!T X))
alias X ArrayTypeOf;
else static if (is(DynamicArrayTypeOf!T X))
alias X ArrayTypeOf;
else
static assert(0, T.stringof~" is not an array type");
}
unittest
{
}
/*
*/
template StringTypeOf(T) if (!is(T == enum) && isSomeString!T)
{
alias ArrayTypeOf!T StringTypeOf;
}
unittest
{
foreach (T; CharTypeList)
foreach (Q; TypeTuple!(MutableOf, ConstOf, ImmutableOf, WildOf))
{
static assert(is(Q!T[] == StringTypeOf!( Q!T[] )));
static if (!__traits(isSame, Q, WildOf))
{
static assert(is(Q!T[] == StringTypeOf!( SubTypeOf!(Q!T[]) )));
alias Q!T[] Str;
class C(Str) { Str val; alias val this; }
static assert(is(StringTypeOf!(C!Str) == Str));
}
}
foreach (T; CharTypeList)
foreach (Q; TypeTuple!(SharedOf, SharedConstOf, SharedWildOf))
{
static assert(!is(StringTypeOf!( Q!T[] )));
}
}
/*
*/
template AssocArrayTypeOf(T) if (!is(T == enum))
{
immutable(V [K]) idx(K, V)( immutable(V [K]) );
inout(V)[K] idy(K, V)( inout(V)[K] );
shared( V [K]) idy(K, V)( shared( V [K]) );
inout(V [K]) idz(K, V)( inout(V [K]) );
shared(inout V [K]) idz(K, V)( shared(inout V [K]) );
inout(immutable(V)[K]) idw(K, V)( inout(immutable(V)[K]) );
shared(inout(immutable(V)[K])) idw(K, V)( shared(inout(immutable(V)[K])) );
static if (is(typeof(idx(defaultInit!T)) X))
{
alias X AssocArrayTypeOf;
}
else static if (is(typeof(idy(defaultInit!T)) X))
{
alias X AssocArrayTypeOf;
}
else static if (is(typeof(idz(defaultInit!T)) X))
{
inout( V [K]) idzp(K, V)( inout( V [K]) );
inout( shared(V) [K]) idzp(K, V)( inout( shared(V) [K]) );
inout( const(V) [K]) idzp(K, V)( inout( const(V) [K]) );
inout(shared(const V) [K]) idzp(K, V)( inout(shared(const V) [K]) );
inout( immutable(V) [K]) idzp(K, V)( inout( immutable(V) [K]) );
shared(inout V [K]) idzp(K, V)( shared(inout V [K]) );
shared(inout const(V) [K]) idzp(K, V)( shared(inout const(V) [K]) );
shared(inout immutable(V) [K]) idzp(K, V)( shared(inout immutable(V) [K]) );
alias typeof(idzp(defaultInit!T)) AssocArrayTypeOf;
}
else static if (is(typeof(idw(defaultInit!T)) X))
alias X AssocArrayTypeOf;
else
static assert(0, T.stringof~" is not an associative array type");
}
unittest
{
foreach (T; TypeTuple!(int/*bool, CharTypeList, NumericTypeList, ImaginaryTypeList, ComplexTypeList*/))
foreach (P; TypeTuple!(TypeQualifierList, WildOf, SharedWildOf))
foreach (Q; TypeTuple!(TypeQualifierList, WildOf, SharedWildOf))
foreach (R; TypeTuple!(TypeQualifierList, WildOf, SharedWildOf))
{
static assert(is( P!(Q!T[R!T]) == AssocArrayTypeOf!( P!(Q!T[R!T]) ) ));
}
foreach (T; TypeTuple!(int/*bool, CharTypeList, NumericTypeList, ImaginaryTypeList, ComplexTypeList*/))
foreach (O; TypeTuple!(TypeQualifierList, WildOf, SharedWildOf))
foreach (P; TypeTuple!(TypeQualifierList))
foreach (Q; TypeTuple!(TypeQualifierList))
foreach (R; TypeTuple!(TypeQualifierList))
{
static assert(is( O!(P!(Q!T[R!T])) == AssocArrayTypeOf!( O!(SubTypeOf!(P!(Q!T[R!T]))) ) ));
}
}
/*
*/
template BuiltinTypeOf(T)
{
static if (is(T : void)) alias void BuiltinTypeOf;
else static if (is(BooleanTypeOf!T X)) alias X BuiltinTypeOf;
else static if (is(IntegralTypeOf!T X)) alias X BuiltinTypeOf;
else static if (is(FloatingPointTypeOf!T X))alias X BuiltinTypeOf;
else static if (is(T : const(ireal))) alias ireal BuiltinTypeOf; //TODO
else static if (is(T : const(creal))) alias creal BuiltinTypeOf; //TODO
else static if (is(CharTypeOf!T X)) alias X BuiltinTypeOf;
else static if (is(ArrayTypeOf!T X)) alias X BuiltinTypeOf;
else static if (is(AssocArrayTypeOf!T X)) alias X BuiltinTypeOf;
else static assert(0);
}
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
// isSomething
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
/**
* Detect whether we can treat T as a built-in boolean type.
*/
template isBoolean(T)
{
enum bool isBoolean = is(BooleanTypeOf!T);
}
/**
* Detect whether we can treat T as a built-in integral type. Types $(D bool),
* $(D char), $(D wchar), and $(D dchar) are not considered integral.
*/
template isIntegral(T)
{
enum bool isIntegral = is(IntegralTypeOf!T);
}
unittest
{
static assert(isIntegral!(byte));
static assert(isIntegral!(const(byte)));
static assert(isIntegral!(immutable(byte)));
static assert(isIntegral!(shared(byte)));
static assert(isIntegral!(shared(const(byte))));
static assert(isIntegral!(ubyte));
static assert(isIntegral!(const(ubyte)));
static assert(isIntegral!(immutable(ubyte)));
static assert(isIntegral!(shared(ubyte)));
static assert(isIntegral!(shared(const(ubyte))));
static assert(isIntegral!(short));
static assert(isIntegral!(const(short)));
static assert(isIntegral!(immutable(short)));
static assert(isIntegral!(shared(short)));
static assert(isIntegral!(shared(const(short))));
static assert(isIntegral!(ushort));
static assert(isIntegral!(const(ushort)));
static assert(isIntegral!(immutable(ushort)));
static assert(isIntegral!(shared(ushort)));
static assert(isIntegral!(shared(const(ushort))));
static assert(isIntegral!(int));
static assert(isIntegral!(const(int)));
static assert(isIntegral!(immutable(int)));
static assert(isIntegral!(shared(int)));
static assert(isIntegral!(shared(const(int))));
static assert(isIntegral!(uint));
static assert(isIntegral!(const(uint)));
static assert(isIntegral!(immutable(uint)));
static assert(isIntegral!(shared(uint)));
static assert(isIntegral!(shared(const(uint))));
static assert(isIntegral!(long));
static assert(isIntegral!(const(long)));
static assert(isIntegral!(immutable(long)));
static assert(isIntegral!(shared(long)));
static assert(isIntegral!(shared(const(long))));
static assert(isIntegral!(ulong));
static assert(isIntegral!(const(ulong)));
static assert(isIntegral!(immutable(ulong)));
static assert(isIntegral!(shared(ulong)));
static assert(isIntegral!(shared(const(ulong))));
static assert(!isIntegral!(float));
}
/**
* Detect whether we can treat T as a built-in floating point type.
*/
template isFloatingPoint(T)
{
enum bool isFloatingPoint = is(FloatingPointTypeOf!T);
}
unittest
{
foreach (F; TypeTuple!(float, double, real))
{
F a = 5.5;
const F b = 5.5;
immutable F c = 5.5;
static assert(isFloatingPoint!(typeof(a)));
static assert(isFloatingPoint!(typeof(b)));
static assert(isFloatingPoint!(typeof(c)));
}
foreach (T; TypeTuple!(int, long, char))
{
T a;
const T b = 0;
immutable T c = 0;
static assert(!isFloatingPoint!(typeof(a)));
static assert(!isFloatingPoint!(typeof(b)));
static assert(!isFloatingPoint!(typeof(c)));
}
}
/**
Detect whether we can treat T as a built-in numeric type (integral or floating
point).
*/
template isNumeric(T)
{
enum bool isNumeric = is(NumericTypeOf!T);
}
/**
Detect whether T is a scalar type.
*/
template isScalarType(T)
{
enum bool isScalarType = isNumeric!T || isSomeChar!T || isBoolean!T;
}
unittest
{
static assert(!isScalarType!void);
static assert( isScalarType!(immutable(int)));
static assert( isScalarType!(shared(float)));
static assert( isScalarType!(shared(const bool)));
static assert( isScalarType!(const(dchar)));
}
/**
Detect whether T is a basic type.
*/
template isBasicType(T)
{
enum bool isBasicType = isScalarType!T || is(T == void);
}
unittest
{
static assert(isBasicType!void);
static assert(isBasicType!(immutable(int)));
static assert(isBasicType!(shared(float)));
static assert(isBasicType!(shared(const bool)));
static assert(isBasicType!(const(dchar)));
}
/**
Detect whether $(D T) is a built-in unsigned numeric type.
*/
template isUnsigned(T)
{
enum bool isUnsigned = is(UnsignedTypeOf!T);
}
/**
Detect whether $(D T) is a built-in signed numeric type.
*/
template isSigned(T)
{
enum bool isSigned = is(SignedTypeOf!T);
}
/**
Detect whether we can treat T as one of the built-in character types.
*/
template isSomeChar(T)
{
enum isSomeChar = is(CharTypeOf!T);
}
unittest
{
static assert( isSomeChar!(char));
static assert( isSomeChar!(dchar));
static assert( isSomeChar!(immutable(char)));
static assert(!isSomeChar!(int));
static assert(!isSomeChar!(int));
static assert(!isSomeChar!(byte));
static assert(!isSomeChar!(string));
static assert(!isSomeChar!(wstring));
static assert(!isSomeChar!(dstring));
static assert(!isSomeChar!(char[4]));
}
/**
Detect whether we can treat T as one of the built-in string types.
*/
template isSomeString(T)
{
static if (is(T == enum))
{
enum isSomeString = false;
}
else static if (is(T == typeof(null)))
{
// It is impossible to determine exact string type from typeof(null) -
// it means that StringTypeOf!(typeof(null)) is undefined.
// Then this behavior is convenient for template constraint.
enum isSomeString = false;
}
else
enum isSomeString = isNarrowString!T || is(T : const(dchar[]));
}
unittest
{
static assert( isSomeString!(char[]));
static assert( isSomeString!(dchar[]));
static assert( isSomeString!(string));
static assert( isSomeString!(wstring));
static assert( isSomeString!(dstring));
static assert( isSomeString!(char[4]));
static assert(!isSomeString!(int));
static assert(!isSomeString!(int[]));
static assert(!isSomeString!(byte[]));
static assert(!isSomeString!(typeof(null)));
}
template isNarrowString(T)
{
enum isNarrowString = is(T : const(char[])) || is(T : const(wchar[]));
}
unittest
{
static assert( isNarrowString!(char[]));
static assert( isNarrowString!(string));
static assert( isNarrowString!(wstring));
static assert( isNarrowString!(char[4]));
static assert(!isNarrowString!(int));
static assert(!isNarrowString!(int[]));
static assert(!isNarrowString!(byte[]));
static assert(!isNarrowString!(dchar[]));
static assert(!isNarrowString!(dstring));
}
/**
* Detect whether type T is a static array.
*/
template isStaticArray(T : U[N], U, size_t N)
{
enum bool isStaticArray = true;
}
template isStaticArray(T)
{
enum bool isStaticArray = false;
}
unittest
{
static assert( isStaticArray!(int[51]));
static assert( isStaticArray!(int[][2]));
static assert( isStaticArray!(char[][int][11]));
static assert( isStaticArray!(immutable char[13u]));
static assert( isStaticArray!(const(real)[1]));
static assert( isStaticArray!(const(real)[1][1]));
static assert( isStaticArray!(void[0]));
static assert(!isStaticArray!(const(int)[]));
static assert(!isStaticArray!(immutable(int)[]));
static assert(!isStaticArray!(const(int)[4][]));
static assert(!isStaticArray!(int[]));
static assert(!isStaticArray!(int[char]));
static assert(!isStaticArray!(int[1][]));
static assert(!isStaticArray!(int[int]));
static assert(!isStaticArray!(int));
}
/**
* Detect whether type T is a dynamic array.
*/
template isDynamicArray(T, U = void)
{
enum bool isDynamicArray = false;
}
template isDynamicArray(T : U[], U)
{
enum bool isDynamicArray = !isStaticArray!(T);
}
unittest
{
static assert( isDynamicArray!(int[]));
static assert(!isDynamicArray!(int[5]));
static assert(!isDynamicArray!(typeof(null)));
}
/**
* Detect whether type T is an array.
*/
template isArray(T)
{
enum bool isArray = isStaticArray!(T) || isDynamicArray!(T);
}
unittest
{
static assert( isArray!(int[]));
static assert( isArray!(int[5]));
static assert( isArray!(void[]));
static assert(!isArray!(uint));
static assert(!isArray!(uint[uint]));
static assert(!isArray!(typeof(null)));
}
/**
* Detect whether T is an associative array type
*/
template isAssociativeArray(T)
{
enum bool isAssociativeArray = is(AssocArrayTypeOf!T);
}
unittest
{
struct Foo
{
@property uint[] keys() { return null; }
@property uint[] values() { return null; }
}
static assert( isAssociativeArray!(int[int]));
static assert( isAssociativeArray!(int[string]));
static assert( isAssociativeArray!(immutable(char[5])[int]));
static assert(!isAssociativeArray!(Foo));
static assert(!isAssociativeArray!(int));
static assert(!isAssociativeArray!(int[]));
static assert(!isAssociativeArray!(typeof(null)));
}
template isBuiltinType(T)
{
enum isBuiltinType = is(BuiltinTypeOf!T);
}
/**
* Detect whether type $(D T) is a pointer.
*/
template isPointer(T)
{
static if (is(T P == U*, U))
{
enum bool isPointer = true;
}
else
{
enum bool isPointer = false;
}
}
unittest
{
static assert( isPointer!(int*));
static assert( isPointer!(void*));
static assert(!isPointer!(uint));
static assert(!isPointer!(uint[uint]));
static assert(!isPointer!(char[]));
static assert(!isPointer!(typeof(null)));
}
/**
Returns the target type of a pointer.
*/
template PointerTarget(T : T*)
{
alias T PointerTarget;
}
/// $(RED Scheduled for deprecation. Please use $(LREF PointerTarget) instead.)
alias PointerTarget pointerTarget;
unittest
{
static assert( is(PointerTarget!(int*) == int));
static assert( is(PointerTarget!(long*) == long));
static assert(!is(PointerTarget!int));
}
/**
* Detect whether type $(D T) is an aggregate type.
*/
template isAggregateType(T)
{
enum isAggregateType = is(T == struct) || is(T == union) ||
is(T == class) || is(T == interface);
}
/**
* Returns $(D true) if T can be iterated over using a $(D foreach) loop with
* a single loop variable of automatically inferred type, regardless of how
* the $(D foreach) loop is implemented. This includes ranges, structs/classes
* that define $(D opApply) with a single loop variable, and builtin dynamic,
* static and associative arrays.
*/
template isIterable(T)
{
enum isIterable = is(typeof({ foreach(elem; T.init) {} }));
}
unittest
{
struct OpApply
{
int opApply(int delegate(ref uint) dg) { assert(0); }
}
struct Range
{
@property uint front() { assert(0); }
void popFront() { assert(0); }
enum bool empty = false;
}
static assert( isIterable!(uint[]));
static assert( isIterable!(OpApply));
static assert( isIterable!(uint[string]));
static assert( isIterable!(Range));
static assert(!isIterable!(uint));
}
/*
* Returns true if T is not const or immutable. Note that isMutable is true for
* string, or immutable(char)[], because the 'head' is mutable.
*/
template isMutable(T)
{
enum isMutable = !is(T == const) && !is(T == immutable) && !is(T == inout);
}
unittest
{
static assert( isMutable!int);
static assert( isMutable!string);
static assert( isMutable!(shared int));
static assert( isMutable!(shared const(int)[]));
static assert(!isMutable!(const int));
static assert(!isMutable!(inout int));
static assert(!isMutable!(shared(const int)));
static assert(!isMutable!(shared(inout int)));
static assert(!isMutable!(immutable string));
}
/**
* Tells whether the tuple T is an expression tuple.
*/
template isExpressionTuple(T ...)
{
static if (T.length > 0)
enum bool isExpressionTuple =
!is(T[0]) && __traits(compiles, { auto ex = T[0]; }) &&
isExpressionTuple!(T[1 .. $]);
else
enum bool isExpressionTuple = true; // default
}
unittest
{
void foo();
static int bar() { return 42; }
enum aa = [ 1: -1 ];
alias int myint;
static assert( isExpressionTuple!(42));
static assert( isExpressionTuple!(aa));
static assert( isExpressionTuple!("cattywampus", 2.7, aa));
static assert( isExpressionTuple!(bar()));
static assert(!isExpressionTuple!(isExpressionTuple));
static assert(!isExpressionTuple!(foo));
static assert(!isExpressionTuple!( (a) { } ));
static assert(!isExpressionTuple!(int));
static assert(!isExpressionTuple!(myint));
}
/**
Detect whether tuple $(D T) is a type tuple.
*/
template isTypeTuple(T...)
{
static if (T.length > 0)
enum bool isTypeTuple = is(T[0]) && isTypeTuple!(T[1 .. $]);
else
enum bool isTypeTuple = true; // default
}
unittest
{
class C {}
void func(int) {}
auto c = new C;
enum CONST = 42;
static assert( isTypeTuple!(int));
static assert( isTypeTuple!(string));
static assert( isTypeTuple!(C));
static assert( isTypeTuple!(typeof(func)));
static assert( isTypeTuple!(int, char, double));
static assert(!isTypeTuple!(c));
static assert(!isTypeTuple!(isTypeTuple));
static assert(!isTypeTuple!(CONST));
}
/**
Detect whether symbol or type $(D T) is a function pointer.
*/
template isFunctionPointer(T...)
if (T.length == 1)
{
static if (is(T[0] U) || is(typeof(T[0]) U))
{
static if (is(U F : F*) && is(F == function))
enum bool isFunctionPointer = true;
else
enum bool isFunctionPointer = false;
}
else
enum bool isFunctionPointer = false;
}
unittest
{
static void foo() {}
void bar() {}
auto fpfoo = &foo;
static assert( isFunctionPointer!(fpfoo));
static assert( isFunctionPointer!(void function()));
auto dgbar = &bar;
static assert(!isFunctionPointer!(dgbar));
static assert(!isFunctionPointer!(void delegate()));
static assert(!isFunctionPointer!(foo));
static assert(!isFunctionPointer!(bar));
static assert( isFunctionPointer!((int a) {}));
}
/**
Detect whether $(D T) is a delegate.
*/
template isDelegate(T...)
if(T.length == 1)
{
enum bool isDelegate = is(T[0] == delegate);
}
unittest
{
static assert( isDelegate!(void delegate()));
static assert( isDelegate!(uint delegate(uint)));
static assert( isDelegate!(shared uint delegate(uint)));
static assert(!isDelegate!(uint));
static assert(!isDelegate!(void function()));
}
/**
Detect whether symbol or type $(D T) is a function, a function pointer or a delegate.
*/
template isSomeFunction(T...)
if (T.length == 1)
{
static if (is(typeof(& T[0]) U : U*) && is(U == function) || is(typeof(& T[0]) U == delegate))
{
// T is a (nested) function symbol.
enum bool isSomeFunction = true;
}
else static if (is(T[0] W) || is(typeof(T[0]) W))
{
// T is an expression or a type. Take the type of it and examine.
static if (is(W F : F*) && is(F == function))
enum bool isSomeFunction = true; // function pointer
else
enum bool isSomeFunction = is(W == function) || is(W == delegate);
}
else
enum bool isSomeFunction = false;
}
unittest
{
static real func(ref int) { return 0; }
static void prop() @property { }
void nestedFunc() { }
void nestedProp() @property { }
class C
{
real method(ref int) { return 0; }
real prop() @property { return 0; }
}
auto c = new C;
auto fp = &func;
auto dg = &c.method;
real val;
static assert( isSomeFunction!(func));
static assert( isSomeFunction!(prop));
static assert( isSomeFunction!(nestedFunc));
static assert( isSomeFunction!(nestedProp));
static assert( isSomeFunction!(C.method));
static assert( isSomeFunction!(C.prop));
static assert( isSomeFunction!(c.prop));
static assert( isSomeFunction!(c.prop));
static assert( isSomeFunction!(fp));
static assert( isSomeFunction!(dg));
static assert( isSomeFunction!(typeof(func)));
static assert( isSomeFunction!(real function(ref int)));
static assert( isSomeFunction!(real delegate(ref int)));
static assert( isSomeFunction!((int a) { return a; }));
static assert(!isSomeFunction!(int));
static assert(!isSomeFunction!(val));
static assert(!isSomeFunction!(isSomeFunction));
}
/**
Detect whether $(D T) is a callable object, which can be called with the
function call operator $(D $(LPAREN)...$(RPAREN)).
*/
template isCallable(T...)
if (T.length == 1)
{
static if (is(typeof(& T[0].opCall) == delegate))
// T is a object which has a member function opCall().
enum bool isCallable = true;
else static if (is(typeof(& T[0].opCall) V : V*) && is(V == function))
// T is a type which has a static member function opCall().
enum bool isCallable = true;
else
enum bool isCallable = isSomeFunction!(T);
}
unittest
{
interface I { real value() @property; }
struct S { static int opCall(int) { return 0; } }
class C { int opCall(int) { return 0; } }
auto c = new C;
static assert( isCallable!(c));
static assert( isCallable!(S));
static assert( isCallable!(c.opCall));
static assert( isCallable!(I.value));
static assert( isCallable!((int a) { return a; }));
static assert(!isCallable!(I));
}
/**
Exactly the same as the builtin traits:
$(D ___traits(_isAbstractFunction, method)).
*/
template isAbstractFunction(method...)
if (method.length == 1)
{
enum bool isAbstractFunction = __traits(isAbstractFunction, method[0]);
}
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
// General Types
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
/**
Removes all qualifiers, if any, from type $(D T).
Example:
----
static assert(is(Unqual!(int) == int));
static assert(is(Unqual!(const int) == int));
static assert(is(Unqual!(immutable int) == int));
static assert(is(Unqual!(shared int) == int));
static assert(is(Unqual!(shared(const int)) == int));
----
*/
template Unqual(T)
{
version (none) // Error: recursive alias declaration @@@BUG1308@@@
{
static if (is(T U == const U)) alias Unqual!U Unqual;
else static if (is(T U == immutable U)) alias Unqual!U Unqual;
else static if (is(T U == inout U)) alias Unqual!U Unqual;
else static if (is(T U == shared U)) alias Unqual!U Unqual;
else alias T Unqual;
}
else // workaround
{
static if (is(T U == shared(const U))) alias U Unqual;
else static if (is(T U == const U )) alias U Unqual;
else static if (is(T U == immutable U )) alias U Unqual;
else static if (is(T U == inout U )) alias U Unqual;
else static if (is(T U == shared U )) alias U Unqual;
else alias T Unqual;
}
}
unittest
{
static assert(is(Unqual!(int) == int));
static assert(is(Unqual!(const int) == int));
static assert(is(Unqual!(immutable int) == int));
static assert(is(Unqual!(inout int) == int));
static assert(is(Unqual!(shared int) == int));
static assert(is(Unqual!(shared(const int)) == int));
alias immutable(int[]) ImmIntArr;
static assert(is(Unqual!(ImmIntArr) == immutable(int)[]));
}
// [For internal use]
private template ModifyTypePreservingSTC(alias Modifier, T)
{
static if (is(T U == shared(const U))) alias shared(const Modifier!U) ModifyTypePreservingSTC;
else static if (is(T U == const U )) alias const(Modifier!U) ModifyTypePreservingSTC;
else static if (is(T U == immutable U )) alias immutable(Modifier!U) ModifyTypePreservingSTC;
else static if (is(T U == shared U )) alias shared(Modifier!U) ModifyTypePreservingSTC;
else alias Modifier!T ModifyTypePreservingSTC;
}
unittest
{
static assert(is(ModifyTypePreservingSTC!(Intify, const real) == const int));
static assert(is(ModifyTypePreservingSTC!(Intify, immutable real) == immutable int));
static assert(is(ModifyTypePreservingSTC!(Intify, shared real) == shared int));
static assert(is(ModifyTypePreservingSTC!(Intify, shared(const real)) == shared(const int)));
}
version (unittest) private template Intify(T) { alias int Intify; }
/**
Returns the inferred type of the loop variable when a variable of type T
is iterated over using a $(D foreach) loop with a single loop variable and
automatically inferred return type. Note that this may not be the same as
$(D std.range.ElementType!(Range)) in the case of narrow strings, or if T
has both opApply and a range interface.
*/
template ForeachType(T)
{
alias ReturnType!(typeof(
(inout int x = 0)
{
foreach(elem; T.init)
{
return elem;
}
assert(0);
})) ForeachType;
}
unittest
{
static assert(is(ForeachType!(uint[]) == uint));
static assert(is(ForeachType!(string) == immutable(char)));
static assert(is(ForeachType!(string[string]) == string));
static assert(is(ForeachType!(inout(int)[]) == inout(int)));
}
/**
Strips off all $(D typedef)s (including $(D enum) ones) from type $(D T).
Example:
--------------------
enum E : int { a }
typedef E F;
typedef const F G;
static assert(is(OriginalType!G == const int));
--------------------
*/
template OriginalType(T)
{
template Impl(T)
{
static if (is(T U == typedef)) alias OriginalType!U Impl;
else static if (is(T U == enum)) alias OriginalType!U Impl;
else alias T Impl;
}
alias ModifyTypePreservingSTC!(Impl, T) OriginalType;
}
unittest
{
//typedef real T;
//typedef T U;
//enum V : U { a }
//static assert(is(OriginalType!T == real));
//static assert(is(OriginalType!U == real));
//static assert(is(OriginalType!V == real));
enum E : real { a }
enum F : E { a = E.a }
//typedef const F G;
static assert(is(OriginalType!E == real));
static assert(is(OriginalType!F == real));
//static assert(is(OriginalType!G == const real));
}
/**
* Get the Key type of an Associative Array.
* Example:
* ---
* import std.traits;
* alias int[string] Hash;
* static assert(is(KeyType!Hash == string));
* KeyType!Hash str = "string"; // str is declared as string
* ---
*/
template KeyType(V : V[K], K)
{
alias K KeyType;
}
/**
* Get the Value type of an Associative Array.
* Example:
* ---
* import std.traits;
* alias int[string] Hash;
* static assert(is(ValueType!Hash == int));
* ValueType!Hash num = 1; // num is declared as int
* ---
*/
template ValueType(V : V[K], K)
{
alias V ValueType;
}
unittest
{
alias int[string] Hash;
static assert(is(KeyType!Hash == string));
static assert(is(ValueType!Hash == int));
KeyType!Hash str = "a";
ValueType!Hash num = 1;
}
/**
* Returns the corresponding unsigned type for T. T must be a numeric
* integral type, otherwise a compile-time error occurs.
*/
template Unsigned(T)
{
template Impl(T)
{
static if (is(UnsignedTypeOf!T X))
alias X Impl;
else static if (is(SignedTypeOf!T X))
{
static if (is(X == byte )) alias ubyte Impl;
static if (is(X == short)) alias ushort Impl;
static if (is(X == int )) alias uint Impl;
static if (is(X == long )) alias ulong Impl;
}
else
static assert(false, "Type " ~ T.stringof ~
" does not have an Unsigned counterpart");
}
alias ModifyTypePreservingSTC!(Impl, OriginalType!T) Unsigned;
}
unittest
{
alias Unsigned!(int) U1;
alias Unsigned!(const(int)) U2;
alias Unsigned!(immutable(int)) U3;
static assert(is(U1 == uint));
static assert(is(U2 == const(uint)));
static assert(is(U3 == immutable(uint)));
//struct S {}
//alias Unsigned!(S) U2;
//alias Unsigned!(double) U3;
}
/**
Returns the largest type, i.e. T such that T.sizeof is the largest. If more
than one type is of the same size, the leftmost argument of these in will be
returned.
*/
template Largest(T...) if(T.length >= 1)
{
static if (T.length == 1)
{
alias T[0] Largest;
}
else static if (T.length == 2)
{
static if(T[0].sizeof >= T[1].sizeof)
{
alias T[0] Largest;
}
else
{
alias T[1] Largest;
}
}
else
{
alias Largest!(Largest!(T[0], T[1]), T[2..$]) Largest;
}
}
unittest
{
static assert(is(Largest!(uint, ubyte, ulong, real) == real));
static assert(is(Largest!(ulong, double) == ulong));
static assert(is(Largest!(double, ulong) == double));
static assert(is(Largest!(uint, byte, double, short) == double));
}
/**
Returns the corresponding signed type for T. T must be a numeric integral type,
otherwise a compile-time error occurs.
*/
template Signed(T)
{
template Impl(T)
{
static if (is(SignedTypeOf!T X))
alias X Impl;
else static if (is(UnsignedTypeOf!T X))
{
static if (is(X == ubyte )) alias byte Impl;
static if (is(X == ushort)) alias short Impl;
static if (is(X == uint )) alias int Impl;
static if (is(X == ulong )) alias long Impl;
}
else
static assert(false, "Type " ~ T.stringof ~
" does not have an Signed counterpart");
}
alias ModifyTypePreservingSTC!(Impl, OriginalType!T) Signed;
}
unittest
{
alias Signed!(uint) S1;
alias Signed!(const(uint)) S2;
alias Signed!(immutable(uint)) S3;
static assert(is(S1 == int));
static assert(is(S2 == const(int)));
static assert(is(S3 == immutable(int)));
}
/**
* Returns the corresponding unsigned value for $(D x), e.g. if $(D x)
* has type $(D int), returns $(D cast(uint) x). The advantage
* compared to the cast is that you do not need to rewrite the cast if
* $(D x) later changes type to e.g. $(D long).
*/
auto unsigned(T)(T x) if (isIntegral!T)
{
static if (is(Unqual!T == byte )) return cast(ubyte ) x;
else static if (is(Unqual!T == short)) return cast(ushort) x;
else static if (is(Unqual!T == int )) return cast(uint ) x;
else static if (is(Unqual!T == long )) return cast(ulong ) x;
else
{
static assert(T.min == 0, "Bug in either unsigned or isIntegral");
return cast(Unqual!T) x;
}
}
unittest
{
foreach(T; TypeTuple!(byte, ubyte))
{
static assert(is(typeof(unsigned(cast(T)1)) == ubyte));
static assert(is(typeof(unsigned(cast(const T)1)) == ubyte));
static assert(is(typeof(unsigned(cast(immutable T)1)) == ubyte));
}
foreach(T; TypeTuple!(short, ushort))
{
static assert(is(typeof(unsigned(cast(T)1)) == ushort));
static assert(is(typeof(unsigned(cast(const T)1)) == ushort));
static assert(is(typeof(unsigned(cast(immutable T)1)) == ushort));
}
foreach(T; TypeTuple!(int, uint))
{
static assert(is(typeof(unsigned(cast(T)1)) == uint));
static assert(is(typeof(unsigned(cast(const T)1)) == uint));
static assert(is(typeof(unsigned(cast(immutable T)1)) == uint));
}
foreach(T; TypeTuple!(long, ulong))
{
static assert(is(typeof(unsigned(cast(T)1)) == ulong));
static assert(is(typeof(unsigned(cast(const T)1)) == ulong));
static assert(is(typeof(unsigned(cast(immutable T)1)) == ulong));
}
}
auto unsigned(T)(T x) if (isSomeChar!T)
{
// All characters are unsigned
static assert(T.min == 0);
return cast(Unqual!T) x;
}
unittest
{
foreach(T; TypeTuple!(char, wchar, dchar))
{
static assert(is(typeof(unsigned(cast(T)'A')) == T));
static assert(is(typeof(unsigned(cast(const T)'A')) == T));
static assert(is(typeof(unsigned(cast(immutable T)'A')) == T));
}
}
/**
Returns the most negative value of the numeric type T.
*/
template mostNegative(T)
if(isNumeric!T || isSomeChar!T)
{
static if (is(typeof(T.min_normal)))
enum mostNegative = -T.max;
else static if (T.min == 0)
enum byte mostNegative = 0;
else
enum mostNegative = T.min;
}
unittest
{
static assert(mostNegative!float == -float.max);
static assert(mostNegative!double == -double.max);
static assert(mostNegative!real == -real.max);
foreach(T; TypeTuple!(byte, short, int, long))
static assert(mostNegative!T == T.min);
foreach(T; TypeTuple!(ubyte, ushort, uint, ulong, char, wchar, dchar))
static assert(mostNegative!T == 0);
}
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
// Misc.
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
/**
Returns the mangled name of symbol or type $(D sth).
$(D mangledName) is the same as builtin $(D .mangleof) property, except that
the correct names of property functions are obtained.
--------------------
module test;
import std.traits : mangledName;
class C
{
int value() @property;
}
pragma(msg, C.value.mangleof); // prints "i"
pragma(msg, mangledName!(C.value)); // prints "_D4test1C5valueMFNdZi"
--------------------
*/
template mangledName(sth...)
if (sth.length == 1)
{
static if (is(typeof(sth[0]) X) && is(X == void))
{
// sth[0] is a template symbol
enum string mangledName = removeDummyEnvelope(Dummy!(sth).Hook.mangleof);
}
else
{
enum string mangledName = sth[0].mangleof;
}
}
private template Dummy(T...) { struct Hook {} }
private string removeDummyEnvelope(string s)
{
// remove --> S3std6traits ... Z4Hook
s = s[12 .. $ - 6];
// remove --> DIGIT+ __T5Dummy
foreach (i, c; s)
{
if (c < '0' || '9' < c)
{
s = s[i .. $];
break;
}
}
s = s[9 .. $]; // __T5Dummy
// remove --> T | V | S
immutable kind = s[0];
s = s[1 .. $];
if (kind == 'S') // it's a symbol
{
/*
* The mangled symbol name is packed in LName --> Number Name. Here
* we are chopping off the useless preceding Number, which is the
* length of Name in decimal notation.
*
* NOTE: n = m + Log(m) + 1; n = LName.length, m = Name.length.
*/
immutable n = s.length;
size_t m_upb = 10;
foreach (k; 1 .. 5) // k = Log(m_upb)
{
if (n < m_upb + k + 1)
{
// Now m_upb/10 <= m < m_upb; hence k = Log(m) + 1.
s = s[k .. $];
break;
}
m_upb *= 10;
}
}
return s;
}
unittest
{
//typedef int MyInt;
//MyInt test() { return 0; }
//static assert(mangledName!(MyInt)[$ - 7 .. $] == "T5MyInt"); // XXX depends on bug 4237
//static assert(mangledName!(test)[$ - 7 .. $] == "T5MyInt");
class C { int value() @property { return 0; } }
static assert(mangledName!(int) == int.mangleof);
static assert(mangledName!(C) == C.mangleof);
static assert(mangledName!(C.value)[$ - 12 .. $] == "5valueMFNdZi");
static assert(mangledName!(mangledName) == "3std6traits11mangledName");
static assert(mangledName!(removeDummyEnvelope) ==
"_D3std6traits19removeDummyEnvelopeFAyaZAya");
int x;
static assert(mangledName!((int a) { return a+x; }) == "DFNbNfiZi"); // nothrow safe
}
unittest
{
// Test for bug 5718
import std.demangle;
int foo;
assert(demangle(mangledName!foo)[$-7 .. $] == "int foo");
void bar(){}
assert(demangle(mangledName!bar)[$-10 .. $] == "void bar()");
}
// XXX Select & select should go to another module. (functional or algorithm?)
/**
Aliases itself to $(D T) if the boolean $(D condition) is $(D true)
and to $(D F) otherwise.
Example:
----
alias Select!(size_t.sizeof == 4, int, long) Int;
----
*/
template Select(bool condition, T, F)
{
static if (condition) alias T Select;
else alias F Select;
}
unittest
{
static assert(is(Select!(true, int, long) == int));
static assert(is(Select!(false, int, long) == long));
}
/**
If $(D cond) is $(D true), returns $(D a) without evaluating $(D
b). Otherwise, returns $(D b) without evaluating $(D a).
*/
A select(bool cond : true, A, B)(A a, lazy B b) { return a; }
/// Ditto
B select(bool cond : false, A, B)(lazy A a, B b) { return b; }
unittest
{
real pleasecallme() { return 0; }
int dontcallme() { assert(0); }
auto a = select!true(pleasecallme(), dontcallme());
auto b = select!false(dontcallme(), pleasecallme());
static assert(is(typeof(a) == real));
static assert(is(typeof(b) == real));
}
|
D
|
/**
* Windows API header module
*
* Translated from MinGW Windows headers
*
* Authors: Stewart Gordon
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(DRUNTIMESRC core/sys/windows/_wincrypt.d)
*/
module core.sys.windows.wincrypt;
version (Windows):
pragma(lib, "advapi32");
version (ANSI) {} else version = Unicode;
import core.sys.windows.w32api, core.sys.windows.winbase, core.sys.windows.windef;
/* FIXME:
* Types of some constants
* Types of macros
* Inits of various "size" and "version" members
* Why are some #ifdefs commented out?
*/
const TCHAR[]
MS_DEF_PROV = "Microsoft Base Cryptographic Provider v1.0",
MS_ENHANCED_PROV = "Microsoft Enhanced Cryptographic Provider v1.0",
MS_STRONG_PROV = "Microsoft Strong Cryptographic Provider",
MS_DEF_RSA_SIG_PROV = "Microsoft RSA Signature Cryptographic Provider",
MS_DEF_RSA_SCHANNEL_PROV = "Microsoft RSA SChannel Cryptographic Provider",
MS_DEF_DSS_PROV = "Microsoft Base DSS Cryptographic Provider",
MS_DEF_DSS_DH_PROV
= "Microsoft Base DSS and Diffie-Hellman Cryptographic Provider",
MS_ENH_DSS_DH_PROV
= "Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider",
MS_DEF_DH_SCHANNEL_PROV = "Microsoft DH SChannel Cryptographic Provider",
MS_SCARD_PROV = "Microsoft Base Smart Card Crypto Provider";
static if (_WIN32_WINNT > 0x501) {
const TCHAR[] MS_ENH_RSA_AES_PROV
= "Microsoft Enhanced RSA and AES Cryptographic Provider";
} else static if (_WIN32_WINNT == 0x501) {
const TCHAR[] MS_ENH_RSA_AES_PROV
= "Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)";
}
ALG_ID GET_ALG_CLASS(ALG_ID x) { return x & 0xE000; }
ALG_ID GET_ALG_TYPE (ALG_ID x) { return x & 0x1E00; }
ALG_ID GET_ALG_SID (ALG_ID x) { return x & 0x01FF; }
enum : ALG_ID {
ALG_CLASS_ANY = 0,
ALG_CLASS_SIGNATURE = 0x2000,
ALG_CLASS_MSG_ENCRYPT = 0x4000,
ALG_CLASS_DATA_ENCRYPT = 0x6000,
ALG_CLASS_HASH = 0x8000,
ALG_CLASS_KEY_EXCHANGE = 0xA000,
ALG_CLASS_ALL = 0xE000
}
enum : ALG_ID {
ALG_TYPE_ANY = 0,
ALG_TYPE_DSS = 0x0200,
ALG_TYPE_RSA = 0x0400,
ALG_TYPE_BLOCK = 0x0600,
ALG_TYPE_STREAM = 0x0800,
ALG_TYPE_DH = 0x0A00,
ALG_TYPE_SECURECHANNEL = 0x0C00
}
enum : ALG_ID {
ALG_SID_ANY = 0,
ALG_SID_RSA_ANY = 0,
ALG_SID_RSA_PKCS,
ALG_SID_RSA_MSATWORK,
ALG_SID_RSA_ENTRUST,
ALG_SID_RSA_PGP, // = 4
ALG_SID_DSS_ANY = 0,
ALG_SID_DSS_PKCS,
ALG_SID_DSS_DMS, // = 2
ALG_SID_DES = 1,
ALG_SID_3DES = 3,
ALG_SID_DESX,
ALG_SID_IDEA,
ALG_SID_CAST,
ALG_SID_SAFERSK64,
ALG_SID_SAFERSK128,
ALG_SID_3DES_112,
ALG_SID_SKIPJACK,
ALG_SID_TEK,
ALG_SID_CYLINK_MEK,
ALG_SID_RC5, // = 13
ALG_SID_RC2 = 2,
ALG_SID_RC4 = 1,
ALG_SID_SEAL = 2,
ALG_SID_MD2 = 1,
ALG_SID_MD4,
ALG_SID_MD5,
ALG_SID_SHA,
ALG_SID_MAC,
ALG_SID_RIPEMD,
ALG_SID_RIPEMD160,
ALG_SID_SSL3SHAMD5,
ALG_SID_HMAC,
ALG_SID_TLS1PRF, // = 10
ALG_SID_AES_128 = 14,
ALG_SID_AES_192,
ALG_SID_AES_256,
ALG_SID_AES, // = 17
ALG_SID_EXAMPLE = 80
}
enum : ALG_ID {
CALG_MD2 = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD2,
CALG_MD4 = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD4,
CALG_MD5 = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD5,
CALG_SHA = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA,
CALG_SHA1 = CALG_SHA,
CALG_MAC = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MAC,
CALG_3DES = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | 3,
CALG_CYLINK_MEK = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | 12,
CALG_SKIPJACK = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | 10,
CALG_KEA_KEYX = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_STREAM | ALG_TYPE_DSS | 4,
CALG_RSA_SIGN = ALG_CLASS_SIGNATURE | ALG_TYPE_RSA | ALG_SID_RSA_ANY,
CALG_DSS_SIGN = ALG_CLASS_SIGNATURE | ALG_TYPE_DSS | ALG_SID_DSS_ANY,
CALG_RSA_KEYX = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_RSA | ALG_SID_RSA_ANY,
CALG_DES = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_DES,
CALG_RC2 = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_RC2,
CALG_RC4 = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM | ALG_SID_RC4,
CALG_SEAL = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM | ALG_SID_SEAL,
CALG_DH_EPHEM = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_STREAM | ALG_TYPE_DSS
| ALG_SID_DSS_DMS,
CALG_DESX = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_DESX,
// is undefined ALG_CLASS_DHASH in MinGW - presuming typo
CALG_TLS1PRF = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_TLS1PRF,
CALG_AES_128 = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_128,
CALG_AES_192 = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_192,
CALG_AES_256 = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_256,
CALG_AES = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES,
}
enum {
CRYPT_VERIFYCONTEXT = 0xF0000000,
}
enum {
CRYPT_NEWKEYSET = 8,
CRYPT_DELETEKEYSET = 16,
CRYPT_MACHINE_KEYSET = 32,
CRYPT_SILENT = 64,
}
enum {
CRYPT_EXPORTABLE = 1,
CRYPT_USER_PROTECTED = 2,
CRYPT_CREATE_SALT = 4,
CRYPT_UPDATE_KEY = 8,
}
enum {
SIMPLEBLOB = 1,
PUBLICKEYBLOB = 6,
PRIVATEKEYBLOB = 7,
PLAINTEXTKEYBLOB = 8,
OPAQUEKEYBLOB = 9,
PUBLICKEYBLOBEX = 10,
SYMMETRICWRAPKEYBLOB = 11,
}
enum {
AT_KEYEXCHANGE = 1,
AT_SIGNATURE = 2,
}
enum {
CRYPT_USERDATA = 1,
}
enum {
PKCS5_PADDING = 1,
}
enum {
CRYPT_MODE_CBC = 1,
CRYPT_MODE_ECB = 2,
CRYPT_MODE_OFB = 3,
CRYPT_MODE_CFB = 4,
CRYPT_MODE_CTS = 5,
CRYPT_MODE_CBCI = 6,
CRYPT_MODE_CFBP = 7,
CRYPT_MODE_OFBP = 8,
CRYPT_MODE_CBCOFM = 9,
CRYPT_MODE_CBCOFMI = 10,
}
enum {
CRYPT_ENCRYPT = 1,
CRYPT_DECRYPT = 2,
CRYPT_EXPORT = 4,
CRYPT_READ = 8,
CRYPT_WRITE = 16,
CRYPT_MAC = 32,
}
enum {
HP_ALGID = 1,
HP_HASHVAL = 2,
HP_HASHSIZE = 4,
HP_HMAC_INFO = 5,
}
enum {
CRYPT_FAILED = FALSE,
CRYPT_SUCCEED = TRUE,
}
bool RCRYPT_SUCCEEDED(BOOL r) { return r==CRYPT_SUCCEED; }
bool RCRYPT_FAILED(BOOL r) { return r==CRYPT_FAILED; }
enum {
PP_ENUMALGS = 1,
PP_ENUMCONTAINERS = 2,
PP_IMPTYPE = 3,
PP_NAME = 4,
PP_VERSION = 5,
PP_CONTAINER = 6,
PP_CHANGE_PASSWORD = 7,
PP_KEYSET_SEC_DESCR = 8,
PP_CERTCHAIN = 9,
PP_KEY_TYPE_SUBTYPE = 10,
PP_PROVTYPE = 16,
PP_KEYSTORAGE = 17,
PP_APPLI_CERT = 18,
PP_SYM_KEYSIZE = 19,
PP_SESSION_KEYSIZE = 20,
PP_UI_PROMPT = 21,
PP_ENUMALGS_EX = 22,
PP_ENUMMANDROOTS = 25,
PP_ENUMELECTROOTS = 26,
PP_KEYSET_TYPE = 27,
PP_ADMIN_PIN = 31,
PP_KEYEXCHANGE_PIN = 32,
PP_SIGNATURE_PIN = 33,
PP_SIG_KEYSIZE_INC = 34,
PP_KEYX_KEYSIZE_INC = 35,
PP_UNIQUE_CONTAINER = 36,
PP_SGC_INFO = 37,
PP_USE_HARDWARE_RNG = 38,
PP_KEYSPEC = 39,
PP_ENUMEX_SIGNING_PROT = 40,
}
enum {
CRYPT_FIRST = 1,
CRYPT_NEXT = 2,
}
enum {
CRYPT_IMPL_HARDWARE = 1,
CRYPT_IMPL_SOFTWARE = 2,
CRYPT_IMPL_MIXED = 3,
CRYPT_IMPL_UNKNOWN = 4,
}
enum {
PROV_RSA_FULL = 1,
PROV_RSA_SIG = 2,
PROV_DSS = 3,
PROV_FORTEZZA = 4,
PROV_MS_MAIL = 5,
PROV_SSL = 6,
PROV_STT_MER = 7,
PROV_STT_ACQ = 8,
PROV_STT_BRND = 9,
PROV_STT_ROOT = 10,
PROV_STT_ISS = 11,
PROV_RSA_SCHANNEL = 12,
PROV_DSS_DH = 13,
PROV_EC_ECDSA_SIG = 14,
PROV_EC_ECNRA_SIG = 15,
PROV_EC_ECDSA_FULL = 16,
PROV_EC_ECNRA_FULL = 17,
PROV_DH_SCHANNEL = 18,
PROV_SPYRUS_LYNKS = 20,
PROV_RNG = 21,
PROV_INTEL_SEC = 22,
PROV_RSA_AES = 24,
MAXUIDLEN = 64,
}
enum {
CUR_BLOB_VERSION = 2,
}
enum {
X509_ASN_ENCODING = 1,
PKCS_7_ASN_ENCODING = 65536,
}
enum {
CERT_V1 = 0,
CERT_V2 = 1,
CERT_V3 = 2,
}
enum {
CERT_E_CHAINING = (-2146762486),
CERT_E_CN_NO_MATCH = (-2146762481),
CERT_E_EXPIRED = (-2146762495),
CERT_E_PURPOSE = (-2146762490),
CERT_E_REVOCATION_FAILURE = (-2146762482),
CERT_E_REVOKED = (-2146762484),
CERT_E_ROLE = (-2146762493),
CERT_E_UNTRUSTEDROOT = (-2146762487),
CERT_E_UNTRUSTEDTESTROOT = (-2146762483),
CERT_E_VALIDITYPERIODNESTING = (-2146762494),
CERT_E_WRONG_USAGE = (-2146762480),
CERT_E_PATHLENCONST = (-2146762492),
CERT_E_CRITICAL = (-2146762491),
CERT_E_ISSUERCHAINING = (-2146762489),
CERT_E_MALFORMED = (-2146762488),
CRYPT_E_REVOCATION_OFFLINE = (-2146885613),
CRYPT_E_REVOKED = (-2146885616),
TRUST_E_BASIC_CONSTRAINTS = (-2146869223),
TRUST_E_CERT_SIGNATURE = (-2146869244),
TRUST_E_FAIL = (-2146762485),
}
enum {
CERT_TRUST_NO_ERROR = 0,
CERT_TRUST_IS_NOT_TIME_VALID = 1,
CERT_TRUST_IS_NOT_TIME_NESTED = 2,
CERT_TRUST_IS_REVOKED = 4,
CERT_TRUST_IS_NOT_SIGNATURE_VALID = 8,
CERT_TRUST_IS_NOT_VALID_FOR_USAGE = 16,
CERT_TRUST_IS_UNTRUSTED_ROOT = 32,
CERT_TRUST_REVOCATION_STATUS_UNKNOWN = 64,
CERT_TRUST_IS_CYCLIC = 128,
CERT_TRUST_IS_PARTIAL_CHAIN = 65536,
CERT_TRUST_CTL_IS_NOT_TIME_VALID = 131072,
CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID = 262144,
CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE = 524288,
}
enum {
CERT_TRUST_HAS_EXACT_MATCH_ISSUER = 1,
CERT_TRUST_HAS_KEY_MATCH_ISSUER = 2,
CERT_TRUST_HAS_NAME_MATCH_ISSUER = 4,
CERT_TRUST_IS_SELF_SIGNED = 8,
CERT_TRUST_IS_COMPLEX_CHAIN = 65536,
}
enum {
CERT_CHAIN_POLICY_BASE = cast(LPCSTR) 1,
CERT_CHAIN_POLICY_AUTHENTICODE = cast(LPCSTR) 2,
CERT_CHAIN_POLICY_AUTHENTICODE_TS = cast(LPCSTR) 3,
CERT_CHAIN_POLICY_SSL = cast(LPCSTR) 4,
CERT_CHAIN_POLICY_BASIC_CONSTRAINTS = cast(LPCSTR) 5,
CERT_CHAIN_POLICY_NT_AUTH = cast(LPCSTR) 6,
}
enum {
USAGE_MATCH_TYPE_AND = 0,
USAGE_MATCH_TYPE_OR = 1,
}
enum {
CERT_SIMPLE_NAME_STR = 1,
CERT_OID_NAME_STR = 2,
CERT_X500_NAME_STR = 3,
}
enum {
CERT_NAME_STR_SEMICOLON_FLAG = 1073741824,
CERT_NAME_STR_CRLF_FLAG = 134217728,
CERT_NAME_STR_NO_PLUS_FLAG = 536870912,
CERT_NAME_STR_NO_QUOTING_FLAG = 268435456,
CERT_NAME_STR_REVERSE_FLAG = 33554432,
CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG = 131072,
}
enum {
CERT_FIND_ANY = 0,
CERT_FIND_CERT_ID = 1048576,
CERT_FIND_CTL_USAGE = 655360,
CERT_FIND_ENHKEY_USAGE = 655360,
CERT_FIND_EXISTING = 851968,
CERT_FIND_HASH = 65536,
CERT_FIND_ISSUER_ATTR = 196612,
CERT_FIND_ISSUER_NAME = 131076,
CERT_FIND_ISSUER_OF = 786432,
CERT_FIND_KEY_IDENTIFIER = 983040,
CERT_FIND_KEY_SPEC = 589824,
CERT_FIND_MD5_HASH = 262144,
CERT_FIND_PROPERTY = 327680,
CERT_FIND_PUBLIC_KEY = 393216,
CERT_FIND_SHA1_HASH = 65536,
CERT_FIND_SIGNATURE_HASH = 917504,
CERT_FIND_SUBJECT_ATTR = 196615,
CERT_FIND_SUBJECT_CERT = 720896,
CERT_FIND_SUBJECT_NAME = 131079,
CERT_FIND_SUBJECT_STR_A = 458759,
CERT_FIND_SUBJECT_STR_W = 524295,
CERT_FIND_ISSUER_STR_A = 458756,
CERT_FIND_ISSUER_STR_W = 524292,
}
enum {
CERT_FIND_OR_ENHKEY_USAGE_FLAG = 16,
CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG = 1,
CERT_FIND_NO_ENHKEY_USAGE_FLAG = 8,
CERT_FIND_VALID_ENHKEY_USAGE_FLAG = 32,
CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG = 2,
}
enum {
CERT_CASE_INSENSITIVE_IS_RDN_ATTRS_FLAG = 2,
CERT_UNICODE_IS_RDN_ATTRS_FLAG = 1,
CERT_CHAIN_FIND_BY_ISSUER = 1,
}
enum {
CERT_CHAIN_FIND_BY_ISSUER_COMPARE_KEY_FLAG = 1,
CERT_CHAIN_FIND_BY_ISSUER_COMPLEX_CHAIN_FLAG = 2,
CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_URL_FLAG = 4,
CERT_CHAIN_FIND_BY_ISSUER_LOCAL_MACHINE_FLAG = 8,
CERT_CHAIN_FIND_BY_ISSUER_NO_KEY_FLAG = 16384,
CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_FLAG = 32768,
}
enum {
CERT_STORE_PROV_SYSTEM = 10,
CERT_SYSTEM_STORE_LOCAL_MACHINE = 131072,
}
enum {
szOID_PKIX_KP_SERVER_AUTH = "4235600",
szOID_SERVER_GATED_CRYPTO = "4235658",
szOID_SGC_NETSCAPE = "2.16.840.1.113730.4.1",
szOID_PKIX_KP_CLIENT_AUTH = "1.3.6.1.5.5.7.3.2",
}
enum {
CRYPT_NOHASHOID = 0x00000001,
CRYPT_NO_SALT = 0x10,
CRYPT_PREGEN = 0x40,
}
enum {
CRYPT_RECIPIENT = 0x10,
CRYPT_INITIATOR = 0x40,
CRYPT_ONLINE = 0x80,
CRYPT_SF = 0x100,
CRYPT_CREATE_IV = 0x200,
CRYPT_KEK = 0x400,
CRYPT_DATA_KEY = 0x800,
CRYPT_VOLATILE = 0x1000,
CRYPT_SGCKEY = 0x2000,
}
enum {
KP_IV = 0x00000001,
KP_SALT = 0x00000002,
KP_PADDING = 0x00000003,
KP_MODE = 0x00000004,
KP_MODE_BITS = 0x00000005,
KP_PERMISSIONS = 0x00000006,
KP_ALGID = 0x00000007,
KP_BLOCKLEN = 0x00000008,
KP_KEYLEN = 0x00000009,
KP_SALT_EX = 0x0000000a,
KP_P = 0x0000000b,
KP_G = 0x0000000c,
KP_Q = 0x0000000d,
KP_X = 0x0000000e,
KP_Y = 0x0000000f,
KP_RA = 0x00000010,
KP_RB = 0x00000011,
KP_INFO = 0x00000012,
KP_EFFECTIVE_KEYLEN = 0x00000013,
KP_SCHANNEL_ALG = 0x00000014,
KP_PUB_PARAMS = 0x00000027,
}
enum {
CRYPT_FLAG_PCT1 = 0x0001,
CRYPT_FLAG_SSL2 = 0x0002,
CRYPT_FLAG_SSL3 = 0x0004,
CRYPT_FLAG_TLS1 = 0x0008,
CRYPT_FLAG_IPSEC = 0x0010,
CRYPT_FLAG_SIGNING = 0x0020,
}
enum {
SCHANNEL_MAC_KEY = 0x00000000,
SCHANNEL_ENC_KEY = 0x00000001,
}
enum {
INTERNATIONAL_USAGE = 0x00000001,
}
alias UINT ALG_ID;
alias ULONG_PTR HCRYPTPROV, HCRYPTKEY, HCRYPTHASH;
alias PVOID HCERTSTORE, HCRYPTMSG, HCERTCHAINENGINE;
struct VTableProvStruc {
FARPROC FuncVerifyImage;
}
alias VTableProvStruc* PVTableProvStruc;
struct _CRYPTOAPI_BLOB {
DWORD cbData;
BYTE* pbData;
}
alias _CRYPTOAPI_BLOB CRYPT_INTEGER_BLOB, CRYPT_UINT_BLOB,
CRYPT_OBJID_BLOB, CERT_NAME_BLOB, CERT_RDN_VALUE_BLOB, CERT_BLOB,
CRL_BLOB, DATA_BLOB, CRYPT_DATA_BLOB, CRYPT_HASH_BLOB,
CRYPT_DIGEST_BLOB, CRYPT_DER_BLOB, CRYPT_ATTR_BLOB;
alias _CRYPTOAPI_BLOB* PCRYPT_INTEGER_BLOB, PCRYPT_UINT_BLOB,
PCRYPT_OBJID_BLOB, PCERT_NAME_BLOB, PCERT_RDN_VALUE_BLOB, PCERT_BLOB,
PCRL_BLOB, PDATA_BLOB, PCRYPT_DATA_BLOB, PCRYPT_HASH_BLOB,
PCRYPT_DIGEST_BLOB, PCRYPT_DER_BLOB, PCRYPT_ATTR_BLOB;
// not described in SDK; has the same layout as HTTPSPolicyCallbackData
struct SSL_EXTRA_CERT_CHAIN_POLICY_PARA {
DWORD cbStruct;
DWORD dwAuthType;
DWORD fdwChecks;
LPWSTR pwszServerName;
}
alias SSL_EXTRA_CERT_CHAIN_POLICY_PARA HTTPSPolicyCallbackData;
alias SSL_EXTRA_CERT_CHAIN_POLICY_PARA* PSSL_EXTRA_CERT_CHAIN_POLICY_PARA,
PHTTPSPolicyCallbackData;
/* #if (_WIN32_WINNT>=0x500) */
struct CERT_CHAIN_POLICY_PARA {
DWORD cbSize = CERT_CHAIN_POLICY_PARA.sizeof;
DWORD dwFlags;
void* pvExtraPolicyPara;
}
alias CERT_CHAIN_POLICY_PARA* PCERT_CHAIN_POLICY_PARA;
struct CERT_CHAIN_POLICY_STATUS {
DWORD cbSize = CERT_CHAIN_POLICY_STATUS.sizeof;
DWORD dwError;
LONG lChainIndex;
LONG lElementIndex;
void* pvExtraPolicyStatus;
}
alias CERT_CHAIN_POLICY_STATUS* PCERT_CHAIN_POLICY_STATUS;
/* #endif */
struct CRYPT_ALGORITHM_IDENTIFIER {
LPSTR pszObjId;
CRYPT_OBJID_BLOB Parameters;
}
alias CRYPT_ALGORITHM_IDENTIFIER* PCRYPT_ALGORITHM_IDENTIFIER;
struct CRYPT_BIT_BLOB {
DWORD cbData;
BYTE* pbData;
DWORD cUnusedBits;
}
alias CRYPT_BIT_BLOB* PCRYPT_BIT_BLOB;
struct CERT_PUBLIC_KEY_INFO {
CRYPT_ALGORITHM_IDENTIFIER Algorithm;
CRYPT_BIT_BLOB PublicKey;
}
alias CERT_PUBLIC_KEY_INFO* PCERT_PUBLIC_KEY_INFO;
struct CERT_EXTENSION {
LPSTR pszObjId;
BOOL fCritical;
CRYPT_OBJID_BLOB Value;
}
alias CERT_EXTENSION* PCERT_EXTENSION;
struct CERT_INFO {
DWORD dwVersion;
CRYPT_INTEGER_BLOB SerialNumber;
CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm;
CERT_NAME_BLOB Issuer;
FILETIME NotBefore;
FILETIME NotAfter;
CERT_NAME_BLOB Subject;
CERT_PUBLIC_KEY_INFO SubjectPublicKeyInfo;
CRYPT_BIT_BLOB IssuerUniqueId;
CRYPT_BIT_BLOB SubjectUniqueId;
DWORD cExtension;
PCERT_EXTENSION rgExtension;
}
alias CERT_INFO* PCERT_INFO;
struct CERT_CONTEXT {
DWORD dwCertEncodingType;
BYTE* pbCertEncoded;
DWORD cbCertEncoded;
PCERT_INFO pCertInfo;
HCERTSTORE hCertStore;
}
alias CERT_CONTEXT* PCERT_CONTEXT;
alias const(CERT_CONTEXT)* PCCERT_CONTEXT;
struct CTL_USAGE {
DWORD cUsageIdentifier;
LPSTR* rgpszUsageIdentifier;
}
alias CTL_USAGE CERT_ENHKEY_USAGE;
alias CTL_USAGE* PCTRL_USAGE, PCERT_ENHKEY_USAGE;
struct CERT_USAGE_MATCH {
DWORD dwType;
CERT_ENHKEY_USAGE Usage;
}
alias CERT_USAGE_MATCH* PCERT_USAGE_MATCH;
/* #if (_WIN32_WINNT>=0x500) */
struct CERT_CHAIN_PARA {
DWORD cbSize = CERT_CHAIN_PARA.sizeof;
CERT_USAGE_MATCH RequestedUsage;
//#if CERT_CHAIN_PARA_HAS_EXTRA_FIELDS
CERT_USAGE_MATCH RequestedIssuancePolicy;
DWORD dwUrlRetrievalTimeout;
BOOL fCheckRevocationFreshnessTime;
DWORD dwRevocationFreshnessTime;
//#endif
}
alias CERT_CHAIN_PARA* PCERT_CHAIN_PARA;
extern (Windows) alias BOOL function(PCCERT_CONTEXT, void*)
PFN_CERT_CHAIN_FIND_BY_ISSUER_CALLBACK;
struct CERT_CHAIN_FIND_BY_ISSUER_PARA {
DWORD cbSize = CERT_CHAIN_FIND_BY_ISSUER_PARA.sizeof;
LPCSTR pszUsageIdentifier;
DWORD dwKeySpec;
DWORD dwAcquirePrivateKeyFlags;
DWORD cIssuer;
CERT_NAME_BLOB* rgIssuer;
PFN_CERT_CHAIN_FIND_BY_ISSUER_CALLBACK pfnFIndCallback;
void* pvFindArg;
DWORD* pdwIssuerChainIndex;
DWORD* pdwIssuerElementIndex;
}
alias CERT_CHAIN_FIND_BY_ISSUER_PARA* PCERT_CHAIN_FIND_BY_ISSUER_PARA;
/* #endif */
struct CERT_TRUST_STATUS {
DWORD dwErrorStatus;
DWORD dwInfoStatus;
}
alias CERT_TRUST_STATUS* PCERT_TRUST_STATUS;
struct CRL_ENTRY {
CRYPT_INTEGER_BLOB SerialNumber;
FILETIME RevocationDate;
DWORD cExtension;
PCERT_EXTENSION rgExtension;
}
alias CRL_ENTRY* PCRL_ENTRY;
struct CRL_INFO {
DWORD dwVersion;
CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm;
CERT_NAME_BLOB Issuer;
FILETIME ThisUpdate;
FILETIME NextUpdate;
DWORD cCRLEntry;
PCRL_ENTRY rgCRLEntry;
DWORD cExtension;
PCERT_EXTENSION rgExtension;
}
alias CRL_INFO* PCRL_INFO;
struct CRL_CONTEXT {
DWORD dwCertEncodingType;
BYTE* pbCrlEncoded;
DWORD cbCrlEncoded;
PCRL_INFO pCrlInfo;
HCERTSTORE hCertStore;
}
alias CRL_CONTEXT* PCRL_CONTEXT;
alias const(CRL_CONTEXT)* PCCRL_CONTEXT;
struct CERT_REVOCATION_CRL_INFO {
DWORD cbSize = CERT_REVOCATION_CRL_INFO.sizeof;
PCCRL_CONTEXT pBaseCRLContext;
PCCRL_CONTEXT pDeltaCRLContext;
PCRL_ENTRY pCrlEntry;
BOOL fDeltaCrlEntry;
}
alias CERT_REVOCATION_CRL_INFO* PCERT_REVOCATION_CRL_INFO;
struct CERT_REVOCATION_INFO {
DWORD cbSize = CERT_REVOCATION_INFO.sizeof;
DWORD dwRevocationResult;
LPCSTR pszRevocationOid;
LPVOID pvOidSpecificInfo;
BOOL fHasFreshnessTime;
DWORD dwFreshnessTime;
PCERT_REVOCATION_CRL_INFO pCrlInfo;
}
alias CERT_REVOCATION_INFO* PCERT_REVOCATION_INFO;
/* #if (_WIN32_WINNT>=0x500) */
struct CERT_CHAIN_ELEMENT {
DWORD cbSize = CERT_CHAIN_ELEMENT.sizeof;
PCCERT_CONTEXT pCertContext;
CERT_TRUST_STATUS TrustStatus;
PCERT_REVOCATION_INFO pRevocationInfo;
PCERT_ENHKEY_USAGE pIssuanceUsage;
PCERT_ENHKEY_USAGE pApplicationUsage;
}
alias CERT_CHAIN_ELEMENT* PCERT_CHAIN_ELEMENT;
/* #endif */
struct CRYPT_ATTRIBUTE {
LPSTR pszObjId;
DWORD cValue;
PCRYPT_ATTR_BLOB rgValue;
}
alias CRYPT_ATTRIBUTE* PCRYPT_ATTRIBUTE;
struct CTL_ENTRY {
CRYPT_DATA_BLOB SubjectIdentifier;
DWORD cAttribute;
PCRYPT_ATTRIBUTE rgAttribute;
}
alias CTL_ENTRY* PCTL_ENTRY;
struct CTL_INFO {
DWORD dwVersion;
CTL_USAGE SubjectUsage;
CRYPT_DATA_BLOB ListIdentifier;
CRYPT_INTEGER_BLOB SequenceNumber;
FILETIME ThisUpdate;
FILETIME NextUpdate;
CRYPT_ALGORITHM_IDENTIFIER SubjectAlgorithm;
DWORD cCTLEntry;
PCTL_ENTRY rgCTLEntry;
DWORD cExtension;
PCERT_EXTENSION rgExtension;
}
alias CTL_INFO* PCTL_INFO;
struct CTL_CONTEXT {
DWORD dwMsgAndCertEncodingType;
BYTE* pbCtlEncoded;
DWORD cbCtlEncoded;
PCTL_INFO pCtlInfo;
HCERTSTORE hCertStore;
HCRYPTMSG hCryptMsg;
BYTE* pbCtlContent;
DWORD cbCtlContent;
}
alias CTL_CONTEXT* PCTL_CONTEXT;
alias const(CTL_CONTEXT)* PCCTL_CONTEXT;
struct CERT_TRUST_LIST_INFO {
DWORD cbSize = CERT_TRUST_LIST_INFO.sizeof;
PCTL_ENTRY pCtlEntry;
PCCTL_CONTEXT pCtlContext;
}
alias CERT_TRUST_LIST_INFO* PCERT_TRUST_LIST_INFO;
struct CERT_SIMPLE_CHAIN {
DWORD cbSize = CERT_SIMPLE_CHAIN.sizeof;
CERT_TRUST_STATUS TrustStatus;
DWORD cElement;
PCERT_CHAIN_ELEMENT* rgpElement;
PCERT_TRUST_LIST_INFO pTrustListInfo;
BOOL fHasRevocationFreshnessTime;
DWORD dwRevocationFreshnessTime;
}
alias CERT_SIMPLE_CHAIN* PCERT_SIMPLE_CHAIN;
/* #if (_WIN32_WINNT>=0x500) */
alias const(CERT_CHAIN_CONTEXT)* PCCERT_CHAIN_CONTEXT;
struct CERT_CHAIN_CONTEXT {
DWORD cbSize = CERT_CHAIN_CONTEXT.sizeof;
CERT_TRUST_STATUS TrustStatus;
DWORD cChain;
PCERT_SIMPLE_CHAIN* rgpChain;
DWORD cLowerQualityChainContext;
PCCERT_CHAIN_CONTEXT* rgpLowerQualityChainContext;
BOOL fHasRevocationFreshnessTime;
DWORD dwRevocationFreshnessTime;
}
alias CERT_CHAIN_CONTEXT* PCERT_CHAIN_CONTEXT;
/* #endif */
struct PROV_ENUMALGS {
ALG_ID aiAlgid;
DWORD dwBitLen;
DWORD dwNameLen;
CHAR[20] szName = 0;
}
struct PUBLICKEYSTRUC {
BYTE bType;
BYTE bVersion;
WORD reserved;
ALG_ID aiKeyAlg;
}
alias PUBLICKEYSTRUC BLOBHEADER;
struct RSAPUBKEY {
DWORD magic;
DWORD bitlen;
DWORD pubexp;
}
struct HMAC_INFO {
ALG_ID HashAlgid;
BYTE* pbInnerString;
DWORD cbInnerString;
BYTE* pbOuterString;
DWORD cbOuterString;
}
alias HMAC_INFO* PHMAC_INFO;
extern (Windows) @nogc nothrow {
BOOL CertCloseStore(HCERTSTORE, DWORD);
BOOL CertGetCertificateChain(HCERTCHAINENGINE, PCCERT_CONTEXT, LPFILETIME,
HCERTSTORE, PCERT_CHAIN_PARA, DWORD, LPVOID, PCCERT_CHAIN_CONTEXT*);
BOOL CertVerifyCertificateChainPolicy(LPCSTR, PCCERT_CHAIN_CONTEXT,
PCERT_CHAIN_POLICY_PARA, PCERT_CHAIN_POLICY_STATUS);
void CertFreeCertificateChain(PCCERT_CHAIN_CONTEXT);
DWORD CertNameToStrA(DWORD, PCERT_NAME_BLOB, DWORD, LPSTR, DWORD);
DWORD CertNameToStrW(DWORD, PCERT_NAME_BLOB, DWORD, LPWSTR, DWORD);
HCERTSTORE CertOpenSystemStoreA(HCRYPTPROV, LPCSTR);
HCERTSTORE CertOpenSystemStoreW(HCRYPTPROV, LPCWSTR);
HCERTSTORE CertOpenStore(LPCSTR, DWORD, HCRYPTPROV, DWORD, const(void)*);
PCCERT_CONTEXT CertFindCertificateInStore(HCERTSTORE, DWORD, DWORD, DWORD,
const(void)*, PCCERT_CONTEXT);
BOOL CertFreeCertificateContext(PCCERT_CONTEXT);
PCCERT_CONTEXT CertGetIssuerCertificateFromStore(HCERTSTORE,
PCCERT_CONTEXT, PCCERT_CONTEXT, DWORD*);
PCCERT_CHAIN_CONTEXT CertFindChainInStore(HCERTSTORE, DWORD, DWORD, DWORD,
const(void)*, PCCERT_CHAIN_CONTEXT);
BOOL CryptAcquireContextA(HCRYPTPROV*, LPCSTR, LPCSTR, DWORD, DWORD);
BOOL CryptAcquireContextW(HCRYPTPROV*, LPCWSTR, LPCWSTR, DWORD, DWORD);
BOOL CryptContextAddRef(HCRYPTPROV, DWORD*, DWORD);
BOOL CryptReleaseContext(HCRYPTPROV, ULONG_PTR);
BOOL CryptGenKey(HCRYPTPROV, ALG_ID, DWORD, HCRYPTKEY*);
BOOL CryptDeriveKey(HCRYPTPROV, ALG_ID, HCRYPTHASH, DWORD, HCRYPTKEY*);
BOOL CryptDestroyKey(HCRYPTKEY);
static if (_WIN32_WINNT >= 0x500) {
BOOL CryptDuplicateHash(HCRYPTHASH, DWORD*, DWORD, HCRYPTHASH*);
BOOL CryptDuplicateKey(HCRYPTKEY, DWORD*, DWORD, HCRYPTKEY*);
}
BOOL CryptSetKeyParam(HCRYPTKEY, DWORD, PBYTE, DWORD);
BOOL CryptGetKeyParam(HCRYPTKEY, DWORD, PBYTE, PDWORD, DWORD);
BOOL CryptSetHashParam(HCRYPTHASH, DWORD, PBYTE, DWORD);
BOOL CryptGetHashParam(HCRYPTHASH, DWORD, PBYTE, PDWORD, DWORD);
BOOL CryptSetProvParam(HCRYPTPROV, DWORD, PBYTE, DWORD);
BOOL CryptGetProvParam(HCRYPTPROV, DWORD, PBYTE, PDWORD, DWORD);
BOOL CryptGenRandom(HCRYPTPROV, DWORD, PBYTE);
BOOL CryptGetUserKey(HCRYPTPROV, DWORD, HCRYPTKEY*);
BOOL CryptExportKey(HCRYPTKEY, HCRYPTKEY, DWORD, DWORD, PBYTE, PDWORD);
BOOL CryptImportKey(HCRYPTPROV, PBYTE, DWORD, HCRYPTKEY, DWORD,
HCRYPTKEY*);
BOOL CryptEncrypt(HCRYPTKEY, HCRYPTHASH, BOOL, DWORD, PBYTE, PDWORD,
DWORD);
BOOL CryptDecrypt(HCRYPTKEY, HCRYPTHASH, BOOL, DWORD, PBYTE, PDWORD);
BOOL CryptCreateHash(HCRYPTPROV, ALG_ID, HCRYPTKEY, DWORD, HCRYPTHASH*);
BOOL CryptHashData(HCRYPTHASH, PBYTE, DWORD, DWORD);
BOOL CryptHashSessionKey(HCRYPTHASH, HCRYPTKEY, DWORD);
BOOL CryptGetHashValue(HCRYPTHASH, DWORD, PBYTE, PDWORD);
BOOL CryptDestroyHash(HCRYPTHASH);
BOOL CryptSignHashA(HCRYPTHASH, DWORD, LPCSTR, DWORD, PBYTE, PDWORD);
BOOL CryptSignHashW(HCRYPTHASH, DWORD, LPCWSTR, DWORD, PBYTE, PDWORD);
BOOL CryptVerifySignatureA(HCRYPTHASH, PBYTE, DWORD, HCRYPTKEY, LPCSTR,
DWORD);
BOOL CryptVerifySignatureW(HCRYPTHASH, PBYTE, DWORD, HCRYPTKEY, LPCWSTR,
DWORD);
BOOL CryptSetProviderA(LPCSTR, DWORD);
BOOL CryptSetProviderW(LPCWSTR, DWORD);
}
version (Unicode) {
alias CertNameToStrW CertNameToStr;
alias CryptAcquireContextW CryptAcquireContext;
alias CryptSignHashW CryptSignHash;
alias CryptVerifySignatureW CryptVerifySignature;
alias CryptSetProviderW CryptSetProvider;
alias CertOpenSystemStoreW CertOpenSystemStore;
/+alias CERT_FIND_SUBJECT_STR_W CERT_FIND_SUBJECT_STR;
alias CERT_FIND_ISSUER_STR_W CERT_FIND_ISSUER_STR;+/
} else {
alias CertNameToStrA CertNameToStr;
alias CryptAcquireContextA CryptAcquireContext;
alias CryptSignHashA CryptSignHash;
alias CryptVerifySignatureA CryptVerifySignature;
alias CryptSetProviderA CryptSetProvider;
alias CertOpenSystemStoreA CertOpenSystemStore;
/+alias CERT_FIND_SUBJECT_STR_A CERT_FIND_SUBJECT_STR;
alias CERT_FIND_ISSUER_STR_A CERT_FIND_ISSUER_STR;+/
}
|
D
|
instance BAU_912_Pepe(Npc_Default)
{
name[0] = "Οεοε";
guild = GIL_BAU;
id = 912;
voice = 3;
flags = 0;
npcType = NPCTYPE_MAIN;
B_SetAttributesToChapter(self,1);
fight_tactic = FAI_HUMAN_COWARD;
EquipItem(self,ItMw_1h_Bau_Mace);
B_CreateAmbientInv(self);
B_CreateItemToSteal(self,15,ItMi_Gold,25);
B_SetNpcVisual(self,MALE,"Hum_Head_Bald",Face_N_Weak_Markus_Kark,BodyTex_N,ITAR_Bau_L);
Mdl_SetModelFatness(self,0);
Mdl_ApplyOverlayMds(self,"Humans_Relaxed.mds");
B_GiveNpcTalents(self);
B_SetFightSkills(self,10);
daily_routine = Rtn_Start_912;
};
func void Rtn_Start_912()
{
TA_Stand_Eating(10,0,16,0,"NW_BIGFARM_SHEEP2_02");
TA_Stand_Drinking(16,0,22,0,"NW_BIGFARM_SHEEP2_03");
TA_Stand_ArmsCrossed(22,0,4,0,"NW_BIGFARM_SHEEP2_04");
TA_Stand_ArmsCrossed(4,0,10,0,"NW_BIGFARM_SHEEP2_01");
};
|
D
|
/*
* Hunt - A redis client library for D programming language.
*
* Copyright (C) 2018-2019 HuntLabs
*
* Website: https://www.huntlabs.net/
*
* Licensed under the Apache-2.0 License.
*
*/
module hunt.redis.util.SafeEncoder;
import hunt.redis.Exceptions;
import hunt.redis.Protocol;
import hunt.Exceptions;
import hunt.text.StringUtils;
import std.array;
import std.conv;
/**
* The only reason to have this is to be able to compatible with java 1.5 :(
*/
class SafeEncoder {
private this(){
throw new InstantiationError( "Must not instantiate this class" );
}
static const(ubyte)[][] encodeMany(string[] strs...) {
const(ubyte)[][] many = new const(ubyte)[][strs.length];
for (size_t i = 0; i < strs.length; i++) {
many[i] = encode(strs[i]);
}
return many;
}
// static string[] encodeMany(string[] strs...) {
// return strs;
// // byte[][] many = new byte[][strs.length];
// // for (size_t i = 0; i < strs.length; i++) {
// // many[i] = encode(strs[i]);
// // }
// // return many;
// }
// static const(ubyte)[] encode(string str) {
// return cast(const(ubyte)[])str;
// }
static const(ubyte)[] encode(string str) {
try {
if (str.empty) {
throw new RedisDataException("The value sent to redis cannot be null");
}
return cast(const(ubyte)[])(StringUtils.getBytes(str, Protocol.CHARSET));
} catch (UnsupportedEncodingException e) {
throw new RedisException(e);
}
}
static string encode(const(ubyte)[] data) {
try {
return cast(string)data.idup;
} catch (UnsupportedEncodingException e) {
throw new RedisException(e);
}
}
}
|
D
|
func void ZS_RunToWP()
{
Perception_Set_Normal();
B_ResetAll(self);
AI_SetWalkMode(self,NPC_RUN);
if(Npc_GetDistToWP(self,self.wp) > TA_DIST_SELFWP_MAX)
{
AI_GotoWP(self,self.wp);
};
AI_AlignToWP(self);
AI_PlayAni(self,"T_STAND_2_HGUARD");
};
func int ZS_RunToWP_Loop()
{
var int random;
if(Npc_GetStateTime(self) > 5)
{
random = Hlp_Random(2);
if(random == 0)
{
AI_PlayAni(self,"T_HGUARD_LOOKAROUND");
};
Npc_SetStateTime(self,0);
};
return LOOP_CONTINUE;
};
func int ZS_RunToWP_End()
{
return 0;
};
|
D
|
/Users/kelvintan/Desktop/MVP/Build/Intermediates.noindex/MVC.build/Debug-iphonesimulator/MVC.build/Objects-normal/x86_64/SceneDelegate.o : /Users/kelvintan/Desktop/MVP/MVC/SceneDelegate.swift /Users/kelvintan/Desktop/MVP/MVC/AppDelegate.swift /Users/kelvintan/Desktop/MVP/MVC/View/Home/HomeTableViewCell.swift /Users/kelvintan/Desktop/MVP/MVC/Controller/Home/HomeViewController.swift /Users/kelvintan/Desktop/MVP/MVC/Controller/Detail/DetailViewController.swift /Users/kelvintan/Desktop/MVP/MVC/Model/BucketList.swift /Users/kelvintan/Desktop/MVP/MVC/Extension/Date_Ext.swift /Users/kelvintan/Desktop/MVP/MVC/Extension/View_Ext.swift /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreImage.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/QuartzCore.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Metal.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Swift.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/UIKit.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/mach-o/dyld.modulemap /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/mach-o/compact_unwind_encoding.modulemap /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/UserNotifications.framework/Headers/UserNotifications.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/kelvintan/Desktop/MVP/Build/Intermediates.noindex/MVC.build/Debug-iphonesimulator/MVC.build/Objects-normal/x86_64/SceneDelegate~partial.swiftmodule : /Users/kelvintan/Desktop/MVP/MVC/SceneDelegate.swift /Users/kelvintan/Desktop/MVP/MVC/AppDelegate.swift /Users/kelvintan/Desktop/MVP/MVC/View/Home/HomeTableViewCell.swift /Users/kelvintan/Desktop/MVP/MVC/Controller/Home/HomeViewController.swift /Users/kelvintan/Desktop/MVP/MVC/Controller/Detail/DetailViewController.swift /Users/kelvintan/Desktop/MVP/MVC/Model/BucketList.swift /Users/kelvintan/Desktop/MVP/MVC/Extension/Date_Ext.swift /Users/kelvintan/Desktop/MVP/MVC/Extension/View_Ext.swift /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreImage.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/QuartzCore.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Metal.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Swift.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/UIKit.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/mach-o/dyld.modulemap /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/mach-o/compact_unwind_encoding.modulemap /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/UserNotifications.framework/Headers/UserNotifications.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/kelvintan/Desktop/MVP/Build/Intermediates.noindex/MVC.build/Debug-iphonesimulator/MVC.build/Objects-normal/x86_64/SceneDelegate~partial.swiftdoc : /Users/kelvintan/Desktop/MVP/MVC/SceneDelegate.swift /Users/kelvintan/Desktop/MVP/MVC/AppDelegate.swift /Users/kelvintan/Desktop/MVP/MVC/View/Home/HomeTableViewCell.swift /Users/kelvintan/Desktop/MVP/MVC/Controller/Home/HomeViewController.swift /Users/kelvintan/Desktop/MVP/MVC/Controller/Detail/DetailViewController.swift /Users/kelvintan/Desktop/MVP/MVC/Model/BucketList.swift /Users/kelvintan/Desktop/MVP/MVC/Extension/Date_Ext.swift /Users/kelvintan/Desktop/MVP/MVC/Extension/View_Ext.swift /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreImage.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/QuartzCore.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Metal.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Swift.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/UIKit.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/mach-o/dyld.modulemap /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/mach-o/compact_unwind_encoding.modulemap /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/UserNotifications.framework/Headers/UserNotifications.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/kelvintan/Desktop/MVP/Build/Intermediates.noindex/MVC.build/Debug-iphonesimulator/MVC.build/Objects-normal/x86_64/SceneDelegate~partial.swiftsourceinfo : /Users/kelvintan/Desktop/MVP/MVC/SceneDelegate.swift /Users/kelvintan/Desktop/MVP/MVC/AppDelegate.swift /Users/kelvintan/Desktop/MVP/MVC/View/Home/HomeTableViewCell.swift /Users/kelvintan/Desktop/MVP/MVC/Controller/Home/HomeViewController.swift /Users/kelvintan/Desktop/MVP/MVC/Controller/Detail/DetailViewController.swift /Users/kelvintan/Desktop/MVP/MVC/Model/BucketList.swift /Users/kelvintan/Desktop/MVP/MVC/Extension/Date_Ext.swift /Users/kelvintan/Desktop/MVP/MVC/Extension/View_Ext.swift /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreImage.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/QuartzCore.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Metal.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Swift.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/UIKit.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/mach-o/dyld.modulemap /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/mach-o/compact_unwind_encoding.modulemap /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/UserNotifications.framework/Headers/UserNotifications.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
|
D
|
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto N = readln.chomp.to!int;
auto PS = readln.split.to!(double[]);
double[][] MEMO;
MEMO.length = N;
foreach (ref m; MEMO) m.length = N+1;
double zero = 0.0, one = 1.0;
foreach (i; 0..N) {
if (!i) {
MEMO[i][0] = one - PS[i];
MEMO[i][1] = PS[i];
continue;
}
foreach (j; 0..i+2) {
MEMO[i][j] = (MEMO[i-1][j].isNaN ? zero : MEMO[i-1][j] * (one - PS[i])) + (j ? MEMO[i-1][j-1] * PS[i] : zero);
}
}
double ret = 0.0;
foreach (c; N/2+1..N+1) {
ret += MEMO[N-1][c];
}
writefln("%1.10f", ret);
}
|
D
|
/**
Win32 driver implementation using WSAAsyncSelect
Copyright: © 2012 Sönke Ludwig
Authors: Sönke Ludwig, Leonid Kramer
License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file.
*/
module vibe.core.drivers.win32;
version(VibeWin32Driver)
{
import vibe.core.core;
import vibe.core.driver;
import vibe.core.drivers.utils;
import vibe.core.log;
import vibe.inet.url;
import vibe.internal.win32;
import vibe.utils.array;
import vibe.utils.hashmap;
import core.atomic;
import core.sync.mutex;
import core.sys.windows.windows;
import core.time;
import core.thread;
import std.algorithm;
import std.conv;
import std.c.windows.windows;
import std.c.windows.winsock;
import std.exception;
import std.string : lastIndexOf;
import std.typecons;
import std.utf;
enum WM_USER_SIGNAL = WM_USER+101;
enum WM_USER_SOCKET = WM_USER+102;
pragma(lib, "wsock32");
pragma(lib, "ws2_32");
/******************************************************************************/
/* class Win32EventDriver */
/******************************************************************************/
class Win32EventDriver : EventDriver {
import std.container : Array, BinaryHeap, heapify;
import std.datetime : Clock;
private {
HWND m_hwnd;
DWORD m_tid;
DriverCore m_core;
bool m_exit = false;
SocketEventHandler[SOCKET] m_socketHandlers;
HANDLE[] m_registeredEvents;
HANDLE m_fileCompletionEvent;
bool[Win32TCPConnection] m_fileWriters;
int m_timerIDCounter = 1;
HashMap!(size_t, TimerInfo) m_timers;
Array!TimeoutEntry m_timeoutHeapStore;
BinaryHeap!(Array!TimeoutEntry, "a.timeout > b.timeout") m_timeoutHeap;
}
this(DriverCore core)
{
setupWindowClass();
m_core = core;
m_tid = GetCurrentThreadId();
m_hwnd = CreateWindowA("VibeWin32MessageWindow", "VibeWin32MessageWindow", 0, 0,0,0,0, HWND_MESSAGE,null,null,null);
SetWindowLongPtrA(m_hwnd, GWLP_USERDATA, cast(ULONG_PTR)cast(void*)this);
assert( cast(Win32EventDriver)cast(void*)GetWindowLongPtrA(m_hwnd, GWLP_USERDATA) == this );
WSADATA wd;
enforce(WSAStartup(0x0202, &wd) == 0, "Failed to initialize WinSock");
m_fileCompletionEvent = CreateEventW(null, false, false, null);
m_registeredEvents ~= m_fileCompletionEvent;
m_timeoutHeap = heapify!"a.timeout > b.timeout"(m_timeoutHeapStore, 0);
}
~this()
{
// DestroyWindow(m_hwnd);
}
int runEventLoop()
{
m_exit = false;
while( !m_exit && haveEvents() )
runEventLoopOnce();
return 0;
}
int runEventLoopOnce()
{
doProcessEvents(INFINITE);
m_core.notifyIdle();
return 0;
}
bool processEvents()
{
return doProcessEvents(0);
}
bool doProcessEvents(uint timeout_msecs)
{
assert(m_tid == GetCurrentThreadId());
waitForEvents(timeout_msecs);
processTimers();
MSG msg;
//uint cnt = 0;
while (PeekMessageW(&msg, null, 0, 0, PM_REMOVE)) {
if( msg.message == WM_QUIT ) return false;
if( msg.message == WM_USER_SIGNAL )
msg.hwnd = m_hwnd;
TranslateMessage(&msg);
DispatchMessageW(&msg);
// process timers every now and then so that they don't get stuck
//if (++cnt % 10 == 0) processTimers();
}
return true;
}
private bool haveEvents()
{
version(VibePartialAutoExit)
return !m_fileWriters.byKey.empty || !m_socketHandlers.byKey.empty;
else return true;
}
private void waitForEvents(uint timeout_msecs)
{
// if timers are pending, limit the wait time to the first timer timeout
if (timeout_msecs > 0 && !m_timeoutHeap.empty) {
auto now = Clock.currStdTime();
auto timer_timeout = (m_timeoutHeap.front.timeout - now) / 10_000;
if (timeout_msecs == INFINITE || timer_timeout < timeout_msecs)
timeout_msecs = cast(uint)(timer_timeout < 0 ? 0 : timer_timeout > uint.max ? uint.max : timer_timeout);
}
auto ret = MsgWaitForMultipleObjectsEx(cast(DWORD)m_registeredEvents.length, m_registeredEvents.ptr, timeout_msecs, QS_ALLEVENTS, MWMO_ALERTABLE|MWMO_INPUTAVAILABLE);
if( ret == WAIT_OBJECT_0 ){
Win32TCPConnection[] to_remove;
foreach( fw; m_fileWriters.byKey )
if( fw.testFileWritten() )
to_remove ~= fw;
foreach( fw; to_remove )
m_fileWriters.remove(fw);
}
}
private void processTimers()
{
// process all timers that have expired up to now
auto now = Clock.currStdTime();
while (!m_timeoutHeap.empty && (m_timeoutHeap.front.timeout - now) / 10_000 <= 0) {
auto tm = m_timeoutHeap.front.id;
m_timeoutHeap.removeFront();
auto pt = tm in m_timers;
if (!pt || !pt.pending) continue;
Task owner = pt.owner;
auto callback = pt.callback;
if (pt.repeatDuration > 0) {
pt.timeout += pt.repeatDuration;
if (pt.timeout <= now) pt.timeout = now; // never try to process periodic timers faster than possible
m_timeoutHeap.insert(TimeoutEntry(pt.timeout, tm));
} else {
pt.pending = false;
releaseTimer(tm);
}
if (owner && owner.running) m_core.resumeTask(owner);
if (callback) runTask(callback);
}
}
void exitEventLoop()
{
m_exit = true;
PostThreadMessageW(m_tid, WM_QUIT, 0, 0);
}
Win32FileStream openFile(Path path, FileMode mode)
{
assert(m_tid == GetCurrentThreadId());
return new Win32FileStream(m_core, path, mode);
}
DirectoryWatcher watchDirectory(Path path, bool recursive)
{
assert(m_tid == GetCurrentThreadId());
return new Win32DirectoryWatcher(m_core, path, recursive);
}
NetworkAddress resolveHost(string host, ushort family = AF_UNSPEC, bool use_dns = true)
{
static immutable ushort[] addrfamilies = [AF_INET, AF_INET6];
NetworkAddress addr;
foreach( af; addrfamilies ){
if( family != af && family != AF_UNSPEC ) continue;
addr.family = af;
INT addrlen = addr.sockAddrLen;
auto ret = WSAStringToAddressW(toUTFz!(immutable(wchar)*)(host), af, null, addr.sockAddr, &addrlen);
if( ret != 0 ) continue;
assert(addrlen == addr.sockAddrLen);
return addr;
}
enforce(use_dns, "Invalid IP address string: "~host);
LookupStatus status;
status.task = Task.getThis();
status.driver = this;
status.finished = false;
WSAOVERLAPPEDX overlapped;
overlapped.Internal = 0;
overlapped.InternalHigh = 0;
overlapped.hEvent = cast(HANDLE)cast(void*)&status;
void* aif;
version(none){ // Windows 8+
ADDRINFOEXW addr_hint;
ADDRINFOEXW* addr_ret;
addr_hint.ai_family = family;
addr_hint.ai_socktype = SOCK_STREAM;
addr_hint.ai_protocol = IPPROTO_TCP;
enforce(GetAddrInfoExW(toUTFz!(immutable(wchar)*)(host), null, NS_DNS, null, &addr_hint, &addr_ret, null, &overlapped, &onDnsResult, null) == 0, "Failed to lookup host");
while( !status.finished ) m_core.yieldForEvent();
enforce(!status.error, "Failed to lookup host: "~to!string(status.error));
aif = addr_ret;
addr.family = cast(ubyte)addr_ret.ai_family;
switch(addr.family){
default: assert(false, "Invalid address family returned from host lookup.");
case AF_INET: addr.sockAddrInet4 = *cast(sockaddr_in*)addr_ret.ai_addr; break;
case AF_INET6: addr.sockAddrInet6 = *cast(sockaddr_in6*)addr_ret.ai_addr; break;
}
FreeAddrInfoW(addr_ret);
} else {
auto he = gethostbyname(toUTFz!(immutable(char)*)(host));
socketEnforce(he !is null, "Failed to look up host "~host);
addr.family = he.h_addrtype;
switch(addr.family){
default: assert(false, "Invalid address family returned from host lookup.");
case AF_INET: addr.sockAddrInet4.sin_addr = *cast(in_addr*)he.h_addr_list[0]; break;
case AF_INET6: addr.sockAddrInet6.sin6_addr = *cast(in6_addr*)he.h_addr_list[0]; break;
}
}
return addr;
}
Win32TCPConnection connectTCP(NetworkAddress addr)
{
assert(m_tid == GetCurrentThreadId());
auto sock = WSASocketW(AF_INET, SOCK_STREAM, IPPROTO_TCP, null, 0, WSA_FLAG_OVERLAPPED);
socketEnforce(sock != INVALID_SOCKET, "Failed to create socket");
NetworkAddress bind_addr;
bind_addr.family = addr.family;
if (addr.family == AF_INET) bind_addr.sockAddrInet4.sin_addr.s_addr = 0;
else bind_addr.sockAddrInet6.sin6_addr.s6_addr[] = 0;
socketEnforce(bind(sock, bind_addr.sockAddr, bind_addr.sockAddrLen) == 0, "Failed to bind socket");
auto conn = new Win32TCPConnection(this, sock, addr);
conn.connect(addr);
return conn;
}
Win32TCPListener listenTCP(ushort port, void delegate(TCPConnection conn) conn_callback, string bind_address, TCPListenOptions options)
{
assert(m_tid == GetCurrentThreadId());
auto addr = resolveHost(bind_address);
addr.port = port;
auto sock = WSASocketW(AF_INET, SOCK_STREAM, IPPROTO_TCP, null, 0, WSA_FLAG_OVERLAPPED);
socketEnforce(sock != INVALID_SOCKET, "Failed to create socket");
socketEnforce(bind(sock, addr.sockAddr, addr.sockAddrLen) == 0,
"Failed to bind listening socket");
socketEnforce(listen(sock, 128) == 0,
"Failed to listen");
return new Win32TCPListener(this, sock, conn_callback);
}
UDPConnection listenUDP(ushort port, string bind_address = "0.0.0.0")
{
assert(m_tid == GetCurrentThreadId());
auto addr = resolveHost(bind_address);
addr.port = port;
assert(false);
}
Win32ManualEvent createManualEvent()
{
assert(m_tid == GetCurrentThreadId());
return new Win32ManualEvent(this);
}
FileDescriptorEvent createFileDescriptorEvent(int file_descriptor, FileDescriptorEvent.Trigger events)
{
assert(false, "Not implemented.");
}
size_t createTimer(void delegate() callback)
{
assert(m_tid == GetCurrentThreadId());
auto id = m_timerIDCounter++;
if (!id) id = m_timerIDCounter++;
m_timers[id] = TimerInfo(callback);
return id;
}
void acquireTimer(size_t timer_id) { m_timers[timer_id].refCount++; }
void releaseTimer(size_t timer_id)
{
if (!--m_timers[timer_id].refCount)
m_timers.remove(timer_id);
}
bool isTimerPending(size_t timer_id) { return m_timers[timer_id].pending; }
void rearmTimer(size_t timer_id, Duration dur, bool periodic)
{
auto timeout = Clock.currStdTime() + dur.total!"hnsecs";
auto pt = timer_id in m_timers;
assert(pt !is null, "Accessing non-existent timer ID.");
pt.timeout = timeout;
pt.repeatDuration = periodic ? dur.total!"hnsecs" : 0;
if (!pt.pending) {
pt.pending = true;
acquireTimer(timer_id);
}
m_timeoutHeap.insert(TimeoutEntry(timeout, timer_id));
}
void stopTimer(size_t timer_id)
{
auto pt = timer_id in m_timers;
if (pt.pending) {
pt.pending = false;
releaseTimer(timer_id);
}
}
void waitTimer(size_t timer_id)
{
while (true) {
{
auto pt = timer_id in m_timers;
if (!pt || !pt.pending) return;
assert(pt.owner == Task.init, "Waiting for the same timer from multiple tasks is not supported.");
pt.owner = Task.getThis();
}
scope (exit) {
auto pt = timer_id in m_timers;
if (pt) pt.owner = Task.init;
}
m_core.yieldForEvent();
}
}
static struct LookupStatus {
Task task;
DWORD error;
bool finished;
Win32EventDriver driver;
}
private static nothrow extern(System)
void onDnsResult(DWORD dwError, DWORD /*dwBytes*/, WSAOVERLAPPEDX* lpOverlapped)
{
auto stat = cast(LookupStatus*)cast(void*)lpOverlapped.hEvent;
stat.error = dwError;
stat.finished = true;
if( stat.task )
try stat.driver.m_core.resumeTask(stat.task);
catch( Throwable th ) logWarn("Resuming task for DNS lookup has thrown: %s", th.msg);
}
private static nothrow extern(System)
LRESULT onMessage(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
auto driver = cast(Win32EventDriver)cast(void*)GetWindowLongPtrA(wnd, GWLP_USERDATA);
switch(msg){
default: break;
case WM_USER_SIGNAL:
auto sig = cast(Win32ManualEvent)cast(void*)lparam;
Win32EventDriver[Task] lst;
try {
synchronized(sig.m_mutex) lst = sig.m_listeners.dup;
foreach( task, tid; lst )
if( tid is driver && task )
driver.m_core.resumeTask(task);
} catch(Throwable th){
logWarn("Failed to resume signal listeners: %s", th.msg);
return 0;
}
return 0;
case WM_USER_SOCKET:
SOCKET sock = cast(SOCKET)wparam;
auto evt = LOWORD(lparam);
auto err = HIWORD(lparam);
auto ph = sock in driver.m_socketHandlers;
if( ph is null ){
logWarn("Socket %s has no associated handler for event %s/%s", sock, evt, err);
} else ph.notifySocketEvent(sock, evt, err);
return 0;
}
return DefWindowProcA(wnd, msg, wparam, lparam);
}
}
interface SocketEventHandler {
SOCKET socket() nothrow;
void notifySocketEvent(SOCKET sock, WORD event, WORD error) nothrow;
}
private struct TimerInfo {
long timeout;
long repeatDuration;
size_t refCount = 1;
void delegate() callback;
Task owner;
bool pending;
this(void delegate() callback) { this.callback = callback; }
}
private struct TimeoutEntry {
long timeout;
size_t id;
}
/******************************************************************************/
/* class Win32ManualEvent */
/******************************************************************************/
class Win32ManualEvent : ManualEvent {
private {
core.sync.mutex.Mutex m_mutex;
Win32EventDriver m_driver;
Win32EventDriver[Task] m_listeners;
shared int m_emitCount = 0;
Task m_waiter;
bool m_timedOut;
}
this(Win32EventDriver driver)
{
m_mutex = new core.sync.mutex.Mutex;
m_driver = driver;
}
void emit()
{
auto newcnt = atomicOp!"+="(m_emitCount, 1);
bool[Win32EventDriver] threads;
synchronized(m_mutex)
{
foreach( th; m_listeners )
threads[th] = true;
}
foreach( th, _; threads )
if( !PostMessageW(th.m_hwnd, WM_USER_SIGNAL, 0, cast(LPARAM)cast(void*)this) )
logWarn("Failed to post thread message.");
}
void wait()
{
wait(emitCount);
}
int wait(int reference_emit_count)
{
//logDebugV("Signal %s wait enter %s", cast(void*)this, reference_emit_count);
acquire();
scope(exit) release();
auto ec = atomicLoad(m_emitCount);
while( ec == reference_emit_count ){
m_driver.m_core.yieldForEvent();
ec = atomicLoad(m_emitCount);
}
//logDebugV("Signal %s wait leave %s", cast(void*)this, ec);
return ec;
}
int wait(Duration timeout, int reference_emit_count = emitCount)
{
acquire();
scope(exit) release();
auto ec = atomicLoad(m_emitCount);
m_timedOut = false;
m_waiter = Task.getThis();
auto timer = m_driver.createTimer(null);
scope(exit) m_driver.releaseTimer(timer);
m_driver.m_timers[timer].owner = Task.getThis();
m_driver.rearmTimer(timer, timeout, false);
while (ec == reference_emit_count && !m_driver.isTimerPending(timer)) {
m_driver.m_core.yieldForEvent();
ec = atomicLoad(m_emitCount);
}
return ec;
}
void acquire()
{
synchronized(m_mutex)
{
m_listeners[Task.getThis()] = cast(Win32EventDriver)getEventDriver();
}
}
void release()
{
auto self = Task.getThis();
synchronized(m_mutex)
{
if( self in m_listeners )
m_listeners.remove(self);
}
}
bool amOwner()
{
synchronized(m_mutex)
{
return (Task.getThis() in m_listeners) !is null;
}
}
@property int emitCount() const { return atomicLoad(m_emitCount); }
}
/******************************************************************************/
/* class Win32FileStream */
/******************************************************************************/
class Win32FileStream : FileStream {
private {
Path m_path;
HANDLE m_handle;
FileMode m_mode;
DriverCore m_driver;
Task m_task;
ulong m_size;
ulong m_ptr = 0;
DWORD m_bytesTransferred;
}
this(DriverCore driver, Path path, FileMode mode)
{
m_path = path;
m_mode = mode;
m_driver = driver;
auto nstr = m_path.toNativeString();
auto access = m_mode == FileMode.readWrite ? (GENERIC_WRITE | GENERIC_READ) :
(m_mode == FileMode.createTrunc || m_mode == FileMode.append)? GENERIC_WRITE : GENERIC_READ;
auto shareMode = m_mode == FileMode.read? FILE_SHARE_READ : 0;
auto creation = m_mode == FileMode.createTrunc? CREATE_ALWAYS : m_mode == FileMode.append? OPEN_ALWAYS : OPEN_EXISTING;
m_handle = CreateFileW(
toUTF16z(m_path.toNativeString()),
access,
shareMode,
null,
creation,
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED,
null);
auto errorcode = GetLastError();
enforce(m_handle != INVALID_HANDLE_VALUE, "Failed to open "~path.toNativeString()~": "~to!string(errorcode));
if(mode == FileMode.createTrunc && errorcode == ERROR_ALREADY_EXISTS)
{
// truncate file
// TODO: seek to start pos?
BOOL ret = SetEndOfFile(m_handle);
errorcode = GetLastError();
enforce(ret, "Failed to call SetFileEndPos for path "~path.toNativeString()~", Error: " ~ to!string(errorcode));
}
long size;
auto succeeded = GetFileSizeEx(m_handle, &size);
enforce(succeeded);
m_size = size;
}
~this()
{
close();
}
void release()
{
assert(m_task == Task.getThis(), "Releasing FileStream that is not owned by the calling task.");
m_task = Task();
}
void acquire()
{
assert(m_task == Task(), "Acquiring FileStream that is already owned.");
m_task = Task.getThis();
}
bool amOwner()
{
return m_task == Task.getThis();
}
void close()
{
if(m_handle == INVALID_HANDLE_VALUE)
return;
CloseHandle(m_handle);
m_handle = INVALID_HANDLE_VALUE;
}
ulong tell() { return m_ptr; }
@property Path path() const { return m_path; }
@property bool isOpen() const { return m_handle != INVALID_HANDLE_VALUE; }
@property ulong size() const { return m_size; }
@property bool readable()
const {
return m_mode != FileMode.append;
}
@property bool writable()
const {
return m_mode == FileMode.append || m_mode == FileMode.createTrunc || m_mode == FileMode.readWrite;
}
void seek(ulong offset)
{
m_ptr = offset;
}
@property bool empty() const { assert(this.readable); return m_ptr >= m_size; }
@property ulong leastSize() const { assert(this.readable); return m_size - m_ptr; }
@property bool dataAvailableForRead(){
return leastSize() > 0;
}
const(ubyte)[] peek(){
assert(false);
}
void read(ubyte[] dst)
{
assert(this.readable);
acquire();
scope(exit) release();
while( dst.length > 0 ){
enforce(dst.length <= leastSize);
OVERLAPPED overlapped;
overlapped.Internal = 0;
overlapped.InternalHigh = 0;
overlapped.Offset = cast(uint)(m_ptr & 0xFFFFFFFF);
overlapped.OffsetHigh = cast(uint)(m_ptr >> 32);
overlapped.hEvent = cast(HANDLE)cast(void*)this;
m_bytesTransferred = 0;
auto to_read = min(dst.length, DWORD.max);
// request to write the data
ReadFileEx(m_handle, cast(void*)dst, to_read, &overlapped, &onIOCompleted);
// yield until the data is read
while( !m_bytesTransferred ) m_driver.yieldForEvent();
assert(m_bytesTransferred <= to_read, "More bytes read than requested!?");
dst = dst[m_bytesTransferred .. $];
m_ptr += m_bytesTransferred;
}
}
void write(in ubyte[] bytes_)
{
assert(this.writable);
acquire();
scope(exit) release();
const(ubyte)[] bytes = bytes_;
while( bytes.length > 0 ){
OVERLAPPED overlapped;
overlapped.Internal = 0;
overlapped.InternalHigh = 0;
overlapped.Offset = cast(uint)(m_ptr & 0xFFFFFFFF);
overlapped.OffsetHigh = cast(uint)(m_ptr >> 32);
overlapped.hEvent = cast(HANDLE)cast(void*)this;
m_bytesTransferred = 0;
auto to_write = min(bytes.length, DWORD.max);
// request to write the data
WriteFileEx(m_handle, cast(void*)bytes, to_write, &overlapped, &onIOCompleted);
// yield until the data is written
while( !m_bytesTransferred ) m_driver.yieldForEvent();
assert(m_bytesTransferred <= to_write, "More bytes written than requested!?");
bytes = bytes[m_bytesTransferred .. $];
m_ptr += m_bytesTransferred;
}
if(m_ptr > m_size) m_size = m_ptr;
}
void flush(){}
void finalize(){}
void write(InputStream stream, ulong nbytes = 0)
{
writeDefault(stream, nbytes);
}
private static extern(System) nothrow
void onIOCompleted(DWORD dwError, DWORD cbTransferred, OVERLAPPED* overlapped)
{
try {
auto fileStream = cast(Win32FileStream)(overlapped.hEvent);
fileStream.m_bytesTransferred = cbTransferred;
if( fileStream.m_task ){
Exception ex;
if( dwError != 0 ) ex = new Exception("File I/O error: "~to!string(dwError));
if( fileStream.m_task ) fileStream.m_driver.resumeTask(fileStream.m_task, ex);
}
} catch( Throwable e ){
logWarn("Exception while handling file I/O: %s", e.msg);
}
}
}
/******************************************************************************/
/* class Win32Directory Watcher */
/******************************************************************************/
class Win32DirectoryWatcher : DirectoryWatcher {
private {
Path m_path;
bool m_recursive;
HANDLE m_handle;
DWORD m_bytesTransferred;
DriverCore m_core;
ubyte[16384] m_buffer;
UINT m_notifications = FILE_NOTIFY_CHANGE_FILE_NAME|FILE_NOTIFY_CHANGE_DIR_NAME|
FILE_NOTIFY_CHANGE_SIZE|FILE_NOTIFY_CHANGE_LAST_WRITE;
Task m_task;
}
this(DriverCore core, Path path, bool recursive)
{
m_core = core;
m_path = path;
m_recursive = recursive;
m_task = Task.getThis();
auto pstr = m_path.toString();
m_handle = CreateFileW(toUTFz!(const(wchar)*)(pstr),
FILE_LIST_DIRECTORY,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
null,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED,
null);
}
~this()
{
CloseHandle(m_handle);
}
@property Path path() const { return m_path; }
@property bool recursive() const { return m_recursive; }
void release()
{
assert(m_task == Task.getThis(), "Releasing FileStream that is not owned by the calling task.");
m_task = Task();
}
void acquire()
{
assert(m_task == Task(), "Acquiring FileStream that is already owned.");
m_task = Task.getThis();
}
bool amOwner()
{
return m_task == Task.getThis();
}
bool readChanges(ref DirectoryChange[] dst, Duration timeout)
{
OVERLAPPED overlapped;
overlapped.Internal = 0;
overlapped.InternalHigh = 0;
overlapped.Offset = 0;
overlapped.OffsetHigh = 0;
overlapped.hEvent = cast(HANDLE)cast(void*)this;
m_bytesTransferred = 0;
DWORD bytesReturned;
if( !ReadDirectoryChangesW(m_handle, m_buffer.ptr, m_buffer.length, m_recursive,
m_notifications, &bytesReturned, &overlapped, &onIOCompleted) )
{
logError("Failed to read directory changes in '%s'", m_path);
return false;
}
// FIXME: obey timeout!
assert(timeout.isNegative());
while( !m_bytesTransferred ) m_core.yieldForEvent();
ubyte[] result = m_buffer[0 .. m_bytesTransferred];
do {
assert(result.length >= FILE_NOTIFY_INFORMATION.sizeof);
auto fni = cast(FILE_NOTIFY_INFORMATION*)result.ptr;
DirectoryChangeType kind;
switch( fni.Action ){
default: kind = DirectoryChangeType.modified; break;
case 0x1: kind = DirectoryChangeType.added; break;
case 0x2: kind = DirectoryChangeType.removed; break;
case 0x3: kind = DirectoryChangeType.modified; break;
case 0x4: kind = DirectoryChangeType.removed; break;
case 0x5: kind = DirectoryChangeType.added; break;
}
string filename = to!string(fni.FileName.ptr[0 .. fni.FileNameLength/2]);
dst ~= DirectoryChange(kind, Path(filename));
//logTrace("File changed: %s", fni.FileName.ptr[0 .. fni.FileNameLength/2]);
if( fni.NextEntryOffset == 0 ) break;
result = result[fni.NextEntryOffset .. $];
} while(result.length > 0);
return true;
}
static nothrow extern(System)
{
void onIOCompleted(DWORD dwError, DWORD cbTransferred, OVERLAPPED* overlapped)
{
try {
auto watcher = cast(Win32DirectoryWatcher)overlapped.hEvent;
watcher.m_bytesTransferred = cbTransferred;
if( watcher.m_task ){
Exception ex;
if( dwError != 0 ) ex = new Exception("Diretory watcher error: "~to!string(dwError));
if( watcher.m_task ) watcher.m_core.resumeTask(watcher.m_task, ex);
}
} catch( Throwable th ){
logWarn("Exception in directory watcher callback: %s", th.msg);
}
}
}
}
/******************************************************************************/
/* class Win32UDPConnection */
/******************************************************************************/
class Win32UDPConnection : UDPConnection, SocketEventHandler {
private {
Task m_task;
Win32EventDriver m_driver;
SOCKET m_socket;
NetworkAddress m_bindAddress;
bool m_canBroadcast;
}
this(Win32EventDriver driver, SOCKET sock, NetworkAddress bind_addr)
{
m_driver = driver;
m_socket = sock;
m_bindAddress = bind_addr;
WSAAsyncSelect(sock, m_driver.m_hwnd, WM_USER_SOCKET, FD_READ|FD_WRITE|FD_CLOSE);
//bind...
}
@property SOCKET socket() { return m_socket; }
@property string bindAddress() const {
// NOTE: using WSAAddressToStringW instead of inet_ntop because that is only available from Vista up
wchar[64] buf;
DWORD buf_len = 64;
WSAAddressToStringW(m_bindAddress.sockAddr, m_bindAddress.sockAddrLen, null, buf.ptr, &buf_len);
auto ret = to!string(buf[0 .. buf_len]);
ret = ret[0 .. ret.lastIndexOf(':')]; // strip the port number
return ret;
}
@property NetworkAddress localAddress() const { return m_bindAddress; }
@property bool canBroadcast() const { return m_canBroadcast; }
@property void canBroadcast(bool val)
{
int tmp_broad = val;
socketEnforce(setsockopt(m_socket, SOL_SOCKET, SO_BROADCAST, &tmp_broad, tmp_broad.sizeof) == 0,
"Failed to change the socket broadcast flag");
m_canBroadcast = val;
}
bool amOwner() {
return m_task != Task() && m_task == Task.getThis();
}
void acquire()
{
assert(m_task == Task(), "Trying to acquire a TCP connection that is currently owned.");
m_task = Task.getThis();
}
void release()
{
assert(m_task != Task(), "Trying to release a TCP connection that is not owned.");
assert(m_task == Task.getThis(), "Trying to release a foreign TCP connection.");
m_task = Task();
}
void connect(string host, ushort port)
{
NetworkAddress addr = m_driver.resolveHost(host, m_bindAddress.family);
addr.port = port;
connect(addr);
}
void connect(NetworkAddress addr)
{
socketEnforce(.connect(m_socket, addr.sockAddr, addr.sockAddrLen) == 0, "Failed to connect UDP socket");
}
void send(in ubyte[] data, in NetworkAddress* peer_address = null)
{
assert(data.length <= int.max);
sizediff_t ret;
if( peer_address ){
ret = .sendto(m_socket, data.ptr, cast(int)data.length, 0, peer_address.sockAddr, peer_address.sockAddrLen);
} else {
ret = .send(m_socket, data.ptr, cast(int)data.length, 0);
}
logTrace("send ret: %s, %s", ret, WSAGetLastError());
socketEnforce(ret >= 0, "Error sending UDP packet");
enforce(ret == data.length, "Unable to send full packet.");
}
ubyte[] recv(ubyte[] buf = null, NetworkAddress* peer_address = null)
{
acquire();
scope(exit) release();
assert(buf.length <= int.max);
if( buf.length == 0 ) buf.length = 65507;
NetworkAddress from;
from.family = m_bindAddress.family;
while(true){
socklen_t addr_len = from.sockAddrLen;
auto ret = .recvfrom(m_socket, buf.ptr, cast(int)buf.length, 0, from.sockAddr, &addr_len);
if( ret > 0 ){
if( peer_address ) *peer_address = from;
return buf[0 .. ret];
}
if( ret < 0 ){
auto err = WSAGetLastError();
logDebug("UDP recv err: %s", err);
socketEnforce(err == WSAEWOULDBLOCK, "Error receiving UDP packet");
}
m_driver.m_core.yieldForEvent();
}
}
void notifySocketEvent(SOCKET sock, WORD event, WORD error)
{
assert(false);
}
private static nothrow extern(C) void onUDPRead(SOCKET sockfd, short evts, void* arg)
{
/*auto ctx = cast(TCPContext*)arg;
logTrace("udp socket %d read event!", ctx.socketfd);
try {
auto f = ctx.task;
if( f && f.state != Fiber.State.TERM )
ctx.core.resumeTask(f);
} catch( Throwable e ){
logError("Exception onUDPRead: %s", e.msg);
debug assert(false);
}*/
}
}
/******************************************************************************/
/* class Win32TCPConnection */
/******************************************************************************/
enum ConnectionStatus { Initialized, Connected, Disconnected }
class Win32TCPConnection : TCPConnection, SocketEventHandler {
private {
Win32EventDriver m_driver;
Task m_readOwner;
Task m_writeOwner;
bool m_tcpNoDelay;
Duration m_readTimeout;
SOCKET m_socket;
NetworkAddress m_localAddress;
NetworkAddress m_peerAddress;
string m_peerAddressString;
DWORD m_bytesTransferred;
ConnectionStatus m_status;
FixedRingBuffer!(ubyte, 64*1024) m_readBuffer;
void delegate(TCPConnection) m_connectionCallback;
HANDLE m_transferredFile;
OVERLAPPED m_fileOverlapped;
}
this(Win32EventDriver driver, SOCKET sock, NetworkAddress peer_address, ConnectionStatus status = ConnectionStatus.Initialized)
{
m_driver = driver;
m_socket = sock;
m_driver.m_socketHandlers[sock] = this;
m_status = status;
m_localAddress.family = peer_address.family;
if (peer_address.family == AF_INET) m_localAddress.sockAddrInet4.sin_addr.s_addr = 0;
else m_localAddress.sockAddrInet6.sin6_addr.s6_addr[] = 0;
socklen_t balen = m_localAddress.sockAddrLen;
socketEnforce(getsockname(sock, m_localAddress.sockAddr, &balen) == 0, "getsockname failed");
m_peerAddress = peer_address;
// NOTE: using WSAAddressToStringW instead of inet_ntop because that is only available from Vista up
wchar[64] buf;
DWORD buflen = buf.length;
socketEnforce(WSAAddressToStringW(m_peerAddress.sockAddr, m_peerAddress.sockAddrLen, null, buf.ptr, &buflen) == 0, "Failed to get string representation of peer address");
m_peerAddressString = to!string(buf[0 .. buflen]);
m_peerAddressString = m_peerAddressString[0 .. m_peerAddressString.lastIndexOf(':')]; // strip the port number
// setup overlapped structure for copy-less file sending
m_fileOverlapped.Internal = 0;
m_fileOverlapped.InternalHigh = 0;
m_fileOverlapped.Offset = 0;
m_fileOverlapped.OffsetHigh = 0;
m_fileOverlapped.hEvent = m_driver.m_fileCompletionEvent;
WSAAsyncSelect(sock, m_driver.m_hwnd, WM_USER_SOCKET, FD_READ|FD_WRITE|FD_CLOSE);
}
~this()
{
/*if( m_socket != -1 ){
closesocket(m_socket);
}*/
}
@property SOCKET socket() { return m_socket; }
private void connect(NetworkAddress addr)
{
enforce(m_status != ConnectionStatus.Connected, "Connection is already established.");
acquire();
scope(exit) release();
auto ret = .connect(m_socket, addr.sockAddr, addr.sockAddrLen);
//enforce(WSAConnect(m_socket, addr.sockAddr, addr.sockAddrLen, null, null, null, null), "Failed to connect to host");
if (ret != 0) {
auto err = WSAGetLastError();
logDebugV("connect err: %s", err);
import std.string;
socketEnforce(err == WSAEWOULDBLOCK, "Connect call failed");
while (m_status != ConnectionStatus.Connected)
m_driver.m_core.yieldForEvent();
}
assert(m_status == ConnectionStatus.Connected);
}
void release()
{
assert(m_readOwner == Task.getThis() && m_readOwner == m_writeOwner, "Releasing TCP connection that is not owned by the calling task.");
m_readOwner = m_writeOwner = Task();
}
void acquire()
{
assert(m_readOwner == Task() && m_writeOwner == Task(), "Acquiring TCP connection that is currently owned.");
m_readOwner = m_writeOwner = Task.getThis();
}
bool amOwner() { return Task.getThis() == m_readOwner && m_readOwner == m_writeOwner; }
@property void tcpNoDelay(bool enabled)
{
m_tcpNoDelay = enabled;
BOOL eni = enabled;
setsockopt(m_socket, IPPROTO_TCP, TCP_NODELAY, &eni, eni.sizeof);
assert(false);
}
@property bool tcpNoDelay() const { return m_tcpNoDelay; }
@property void readTimeout(Duration v)
{
m_readTimeout = v;
auto msecs = v.total!"msecs"();
assert(msecs < DWORD.max);
DWORD vdw = cast(DWORD)msecs;
setsockopt(m_socket, SOL_SOCKET, SO_RCVTIMEO, &vdw, vdw.sizeof);
}
@property Duration readTimeout() const { return m_readTimeout; }
@property bool connected() const { return m_status == ConnectionStatus.Connected; }
@property string peerAddress() const { return m_peerAddressString; }
@property NetworkAddress localAddress() const { return m_localAddress; }
@property NetworkAddress remoteAddress() const { return m_peerAddress; }
@property bool empty() { return leastSize == 0; }
@property ulong leastSize()
{
acquireReader();
scope(exit) releaseReader();
while( m_readBuffer.empty ){
if( !connected ) return 0;
m_driver.m_core.yieldForEvent();
}
return m_readBuffer.length;
}
@property bool dataAvailableForRead()
{
acquireReader();
scope(exit) releaseReader();
return !m_readBuffer.empty;
}
void close()
{
acquire();
scope(exit) release();
WSASendDisconnect(m_socket, null);
closesocket(m_socket);
m_socket = -1;
m_status = ConnectionStatus.Disconnected;
}
bool waitForData(Duration timeout)
{
acquireReader();
scope(exit) releaseReader();
auto tm = m_driver.createTimer(null);
scope(exit) m_driver.releaseTimer(tm);
m_driver.m_timers[tm].owner = Task.getThis();
m_driver.rearmTimer(tm, timeout, false);
while (m_readBuffer.empty) {
if (!connected) return false;
m_driver.m_core.yieldForEvent();
if (!m_driver.isTimerPending(tm)) return false;
}
return true;
}
const(ubyte)[] peek()
{
acquireReader();
scope(exit) releaseReader();
return m_readBuffer.peek();
}
void read(ubyte[] dst)
{
acquireReader();
scope(exit) releaseReader();
while( dst.length > 0 ){
while( m_readBuffer.empty ){
checkConnected();
m_driver.m_core.yieldForEvent();
}
size_t amt = min(dst.length, m_readBuffer.length);
m_readBuffer.read(dst[0 .. amt]);
dst = dst[amt .. $];
}
}
void write(in ubyte[] bytes_)
{
acquireWriter();
scope(exit) releaseWriter();
checkConnected();
const(ubyte)[] bytes = bytes_;
logTrace("TCP write with %s bytes called", bytes.length);
WSAOVERLAPPEDX overlapped;
overlapped.Internal = 0;
overlapped.InternalHigh = 0;
overlapped.Offset = 0;
overlapped.OffsetHigh = 0;
overlapped.hEvent = cast(HANDLE)cast(void*)this;
while( bytes.length > 0 ){
WSABUF buf;
buf.len = bytes.length;
buf.buf = cast(ubyte*)bytes.ptr;
m_bytesTransferred = 0;
logTrace("Sending %s bytes TCP", buf.len);
auto ret = WSASend(m_socket, &buf, 1, null, 0, &overlapped, &onIOWriteCompleted);
if( ret == SOCKET_ERROR ){
auto err = WSAGetLastError();
socketEnforce(err == WSA_IO_PENDING, "Failed to send data");
}
while( !m_bytesTransferred ) m_driver.m_core.yieldForEvent();
assert(m_bytesTransferred <= bytes.length, "More data sent than requested!?");
bytes = bytes[m_bytesTransferred .. $];
}
}
void flush()
{
acquireWriter();
scope(exit) releaseWriter();
checkConnected();
}
void finalize()
{
flush();
}
void write(InputStream stream, ulong nbytes = 0)
{
// special case sending of files
if( auto fstream = cast(Win32FileStream)stream ){
if( fstream.tell() == 0 && fstream.size <= 1<<31 ){
acquireWriter();
scope(exit) releaseWriter();
logDebug("Using sendfile! %s %s %s", fstream.m_handle, fstream.tell(), fstream.size);
m_bytesTransferred = 0;
m_driver.m_fileWriters[this] = true;
if( TransmitFile(m_socket, fstream.m_handle, 0, 0, &m_fileOverlapped, null, 0) )
m_bytesTransferred = 1;
socketEnforce(WSAGetLastError() == WSA_IO_PENDING, "Failed to send file over TCP.");
while( m_bytesTransferred < fstream.size ) m_driver.m_core.yieldForEvent();
return;
}
}
writeDefault(stream, nbytes);
}
InputStream acquireReader() { assert(m_readOwner == Task()); m_readOwner = Task.getThis(); return this; }
void releaseReader() { assert(m_readOwner == Task.getThis()); m_readOwner = Task(); }
bool amReadOwner() const { return m_readOwner == Task.getThis(); }
OutputStream acquireWriter() { assert(m_writeOwner == Task()); m_writeOwner = Task.getThis(); return this; }
void releaseWriter() { assert(m_writeOwner == Task.getThis()); m_writeOwner = Task(); }
bool amWriteOwner() const { return m_writeOwner == Task.getThis(); }
private void checkConnected()
{
// TODO!
}
private bool testFileWritten()
{
if( !GetOverlappedResult(m_transferredFile, &m_fileOverlapped, &m_bytesTransferred, false) ){
if( GetLastError() != ERROR_IO_PENDING ){
m_driver.m_core.resumeTask(m_writeOwner, new Exception("File transfer over TCP failed."));
return true;
}
return false;
} else {
m_driver.m_core.resumeTask(m_writeOwner);
return true;
}
}
void notifySocketEvent(SOCKET sock, WORD event, WORD error)
nothrow {
try {
logDebugV("Socket event for %s: %s, error: %s", sock, event, error);
if (m_socket == -1) {
logDebug("Event for already closed socket - ignoring");
return;
}
assert(sock == m_socket);
Exception ex;
switch(event){
default: break;
case FD_CONNECT: // doesn't seem to occur, but we handle it just in case
if (error) {
ex = new Exception("Failed to connect to host: "~to!string(error));
m_status = ConnectionStatus.Disconnected;
} else m_status = ConnectionStatus.Connected;
if (m_writeOwner) m_driver.m_core.resumeTask(m_writeOwner, ex);
break;
case FD_READ:
logTrace("TCP read event");
while( m_readBuffer.freeSpace > 0 ){
auto dst = m_readBuffer.peekDst();
assert(dst.length <= int.max);
logTrace("Try to read up to %s bytes", dst.length);
auto ret = .recv(m_socket, dst.ptr, cast(int)dst.length, 0);
if( ret >= 0 ){
logTrace("received %s bytes", ret);
if( ret == 0 ) break;
m_readBuffer.putN(ret);
} else {
auto err = WSAGetLastError();
if( err != WSAEWOULDBLOCK ){
logTrace("receive error %s", err);
ex = new Exception("Socket error: "~to!string(err));
}
break;
}
}
//m_driver.m_core.resumeTask(m_readOwner, ex);
/*WSABUF buf;
buf.len = dst.length;
buf.buf = dst.ptr;
DWORD flags = 0;
WSAOVERLAPPEDX overlapped;
overlapped.Internal = 0;
overlapped.InternalHigh = 0;
overlapped.Offset = 0;
overlapped.OffsetHigh = 0;
overlapped.hEvent = cast(HANDLE)cast(void*)this;
m_bytesTransferred = 0;
auto ret = WSARecv(m_socket, &buf, 1, null, &flags, &overlapped, &onIOCompleted);
if( ret == SOCKET_ERROR ){
auto err = WSAGetLastError();
socketEnforce(err == WSA_IO_PENDING, "Failed to receive data");
}
while( !m_bytesTransferred ) m_driver.m_core.yieldForEvent();
assert(m_bytesTransferred <= dst.length, "More data received than requested!?");
m_readBuffer.pushN(m_bytesTransferred);*/
if (m_readOwner) m_driver.m_core.resumeTask(m_readOwner, ex);
break;
case FD_WRITE:
if( m_status == ConnectionStatus.Initialized ){
if( error ){
ex = new Exception("Failed to connect to host: "~to!string(error));
} else m_status = ConnectionStatus.Connected;
}
if (m_writeOwner) m_driver.m_core.resumeTask(m_writeOwner, ex);
break;
case FD_CLOSE:
if( error ){
if( m_status == ConnectionStatus.Initialized ){
ex = new Exception("Failed to connect to host: "~to!string(error));
} else {
ex = new Exception("The connection was closed with error: "~to!string(error));
}
} else {
m_status = ConnectionStatus.Disconnected;
closesocket(m_socket);
m_socket = -1;
}
if (m_writeOwner) m_driver.m_core.resumeTask(m_writeOwner, ex);
break;
}
} catch( Throwable th ){
logWarn("Exception while handling socket event: %s", th.msg);
}
}
private void runConnectionCallback()
{
try {
m_connectionCallback(this);
logDebug("task out (fd %d).", m_socket);
} catch( Exception e ){
logWarn("Handling of connection failed: %s", e.msg);
logDiagnostic("%s", e.toString());
}
if( this.connected ) close();
}
private static extern(System) nothrow
void onIOWriteCompleted(DWORD dwError, DWORD cbTransferred, WSAOVERLAPPEDX* lpOverlapped, DWORD dwFlags)
{
logTrace("IO completed for TCP send: %s (error=%s)", cbTransferred, dwError);
try {
auto conn = cast(Win32TCPConnection)(lpOverlapped.hEvent);
conn.m_bytesTransferred = cbTransferred;
if (conn.m_writeOwner != Task.init) {
Exception ex;
if( dwError != 0 ) ex = new Exception("Socket I/O error: "~to!string(dwError));
conn.m_driver.m_core.resumeTask(conn.m_writeOwner, ex);
}
} catch( Throwable th ){
logWarn("Exception while handling TCP I/O: %s", th.msg);
}
}
}
/******************************************************************************/
/* class Win32TCPListener */
/******************************************************************************/
class Win32TCPListener : TCPListener, SocketEventHandler {
private {
Win32EventDriver m_driver;
SOCKET m_socket;
void delegate(TCPConnection conn) m_connectionCallback;
}
this(Win32EventDriver driver, SOCKET sock, void delegate(TCPConnection conn) conn_callback)
{
m_driver = driver;
m_socket = sock;
m_connectionCallback = conn_callback;
m_driver.m_socketHandlers[sock] = this;
WSAAsyncSelect(sock, m_driver.m_hwnd, WM_USER_SOCKET, FD_ACCEPT);
}
void stopListening()
{
if( m_socket == -1 ) return;
closesocket(m_socket);
m_socket = -1;
}
SOCKET socket() nothrow { return m_socket; }
void notifySocketEvent(SOCKET sock, WORD event, WORD error)
nothrow {
assert(sock == m_socket);
switch(event){
default: assert(false);
case FD_ACCEPT:
try {
NetworkAddress addr;
addr.family = AF_INET6;
int addrlen = addr.sockAddrLen;
auto clientsock = WSAAccept(sock, addr.sockAddr, &addrlen, null, 0);
assert(addrlen == addr.sockAddrLen);
// TODO avoid GC allocations for delegate and Win32TCPConnection
auto conn = new Win32TCPConnection(m_driver, clientsock, addr, ConnectionStatus.Connected);
conn.m_connectionCallback = m_connectionCallback;
runTask(&conn.runConnectionCallback);
} catch( Exception e ){
logWarn("Exception white accepting TCP connection: %s", e.msg);
try logDiagnostic("Exception white accepting TCP connection: %s", e.toString());
catch( Exception ){}
}
break;
}
}
}
private {
struct TimerMapTraits {
enum clearValue = UINT_PTR.max;
static bool equals(UINT_PTR a, UINT_PTR b) { return a == b; }
}
HashMap!(UINT_PTR, void*/*Win32Timer*/, TimerMapTraits) s_timers;
__gshared s_setupWindowClass = false;
}
void setupWindowClass()
{
if( s_setupWindowClass ) return;
WNDCLASS wc;
wc.lpfnWndProc = &Win32EventDriver.onMessage;
wc.lpszClassName = "VibeWin32MessageWindow";
RegisterClassA(&wc);
s_setupWindowClass = true;
}
} // version(VibeWin32Driver)
|
D
|
func void startup_AI_Testlevel_Monster()
{
B_InitMonsterAttitudes();
};
|
D
|
module stm32f401re;
version (ARM_Thumb):
@nogc:
nothrow:
version(LDC)
{
pragma(LDC_no_moduleinfo);
pragma(LDC_no_typeinfo);
}
public import cortexm;
/**
Power on each peripherals.
*/
auto powerOn(string name)()
{
static if (name == "GPIOA" || name == "GPIOB" || name == "GPIOC" || name == "GPIOD" || name == "GPIOE")
{
import stm32f401re.gpio;
return powerOnGPIO!(name)();
}
else static if (name == "TIM2" || name == "TIM3" || name == "TIM4" || name == "TIM5")
{
import stm32f401re.timer;
return powerOnTIM!(name)();
}
else static assert (false);
}
|
D
|
instance Mod_781_SLD_Cipher_MT (Npc_Default)
{
// ------ NSC ------
name = "Cipher";
guild = GIL_MIL;
id = 781;
voice = 7;
flags = 0; //NPC_FLAG_IMMORTAL oder 0
npctype = NPCTYPE_MAIN;
// ------ Attribute ------
B_SetAttributesToChapter (self, 2); //setzt Attribute und LEVEL entsprechend dem angegebenen Kapitel (1-6)
// ------ Kampf-Taktik ------
fight_tactic = FAI_HUMAN_STRONG; // MASTER / STRONG / COWARD
// ------ Equippte Waffen ------ //Munition wird automatisch generiert, darf aber angegeben werden
EquipItem (self, ItMw_GrobesKurzschwert);
// ------ Inventory ------
B_CreateAmbientInv (self);
CreateInvItems (self, ItRw_Arrow, 50);
CreateInvItems (self, ItRw_Bow_L_02, 1);
CreateInvItems (self, ItRw_Sld_Bow, 1);
CreateInvItems (self, ItMw_2H_OrcAxe_01, 1);
CreateInvItems (self, ItLsTorch, 8);
// ------ visuals ------ //Muss NACH Attributen kommen, weil in B_SetNpcVisual die Breite abh. v. STR skaliert wird
B_SetNpcVisual (self, MALE, "Hum_Head_Bald", Face_N_NormalBart10, BodyTex_N, ITAR_SLD_L);
Mdl_SetModelFatness (self, 0);
Mdl_ApplyOverlayMds (self, "Humans_Relaxed.mds"); // Tired / Militia / Mage / Arrogance / Relaxed
// ------ NSC-relevante Talente vergeben ------
B_GiveNpcTalents (self);
// ------ Kampf-Talente ------ //Der enthaltene B_AddFightSkill setzt Talent-Ani abhängig von TrefferChance% - alle Kampftalente werden gleichhoch gesetzt
B_SetFightSkills (self, 50); //Grenzen für Talent-Level liegen bei 30 und 60
// ------ TA anmelden ------
daily_routine = Rtn_Start_781;
};
FUNC VOID Rtn_Start_781 ()
{
TA_Smalltalk (07,35,10,30,"NC_PATH67");
TA_Stand_Drinking (10,30,11,00,"NC_TAVERN_BAR");
TA_Smalltalk (11,00,12,00,"NC_PATH67");
TA_Stand_Eating (12,00,12,30,"NC_TAVERN_BAR");
TA_Smalltalk (12,30,15,00,"NC_PATH67");
TA_Smoke_Joint (15,00,15,30,"NC_TAVERN_SIDE01");
TA_Smalltalk (15,30,22,00,"NC_PATH67");
TA_Sleep (22,00,07,35,"NC_HUT07_IN");
};
FUNC VOID Rtn_FMC_781 ()
{
TA_Smalltalk (08,00,22,00,"FMC_HUT01_OUT");
TA_Smalltalk (22,00,08,00,"FMC_HUT01_OUT");
};
FUNC VOID Rtn_Aufstellung_781 ()
{
TA_Stand_ArmsCrossed (08,00,22,00,"OW_PATH_3001_MOVE5");
TA_Stand_ArmsCrossed (22,00,08,00,"OW_PATH_3001_MOVE5");
};
FUNC VOID Rtn_Angriff_781 ()
{
TA_RunToWP (08,00,22,00,"OW_PATH_3001_05");
TA_RunToWP (22,00,08,00,"OW_PATH_3001_05");
};
|
D
|
PLONG PLAT ED95 KD LOMAGAGE HIMAGAGE SLAT SLONG RESULTNO DP DM ROCKTYPE
298.399994 61.7000008 5.9000001 0 58 62 -19.6000004 116.099998 141 3.29999995 8 sediments, sandstones, siltstones
310.200012 40.5999985 4.69999981 120.900002 56 59 -33.2000008 151.100006 241 8.60000038 8.60000038 extrusives
225.800003 43.9000015 7.5999999 145.5 71 89 -9.69999981 119.599998 7799 4.9000001 8.69999981 sediments
219.300003 -4.19999981 9.39999962 22.3999996 56 65 -10 121 7800 4.9000001 9.60000038 extrusives, basalts, andesites
321.100006 59.7999992 1.29999995 137.5 65 90 -43.5 146.800003 1350 2.4000001 2.5 sediments, limestones
-65.400002 61.2999992 1.39999998 297 50 70 -31.6000004 145.600006 9339 2.20000005 2.20000005 sediments, saprolite
221.899994 42 8.80000019 0 63 75 -9.69999981 119.5 1211 5.30000019 9.69999981 intrusives, granodiorite, andesite dykes
264.399994 75 15.6000004 0 2 65 -8.80000019 126.699997 1206 10.3999996 18 extrusives, intrusives
346 61 9 41.2000008 35 100 -31.3999996 138.600006 1170 13 15 sediments
333 45 9 16.5 35 100 -30.3999996 139.399994 1161 17 18 sediments, tillite
317 57 5 200 35 100 -30.5 139.300003 1165 9 10 sediments, redbeds
329 58 25 4.0999999 35 100 -30.2000008 139 1166 41.5999985 45.5999985 sediments, sandstone, tillite
223 26 13 14.8000002 35 100 -30.2999992 139.5 1157 26 26 extrusives
320 63 9 15.5 34 65 -38 145.5 1854 16 16 extrusives
302.700012 66.8000031 6.80000019 35 34 65 -38 145.5 1819 10.8000002 12.1000004 extrusives
274 66 27.6000004 8.60000038 25 65 -41.2999992 145.899994 1873 39.7999992 46.9000015 intrusives, granite
321 64 6 27.5 25 65 -35.5999985 137.5 1874 10 11 sediments
269 40 0 0 50 300 -32.5999985 151.5 1868 0 0 extrusives, andesites
294 75 11 7 25 65 -41.0999985 146.100006 1871 16.2999992 18.8999996 sediments, sandstone
315 66 10.5 18 25 65 -41 145.5 1872 18.2000008 19.6000004 extrusives, sediments
298 58.7999992 2.4000001 0 35 65 -27 141.5 1972 3.79999995 3.79999995 sediments, weathered
297.200012 59.2000008 6 0 50 70 -30.5 151.5 1964 9.10000038 9.89999962 sediments, weathered
102 19.8999996 21.7000008 18.7999992 65 245 -32 116 1944 28.1000004 28.1000004 intrusives
310.899994 68.5 0 0 40 60 -35 150 1927 5.19999981 5.19999981 extrusives, basalts
271 63 2.9000001 352 50 80 -34 151 1595 3.5 4.5 intrusives
318 37 6.80000019 41 56 59 -33.2000008 151.100006 1597 13.1999998 13.3999996 intrusives
324 51 3.29999995 960 65 100 -34 151 1591 6.0999999 6.4000001 intrusives
272 66 4.80000019 191 60 100 -33.7000008 151.100006 1592 5.80000019 7.4000001 intrusives
|
D
|
.\" $Header: XPoint.d,v 1.2 87/09/01 18:23:04 mento Exp $
The
.PN XDrawPoint
function uses the foreground pixel and function components of the graphics context to
draw a single point into the specified drawable, while
.PN XDrawPoints
draws multiple points into the specified drawable.
These functions are not affected by the tile or stipple in the graphics context.
|
D
|
# FIXED
driverlib/f28004x/driverlib/cla.obj: C:/Users/STarikUser/Documents/F280049_Projects/F280049_Projects_GIT/DSP_280049_Common/driverlib/f28004x/driverlib/cla.c
driverlib/f28004x/driverlib/cla.obj: C:/Users/STarikUser/Documents/F280049_Projects/F280049_Projects_GIT/DSP_280049_Common/driverlib/f28004x/driverlib/cla.h
driverlib/f28004x/driverlib/cla.obj: C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/stdint.h
driverlib/f28004x/driverlib/cla.obj: C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/_ti_config.h
driverlib/f28004x/driverlib/cla.obj: C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/linkage.h
driverlib/f28004x/driverlib/cla.obj: C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/_stdint40.h
driverlib/f28004x/driverlib/cla.obj: C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/sys/stdint.h
driverlib/f28004x/driverlib/cla.obj: C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/sys/cdefs.h
driverlib/f28004x/driverlib/cla.obj: C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/sys/_types.h
driverlib/f28004x/driverlib/cla.obj: C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/machine/_types.h
driverlib/f28004x/driverlib/cla.obj: C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/machine/_stdint.h
driverlib/f28004x/driverlib/cla.obj: C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/sys/_stdint.h
driverlib/f28004x/driverlib/cla.obj: C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/stdbool.h
driverlib/f28004x/driverlib/cla.obj: C:/Users/STarikUser/Documents/F280049_Projects/F280049_Projects_GIT/DSP_280049_Common/driverlib/f28004x/driverlib/cpu.h
driverlib/f28004x/driverlib/cla.obj: C:/Users/STarikUser/Documents/F280049_Projects/F280049_Projects_GIT/DSP_280049_Common/driverlib/f28004x/driverlib/debug.h
driverlib/f28004x/driverlib/cla.obj: C:/Users/STarikUser/Documents/F280049_Projects/F280049_Projects_GIT/DSP_280049_Common/driverlib/f28004x/driverlib/inc/hw_cla.h
driverlib/f28004x/driverlib/cla.obj: C:/Users/STarikUser/Documents/F280049_Projects/F280049_Projects_GIT/DSP_280049_Common/driverlib/f28004x/driverlib/inc/hw_memmap.h
driverlib/f28004x/driverlib/cla.obj: C:/Users/STarikUser/Documents/F280049_Projects/F280049_Projects_GIT/DSP_280049_Common/driverlib/f28004x/driverlib/inc/hw_sysctl.h
driverlib/f28004x/driverlib/cla.obj: C:/Users/STarikUser/Documents/F280049_Projects/F280049_Projects_GIT/DSP_280049_Common/driverlib/f28004x/driverlib/inc/hw_types.h
C:/Users/STarikUser/Documents/F280049_Projects/F280049_Projects_GIT/DSP_280049_Common/driverlib/f28004x/driverlib/cla.c:
C:/Users/STarikUser/Documents/F280049_Projects/F280049_Projects_GIT/DSP_280049_Common/driverlib/f28004x/driverlib/cla.h:
C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/stdint.h:
C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/_ti_config.h:
C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/linkage.h:
C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/_stdint40.h:
C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/sys/stdint.h:
C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/sys/cdefs.h:
C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/sys/_types.h:
C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/machine/_types.h:
C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/machine/_stdint.h:
C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/sys/_stdint.h:
C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include/stdbool.h:
C:/Users/STarikUser/Documents/F280049_Projects/F280049_Projects_GIT/DSP_280049_Common/driverlib/f28004x/driverlib/cpu.h:
C:/Users/STarikUser/Documents/F280049_Projects/F280049_Projects_GIT/DSP_280049_Common/driverlib/f28004x/driverlib/debug.h:
C:/Users/STarikUser/Documents/F280049_Projects/F280049_Projects_GIT/DSP_280049_Common/driverlib/f28004x/driverlib/inc/hw_cla.h:
C:/Users/STarikUser/Documents/F280049_Projects/F280049_Projects_GIT/DSP_280049_Common/driverlib/f28004x/driverlib/inc/hw_memmap.h:
C:/Users/STarikUser/Documents/F280049_Projects/F280049_Projects_GIT/DSP_280049_Common/driverlib/f28004x/driverlib/inc/hw_sysctl.h:
C:/Users/STarikUser/Documents/F280049_Projects/F280049_Projects_GIT/DSP_280049_Common/driverlib/f28004x/driverlib/inc/hw_types.h:
|
D
|
/* Digital Mars DMDScript source code.
* Copyright (c) 2000-2002 by Chromium Communications
* D version Copyright (c) 2004-2010 by Digital Mars
* 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)
* written by Walter Bright
* http://www.digitalmars.com
*
* D2 port by Dmitry Olshansky
*
* Upgrading to EcmaScript 5.1 by Carsten Bleser Rasmussen
*
* DMDScript is implemented in the D Programming Language,
* http://www.digitalmars.com/d/
*
* For a C++ implementation of DMDScript, including COM support, see
* http://www.digitalmars.com/dscript/cppscript.html
*/
module dmdscript.symbol;
import std.stdio;
import dmdscript.script;
import dmdscript.identifier;
import dmdscript.scopex;
import dmdscript.statement;
import dmdscript.irstate;
import dmdscript.opcodes;
import dmdscript.errmsgs;
/****************************** Symbol ******************************/
class Symbol : ScriptType
{
Identifier *ident;
this()
{
}
this(Identifier * ident)
{
this.ident = ident;
}
override bool opEquals(Object o)
{
Symbol s;
if(this == o)
return true;
s = cast(Symbol)o;
if(s && ident == s.ident)
return true;
return false;
}
override d_string toText()
{
return ident ? "__ident" : "__anonymous";
}
void semantic(Scope *sc)
{
assert(0);
}
Symbol search(Identifier *ident)
{
assert(0);
//error(DTEXT("%s.%s is undefined"),toString(), ident.toString());
}
void toBuffer(ref wchar[] buf)
{
buf ~= toText;
}
}
/********************************* ScopeSymbol ****************************/
// Symbol that generates a scope
class ScopeSymbol : Symbol
{
Symbol[] members; // all Symbol's in this scope
SymbolTable *symtab; // member[] sorted into table
this()
{
super();
}
this(Identifier * id)
{
super(id);
}
override Symbol search(Identifier *ident)
{
Symbol s;
//writef("ScopeSymbol::search(%s, '%s')\n", toString(), ident.toString());
// Look in symbols declared in this module
s = symtab ? symtab.lookup(ident) : null;
if(s)
writef("\ts = '%s.%s'\n", toString(), s.toString());
return s;
}
}
/****************************** SymbolTable ******************************/
// Table of Symbol's
struct SymbolTable
{
Symbol[Identifier *] members;
// Look up Identifier. Return Symbol if found, NULL if not.
Symbol lookup(Identifier *ident)
{
Symbol *ps;
ps = ident in members;
if(ps)
return *ps;
return null;
}
// Insert Symbol in table. Return NULL if already there.
Symbol insert(Symbol s)
{
Symbol *ps;
ps = s.ident in members;
if(ps)
return null; // already in table
members[s.ident] = s;
return s;
}
// Look for Symbol in table. If there, return it.
// If not, insert s and return that.
Symbol update(Symbol s)
{
members[s.ident] = s;
return s;
}
}
/****************************** FunctionSymbol ******************************/
class FunctionSymbol : ScopeSymbol
{
Loc loc;
Identifier*[] parameters; // array of Identifier's
TopStatement[] topstatements; // array of TopStatement's
SymbolTable labtab; // symbol table for LabelSymbol's
IR *code;
uint nlocals;
this(Loc loc, Identifier * ident, Identifier *[] parameters,
TopStatement[] topstatements)
{
super(ident);
this.loc = loc;
this.parameters = parameters;
this.topstatements = topstatements;
}
override void semantic(Scope *sc)
{
}
}
/****************************** LabelSymbol ******************************/
class LabelSymbol : Symbol
{ Loc loc;
LabelStatement statement;
this(Loc loc, Identifier * ident, LabelStatement statement)
{
super(ident);
this.loc = loc;
this.statement = statement;
}
}
|
D
|
module test.with_wrapper.test;
import test.with_wrapper.mul;
import test.with_wrapper.no_prologue;
import test.with_wrapper.no_unittest;
import test.with_wrapper.excluded;
version (unittest) {
static import test.with_wrapper.sut_wrapper; // import
}
int add (const int arg, const int n) {
return arg + n;
}
@("add")
unittest {
mixin (test.with_wrapper.sut_wrapper.prologue); // prologue code
assert (add(10, 1) == 11);
}
int sub (const int arg, const int n) {
return arg - n;
}
@("sub")
unittest {
mixin (test.with_wrapper.sut_wrapper.prologue); // prologue code
assert (sub(10, 1) == 9);
}
|
D
|
// This source code is in the public domain.
// Example of:
// a plain button
// coded in the imperative paradigm
// no args passed to the button's callback
import std.stdio;
import gtk.MainWindow;
import gtk.Main;
import gtk.Widget;
import gtk.Button; // *** NEW ***
import gdk.Event; // *** NEW ***
void main(string[] args)
{
string title = "Button in a Window - Inperative";
string buttonText = "Label Text";
Main.init(args);
MainWindow testRigWindow = new MainWindow(title);
testRigWindow.addOnDestroy(delegate void(Widget w) { quitApp(); } );
Button button = new Button(buttonText); // *** NEW ***
button.addOnClicked(delegate void(Button b) { quitApp(); });
testRigWindow.add(button);
testRigWindow.showAll();
Main.run();
} // main()
void quitApp()
{
string exitMessage = "Bye.";
writeln(exitMessage);
Main.quit();
} // quitApp()
|
D
|
a quantity that is added
a change resulting in an increase
a process of becoming larger or longer or more numerous or more important
the amount by which something increases
the act of increasing something
become bigger or greater in amount
make bigger or more
|
D
|
module android.java.android.accessibilityservice.GestureDescription_Builder_d_interface;
import arsd.jni : IJavaObjectImplementation, JavaPackageId, JavaName, IJavaObject, ImportExportImpl, JavaInterfaceMembers;
static import arsd.jni;
import import3 = android.java.java.lang.Class_d_interface;
import import1 = android.java.android.accessibilityservice.GestureDescription_StrokeDescription_d_interface;
import import2 = android.java.android.accessibilityservice.GestureDescription_d_interface;
import import0 = android.java.android.accessibilityservice.GestureDescription_Builder_d_interface;
@JavaName("GestureDescription$Builder")
final class GestureDescription_Builder : IJavaObject {
static immutable string[] _d_canCastTo = [
];
@Import this(arsd.jni.Default);
@Import import0.GestureDescription_Builder addStroke(import1.GestureDescription_StrokeDescription);
@Import import2.GestureDescription build();
@Import import3.Class getClass();
@Import int hashCode();
@Import bool equals(IJavaObject);
@Import @JavaName("toString") string toString_();
override string toString() { return arsd.jni.javaObjectToString(this); }
@Import void notify();
@Import void notifyAll();
@Import void wait(long);
@Import void wait(long, int);
@Import void wait();
mixin IJavaObjectImplementation!(false);
public static immutable string _javaParameterString = "Landroid/accessibilityservice/GestureDescription$Builder;";
}
|
D
|
/Users/sunchuyue/Documents/test/RX_Product/DerivedData/RX_Product/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/EZSwiftExtensions.build/Objects-normal/x86_64/CGPointExtensions.o : /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockSwipe.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockPinch.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockPan.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/FileManagerExtension.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/CollectionsExtension.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UserDefaultsExtension.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockButton.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockTap.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/URLExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UITextFieldExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIStoryboardExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIDeviceExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIImageExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/DoubleExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BundleExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/ErrorTypeExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/DateExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/StringExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/NSAttributedStringExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UISwitchExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UILabelExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BoolExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIBarButtonItemExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIApplicationExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIButtonExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UISliderExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIAlertControllerExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIViewControllerExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/TimerExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/CharacterExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIColorExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIUserInterfaceSizeClassExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/CGFloatExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/CGRectExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/NSObjectExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/IntExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/CGPointExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/FloatingPointExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIFontExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIViewExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIImageViewExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UITextViewExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIWindowExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/ArrayExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/DictionaryExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/NSDictionaryExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/EZSwiftFunctions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockLongPress.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIEdgeInsets.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockWebView.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIColoredView.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/sunchuyue/Documents/test/RX_Product/Pods/Target\ Support\ Files/EZSwiftExtensions/EZSwiftExtensions-umbrella.h /Users/sunchuyue/Documents/test/RX_Product/DerivedData/RX_Product/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/EZSwiftExtensions.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/sunchuyue/Documents/test/RX_Product/DerivedData/RX_Product/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/EZSwiftExtensions.build/Objects-normal/x86_64/CGPointExtensions~partial.swiftmodule : /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockSwipe.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockPinch.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockPan.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/FileManagerExtension.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/CollectionsExtension.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UserDefaultsExtension.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockButton.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockTap.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/URLExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UITextFieldExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIStoryboardExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIDeviceExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIImageExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/DoubleExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BundleExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/ErrorTypeExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/DateExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/StringExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/NSAttributedStringExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UISwitchExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UILabelExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BoolExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIBarButtonItemExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIApplicationExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIButtonExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UISliderExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIAlertControllerExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIViewControllerExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/TimerExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/CharacterExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIColorExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIUserInterfaceSizeClassExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/CGFloatExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/CGRectExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/NSObjectExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/IntExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/CGPointExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/FloatingPointExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIFontExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIViewExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIImageViewExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UITextViewExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIWindowExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/ArrayExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/DictionaryExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/NSDictionaryExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/EZSwiftFunctions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockLongPress.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIEdgeInsets.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockWebView.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIColoredView.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/sunchuyue/Documents/test/RX_Product/Pods/Target\ Support\ Files/EZSwiftExtensions/EZSwiftExtensions-umbrella.h /Users/sunchuyue/Documents/test/RX_Product/DerivedData/RX_Product/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/EZSwiftExtensions.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/sunchuyue/Documents/test/RX_Product/DerivedData/RX_Product/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/EZSwiftExtensions.build/Objects-normal/x86_64/CGPointExtensions~partial.swiftdoc : /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockSwipe.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockPinch.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockPan.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/FileManagerExtension.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/CollectionsExtension.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UserDefaultsExtension.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockButton.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockTap.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/URLExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UITextFieldExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIStoryboardExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIDeviceExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIImageExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/DoubleExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BundleExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/ErrorTypeExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/DateExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/StringExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/NSAttributedStringExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UISwitchExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UILabelExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BoolExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIBarButtonItemExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIApplicationExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIButtonExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UISliderExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIAlertControllerExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIViewControllerExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/TimerExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/CharacterExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIColorExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIUserInterfaceSizeClassExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/CGFloatExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/CGRectExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/NSObjectExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/IntExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/CGPointExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/FloatingPointExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIFontExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIViewExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIImageViewExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UITextViewExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIWindowExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/ArrayExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/DictionaryExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/NSDictionaryExtensions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/EZSwiftFunctions.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockLongPress.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIEdgeInsets.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/BlockWebView.swift /Users/sunchuyue/Documents/test/RX_Product/Pods/EZSwiftExtensions/Sources/UIColoredView.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/sunchuyue/Documents/test/RX_Product/Pods/Target\ Support\ Files/EZSwiftExtensions/EZSwiftExtensions-umbrella.h /Users/sunchuyue/Documents/test/RX_Product/DerivedData/RX_Product/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/EZSwiftExtensions.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
|
D
|
/Users/okasho/serverProject/tryswift/helloworld/swift/.build/debug/Console.build/Terminal/Terminal+Command.swift.o : /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Bar/Bar.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Argument.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Command+Print.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Command.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Group.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Option.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Runnable.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Value.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console+Ask.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console+Center.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console+Confirm.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console+Options.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console+Print.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console+Run.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/ConsoleError.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Stream/FileHandle+Stream.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Stream/Pipe+Stream.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Stream/Stream.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Terminal/ConsoleColor+Terminal.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Terminal/ConsoleStyle+Terminal.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Terminal/String+ANSI.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Terminal/Terminal+Command.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Terminal/Terminal.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Utilities/Bool+Polymorphic.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Utilities/String+Trim.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Bar/Loading/Console+LoadingBar.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Bar/Loading/LoadingBar.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Bar/Progress/Console+ProgressBar.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Bar/Progress/ProgressBar.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Clear/ConsoleClear.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Color/ConsoleColor.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Style/Console+ConsoleStyle.swift /Users/okasho/serverProject/tryswift/helloworld/swift/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/okasho/serverProject/tryswift/helloworld/swift/.build/debug/libc.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Users/okasho/serverProject/tryswift/helloworld/swift/.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/okasho/serverProject/tryswift/helloworld/swift/.build/debug/Core.swiftmodule
/Users/okasho/serverProject/tryswift/helloworld/swift/.build/debug/Console.build/Terminal+Command~partial.swiftmodule : /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Bar/Bar.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Argument.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Command+Print.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Command.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Group.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Option.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Runnable.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Value.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console+Ask.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console+Center.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console+Confirm.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console+Options.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console+Print.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console+Run.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/ConsoleError.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Stream/FileHandle+Stream.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Stream/Pipe+Stream.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Stream/Stream.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Terminal/ConsoleColor+Terminal.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Terminal/ConsoleStyle+Terminal.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Terminal/String+ANSI.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Terminal/Terminal+Command.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Terminal/Terminal.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Utilities/Bool+Polymorphic.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Utilities/String+Trim.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Bar/Loading/Console+LoadingBar.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Bar/Loading/LoadingBar.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Bar/Progress/Console+ProgressBar.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Bar/Progress/ProgressBar.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Clear/ConsoleClear.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Color/ConsoleColor.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Style/Console+ConsoleStyle.swift /Users/okasho/serverProject/tryswift/helloworld/swift/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/okasho/serverProject/tryswift/helloworld/swift/.build/debug/libc.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Users/okasho/serverProject/tryswift/helloworld/swift/.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/okasho/serverProject/tryswift/helloworld/swift/.build/debug/Core.swiftmodule
/Users/okasho/serverProject/tryswift/helloworld/swift/.build/debug/Console.build/Terminal+Command~partial.swiftdoc : /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Bar/Bar.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Argument.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Command+Print.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Command.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Group.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Option.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Runnable.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Command/Value.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console+Ask.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console+Center.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console+Confirm.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console+Options.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console+Print.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console+Run.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Console.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/ConsoleError.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Stream/FileHandle+Stream.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Stream/Pipe+Stream.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Stream/Stream.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Terminal/ConsoleColor+Terminal.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Terminal/ConsoleStyle+Terminal.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Terminal/String+ANSI.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Terminal/Terminal+Command.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Terminal/Terminal.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Utilities/Bool+Polymorphic.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Utilities/String+Trim.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Bar/Loading/Console+LoadingBar.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Bar/Loading/LoadingBar.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Bar/Progress/Console+ProgressBar.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Bar/Progress/ProgressBar.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Clear/ConsoleClear.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Color/ConsoleColor.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/Console-1.0.2/Sources/Console/Console/Style/Console+ConsoleStyle.swift /Users/okasho/serverProject/tryswift/helloworld/swift/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/okasho/serverProject/tryswift/helloworld/swift/.build/debug/libc.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Users/okasho/serverProject/tryswift/helloworld/swift/.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/okasho/serverProject/tryswift/helloworld/swift/.build/debug/Core.swiftmodule
|
D
|
// Written in the D programming language
/**
Change log generator which fetches the list of bugfixes
from the D Bugzilla between the given dates.
It stores its result in DDoc form to a text file.
Copyright: Dmitry Olshansky 2013.
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: Dmitry Olshansky,
Andrej Mitrovic
Example usage:
---
rdmd changed.d --start=2013-01-01 --end=2013-04-01
rdmd changed.d --start=2013-01-01 (end date implicitly set to current date)
---
$(B Note:) The script will cache the results of an invocation, to avoid
re-querying bugzilla when invoked with the same arguments.
Use the --nocache option to override this behavior.
*/
// NOTE: this script requires libcurl to be linked in (usually done by default).
module changed;
import std.net.curl, std.conv, std.exception, std.algorithm, std.csv, std.typecons,
std.stdio, std.datetime, std.array, std.string, std.file, std.format, std.getopt,
std.path;
string[dchar] charToValid;
shared static this()
{
charToValid = [':' : "_", ' ': ""];
}
/** Return a valid file name. */
string normalize(string input)
{
return input.translate(charToValid);
}
/** Generate location for the cache file. */
string getCachePath(string start_date, string end_date)
{
return buildPath(tempDir(),
format("dlog_%s_%s_%s_%s",
__DATE__, __TIME__, start_date, end_date).normalize());
}
auto templateRequest =
`https://issues.dlang.org/buglist.cgi?username=crap2crap%40yandex.ru&password=powerlow7&chfieldto={to}&query_format=advanced&chfield=resolution&chfieldfrom={from}&bug_status=RESOLVED&resolution=FIXED&product=D&ctype=csv&columnlist=component%2Cbug_severity%2Cshort_desc`;
auto generateRequest(string templ, Date start, Date end)
{
auto ss = format("%04s-%02s-%02s", start.year, to!int(start.month), start.day);
auto es = format("%04s-%02s-%02s", end.year, to!int(end.month), end.day);
return templateRequest.replace("{from}", ss).replace("{to}", es);
}
auto dateFromStr(string sdate)
{
int year, month, day;
formattedRead(sdate, "%s-%s-%s", &year, &month, &day);
return Date(year, month, day);
}
struct Entry
{
int id;
string summary;
}
string[dchar] parenToMacro;
shared static this()
{
parenToMacro = ['(' : "$(LPAREN)", ')' : "$(RPAREN)"];
}
/** Replace '(' and ')' with macros to avoid closing down macros by accident. */
string escapeParens(string input)
{
return input.translate(parenToMacro);
}
/** Generate and return the change log as a string. */
string getChangeLog(Date start, Date end)
{
auto req = generateRequest(templateRequest, start, end);
debug stderr.writeln(req); // write text
auto data = req.get;
// component (e.g. DMD) -> bug type (e.g. regression) -> list of bug entries
Entry[][string][string] entries;
immutable bugtypes = ["regressions", "bugs", "enhancements"];
immutable components = ["DMD Compiler", "Phobos", "Druntime", "Optlink", "Installer", "Website"];
foreach (fields; csvReader!(Tuple!(int, string, string, string))(data, null))
{
string comp = fields[1].toLower;
switch (comp)
{
case "dmd": comp = "DMD Compiler"; break;
case "websites": comp = "Website"; break;
default: comp = comp.capitalize;
}
string type = fields[2].toLower;
switch (type)
{
case "regression":
type = "regressions";
break;
case "blocker", "critical", "major", "normal", "minor", "trivial":
type = "bugs";
break;
case "enhancement":
type = "enhancements";
break;
default: assert(0, type);
}
entries[comp][type] ~= Entry(fields[0], fields[3].idup);
}
Appender!string result;
result ~= "$(BUGSTITLE Language Changes,\n";
result ~= "-- Insert major language changes here --\n)\n\n";
result ~= "$(BUGSTITLE Library Changes,\n";
result ~= "-- Insert major library changes here --\n)\n\n";
result ~= "$(BR)$(BIG List of all bug fixes and enhancements:)\n\n";
foreach (component; components)
if (auto comp = component in entries)
{
foreach (bugtype; bugtypes)
if (auto bugs = bugtype in *comp)
{
result ~= format("$(BUGSTITLE %s %s,\n\n", component, bugtype);
result ~= "$(P\n";
foreach (bug; sort!"a.id < b.id"(*bugs))
{
result ~= format("$(LI $(BUGZILLA %s): %s)\n",
bug.id, bug.summary.escapeParens());
}
result ~= ")\n";
result ~= ")\n";
}
}
return result.data;
}
int main(string[] args)
{
string start_date, end_date;
bool ddoc = false;
bool nocache; // don't read from cache
getopt(args,
"nocache", &nocache,
"start", &start_date, // numeric
"end", &end_date); // string
if (start_date.empty)
{
stderr.writefln("*ERROR: No start date set.\nUsage example:\n%s --start=YYYY-MM-HH [--end=YYYY-MM-HH] ",
args[0].baseName);
return 1;
}
Date start = dateFromStr(start_date);
Date end = end_date.empty ? to!Date(Clock.currTime()) : dateFromStr(end_date);
// caching to avoid querying bugzilla
// (depends on the compile date of the generator + the start and end dates)
string cachePath = getCachePath(to!string(start), to!string(end));
debug stderr.writefln("Cache file: %s\nCache file found: %s", cachePath, cachePath.exists);
string changeLog;
if (!nocache && cachePath.exists)
{
changeLog = (cast(string)read(cachePath)).strip;
}
else
{
changeLog = getChangeLog(start, end);
std.file.write(cachePath, changeLog);
}
string logPath = "./changelog.txt".absolutePath.buildNormalizedPath;
std.file.write(logPath, changeLog);
writefln("Change log generated to: '%s'", logPath);
return 0;
}
|
D
|
/Users/phungdu/Documents/code/vapor/TILApp/Build/Intermediates/TILApp.build/Debug/HTTP.build/Objects-normal/x86_64/HTTPBodyStorage.o : /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Utilities/RFC1123.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/URL+HTTP.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Utilities/HTTPHeaders+Basic.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/Forwarded.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/MediaTypePreference.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Body/HTTPBodyStorage.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/HTTPMessage.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Body/HTTPBodyRepresentable.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/HTTPHeaderName.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Responder/HTTPScheme.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/HTTPResponse.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Cookies/HTTPCookieValue.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Body/HTTPChunkedStream.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Responder/HTTPClientProtocolUpgrader.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Responder/HTTPServerResponder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Codable/HTTPMessageCoder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Utilities/HTTPHeaders+Bearer.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Responder/HTTPServer.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Utilities/HTTPError.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Cookies/HTTPCookies.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/HTTPHeaders.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Utilities/String+IsIPAddress.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Exports.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Responder/HTTPClient.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/HTTPRequest.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Body/HTTPBody.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/NIOHTTP1.framework/Modules/NIOHTTP1.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/NIOOpenSSL.framework/Modules/NIOOpenSSL.swiftmodule/x86_64.swiftmodule /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/NIOTLS.framework/Modules/NIOTLS.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/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 /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 /usr/local/Cellar/libressl/2.8.3/include/openssl/asn1.h /usr/local/Cellar/libressl/2.8.3/include/openssl/tls1.h /usr/local/Cellar/libressl/2.8.3/include/openssl/dtls1.h /usr/local/Cellar/libressl/2.8.3/include/openssl/pkcs12.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ssl2.h /usr/local/Cellar/libressl/2.8.3/include/openssl/pem2.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ssl23.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ssl3.h /usr/local/Cellar/libressl/2.8.3/include/openssl/x509v3.h /usr/local/Cellar/libressl/2.8.3/include/openssl/md5.h /usr/local/Cellar/libressl/2.8.3/include/openssl/pkcs7.h /usr/local/Cellar/libressl/2.8.3/include/openssl/x509.h /usr/local/Cellar/libressl/2.8.3/include/openssl/sha.h /usr/local/Cellar/libressl/2.8.3/include/openssl/dsa.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ecdsa.h /usr/local/Cellar/libressl/2.8.3/include/openssl/rsa.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOZlib.framework/Headers/CNIOZlib.h /usr/local/Cellar/libressl/2.8.3/include/openssl/obj_mac.h /usr/local/Cellar/libressl/2.8.3/include/openssl/hmac.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ec.h /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 /usr/local/Cellar/libressl/2.8.3/include/openssl/rand.h /usr/local/Cellar/libressl/2.8.3/include/openssl/conf.h /usr/local/Cellar/libressl/2.8.3/include/openssl/opensslconf.h /usr/local/Cellar/libressl/2.8.3/include/openssl/dh.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ecdh.h /usr/local/Cellar/libressl/2.8.3/include/openssl/lhash.h /usr/local/Cellar/libressl/2.8.3/include/openssl/stack.h /usr/local/Cellar/libressl/2.8.3/include/openssl/safestack.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ssl.h /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/swift-nio-ssl.git-364103626492085369/Sources/CNIOOpenSSL/include/c_nio_openssl.h /usr/local/Cellar/libressl/2.8.3/include/openssl/pem.h /usr/local/Cellar/libressl/2.8.3/include/openssl/bn.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIODarwin.framework/Headers/CNIODarwin.h /usr/local/Cellar/libressl/2.8.3/include/openssl/bio.h /usr/local/Cellar/libressl/2.8.3/include/openssl/crypto.h /usr/local/Cellar/libressl/2.8.3/include/openssl/srtp.h /usr/local/Cellar/libressl/2.8.3/include/openssl/evp.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/2.8.3/include/openssl/buffer.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOHTTPParser.framework/Headers/CNIOHTTPParser.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOHTTPParser.framework/Headers/c_nio_http_parser.h /usr/local/Cellar/libressl/2.8.3/include/openssl/err.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOAtomics.framework/Headers/CNIOAtomics.h /usr/local/Cellar/libressl/2.8.3/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/2.8.3/include/openssl/objects.h /usr/local/Cellar/libressl/2.8.3/include/openssl/opensslv.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOLinux.framework/Headers/CNIOLinux.h /usr/local/Cellar/libressl/2.8.3/include/openssl/x509_vfy.h /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/swift-nio-ssl-support.git-5405304412507994221/module.modulemap /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/swift-nio-zlib-support.git--5226887469817572071/module.modulemap /Users/phungdu/Documents/code/vapor/TILApp/TILApp.xcodeproj/GeneratedModuleMap/CNIOOpenSSL/module.modulemap /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOZlib.framework/Modules/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/CNIOHTTPParser.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/HTTP.build/Objects-normal/x86_64/HTTPBodyStorage~partial.swiftmodule : /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Utilities/RFC1123.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/URL+HTTP.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Utilities/HTTPHeaders+Basic.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/Forwarded.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/MediaTypePreference.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Body/HTTPBodyStorage.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/HTTPMessage.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Body/HTTPBodyRepresentable.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/HTTPHeaderName.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Responder/HTTPScheme.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/HTTPResponse.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Cookies/HTTPCookieValue.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Body/HTTPChunkedStream.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Responder/HTTPClientProtocolUpgrader.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Responder/HTTPServerResponder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Codable/HTTPMessageCoder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Utilities/HTTPHeaders+Bearer.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Responder/HTTPServer.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Utilities/HTTPError.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Cookies/HTTPCookies.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/HTTPHeaders.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Utilities/String+IsIPAddress.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Exports.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Responder/HTTPClient.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/HTTPRequest.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Body/HTTPBody.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/NIOHTTP1.framework/Modules/NIOHTTP1.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/NIOOpenSSL.framework/Modules/NIOOpenSSL.swiftmodule/x86_64.swiftmodule /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/NIOTLS.framework/Modules/NIOTLS.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/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 /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 /usr/local/Cellar/libressl/2.8.3/include/openssl/asn1.h /usr/local/Cellar/libressl/2.8.3/include/openssl/tls1.h /usr/local/Cellar/libressl/2.8.3/include/openssl/dtls1.h /usr/local/Cellar/libressl/2.8.3/include/openssl/pkcs12.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ssl2.h /usr/local/Cellar/libressl/2.8.3/include/openssl/pem2.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ssl23.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ssl3.h /usr/local/Cellar/libressl/2.8.3/include/openssl/x509v3.h /usr/local/Cellar/libressl/2.8.3/include/openssl/md5.h /usr/local/Cellar/libressl/2.8.3/include/openssl/pkcs7.h /usr/local/Cellar/libressl/2.8.3/include/openssl/x509.h /usr/local/Cellar/libressl/2.8.3/include/openssl/sha.h /usr/local/Cellar/libressl/2.8.3/include/openssl/dsa.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ecdsa.h /usr/local/Cellar/libressl/2.8.3/include/openssl/rsa.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOZlib.framework/Headers/CNIOZlib.h /usr/local/Cellar/libressl/2.8.3/include/openssl/obj_mac.h /usr/local/Cellar/libressl/2.8.3/include/openssl/hmac.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ec.h /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 /usr/local/Cellar/libressl/2.8.3/include/openssl/rand.h /usr/local/Cellar/libressl/2.8.3/include/openssl/conf.h /usr/local/Cellar/libressl/2.8.3/include/openssl/opensslconf.h /usr/local/Cellar/libressl/2.8.3/include/openssl/dh.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ecdh.h /usr/local/Cellar/libressl/2.8.3/include/openssl/lhash.h /usr/local/Cellar/libressl/2.8.3/include/openssl/stack.h /usr/local/Cellar/libressl/2.8.3/include/openssl/safestack.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ssl.h /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/swift-nio-ssl.git-364103626492085369/Sources/CNIOOpenSSL/include/c_nio_openssl.h /usr/local/Cellar/libressl/2.8.3/include/openssl/pem.h /usr/local/Cellar/libressl/2.8.3/include/openssl/bn.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIODarwin.framework/Headers/CNIODarwin.h /usr/local/Cellar/libressl/2.8.3/include/openssl/bio.h /usr/local/Cellar/libressl/2.8.3/include/openssl/crypto.h /usr/local/Cellar/libressl/2.8.3/include/openssl/srtp.h /usr/local/Cellar/libressl/2.8.3/include/openssl/evp.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/2.8.3/include/openssl/buffer.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOHTTPParser.framework/Headers/CNIOHTTPParser.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOHTTPParser.framework/Headers/c_nio_http_parser.h /usr/local/Cellar/libressl/2.8.3/include/openssl/err.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOAtomics.framework/Headers/CNIOAtomics.h /usr/local/Cellar/libressl/2.8.3/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/2.8.3/include/openssl/objects.h /usr/local/Cellar/libressl/2.8.3/include/openssl/opensslv.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOLinux.framework/Headers/CNIOLinux.h /usr/local/Cellar/libressl/2.8.3/include/openssl/x509_vfy.h /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/swift-nio-ssl-support.git-5405304412507994221/module.modulemap /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/swift-nio-zlib-support.git--5226887469817572071/module.modulemap /Users/phungdu/Documents/code/vapor/TILApp/TILApp.xcodeproj/GeneratedModuleMap/CNIOOpenSSL/module.modulemap /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOZlib.framework/Modules/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/CNIOHTTPParser.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/HTTP.build/Objects-normal/x86_64/HTTPBodyStorage~partial.swiftdoc : /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Utilities/RFC1123.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/URL+HTTP.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Utilities/HTTPHeaders+Basic.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/Forwarded.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/MediaTypePreference.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Body/HTTPBodyStorage.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/HTTPMessage.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Body/HTTPBodyRepresentable.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/HTTPHeaderName.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Responder/HTTPScheme.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/HTTPResponse.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Cookies/HTTPCookieValue.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Body/HTTPChunkedStream.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Responder/HTTPClientProtocolUpgrader.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Responder/HTTPServerResponder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Codable/HTTPMessageCoder.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Utilities/HTTPHeaders+Bearer.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Responder/HTTPServer.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Utilities/HTTPError.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Cookies/HTTPCookies.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/HTTPHeaders.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Utilities/String+IsIPAddress.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Exports.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Responder/HTTPClient.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Message/HTTPRequest.swift /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/http.git-6906648727968998715/Sources/HTTP/Body/HTTPBody.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/NIOHTTP1.framework/Modules/NIOHTTP1.swiftmodule/x86_64.swiftmodule /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/NIOOpenSSL.framework/Modules/NIOOpenSSL.swiftmodule/x86_64.swiftmodule /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/NIOTLS.framework/Modules/NIOTLS.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/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 /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 /usr/local/Cellar/libressl/2.8.3/include/openssl/asn1.h /usr/local/Cellar/libressl/2.8.3/include/openssl/tls1.h /usr/local/Cellar/libressl/2.8.3/include/openssl/dtls1.h /usr/local/Cellar/libressl/2.8.3/include/openssl/pkcs12.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ssl2.h /usr/local/Cellar/libressl/2.8.3/include/openssl/pem2.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ssl23.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ssl3.h /usr/local/Cellar/libressl/2.8.3/include/openssl/x509v3.h /usr/local/Cellar/libressl/2.8.3/include/openssl/md5.h /usr/local/Cellar/libressl/2.8.3/include/openssl/pkcs7.h /usr/local/Cellar/libressl/2.8.3/include/openssl/x509.h /usr/local/Cellar/libressl/2.8.3/include/openssl/sha.h /usr/local/Cellar/libressl/2.8.3/include/openssl/dsa.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ecdsa.h /usr/local/Cellar/libressl/2.8.3/include/openssl/rsa.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOZlib.framework/Headers/CNIOZlib.h /usr/local/Cellar/libressl/2.8.3/include/openssl/obj_mac.h /usr/local/Cellar/libressl/2.8.3/include/openssl/hmac.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ec.h /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 /usr/local/Cellar/libressl/2.8.3/include/openssl/rand.h /usr/local/Cellar/libressl/2.8.3/include/openssl/conf.h /usr/local/Cellar/libressl/2.8.3/include/openssl/opensslconf.h /usr/local/Cellar/libressl/2.8.3/include/openssl/dh.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ecdh.h /usr/local/Cellar/libressl/2.8.3/include/openssl/lhash.h /usr/local/Cellar/libressl/2.8.3/include/openssl/stack.h /usr/local/Cellar/libressl/2.8.3/include/openssl/safestack.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ssl.h /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/swift-nio-ssl.git-364103626492085369/Sources/CNIOOpenSSL/include/c_nio_openssl.h /usr/local/Cellar/libressl/2.8.3/include/openssl/pem.h /usr/local/Cellar/libressl/2.8.3/include/openssl/bn.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIODarwin.framework/Headers/CNIODarwin.h /usr/local/Cellar/libressl/2.8.3/include/openssl/bio.h /usr/local/Cellar/libressl/2.8.3/include/openssl/crypto.h /usr/local/Cellar/libressl/2.8.3/include/openssl/srtp.h /usr/local/Cellar/libressl/2.8.3/include/openssl/evp.h /usr/local/Cellar/libressl/2.8.3/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/2.8.3/include/openssl/buffer.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOHTTPParser.framework/Headers/CNIOHTTPParser.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOHTTPParser.framework/Headers/c_nio_http_parser.h /usr/local/Cellar/libressl/2.8.3/include/openssl/err.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOAtomics.framework/Headers/CNIOAtomics.h /usr/local/Cellar/libressl/2.8.3/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/2.8.3/include/openssl/objects.h /usr/local/Cellar/libressl/2.8.3/include/openssl/opensslv.h /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOLinux.framework/Headers/CNIOLinux.h /usr/local/Cellar/libressl/2.8.3/include/openssl/x509_vfy.h /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/swift-nio-ssl-support.git-5405304412507994221/module.modulemap /Users/phungdu/Documents/code/vapor/TILApp/.build/checkouts/swift-nio-zlib-support.git--5226887469817572071/module.modulemap /Users/phungdu/Documents/code/vapor/TILApp/TILApp.xcodeproj/GeneratedModuleMap/CNIOOpenSSL/module.modulemap /Users/phungdu/Documents/code/vapor/TILApp/Build/Products/Debug/CNIOZlib.framework/Modules/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/CNIOHTTPParser.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
|
module monetdb.monetdb;
import std.string;
import std.exception;
import std.conv;
import std.datetime;
import std.range;
import std.variant;
import monetdb.binding;
alias Null = typeof(null);
//TODO: support const type as well
alias Record = Algebraic!(int, short, long, double, char, bool, string, Date, DateTime, Null);
class MonetDbException : Exception
{
this(string msg, string file = __FILE__, size_t line = __LINE__)
{
super(msg, file, line);
}
}
protected Record dize(T)(const T typeName, const T value) if (is(T : string))
{
Record res;
if (value == "")
{
res = null;
return res;
}
if (typeName == "int")
{
res = value.to!int;
}
else if (typeName == "tinyint")
{
res = value.to!short;
}
else if (typeName == "bigint")
{
res = value.to!long;
}
else if (typeName == "double")
{
res = value.to!double;
}
else if (typeName == "date")
{
res = Date.fromISOExtString(value.to!string);
}
else if (typeName == "timestamp")
{
auto toExtISOFormat = (const string d) => d[0 .. 10] ~ "T" ~ d[11 .. 19];
res = DateTime.fromISOExtString(toExtISOFormat(value.to!string));
}
else if (typeName == "varchar" || typeName == "char")
{
res = value.to!string;
}
else
{
enforce!MonetDbException(false, "Could not d-ize type: " ~ typeName);
}
return res;
}
protected MapiDate monetizeDate(const Date date)
{
return MapiDate(date.year, date.month, date.day);
}
protected MapiDateTime monetizeDateTime(const DateTime date)
{
return MapiDateTime(date.year, date.month, date.day, date.hour, date.minute, date.second, 0);
}
Record[] recordArray(T...)(T params)
{
Record[] records;
foreach (i, p; params)
{
records ~= Record(p);
}
return records;
}
class MonetDb
{
private Mapi _mapi;
this(string host, int port, string username, string password, string lang, string dbname) @trusted
{
_mapi = mapi_connect(toStringz(host), port, toStringz(username),
toStringz(password), toStringz(lang), toStringz(dbname));
}
~this()
{
mapi_destroy(_mapi);
}
private string errorMessage(MapiHdl handler)
{
auto msg = mapi_error_str(_mapi);
if (msg)
{
return to!string(msg);
}
return to!string(mapi_result_error(handler));
}
private int getMapiType(Record p)
{
return p.visit!((int a) => MAPI_INT, (short a) => MAPI_SHORT,
(long a) => MAPI_LONG, (char a) => MAPI_CHAR, (string a) => MAPI_VARCHAR,
(double a) => MAPI_DOUBLE, (Date a) => MAPI_DATE,
(DateTime a) => MAPI_DATETIME, (bool a) => MAPI_USHORT, (Null a) => -1)();
}
private MapiHdl buildHandler(string command, Record[] params)
{
MapiHdl result;
if (params is null)
{
result = mapi_query(_mapi, toStringz(command));
}
else
{
result = mapi_prepare(_mapi, toStringz(command));
foreach (i, p; params)
{
auto mapiType = getMapiType(p);
enforce!MonetDbException(mapiType >= 0,
"Parameter having a null value are not supported!");
if (p.type == typeid(Date))
{
auto d = p.get!Date.monetizeDate;
mapi_param_type(result, i.to!int, mapiType, mapiType, &d);
}
else if (p.type == typeid(DateTime))
{
auto d = p.get!DateTime.monetizeDateTime;
mapi_param_type(result, i.to!int, mapiType, mapiType, &d);
}
else if (p.type == typeid(string))
{
auto s = cast(char*) p.get!string.toStringz;
mapi_param_type(result, i.to!int, mapiType, mapiType, s);
}
else if (p.type == typeid(int))
{
auto v = p.get!int;
mapi_param_type(result, i.to!int, mapiType, mapiType, &v);
}
else if (p.type == typeid(long))
{
auto v = p.get!long;
mapi_param_type(result, i.to!int, mapiType, mapiType, &v);
}
else if (p.type == typeid(double))
{
auto v = p.get!double;
mapi_param_type(result, i.to!int, mapiType, mapiType, &v);
}
else if (p.type == typeid(char))
{
auto v = p.get!char;
mapi_param_type(result, i.to!int, mapiType, mapiType, &v);
}
else if (p.type == typeid(bool))
{
auto v = p.get!bool;
mapi_param_type(result, i.to!int, mapiType, mapiType, &v);
}
else
{
assert(false);
}
}
mapi_execute(result);
}
enforce!MonetDbException(mapi_error(_mapi) == MOK, errorMessage(result));
return result;
}
void exec(string command, Record[] params = null)
{
auto result = buildHandler(command, params);
mapi_close_handle(result);
}
auto query(string command, Record[] params = null)
{
auto result = buildHandler(command, params);
static struct QueryResult
{
private MapiHdl handler_;
private bool hasRow_;
private int count_;
this(MapiHdl handler)
{
handler_ = handler;
fetchRow();
}
auto empty()
{
return !hasRow_;
}
private void fetchRow()
{
hasRow_ = mapi_fetch_row(handler_) != 0;
count_ = mapi_get_field_count(handler_);
}
auto front()
{
assert(!empty);
Record[string] records;
foreach (i; iota(count_))
{
auto name = mapi_get_name(handler_, i).to!string;
auto typeName = mapi_get_type(handler_, i).to!string;
auto value = mapi_fetch_field(handler_, i).to!string;
records[name] = dize(typeName, value);
}
return records;
}
void popFront()
{
assert(!empty);
fetchRow();
if (!hasRow_)
mapi_close_handle(handler_);
}
}
return QueryResult(result);
}
void close()
{
mapi_disconnect(_mapi);
}
}
unittest
{
auto conn = new MonetDb("localhost", 50_000, "monetdb", "monetdb", "sql", "16megabytes");
scope (exit)
conn.close();
conn.exec("DROP TABLE IF EXISTS FOO;");
conn.exec(`CREATE TABLE IF NOT EXISTS FOO (
ID INTEGER NOT NULL,
VALUE VARCHAR(5),
RATIO DOUBLE,
CREATION DATE,
SYSDATE TIMESTAMP DEFAULT NOW,
FLAG BOOLEAN DEFAULT FALSE,
UNIT CHAR DEFAULT 'U'
);`);
conn.exec("INSERT INTO FOO (ID, VALUE, RATIO, CREATION) VALUES (1, 'foo', .5, '2018-01-01');");
Record[] p1 = recordArray(2, "bar", .63, Date(2018, 1, 1));
conn.exec("INSERT INTO FOO (ID, VALUE, RATIO, CREATION) VALUES (?, ?, ?, ?);", p1);
Record[] p2 = recordArray(3, Date(2019, 3, 31));
conn.exec("INSERT INTO FOO (ID, CREATION) VALUES (?, ?)", p2);
auto r = conn.query("SELECT ID, VALUE, CREATION, SYSDATE, RATIO FROM FOO ORDER BY ID");
auto row = r.front;
assert("id" in row);
assert("value" in row);
assert("creation" in row);
assert(row["id"].get!int == 1);
assert(row["value"].get!string == "foo");
assert(row["creation"].get!Date == Date(2018, 1, 1));
r.popFront();
auto row2 = r.front;
assert(row2["id"].get!int == 2);
assert(row2["value"].get!string == "bar");
assert(row2["creation"].get!Date == Date(2018, 1, 1));
r.popFront();
auto row3 = r.front;
assert(row3["value"].get!Null is null);
assert(row3["ratio"].get!Null is null);
Record[] params = recordArray(1, "foo");
auto rp = conn.query(
"SELECT ID, VALUE, RATIO, CREATION FROM FOO WHERE ID = ? AND VALUE = ?", params);
assert(rp.front["id"].get!int == 1);
assert(rp.front["value"].get!string == "foo");
assert(rp.front["ratio"].get!double == .5);
assert(rp.front["creation"].get!Date == Date(2018, 1, 1));
auto rl = conn.query("SELECT COUNT(*) AS V, ID FROM FOO WHERE FLAG = ? AND SYSDATE > ? AND UNIT = ? GROUP BY ID HAVING COUNT(*) = ?;",
recordArray(false, DateTime(1970, 1, 1, 0, 0, 0), 'U', 1L));
assert(rl.front["v"].get!long == 1L);
conn.exec("DROP TABLE FOO;");
}
unittest
{
auto conn = new MonetDb("localhost", 50_000, "monetdb", "monetdb", "sql", "16megabytes");
scope (exit)
conn.close();
conn.exec(
"CREATE TABLE IF NOT EXISTS FOO (ID INT); INSERT INTO FOO (ID) VALUES (1), (2); DROP TABLE FOO;");
}
|
D
|
module ast.statement_node;
class StatementNode {
private:
public:
}
|
D
|
import std.stdio, std.algorithm, std.array;
struct Set(T) {
immutable T[] items;
Set opSub(in Set other) const pure nothrow {
return items.filter!(x => !other.items.canFind(x)).array.Set;
}
Set opAdd(in Set other) const pure nothrow {
return Set(this.items ~ (other - this).items);
}
}
Set!T symmetricDifference(T)(in Set!T left, in Set!T right)
pure nothrow {
return (left - right) + (right - left);
}
void main() {
immutable A = ["John", "Bob", "Mary", "Serena"].Set!string;
immutable B = ["Jim", "Mary", "John", "Bob"].Set!string;
writeln(" A\\B: ", (A - B).items);
writeln(" B\\A: ", (B - A).items);
writeln("A symdiff B: ", symmetricDifference(A, B).items);
}
|
D
|
/**
*
* THIS FILE IS AUTO-GENERATED BY ./parse_specs.d FOR MCU at90pwm81 WITH ARCHITECTURE avr4
*
*/
module avr.specs.specs_at90pwm81;
enum __AVR_ARCH__ = 4;
enum __AVR_ASM_ONLY__ = false;
enum __AVR_ENHANCED__ = true;
enum __AVR_HAVE_MUL__ = true;
enum __AVR_HAVE_JMP_CALL__ = false;
enum __AVR_MEGA__ = false;
enum __AVR_HAVE_LPMX__ = true;
enum __AVR_HAVE_MOVW__ = true;
enum __AVR_HAVE_ELPM__ = false;
enum __AVR_HAVE_ELPMX__ = false;
enum __AVR_HAVE_EIJMP_EICALL_ = false;
enum __AVR_2_BYTE_PC__ = true;
enum __AVR_3_BYTE_PC__ = false;
enum __AVR_XMEGA__ = false;
enum __AVR_HAVE_RAMPX__ = false;
enum __AVR_HAVE_RAMPY__ = false;
enum __AVR_HAVE_RAMPZ__ = false;
enum __AVR_HAVE_RAMPD__ = false;
enum __AVR_TINY__ = false;
enum __AVR_PM_BASE_ADDRESS__ = 0;
enum __AVR_SFR_OFFSET__ = 32;
enum __AVR_DEVICE_NAME__ = "at90pwm81";
|
D
|
import vibe.vibe;
@safe:
URLRouter router;
@trusted void run()
{
runApplication();
}
void main()
{
router = new URLRouter;
router.registerWebInterface(new WebInterface);
auto settings = new HTTPServerSettings;
settings.port = 8080;
settings.bindAddresses = ["::1", "127.0.0.1"];
listenHTTP(settings, &setupAllocator);
logInfo("Please open http://127.0.0.1:8080/ in your browser.");
run();
}
void foo(int* a)
{
}
class WebInterface
{
void index()
{
auto b = allocator.allocate();
foo(b.buffer);
logInfo("index");
}
}
@trusted struct FiberLocal
{
TaskLocal!Allocator local;
@trusted auto storage()
{
return local.storage;
}
@trusted auto allocate()
{
return local.allocate;
}
@trusted void setup()
{
local.setup;
}
@trusted void teardown()
{
local.teardown;
}
}
int* globalBuffer;
int* global;
FiberLocal allocator;
struct Allocator
{
void setup()
{
logInfo("setup allocator");
}
void teardown()
{
logInfo("teardown allocator");
}
Buffer allocate()
{
logInfo("allocate");
return Buffer(globalBuffer);
}
}
struct Buffer
{
private int* buffer_;
int* buffer() return
{
return buffer_;
}
}
void setupAllocator(HTTPServerRequest req, HTTPServerResponse res)
{
allocator.setup();
scope (exit) allocator.teardown();
router.handleRequest(req, res);
}
|
D
|
module mach.traits.element.commontype;
private:
import mach.meta : Map, All;
import mach.traits.element.type : canGetElementType, ElementType;
public:
/// Determine whether the given types share a common element type.
template hasCommonElementType(T...) if(All!(canGetElementType, T)){
import mach.traits.common : hasCommonType;
enum bool hasCommonElementType = hasCommonType!(Map!(ElementType, T));
}
/// Get the common element type of the given types.
template CommonElementType(T...) if(hasCommonElementType!T){
import mach.traits.common : CommonType;
alias CommonElementType = CommonType!(Map!(ElementType, T));
}
unittest{
static assert(hasCommonElementType!(int[], real[]));
static assert(!hasCommonElementType!(int[], string[]));
static assert(is(CommonElementType!(int[], real[]) == real));
}
unittest{
class Base{}
class A: Base{}
class B: Base{}
static assert(hasCommonElementType!(A[], B[]));
static assert(hasCommonElementType!(A[], B[], Base[]));
static assert(!hasCommonElementType!(A[], int[]));
static assert(is(CommonElementType!(A[], B[]) == Base));
static assert(is(CommonElementType!(A[], B[], Base[]) == Base));
}
|
D
|
a party of guests wearing costumes and masks
|
D
|
module alglib.linalg;
import alglib.ap;
import alglib.internal;
import alglib.misc;
struct sparsematrix
{
ae_vector vals;
ae_vector idx;
ae_vector ridx;
ae_vector didx;
ae_vector uidx;
ae_int_t matrixtype;
ae_int_t m;
ae_int_t n;
ae_int_t nfree;
ae_int_t ninitialized;
ae_int_t tablesize;
}
struct sparsebuffers
{
ae_vector d;
ae_vector u;
sparsematrix s;
}
struct matinvreport
{
double r1;
double rinf;
}
struct fblslincgstate
{
double e1;
double e2;
ae_vector x;
ae_vector ax;
double xax;
ae_int_t n;
ae_vector rk;
ae_vector rk1;
ae_vector xk;
ae_vector xk1;
ae_vector pk;
ae_vector pk1;
ae_vector b;
rcommstate rstate;
ae_vector tmp2;
}
struct normestimatorstate
{
ae_int_t n;
ae_int_t m;
ae_int_t nstart;
ae_int_t nits;
ae_int_t seedval;
ae_vector x0;
ae_vector x1;
ae_vector t;
ae_vector xbest;
hqrndstate r;
ae_vector x;
ae_vector mv;
ae_vector mtv;
ae_bool needmv;
ae_bool needmtv;
double repnorm;
rcommstate rstate;
}
/**
extern(C++,alglib):
{
class _sparsematrix_owner
{
_sparsematrix_owner();
_sparsematrix_owner(const _sparsematrix_owner &rhs);
_sparsematrix_owner& operator=(const _sparsematrix_owner &rhs);
virtual ~_sparsematrix_owner();
alglib_impl::sparsematrix* c_ptr();
alglib_impl::sparsematrix* c_ptr() const;
protected:
alglib_impl::sparsematrix *p_struct;
}
class sparsematrix : _sparsematrix_owner
{
sparsematrix();
sparsematrix(const sparsematrix &rhs);
sparsematrix& operator=(const sparsematrix &rhs);
virtual ~sparsematrix();
}
class _sparsebuffers_owner
{
_sparsebuffers_owner();
_sparsebuffers_owner(const _sparsebuffers_owner &rhs);
_sparsebuffers_owner& operator=(const _sparsebuffers_owner &rhs);
virtual ~_sparsebuffers_owner();
alglib_impl::sparsebuffers* c_ptr();
alglib_impl::sparsebuffers* c_ptr() const;
protected:
alglib_impl::sparsebuffers *p_struct;
}
class sparsebuffers : public _sparsebuffers_owner
{
sparsebuffers();
sparsebuffers(const sparsebuffers &rhs);
sparsebuffers& operator=(const sparsebuffers &rhs);
virtual ~sparsebuffers();
}
class _matinvreport_owner
{
_matinvreport_owner();
_matinvreport_owner(const _matinvreport_owner &rhs);
_matinvreport_owner& operator=(const _matinvreport_owner &rhs);
virtual ~_matinvreport_owner();
alglib_impl::matinvreport* c_ptr();
alglib_impl::matinvreport* c_ptr() const;
protected:
alglib_impl::matinvreport *p_struct;
}
class matinvreport : _matinvreport_owner
{
matinvreport();
matinvreport(const matinvreport &rhs);
matinvreport& operator=(const matinvreport &rhs);
virtual ~matinvreport();
double &r1;
double &rinf;
}
class _normestimatorstate_owner
{
_normestimatorstate_owner();
_normestimatorstate_owner(const _normestimatorstate_owner &rhs);
_normestimatorstate_owner& operator=(const _normestimatorstate_owner &rhs);
virtual ~_normestimatorstate_owner();
alglib_impl::normestimatorstate* c_ptr();
alglib_impl::normestimatorstate* c_ptr() const;
protected:
alglib_impl::normestimatorstate *p_struct;
}
class normestimatorstate : _normestimatorstate_owner
{
normestimatorstate();
normestimatorstate(const normestimatorstate &rhs);
normestimatorstate& operator=(const normestimatorstate &rhs);
virtual ~normestimatorstate();
}
void cmatrixtranspose(const ae_int_t m, const ae_int_t n, const complex_2d_array &a, const ae_int_t ia, const ae_int_t ja, complex_2d_array &b, const ae_int_t ib, const ae_int_t jb);
void rmatrixtranspose(const ae_int_t m, const ae_int_t n, const real_2d_array &a, const ae_int_t ia, const ae_int_t ja, const real_2d_array &b, const ae_int_t ib, const ae_int_t jb);
void rmatrixenforcesymmetricity(const real_2d_array &a, const ae_int_t n, const bool isupper);
void cmatrixcopy(const ae_int_t m, const ae_int_t n, const complex_2d_array &a, const ae_int_t ia, const ae_int_t ja, complex_2d_array &b, const ae_int_t ib, const ae_int_t jb);
void rmatrixcopy(const ae_int_t m, const ae_int_t n, const real_2d_array &a, const ae_int_t ia, const ae_int_t ja, real_2d_array &b, const ae_int_t ib, const ae_int_t jb);
void cmatrixrank1(const ae_int_t m, const ae_int_t n, complex_2d_array &a, const ae_int_t ia, const ae_int_t ja, complex_1d_array &u, const ae_int_t iu, complex_1d_array &v, const ae_int_t iv);
void rmatrixrank1(const ae_int_t m, const ae_int_t n, real_2d_array &a, const ae_int_t ia, const ae_int_t ja, real_1d_array &u, const ae_int_t iu, real_1d_array &v, const ae_int_t iv);
void cmatrixmv(const ae_int_t m, const ae_int_t n, const complex_2d_array &a, const ae_int_t ia, const ae_int_t ja, const ae_int_t opa, const complex_1d_array &x, const ae_int_t ix, complex_1d_array &y, const ae_int_t iy);
void rmatrixmv(const ae_int_t m, const ae_int_t n, const real_2d_array &a, const ae_int_t ia, const ae_int_t ja, const ae_int_t opa, const real_1d_array &x, const ae_int_t ix, real_1d_array &y, const ae_int_t iy);
void cmatrixrighttrsm(const ae_int_t m, const ae_int_t n, const complex_2d_array &a, const ae_int_t i1, const ae_int_t j1, const bool isupper, const bool isunit, const ae_int_t optype, const complex_2d_array &x, const ae_int_t i2, const ae_int_t j2);
void smp_cmatrixrighttrsm(const ae_int_t m, const ae_int_t n, const complex_2d_array &a, const ae_int_t i1, const ae_int_t j1, const bool isupper, const bool isunit, const ae_int_t optype, const complex_2d_array &x, const ae_int_t i2, const ae_int_t j2);
void cmatrixlefttrsm(const ae_int_t m, const ae_int_t n, const complex_2d_array &a, const ae_int_t i1, const ae_int_t j1, const bool isupper, const bool isunit, const ae_int_t optype, const complex_2d_array &x, const ae_int_t i2, const ae_int_t j2);
void smp_cmatrixlefttrsm(const ae_int_t m, const ae_int_t n, const complex_2d_array &a, const ae_int_t i1, const ae_int_t j1, const bool isupper, const bool isunit, const ae_int_t optype, const complex_2d_array &x, const ae_int_t i2, const ae_int_t j2);
void rmatrixrighttrsm(const ae_int_t m, const ae_int_t n, const real_2d_array &a, const ae_int_t i1, const ae_int_t j1, const bool isupper, const bool isunit, const ae_int_t optype, const real_2d_array &x, const ae_int_t i2, const ae_int_t j2);
void smp_rmatrixrighttrsm(const ae_int_t m, const ae_int_t n, const real_2d_array &a, const ae_int_t i1, const ae_int_t j1, const bool isupper, const bool isunit, const ae_int_t optype, const real_2d_array &x, const ae_int_t i2, const ae_int_t j2);
void rmatrixlefttrsm(const ae_int_t m, const ae_int_t n, const real_2d_array &a, const ae_int_t i1, const ae_int_t j1, const bool isupper, const bool isunit, const ae_int_t optype, const real_2d_array &x, const ae_int_t i2, const ae_int_t j2);
void smp_rmatrixlefttrsm(const ae_int_t m, const ae_int_t n, const real_2d_array &a, const ae_int_t i1, const ae_int_t j1, const bool isupper, const bool isunit, const ae_int_t optype, const real_2d_array &x, const ae_int_t i2, const ae_int_t j2);
void cmatrixherk(const ae_int_t n, const ae_int_t k, const double alpha, const complex_2d_array &a, const ae_int_t ia, const ae_int_t ja, const ae_int_t optypea, const double beta, const complex_2d_array &c, const ae_int_t ic, const ae_int_t jc, const bool isupper);
void smp_cmatrixherk(const ae_int_t n, const ae_int_t k, const double alpha, const complex_2d_array &a, const ae_int_t ia, const ae_int_t ja, const ae_int_t optypea, const double beta, const complex_2d_array &c, const ae_int_t ic, const ae_int_t jc, const bool isupper);
void rmatrixsyrk(const ae_int_t n, const ae_int_t k, const double alpha, const real_2d_array &a, const ae_int_t ia, const ae_int_t ja, const ae_int_t optypea, const double beta, const real_2d_array &c, const ae_int_t ic, const ae_int_t jc, const bool isupper);
void smp_rmatrixsyrk(const ae_int_t n, const ae_int_t k, const double alpha, const real_2d_array &a, const ae_int_t ia, const ae_int_t ja, const ae_int_t optypea, const double beta, const real_2d_array &c, const ae_int_t ic, const ae_int_t jc, const bool isupper);
void cmatrixgemm(const ae_int_t m, const ae_int_t n, const ae_int_t k, const alglib::complex alpha, const complex_2d_array &a, const ae_int_t ia, const ae_int_t ja, const ae_int_t optypea, const complex_2d_array &b, const ae_int_t ib, const ae_int_t jb, const ae_int_t optypeb, const alglib::complex beta, const complex_2d_array &c, const ae_int_t ic, const ae_int_t jc);
void smp_cmatrixgemm(const ae_int_t m, const ae_int_t n, const ae_int_t k, const alglib::complex alpha, const complex_2d_array &a, const ae_int_t ia, const ae_int_t ja, const ae_int_t optypea, const complex_2d_array &b, const ae_int_t ib, const ae_int_t jb, const ae_int_t optypeb, const alglib::complex beta, const complex_2d_array &c, const ae_int_t ic, const ae_int_t jc);
void rmatrixgemm(const ae_int_t m, const ae_int_t n, const ae_int_t k, const double alpha, const real_2d_array &a, const ae_int_t ia, const ae_int_t ja, const ae_int_t optypea, const real_2d_array &b, const ae_int_t ib, const ae_int_t jb, const ae_int_t optypeb, const double beta, const real_2d_array &c, const ae_int_t ic, const ae_int_t jc);
void smp_rmatrixgemm(const ae_int_t m, const ae_int_t n, const ae_int_t k, const double alpha, const real_2d_array &a, const ae_int_t ia, const ae_int_t ja, const ae_int_t optypea, const real_2d_array &b, const ae_int_t ib, const ae_int_t jb, const ae_int_t optypeb, const double beta, const real_2d_array &c, const ae_int_t ic, const ae_int_t jc);
void cmatrixsyrk(const ae_int_t n, const ae_int_t k, const double alpha, const complex_2d_array &a, const ae_int_t ia, const ae_int_t ja, const ae_int_t optypea, const double beta, const complex_2d_array &c, const ae_int_t ic, const ae_int_t jc, const bool isupper);
void smp_cmatrixsyrk(const ae_int_t n, const ae_int_t k, const double alpha, const complex_2d_array &a, const ae_int_t ia, const ae_int_t ja, const ae_int_t optypea, const double beta, const complex_2d_array &c, const ae_int_t ic, const ae_int_t jc, const bool isupper);
void rmatrixqr(real_2d_array &a, const ae_int_t m, const ae_int_t n, real_1d_array &tau);
void smp_rmatrixqr(real_2d_array &a, const ae_int_t m, const ae_int_t n, real_1d_array &tau);
void rmatrixlq(real_2d_array &a, const ae_int_t m, const ae_int_t n, real_1d_array &tau);
void smp_rmatrixlq(real_2d_array &a, const ae_int_t m, const ae_int_t n, real_1d_array &tau);
void cmatrixqr(complex_2d_array &a, const ae_int_t m, const ae_int_t n, complex_1d_array &tau);
void smp_cmatrixqr(complex_2d_array &a, const ae_int_t m, const ae_int_t n, complex_1d_array &tau);
void cmatrixlq(complex_2d_array &a, const ae_int_t m, const ae_int_t n, complex_1d_array &tau);
void smp_cmatrixlq(complex_2d_array &a, const ae_int_t m, const ae_int_t n, complex_1d_array &tau);
void rmatrixqrunpackq(const real_2d_array &a, const ae_int_t m, const ae_int_t n, const real_1d_array &tau, const ae_int_t qcolumns, real_2d_array &q);
void smp_rmatrixqrunpackq(const real_2d_array &a, const ae_int_t m, const ae_int_t n, const real_1d_array &tau, const ae_int_t qcolumns, real_2d_array &q);
void rmatrixqrunpackr(const real_2d_array &a, const ae_int_t m, const ae_int_t n, real_2d_array &r);
void rmatrixlqunpackq(const real_2d_array &a, const ae_int_t m, const ae_int_t n, const real_1d_array &tau, const ae_int_t qrows, real_2d_array &q);
void smp_rmatrixlqunpackq(const real_2d_array &a, const ae_int_t m, const ae_int_t n, const real_1d_array &tau, const ae_int_t qrows, real_2d_array &q);
void rmatrixlqunpackl(const real_2d_array &a, const ae_int_t m, const ae_int_t n, real_2d_array &l);
void cmatrixqrunpackq(const complex_2d_array &a, const ae_int_t m, const ae_int_t n, const complex_1d_array &tau, const ae_int_t qcolumns, complex_2d_array &q);
void smp_cmatrixqrunpackq(const complex_2d_array &a, const ae_int_t m, const ae_int_t n, const complex_1d_array &tau, const ae_int_t qcolumns, complex_2d_array &q);
void cmatrixqrunpackr(const complex_2d_array &a, const ae_int_t m, const ae_int_t n, complex_2d_array &r);
void cmatrixlqunpackq(const complex_2d_array &a, const ae_int_t m, const ae_int_t n, const complex_1d_array &tau, const ae_int_t qrows, complex_2d_array &q);
void smp_cmatrixlqunpackq(const complex_2d_array &a, const ae_int_t m, const ae_int_t n, const complex_1d_array &tau, const ae_int_t qrows, complex_2d_array &q);
void cmatrixlqunpackl(const complex_2d_array &a, const ae_int_t m, const ae_int_t n, complex_2d_array &l);
void rmatrixbd(real_2d_array &a, const ae_int_t m, const ae_int_t n, real_1d_array &tauq, real_1d_array &taup);
void rmatrixbdunpackq(const real_2d_array &qp, const ae_int_t m, const ae_int_t n, const real_1d_array &tauq, const ae_int_t qcolumns, real_2d_array &q);
void rmatrixbdmultiplybyq(const real_2d_array &qp, const ae_int_t m, const ae_int_t n, const real_1d_array &tauq, real_2d_array &z, const ae_int_t zrows, const ae_int_t zcolumns, const bool fromtheright, const bool dotranspose);
void rmatrixbdunpackpt(const real_2d_array &qp, const ae_int_t m, const ae_int_t n, const real_1d_array &taup, const ae_int_t ptrows, real_2d_array &pt);
void rmatrixbdmultiplybyp(const real_2d_array &qp, const ae_int_t m, const ae_int_t n, const real_1d_array &taup, real_2d_array &z, const ae_int_t zrows, const ae_int_t zcolumns, const bool fromtheright, const bool dotranspose);
void rmatrixbdunpackdiagonals(const real_2d_array &b, const ae_int_t m, const ae_int_t n, bool &isupper, real_1d_array &d, real_1d_array &e);
void rmatrixhessenberg(real_2d_array &a, const ae_int_t n, real_1d_array &tau);
void rmatrixhessenbergunpackq(const real_2d_array &a, const ae_int_t n, const real_1d_array &tau, real_2d_array &q);
void rmatrixhessenbergunpackh(const real_2d_array &a, const ae_int_t n, real_2d_array &h);
void smatrixtd(real_2d_array &a, const ae_int_t n, const bool isupper, real_1d_array &tau, real_1d_array &d, real_1d_array &e);
void smatrixtdunpackq(const real_2d_array &a, const ae_int_t n, const bool isupper, const real_1d_array &tau, real_2d_array &q);
void hmatrixtd(complex_2d_array &a, const ae_int_t n, const bool isupper, complex_1d_array &tau, real_1d_array &d, real_1d_array &e);
void hmatrixtdunpackq(const complex_2d_array &a, const ae_int_t n, const bool isupper, const complex_1d_array &tau, complex_2d_array &q);
bool rmatrixbdsvd(real_1d_array &d, const real_1d_array &e, const ae_int_t n, const bool isupper, const bool isfractionalaccuracyrequired, real_2d_array &u, const ae_int_t nru, real_2d_array &c, const ae_int_t ncc, real_2d_array &vt, const ae_int_t ncvt);
bool rmatrixsvd(const real_2d_array &a, const ae_int_t m, const ae_int_t n, const ae_int_t uneeded, const ae_int_t vtneeded, const ae_int_t additionalmemory, real_1d_array &w, real_2d_array &u, real_2d_array &vt);
bool smp_rmatrixsvd(const real_2d_array &a, const ae_int_t m, const ae_int_t n, const ae_int_t uneeded, const ae_int_t vtneeded, const ae_int_t additionalmemory, real_1d_array &w, real_2d_array &u, real_2d_array &vt);
bool smatrixevd(const real_2d_array &a, const ae_int_t n, const ae_int_t zneeded, const bool isupper, real_1d_array &d, real_2d_array &z);
bool smatrixevdr(const real_2d_array &a, const ae_int_t n, const ae_int_t zneeded, const bool isupper, const double b1, const double b2, ae_int_t &m, real_1d_array &w, real_2d_array &z);
bool smatrixevdi(const real_2d_array &a, const ae_int_t n, const ae_int_t zneeded, const bool isupper, const ae_int_t i1, const ae_int_t i2, real_1d_array &w, real_2d_array &z);
bool hmatrixevd(const complex_2d_array &a, const ae_int_t n, const ae_int_t zneeded, const bool isupper, real_1d_array &d, complex_2d_array &z);
bool hmatrixevdr(const complex_2d_array &a, const ae_int_t n, const ae_int_t zneeded, const bool isupper, const double b1, const double b2, ae_int_t &m, real_1d_array &w, complex_2d_array &z);
bool hmatrixevdi(const complex_2d_array &a, const ae_int_t n, const ae_int_t zneeded, const bool isupper, const ae_int_t i1, const ae_int_t i2, real_1d_array &w, complex_2d_array &z);
bool smatrixtdevd(real_1d_array &d, const real_1d_array &e, const ae_int_t n, const ae_int_t zneeded, real_2d_array &z);
bool smatrixtdevdr(real_1d_array &d, const real_1d_array &e, const ae_int_t n, const ae_int_t zneeded, const double a, const double b, ae_int_t &m, real_2d_array &z);
bool smatrixtdevdi(real_1d_array &d, const real_1d_array &e, const ae_int_t n, const ae_int_t zneeded, const ae_int_t i1, const ae_int_t i2, real_2d_array &z);
bool rmatrixevd(const real_2d_array &a, const ae_int_t n, const ae_int_t vneeded, real_1d_array &wr, real_1d_array &wi, real_2d_array &vl, real_2d_array &vr);
void rmatrixrndorthogonal(const ae_int_t n, real_2d_array &a);
void rmatrixrndcond(const ae_int_t n, const double c, real_2d_array &a);
void cmatrixrndorthogonal(const ae_int_t n, complex_2d_array &a);
void cmatrixrndcond(const ae_int_t n, const double c, complex_2d_array &a);
void smatrixrndcond(const ae_int_t n, const double c, real_2d_array &a);
void spdmatrixrndcond(const ae_int_t n, const double c, real_2d_array &a);
void hmatrixrndcond(const ae_int_t n, const double c, complex_2d_array &a);
void hpdmatrixrndcond(const ae_int_t n, const double c, complex_2d_array &a);
void rmatrixrndorthogonalfromtheright(real_2d_array &a, const ae_int_t m, const ae_int_t n);
void rmatrixrndorthogonalfromtheleft(real_2d_array &a, const ae_int_t m, const ae_int_t n);
void cmatrixrndorthogonalfromtheleft(complex_2d_array &a, const ae_int_t m, const ae_int_t n);
void smatrixrndmultiply(real_2d_array &a, const ae_int_t n);
void hmatrixrndmultiply(complex_2d_array &a, const ae_int_t n);
void sparsecreate(const ae_int_t m, const ae_int_t n, const ae_int_t k, sparsematrix &s);
void sparsecreate(const ae_int_t m, const ae_int_t n, sparsematrix &s);
void sparsecreatebuf(const ae_int_t m, const ae_int_t n, const ae_int_t k, const sparsematrix &s);
void sparsecreatebuf(const ae_int_t m, const ae_int_t n, const sparsematrix &s);
void sparsecreatecrs(const ae_int_t m, const ae_int_t n, const integer_1d_array &ner, sparsematrix &s);
void sparsecreatecrsbuf(const ae_int_t m, const ae_int_t n, const integer_1d_array &ner, const sparsematrix &s);
void sparsecreatesks(const ae_int_t m, const ae_int_t n, const integer_1d_array &d, const integer_1d_array &u, sparsematrix &s);
void sparsecreatesksbuf(const ae_int_t m, const ae_int_t n, const integer_1d_array &d, const integer_1d_array &u, const sparsematrix &s);
void sparsecopy(const sparsematrix &s0, sparsematrix &s1);
void sparsecopybuf(const sparsematrix &s0, const sparsematrix &s1);
void sparseswap(const sparsematrix &s0, const sparsematrix &s1);
void sparseadd(const sparsematrix &s, const ae_int_t i, const ae_int_t j, const double v);
void sparseset(const sparsematrix &s, const ae_int_t i, const ae_int_t j, const double v);
double sparsegetdiagonal(const sparsematrix &s, const ae_int_t i);
void sparsemv(const sparsematrix &s, const real_1d_array &x, real_1d_array &y);
void sparsemtv(const sparsematrix &s, const real_1d_array &x, real_1d_array &y);
void sparsemv2(const sparsematrix &s, const real_1d_array &x, real_1d_array &y0, real_1d_array &y1);
void sparsesmv(const sparsematrix &s, const bool isupper, const real_1d_array &x, real_1d_array &y);
double sparsevsmv(const sparsematrix &s, const bool isupper, const real_1d_array &x);
void sparsemtm(const sparsematrix &s, const real_2d_array &a, const ae_int_t k, real_2d_array &b);
void sparsemm2(const sparsematrix &s, const real_2d_array &a, const ae_int_t k, real_2d_array &b0, real_2d_array &b1);
void sparsesmm(const sparsematrix &s, const bool isupper, const real_2d_array &a, const ae_int_t k, real_2d_array &b);
void sparsetrmv(const sparsematrix &s, const bool isupper, const bool isunit, const ae_int_t optype, const real_1d_array &x, real_1d_array &y);
void sparsetrsv(const sparsematrix &s, const bool isupper, const bool isunit, const ae_int_t optype, const real_1d_array &x);
void sparseresizematrix(const sparsematrix &s);
bool sparseenumerate(const sparsematrix &s, ae_int_t &t0, ae_int_t &t1, ae_int_t &i, ae_int_t &j, double &v);
bool sparserewriteexisting(const sparsematrix &s, const ae_int_t i, const ae_int_t j, const double v);
void sparsegetrow(const sparsematrix &s, const ae_int_t i, real_1d_array &irow);
void sparsegetcompressedrow(const sparsematrix &s, const ae_int_t i, integer_1d_array &colidx, real_1d_array &vals, ae_int_t &nzcnt);
void sparsetransposesks(const sparsematrix &s);
void sparsecopytobuf(const sparsematrix &s0, const ae_int_t fmt, const sparsematrix &s1);
void sparseconverttohash(const sparsematrix &s);
void sparsecopytohash(const sparsematrix &s0, sparsematrix &s1);
void sparsecopytohashbuf(const sparsematrix &s0, const sparsematrix &s1);
void sparseconverttocrs(const sparsematrix &s);
void sparsecopytocrsbuf(const sparsematrix &s0, const sparsematrix &s1);
void sparseconverttosks(const sparsematrix &s);
void sparsecopytosks(const sparsematrix &s0, sparsematrix &s1);
ae_int_t sparsegetmatrixtype(const sparsematrix &s);
bool sparseishash(const sparsematrix &s);
bool sparseiscrs(const sparsematrix &s);
bool sparseissks(const sparsematrix &s);
void sparsefree(sparsematrix &s);
ae_int_t sparsegetnrows(const sparsematrix &s);
ae_int_t sparsegetncols(const sparsematrix &s);
ae_int_t sparsegetlowercount(const sparsematrix &s);
void rmatrixlu(real_2d_array &a, const ae_int_t m, const ae_int_t n, integer_1d_array &pivots);
void smp_rmatrixlu(real_2d_array &a, const ae_int_t m, const ae_int_t n, integer_1d_array &pivots);
void cmatrixlu(complex_2d_array &a, const ae_int_t m, const ae_int_t n, integer_1d_array &pivots);
void smp_cmatrixlu(complex_2d_array &a, const ae_int_t m, const ae_int_t n, integer_1d_array &pivots);
bool hpdmatrixcholesky(complex_2d_array &a, const ae_int_t n, const bool isupper);
bool smp_hpdmatrixcholesky(complex_2d_array &a, const ae_int_t n, const bool isupper);
bool spdmatrixcholesky(real_2d_array &a, const ae_int_t n, const bool isupper);
bool smp_spdmatrixcholesky(real_2d_array &a, const ae_int_t n, const bool isupper);
void spdmatrixcholeskyupdateadd1(const real_2d_array &a, const ae_int_t n, const bool isupper, const real_1d_array &u);
void spdmatrixcholeskyupdatefix(const real_2d_array &a, const ae_int_t n, const bool isupper, const boolean_1d_array &fix);
void spdmatrixcholeskyupdateadd1buf(const real_2d_array &a, const ae_int_t n, const bool isupper, const real_1d_array &u, real_1d_array &bufr);
void spdmatrixcholeskyupdatefixbuf(const real_2d_array &a, const ae_int_t n, const bool isupper, const boolean_1d_array &fix, real_1d_array &bufr);
bool sparsecholeskyskyline(const sparsematrix &a, const ae_int_t n, const bool isupper);
double rmatrixrcond1(const real_2d_array &a, const ae_int_t n);
double spdmatrixrcond(const real_2d_array &a, const ae_int_t n, const bool isupper);
double rmatrixtrrcond1(const real_2d_array &a, const ae_int_t n, const bool isupper, const bool isunit);
double hpdmatrixrcond(const complex_2d_array &a, const ae_int_t n, const bool isupper);
double cmatrixrcond1(const complex_2d_array &a, const ae_int_t n);
double cmatrixrcondinf(const complex_2d_array &a, const ae_int_t n);
double rmatrixlurcond1(const real_2d_array &lua, const ae_int_t n);
double spdmatrixcholeskyrcond(const real_2d_array &a, const ae_int_t n, const bool isupper);
double hpdmatrixcholeskyrcond(const complex_2d_array &a, const ae_int_t n, const bool isupper);
double cmatrixlurcond1(const complex_2d_array &lua, const ae_int_t n);
double cmatrixlurcondinf(const complex_2d_array &lua, const ae_int_t n);
double cmatrixtrrcondinf(const complex_2d_array &a, const ae_int_t n, const bool isupper, const bool isunit);
void rmatrixluinverse(real_2d_array &a, const integer_1d_array &pivots, const ae_int_t n, ae_int_t &info, matinvreport &rep);
void smp_rmatrixluinverse(real_2d_array &a, const integer_1d_array &pivots, const ae_int_t n, ae_int_t &info, matinvreport &rep);
void rmatrixluinverse(real_2d_array &a, const integer_1d_array &pivots, ae_int_t &info, matinvreport &rep);
void smp_rmatrixluinverse(real_2d_array &a, const integer_1d_array &pivots, ae_int_t &info, matinvreport &rep);
void rmatrixinverse(real_2d_array &a, const ae_int_t n, ae_int_t &info, matinvreport &rep);
void smp_rmatrixinverse(real_2d_array &a, const ae_int_t n, ae_int_t &info, matinvreport &rep);
void rmatrixinverse(real_2d_array &a, ae_int_t &info, matinvreport &rep);
void smp_rmatrixinverse(real_2d_array &a, ae_int_t &info, matinvreport &rep);
void cmatrixluinverse(complex_2d_array &a, const integer_1d_array &pivots, const ae_int_t n, ae_int_t &info, matinvreport &rep);
void smp_cmatrixluinverse(complex_2d_array &a, const integer_1d_array &pivots, const ae_int_t n, ae_int_t &info, matinvreport &rep);
void cmatrixluinverse(complex_2d_array &a, const integer_1d_array &pivots, ae_int_t &info, matinvreport &rep);
void smp_cmatrixluinverse(complex_2d_array &a, const integer_1d_array &pivots, ae_int_t &info, matinvreport &rep);
void cmatrixinverse(complex_2d_array &a, const ae_int_t n, ae_int_t &info, matinvreport &rep);
void smp_cmatrixinverse(complex_2d_array &a, const ae_int_t n, ae_int_t &info, matinvreport &rep);
void cmatrixinverse(complex_2d_array &a, ae_int_t &info, matinvreport &rep);
void smp_cmatrixinverse(complex_2d_array &a, ae_int_t &info, matinvreport &rep);
void spdmatrixcholeskyinverse(real_2d_array &a, const ae_int_t n, const bool isupper, ae_int_t &info, matinvreport &rep);
void smp_spdmatrixcholeskyinverse(real_2d_array &a, const ae_int_t n, const bool isupper, ae_int_t &info, matinvreport &rep);
void spdmatrixcholeskyinverse(real_2d_array &a, ae_int_t &info, matinvreport &rep);
void smp_spdmatrixcholeskyinverse(real_2d_array &a, ae_int_t &info, matinvreport &rep);
void spdmatrixinverse(real_2d_array &a, const ae_int_t n, const bool isupper, ae_int_t &info, matinvreport &rep);
void smp_spdmatrixinverse(real_2d_array &a, const ae_int_t n, const bool isupper, ae_int_t &info, matinvreport &rep);
void spdmatrixinverse(real_2d_array &a, ae_int_t &info, matinvreport &rep);
void smp_spdmatrixinverse(real_2d_array &a, ae_int_t &info, matinvreport &rep);
void hpdmatrixcholeskyinverse(complex_2d_array &a, const ae_int_t n, const bool isupper, ae_int_t &info, matinvreport &rep);
void smp_hpdmatrixcholeskyinverse(complex_2d_array &a, const ae_int_t n, const bool isupper, ae_int_t &info, matinvreport &rep);
void hpdmatrixcholeskyinverse(complex_2d_array &a, ae_int_t &info, matinvreport &rep);
void smp_hpdmatrixcholeskyinverse(complex_2d_array &a, ae_int_t &info, matinvreport &rep);
void hpdmatrixinverse(complex_2d_array &a, const ae_int_t n, const bool isupper, ae_int_t &info, matinvreport &rep);
void smp_hpdmatrixinverse(complex_2d_array &a, const ae_int_t n, const bool isupper, ae_int_t &info, matinvreport &rep);
void hpdmatrixinverse(complex_2d_array &a, ae_int_t &info, matinvreport &rep);
void smp_hpdmatrixinverse(complex_2d_array &a, ae_int_t &info, matinvreport &rep);
void rmatrixtrinverse(real_2d_array &a, const ae_int_t n, const bool isupper, const bool isunit, ae_int_t &info, matinvreport &rep);
void smp_rmatrixtrinverse(real_2d_array &a, const ae_int_t n, const bool isupper, const bool isunit, ae_int_t &info, matinvreport &rep);
void rmatrixtrinverse(real_2d_array &a, const bool isupper, ae_int_t &info, matinvreport &rep);
void smp_rmatrixtrinverse(real_2d_array &a, const bool isupper, ae_int_t &info, matinvreport &rep);
void cmatrixtrinverse(complex_2d_array &a, const ae_int_t n, const bool isupper, const bool isunit, ae_int_t &info, matinvreport &rep);
void smp_cmatrixtrinverse(complex_2d_array &a, const ae_int_t n, const bool isupper, const bool isunit, ae_int_t &info, matinvreport &rep);
void cmatrixtrinverse(complex_2d_array &a, const bool isupper, ae_int_t &info, matinvreport &rep);
void smp_cmatrixtrinverse(complex_2d_array &a, const bool isupper, ae_int_t &info, matinvreport &rep);
void normestimatorcreate(const ae_int_t m, const ae_int_t n, const ae_int_t nstart, const ae_int_t nits, normestimatorstate &state);
void normestimatorsetseed(const normestimatorstate &state, const ae_int_t seedval);
void normestimatorestimatesparse(const normestimatorstate &state, const sparsematrix &a);
void normestimatorresults(const normestimatorstate &state, double &nrm);
double rmatrixludet(const real_2d_array &a, const integer_1d_array &pivots, const ae_int_t n);
double rmatrixludet(const real_2d_array &a, const integer_1d_array &pivots);
double rmatrixdet(const real_2d_array &a, const ae_int_t n);
double rmatrixdet(const real_2d_array &a);
alglib::complex cmatrixludet(const complex_2d_array &a, const integer_1d_array &pivots, const ae_int_t n);
alglib::complex cmatrixludet(const complex_2d_array &a, const integer_1d_array &pivots);
alglib::complex cmatrixdet(const complex_2d_array &a, const ae_int_t n);
alglib::complex cmatrixdet(const complex_2d_array &a);
double spdmatrixcholeskydet(const real_2d_array &a, const ae_int_t n);
double spdmatrixcholeskydet(const real_2d_array &a);
double spdmatrixdet(const real_2d_array &a, const ae_int_t n, const bool isupper);
double spdmatrixdet(const real_2d_array &a);
bool smatrixgevd(const real_2d_array &a, const ae_int_t n, const bool isuppera, const real_2d_array &b, const bool isupperb, const ae_int_t zneeded, const ae_int_t problemtype, real_1d_array &d, real_2d_array &z);
bool smatrixgevdreduce(real_2d_array &a, const ae_int_t n, const bool isuppera, const real_2d_array &b, const bool isupperb, const ae_int_t problemtype, real_2d_array &r, bool &isupperr);
void rmatrixinvupdatesimple(real_2d_array &inva, const ae_int_t n, const ae_int_t updrow, const ae_int_t updcolumn, const double updval);
void rmatrixinvupdaterow(real_2d_array &inva, const ae_int_t n, const ae_int_t updrow, const real_1d_array &v);
void rmatrixinvupdatecolumn(real_2d_array &inva, const ae_int_t n, const ae_int_t updcolumn, const real_1d_array &u);
void rmatrixinvupdateuv(real_2d_array &inva, const ae_int_t n, const real_1d_array &u, const real_1d_array &v);
bool rmatrixschur(real_2d_array &a, const ae_int_t n, real_2d_array &s);
}
*/
extern(C)
{
void ablassplitlength(/* Real */ ae_matrix* a, ae_int_t n, ae_int_t* n1, ae_int_t* n2, ae_state *_state);
void ablascomplexsplitlength(/* Complex */ ae_matrix* a, ae_int_t n, ae_int_t* n1, ae_int_t* n2, ae_state *_state);
ae_int_t ablasblocksize(/* Real */ ae_matrix* a, ae_state *_state);
ae_int_t ablascomplexblocksize(/* Complex */ ae_matrix* a, ae_state *_state);
ae_int_t ablasmicroblocksize(ae_state *_state);
void cmatrixtranspose(ae_int_t m, ae_int_t n, /* Complex */ ae_matrix* a, ae_int_t ia, ae_int_t ja, /* Complex */ ae_matrix* b, ae_int_t ib, ae_int_t jb, ae_state *_state);
void rmatrixtranspose(ae_int_t m, ae_int_t n, /* Real */ ae_matrix* a, ae_int_t ia, ae_int_t ja, /* Real */ ae_matrix* b, ae_int_t ib, ae_int_t jb, ae_state *_state);
void rmatrixenforcesymmetricity(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_state *_state);
void cmatrixcopy(ae_int_t m, ae_int_t n, /* Complex */ ae_matrix* a, ae_int_t ia, ae_int_t ja, /* Complex */ ae_matrix* b, ae_int_t ib, ae_int_t jb, ae_state *_state);
void rmatrixcopy(ae_int_t m, ae_int_t n, /* Real */ ae_matrix* a, ae_int_t ia, ae_int_t ja, /* Real */ ae_matrix* b, ae_int_t ib, ae_int_t jb, ae_state *_state);
void cmatrixrank1(ae_int_t m, ae_int_t n, /* Complex */ ae_matrix* a, ae_int_t ia, ae_int_t ja, /* Complex */ ae_vector* u, ae_int_t iu, /* Complex */ ae_vector* v, ae_int_t iv, ae_state *_state);
void rmatrixrank1(ae_int_t m, ae_int_t n, /* Real */ ae_matrix* a, ae_int_t ia, ae_int_t ja, /* Real */ ae_vector* u, ae_int_t iu, /* Real */ ae_vector* v, ae_int_t iv, ae_state *_state);
void cmatrixmv(ae_int_t m, ae_int_t n, /* Complex */ ae_matrix* a, ae_int_t ia, ae_int_t ja, ae_int_t opa, /* Complex */ ae_vector* x, ae_int_t ix, /* Complex */ ae_vector* y, ae_int_t iy, ae_state *_state);
void rmatrixmv(ae_int_t m, ae_int_t n, /* Real */ ae_matrix* a, ae_int_t ia, ae_int_t ja, ae_int_t opa, /* Real */ ae_vector* x, ae_int_t ix, /* Real */ ae_vector* y, ae_int_t iy, ae_state *_state);
void cmatrixrighttrsm(ae_int_t m, ae_int_t n, /* Complex */ ae_matrix* a, ae_int_t i1, ae_int_t j1, ae_bool isupper, ae_bool isunit, ae_int_t optype, /* Complex */ ae_matrix* x, ae_int_t i2, ae_int_t j2, ae_state *_state);
void _pexec_cmatrixrighttrsm(ae_int_t m, ae_int_t n, /* Complex */ ae_matrix* a, ae_int_t i1, ae_int_t j1, ae_bool isupper, ae_bool isunit, ae_int_t optype, /* Complex */ ae_matrix* x, ae_int_t i2, ae_int_t j2, ae_state *_state);
void cmatrixlefttrsm(ae_int_t m, ae_int_t n, /* Complex */ ae_matrix* a, ae_int_t i1, ae_int_t j1, ae_bool isupper, ae_bool isunit, ae_int_t optype, /* Complex */ ae_matrix* x, ae_int_t i2, ae_int_t j2, ae_state *_state);
void _pexec_cmatrixlefttrsm(ae_int_t m, ae_int_t n, /* Complex */ ae_matrix* a, ae_int_t i1, ae_int_t j1, ae_bool isupper, ae_bool isunit, ae_int_t optype, /* Complex */ ae_matrix* x, ae_int_t i2, ae_int_t j2, ae_state *_state);
void rmatrixrighttrsm(ae_int_t m, ae_int_t n, /* Real */ ae_matrix* a, ae_int_t i1, ae_int_t j1, ae_bool isupper, ae_bool isunit, ae_int_t optype, /* Real */ ae_matrix* x, ae_int_t i2, ae_int_t j2, ae_state *_state);
void _pexec_rmatrixrighttrsm(ae_int_t m, ae_int_t n, /* Real */ ae_matrix* a, ae_int_t i1, ae_int_t j1, ae_bool isupper, ae_bool isunit, ae_int_t optype, /* Real */ ae_matrix* x, ae_int_t i2, ae_int_t j2, ae_state *_state);
void rmatrixlefttrsm(ae_int_t m, ae_int_t n, /* Real */ ae_matrix* a, ae_int_t i1, ae_int_t j1, ae_bool isupper, ae_bool isunit, ae_int_t optype, /* Real */ ae_matrix* x, ae_int_t i2, ae_int_t j2, ae_state *_state);
void _pexec_rmatrixlefttrsm(ae_int_t m, ae_int_t n, /* Real */ ae_matrix* a, ae_int_t i1, ae_int_t j1, ae_bool isupper, ae_bool isunit, ae_int_t optype, /* Real */ ae_matrix* x, ae_int_t i2, ae_int_t j2, ae_state *_state);
void cmatrixherk(ae_int_t n, ae_int_t k, double alpha, /* Complex */ ae_matrix* a, ae_int_t ia, ae_int_t ja, ae_int_t optypea, double beta, /* Complex */ ae_matrix* c, ae_int_t ic, ae_int_t jc, ae_bool isupper, ae_state *_state);
void _pexec_cmatrixherk(ae_int_t n, ae_int_t k, double alpha, /* Complex */ ae_matrix* a, ae_int_t ia, ae_int_t ja, ae_int_t optypea, double beta, /* Complex */ ae_matrix* c, ae_int_t ic, ae_int_t jc, ae_bool isupper, ae_state *_state);
void rmatrixsyrk(ae_int_t n, ae_int_t k, double alpha, /* Real */ ae_matrix* a, ae_int_t ia, ae_int_t ja, ae_int_t optypea, double beta, /* Real */ ae_matrix* c, ae_int_t ic, ae_int_t jc, ae_bool isupper, ae_state *_state);
void _pexec_rmatrixsyrk(ae_int_t n, ae_int_t k, double alpha, /* Real */ ae_matrix* a, ae_int_t ia, ae_int_t ja, ae_int_t optypea, double beta, /* Real */ ae_matrix* c, ae_int_t ic, ae_int_t jc, ae_bool isupper, ae_state *_state);
void cmatrixgemm(ae_int_t m, ae_int_t n, ae_int_t k, ae_complex alpha, /* Complex */ ae_matrix* a, ae_int_t ia, ae_int_t ja, ae_int_t optypea, /* Complex */ ae_matrix* b, ae_int_t ib, ae_int_t jb, ae_int_t optypeb, ae_complex beta, /* Complex */ ae_matrix* c, ae_int_t ic, ae_int_t jc, ae_state *_state);
void _pexec_cmatrixgemm(ae_int_t m, ae_int_t n, ae_int_t k, ae_complex alpha, /* Complex */ ae_matrix* a, ae_int_t ia, ae_int_t ja, ae_int_t optypea, /* Complex */ ae_matrix* b, ae_int_t ib, ae_int_t jb, ae_int_t optypeb, ae_complex beta, /* Complex */ ae_matrix* c, ae_int_t ic, ae_int_t jc, ae_state *_state);
void rmatrixgemm(ae_int_t m, ae_int_t n, ae_int_t k, double alpha, /* Real */ ae_matrix* a, ae_int_t ia, ae_int_t ja, ae_int_t optypea, /* Real */ ae_matrix* b, ae_int_t ib, ae_int_t jb, ae_int_t optypeb, double beta, /* Real */ ae_matrix* c, ae_int_t ic, ae_int_t jc, ae_state *_state);
void _pexec_rmatrixgemm(ae_int_t m, ae_int_t n, ae_int_t k, double alpha, /* Real */ ae_matrix* a, ae_int_t ia, ae_int_t ja, ae_int_t optypea, /* Real */ ae_matrix* b, ae_int_t ib, ae_int_t jb, ae_int_t optypeb, double beta, /* Real */ ae_matrix* c, ae_int_t ic, ae_int_t jc, ae_state *_state);
void cmatrixsyrk(ae_int_t n, ae_int_t k, double alpha, /* Complex */ ae_matrix* a, ae_int_t ia, ae_int_t ja, ae_int_t optypea, double beta, /* Complex */ ae_matrix* c, ae_int_t ic, ae_int_t jc, ae_bool isupper, ae_state *_state);
void _pexec_cmatrixsyrk(ae_int_t n, ae_int_t k, double alpha, /* Complex */ ae_matrix* a, ae_int_t ia, ae_int_t ja, ae_int_t optypea, double beta, /* Complex */ ae_matrix* c, ae_int_t ic, ae_int_t jc, ae_bool isupper, ae_state *_state);
void rmatrixqr(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Real */ ae_vector* tau, ae_state *_state);
void _pexec_rmatrixqr(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Real */ ae_vector* tau, ae_state *_state);
void rmatrixlq(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Real */ ae_vector* tau, ae_state *_state);
void _pexec_rmatrixlq(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Real */ ae_vector* tau, ae_state *_state);
void cmatrixqr(/* Complex */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Complex */ ae_vector* tau, ae_state *_state);
void _pexec_cmatrixqr(/* Complex */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Complex */ ae_vector* tau, ae_state *_state);
void cmatrixlq(/* Complex */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Complex */ ae_vector* tau, ae_state *_state);
void _pexec_cmatrixlq(/* Complex */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Complex */ ae_vector* tau, ae_state *_state);
void rmatrixqrunpackq(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Real */ ae_vector* tau, ae_int_t qcolumns, /* Real */ ae_matrix* q, ae_state *_state);
void _pexec_rmatrixqrunpackq(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Real */ ae_vector* tau, ae_int_t qcolumns, /* Real */ ae_matrix* q, ae_state *_state);
void rmatrixqrunpackr(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Real */ ae_matrix* r, ae_state *_state);
void rmatrixlqunpackq(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Real */ ae_vector* tau, ae_int_t qrows, /* Real */ ae_matrix* q, ae_state *_state);
void _pexec_rmatrixlqunpackq(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Real */ ae_vector* tau, ae_int_t qrows, /* Real */ ae_matrix* q, ae_state *_state);
void rmatrixlqunpackl(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Real */ ae_matrix* l, ae_state *_state);
void cmatrixqrunpackq(/* Complex */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Complex */ ae_vector* tau, ae_int_t qcolumns, /* Complex */ ae_matrix* q, ae_state *_state);
void _pexec_cmatrixqrunpackq(/* Complex */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Complex */ ae_vector* tau, ae_int_t qcolumns, /* Complex */ ae_matrix* q, ae_state *_state);
void cmatrixqrunpackr(/* Complex */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Complex */ ae_matrix* r, ae_state *_state);
void cmatrixlqunpackq(/* Complex */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Complex */ ae_vector* tau, ae_int_t qrows, /* Complex */ ae_matrix* q, ae_state *_state);
void _pexec_cmatrixlqunpackq(/* Complex */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Complex */ ae_vector* tau, ae_int_t qrows, /* Complex */ ae_matrix* q, ae_state *_state);
void cmatrixlqunpackl(/* Complex */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Complex */ ae_matrix* l, ae_state *_state);
void rmatrixqrbasecase(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Real */ ae_vector* work, /* Real */ ae_vector* t, /* Real */ ae_vector* tau, ae_state *_state);
void rmatrixlqbasecase(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Real */ ae_vector* work, /* Real */ ae_vector* t, /* Real */ ae_vector* tau, ae_state *_state);
void rmatrixbd(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Real */ ae_vector* tauq, /* Real */ ae_vector* taup, ae_state *_state);
void rmatrixbdunpackq(/* Real */ ae_matrix* qp, ae_int_t m, ae_int_t n, /* Real */ ae_vector* tauq, ae_int_t qcolumns, /* Real */ ae_matrix* q, ae_state *_state);
void rmatrixbdmultiplybyq(/* Real */ ae_matrix* qp, ae_int_t m, ae_int_t n, /* Real */ ae_vector* tauq, /* Real */ ae_matrix* z, ae_int_t zrows, ae_int_t zcolumns, ae_bool fromtheright, ae_bool dotranspose, ae_state *_state);
void rmatrixbdunpackpt(/* Real */ ae_matrix* qp, ae_int_t m, ae_int_t n, /* Real */ ae_vector* taup, ae_int_t ptrows, /* Real */ ae_matrix* pt, ae_state *_state);
void rmatrixbdmultiplybyp(/* Real */ ae_matrix* qp, ae_int_t m, ae_int_t n, /* Real */ ae_vector* taup, /* Real */ ae_matrix* z, ae_int_t zrows, ae_int_t zcolumns, ae_bool fromtheright, ae_bool dotranspose, ae_state *_state);
void rmatrixbdunpackdiagonals(/* Real */ ae_matrix* b, ae_int_t m, ae_int_t n, ae_bool* isupper, /* Real */ ae_vector* d, /* Real */ ae_vector* e, ae_state *_state);
void rmatrixhessenberg(/* Real */ ae_matrix* a, ae_int_t n, /* Real */ ae_vector* tau, ae_state *_state);
void rmatrixhessenbergunpackq(/* Real */ ae_matrix* a, ae_int_t n, /* Real */ ae_vector* tau, /* Real */ ae_matrix* q, ae_state *_state);
void rmatrixhessenbergunpackh(/* Real */ ae_matrix* a, ae_int_t n, /* Real */ ae_matrix* h, ae_state *_state);
void smatrixtd(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, /* Real */ ae_vector* tau, /* Real */ ae_vector* d, /* Real */ ae_vector* e, ae_state *_state);
void smatrixtdunpackq(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, /* Real */ ae_vector* tau, /* Real */ ae_matrix* q, ae_state *_state);
void hmatrixtd(/* Complex */ ae_matrix* a, ae_int_t n, ae_bool isupper, /* Complex */ ae_vector* tau, /* Real */ ae_vector* d, /* Real */ ae_vector* e, ae_state *_state);
void hmatrixtdunpackq(/* Complex */ ae_matrix* a, ae_int_t n, ae_bool isupper, /* Complex */ ae_vector* tau, /* Complex */ ae_matrix* q, ae_state *_state);
ae_bool rmatrixbdsvd(/* Real */ ae_vector* d, /* Real */ ae_vector* e, ae_int_t n, ae_bool isupper, ae_bool isfractionalaccuracyrequired, /* Real */ ae_matrix* u, ae_int_t nru, /* Real */ ae_matrix* c, ae_int_t ncc, /* Real */ ae_matrix* vt, ae_int_t ncvt, ae_state *_state);
ae_bool bidiagonalsvddecomposition(/* Real */ ae_vector* d, /* Real */ ae_vector* e, ae_int_t n, ae_bool isupper, ae_bool isfractionalaccuracyrequired, /* Real */ ae_matrix* u, ae_int_t nru, /* Real */ ae_matrix* c, ae_int_t ncc, /* Real */ ae_matrix* vt, ae_int_t ncvt, ae_state *_state);
ae_bool rmatrixsvd(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, ae_int_t uneeded, ae_int_t vtneeded, ae_int_t additionalmemory, /* Real */ ae_vector* w, /* Real */ ae_matrix* u, /* Real */ ae_matrix* vt, ae_state *_state);
ae_bool _pexec_rmatrixsvd(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, ae_int_t uneeded, ae_int_t vtneeded, ae_int_t additionalmemory, /* Real */ ae_vector* w, /* Real */ ae_matrix* u, /* Real */ ae_matrix* vt, ae_state *_state);
ae_bool smatrixevd(/* Real */ ae_matrix* a, ae_int_t n, ae_int_t zneeded, ae_bool isupper, /* Real */ ae_vector* d, /* Real */ ae_matrix* z, ae_state *_state);
ae_bool smatrixevdr(/* Real */ ae_matrix* a, ae_int_t n, ae_int_t zneeded, ae_bool isupper, double b1, double b2, ae_int_t* m, /* Real */ ae_vector* w, /* Real */ ae_matrix* z, ae_state *_state);
ae_bool smatrixevdi(/* Real */ ae_matrix* a, ae_int_t n, ae_int_t zneeded, ae_bool isupper, ae_int_t i1, ae_int_t i2, /* Real */ ae_vector* w, /* Real */ ae_matrix* z, ae_state *_state);
ae_bool hmatrixevd(/* Complex */ ae_matrix* a, ae_int_t n, ae_int_t zneeded, ae_bool isupper, /* Real */ ae_vector* d, /* Complex */ ae_matrix* z, ae_state *_state);
ae_bool hmatrixevdr(/* Complex */ ae_matrix* a, ae_int_t n, ae_int_t zneeded, ae_bool isupper, double b1, double b2, ae_int_t* m, /* Real */ ae_vector* w, /* Complex */ ae_matrix* z, ae_state *_state);
ae_bool hmatrixevdi(/* Complex */ ae_matrix* a, ae_int_t n, ae_int_t zneeded, ae_bool isupper, ae_int_t i1, ae_int_t i2, /* Real */ ae_vector* w, /* Complex */ ae_matrix* z, ae_state *_state);
ae_bool smatrixtdevd(/* Real */ ae_vector* d,
/* Real */ ae_vector* e,
ae_int_t n,
ae_int_t zneeded,
/* Real */ ae_matrix* z,
ae_state *_state);
ae_bool smatrixtdevdr(/* Real */ ae_vector* d, /* Real */ ae_vector* e, ae_int_t n, ae_int_t zneeded, double a, double b, ae_int_t* m, /* Real */ ae_matrix* z, ae_state *_state);
ae_bool smatrixtdevdi(/* Real */ ae_vector* d, /* Real */ ae_vector* e, ae_int_t n, ae_int_t zneeded, ae_int_t i1, ae_int_t i2, /* Real */ ae_matrix* z, ae_state *_state);
ae_bool rmatrixevd(/* Real */ ae_matrix* a, ae_int_t n, ae_int_t vneeded, /* Real */ ae_vector* wr, /* Real */ ae_vector* wi, /* Real */ ae_matrix* vl, /* Real */ ae_matrix* vr, ae_state *_state);
void rmatrixrndorthogonal(ae_int_t n, /* Real */ ae_matrix* a, ae_state *_state);
void rmatrixrndcond(ae_int_t n, double c, /* Real */ ae_matrix* a, ae_state *_state);
void cmatrixrndorthogonal(ae_int_t n, /* Complex */ ae_matrix* a, ae_state *_state);
void cmatrixrndcond(ae_int_t n, double c, /* Complex */ ae_matrix* a, ae_state *_state);
void smatrixrndcond(ae_int_t n, double c, /* Real */ ae_matrix* a, ae_state *_state);
void spdmatrixrndcond(ae_int_t n, double c, /* Real */ ae_matrix* a, ae_state *_state);
void hmatrixrndcond(ae_int_t n, double c, /* Complex */ ae_matrix* a, ae_state *_state);
void hpdmatrixrndcond(ae_int_t n, double c, /* Complex */ ae_matrix* a, ae_state *_state);
void rmatrixrndorthogonalfromtheright(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, ae_state *_state);
void rmatrixrndorthogonalfromtheleft(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, ae_state *_state);
void cmatrixrndorthogonalfromtheright(/* Complex */ ae_matrix* a, ae_int_t m, ae_int_t n, ae_state *_state);
void cmatrixrndorthogonalfromtheleft(/* Complex */ ae_matrix* a, ae_int_t m, ae_int_t n, ae_state *_state);
void smatrixrndmultiply(/* Real */ ae_matrix* a, ae_int_t n, ae_state *_state);
void hmatrixrndmultiply(/* Complex */ ae_matrix* a, ae_int_t n, ae_state *_state);
void sparsecreate(ae_int_t m, ae_int_t n, ae_int_t k, sparsematrix* s, ae_state *_state);
void sparsecreatebuf(ae_int_t m, ae_int_t n, ae_int_t k, sparsematrix* s, ae_state *_state);
void sparsecreatecrs(ae_int_t m, ae_int_t n, /* Integer */ ae_vector* ner, sparsematrix* s, ae_state *_state);
void sparsecreatecrsbuf(ae_int_t m, ae_int_t n, /* Integer */ ae_vector* ner, sparsematrix* s, ae_state *_state);
void sparsecreatesks(ae_int_t m, ae_int_t n, /* Integer */ ae_vector* d, /* Integer */ ae_vector* u, sparsematrix* s, ae_state *_state);
void sparsecreatesksbuf(ae_int_t m, ae_int_t n, /* Integer */ ae_vector* d, /* Integer */ ae_vector* u, sparsematrix* s, ae_state *_state);
void sparsecopy(sparsematrix* s0, sparsematrix* s1, ae_state *_state);
void sparsecopybuf(sparsematrix* s0, sparsematrix* s1, ae_state *_state);
void sparseswap(sparsematrix* s0, sparsematrix* s1, ae_state *_state);
void sparseadd(sparsematrix* s, ae_int_t i, ae_int_t j, double v, ae_state *_state);
void sparseset(sparsematrix* s, ae_int_t i, ae_int_t j, double v, ae_state *_state);
double sparseget(sparsematrix* s, ae_int_t i, ae_int_t j, ae_state *_state);
double sparsegetdiagonal(sparsematrix* s, ae_int_t i, ae_state *_state);
void sparsemv(sparsematrix* s, /* Real */ ae_vector* x, /* Real */ ae_vector* y, ae_state *_state);
void sparsemtv(sparsematrix* s, /* Real */ ae_vector* x, /* Real */ ae_vector* y, ae_state *_state);
void sparsemv2(sparsematrix* s, /* Real */ ae_vector* x, /* Real */ ae_vector* y0, /* Real */ ae_vector* y1, ae_state *_state);
void sparsesmv(sparsematrix* s, ae_bool isupper, /* Real */ ae_vector* x, /* Real */ ae_vector* y, ae_state *_state);
double sparsevsmv(sparsematrix* s, ae_bool isupper, /* Real */ ae_vector* x, ae_state *_state);
void sparsemm(sparsematrix* s, /* Real */ ae_matrix* a, ae_int_t k, /* Real */ ae_matrix* b, ae_state *_state);
void sparsemtm(sparsematrix* s, /* Real */ ae_matrix* a, ae_int_t k, /* Real */ ae_matrix* b, ae_state *_state);
void sparsemm2(sparsematrix* s, /* Real */ ae_matrix* a, ae_int_t k, /* Real */ ae_matrix* b0, /* Real */ ae_matrix* b1, ae_state *_state);
void sparsesmm(sparsematrix* s, ae_bool isupper, /* Real */ ae_matrix* a, ae_int_t k, /* Real */ ae_matrix* b, ae_state *_state);
void sparsetrmv(sparsematrix* s, ae_bool isupper, ae_bool isunit, ae_int_t optype, /* Real */ ae_vector* x, /* Real */ ae_vector* y, ae_state *_state);
void sparsetrsv(sparsematrix* s, ae_bool isupper, ae_bool isunit, ae_int_t optype, /* Real */ ae_vector* x, ae_state *_state);
void sparseresizematrix(sparsematrix* s, ae_state *_state);
double sparsegetaveragelengthofchain(sparsematrix* s, ae_state *_state);
ae_bool sparseenumerate(sparsematrix* s, ae_int_t* t0, ae_int_t* t1, ae_int_t* i, ae_int_t* j, double* v, ae_state *_state);
ae_bool sparserewriteexisting(sparsematrix* s, ae_int_t i, ae_int_t j, double v, ae_state *_state);
void sparsegetrow(sparsematrix* s, ae_int_t i, /* Real */ ae_vector* irow, ae_state *_state);
void sparsegetcompressedrow(sparsematrix* s, ae_int_t i, /* Integer */ ae_vector* colidx, /* Real */ ae_vector* vals, ae_int_t* nzcnt, ae_state *_state);
void sparsetransposesks(sparsematrix* s, ae_state *_state);
void sparseconvertto(sparsematrix* s0, ae_int_t fmt, ae_state *_state);
void sparsecopytobuf(sparsematrix* s0, ae_int_t fmt, sparsematrix* s1, ae_state *_state);
void sparseconverttohash(sparsematrix* s, ae_state *_state);
void sparsecopytohash(sparsematrix* s0, sparsematrix* s1, ae_state *_state);
void sparsecopytohashbuf(sparsematrix* s0, sparsematrix* s1, ae_state *_state);
void sparseconverttocrs(sparsematrix* s, ae_state *_state);
void sparsecopytocrs(sparsematrix* s0, sparsematrix* s1, ae_state *_state);
void sparsecopytocrsbuf(sparsematrix* s0, sparsematrix* s1, ae_state *_state);
void sparseconverttosks(sparsematrix* s, ae_state *_state);
void sparsecopytosks(sparsematrix* s0, sparsematrix* s1, ae_state *_state);
void sparsecopytosksbuf(sparsematrix* s0,
sparsematrix* s1,
ae_state *_state);
ae_int_t sparsegetmatrixtype(sparsematrix* s, ae_state *_state);
ae_bool sparseishash(sparsematrix* s, ae_state *_state);
ae_bool sparseiscrs(sparsematrix* s, ae_state *_state);
ae_bool sparseissks(sparsematrix* s, ae_state *_state);
void sparsefree(sparsematrix* s, ae_state *_state);
ae_int_t sparsegetnrows(sparsematrix* s, ae_state *_state);
ae_int_t sparsegetncols(sparsematrix* s, ae_state *_state);
ae_int_t sparsegetuppercount(sparsematrix* s, ae_state *_state);
ae_int_t sparsegetlowercount(sparsematrix* s, ae_state *_state);
void _sparsematrix_init(void* _p, ae_state *_state);
void _sparsematrix_init_copy(void* _dst, void* _src, ae_state *_state);
void _sparsematrix_clear(void* _p);
void _sparsematrix_destroy(void* _p);
void _sparsebuffers_init(void* _p, ae_state *_state);
void _sparsebuffers_init_copy(void* _dst, void* _src, ae_state *_state);
void _sparsebuffers_clear(void* _p);
void _sparsebuffers_destroy(void* _p);
void rmatrixlu(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Integer */ ae_vector* pivots, ae_state *_state);
void _pexec_rmatrixlu(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Integer */ ae_vector* pivots, ae_state *_state);
void cmatrixlu(/* Complex */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Integer */ ae_vector* pivots, ae_state *_state);
void _pexec_cmatrixlu(/* Complex */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Integer */ ae_vector* pivots, ae_state *_state);
ae_bool hpdmatrixcholesky(/* Complex */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_state *_state);
ae_bool _pexec_hpdmatrixcholesky(/* Complex */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_state *_state);
ae_bool spdmatrixcholesky(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_state *_state);
ae_bool _pexec_spdmatrixcholesky(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_state *_state);
void spdmatrixcholeskyupdateadd1(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, /* Real */ ae_vector* u, ae_state *_state);
void spdmatrixcholeskyupdatefix(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, /* Boolean */ ae_vector* fix, ae_state *_state);
void spdmatrixcholeskyupdateadd1buf(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, /* Real */ ae_vector* u, /* Real */ ae_vector* bufr, ae_state *_state);
void spdmatrixcholeskyupdatefixbuf(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, /* Boolean */ ae_vector* fix, /* Real */ ae_vector* bufr, ae_state *_state);
ae_bool sparsecholeskyskyline(sparsematrix* a, ae_int_t n, ae_bool isupper, ae_state *_state);
ae_bool sparsecholeskyx(sparsematrix* a, ae_int_t n, ae_bool isupper, /* Integer */ ae_vector* p0, /* Integer */ ae_vector* p1, ae_int_t ordering, ae_int_t algo, ae_int_t fmt, sparsebuffers* buf, sparsematrix* c, ae_state *_state);
void rmatrixlup(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Integer */ ae_vector* pivots, ae_state *_state);
void cmatrixlup(/* Complex */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Integer */ ae_vector* pivots, ae_state *_state);
void rmatrixplu(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Integer */ ae_vector* pivots, ae_state *_state);
void cmatrixplu(/* Complex */ ae_matrix* a, ae_int_t m, ae_int_t n, /* Integer */ ae_vector* pivots, ae_state *_state);
ae_bool spdmatrixcholeskyrec(/* Real */ ae_matrix* a, ae_int_t offs, ae_int_t n, ae_bool isupper, /* Real */ ae_vector* tmp, ae_state *_state);
double rmatrixrcond1(/* Real */ ae_matrix* a, ae_int_t n, ae_state *_state);
double rmatrixrcondinf(/* Real */ ae_matrix* a, ae_int_t n, ae_state *_state);
double spdmatrixrcond(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_state *_state);
double rmatrixtrrcond1(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_bool isunit, ae_state *_state);
double rmatrixtrrcondinf(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_bool isunit, ae_state *_state);
double hpdmatrixrcond(/* Complex */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_state *_state);
double cmatrixrcond1(/* Complex */ ae_matrix* a, ae_int_t n, ae_state *_state);
double cmatrixrcondinf(/* Complex */ ae_matrix* a, ae_int_t n, ae_state *_state);
double rmatrixlurcond1(/* Real */ ae_matrix* lua, ae_int_t n, ae_state *_state);
double rmatrixlurcondinf(/* Real */ ae_matrix* lua, ae_int_t n, ae_state *_state);
double spdmatrixcholeskyrcond(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_state *_state);
double hpdmatrixcholeskyrcond(/* Complex */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_state *_state);
double cmatrixlurcond1(/* Complex */ ae_matrix* lua, ae_int_t n, ae_state *_state);
double cmatrixlurcondinf(/* Complex */ ae_matrix* lua, ae_int_t n, ae_state *_state);
double cmatrixtrrcond1(/* Complex */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_bool isunit, ae_state *_state);
double cmatrixtrrcondinf(/* Complex */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_bool isunit, ae_state *_state);
double rcondthreshold(ae_state *_state);
void rmatrixluinverse(/* Real */ ae_matrix* a, /* Integer */ ae_vector* pivots, ae_int_t n, ae_int_t* info, matinvreport* rep, ae_state *_state);
void _pexec_rmatrixluinverse(/* Real */ ae_matrix* a, /* Integer */ ae_vector* pivots, ae_int_t n, ae_int_t* info, matinvreport* rep, ae_state *_state);
void rmatrixinverse(/* Real */ ae_matrix* a, ae_int_t n, ae_int_t* info, matinvreport* rep, ae_state *_state);
void _pexec_rmatrixinverse(/* Real */ ae_matrix* a, ae_int_t n, ae_int_t* info, matinvreport* rep, ae_state *_state);
void cmatrixluinverse(/* Complex */ ae_matrix* a, /* Integer */ ae_vector* pivots, ae_int_t n, ae_int_t* info, matinvreport* rep, ae_state *_state);
void _pexec_cmatrixluinverse(/* Complex */ ae_matrix* a, /* Integer */ ae_vector* pivots, ae_int_t n, ae_int_t* info, matinvreport* rep, ae_state *_state);
void cmatrixinverse(/* Complex */ ae_matrix* a, ae_int_t n, ae_int_t* info, matinvreport* rep, ae_state *_state);
void _pexec_cmatrixinverse(/* Complex */ ae_matrix* a, ae_int_t n, ae_int_t* info, matinvreport* rep, ae_state *_state);
void spdmatrixcholeskyinverse(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_int_t* info, matinvreport* rep, ae_state *_state);
void _pexec_spdmatrixcholeskyinverse(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_int_t* info, matinvreport* rep, ae_state *_state);
void spdmatrixinverse(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_int_t* info, matinvreport* rep, ae_state *_state);
void _pexec_spdmatrixinverse(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_int_t* info, matinvreport* rep, ae_state *_state);
void hpdmatrixcholeskyinverse(/* Complex */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_int_t* info, matinvreport* rep, ae_state *_state);
void _pexec_hpdmatrixcholeskyinverse(/* Complex */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_int_t* info, matinvreport* rep, ae_state *_state);
void hpdmatrixinverse(/* Complex */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_int_t* info, matinvreport* rep, ae_state *_state);
void _pexec_hpdmatrixinverse(/* Complex */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_int_t* info, matinvreport* rep, ae_state *_state);
void rmatrixtrinverse(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_bool isunit, ae_int_t* info, matinvreport* rep, ae_state *_state);
void _pexec_rmatrixtrinverse(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_bool isunit, ae_int_t* info, matinvreport* rep, ae_state *_state);
void cmatrixtrinverse(/* Complex */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_bool isunit, ae_int_t* info, matinvreport* rep, ae_state *_state);
void _pexec_cmatrixtrinverse(/* Complex */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_bool isunit, ae_int_t* info, matinvreport* rep, ae_state *_state);
void spdmatrixcholeskyinverserec(/* Real */ ae_matrix* a, ae_int_t offs, ae_int_t n, ae_bool isupper, /* Real */ ae_vector* tmp, ae_state *_state);
void _matinvreport_init(void* _p, ae_state *_state);
void _matinvreport_init_copy(void* _dst, void* _src, ae_state *_state);
void _matinvreport_clear(void* _p);
void _matinvreport_destroy(void* _p);
void fblscholeskysolve(/* Real */ ae_matrix* cha, double sqrtscalea, ae_int_t n, ae_bool isupper, /* Real */ ae_vector* xb, /* Real */ ae_vector* tmp, ae_state *_state);
void fblssolvecgx(/* Real */ ae_matrix* a, ae_int_t m, ae_int_t n, double alpha, /* Real */ ae_vector* b, /* Real */ ae_vector* x, /* Real */ ae_vector* buf, ae_state *_state);
void fblscgcreate(/* Real */ ae_vector* x, /* Real */ ae_vector* b, ae_int_t n, fblslincgstate* state, ae_state *_state);
ae_bool fblscgiteration(fblslincgstate* state, ae_state *_state);
void fblssolvels(/* Real */ ae_matrix* a, /* Real */ ae_vector* b, ae_int_t m, ae_int_t n, /* Real */ ae_vector* tmp0, /* Real */ ae_vector* tmp1, /* Real */ ae_vector* tmp2, ae_state *_state);
void _fblslincgstate_init(void* _p, ae_state *_state);
void _fblslincgstate_init_copy(void* _dst, void* _src, ae_state *_state);
void _fblslincgstate_clear(void* _p);
void _fblslincgstate_destroy(void* _p);
void normestimatorcreate(ae_int_t m, ae_int_t n, ae_int_t nstart, ae_int_t nits, normestimatorstate* state, ae_state *_state);
void normestimatorsetseed(normestimatorstate* state, ae_int_t seedval, ae_state *_state);
ae_bool normestimatoriteration(normestimatorstate* state, ae_state *_state);
void normestimatorestimatesparse(normestimatorstate* state, sparsematrix* a, ae_state *_state);
void normestimatorresults(normestimatorstate* state, double* nrm, ae_state *_state);
void normestimatorrestart(normestimatorstate* state, ae_state *_state);
void _normestimatorstate_init(void* _p, ae_state *_state);
void _normestimatorstate_init_copy(void* _dst, void* _src, ae_state *_state);
void _normestimatorstate_clear(void* _p);
void _normestimatorstate_destroy(void* _p);
double rmatrixludet(/* Real */ ae_matrix* a, /* Integer */ ae_vector* pivots, ae_int_t n, ae_state *_state);
double rmatrixdet(/* Real */ ae_matrix* a, ae_int_t n, ae_state *_state);
ae_complex cmatrixludet(/* Complex */ ae_matrix* a, /* Integer */ ae_vector* pivots, ae_int_t n, ae_state *_state);
ae_complex cmatrixdet(/* Complex */ ae_matrix* a, ae_int_t n, ae_state *_state);
double spdmatrixcholeskydet(/* Real */ ae_matrix* a, ae_int_t n, ae_state *_state);
double spdmatrixdet(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isupper, ae_state *_state);
ae_bool smatrixgevd(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isuppera, /* Real */ ae_matrix* b, ae_bool isupperb, ae_int_t zneeded, ae_int_t problemtype, /* Real */ ae_vector* d, /* Real */ ae_matrix* z, ae_state *_state);
ae_bool smatrixgevdreduce(/* Real */ ae_matrix* a, ae_int_t n, ae_bool isuppera, /* Real */ ae_matrix* b, ae_bool isupperb, ae_int_t problemtype, /* Real */ ae_matrix* r, ae_bool* isupperr, ae_state *_state);
void rmatrixinvupdatesimple(/* Real */ ae_matrix* inva, ae_int_t n, ae_int_t updrow, ae_int_t updcolumn, double updval, ae_state *_state);
void rmatrixinvupdaterow(/* Real */ ae_matrix* inva, ae_int_t n, ae_int_t updrow, /* Real */ ae_vector* v, ae_state *_state); void rmatrixinvupdatecolumn(/* Real */ ae_matrix* inva, ae_int_t n, ae_int_t updcolumn, /* Real */ ae_vector* u, ae_state *_state);
void rmatrixinvupdateuv(/* Real */ ae_matrix* inva, ae_int_t n, /* Real */ ae_vector* u, /* Real */ ae_vector* v, ae_state *_state);
ae_bool rmatrixschur(/* Real */ ae_matrix* a, ae_int_t n, /* Real */ ae_matrix* s, ae_state *_state);
}
|
D
|
instance KDF_505_Marduk(Npc_Default)
{
name[0] = "Мардук";
guild = GIL_KDF;
id = 505;
voice = 11;//5;
flags = 0;
npcType = NPCTYPE_AMBIENT;
B_SetAttributesToChapter(self,6);
aivar[AIV_Temper] = TEMPER_MagicUser;
fight_tactic = FAI_HUMAN_MASTER;
B_CreateAmbientInv(self);
CreateInvItem(self,ItMi_Pliers);
B_SetNpcVisual(self,MALE,"Hum_Head_Bald",Face_P_OldMan_Gravo,BodyTex_P,ItAr_KDF_L);
Mdl_SetModelFatness(self,0);
Mdl_ApplyOverlayMds(self,"Humans_Mage.mds");
B_GiveNpcTalents(self);
B_SetFightSkills(self,30);
daily_routine = Rtn_Start_505;
aivar[AIV_TheftDex] = 36;
CreateInvItems(self, ItMi_Gold, 40);
};
func void Rtn_Start_505()
{
TA_Stand_Guarding(8,0,23,0,"NW_MONASTERY_CORRIDOR_03");
TA_Sleep(23,0,8,0,"NW_MONASTERY_MAGE02_BED_02");
};
|
D
|
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 Devisualization (Richard Andrew Cattermole)
*
* 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 devisualization.image.png.writer_chunks;
import devisualization.image.png.defs;
import devisualization.image.png.write;
import std.bitmanip : nativeToBigEndian;
void write_IHDR(PngImage image, ref ubyte[] ret) {
ubyte[] data;
data ~= nativeToBigEndian!uint(image.IHDR.width);
data ~= nativeToBigEndian!uint(image.IHDR.height);
data ~= cast(ubyte)image.IHDR.bitDepth;
data ~= cast(ubyte)image.IHDR.colorType;
data ~= cast(ubyte)image.IHDR.compressionMethod;
data ~= cast(ubyte)image.IHDR.filterMethod;
data ~= cast(ubyte)image.IHDR.interlaceMethod;
writeChunk("IHDR", data, ret);
}
void write_PLTE(PngImage image, ref ubyte[] ret) {
if (image.PLTE is null) return;
ubyte[] data;
foreach(color; image.PLTE.colors) {
data ~= color.r;
data ~= color.g;
data ~= color.b;
}
writeChunk("PLTE", data, ret);
}
void write_BKGD(PngImage image, ref ubyte[] ret) {
// TODO: waiting on loader
}
void write_cHRM(PngImage image, ref ubyte[] ret) {
if (image.cHRM is null) return;
ubyte[] data;
data ~= nativeToBigEndian!uint(image.cHRM.white_x);
data ~= nativeToBigEndian!uint(image.cHRM.white_y);
data ~= nativeToBigEndian!uint(image.cHRM.red_x);
data ~= nativeToBigEndian!uint(image.cHRM.red_y);
data ~= nativeToBigEndian!uint(image.cHRM.green_x);
data ~= nativeToBigEndian!uint(image.cHRM.green_y);
data ~= nativeToBigEndian!uint(image.cHRM.blue_x);
data ~= nativeToBigEndian!uint(image.cHRM.blue_y);
writeChunk("cHRM", data, ret);
}
void write_gAMA(PngImage image, ref ubyte[] ret) {
if (image.gAMA is null) return;
ubyte[] data;
data ~= nativeToBigEndian!uint(image.gAMA.value);
writeChunk("gAMA", data, ret);
}
void write_hIST(PngImage image, ref ubyte[] ret) {
// TODO: waiting on loader
}
void write_pHYs(PngImage image, ref ubyte[] ret) {
// TODO: waiting on loader
}
void write_sBIT(PngImage image, ref ubyte[] ret) {
// TODO: waiting on loader
}
void write_tEXt(PngImage image, ref ubyte[] ret) {
foreach(k, v; image.tEXt) {
writeChunk("tEXt", cast(ubyte[])(k ~ "\0" ~ v), ret);
}
}
void write_tIME(PngImage image, ref ubyte[] ret) {
// TODO: waiting on loader
}
void write_tRNS(PngImage image, ref ubyte[] ret) {
// TODO: waiting on loader
}
void write_zTXt(PngImage image, ref ubyte[] ret) {
// TODO: waiting on loader
}
void write_IEND(PngImage image, ref ubyte[] ret) {
writeChunk("IEND", [], ret);
}
|
D
|
// This file is part of CCBI - Conforming Concurrent Befunge-98 Interpreter
// Copyright (c) 2006-2010 Matti Niemenmaa
// See license.txt, which you should have received together with this file, for
// licensing information.
// File created: 2007-01-20 21:19:40
module ccbi.fingerprints.glfunge98.scke;
import ccbi.fingerprint;
version (SOCK) {} else
static assert (false, "SCKE requires SOCK!");
mixin (Fingerprint!(
"SCKE",
"",
"H", "getHostByName",
"P", "peek"
));
template SCKE() {
alias SOCK.sockets sockets;
void ctor() {
if (!ss)
ss = new SocketSet(1);
}
SocketSet ss;
void getHostByName() {
auto h = new NetHost;
try if (!h.getHostByName(popString()))
return reverse();
catch {
return reverse();
}
cip.stack.push(h.addrList[0]);
}
void peek() {
auto s = cast(size_t)cip.stack.pop;
if (s >= sockets.length || !sockets[s])
return reverse();
ss.reset();
ss.add(sockets[s]);
auto n = ss.select(ss, null, null, 0);
if (n == -1)
reverse();
else
cip.stack.push(n);
}
}
|
D
|
Listen {{ Port }}
<VirtualHost {{ansible_facts['default_ipv4']['address']}}:{{Port}}>
DocumentRoot {{ Document_root }}
</VirtualHost>
|
D
|
/Users/yinheng/Desktop/code/node/rs/httpie/target/debug/deps/mime-7ece07cf9aa5b214.rmeta: /Users/yinheng/.cargo/registry/src/github.com-1ecc6299db9ec823/mime-0.3.16/src/lib.rs /Users/yinheng/.cargo/registry/src/github.com-1ecc6299db9ec823/mime-0.3.16/src/parse.rs
/Users/yinheng/Desktop/code/node/rs/httpie/target/debug/deps/libmime-7ece07cf9aa5b214.rlib: /Users/yinheng/.cargo/registry/src/github.com-1ecc6299db9ec823/mime-0.3.16/src/lib.rs /Users/yinheng/.cargo/registry/src/github.com-1ecc6299db9ec823/mime-0.3.16/src/parse.rs
/Users/yinheng/Desktop/code/node/rs/httpie/target/debug/deps/mime-7ece07cf9aa5b214.d: /Users/yinheng/.cargo/registry/src/github.com-1ecc6299db9ec823/mime-0.3.16/src/lib.rs /Users/yinheng/.cargo/registry/src/github.com-1ecc6299db9ec823/mime-0.3.16/src/parse.rs
/Users/yinheng/.cargo/registry/src/github.com-1ecc6299db9ec823/mime-0.3.16/src/lib.rs:
/Users/yinheng/.cargo/registry/src/github.com-1ecc6299db9ec823/mime-0.3.16/src/parse.rs:
|
D
|
/*
TEST_OUTPUT:
---
fail_compilation/fail15535.d(17): Error: goto default not allowed in final switch statement
---
*/
void test()
{
int i;
switch (i)
{
case 0:
final switch (i)
{
case 1:
goto default;
}
default:
break;
}
}
|
D
|
a former British gold coin worth 21 shillings
(ethnic slur) offensive term for a person of Italian descent
a republic in western Africa on the Atlantic
a west African bird having dark plumage mottled with white
|
D
|
/*******************************************************************************
* Copyright (c) 2000, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Port to the D programming language:
* Frank Benoit <benoit@tionex.de>
*******************************************************************************/
module dwtx.jface.text.templates.persistence.TemplateStore;
import dwtx.jface.text.templates.persistence.TemplatePersistenceData; // packageimport
import dwtx.jface.text.templates.persistence.TemplateReaderWriter; // packageimport
import dwtx.jface.text.templates.persistence.TemplatePersistenceMessages; // packageimport
import dwt.dwthelper.utils;
import dwtx.dwtxhelper.Collection;
import dwtx.dwtxhelper.StringWriter;
import dwtx.dwtxhelper.StringReader;
import dwtx.core.runtime.Assert;
import dwtx.jface.preference.IPersistentPreferenceStore;
import dwtx.jface.preference.IPreferenceStore;
import dwtx.jface.text.templates.ContextTypeRegistry;
import dwtx.jface.text.templates.Template;
import dwtx.jface.text.templates.TemplateException;
import dwtx.jface.util.IPropertyChangeListener;
import dwtx.jface.util.PropertyChangeEvent;
/**
* A collection of templates. Clients may instantiate this class. In order to
* load templates contributed using the <code>dwtx.ui.editors.templates</code>
* extension point, use a <code>ContributionTemplateStore</code>.
*
* @since 3.0
*/
public class TemplateStore {
/** The stored templates. */
private const List fTemplates;
/** The preference store. */
private IPreferenceStore fPreferenceStore;
/**
* The key into <code>fPreferenceStore</code> the value of which holds custom templates
* encoded as XML.
*/
private String fKey;
/**
* The context type registry, or <code>null</code> if all templates regardless
* of context type should be loaded.
*/
private ContextTypeRegistry fRegistry;
/**
* Set to <code>true</code> if property change events should be ignored (e.g. during writing
* to the preference store).
*
* @since 3.2
*/
private bool fIgnorePreferenceStoreChanges= false;
/**
* The property listener, if any is registered, <code>null</code> otherwise.
*
* @since 3.2
*/
private IPropertyChangeListener fPropertyListener;
/**
* Creates a new template store.
*
* @param store the preference store in which to store custom templates
* under <code>key</code>
* @param key the key into <code>store</code> where to store custom
* templates
*/
public this(IPreferenceStore store, String key) {
fTemplates= new ArrayList();
Assert.isNotNull(cast(Object)store);
Assert.isNotNull(key);
fPreferenceStore= store;
fKey= key;
}
/**
* Creates a new template store with a context type registry. Only templates
* that specify a context type contained in the registry will be loaded by
* this store if the registry is not <code>null</code>.
*
* @param registry a context type registry, or <code>null</code> if all
* templates should be loaded
* @param store the preference store in which to store custom templates
* under <code>key</code>
* @param key the key into <code>store</code> where to store custom
* templates
*/
public this(ContextTypeRegistry registry, IPreferenceStore store, String key) {
this(store, key);
fRegistry= registry;
}
/**
* Loads the templates from contributions and preferences.
*
* @throws IOException if loading fails.
*/
public void load() {
fTemplates.clear();
loadContributedTemplates();
loadCustomTemplates();
}
/**
* Starts listening for property changes on the preference store. If the configured preference
* key changes, the template store is {@link #load() reloaded}. Call
* {@link #stopListeningForPreferenceChanges()} to remove any listener and stop the
* auto-updating behavior.
*
* @since 3.2
*/
public final void startListeningForPreferenceChanges() {
if (fPropertyListener is null) {
fPropertyListener= new class() IPropertyChangeListener {
public void propertyChange(PropertyChangeEvent event) {
/*
* Don't load if we are in the process of saving ourselves. We are in sync anyway after the
* save operation, and clients may trigger reloading by listening to preference store
* updates.
*/
if (!fIgnorePreferenceStoreChanges && fKey.equals(event.getProperty()))
try {
load();
} catch (IOException x) {
handleException(x);
}
}
};
fPreferenceStore.addPropertyChangeListener(fPropertyListener);
}
}
/**
* Stops the auto-updating behavior started by calling
* {@link #startListeningForPreferenceChanges()}.
*
* @since 3.2
*/
public final void stopListeningForPreferenceChanges() {
if (fPropertyListener !is null) {
fPreferenceStore.removePropertyChangeListener(fPropertyListener);
fPropertyListener= null;
}
}
/**
* Handles an {@link IOException} thrown during reloading the preferences due to a preference
* store update. The default is to write to stderr.
*
* @param x the exception
* @since 3.2
*/
protected void handleException(IOException x) {
ExceptionPrintStackTrace(x);
}
/**
* Hook method to load contributed templates. Contributed templates are superseded
* by customized versions of user added templates stored in the preferences.
* <p>
* The default implementation does nothing.</p>
*
* @throws IOException if loading fails
*/
protected void loadContributedTemplates() {
}
/**
* Adds a template to the internal store. The added templates must have
* a unique id.
*
* @param data the template data to add
*/
protected void internalAdd(TemplatePersistenceData data) {
if (!data.isCustom()) {
// check if the added template is not a duplicate id
String id= data.getId();
for (Iterator it= fTemplates.iterator(); it.hasNext();) {
TemplatePersistenceData d2= cast(TemplatePersistenceData) it.next();
if (d2.getId() !is null && d2.getId().equals(id))
return;
}
fTemplates.add(data);
}
}
/**
* Saves the templates to the preferences.
*
* @throws IOException if the templates cannot be written
*/
public void save() {
ArrayList custom= new ArrayList();
for (Iterator it= fTemplates.iterator(); it.hasNext();) {
TemplatePersistenceData data= cast(TemplatePersistenceData) it.next();
if (data.isCustom() && !(data.isUserAdded() && data.isDeleted())) // don't save deleted user-added templates
custom.add(data);
}
StringWriter output= new StringWriter();
TemplateReaderWriter writer= new TemplateReaderWriter();
writer.save(arraycast!(TemplatePersistenceData)( custom.toArray()), output);
fIgnorePreferenceStoreChanges= true;
try {
fPreferenceStore.setValue(fKey, output.toString());
if ( cast(IPersistentPreferenceStore)fPreferenceStore )
(cast(IPersistentPreferenceStore)fPreferenceStore).save();
} finally {
fIgnorePreferenceStoreChanges= false;
}
}
/**
* Adds a template encapsulated in its persistent form.
*
* @param data the template to add
*/
public void add(TemplatePersistenceData data) {
if (!validateTemplate(data.getTemplate()))
return;
if (data.isUserAdded()) {
fTemplates.add(data);
} else {
for (Iterator it= fTemplates.iterator(); it.hasNext();) {
TemplatePersistenceData d2= cast(TemplatePersistenceData) it.next();
if (d2.getId() !is null && d2.getId().equals(data.getId())) {
d2.setTemplate(data.getTemplate());
d2.setDeleted(data.isDeleted());
d2.setEnabled(data.isEnabled());
return;
}
}
// add an id which is not contributed as add-on
if (data.getTemplate() !is null) {
TemplatePersistenceData newData= new TemplatePersistenceData(data.getTemplate(), data.isEnabled());
fTemplates.add(newData);
}
}
}
/**
* Removes a template from the store.
*
* @param data the template to remove
*/
public void delete_(TemplatePersistenceData data) {
if (data.isUserAdded())
fTemplates.remove(data);
else
data.setDeleted(true);
}
/**
* Restores all contributed templates that have been deleted.
*/
public void restoreDeleted() {
for (Iterator it= fTemplates.iterator(); it.hasNext();) {
TemplatePersistenceData data= cast(TemplatePersistenceData) it.next();
if (data.isDeleted())
data.setDeleted(false);
}
}
/**
* Deletes all user-added templates and reverts all contributed templates.
*/
public void restoreDefaults() {
try {
fIgnorePreferenceStoreChanges= true;
fPreferenceStore.setToDefault(fKey);
} finally {
fIgnorePreferenceStoreChanges= false;
}
try {
load();
} catch (IOException x) {
// can't log from jface-text
ExceptionPrintStackTrace(x);
}
}
/**
* Returns all enabled templates.
*
* @return all enabled templates
*/
public Template[] getTemplates() {
return getTemplates(null);
}
/**
* Returns all enabled templates for the given context type.
*
* @param contextTypeId the id of the context type of the requested templates, or <code>null</code> if all templates should be returned
* @return all enabled templates for the given context type
*/
public Template[] getTemplates(String contextTypeId) {
List templates= new ArrayList();
for (Iterator it= fTemplates.iterator(); it.hasNext();) {
TemplatePersistenceData data= cast(TemplatePersistenceData) it.next();
if (data.isEnabled() && !data.isDeleted() && (contextTypeId is null || contextTypeId.equals(data.getTemplate().getContextTypeId())))
templates.add(data.getTemplate());
}
return arraycast!(Template)( templates.toArray());
}
/**
* Returns the first enabled template that matches the name.
*
* @param name the name of the template searched for
* @return the first enabled template that matches both name and context type id, or <code>null</code> if none is found
*/
public Template findTemplate(String name) {
return findTemplate(name, null);
}
/**
* Returns the first enabled template that matches both name and context type id.
*
* @param name the name of the template searched for
* @param contextTypeId the context type id to clip unwanted templates, or <code>null</code> if any context type is OK
* @return the first enabled template that matches both name and context type id, or <code>null</code> if none is found
*/
public Template findTemplate(String name, String contextTypeId) {
Assert.isNotNull(name);
for (Iterator it= fTemplates.iterator(); it.hasNext();) {
TemplatePersistenceData data= cast(TemplatePersistenceData) it.next();
Template template_= data.getTemplate();
if (data.isEnabled() && !data.isDeleted()
&& (contextTypeId is null || contextTypeId.equals(template_.getContextTypeId()))
&& name.equals(template_.getName()))
return template_;
}
return null;
}
/**
* Returns the first enabled template that matches the given template id.
*
* @param id the id of the template searched for
* @return the first enabled template that matches id, or <code>null</code> if none is found
* @since 3.1
*/
public Template findTemplateById(String id) {
TemplatePersistenceData data= getTemplateData(id);
if (data !is null && !data.isDeleted())
return data.getTemplate();
return null;
}
/**
* Returns all template data.
*
* @param includeDeleted whether to include deleted data
* @return all template data, whether enabled or not
*/
public TemplatePersistenceData[] getTemplateData(bool includeDeleted) {
List datas= new ArrayList();
for (Iterator it= fTemplates.iterator(); it.hasNext();) {
TemplatePersistenceData data= cast(TemplatePersistenceData) it.next();
if (includeDeleted || !data.isDeleted())
datas.add(data);
}
return arraycast!(TemplatePersistenceData)( datas.toArray());
}
/**
* Returns the template data of the template with id <code>id</code> or
* <code>null</code> if no such template can be found.
*
* @param id the id of the template data
* @return the template data of the template with id <code>id</code> or <code>null</code>
* @since 3.1
*/
public TemplatePersistenceData getTemplateData(String id) {
Assert.isNotNull(id);
for (Iterator it= fTemplates.iterator(); it.hasNext();) {
TemplatePersistenceData data= cast(TemplatePersistenceData) it.next();
if (id.equals(data.getId()))
return data;
}
return null;
}
private void loadCustomTemplates() {
String pref= fPreferenceStore.getString(fKey);
if (pref !is null && pref.trim().length() > 0) {
Reader input= new StringReader(pref);
TemplateReaderWriter reader= new TemplateReaderWriter();
TemplatePersistenceData[] datas= reader.read(input);
for (int i= 0; i < datas.length; i++) {
TemplatePersistenceData data= datas[i];
add(data);
}
}
}
/**
* Validates a template against the context type registered in the context
* type registry. Returns always <code>true</code> if no registry is
* present.
*
* @param template the template to validate
* @return <code>true</code> if validation is successful or no context
* type registry is specified, <code>false</code> if validation
* fails
*/
private bool validateTemplate(Template template_) {
String contextTypeId= template_.getContextTypeId();
if (contextExists(contextTypeId)) {
if (fRegistry !is null)
try {
fRegistry.getContextType(contextTypeId).validate(template_.getPattern());
} catch (TemplateException e) {
return false;
}
return true;
}
return false;
}
/**
* Returns <code>true</code> if a context type id specifies a valid context type
* or if no context type registry is present.
*
* @param contextTypeId the context type id to look for
* @return <code>true</code> if the context type specified by the id
* is present in the context type registry, or if no registry is
* specified
*/
private bool contextExists(String contextTypeId) {
return contextTypeId !is null && (fRegistry is null || fRegistry.getContextType(contextTypeId) !is null);
}
/**
* Returns the registry.
*
* @return Returns the registry
*/
protected final ContextTypeRegistry getRegistry() {
return fRegistry;
}
}
|
D
|
/+
REQUIRED_ARGS: -HC -c -o- -wi -extern-std=c++20
PERMUTE_ARGS:
TEST_OUTPUT:
---
compilable/dtoh_invalid_identifiers.d(103): Warning: function `register` is a keyword in C++
compilable/dtoh_invalid_identifiers.d(103): The generated C++ header will contain identifiers that are keywords in C++
compilable/dtoh_invalid_identifiers.d(105): Warning: namespace `const_cast` is a keyword in C++
compilable/dtoh_invalid_identifiers.d(116): Warning: function `and` is a special operator in C++
compilable/dtoh_invalid_identifiers.d(121): Warning: enum `mutable` is a keyword in C++
compilable/dtoh_invalid_identifiers.d(123): Warning: alias `char8_t` is a keyword in C++20
// Automatically generated by Digital Mars D Compiler
#pragma once
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <math.h>
#ifdef CUSTOM_D_ARRAY_TYPE
#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
#else
/// Represents a D [] array
template<typename T>
struct _d_dynamicArray final
{
size_t length;
T *ptr;
_d_dynamicArray() : length(0), ptr(NULL) { }
_d_dynamicArray(size_t length_in, T *ptr_in)
: length(length_in), ptr(ptr_in) { }
T& operator[](const size_t idx) {
assert(idx < length);
return ptr[idx];
}
const T& operator[](const size_t idx) const {
assert(idx < length);
return ptr[idx];
}
};
#endif
extern void register(int32_t* ptr);
namespace const_cast
{
extern void bar();
}
template <typename register_>
struct S final
{
// Ignoring var x alignment 0
register_ x;
S()
{
}
};
struct S2 final
{
int32_t register_;
void and();
S2() :
register_()
{
}
S2(int32_t register_) :
register_(register_)
{}
};
extern void f(int32_t alignas_);
enum class mutable
{
yes = 0,
no = 1,
};
typedef S<char > char8_t;
class Base
{
public:
virtual void foo();
};
template <typename typename_>
class Alias : public typename_
{
};
extern void user(Alias<Base* >* i);
template <typename typename_>
struct InvalidNames final
{
// Ignoring var register alignment 0
typename_ register_;
void foo(typename_ and_);
InvalidNames()
{
}
};
extern void useInvalid(InvalidNames<int32_t > _param_0);
---
+/
#line 100
extern(C++):
__gshared bool and;
void register(int* ptr) {}
extern(C++, const_cast)
void bar() {}
struct S(register)
{
register x;
}
struct S2
{
int register;
void and() {}
}
void f(int alignas) {}
enum mutable { yes, no }
alias char8_t = S!char;
class Base {
void foo() {}
}
class Alias(typename) : typename {}
void user(Alias!Base i) {}
struct InvalidNames(typename)
{
typename register;
void foo(typename and) {}
}
void useInvalid(InvalidNames!int) {}
|
D
|
module io.device.Array;
private import exception;
private import io.device.Conduit;
class Массив : Провод, БуферВвода, БуферВывода, ИПровод.ИШаг
{
private проц[] данные; // the необр данные буфер
private т_мера индекс; // current читай позиция
private т_мера протяженность; // предел of valid контент
private т_мера дименсия; // maximum протяженность of контент
private т_мера расширение; // for нарастает instances
protected static ткст перебор = "буфер вывода полон";
protected static ткст недобор = "буфер ввода пуст";
protected static ткст кфЧтен = "достигнут конец потока при чтении";
protected static ткст кфЗап = "достигнут конец потока при записи";
this (т_мера ёмкость = 0, т_мера нарастает = 0);
this (проц[] данные);
this (проц[] данные, т_мера читаемый);
final override ткст вТкст ();
final override т_мера читай (проц[] приёмн);
final override т_мера пиши (проц[] ист);
final override т_мера размерБуфера ();
override проц открепи ();
override дол сместись (дол смещение, Якорь якорь = Якорь.Нач);
Массив присвой (проц[] данные);
Массив присвой (проц[] данные, т_мера читаемый);
final проц[] присвой ();
final проц[] opSlice (т_мера старт, т_мера конец);
final проц[] срез ();
final проц[] срез (т_мера размер, бул съешь = да);
final Массив добавь (проц[] ист);
final бул следщ (т_мера delegate (проц[]) скан);
final т_мера читаемый ();
final т_мера записываемый ();
final т_мера предел ();
final т_мера ёмкость ();
final т_мера позиция ();
final Массив очисть ();
final override Массив слей ();
final т_мера писатель (т_мера delegate (проц[]) дг);
final т_мера читатель (т_мера delegate (проц[]) дг);
}
|
D
|
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;
void get(Args...)(ref Args args)
{
import std.traits, std.meta, std.typecons;
static if (Args.length == 1) {
alias Arg = Args[0];
static if (isArray!Arg) {
static if (isSomeChar!(ElementType!Arg)) {
args[0] = readln.chomp.to!Arg;
} else {
args[0] = readln.split.to!Arg;
}
} else static if (isTuple!Arg) {
auto input = readln.split;
static foreach (i; 0..Fields!Arg.length) {
args[0][i] = input[i].to!(Fields!Arg[i]);
}
} else {
args[0] = readln.chomp.to!Arg;
}
} else {
auto input = readln.split;
assert(input.length == Args.length);
static foreach (i; 0..Args.length) {
args[i] = input[i].to!(Args[i]);
}
}
}
void get_lines(Args...)(size_t N, ref Args args)
{
import std.traits, std.range;
static foreach (i; 0..Args.length) {
static assert(isArray!(Args[i]));
args[i].length = N;
}
foreach (i; 0..N) {
static if (Args.length == 1) {
get(args[0][i]);
} else {
auto input = readln.split;
static foreach (j; 0..Args.length) {
args[j][i] = input[j].to!(ElementType!(Args[j]));
}
}
}
}
void main()
{
long A, B; get(A, B);
switch (B % 4) {
case 0: return writeln("Devil");
case 1:
case 2: return writeln("Angel");
default: writeln(A % 2 == 0 ? "Devil" : "Angel");
}
}
/*
0
0 1 2 3 4 5 6 7 8 9 | B
0 D A A D D A A D D A
1 D A A A D A A A D A
2 D A A D D A A D D A
3 D A A A D A A A D A
4 D A A D D A A D D A
5 D A A A D A A A D A
6 D A A D D A A D D A
7 D A A A D A A A D A
8 D A A D D A A D D A
9 D A A A D A A A D A
-
A
1
0 1 2 3 4 5 6 7 8 9 | B
0 A D D A A D D A A D
1 A A D A A A D
2 A D D A A D D
3 A A D A A A D
4 A D D A A D D
5 A A D A A A D
6 A D D A A D D
7 A A D A A A D
8 A D D A A D D
9 A A D A A A D
-
A
*/
|
D
|
module xf.mem.ChunkCache;
private {
import xf.mem.Chunk;
import xf.mem.Common;
import xf.mem.Log;
import tango.text.convert.Format;
//import Trace = tango.core.tools.StackTrace;
import tango.core.Thread;
static import tango.core.Exception;
}
/**
ChunkCache allows the caching and on-demand allocation of memory chunks.
The actual allocation is delegated to the allocator specified as a template alias parameter
the parameter will usually be a symbol of a thread-local or global allocator instance.
*/
private struct ChunkCache(int _pageSize, alias _allocator) {
static assert ((_pageSize + _allocator.maxChunkOverhead) % minDefaultPageSize == 0);
const size_t maxChunkOverhead = _allocator.maxChunkOverhead;
static assert (implementsChunkAllocator!(ChunkCache));
private {
struct CachedChunk {
Chunk* chunk;
CachedChunk* next;
}
CachedChunk* next;
int _totalAllocated = 0;
}
Chunk* alloc(size_t size = 0) {
if (size > _pageSize) {
throw new Exception(Format(
"The ChunkCache cannot allocate more data ({}) than it was statically parametrized for ({})",
size,
_pageSize
));
}
if (auto res = next) {
next = res.next;
return res.chunk;
} else {
++_totalAllocated;
/+if (Thread.getThis()) {
auto tr = Trace.basicTracer(null);
char[] msg;
tr.writeOut((char[] s) { msg ~= s; });
memLog.trace(
"ChunkCache: allocating a new chunk ({}). At:\n{}",
_totalAllocated,
msg
);
delete tr;
} else {
memLog.trace(
"ChunkCache: allocating a new chunk ({}) in foreign thread.",
_totalAllocated
);
}+/
auto raw = _allocator.allocRaw(_pageSize);
auto res = cast(Chunk*)(alignPointerUp(raw.ptr + Chunk.sizeof, defaultAllocationAlignment) - Chunk.sizeof);
res._size = raw.size - (res.ptr() - raw.ptr);
res._dispose = &free;
res._reserved = cast(size_t)raw.ptr;
return res;
}
}
void free(Chunk* chunk) {
assert (chunk !is null);
auto cchunk = cast(CachedChunk*)chunk.ptr;
cchunk.chunk = chunk;
cchunk.next = this.next;
this.next = cchunk;
}
}
template chunkCache(int _pageSize, alias allocator) {
__thread ChunkCache!(_pageSize, allocator) chunkCache;
}
|
D
|
module minima.world.messagehandling;
import minima.world;
import minima.world.log;
import data = minima.world.data;
import comm = minima.world.comm;
import videocomm = minima.video.comm;
import minima.intercomm.videoworld;
import minima.intercomm.mainworld;
import minima.core.biarray;
void handleMessage(comm.Receive message)
{
if (message !is null)
{
if (cast(immutable MainToWorld.Quit) message)
{
debug (world_process_MtwQuit)
{
log("Received MtwQuit");
}
data.mustQuit = true;
}
else if (auto viewRequest = cast(immutable VideoToWorld.RequestView) message)
{
respondToViewRequest(viewRequest);
}
else
{
assert(false, makeLog("Received unhandled message."));
}
}
}
void respondToViewRequest(immutable VideoToWorld.RequestView viewRequest)
{
import std.algorithm;
import std.range;
import minima.math.arrayindex;
import minima.geometry.box;
import std.conv;
import minima.world.physics;
auto numberOfRows = viewRequest.numberOfRows;
auto rowRange = iota(numberOfRows);
auto numberOfColumns = viewRequest.numberOfColumns;
auto columnRange = iota(numberOfColumns);
auto requestId = viewRequest.id;
Biarray!string blockNames = Biarray!string(numberOfRows, numberOfColumns, "");
foreach (row; rowRange)
foreach (column; columnRange)
blockNames[row, column] = data.world.terrain.solidAt(column, row) ? "something" : "none";
Box[] boxes = [data.world.player.box];
string debugMessage = text("Player on ground? ", data.world.player.onGround ? " yes" : " no");
import std.stdio;
writeln(debugMessage);
debug boxes ~= data.world.player.box.collidingBox;
auto response = new immutable WorldToVideo.ResponseView(blockNames,
viewRequest.lowerRow, viewRequest.higherRow,
viewRequest.lowerColumn, viewRequest.higherColumn, requestId, boxes);
debug (world_respondToViewRequest)
log("Sent response view");
videocomm.send(response);
}
|
D
|
module android.java.java.io.FileReader_d_interface;
import arsd.jni : IJavaObjectImplementation, JavaPackageId, JavaName, IJavaObject, ImportExportImpl, JavaInterfaceMembers;
static import arsd.jni;
import import2 = android.java.java.nio.CharBuffer_d_interface;
import import1 = android.java.java.io.FileDescriptor_d_interface;
import import3 = android.java.java.lang.Class_d_interface;
import import0 = android.java.java.io.File_d_interface;
final class FileReader : IJavaObject {
static immutable string[] _d_canCastTo = [
];
@Import this(string);
@Import this(import0.File);
@Import this(import1.FileDescriptor);
@Import string getEncoding();
@Import int read();
@Import int read(wchar, int, int[]);
@Import bool ready();
@Import void close();
@Import int read(import2.CharBuffer);
@Import int read(wchar[]);
@Import long skip(long);
@Import bool markSupported();
@Import void mark(int);
@Import void reset();
@Import import3.Class getClass();
@Import int hashCode();
@Import bool equals(IJavaObject);
@Import @JavaName("toString") string toString_();
override string toString() { return arsd.jni.javaObjectToString(this); }
@Import void notify();
@Import void notifyAll();
@Import void wait(long);
@Import void wait(long, int);
@Import void wait();
mixin IJavaObjectImplementation!(false);
public static immutable string _javaParameterString = "Ljava/io/FileReader;";
}
|
D
|
//Written in the D programming language
/++
Module containing Date/Time functionality.
This module provides:
$(UL
$(LI Types to represent points in time: $(LREF SysTime), $(LREF Date),
$(LREF TimeOfDay), and $(LREF2 .DateTime, 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 $(LREF SysTime)).)
$(LI A platform-independent, high precision stopwatch type:
$(LREF 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
$(LREF Date) (if they want dates but don't care about time), $(LREF DateTime)
(if they want dates and times but don't care about time zones), $(LREF 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).
$(LREF Date) and $(LREF DateTime) are optimized for calendar-based operations,
while $(LREF SysTime) is designed for dealing with time from the OS. Check out
their specific documentation for more details.
To get the current time, use $(LREF2 .Clock.currTime, Clock.currTime).
It will return the current
time as a $(LREF 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 fromSimpleString) to create a
$(LREF 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:
$(LREF DateTimeException) is an alias for $(CXREF time, 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 $(CXREF time, TimeException) or
$(LREF 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)
Macros:
LREF2=<a href="#$1">$(D $2)</a>
+/
module std.datetime;
public import core.time;
import core.exception;
import core.stdc.time;
import std.exception;
import std.range.primitives;
import std.traits;
// FIXME
import std.functional; //: unaryFun;
version(Windows)
{
import core.sys.windows.windows;
import core.sys.windows.winsock2;
import std.windows.registry;
}
else version(Posix)
{
import core.sys.posix.stdlib;
import core.sys.posix.sys.time;
}
version(unittest)
{
import std.stdio;
}
unittest
{
initializeTests();
}
//Verify module example.
unittest
{
auto currentTime = Clock.currTime();
auto timeString = currentTime.toISOExtString();
auto restoredTime = SysTime.fromISOExtString(timeString);
}
//Verify Examples for core.time.Duration which couldn't be in core.time.
unittest
{
assert(std.datetime.Date(2010, 9, 7) + dur!"days"(5) ==
std.datetime.Date(2010, 9, 12));
assert(std.datetime.Date(2010, 9, 7) - std.datetime.Date(2010, 10, 3) ==
dur!"days"(-26));
}
//==============================================================================
// 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 $(LREF2 .Interval, Interval)'s
$(LREF expand, 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 other types.
//==============================================================================
/++
Exception type used by std.datetime. It's an alias to $(CXREF time, TimeException).
Either can be caught without concern about which
module it came from.
+/
alias DateTimeException = TimeException;
/++
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.
Params:
clockType = The $(CXREF time, ClockType) indicates which system
clock to use to get the current time. Very few programs
need to use anything other than the default.
tz = The time zone for the SysTime that's returned.
Throws:
$(LREF DateTimeException) if it fails to get the time.
+/
static SysTime currTime(ClockType clockType = ClockType.normal)(immutable TimeZone tz = LocalTime()) @safe
{
return SysTime(currStdTime!clockType, tz);
}
unittest
{
import std.format : format;
assert(currTime().timezone is LocalTime());
assert(currTime(UTC()).timezone is UTC());
// core.stdc.time.time does not always use unix time on Windows systems.
// In particular, dmc does not use unix time. If we can guarantee that
// the MS runtime uses unix time, then we may be able run this test
// then, but for now, we're just not going to run this test on Windows.
version(Posix)
{
static import std.math;
immutable unixTimeD = currTime().toUnixTime();
immutable unixTimeC = core.stdc.time.time(null);
assert(std.math.abs(unixTimeC - unixTimeD) <= 2);
}
auto norm1 = Clock.currTime;
auto norm2 = Clock.currTime(UTC());
assert(norm1 <= norm2, format("%s %s", norm1, norm2));
assert(abs(norm1 - norm2) <= seconds(2));
import std.typetuple;
foreach(ct; TypeTuple!(ClockType.coarse, ClockType.precise, ClockType.second))
{
scope(failure) writefln("ClockType.%s", ct);
auto value1 = Clock.currTime!ct;
auto value2 = Clock.currTime!ct(UTC());
assert(value1 <= value2, format("%s %s", value1, value2));
assert(abs(value1 - value2) <= seconds(2));
}
}
/++
Returns the number of hnsecs since midnight, January 1st, 1 A.D. for the
current time.
Params:
clockType = The $(CXREF time, ClockType) indicates which system
clock to use to get the current time. Very few programs
need to use anything other than the default.
Throws:
$(LREF DateTimeException) if it fails to get the time.
+/
static @property long currStdTime(ClockType clockType = ClockType.normal)() @trusted
{
static if(clockType != ClockType.coarse &&
clockType != ClockType.normal &&
clockType != ClockType.precise &&
clockType != ClockType.second)
{
import std.format : format;
static assert(0, format("ClockType.%s is not supported by Clock.currTime or Clock.currStdTime", clockType));
}
version(Windows)
{
FILETIME fileTime;
GetSystemTimeAsFileTime(&fileTime);
immutable result = FILETIMEToStdTime(&fileTime);
static if(clockType == ClockType.second)
{
// Ideally, this would use core.std.time.time, but the C runtime
// has to be using unix time for that to work, and that's not
// guaranteed on Windows. Digital Mars does not use unix time.
// MS may or may not. If it does, then this can be made to use
// core.stdc.time for MS, but for now, we'll leave it like this.
return convert!("seconds", "hnsecs")(convert!("hnsecs", "seconds")(result));
}
else
return result;
}
else version(Posix)
{
enum hnsecsToUnixEpoch = unixTimeToStdTime(0);
version(OSX)
{
static if(clockType == ClockType.second)
return unixTimeToStdTime(core.stdc.time.time(null));
else
{
timeval tv;
if(gettimeofday(&tv, null) != 0)
throw new TimeException("Call to gettimeofday() failed");
return convert!("seconds", "hnsecs")(tv.tv_sec) +
convert!("usecs", "hnsecs")(tv.tv_usec) +
hnsecsToUnixEpoch;
}
}
else version(linux)
{
static if(clockType == ClockType.second)
return unixTimeToStdTime(core.stdc.time.time(null));
else
{
import core.sys.linux.time;
static if(clockType == ClockType.coarse) alias clockArg = CLOCK_REALTIME_COARSE;
else static if(clockType == ClockType.normal) alias clockArg = CLOCK_REALTIME;
else static if(clockType == ClockType.precise) alias clockArg = CLOCK_REALTIME;
else static assert(0, "Previous static if is wrong.");
timespec ts;
if(clock_gettime(clockArg, &ts) != 0)
throw new TimeException("Call to clock_gettime() failed");
return convert!("seconds", "hnsecs")(ts.tv_sec) +
ts.tv_nsec / 100 +
hnsecsToUnixEpoch;
}
}
else version(FreeBSD)
{
import core.sys.freebsd.time;
static if(clockType == ClockType.coarse) alias clockArg = CLOCK_REALTIME_FAST;
else static if(clockType == ClockType.normal) alias clockArg = CLOCK_REALTIME;
else static if(clockType == ClockType.precise) alias clockArg = CLOCK_REALTIME_PRECISE;
else static if(clockType == ClockType.second) alias clockArg = CLOCK_SECOND;
else static assert(0, "Previous static if is wrong.");
timespec ts;
if(clock_gettime(clockArg, &ts) != 0)
throw new TimeException("Call to clock_gettime() failed");
return convert!("seconds", "hnsecs")(ts.tv_sec) +
ts.tv_nsec / 100 +
hnsecsToUnixEpoch;
}
else static assert(0, "Unsupported OS");
}
else static assert(0, "Unsupported OS");
}
unittest
{
import std.math : abs;
import std.format : format;
enum limit = convert!("seconds", "hnsecs")(2);
auto norm1 = Clock.currStdTime;
auto norm2 = Clock.currStdTime;
assert(norm1 <= norm2, format("%s %s", norm1, norm2));
assert(abs(norm1 - norm2) <= limit);
import std.typetuple;
foreach(ct; TypeTuple!(ClockType.coarse, ClockType.precise, ClockType.second))
{
scope(failure) writefln("ClockType.%s", ct);
auto value1 = Clock.currStdTime!ct;
auto value2 = Clock.currStdTime!ct;
assert(value1 <= value2, format("%s %s", value1, value2));
assert(abs(value1 - value2) <= limit);
}
}
/++
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:
$(LREF DateTimeException) if it fails to get the time.
+/
static @property TickDuration currSystemTick() @safe nothrow
{
return TickDuration.currSystemTick;
}
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:
$(LREF DateTimeException) if it fails to get the time.
+/
static @property TickDuration currAppTick() @safe
{
return currSystemTick - TickDuration.appOrigin;
}
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
$(LREF 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
$(LREF 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 $(LREF DateTime) would be the type to
use. For system time, use $(D SysTime).
$(LREF2 .Clock.currTime, Clock.currTime) will return the current time as a $(D SysTime).
To convert a $(D SysTime) to a $(LREF Date) or $(LREF DateTime), simply cast
it. To convert a $(LREF Date) or $(LREF 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 $(LREF2 .TimeZone, TimeZone), and the local
time zone will be used). Be aware, however, that converting from a
$(LREF 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
$(LREF PosixTimeZone) on Posix systems (or on Windows, if providing the TZ
Database files), and use $(LREF 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). $(LREF LocalTime) is the $(LREF2 .TimeZone, TimeZone) class
which represents the local time, and $(D UTC) is the $(LREF2 .TimeZone, TimeZone) class
which represents UTC. $(D SysTime) uses $(LREF LocalTime) if no $(LREF2 .TimeZone, TimeZone)
is provided. For more details on time zones, see the documentation for
$(LREF2 .TimeZone, TimeZone), $(LREF PosixTimeZone), and $(LREF WindowsTimeZone).
$(D SysTime)'s range is from approximately 29,000 B.C. to approximately
29,000 A.D.
+/
struct SysTime
{
import std.typecons : Rebindable;
public:
/++
Params:
dateTime = The $(LREF DateTime) to use to set this $(LREF SysTime)'s
internal std time. As $(LREF DateTime) has no concept of
time zone, tz is used as its time zone.
tz = The $(LREF2 .TimeZone, TimeZone) to use for this $(LREF SysTime). If null,
$(LREF LocalTime) will be used. The given $(LREF DateTime) is
assumed to be in the given time zone.
+/
this(in DateTime dateTime, immutable TimeZone tz = null) @safe nothrow
{
try
this(dateTime, Duration.zero, tz);
catch(Exception e)
assert(0, "SysTime's constructor threw when it shouldn't have.");
}
unittest
{
import std.format : format;
static void test(DateTime dt, immutable TimeZone tz, long expected)
{
auto sysTime = SysTime(dt, tz);
assert(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 immutable SimpleTimeZone(dur!"minutes"(-60)), 36_000_000_000L);
test(DateTime(1, 1, 1, 0, 0, 0), new immutable SimpleTimeZone(Duration.zero), 0);
test(DateTime(1, 1, 1, 0, 0, 0), new immutable SimpleTimeZone(dur!"minutes"(60)), -36_000_000_000L);
}
/++
Params:
dateTime = The $(LREF DateTime) to use to set this $(LREF SysTime)'s
internal std time. As $(LREF DateTime) has no concept of
time zone, tz is used as its time zone.
fracSecs = The fractional seconds portion of the time.
tz = The $(LREF2 .TimeZone, TimeZone) to use for this $(LREF SysTime). If null,
$(LREF LocalTime) will be used. The given $(LREF DateTime) is
assumed to be in the given time zone.
Throws:
$(LREF DateTimeException) if $(D fracSecs) is negative or if it's
greater than or equal to one second.
+/
this(in DateTime dateTime, in Duration fracSecs, immutable TimeZone tz = null) @safe
{
enforce(fracSecs >= Duration.zero, new DateTimeException("A SysTime cannot have negative fractional seconds."));
enforce(fracSecs < seconds(1), new DateTimeException("Fractional seconds must be less than one second."));
auto nonNullTZ = tz is null ? LocalTime() : tz;
immutable dateDiff = dateTime.date - Date.init;
immutable todDiff = dateTime.timeOfDay - TimeOfDay.init;
immutable adjustedTime = dateDiff + todDiff + fracSecs;
immutable standardTime = nonNullTZ.tzToUTC(adjustedTime.total!"hnsecs");
this(standardTime, nonNullTZ);
}
unittest
{
import std.format : format;
static void test(DateTime dt, Duration fracSecs, immutable TimeZone tz, long expected)
{
auto sysTime = SysTime(dt, fracSecs, tz);
assert(sysTime._stdTime == expected);
assert(sysTime._timezone is (tz is null ? LocalTime() : tz),
format("Given DateTime: %s, Given Duration: %s", dt, fracSecs));
}
test(DateTime.init, Duration.zero, UTC(), 0);
test(DateTime(1, 1, 1, 12, 30, 33), Duration.zero, UTC(), 450_330_000_000L);
test(DateTime(0, 12, 31, 12, 30, 33), Duration.zero, UTC(), -413_670_000_000L);
test(DateTime(1, 1, 1, 0, 0, 0), msecs(1), UTC(), 10_000L);
test(DateTime(0, 12, 31, 23, 59, 59), msecs(999), UTC(), -10_000L);
test(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999), UTC(), -1);
test(DateTime(0, 12, 31, 23, 59, 59), hnsecs(1), UTC(), -9_999_999);
test(DateTime(0, 12, 31, 23, 59, 59), Duration.zero, UTC(), -10_000_000);
assertThrown!DateTimeException(SysTime(DateTime.init, hnsecs(-1), UTC()));
assertThrown!DateTimeException(SysTime(DateTime.init, seconds(1), UTC()));
}
/++
$(RED Scheduled for deprecation. Please use the overload which takes a
$(CXREF time, Duration) for the fractional seconds. This overload
will be deprecated in 2.068).
Params:
dateTime = The $(LREF DateTime) to use to set this $(LREF SysTime)'s
internal std time. As $(LREF DateTime) has no concept of
time zone, tz is used as its time zone.
fracSec = The fractional seconds portion of the time.
tz = The $(LREF2 .TimeZone, TimeZone) to use for this $(LREF SysTime). If null,
$(LREF LocalTime) will be used. The given $(LREF DateTime) is
assumed to be in the given time zone.
Throws:
$(LREF DateTimeException) if $(D fracSec) is negative.
+/
//deprecated("Please use the overload which takes a Duration instead of a FracSec.")
this(in DateTime dateTime, in FracSec fracSec, immutable TimeZone tz = null) @safe
{
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.");
}
/+deprecated+/ unittest
{
import std.format : format;
static void test(DateTime dt,
FracSec fracSec,
immutable TimeZone tz,
long expected)
{
auto sysTime = SysTime(dt, fracSec, tz);
assert(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 $(LREF Date) to use to set this $(LREF SysTime)'s internal std
time. As $(LREF Date) has no concept of time zone, tz is used as
its time zone.
tz = The $(LREF2 .TimeZone, TimeZone) to use for this $(LREF SysTime). If null,
$(LREF LocalTime) will be used. The given $(LREF Date) is assumed
to be in the given time zone.
+/
this(in Date date, immutable TimeZone tz = null) @safe 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.");
}
unittest
{
static void test(Date d, immutable TimeZone tz, long expected)
{
import std.format : format;
auto sysTime = SysTime(d, tz);
assert(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 $(LREF2 .TimeZone, TimeZone) to use for this $(LREF SysTime). If null,
$(LREF LocalTime) will be used.
+/
this(long stdTime, immutable TimeZone tz = null) @safe pure nothrow
{
_stdTime = stdTime;
_timezone = tz is null ? LocalTime() : tz;
}
unittest
{
static void test(long stdTime, immutable TimeZone tz)
{
import std.format : format;
auto sysTime = SysTime(stdTime, tz);
assert(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 $(LREF SysTime) to assign to this one.
+/
ref SysTime opAssign(const ref SysTime rhs) return @safe pure nothrow
{
_stdTime = rhs._stdTime;
_timezone = rhs._timezone;
return this;
}
/++
Params:
rhs = The $(LREF SysTime) to assign to this one.
+/
ref SysTime opAssign(SysTime rhs) return @safe pure nothrow
{
_stdTime = rhs._stdTime;
_timezone = rhs._timezone;
return this;
}
/++
Checks for equality between this $(LREF SysTime) and the given
$(LREF SysTime).
Note that the time zone is ignored. Only the internal
std times (which are in UTC) are compared.
+/
bool opEquals(const SysTime rhs) @safe const pure nothrow
{
return opEquals(rhs);
}
/// ditto
bool opEquals(const ref SysTime rhs) @safe const pure nothrow
{
return _stdTime == rhs._stdTime;
}
unittest
{
import std.range;
assert(SysTime(DateTime.init, UTC()) == SysTime(0, UTC()));
assert(SysTime(DateTime.init, UTC()) == SysTime(0));
assert(SysTime(Date.init, UTC()) == SysTime(0));
assert(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;
assert(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 $(LREF SysTime) with the given $(LREF SysTime).
Time zone is irrelevant when comparing $(LREF 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) @safe const pure nothrow
{
if(_stdTime < rhs._stdTime)
return -1;
if(_stdTime > rhs._stdTime)
return 1;
return 0;
}
unittest
{
import std.range;
assert(SysTime(DateTime.init, UTC()).opCmp(SysTime(0, UTC())) == 0);
assert(SysTime(DateTime.init, UTC()).opCmp(SysTime(0)) == 0);
assert(SysTime(Date.init, UTC()).opCmp(SysTime(0)) == 0);
assert(SysTime(0).opCmp(SysTime(0)) == 0);
static void testEqual(SysTime st,
immutable TimeZone tz1,
immutable TimeZone tz2)
{
auto st1 = st;
st1.timezone = tz1;
auto st2 = st;
st2.timezone = tz2;
assert(st1.opCmp(st2) == 0);
}
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;
assert(st1.opCmp(st2) < 0);
assert(st2.opCmp(st1) > 0);
}
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() @safe const nothrow
{
return (cast(Date)this).year;
}
unittest
{
import std.range;
static void test(SysTime sysTime, long expected)
{
import std.format : format;
assert(sysTime.year == expected,
format("Value given: %s", sysTime));
}
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 $(LREF SysTime)'s year to.
Throws:
$(LREF DateTimeException) if the new year is not a leap year and the
resulting date would be on February 29th.
+/
@property void year(int year) @safe
{
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;
}
///
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);
}
unittest
{
import std.range;
static void test(SysTime st, int year, in SysTime expected)
{
st.year = year;
assert(st == expected);
}
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.fracSecs,
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:
$(LREF DateTimeException) if $(D isAD) is true.
+/
@property ushort yearBC() @safe const
{
return (cast(Date)this).yearBC;
}
///
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);
}
unittest
{
import std.format : format;
foreach(st; testSysTimesBC)
{
auto msg = format("SysTime: %s", st);
assertNotThrown!DateTimeException(st.yearBC, msg);
assert(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 $(LREF SysTime)'s year to.
Throws:
$(LREF DateTimeException) if a non-positive value is given.
+/
@property void yearBC(int year) @safe
{
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;
}
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)));
}
unittest
{
import std.range;
static void test(SysTime st, int year, in SysTime expected)
{
import std.format : format;
st.yearBC = year;
assert(st == expected, format("SysTime: %s", st));
}
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.fracSecs,
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.
+/
@property Month month() @safe const nothrow
{
return (cast(Date)this).month;
}
///
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);
}
unittest
{
import std.range;
static void test(SysTime sysTime, Month expected)
{
import std.format : format;
assert(sysTime.month == expected,
format("Value given: %s", sysTime));
}
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 $(LREF SysTime)'s month to.
Throws:
$(LREF DateTimeException) if the given month is not a valid month.
+/
@property void month(Month month) @safe
{
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;
}
unittest
{
import std.range;
static void test(SysTime st, Month month, in SysTime expected)
{
st.month = cast(Month)month;
assert(st == expected);
}
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.fracSecs,
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.
+/
@property ubyte day() @safe const nothrow
{
return (cast(Date)this).day;
}
///
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);
}
unittest
{
import std.range;
static void test(SysTime sysTime, int expected)
{
import std.format : format;
assert(sysTime.day == expected,
format("Value given: %s", sysTime));
}
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 $(LREF SysTime)'s day to.
Throws:
$(LREF DateTimeException) if the given day is not a valid day of the
current month.
+/
@property void day(int day) @safe
{
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;
}
unittest
{
import std.format : format;
import std.range;
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.fracSecs,
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() @safe 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);
}
unittest
{
import std.range;
import std.format : format;
static void test(SysTime sysTime, int expected)
{
assert(sysTime.hour == expected,
format("Value given: %s", sysTime));
}
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 $(LREF SysTime)'s hour to.
Throws:
$(LREF DateTimeException) if the given hour are not a valid hour of
the day.
+/
@property void hour(int hour) @safe
{
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;
}
unittest
{
import std.range;
import std.format : format;
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.fracSecs,
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() @safe 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);
}
unittest
{
import std.range;
import std.format : format;
static void test(SysTime sysTime, int expected)
{
assert(sysTime.minute == expected,
format("Value given: %s", sysTime));
}
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:
minute = The minute to set this $(LREF SysTime)'s minute to.
Throws:
$(LREF DateTimeException) if the given minute are not a valid minute
of an hour.
+/
@property void minute(int minute) @safe
{
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;
}
unittest
{
import std.range;
import std.format : format;
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.fracSecs,
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() @safe 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);
}
unittest
{
import std.range;
import std.format : format;
static void test(SysTime sysTime, int expected)
{
assert(sysTime.second == expected,
format("Value given: %s", sysTime));
}
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 $(LREF SysTime)'s second to.
Throws:
$(LREF DateTimeException) if the given second are not a valid second
of a minute.
+/
@property void second(int second) @safe
{
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;
}
unittest
{
import std.range;
import std.format : format;
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.fracSecs,
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 past the second (i.e. the portion of a
$(LREF SysTime) which is less than a second).
+/
@property Duration fracSecs() @safe const nothrow
{
auto hnsecs = removeUnitsFromHNSecs!"days"(adjTime);
if(hnsecs < 0)
hnsecs += convert!("hours", "hnsecs")(24);
return dur!"hnsecs"(removeUnitsFromHNSecs!"seconds"(hnsecs));
}
///
unittest
{
auto dt = DateTime(1982, 4, 1, 20, 59, 22);
assert(SysTime(dt, msecs(213)).fracSecs == msecs(213));
assert(SysTime(dt, usecs(5202)).fracSecs == usecs(5202));
assert(SysTime(dt, hnsecs(1234567)).fracSecs == hnsecs(1234567));
// SysTime and Duration both have a precision of hnsecs (100 ns),
// so nsecs are going to be truncated.
assert(SysTime(dt, nsecs(123456789)).fracSecs == nsecs(123456700));
}
unittest
{
import std.range;
assert(SysTime(0, UTC()).fracSecs == Duration.zero);
assert(SysTime(1, UTC()).fracSecs == hnsecs(1));
assert(SysTime(-1, UTC()).fracSecs == 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)
assert(SysTime(dt, fs, tz).fracSecs == 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.fracSecs));
//static assert(__traits(compiles, ist.fracSecs));
}
/++
Fractional seconds past the second (i.e. the portion of a
$(LREF SysTime) which is less than a second).
Params:
fracSecs = The duration to set this $(LREF SysTime)'s fractional
seconds to.
Throws:
$(LREF DateTimeException) if the given duration is negative or if
it's greater than or equal to one second.
+/
@property void fracSecs(Duration fracSecs) @safe
{
enforce(fracSecs >= Duration.zero, new DateTimeException("A SysTime cannot have negative fractional seconds."));
enforce(fracSecs < seconds(1), new DateTimeException("Fractional seconds must be less than one second."));
auto oldHNSecs = adjTime;
auto days = splitUnitsFromHNSecs!"days"(oldHNSecs);
immutable daysHNSecs = convert!("days", "hnsecs")(days);
immutable negative = oldHNSecs < 0;
if(negative)
oldHNSecs += convert!("hours", "hnsecs")(24);
immutable seconds = splitUnitsFromHNSecs!"seconds"(oldHNSecs);
immutable secondsHNSecs = convert!("seconds", "hnsecs")(seconds);
auto newHNSecs = fracSecs.total!"hnsecs" + secondsHNSecs;
if(negative)
newHNSecs -= convert!("hours", "hnsecs")(24);
adjTime = daysHNSecs + newHNSecs;
}
///
unittest
{
auto st = SysTime(DateTime(1982, 4, 1, 20, 59, 22));
assert(st.fracSecs == Duration.zero);
st.fracSecs = msecs(213);
assert(st.fracSecs == msecs(213));
st.fracSecs = hnsecs(1234567);
assert(st.fracSecs == hnsecs(1234567));
// SysTime has a precision of hnsecs (100 ns), so nsecs are
// going to be truncated.
st.fracSecs = nsecs(123456789);
assert(st.fracSecs == hnsecs(1234567));
}
unittest
{
import std.range;
import std.format : format;
foreach(fracSec; testFracSecs)
{
foreach(st; chain(testSysTimesBC, testSysTimesAD))
{
auto dt = cast(DateTime)st;
auto expected = SysTime(dt, fracSec, st.timezone);
st.fracSecs = fracSec;
assert(st == expected, format("[%s] [%s]", st, expected));
}
}
auto st = testSysTimesAD[0];
assertThrown!DateTimeException(st.fracSecs = hnsecs(-1));
assertThrown!DateTimeException(st.fracSecs = seconds(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.fracSecs = msecs(7)));
//static assert(!__traits(compiles, ist.fracSecs = msecs(7)));
}
/++
$(RED Scheduled for deprecation. Please use $(LREF fracSecs) instead of
fracSec. It uses a $(CXREF time, Duration) to represent the
fractional seconds instead of a $(CXREF time, FracSec). This
overload will be deprecated in 2.068).
Fractional seconds past the second.
+/
//deprecated("Please use fracSecs (with an s) rather than fracSec (without an s). It returns a Duration instead of a FracSec, as FracSec is being deprecated.")
@property FracSec fracSec() @safe 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.");
}
/+deprecated+/ unittest
{
import std.range;
import std.format : format;
static void test(SysTime sysTime, FracSec expected, size_t line = __LINE__)
{
if(sysTime.fracSec != expected)
throw new AssertError(format("Value given: %s", sysTime.fracSec), __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), FracSec.from!"hnsecs"(fs.total!"hnsecs"));
}
}
}
}
}
}
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));
}
/++
$(RED Scheduled for deprecation. Please use $(LREF fracSecs) instead of
fracSec. It uses a $(CXREF time, Duration) to represent the
fractional seconds instead of a $(CXREF time, FracSec). This
overload will be deprecated in 2.068).
Fractional seconds past the second.
Params:
fracSec = The fractional seconds to set this $(LREF SysTime)'s
fractional seconds to.
Throws:
$(LREF DateTimeException) if $(D fracSec) is negative.
+/
//deprecated("Please use fracSecs (with an s) rather than fracSec (without an s). It takes a Duration instead of a FracSec, as FracSec is being deprecated.")
@property void fracSec(FracSec fracSec) @safe
{
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;
}
/+deprecated+/ unittest
{
import std.range;
import std.format : format;
foreach(fracSec; testFracSecs)
{
foreach(st; chain(testSysTimesBC, testSysTimesAD))
{
auto dt = cast(DateTime)st;
auto expected = SysTime(dt, fracSec, st.timezone);
st.fracSec = FracSec.from!"hnsecs"(fracSec.total!"hnsecs");
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 $(LREF SysTime).
+/
@property long stdTime() @safe const pure nothrow
{
return _stdTime;
}
unittest
{
assert(SysTime(0).stdTime == 0);
assert(SysTime(1).stdTime == 1);
assert(SysTime(-1).stdTime == -1);
assert(SysTime(DateTime(1, 1, 1, 0, 0, 33), hnsecs(502), UTC()).stdTime == 330000502L);
assert(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 $(LREF SysTime).
Params:
stdTime = The number of hnsecs since January 1st, 1 A.D. UTC.
+/
@property void stdTime(long stdTime) @safe pure nothrow
{
_stdTime = stdTime;
}
unittest
{
static void test(long stdTime, in SysTime expected, size_t line = __LINE__)
{
auto st = SysTime(0, UTC());
st.stdTime = stdTime;
assert(st == expected);
}
test(0, SysTime(Date(1, 1, 1), UTC()));
test(1, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(1), UTC()));
test(-1, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999), UTC()));
test(330_000_502L, SysTime(DateTime(1, 1, 1, 0, 0, 33), 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 $(LREF 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 $(LREF SysTime)'s time zone before returning.
+/
@property immutable(TimeZone) timezone() @safe const pure nothrow
{
return _timezone;
}
/++
The current time zone of this $(LREF 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 $(LREF SysTime)'s time zone before returning.
Params:
timezone = The $(LREF2 .TimeZone, TimeZone) to set this $(LREF SysTime)'s time zone to.
+/
@property void timezone(immutable TimeZone timezone) @safe pure nothrow
{
if(timezone is null)
_timezone = LocalTime();
else
_timezone = timezone;
}
/++
Returns whether DST is in effect for this $(LREF SysTime).
+/
@property bool dstInEffect() @safe 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 $(LREF SysTime).
It includes the DST offset in effect at that time (if any).
+/
@property Duration utcOffset() @safe const nothrow
{
return _timezone.utcOffsetAt(_stdTime);
}
/++
Returns a $(LREF SysTime) with the same std time as this one, but with
$(LREF LocalTime) as its time zone.
+/
SysTime toLocalTime() @safe const pure nothrow
{
return SysTime(_stdTime, LocalTime());
}
unittest
{
{
auto sysTime = SysTime(DateTime(1982, 1, 4, 8, 59, 7), hnsecs(27));
assert(sysTime == sysTime.toLocalTime());
assert(sysTime._stdTime == sysTime.toLocalTime()._stdTime);
assert(sysTime.toLocalTime().timezone is LocalTime());
assert(sysTime.toLocalTime().timezone is sysTime.timezone);
assert(sysTime.toLocalTime().timezone !is UTC());
}
{
auto stz = new immutable SimpleTimeZone(dur!"minutes"(-3 * 60));
auto sysTime = SysTime(DateTime(1982, 1, 4, 8, 59, 7), hnsecs(27), stz);
assert(sysTime == sysTime.toLocalTime());
assert(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 $(LREF SysTime) with the same std time as this one, but with
$(D UTC) as its time zone.
+/
SysTime toUTC() @safe const pure nothrow
{
return SysTime(_stdTime, UTC());
}
unittest
{
auto sysTime = SysTime(DateTime(1982, 1, 4, 8, 59, 7), hnsecs(27));
assert(sysTime == sysTime.toUTC());
assert(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 $(LREF SysTime) with the same std time as this one, but with
given time zone as its time zone.
+/
SysTime toOtherTZ(immutable TimeZone tz) @safe const pure nothrow
{
if(tz is null)
return SysTime(_stdTime, LocalTime());
else
return SysTime(_stdTime, tz);
}
unittest
{
auto stz = new immutable SimpleTimeZone(dur!"minutes"(11 * 60));
auto sysTime = SysTime(DateTime(1982, 1, 4, 8, 59, 7), hnsecs(27));
assert(sysTime == sysTime.toOtherTZ(stz));
assert(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());
}
/++
Converts this $(LREF SysTime) to unix time (i.e. seconds from midnight,
January 1st, 1970 in UTC).
The C standard does not specify the representation of time_t, so it is
implementation defined. On POSIX systems, unix time is equivalent to
time_t, but that's not necessarily true on other systems (e.g. it is
not true for the Digital Mars C runtime). So, be careful when using unix
time with C functions on non-POSIX systems.
By default, the return type is time_t (which is normally an alias for
int on 32-bit systems and long on 64-bit systems), but if a different
size is required than either int or long can be passed as a template
argument to get the desired size.
If the return type is int, and the result can't fit in an int, then the
closest value that can be held in 32 bits will be used (so $(D int.max)
if it goes over and $(D int.min) if it goes under). However, no attempt
is made to deal with integer overflow if the return type is long.
Params:
T = The return type (int or long). It defaults to time_t, which is
normally 32 bits on a 32-bit system and 64 bits on a 64-bit
system.
Returns:
A signed integer representing the unix time which is equivalent to
this SysTime.
+/
T toUnixTime(T = time_t)() @safe const pure nothrow
if(is(T == int) || is(T == long))
{
return stdTimeToUnixTime!T(_stdTime);
}
///
unittest
{
assert(SysTime(DateTime(1970, 1, 1), UTC()).toUnixTime() == 0);
auto pst = new immutable SimpleTimeZone(hours(-8));
assert(SysTime(DateTime(1970, 1, 1), pst).toUnixTime() == 28800);
auto utc = SysTime(DateTime(2007, 12, 22, 8, 14, 45), UTC());
assert(utc.toUnixTime() == 1_198_311_285);
auto ca = SysTime(DateTime(2007, 12, 22, 8, 14, 45), pst);
assert(ca.toUnixTime() == 1_198_340_085);
}
unittest
{
assert(SysTime(DateTime(1970, 1, 1), UTC()).toUnixTime() == 0);
import std.typetuple : TypeTuple;
foreach(units; TypeTuple!("hnsecs", "usecs", "msecs"))
assert(SysTime(DateTime(1970, 1, 1, 0, 0, 0), dur!units(1), UTC()).toUnixTime() == 0);
assert(SysTime(DateTime(1970, 1, 1, 0, 0, 1), UTC()).toUnixTime() == 1);
assert(SysTime(DateTime(1969, 12, 31, 23, 59, 59), hnsecs(9_999_999), UTC()).toUnixTime() == 0);
assert(SysTime(DateTime(1969, 12, 31, 23, 59, 59), usecs(999_999), UTC()).toUnixTime() == 0);
assert(SysTime(DateTime(1969, 12, 31, 23, 59, 59), msecs(999), UTC()).toUnixTime() == 0);
assert(SysTime(DateTime(1969, 12, 31, 23, 59, 59), UTC()).toUnixTime() == -1);
}
/++
Converts from unix time (i.e. seconds from midnight, January 1st, 1970
in UTC) to a $(LREF SysTime).
The C standard does not specify the representation of time_t, so it is
implementation defined. On POSIX systems, unix time is equivalent to
time_t, but that's not necessarily true on other systems (e.g. it is
not true for the Digital Mars C runtime). So, be careful when using unix
time with C functions on non-POSIX systems.
Params:
unixTime = Seconds from midnight, January 1st, 1970 in UTC.
tz = The time zone for the SysTime that's returned.
+/
static SysTime fromUnixTime(long unixTime, immutable TimeZone tz = LocalTime()) @safe pure nothrow
{
return SysTime(unixTimeToStdTime(unixTime), tz);
}
///
unittest
{
assert(SysTime.fromUnixTime(0) ==
SysTime(DateTime(1970, 1, 1), UTC()));
auto pst = new immutable SimpleTimeZone(hours(-8));
assert(SysTime.fromUnixTime(28800) ==
SysTime(DateTime(1970, 1, 1), pst));
auto st1 = SysTime.fromUnixTime(1_198_311_285, UTC());
assert(st1 == SysTime(DateTime(2007, 12, 22, 8, 14, 45), UTC()));
assert(st1.timezone is UTC());
assert(st1 == SysTime(DateTime(2007, 12, 22, 0, 14, 45), pst));
auto st2 = SysTime.fromUnixTime(1_198_311_285, pst);
assert(st2 == SysTime(DateTime(2007, 12, 22, 8, 14, 45), UTC()));
assert(st2.timezone is pst);
assert(st2 == SysTime(DateTime(2007, 12, 22, 0, 14, 45), pst));
}
unittest
{
assert(SysTime.fromUnixTime(0) == SysTime(DateTime(1970, 1, 1), UTC()));
assert(SysTime.fromUnixTime(1) == SysTime(DateTime(1970, 1, 1, 0, 0, 1), UTC()));
assert(SysTime.fromUnixTime(-1) == SysTime(DateTime(1969, 12, 31, 23, 59, 59), UTC()));
auto st = SysTime.fromUnixTime(0);
auto dt = cast(DateTime)st;
assert(dt <= DateTime(1970, 2, 1) && dt >= DateTime(1969, 12, 31));
assert(st.timezone is LocalTime());
auto aest = new immutable SimpleTimeZone(hours(10));
assert(SysTime.fromUnixTime(-36000) == SysTime(DateTime(1970, 1, 1), aest));
}
/++
Returns a $(D timeval) which represents this $(LREF SysTime).
Note that like all conversions in std.datetime, this is a truncating
conversion.
If $(D timeval.tv_sec) is int, and the result can't fit in an int, then
the closest value that can be held in 32 bits will be used for
$(D tv_sec). (so $(D int.max) if it goes over and $(D int.min) if it
goes under).
+/
timeval toTimeVal() @safe const pure nothrow
{
immutable tv_sec = toUnixTime!(typeof(timeval.tv_sec))();
immutable fracHNSecs = removeUnitsFromHNSecs!"seconds"(_stdTime - 621_355_968_000_000_000L);
immutable tv_usec = cast(typeof(timeval.tv_usec))convert!("hnsecs", "usecs")(fracHNSecs);
return timeval(tv_sec, tv_usec);
}
unittest
{
assert(SysTime(DateTime(1970, 1, 1), UTC()).toTimeVal() == timeval(0, 0));
assert(SysTime(DateTime(1970, 1, 1), hnsecs(9), UTC()).toTimeVal() == timeval(0, 0));
assert(SysTime(DateTime(1970, 1, 1), hnsecs(10), UTC()).toTimeVal() == timeval(0, 1));
assert(SysTime(DateTime(1970, 1, 1), 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), hnsecs(9), UTC()).toTimeVal() == timeval(1, 0));
assert(SysTime(DateTime(1970, 1, 1, 0, 0, 1), hnsecs(10), UTC()).toTimeVal() == timeval(1, 1));
assert(SysTime(DateTime(1970, 1, 1, 0, 0, 1), usecs(7), UTC()).toTimeVal() == timeval(1, 7));
assert(SysTime(DateTime(1969, 12, 31, 23, 59, 59), hnsecs(9_999_999), UTC()).toTimeVal() == timeval(0, 0));
assert(SysTime(DateTime(1969, 12, 31, 23, 59, 59), hnsecs(9_999_990), UTC()).toTimeVal() == timeval(0, -1));
assert(SysTime(DateTime(1969, 12, 31, 23, 59, 59), usecs(999_999), UTC()).toTimeVal() == timeval(0, -1));
assert(SysTime(DateTime(1969, 12, 31, 23, 59, 59), usecs(999), UTC()).toTimeVal() == timeval(0, -999_001));
assert(SysTime(DateTime(1969, 12, 31, 23, 59, 59), 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), usecs(17), UTC()).toTimeVal() == timeval(-1, -999_983));
}
/++
Returns a $(D tm) which represents this $(LREF SysTime).
+/
tm toTM() @safe const nothrow
{
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)
{
import std.utf : toUTFz;
timeInfo.tm_gmtoff = cast(int)convert!("hnsecs", "seconds")(adjTime - _stdTime);
auto zone = (timeInfo.tm_isdst ? _timezone.dstName : _timezone.stdName);
timeInfo.tm_zone = zone.toUTFz!(char*)();
}
return timeInfo;
}
unittest
{
import std.conv : to;
version(Posix)
{
scope(exit) clearTZEnvVar();
setTZEnvVar("America/Los_Angeles");
}
{
auto timeInfo = SysTime(DateTime(1970, 1, 1)).toTM();
assert(timeInfo.tm_sec == 0);
assert(timeInfo.tm_min == 0);
assert(timeInfo.tm_hour == 0);
assert(timeInfo.tm_mday == 1);
assert(timeInfo.tm_mon == 0);
assert(timeInfo.tm_year == 70);
assert(timeInfo.tm_wday == 4);
assert(timeInfo.tm_yday == 0);
version(Posix)
assert(timeInfo.tm_isdst == 0);
else version(Windows)
assert(timeInfo.tm_isdst == 0 || timeInfo.tm_isdst == 1);
version(Posix)
{
assert(timeInfo.tm_gmtoff == -8 * 60 * 60);
assert(to!string(timeInfo.tm_zone) == "PST");
}
}
{
auto timeInfo = SysTime(DateTime(2010, 7, 4, 12, 15, 7), hnsecs(15)).toTM();
assert(timeInfo.tm_sec == 7);
assert(timeInfo.tm_min == 15);
assert(timeInfo.tm_hour == 12);
assert(timeInfo.tm_mday == 4);
assert(timeInfo.tm_mon == 6);
assert(timeInfo.tm_year == 110);
assert(timeInfo.tm_wday == 0);
assert(timeInfo.tm_yday == 184);
version(Posix)
assert(timeInfo.tm_isdst == 1);
else version(Windows)
assert(timeInfo.tm_isdst == 0 || timeInfo.tm_isdst == 1);
version(Posix)
{
assert(timeInfo.tm_gmtoff == -7 * 60 * 60);
assert(to!string(timeInfo.tm_zone) == "PDT");
}
}
}
/++
Adds the given number of years or months to this $(LREF 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
$(LREF SysTime).
allowOverflow = Whether the days should be allowed to overflow,
causing the month to increment.
+/
ref SysTime add(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) @safe 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;
}
unittest
{
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
{
//Test A.D.
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.add!"years"(7);
assert(sysTime == SysTime(Date(2006, 7, 6)));
sysTime.add!"years"(-9);
assert(sysTime == SysTime(Date(1997, 7, 6)));
}
{
auto sysTime = SysTime(Date(1999, 2, 28));
sysTime.add!"years"(1);
assert(sysTime == SysTime(Date(2000, 2, 28)));
}
{
auto sysTime = SysTime(Date(2000, 2, 29));
sysTime.add!"years"(-1);
assert(sysTime == SysTime(Date(1999, 3, 1)));
}
{
auto sysTime = SysTime(DateTime(1999, 7, 6, 12, 7, 3), msecs(234));
sysTime.add!"years"(7);
assert(sysTime == SysTime(DateTime(2006, 7, 6, 12, 7, 3), msecs(234)));
sysTime.add!"years"(-9);
assert(sysTime == SysTime(DateTime(1997, 7, 6, 12, 7, 3), msecs(234)));
}
{
auto sysTime = SysTime(DateTime(1999, 2, 28, 0, 7, 2), usecs(1207));
sysTime.add!"years"(1);
assert(sysTime == SysTime(DateTime(2000, 2, 28, 0, 7, 2), usecs(1207)));
}
{
auto sysTime = SysTime(DateTime(2000, 2, 29, 0, 7, 2), usecs(1207));
sysTime.add!"years"(-1);
assert(sysTime == SysTime(DateTime(1999, 3, 1, 0, 7, 2), usecs(1207)));
}
//Test B.C.
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.add!"years"(-7);
assert(sysTime == SysTime(Date(-2006, 7, 6)));
sysTime.add!"years"(9);
assert(sysTime == SysTime(Date(-1997, 7, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 2, 28));
sysTime.add!"years"(-1);
assert(sysTime == SysTime(Date(-2000, 2, 28)));
}
{
auto sysTime = SysTime(Date(-2000, 2, 29));
sysTime.add!"years"(1);
assert(sysTime == SysTime(Date(-1999, 3, 1)));
}
{
auto sysTime = SysTime(DateTime(-1999, 7, 6, 12, 7, 3), msecs(234));
sysTime.add!"years"(-7);
assert(sysTime == SysTime(DateTime(-2006, 7, 6, 12, 7, 3), msecs(234)));
sysTime.add!"years"(9);
assert(sysTime == SysTime(DateTime(-1997, 7, 6, 12, 7, 3), msecs(234)));
}
{
auto sysTime = SysTime(DateTime(-1999, 2, 28, 3, 3, 3), hnsecs(3));
sysTime.add!"years"(-1);
assert(sysTime == SysTime(DateTime(-2000, 2, 28, 3, 3, 3), hnsecs(3)));
}
{
auto sysTime = SysTime(DateTime(-2000, 2, 29, 3, 3, 3), hnsecs(3));
sysTime.add!"years"(1);
assert(sysTime == SysTime(DateTime(-1999, 3, 1, 3, 3, 3), hnsecs(3)));
}
//Test Both
{
auto sysTime = SysTime(Date(4, 7, 6));
sysTime.add!"years"(-5);
assert(sysTime == SysTime(Date(-1, 7, 6)));
sysTime.add!"years"(5);
assert(sysTime == SysTime(Date(4, 7, 6)));
}
{
auto sysTime = SysTime(Date(-4, 7, 6));
sysTime.add!"years"(5);
assert(sysTime == SysTime(Date(1, 7, 6)));
sysTime.add!"years"(-5);
assert(sysTime == SysTime(Date(-4, 7, 6)));
}
{
auto sysTime = SysTime(Date(4, 7, 6));
sysTime.add!"years"(-8);
assert(sysTime == SysTime(Date(-4, 7, 6)));
sysTime.add!"years"(8);
assert(sysTime == SysTime(Date(4, 7, 6)));
}
{
auto sysTime = SysTime(Date(-4, 7, 6));
sysTime.add!"years"(8);
assert(sysTime == SysTime(Date(4, 7, 6)));
sysTime.add!"years"(-8);
assert(sysTime == SysTime(Date(-4, 7, 6)));
}
{
auto sysTime = SysTime(Date(-4, 2, 29));
sysTime.add!"years"(5);
assert(sysTime == SysTime(Date(1, 3, 1)));
}
{
auto sysTime = SysTime(Date(4, 2, 29));
sysTime.add!"years"(-5);
assert(sysTime == SysTime(Date(-1, 3, 1)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0));
sysTime.add!"years"(-1);
assert(sysTime == SysTime(DateTime(0, 1, 1, 0, 0, 0)));
sysTime.add!"years"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 0, 0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999));
sysTime.add!"years"(-1);
assert(sysTime == SysTime(DateTime(0, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
sysTime.add!"years"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 1, 1, 0, 0, 0));
sysTime.add!"years"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 0, 0)));
sysTime.add!"years"(-1);
assert(sysTime == SysTime(DateTime(0, 1, 1, 0, 0, 0)));
}
{
auto sysTime = SysTime(DateTime(0, 1, 1, 23, 59, 59), hnsecs(9_999_999));
sysTime.add!"years"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
sysTime.add!"years"(-1);
assert(sysTime == SysTime(DateTime(0, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(4, 7, 6, 14, 7, 1), usecs(54329));
sysTime.add!"years"(-5);
assert(sysTime == SysTime(DateTime(-1, 7, 6, 14, 7, 1), usecs(54329)));
sysTime.add!"years"(5);
assert(sysTime == SysTime(DateTime(4, 7, 6, 14, 7, 1), usecs(54329)));
}
{
auto sysTime = SysTime(DateTime(-4, 7, 6, 14, 7, 1), usecs(54329));
sysTime.add!"years"(5);
assert(sysTime == SysTime(DateTime(1, 7, 6, 14, 7, 1), usecs(54329)));
sysTime.add!"years"(-5);
assert(sysTime == SysTime(DateTime(-4, 7, 6, 14, 7, 1), usecs(54329)));
}
{
auto sysTime = SysTime(DateTime(-4, 2, 29, 5, 5, 5), msecs(555));
sysTime.add!"years"(5);
assert(sysTime == SysTime(DateTime(1, 3, 1, 5, 5, 5), msecs(555)));
}
{
auto sysTime = SysTime(DateTime(4, 2, 29, 5, 5, 5), msecs(555));
sysTime.add!"years"(-5);
assert(sysTime == SysTime(DateTime(-1, 3, 1, 5, 5, 5), msecs(555)));
}
{
auto sysTime = SysTime(DateTime(4, 2, 29, 5, 5, 5), msecs(555));
sysTime.add!"years"(-5).add!"years"(7);
assert(sysTime == SysTime(DateTime(6, 3, 1, 5, 5, 5), 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
{
//Test A.D.
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.add!"years"(7, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(2006, 7, 6)));
sysTime.add!"years"(-9, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1997, 7, 6)));
}
{
auto sysTime = SysTime(Date(1999, 2, 28));
sysTime.add!"years"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(2000, 2, 28)));
}
{
auto sysTime = SysTime(Date(2000, 2, 29));
sysTime.add!"years"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 2, 28)));
}
{
auto sysTime = SysTime(DateTime(1999, 7, 6, 12, 7, 3), msecs(234));
sysTime.add!"years"(7, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(2006, 7, 6, 12, 7, 3), msecs(234)));
sysTime.add!"years"(-9, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1997, 7, 6, 12, 7, 3), msecs(234)));
}
{
auto sysTime = SysTime(DateTime(1999, 2, 28, 0, 7, 2), usecs(1207));
sysTime.add!"years"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(2000, 2, 28, 0, 7, 2), usecs(1207)));
}
{
auto sysTime = SysTime(DateTime(2000, 2, 29, 0, 7, 2), usecs(1207));
sysTime.add!"years"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1999, 2, 28, 0, 7, 2), usecs(1207)));
}
//Test B.C.
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.add!"years"(-7, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-2006, 7, 6)));
sysTime.add!"years"(9, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1997, 7, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 2, 28));
sysTime.add!"years"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-2000, 2, 28)));
}
{
auto sysTime = SysTime(Date(-2000, 2, 29));
sysTime.add!"years"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 2, 28)));
}
{
auto sysTime = SysTime(DateTime(-1999, 7, 6, 12, 7, 3), msecs(234));
sysTime.add!"years"(-7, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-2006, 7, 6, 12, 7, 3), msecs(234)));
sysTime.add!"years"(9, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-1997, 7, 6, 12, 7, 3), msecs(234)));
}
{
auto sysTime = SysTime(DateTime(-1999, 2, 28, 3, 3, 3), hnsecs(3));
sysTime.add!"years"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-2000, 2, 28, 3, 3, 3), hnsecs(3)));
}
{
auto sysTime = SysTime(DateTime(-2000, 2, 29, 3, 3, 3), hnsecs(3));
sysTime.add!"years"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-1999, 2, 28, 3, 3, 3), hnsecs(3)));
}
//Test Both
{
auto sysTime = SysTime(Date(4, 7, 6));
sysTime.add!"years"(-5, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1, 7, 6)));
sysTime.add!"years"(5, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(4, 7, 6)));
}
{
auto sysTime = SysTime(Date(-4, 7, 6));
sysTime.add!"years"(5, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1, 7, 6)));
sysTime.add!"years"(-5, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-4, 7, 6)));
}
{
auto sysTime = SysTime(Date(4, 7, 6));
sysTime.add!"years"(-8, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-4, 7, 6)));
sysTime.add!"years"(8, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(4, 7, 6)));
}
{
auto sysTime = SysTime(Date(-4, 7, 6));
sysTime.add!"years"(8, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(4, 7, 6)));
sysTime.add!"years"(-8, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-4, 7, 6)));
}
{
auto sysTime = SysTime(Date(-4, 2, 29));
sysTime.add!"years"(5, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1, 2, 28)));
}
{
auto sysTime = SysTime(Date(4, 2, 29));
sysTime.add!"years"(-5, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1, 2, 28)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0));
sysTime.add!"years"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(0, 1, 1, 0, 0, 0)));
sysTime.add!"years"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 0, 0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999));
sysTime.add!"years"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(0, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
sysTime.add!"years"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 1, 1, 0, 0, 0));
sysTime.add!"years"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 0, 0)));
sysTime.add!"years"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(0, 1, 1, 0, 0, 0)));
}
{
auto sysTime = SysTime(DateTime(0, 1, 1, 23, 59, 59), hnsecs(9_999_999));
sysTime.add!"years"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
sysTime.add!"years"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(0, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(4, 7, 6, 14, 7, 1), usecs(54329));
sysTime.add!"years"(-5);
assert(sysTime == SysTime(DateTime(-1, 7, 6, 14, 7, 1), usecs(54329)));
sysTime.add!"years"(5);
assert(sysTime == SysTime(DateTime(4, 7, 6, 14, 7, 1), usecs(54329)));
}
{
auto sysTime = SysTime(DateTime(4, 7, 6, 14, 7, 1), usecs(54329));
sysTime.add!"years"(-5, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-1, 7, 6, 14, 7, 1), usecs(54329)));
sysTime.add!"years"(5, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(4, 7, 6, 14, 7, 1), usecs(54329)));
}
{
auto sysTime = SysTime(DateTime(-4, 7, 6, 14, 7, 1), usecs(54329));
sysTime.add!"years"(5, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1, 7, 6, 14, 7, 1), usecs(54329)));
sysTime.add!"years"(-5, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-4, 7, 6, 14, 7, 1), usecs(54329)));
}
{
auto sysTime = SysTime(DateTime(-4, 2, 29, 5, 5, 5), msecs(555));
sysTime.add!"years"(5, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1, 2, 28, 5, 5, 5), msecs(555)));
}
{
auto sysTime = SysTime(DateTime(4, 2, 29, 5, 5, 5), msecs(555));
sysTime.add!"years"(-5, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-1, 2, 28, 5, 5, 5), msecs(555)));
}
{
auto sysTime = SysTime(DateTime(4, 2, 29, 5, 5, 5), msecs(555));
sysTime.add!"years"(-5, AllowDayOverflow.no).add!"years"(7, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(6, 2, 28, 5, 5, 5), msecs(555)));
}
}
//Test add!"months"() with AllowDayOverlow.yes
unittest
{
//Test A.D.
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.add!"months"(3);
assert(sysTime == SysTime(Date(1999, 10, 6)));
sysTime.add!"months"(-4);
assert(sysTime == SysTime(Date(1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.add!"months"(6);
assert(sysTime == SysTime(Date(2000, 1, 6)));
sysTime.add!"months"(-6);
assert(sysTime == SysTime(Date(1999, 7, 6)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.add!"months"(27);
assert(sysTime == SysTime(Date(2001, 10, 6)));
sysTime.add!"months"(-28);
assert(sysTime == SysTime(Date(1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(1999, 5, 31));
sysTime.add!"months"(1);
assert(sysTime == SysTime(Date(1999, 7, 1)));
}
{
auto sysTime = SysTime(Date(1999, 5, 31));
sysTime.add!"months"(-1);
assert(sysTime == SysTime(Date(1999, 5, 1)));
}
{
auto sysTime = SysTime(Date(1999, 2, 28));
sysTime.add!"months"(12);
assert(sysTime == SysTime(Date(2000, 2, 28)));
}
{
auto sysTime = SysTime(Date(2000, 2, 29));
sysTime.add!"months"(12);
assert(sysTime == SysTime(Date(2001, 3, 1)));
}
{
auto sysTime = SysTime(Date(1999, 7, 31));
sysTime.add!"months"(1);
assert(sysTime == SysTime(Date(1999, 8, 31)));
sysTime.add!"months"(1);
assert(sysTime == SysTime(Date(1999, 10, 1)));
}
{
auto sysTime = SysTime(Date(1998, 8, 31));
sysTime.add!"months"(13);
assert(sysTime == SysTime(Date(1999, 10, 1)));
sysTime.add!"months"(-13);
assert(sysTime == SysTime(Date(1998, 9, 1)));
}
{
auto sysTime = SysTime(Date(1997, 12, 31));
sysTime.add!"months"(13);
assert(sysTime == SysTime(Date(1999, 1, 31)));
sysTime.add!"months"(-13);
assert(sysTime == SysTime(Date(1997, 12, 31)));
}
{
auto sysTime = SysTime(Date(1997, 12, 31));
sysTime.add!"months"(14);
assert(sysTime == SysTime(Date(1999, 3, 3)));
sysTime.add!"months"(-14);
assert(sysTime == SysTime(Date(1998, 1, 3)));
}
{
auto sysTime = SysTime(Date(1998, 12, 31));
sysTime.add!"months"(14);
assert(sysTime == SysTime(Date(2000, 3, 2)));
sysTime.add!"months"(-14);
assert(sysTime == SysTime(Date(1999, 1, 2)));
}
{
auto sysTime = SysTime(Date(1999, 12, 31));
sysTime.add!"months"(14);
assert(sysTime == SysTime(Date(2001, 3, 3)));
sysTime.add!"months"(-14);
assert(sysTime == SysTime(Date(2000, 1, 3)));
}
{
auto sysTime = SysTime(DateTime(1999, 7, 6, 12, 2, 7), usecs(5007));
sysTime.add!"months"(3);
assert(sysTime == SysTime(DateTime(1999, 10, 6, 12, 2, 7), usecs(5007)));
sysTime.add!"months"(-4);
assert(sysTime == SysTime(DateTime(1999, 6, 6, 12, 2, 7), usecs(5007)));
}
{
auto sysTime = SysTime(DateTime(1998, 12, 31, 7, 7, 7), hnsecs(422202));
sysTime.add!"months"(14);
assert(sysTime == SysTime(DateTime(2000, 3, 2, 7, 7, 7), hnsecs(422202)));
sysTime.add!"months"(-14);
assert(sysTime == SysTime(DateTime(1999, 1, 2, 7, 7, 7), hnsecs(422202)));
}
{
auto sysTime = SysTime(DateTime(1999, 12, 31, 7, 7, 7), hnsecs(422202));
sysTime.add!"months"(14);
assert(sysTime == SysTime(DateTime(2001, 3, 3, 7, 7, 7), hnsecs(422202)));
sysTime.add!"months"(-14);
assert(sysTime == SysTime(DateTime(2000, 1, 3, 7, 7, 7), hnsecs(422202)));
}
//Test B.C.
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.add!"months"(3);
assert(sysTime == SysTime(Date(-1999, 10, 6)));
sysTime.add!"months"(-4);
assert(sysTime == SysTime(Date(-1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.add!"months"(6);
assert(sysTime == SysTime(Date(-1998, 1, 6)));
sysTime.add!"months"(-6);
assert(sysTime == SysTime(Date(-1999, 7, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.add!"months"(-27);
assert(sysTime == SysTime(Date(-2001, 4, 6)));
sysTime.add!"months"(28);
assert(sysTime == SysTime(Date(-1999, 8, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 5, 31));
sysTime.add!"months"(1);
assert(sysTime == SysTime(Date(-1999, 7, 1)));
}
{
auto sysTime = SysTime(Date(-1999, 5, 31));
sysTime.add!"months"(-1);
assert(sysTime == SysTime(Date(-1999, 5, 1)));
}
{
auto sysTime = SysTime(Date(-1999, 2, 28));
sysTime.add!"months"(-12);
assert(sysTime == SysTime(Date(-2000, 2, 28)));
}
{
auto sysTime = SysTime(Date(-2000, 2, 29));
sysTime.add!"months"(-12);
assert(sysTime == SysTime(Date(-2001, 3, 1)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 31));
sysTime.add!"months"(1);
assert(sysTime == SysTime(Date(-1999, 8, 31)));
sysTime.add!"months"(1);
assert(sysTime == SysTime(Date(-1999, 10, 1)));
}
{
auto sysTime = SysTime(Date(-1998, 8, 31));
sysTime.add!"months"(13);
assert(sysTime == SysTime(Date(-1997, 10, 1)));
sysTime.add!"months"(-13);
assert(sysTime == SysTime(Date(-1998, 9, 1)));
}
{
auto sysTime = SysTime(Date(-1997, 12, 31));
sysTime.add!"months"(13);
assert(sysTime == SysTime(Date(-1995, 1, 31)));
sysTime.add!"months"(-13);
assert(sysTime == SysTime(Date(-1997, 12, 31)));
}
{
auto sysTime = SysTime(Date(-1997, 12, 31));
sysTime.add!"months"(14);
assert(sysTime == SysTime(Date(-1995, 3, 3)));
sysTime.add!"months"(-14);
assert(sysTime == SysTime(Date(-1996, 1, 3)));
}
{
auto sysTime = SysTime(Date(-2002, 12, 31));
sysTime.add!"months"(14);
assert(sysTime == SysTime(Date(-2000, 3, 2)));
sysTime.add!"months"(-14);
assert(sysTime == SysTime(Date(-2001, 1, 2)));
}
{
auto sysTime = SysTime(Date(-2001, 12, 31));
sysTime.add!"months"(14);
assert(sysTime == SysTime(Date(-1999, 3, 3)));
sysTime.add!"months"(-14);
assert(sysTime == SysTime(Date(-2000, 1, 3)));
}
{
auto sysTime = SysTime(DateTime(-1999, 7, 6, 12, 2, 7), usecs(5007));
sysTime.add!"months"(3);
assert(sysTime == SysTime(DateTime(-1999, 10, 6, 12, 2, 7), usecs(5007)));
sysTime.add!"months"(-4);
assert(sysTime == SysTime(DateTime(-1999, 6, 6, 12, 2, 7), usecs(5007)));
}
{
auto sysTime = SysTime(DateTime(-2002, 12, 31, 7, 7, 7), hnsecs(422202));
sysTime.add!"months"(14);
assert(sysTime == SysTime(DateTime(-2000, 3, 2, 7, 7, 7), hnsecs(422202)));
sysTime.add!"months"(-14);
assert(sysTime == SysTime(DateTime(-2001, 1, 2, 7, 7, 7), hnsecs(422202)));
}
{
auto sysTime = SysTime(DateTime(-2001, 12, 31, 7, 7, 7), hnsecs(422202));
sysTime.add!"months"(14);
assert(sysTime == SysTime(DateTime(-1999, 3, 3, 7, 7, 7), hnsecs(422202)));
sysTime.add!"months"(-14);
assert(sysTime == SysTime(DateTime(-2000, 1, 3, 7, 7, 7), hnsecs(422202)));
}
//Test Both
{
auto sysTime = SysTime(Date(1, 1, 1));
sysTime.add!"months"(-1);
assert(sysTime == SysTime(Date(0, 12, 1)));
sysTime.add!"months"(1);
assert(sysTime == SysTime(Date(1, 1, 1)));
}
{
auto sysTime = SysTime(Date(4, 1, 1));
sysTime.add!"months"(-48);
assert(sysTime == SysTime(Date(0, 1, 1)));
sysTime.add!"months"(48);
assert(sysTime == SysTime(Date(4, 1, 1)));
}
{
auto sysTime = SysTime(Date(4, 3, 31));
sysTime.add!"months"(-49);
assert(sysTime == SysTime(Date(0, 3, 2)));
sysTime.add!"months"(49);
assert(sysTime == SysTime(Date(4, 4, 2)));
}
{
auto sysTime = SysTime(Date(4, 3, 31));
sysTime.add!"months"(-85);
assert(sysTime == SysTime(Date(-3, 3, 3)));
sysTime.add!"months"(85);
assert(sysTime == SysTime(Date(4, 4, 3)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0));
sysTime.add!"months"(-1);
assert(sysTime == SysTime(DateTime(0, 12, 1, 0, 0, 0)));
sysTime.add!"months"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 0, 0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999));
sysTime.add!"months"(-1);
assert(sysTime == SysTime(DateTime(0, 12, 1, 23, 59, 59), hnsecs(9_999_999)));
sysTime.add!"months"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 1, 0, 0, 0));
sysTime.add!"months"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 0, 0)));
sysTime.add!"months"(-1);
assert(sysTime == SysTime(DateTime(0, 12, 1, 0, 0, 0)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 1, 23, 59, 59), hnsecs(9_999_999));
sysTime.add!"months"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
sysTime.add!"months"(-1);
assert(sysTime == SysTime(DateTime(0, 12, 1, 23, 59, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 7, 9), hnsecs(17));
sysTime.add!"months"(-1);
assert(sysTime == SysTime(DateTime(0, 12, 1, 0, 7, 9), hnsecs(17)));
sysTime.add!"months"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 7, 9), hnsecs(17)));
}
{
auto sysTime = SysTime(DateTime(4, 3, 31, 12, 11, 10), msecs(9));
sysTime.add!"months"(-85);
assert(sysTime == SysTime(DateTime(-3, 3, 3, 12, 11, 10), msecs(9)));
sysTime.add!"months"(85);
assert(sysTime == SysTime(DateTime(4, 4, 3, 12, 11, 10), msecs(9)));
}
{
auto sysTime = SysTime(DateTime(-3, 3, 31, 12, 11, 10), msecs(9));
sysTime.add!"months"(85);
assert(sysTime == SysTime(DateTime(4, 5, 1, 12, 11, 10), msecs(9)));
sysTime.add!"months"(-85);
assert(sysTime == SysTime(DateTime(-3, 4, 1, 12, 11, 10), msecs(9)));
}
{
auto sysTime = SysTime(DateTime(-3, 3, 31, 12, 11, 10), msecs(9));
sysTime.add!"months"(85).add!"months"(-83);
assert(sysTime == SysTime(DateTime(-3, 6, 1, 12, 11, 10), 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
{
//Test A.D.
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.add!"months"(3, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 10, 6)));
sysTime.add!"months"(-4, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.add!"months"(6, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(2000, 1, 6)));
sysTime.add!"months"(-6, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 7, 6)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.add!"months"(27, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(2001, 10, 6)));
sysTime.add!"months"(-28, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(1999, 5, 31));
sysTime.add!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 6, 30)));
}
{
auto sysTime = SysTime(Date(1999, 5, 31));
sysTime.add!"months"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 4, 30)));
}
{
auto sysTime = SysTime(Date(1999, 2, 28));
sysTime.add!"months"(12, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(2000, 2, 28)));
}
{
auto sysTime = SysTime(Date(2000, 2, 29));
sysTime.add!"months"(12, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(2001, 2, 28)));
}
{
auto sysTime = SysTime(Date(1999, 7, 31));
sysTime.add!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 8, 31)));
sysTime.add!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 9, 30)));
}
{
auto sysTime = SysTime(Date(1998, 8, 31));
sysTime.add!"months"(13, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 9, 30)));
sysTime.add!"months"(-13, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1998, 8, 30)));
}
{
auto sysTime = SysTime(Date(1997, 12, 31));
sysTime.add!"months"(13, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 1, 31)));
sysTime.add!"months"(-13, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1997, 12, 31)));
}
{
auto sysTime = SysTime(Date(1997, 12, 31));
sysTime.add!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 2, 28)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1997, 12, 28)));
}
{
auto sysTime = SysTime(Date(1998, 12, 31));
sysTime.add!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(2000, 2, 29)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1998, 12, 29)));
}
{
auto sysTime = SysTime(Date(1999, 12, 31));
sysTime.add!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(2001, 2, 28)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 12, 28)));
}
{
auto sysTime = SysTime(DateTime(1999, 7, 6, 12, 2, 7), usecs(5007));
sysTime.add!"months"(3, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1999, 10, 6, 12, 2, 7), usecs(5007)));
sysTime.add!"months"(-4, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1999, 6, 6, 12, 2, 7), usecs(5007)));
}
{
auto sysTime = SysTime(DateTime(1998, 12, 31, 7, 7, 7), hnsecs(422202));
sysTime.add!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(2000, 2, 29, 7, 7, 7), hnsecs(422202)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1998, 12, 29, 7, 7, 7), hnsecs(422202)));
}
{
auto sysTime = SysTime(DateTime(1999, 12, 31, 7, 7, 7), hnsecs(422202));
sysTime.add!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(2001, 2, 28, 7, 7, 7), hnsecs(422202)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1999, 12, 28, 7, 7, 7), hnsecs(422202)));
}
//Test B.C.
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.add!"months"(3, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 10, 6)));
sysTime.add!"months"(-4, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.add!"months"(6, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1998, 1, 6)));
sysTime.add!"months"(-6, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 7, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.add!"months"(-27, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-2001, 4, 6)));
sysTime.add!"months"(28, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 8, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 5, 31));
sysTime.add!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 6, 30)));
}
{
auto sysTime = SysTime(Date(-1999, 5, 31));
sysTime.add!"months"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 4, 30)));
}
{
auto sysTime = SysTime(Date(-1999, 2, 28));
sysTime.add!"months"(-12, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-2000, 2, 28)));
}
{
auto sysTime = SysTime(Date(-2000, 2, 29));
sysTime.add!"months"(-12, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-2001, 2, 28)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 31));
sysTime.add!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 8, 31)));
sysTime.add!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 9, 30)));
}
{
auto sysTime = SysTime(Date(-1998, 8, 31));
sysTime.add!"months"(13, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1997, 9, 30)));
sysTime.add!"months"(-13, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1998, 8, 30)));
}
{
auto sysTime = SysTime(Date(-1997, 12, 31));
sysTime.add!"months"(13, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1995, 1, 31)));
sysTime.add!"months"(-13, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1997, 12, 31)));
}
{
auto sysTime = SysTime(Date(-1997, 12, 31));
sysTime.add!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1995, 2, 28)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1997, 12, 28)));
}
{
auto sysTime = SysTime(Date(-2002, 12, 31));
sysTime.add!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-2000, 2, 29)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-2002, 12, 29)));
}
{
auto sysTime = SysTime(Date(-2001, 12, 31));
sysTime.add!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 2, 28)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-2001, 12, 28)));
}
{
auto sysTime = SysTime(DateTime(-1999, 7, 6, 12, 2, 7), usecs(5007));
sysTime.add!"months"(3, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-1999, 10, 6, 12, 2, 7), usecs(5007)));
sysTime.add!"months"(-4, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-1999, 6, 6, 12, 2, 7), usecs(5007)));
}
{
auto sysTime = SysTime(DateTime(-2002, 12, 31, 7, 7, 7), hnsecs(422202));
sysTime.add!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-2000, 2, 29, 7, 7, 7), hnsecs(422202)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-2002, 12, 29, 7, 7, 7), hnsecs(422202)));
}
{
auto sysTime = SysTime(DateTime(-2001, 12, 31, 7, 7, 7), hnsecs(422202));
sysTime.add!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-1999, 2, 28, 7, 7, 7), hnsecs(422202)));
sysTime.add!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-2001, 12, 28, 7, 7, 7), hnsecs(422202)));
}
//Test Both
{
auto sysTime = SysTime(Date(1, 1, 1));
sysTime.add!"months"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(0, 12, 1)));
sysTime.add!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1, 1, 1)));
}
{
auto sysTime = SysTime(Date(4, 1, 1));
sysTime.add!"months"(-48, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(0, 1, 1)));
sysTime.add!"months"(48, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(4, 1, 1)));
}
{
auto sysTime = SysTime(Date(4, 3, 31));
sysTime.add!"months"(-49, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(0, 2, 29)));
sysTime.add!"months"(49, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(4, 3, 29)));
}
{
auto sysTime = SysTime(Date(4, 3, 31));
sysTime.add!"months"(-85, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-3, 2, 28)));
sysTime.add!"months"(85, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(4, 3, 28)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0));
sysTime.add!"months"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(0, 12, 1, 0, 0, 0)));
sysTime.add!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 0, 0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999));
sysTime.add!"months"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(0, 12, 1, 23, 59, 59), hnsecs(9_999_999)));
sysTime.add!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 1, 0, 0, 0));
sysTime.add!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 0, 0)));
sysTime.add!"months"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(0, 12, 1, 0, 0, 0)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 1, 23, 59, 59), hnsecs(9_999_999));
sysTime.add!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
sysTime.add!"months"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(0, 12, 1, 23, 59, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 7, 9), hnsecs(17));
sysTime.add!"months"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(0, 12, 1, 0, 7, 9), hnsecs(17)));
sysTime.add!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 7, 9), hnsecs(17)));
}
{
auto sysTime = SysTime(DateTime(4, 3, 31, 12, 11, 10), msecs(9));
sysTime.add!"months"(-85, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-3, 2, 28, 12, 11, 10), msecs(9)));
sysTime.add!"months"(85, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(4, 3, 28, 12, 11, 10), msecs(9)));
}
{
auto sysTime = SysTime(DateTime(-3, 3, 31, 12, 11, 10), msecs(9));
sysTime.add!"months"(85, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(4, 4, 30, 12, 11, 10), msecs(9)));
sysTime.add!"months"(-85, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-3, 3, 30, 12, 11, 10), msecs(9)));
}
{
auto sysTime = SysTime(DateTime(-3, 3, 31, 12, 11, 10), msecs(9));
sysTime.add!"months"(85, AllowDayOverflow.no).add!"months"(-83, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-3, 5, 30, 12, 11, 10), msecs(9)));
}
}
/++
Adds the given number of years or months to this $(LREF SysTime). A
negative number will subtract.
The difference between rolling and adding is that rolling does not
affect larger units. Rolling a $(LREF SysTime) 12 months
gets the exact same $(LREF 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
$(LREF SysTime).
allowOverflow = Whether the days should be allowed to overflow,
causing the month to increment.
+/
ref SysTime roll(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) @safe nothrow
if(units == "years")
{
return add!"years"(value, allowOverflow);
}
///
unittest
{
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
{
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" overload.
ref SysTime roll(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) @safe 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;
return this;
}
//Test roll!"months"() with AllowDayOverlow.yes
unittest
{
//Test A.D.
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.roll!"months"(3);
assert(sysTime == SysTime(Date(1999, 10, 6)));
sysTime.roll!"months"(-4);
assert(sysTime == SysTime(Date(1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.roll!"months"(6);
assert(sysTime == SysTime(Date(1999, 1, 6)));
sysTime.roll!"months"(-6);
assert(sysTime == SysTime(Date(1999, 7, 6)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.roll!"months"(27);
assert(sysTime == SysTime(Date(1999, 10, 6)));
sysTime.roll!"months"(-28);
assert(sysTime == SysTime(Date(1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(1999, 5, 31));
sysTime.roll!"months"(1);
assert(sysTime == SysTime(Date(1999, 7, 1)));
}
{
auto sysTime = SysTime(Date(1999, 5, 31));
sysTime.roll!"months"(-1);
assert(sysTime == SysTime(Date(1999, 5, 1)));
}
{
auto sysTime = SysTime(Date(1999, 2, 28));
sysTime.roll!"months"(12);
assert(sysTime == SysTime(Date(1999, 2, 28)));
}
{
auto sysTime = SysTime(Date(2000, 2, 29));
sysTime.roll!"months"(12);
assert(sysTime == SysTime(Date(2000, 2, 29)));
}
{
auto sysTime = SysTime(Date(1999, 7, 31));
sysTime.roll!"months"(1);
assert(sysTime == SysTime(Date(1999, 8, 31)));
sysTime.roll!"months"(1);
assert(sysTime == SysTime(Date(1999, 10, 1)));
}
{
auto sysTime = SysTime(Date(1998, 8, 31));
sysTime.roll!"months"(13);
assert(sysTime == SysTime(Date(1998, 10, 1)));
sysTime.roll!"months"(-13);
assert(sysTime == SysTime(Date(1998, 9, 1)));
}
{
auto sysTime = SysTime(Date(1997, 12, 31));
sysTime.roll!"months"(13);
assert(sysTime == SysTime(Date(1997, 1, 31)));
sysTime.roll!"months"(-13);
assert(sysTime == SysTime(Date(1997, 12, 31)));
}
{
auto sysTime = SysTime(Date(1997, 12, 31));
sysTime.roll!"months"(14);
assert(sysTime == SysTime(Date(1997, 3, 3)));
sysTime.roll!"months"(-14);
assert(sysTime == SysTime(Date(1997, 1, 3)));
}
{
auto sysTime = SysTime(Date(1998, 12, 31));
sysTime.roll!"months"(14);
assert(sysTime == SysTime(Date(1998, 3, 3)));
sysTime.roll!"months"(-14);
assert(sysTime == SysTime(Date(1998, 1, 3)));
}
{
auto sysTime = SysTime(Date(1999, 12, 31));
sysTime.roll!"months"(14);
assert(sysTime == SysTime(Date(1999, 3, 3)));
sysTime.roll!"months"(-14);
assert(sysTime == SysTime(Date(1999, 1, 3)));
}
{
auto sysTime = SysTime(DateTime(1999, 7, 6, 12, 2, 7), usecs(5007));
sysTime.roll!"months"(3);
assert(sysTime == SysTime(DateTime(1999, 10, 6, 12, 2, 7), usecs(5007)));
sysTime.roll!"months"(-4);
assert(sysTime == SysTime(DateTime(1999, 6, 6, 12, 2, 7), usecs(5007)));
}
{
auto sysTime = SysTime(DateTime(1998, 12, 31, 7, 7, 7), hnsecs(422202));
sysTime.roll!"months"(14);
assert(sysTime == SysTime(DateTime(1998, 3, 3, 7, 7, 7), hnsecs(422202)));
sysTime.roll!"months"(-14);
assert(sysTime == SysTime(DateTime(1998, 1, 3, 7, 7, 7), hnsecs(422202)));
}
{
auto sysTime = SysTime(DateTime(1999, 12, 31, 7, 7, 7), hnsecs(422202));
sysTime.roll!"months"(14);
assert(sysTime == SysTime(DateTime(1999, 3, 3, 7, 7, 7), hnsecs(422202)));
sysTime.roll!"months"(-14);
assert(sysTime == SysTime(DateTime(1999, 1, 3, 7, 7, 7), hnsecs(422202)));
}
//Test B.C.
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.roll!"months"(3);
assert(sysTime == SysTime(Date(-1999, 10, 6)));
sysTime.roll!"months"(-4);
assert(sysTime == SysTime(Date(-1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.roll!"months"(6);
assert(sysTime == SysTime(Date(-1999, 1, 6)));
sysTime.roll!"months"(-6);
assert(sysTime == SysTime(Date(-1999, 7, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.roll!"months"(-27);
assert(sysTime == SysTime(Date(-1999, 4, 6)));
sysTime.roll!"months"(28);
assert(sysTime == SysTime(Date(-1999, 8, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 5, 31));
sysTime.roll!"months"(1);
assert(sysTime == SysTime(Date(-1999, 7, 1)));
}
{
auto sysTime = SysTime(Date(-1999, 5, 31));
sysTime.roll!"months"(-1);
assert(sysTime == SysTime(Date(-1999, 5, 1)));
}
{
auto sysTime = SysTime(Date(-1999, 2, 28));
sysTime.roll!"months"(-12);
assert(sysTime == SysTime(Date(-1999, 2, 28)));
}
{
auto sysTime = SysTime(Date(-2000, 2, 29));
sysTime.roll!"months"(-12);
assert(sysTime == SysTime(Date(-2000, 2, 29)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 31));
sysTime.roll!"months"(1);
assert(sysTime == SysTime(Date(-1999, 8, 31)));
sysTime.roll!"months"(1);
assert(sysTime == SysTime(Date(-1999, 10, 1)));
}
{
auto sysTime = SysTime(Date(-1998, 8, 31));
sysTime.roll!"months"(13);
assert(sysTime == SysTime(Date(-1998, 10, 1)));
sysTime.roll!"months"(-13);
assert(sysTime == SysTime(Date(-1998, 9, 1)));
}
{
auto sysTime = SysTime(Date(-1997, 12, 31));
sysTime.roll!"months"(13);
assert(sysTime == SysTime(Date(-1997, 1, 31)));
sysTime.roll!"months"(-13);
assert(sysTime == SysTime(Date(-1997, 12, 31)));
}
{
auto sysTime = SysTime(Date(-1997, 12, 31));
sysTime.roll!"months"(14);
assert(sysTime == SysTime(Date(-1997, 3, 3)));
sysTime.roll!"months"(-14);
assert(sysTime == SysTime(Date(-1997, 1, 3)));
}
{
auto sysTime = SysTime(Date(-2002, 12, 31));
sysTime.roll!"months"(14);
assert(sysTime == SysTime(Date(-2002, 3, 3)));
sysTime.roll!"months"(-14);
assert(sysTime == SysTime(Date(-2002, 1, 3)));
}
{
auto sysTime = SysTime(Date(-2001, 12, 31));
sysTime.roll!"months"(14);
assert(sysTime == SysTime(Date(-2001, 3, 3)));
sysTime.roll!"months"(-14);
assert(sysTime == SysTime(Date(-2001, 1, 3)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0));
sysTime.roll!"months"(-1);
assert(sysTime == SysTime(DateTime(1, 12, 1, 0, 0, 0)));
sysTime.roll!"months"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 0, 0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999));
sysTime.roll!"months"(-1);
assert(sysTime == SysTime(DateTime(1, 12, 1, 23, 59, 59), hnsecs(9_999_999)));
sysTime.roll!"months"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 1, 0, 0, 0));
sysTime.roll!"months"(1);
assert(sysTime == SysTime(DateTime(0, 1, 1, 0, 0, 0)));
sysTime.roll!"months"(-1);
assert(sysTime == SysTime(DateTime(0, 12, 1, 0, 0, 0)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 1, 23, 59, 59), hnsecs(9_999_999));
sysTime.roll!"months"(1);
assert(sysTime == SysTime(DateTime(0, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
sysTime.roll!"months"(-1);
assert(sysTime == SysTime(DateTime(0, 12, 1, 23, 59, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(-1999, 7, 6, 12, 2, 7), hnsecs(5007));
sysTime.roll!"months"(3);
assert(sysTime == SysTime(DateTime(-1999, 10, 6, 12, 2, 7), hnsecs(5007)));
sysTime.roll!"months"(-4);
assert(sysTime == SysTime(DateTime(-1999, 6, 6, 12, 2, 7), hnsecs(5007)));
}
{
auto sysTime = SysTime(DateTime(-2002, 12, 31, 7, 7, 7), hnsecs(422202));
sysTime.roll!"months"(14);
assert(sysTime == SysTime(DateTime(-2002, 3, 3, 7, 7, 7), hnsecs(422202)));
sysTime.roll!"months"(-14);
assert(sysTime == SysTime(DateTime(-2002, 1, 3, 7, 7, 7), hnsecs(422202)));
}
{
auto sysTime = SysTime(DateTime(-2001, 12, 31, 7, 7, 7), hnsecs(422202));
sysTime.roll!"months"(14);
assert(sysTime == SysTime(DateTime(-2001, 3, 3, 7, 7, 7), hnsecs(422202)));
sysTime.roll!"months"(-14);
assert(sysTime == SysTime(DateTime(-2001, 1, 3, 7, 7, 7), hnsecs(422202)));
}
//Test Both
{
auto sysTime = SysTime(Date(1, 1, 1));
sysTime.roll!"months"(-1);
assert(sysTime == SysTime(Date(1, 12, 1)));
sysTime.roll!"months"(1);
assert(sysTime == SysTime(Date(1, 1, 1)));
}
{
auto sysTime = SysTime(Date(4, 1, 1));
sysTime.roll!"months"(-48);
assert(sysTime == SysTime(Date(4, 1, 1)));
sysTime.roll!"months"(48);
assert(sysTime == SysTime(Date(4, 1, 1)));
}
{
auto sysTime = SysTime(Date(4, 3, 31));
sysTime.roll!"months"(-49);
assert(sysTime == SysTime(Date(4, 3, 2)));
sysTime.roll!"months"(49);
assert(sysTime == SysTime(Date(4, 4, 2)));
}
{
auto sysTime = SysTime(Date(4, 3, 31));
sysTime.roll!"months"(-85);
assert(sysTime == SysTime(Date(4, 3, 2)));
sysTime.roll!"months"(85);
assert(sysTime == SysTime(Date(4, 4, 2)));
}
{
auto sysTime = SysTime(Date(-1, 1, 1));
sysTime.roll!"months"(-1);
assert(sysTime == SysTime(Date(-1, 12, 1)));
sysTime.roll!"months"(1);
assert(sysTime == SysTime(Date(-1, 1, 1)));
}
{
auto sysTime = SysTime(Date(-4, 1, 1));
sysTime.roll!"months"(-48);
assert(sysTime == SysTime(Date(-4, 1, 1)));
sysTime.roll!"months"(48);
assert(sysTime == SysTime(Date(-4, 1, 1)));
}
{
auto sysTime = SysTime(Date(-4, 3, 31));
sysTime.roll!"months"(-49);
assert(sysTime == SysTime(Date(-4, 3, 2)));
sysTime.roll!"months"(49);
assert(sysTime == SysTime(Date(-4, 4, 2)));
}
{
auto sysTime = SysTime(Date(-4, 3, 31));
sysTime.roll!"months"(-85);
assert(sysTime == SysTime(Date(-4, 3, 2)));
sysTime.roll!"months"(85);
assert(sysTime == SysTime(Date(-4, 4, 2)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 7, 9), hnsecs(17));
sysTime.roll!"months"(-1);
assert(sysTime == SysTime(DateTime(1, 12, 1, 0, 7, 9), hnsecs(17)));
sysTime.roll!"months"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 7, 9), hnsecs(17)));
}
{
auto sysTime = SysTime(DateTime(4, 3, 31, 12, 11, 10), msecs(9));
sysTime.roll!"months"(-85);
assert(sysTime == SysTime(DateTime(4, 3, 2, 12, 11, 10), msecs(9)));
sysTime.roll!"months"(85);
assert(sysTime == SysTime(DateTime(4, 4, 2, 12, 11, 10), msecs(9)));
}
{
auto sysTime = SysTime(DateTime(-3, 3, 31, 12, 11, 10), msecs(9));
sysTime.roll!"months"(85);
assert(sysTime == SysTime(DateTime(-3, 5, 1, 12, 11, 10), msecs(9)));
sysTime.roll!"months"(-85);
assert(sysTime == SysTime(DateTime(-3, 4, 1, 12, 11, 10), msecs(9)));
}
{
auto sysTime = SysTime(DateTime(-3, 3, 31, 12, 11, 10), msecs(9));
sysTime.roll!"months"(85).roll!"months"(-83);
assert(sysTime == SysTime(DateTime(-3, 6, 1, 12, 11, 10), 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)));
}
//Test roll!"months"() with AllowDayOverlow.no
unittest
{
//Test A.D.
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.roll!"months"(3, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 10, 6)));
sysTime.roll!"months"(-4, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.roll!"months"(6, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 1, 6)));
sysTime.roll!"months"(-6, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 7, 6)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.roll!"months"(27, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 10, 6)));
sysTime.roll!"months"(-28, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(1999, 5, 31));
sysTime.roll!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 6, 30)));
}
{
auto sysTime = SysTime(Date(1999, 5, 31));
sysTime.roll!"months"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 4, 30)));
}
{
auto sysTime = SysTime(Date(1999, 2, 28));
sysTime.roll!"months"(12, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 2, 28)));
}
{
auto sysTime = SysTime(Date(2000, 2, 29));
sysTime.roll!"months"(12, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(2000, 2, 29)));
}
{
auto sysTime = SysTime(Date(1999, 7, 31));
sysTime.roll!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 8, 31)));
sysTime.roll!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 9, 30)));
}
{
auto sysTime = SysTime(Date(1998, 8, 31));
sysTime.roll!"months"(13, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1998, 9, 30)));
sysTime.roll!"months"(-13, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1998, 8, 30)));
}
{
auto sysTime = SysTime(Date(1997, 12, 31));
sysTime.roll!"months"(13, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1997, 1, 31)));
sysTime.roll!"months"(-13, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1997, 12, 31)));
}
{
auto sysTime = SysTime(Date(1997, 12, 31));
sysTime.roll!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1997, 2, 28)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1997, 12, 28)));
}
{
auto sysTime = SysTime(Date(1998, 12, 31));
sysTime.roll!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1998, 2, 28)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1998, 12, 28)));
}
{
auto sysTime = SysTime(Date(1999, 12, 31));
sysTime.roll!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 2, 28)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1999, 12, 28)));
}
{
auto sysTime = SysTime(DateTime(1999, 7, 6, 12, 2, 7), usecs(5007));
sysTime.roll!"months"(3, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1999, 10, 6, 12, 2, 7), usecs(5007)));
sysTime.roll!"months"(-4, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1999, 6, 6, 12, 2, 7), usecs(5007)));
}
{
auto sysTime = SysTime(DateTime(1998, 12, 31, 7, 7, 7), hnsecs(422202));
sysTime.roll!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1998, 2, 28, 7, 7, 7), hnsecs(422202)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1998, 12, 28, 7, 7, 7), hnsecs(422202)));
}
{
auto sysTime = SysTime(DateTime(1999, 12, 31, 7, 7, 7), hnsecs(422202));
sysTime.roll!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1999, 2, 28, 7, 7, 7), hnsecs(422202)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1999, 12, 28, 7, 7, 7), hnsecs(422202)));
}
//Test B.C.
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.roll!"months"(3, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 10, 6)));
sysTime.roll!"months"(-4, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 6, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.roll!"months"(6, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 1, 6)));
sysTime.roll!"months"(-6, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 7, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.roll!"months"(-27, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 4, 6)));
sysTime.roll!"months"(28, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 8, 6)));
}
{
auto sysTime = SysTime(Date(-1999, 5, 31));
sysTime.roll!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 6, 30)));
}
{
auto sysTime = SysTime(Date(-1999, 5, 31));
sysTime.roll!"months"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 4, 30)));
}
{
auto sysTime = SysTime(Date(-1999, 2, 28));
sysTime.roll!"months"(-12, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 2, 28)));
}
{
auto sysTime = SysTime(Date(-2000, 2, 29));
sysTime.roll!"months"(-12, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-2000, 2, 29)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 31));
sysTime.roll!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 8, 31)));
sysTime.roll!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1999, 9, 30)));
}
{
auto sysTime = SysTime(Date(-1998, 8, 31));
sysTime.roll!"months"(13, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1998, 9, 30)));
sysTime.roll!"months"(-13, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1998, 8, 30)));
}
{
auto sysTime = SysTime(Date(-1997, 12, 31));
sysTime.roll!"months"(13, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1997, 1, 31)));
sysTime.roll!"months"(-13, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1997, 12, 31)));
}
{
auto sysTime = SysTime(Date(-1997, 12, 31));
sysTime.roll!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1997, 2, 28)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1997, 12, 28)));
}
{
auto sysTime = SysTime(Date(-2002, 12, 31));
sysTime.roll!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-2002, 2, 28)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-2002, 12, 28)));
}
{
auto sysTime = SysTime(Date(-2001, 12, 31));
sysTime.roll!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-2001, 2, 28)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-2001, 12, 28)));
}
{
auto sysTime = SysTime(DateTime(-1999, 7, 6, 12, 2, 7), usecs(5007));
sysTime.roll!"months"(3, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-1999, 10, 6, 12, 2, 7), usecs(5007)));
sysTime.roll!"months"(-4, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-1999, 6, 6, 12, 2, 7), usecs(5007)));
}
{
auto sysTime = SysTime(DateTime(-2002, 12, 31, 7, 7, 7), hnsecs(422202));
sysTime.roll!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-2002, 2, 28, 7, 7, 7), hnsecs(422202)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-2002, 12, 28, 7, 7, 7), hnsecs(422202)));
}
{
auto sysTime = SysTime(DateTime(-2001, 12, 31, 7, 7, 7), hnsecs(422202));
sysTime.roll!"months"(14, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-2001, 2, 28, 7, 7, 7), hnsecs(422202)));
sysTime.roll!"months"(-14, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-2001, 12, 28, 7, 7, 7), hnsecs(422202)));
}
//Test Both
{
auto sysTime = SysTime(Date(1, 1, 1));
sysTime.roll!"months"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1, 12, 1)));
sysTime.roll!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(1, 1, 1)));
}
{
auto sysTime = SysTime(Date(4, 1, 1));
sysTime.roll!"months"(-48, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(4, 1, 1)));
sysTime.roll!"months"(48, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(4, 1, 1)));
}
{
auto sysTime = SysTime(Date(4, 3, 31));
sysTime.roll!"months"(-49, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(4, 2, 29)));
sysTime.roll!"months"(49, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(4, 3, 29)));
}
{
auto sysTime = SysTime(Date(4, 3, 31));
sysTime.roll!"months"(-85, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(4, 2, 29)));
sysTime.roll!"months"(85, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(4, 3, 29)));
}
{
auto sysTime = SysTime(Date(-1, 1, 1));
sysTime.roll!"months"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1, 12, 1)));
sysTime.roll!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-1, 1, 1)));
}
{
auto sysTime = SysTime(Date(-4, 1, 1));
sysTime.roll!"months"(-48, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-4, 1, 1)));
sysTime.roll!"months"(48, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-4, 1, 1)));
}
{
auto sysTime = SysTime(Date(-4, 3, 31));
sysTime.roll!"months"(-49, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-4, 2, 29)));
sysTime.roll!"months"(49, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-4, 3, 29)));
}
{
auto sysTime = SysTime(Date(-4, 3, 31));
sysTime.roll!"months"(-85, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-4, 2, 29)));
sysTime.roll!"months"(85, AllowDayOverflow.no);
assert(sysTime == SysTime(Date(-4, 3, 29)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0));
sysTime.roll!"months"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1, 12, 1, 0, 0, 0)));
sysTime.roll!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 0, 0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999));
sysTime.roll!"months"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1, 12, 1, 23, 59, 59), hnsecs(9_999_999)));
sysTime.roll!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 1, 0, 0, 0));
sysTime.roll!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(0, 1, 1, 0, 0, 0)));
sysTime.roll!"months"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(0, 12, 1, 0, 0, 0)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 1, 23, 59, 59), hnsecs(9_999_999));
sysTime.roll!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(0, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
sysTime.roll!"months"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(0, 12, 1, 23, 59, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 7, 9), hnsecs(17));
sysTime.roll!"months"(-1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1, 12, 1, 0, 7, 9), hnsecs(17)));
sysTime.roll!"months"(1, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 7, 9), hnsecs(17)));
}
{
auto sysTime = SysTime(DateTime(4, 3, 31, 12, 11, 10), msecs(9));
sysTime.roll!"months"(-85, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(4, 2, 29, 12, 11, 10), msecs(9)));
sysTime.roll!"months"(85, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(4, 3, 29, 12, 11, 10), msecs(9)));
}
{
auto sysTime = SysTime(DateTime(-3, 3, 31, 12, 11, 10), msecs(9));
sysTime.roll!"months"(85, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-3, 4, 30, 12, 11, 10), msecs(9)));
sysTime.roll!"months"(-85, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-3, 3, 30, 12, 11, 10), msecs(9)));
}
{
auto sysTime = SysTime(DateTime(-3, 3, 31, 12, 11, 10), msecs(9));
sysTime.roll!"months"(85, AllowDayOverflow.no).roll!"months"(-83, AllowDayOverflow.no);
assert(sysTime == SysTime(DateTime(-3, 5, 30, 12, 11, 10), msecs(9)));
}
}
/++
Adds the given number of units to this $(LREF SysTime). A negative number
will subtract.
The difference between rolling and adding is that rolling does not
affect larger units. For instance, rolling a $(LREF SysTime) one
year's worth of days gets the exact same $(LREF 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 $(LREF SysTime).
+/
ref SysTime roll(string units)(long value) @safe 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;
return this;
}
///
unittest
{
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, 2, 12, 12, 0, 0));
st3.roll!"hours"(-1);
assert(st3 == SysTime(DateTime(2010, 2, 12, 11, 0, 0)));
auto st4 = SysTime(DateTime(2009, 12, 31, 0, 0, 0));
st4.roll!"minutes"(1);
assert(st4 == SysTime(DateTime(2009, 12, 31, 0, 1, 0)));
auto st5 = SysTime(DateTime(2010, 1, 1, 0, 0, 0));
st5.roll!"minutes"(-1);
assert(st5 == SysTime(DateTime(2010, 1, 1, 0, 59, 0)));
auto st6 = SysTime(DateTime(2009, 12, 31, 0, 0, 0));
st6.roll!"seconds"(1);
assert(st6 == SysTime(DateTime(2009, 12, 31, 0, 0, 1)));
auto st7 = SysTime(DateTime(2010, 1, 1, 0, 0, 0));
st7.roll!"seconds"(-1);
assert(st7 == SysTime(DateTime(2010, 1, 1, 0, 0, 59)));
auto dt = DateTime(2010, 1, 1, 0, 0, 0);
auto st8 = SysTime(dt);
st8.roll!"msecs"(1);
assert(st8 == SysTime(dt, msecs(1)));
auto st9 = SysTime(dt);
st9.roll!"msecs"(-1);
assert(st9 == SysTime(dt, msecs(999)));
auto st10 = SysTime(dt);
st10.roll!"hnsecs"(1);
assert(st10 == SysTime(dt, hnsecs(1)));
auto st11 = SysTime(dt);
st11.roll!"hnsecs"(-1);
assert(st11 == SysTime(dt, hnsecs(9_999_999)));
}
unittest
{
//Test A.D.
{
auto sysTime = SysTime(Date(1999, 2, 28));
sysTime.roll!"days"(1);
assert(sysTime == SysTime(Date(1999, 2, 1)));
sysTime.roll!"days"(-1);
assert(sysTime == SysTime(Date(1999, 2, 28)));
}
{
auto sysTime = SysTime(Date(2000, 2, 28));
sysTime.roll!"days"(1);
assert(sysTime == SysTime(Date(2000, 2, 29)));
sysTime.roll!"days"(1);
assert(sysTime == SysTime(Date(2000, 2, 1)));
sysTime.roll!"days"(-1);
assert(sysTime == SysTime(Date(2000, 2, 29)));
}
{
auto sysTime = SysTime(Date(1999, 6, 30));
sysTime.roll!"days"(1);
assert(sysTime == SysTime(Date(1999, 6, 1)));
sysTime.roll!"days"(-1);
assert(sysTime == SysTime(Date(1999, 6, 30)));
}
{
auto sysTime = SysTime(Date(1999, 7, 31));
sysTime.roll!"days"(1);
assert(sysTime == SysTime(Date(1999, 7, 1)));
sysTime.roll!"days"(-1);
assert(sysTime == SysTime(Date(1999, 7, 31)));
}
{
auto sysTime = SysTime(Date(1999, 1, 1));
sysTime.roll!"days"(-1);
assert(sysTime == SysTime(Date(1999, 1, 31)));
sysTime.roll!"days"(1);
assert(sysTime == SysTime(Date(1999, 1, 1)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.roll!"days"(9);
assert(sysTime == SysTime(Date(1999, 7, 15)));
sysTime.roll!"days"(-11);
assert(sysTime == SysTime(Date(1999, 7, 4)));
sysTime.roll!"days"(30);
assert(sysTime == SysTime(Date(1999, 7, 3)));
sysTime.roll!"days"(-3);
assert(sysTime == SysTime(Date(1999, 7, 31)));
}
{
auto sysTime = SysTime(Date(1999, 7, 6));
sysTime.roll!"days"(365);
assert(sysTime == SysTime(Date(1999, 7, 30)));
sysTime.roll!"days"(-365);
assert(sysTime == SysTime(Date(1999, 7, 6)));
sysTime.roll!"days"(366);
assert(sysTime == SysTime(Date(1999, 7, 31)));
sysTime.roll!"days"(730);
assert(sysTime == SysTime(Date(1999, 7, 17)));
sysTime.roll!"days"(-1096);
assert(sysTime == SysTime(Date(1999, 7, 6)));
}
{
auto sysTime = SysTime(Date(1999, 2, 6));
sysTime.roll!"days"(365);
assert(sysTime == SysTime(Date(1999, 2, 7)));
sysTime.roll!"days"(-365);
assert(sysTime == SysTime(Date(1999, 2, 6)));
sysTime.roll!"days"(366);
assert(sysTime == SysTime(Date(1999, 2, 8)));
sysTime.roll!"days"(730);
assert(sysTime == SysTime(Date(1999, 2, 10)));
sysTime.roll!"days"(-1096);
assert(sysTime == SysTime(Date(1999, 2, 6)));
}
{
auto sysTime = SysTime(DateTime(1999, 2, 28, 7, 9, 2), usecs(234578));
sysTime.roll!"days"(1);
assert(sysTime == SysTime(DateTime(1999, 2, 1, 7, 9, 2), usecs(234578)));
sysTime.roll!"days"(-1);
assert(sysTime == SysTime(DateTime(1999, 2, 28, 7, 9, 2), usecs(234578)));
}
{
auto sysTime = SysTime(DateTime(1999, 7, 6, 7, 9, 2), usecs(234578));
sysTime.roll!"days"(9);
assert(sysTime == SysTime(DateTime(1999, 7, 15, 7, 9, 2), usecs(234578)));
sysTime.roll!"days"(-11);
assert(sysTime == SysTime(DateTime(1999, 7, 4, 7, 9, 2), usecs(234578)));
sysTime.roll!"days"(30);
assert(sysTime == SysTime(DateTime(1999, 7, 3, 7, 9, 2), usecs(234578)));
sysTime.roll!"days"(-3);
assert(sysTime == SysTime(DateTime(1999, 7, 31, 7, 9, 2), usecs(234578)));
}
//Test B.C.
{
auto sysTime = SysTime(Date(-1999, 2, 28));
sysTime.roll!"days"(1);
assert(sysTime == SysTime(Date(-1999, 2, 1)));
sysTime.roll!"days"(-1);
assert(sysTime == SysTime(Date(-1999, 2, 28)));
}
{
auto sysTime = SysTime(Date(-2000, 2, 28));
sysTime.roll!"days"(1);
assert(sysTime == SysTime(Date(-2000, 2, 29)));
sysTime.roll!"days"(1);
assert(sysTime == SysTime(Date(-2000, 2, 1)));
sysTime.roll!"days"(-1);
assert(sysTime == SysTime(Date(-2000, 2, 29)));
}
{
auto sysTime = SysTime(Date(-1999, 6, 30));
sysTime.roll!"days"(1);
assert(sysTime == SysTime(Date(-1999, 6, 1)));
sysTime.roll!"days"(-1);
assert(sysTime == SysTime(Date(-1999, 6, 30)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 31));
sysTime.roll!"days"(1);
assert(sysTime == SysTime(Date(-1999, 7, 1)));
sysTime.roll!"days"(-1);
assert(sysTime == SysTime(Date(-1999, 7, 31)));
}
{
auto sysTime = SysTime(Date(-1999, 1, 1));
sysTime.roll!"days"(-1);
assert(sysTime == SysTime(Date(-1999, 1, 31)));
sysTime.roll!"days"(1);
assert(sysTime == SysTime(Date(-1999, 1, 1)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.roll!"days"(9);
assert(sysTime == SysTime(Date(-1999, 7, 15)));
sysTime.roll!"days"(-11);
assert(sysTime == SysTime(Date(-1999, 7, 4)));
sysTime.roll!"days"(30);
assert(sysTime == SysTime(Date(-1999, 7, 3)));
sysTime.roll!"days"(-3);
assert(sysTime == SysTime(Date(-1999, 7, 31)));
}
{
auto sysTime = SysTime(Date(-1999, 7, 6));
sysTime.roll!"days"(365);
assert(sysTime == SysTime(Date(-1999, 7, 30)));
sysTime.roll!"days"(-365);
assert(sysTime == SysTime(Date(-1999, 7, 6)));
sysTime.roll!"days"(366);
assert(sysTime == SysTime(Date(-1999, 7, 31)));
sysTime.roll!"days"(730);
assert(sysTime == SysTime(Date(-1999, 7, 17)));
sysTime.roll!"days"(-1096);
assert(sysTime == SysTime(Date(-1999, 7, 6)));
}
{
auto sysTime = SysTime(DateTime(-1999, 2, 28, 7, 9, 2), usecs(234578));
sysTime.roll!"days"(1);
assert(sysTime == SysTime(DateTime(-1999, 2, 1, 7, 9, 2), usecs(234578)));
sysTime.roll!"days"(-1);
assert(sysTime == SysTime(DateTime(-1999, 2, 28, 7, 9, 2), usecs(234578)));
}
{
auto sysTime = SysTime(DateTime(-1999, 7, 6, 7, 9, 2), usecs(234578));
sysTime.roll!"days"(9);
assert(sysTime == SysTime(DateTime(-1999, 7, 15, 7, 9, 2), usecs(234578)));
sysTime.roll!"days"(-11);
assert(sysTime == SysTime(DateTime(-1999, 7, 4, 7, 9, 2), usecs(234578)));
sysTime.roll!"days"(30);
assert(sysTime == SysTime(DateTime(-1999, 7, 3, 7, 9, 2), usecs(234578)));
sysTime.roll!"days"(-3);
}
//Test Both
{
auto sysTime = SysTime(Date(1, 7, 6));
sysTime.roll!"days"(-365);
assert(sysTime == SysTime(Date(1, 7, 13)));
sysTime.roll!"days"(365);
assert(sysTime == SysTime(Date(1, 7, 6)));
sysTime.roll!"days"(-731);
assert(sysTime == SysTime(Date(1, 7, 19)));
sysTime.roll!"days"(730);
assert(sysTime == SysTime(Date(1, 7, 5)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0));
sysTime.roll!"days"(-1);
assert(sysTime == SysTime(DateTime(1, 1, 31, 0, 0, 0)));
sysTime.roll!"days"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 0, 0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999));
sysTime.roll!"days"(-1);
assert(sysTime == SysTime(DateTime(1, 1, 31, 23, 59, 59), hnsecs(9_999_999)));
sysTime.roll!"days"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 0, 0, 0));
sysTime.roll!"days"(1);
assert(sysTime == SysTime(DateTime(0, 12, 1, 0, 0, 0)));
sysTime.roll!"days"(-1);
assert(sysTime == SysTime(DateTime(0, 12, 31, 0, 0, 0)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999));
sysTime.roll!"days"(1);
assert(sysTime == SysTime(DateTime(0, 12, 1, 23, 59, 59), hnsecs(9_999_999)));
sysTime.roll!"days"(-1);
assert(sysTime == SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(1, 7, 6, 13, 13, 9), msecs(22));
sysTime.roll!"days"(-365);
assert(sysTime == SysTime(DateTime(1, 7, 13, 13, 13, 9), msecs(22)));
sysTime.roll!"days"(365);
assert(sysTime == SysTime(DateTime(1, 7, 6, 13, 13, 9), msecs(22)));
sysTime.roll!"days"(-731);
assert(sysTime == SysTime(DateTime(1, 7, 19, 13, 13, 9), msecs(22)));
sysTime.roll!"days"(730);
assert(sysTime == SysTime(DateTime(1, 7, 5, 13, 13, 9), msecs(22)));
}
{
auto sysTime = SysTime(DateTime(0, 7, 6, 13, 13, 9), msecs(22));
sysTime.roll!"days"(-365);
assert(sysTime == SysTime(DateTime(0, 7, 13, 13, 13, 9), msecs(22)));
sysTime.roll!"days"(365);
assert(sysTime == SysTime(DateTime(0, 7, 6, 13, 13, 9), msecs(22)));
sysTime.roll!"days"(-731);
assert(sysTime == SysTime(DateTime(0, 7, 19, 13, 13, 9), msecs(22)));
sysTime.roll!"days"(730);
assert(sysTime == SysTime(DateTime(0, 7, 5, 13, 13, 9), msecs(22)));
}
{
auto sysTime = SysTime(DateTime(0, 7, 6, 13, 13, 9), msecs(22));
sysTime.roll!"days"(-365).roll!"days"(362).roll!"days"(-12).roll!"days"(730);
assert(sysTime == SysTime(DateTime(0, 7, 8, 13, 13, 9), 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)));
}
//Shares documentation with "days" version.
ref SysTime roll(string units)(long value) @safe 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;
return this;
}
catch(Exception e)
assert(0, "Either DateTime's constructor or TimeOfDay's constructor threw.");
}
//Test roll!"hours"().
unittest
{
static void testST(SysTime orig, int hours, in SysTime expected, size_t line = __LINE__)
{
import std.format : format;
orig.roll!"hours"(hours);
if(orig != expected)
throw new AssertError(format("Failed. actual [%s] != expected [%s]", orig, expected), __FILE__, line);
}
//Test A.D.
immutable d = msecs(45);
auto beforeAD = SysTime(DateTime(1999, 7, 6, 12, 30, 33), d);
testST(beforeAD, 0, SysTime(DateTime(1999, 7, 6, 12, 30, 33), d));
testST(beforeAD, 1, SysTime(DateTime(1999, 7, 6, 13, 30, 33), d));
testST(beforeAD, 2, SysTime(DateTime(1999, 7, 6, 14, 30, 33), d));
testST(beforeAD, 3, SysTime(DateTime(1999, 7, 6, 15, 30, 33), d));
testST(beforeAD, 4, SysTime(DateTime(1999, 7, 6, 16, 30, 33), d));
testST(beforeAD, 5, SysTime(DateTime(1999, 7, 6, 17, 30, 33), d));
testST(beforeAD, 6, SysTime(DateTime(1999, 7, 6, 18, 30, 33), d));
testST(beforeAD, 7, SysTime(DateTime(1999, 7, 6, 19, 30, 33), d));
testST(beforeAD, 8, SysTime(DateTime(1999, 7, 6, 20, 30, 33), d));
testST(beforeAD, 9, SysTime(DateTime(1999, 7, 6, 21, 30, 33), d));
testST(beforeAD, 10, SysTime(DateTime(1999, 7, 6, 22, 30, 33), d));
testST(beforeAD, 11, SysTime(DateTime(1999, 7, 6, 23, 30, 33), d));
testST(beforeAD, 12, SysTime(DateTime(1999, 7, 6, 0, 30, 33), d));
testST(beforeAD, 13, SysTime(DateTime(1999, 7, 6, 1, 30, 33), d));
testST(beforeAD, 14, SysTime(DateTime(1999, 7, 6, 2, 30, 33), d));
testST(beforeAD, 15, SysTime(DateTime(1999, 7, 6, 3, 30, 33), d));
testST(beforeAD, 16, SysTime(DateTime(1999, 7, 6, 4, 30, 33), d));
testST(beforeAD, 17, SysTime(DateTime(1999, 7, 6, 5, 30, 33), d));
testST(beforeAD, 18, SysTime(DateTime(1999, 7, 6, 6, 30, 33), d));
testST(beforeAD, 19, SysTime(DateTime(1999, 7, 6, 7, 30, 33), d));
testST(beforeAD, 20, SysTime(DateTime(1999, 7, 6, 8, 30, 33), d));
testST(beforeAD, 21, SysTime(DateTime(1999, 7, 6, 9, 30, 33), d));
testST(beforeAD, 22, SysTime(DateTime(1999, 7, 6, 10, 30, 33), d));
testST(beforeAD, 23, SysTime(DateTime(1999, 7, 6, 11, 30, 33), d));
testST(beforeAD, 24, SysTime(DateTime(1999, 7, 6, 12, 30, 33), d));
testST(beforeAD, 25, SysTime(DateTime(1999, 7, 6, 13, 30, 33), d));
testST(beforeAD, 50, SysTime(DateTime(1999, 7, 6, 14, 30, 33), d));
testST(beforeAD, 10_000, SysTime(DateTime(1999, 7, 6, 4, 30, 33), d));
testST(beforeAD, -1, SysTime(DateTime(1999, 7, 6, 11, 30, 33), d));
testST(beforeAD, -2, SysTime(DateTime(1999, 7, 6, 10, 30, 33), d));
testST(beforeAD, -3, SysTime(DateTime(1999, 7, 6, 9, 30, 33), d));
testST(beforeAD, -4, SysTime(DateTime(1999, 7, 6, 8, 30, 33), d));
testST(beforeAD, -5, SysTime(DateTime(1999, 7, 6, 7, 30, 33), d));
testST(beforeAD, -6, SysTime(DateTime(1999, 7, 6, 6, 30, 33), d));
testST(beforeAD, -7, SysTime(DateTime(1999, 7, 6, 5, 30, 33), d));
testST(beforeAD, -8, SysTime(DateTime(1999, 7, 6, 4, 30, 33), d));
testST(beforeAD, -9, SysTime(DateTime(1999, 7, 6, 3, 30, 33), d));
testST(beforeAD, -10, SysTime(DateTime(1999, 7, 6, 2, 30, 33), d));
testST(beforeAD, -11, SysTime(DateTime(1999, 7, 6, 1, 30, 33), d));
testST(beforeAD, -12, SysTime(DateTime(1999, 7, 6, 0, 30, 33), d));
testST(beforeAD, -13, SysTime(DateTime(1999, 7, 6, 23, 30, 33), d));
testST(beforeAD, -14, SysTime(DateTime(1999, 7, 6, 22, 30, 33), d));
testST(beforeAD, -15, SysTime(DateTime(1999, 7, 6, 21, 30, 33), d));
testST(beforeAD, -16, SysTime(DateTime(1999, 7, 6, 20, 30, 33), d));
testST(beforeAD, -17, SysTime(DateTime(1999, 7, 6, 19, 30, 33), d));
testST(beforeAD, -18, SysTime(DateTime(1999, 7, 6, 18, 30, 33), d));
testST(beforeAD, -19, SysTime(DateTime(1999, 7, 6, 17, 30, 33), d));
testST(beforeAD, -20, SysTime(DateTime(1999, 7, 6, 16, 30, 33), d));
testST(beforeAD, -21, SysTime(DateTime(1999, 7, 6, 15, 30, 33), d));
testST(beforeAD, -22, SysTime(DateTime(1999, 7, 6, 14, 30, 33), d));
testST(beforeAD, -23, SysTime(DateTime(1999, 7, 6, 13, 30, 33), d));
testST(beforeAD, -24, SysTime(DateTime(1999, 7, 6, 12, 30, 33), d));
testST(beforeAD, -25, SysTime(DateTime(1999, 7, 6, 11, 30, 33), d));
testST(beforeAD, -50, SysTime(DateTime(1999, 7, 6, 10, 30, 33), d));
testST(beforeAD, -10_000, SysTime(DateTime(1999, 7, 6, 20, 30, 33), d));
testST(SysTime(DateTime(1999, 7, 6, 0, 30, 33), d), 1, SysTime(DateTime(1999, 7, 6, 1, 30, 33), d));
testST(SysTime(DateTime(1999, 7, 6, 0, 30, 33), d), 0, SysTime(DateTime(1999, 7, 6, 0, 30, 33), d));
testST(SysTime(DateTime(1999, 7, 6, 0, 30, 33), d), -1, SysTime(DateTime(1999, 7, 6, 23, 30, 33), d));
testST(SysTime(DateTime(1999, 7, 6, 23, 30, 33), d), 1, SysTime(DateTime(1999, 7, 6, 0, 30, 33), d));
testST(SysTime(DateTime(1999, 7, 6, 23, 30, 33), d), 0, SysTime(DateTime(1999, 7, 6, 23, 30, 33), d));
testST(SysTime(DateTime(1999, 7, 6, 23, 30, 33), d), -1, SysTime(DateTime(1999, 7, 6, 22, 30, 33), d));
testST(SysTime(DateTime(1999, 7, 31, 23, 30, 33), d), 1, SysTime(DateTime(1999, 7, 31, 0, 30, 33), d));
testST(SysTime(DateTime(1999, 8, 1, 0, 30, 33), d), -1, SysTime(DateTime(1999, 8, 1, 23, 30, 33), d));
testST(SysTime(DateTime(1999, 12, 31, 23, 30, 33), d), 1, SysTime(DateTime(1999, 12, 31, 0, 30, 33), d));
testST(SysTime(DateTime(2000, 1, 1, 0, 30, 33), d), -1, SysTime(DateTime(2000, 1, 1, 23, 30, 33), d));
testST(SysTime(DateTime(1999, 2, 28, 23, 30, 33), d), 25, SysTime(DateTime(1999, 2, 28, 0, 30, 33), d));
testST(SysTime(DateTime(1999, 3, 2, 0, 30, 33), d), -25, SysTime(DateTime(1999, 3, 2, 23, 30, 33), d));
testST(SysTime(DateTime(2000, 2, 28, 23, 30, 33), d), 25, SysTime(DateTime(2000, 2, 28, 0, 30, 33), d));
testST(SysTime(DateTime(2000, 3, 1, 0, 30, 33), d), -25, SysTime(DateTime(2000, 3, 1, 23, 30, 33), d));
//Test B.C.
auto beforeBC = SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d);
testST(beforeBC, 0, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d));
testST(beforeBC, 1, SysTime(DateTime(-1999, 7, 6, 13, 30, 33), d));
testST(beforeBC, 2, SysTime(DateTime(-1999, 7, 6, 14, 30, 33), d));
testST(beforeBC, 3, SysTime(DateTime(-1999, 7, 6, 15, 30, 33), d));
testST(beforeBC, 4, SysTime(DateTime(-1999, 7, 6, 16, 30, 33), d));
testST(beforeBC, 5, SysTime(DateTime(-1999, 7, 6, 17, 30, 33), d));
testST(beforeBC, 6, SysTime(DateTime(-1999, 7, 6, 18, 30, 33), d));
testST(beforeBC, 7, SysTime(DateTime(-1999, 7, 6, 19, 30, 33), d));
testST(beforeBC, 8, SysTime(DateTime(-1999, 7, 6, 20, 30, 33), d));
testST(beforeBC, 9, SysTime(DateTime(-1999, 7, 6, 21, 30, 33), d));
testST(beforeBC, 10, SysTime(DateTime(-1999, 7, 6, 22, 30, 33), d));
testST(beforeBC, 11, SysTime(DateTime(-1999, 7, 6, 23, 30, 33), d));
testST(beforeBC, 12, SysTime(DateTime(-1999, 7, 6, 0, 30, 33), d));
testST(beforeBC, 13, SysTime(DateTime(-1999, 7, 6, 1, 30, 33), d));
testST(beforeBC, 14, SysTime(DateTime(-1999, 7, 6, 2, 30, 33), d));
testST(beforeBC, 15, SysTime(DateTime(-1999, 7, 6, 3, 30, 33), d));
testST(beforeBC, 16, SysTime(DateTime(-1999, 7, 6, 4, 30, 33), d));
testST(beforeBC, 17, SysTime(DateTime(-1999, 7, 6, 5, 30, 33), d));
testST(beforeBC, 18, SysTime(DateTime(-1999, 7, 6, 6, 30, 33), d));
testST(beforeBC, 19, SysTime(DateTime(-1999, 7, 6, 7, 30, 33), d));
testST(beforeBC, 20, SysTime(DateTime(-1999, 7, 6, 8, 30, 33), d));
testST(beforeBC, 21, SysTime(DateTime(-1999, 7, 6, 9, 30, 33), d));
testST(beforeBC, 22, SysTime(DateTime(-1999, 7, 6, 10, 30, 33), d));
testST(beforeBC, 23, SysTime(DateTime(-1999, 7, 6, 11, 30, 33), d));
testST(beforeBC, 24, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d));
testST(beforeBC, 25, SysTime(DateTime(-1999, 7, 6, 13, 30, 33), d));
testST(beforeBC, 50, SysTime(DateTime(-1999, 7, 6, 14, 30, 33), d));
testST(beforeBC, 10_000, SysTime(DateTime(-1999, 7, 6, 4, 30, 33), d));
testST(beforeBC, -1, SysTime(DateTime(-1999, 7, 6, 11, 30, 33), d));
testST(beforeBC, -2, SysTime(DateTime(-1999, 7, 6, 10, 30, 33), d));
testST(beforeBC, -3, SysTime(DateTime(-1999, 7, 6, 9, 30, 33), d));
testST(beforeBC, -4, SysTime(DateTime(-1999, 7, 6, 8, 30, 33), d));
testST(beforeBC, -5, SysTime(DateTime(-1999, 7, 6, 7, 30, 33), d));
testST(beforeBC, -6, SysTime(DateTime(-1999, 7, 6, 6, 30, 33), d));
testST(beforeBC, -7, SysTime(DateTime(-1999, 7, 6, 5, 30, 33), d));
testST(beforeBC, -8, SysTime(DateTime(-1999, 7, 6, 4, 30, 33), d));
testST(beforeBC, -9, SysTime(DateTime(-1999, 7, 6, 3, 30, 33), d));
testST(beforeBC, -10, SysTime(DateTime(-1999, 7, 6, 2, 30, 33), d));
testST(beforeBC, -11, SysTime(DateTime(-1999, 7, 6, 1, 30, 33), d));
testST(beforeBC, -12, SysTime(DateTime(-1999, 7, 6, 0, 30, 33), d));
testST(beforeBC, -13, SysTime(DateTime(-1999, 7, 6, 23, 30, 33), d));
testST(beforeBC, -14, SysTime(DateTime(-1999, 7, 6, 22, 30, 33), d));
testST(beforeBC, -15, SysTime(DateTime(-1999, 7, 6, 21, 30, 33), d));
testST(beforeBC, -16, SysTime(DateTime(-1999, 7, 6, 20, 30, 33), d));
testST(beforeBC, -17, SysTime(DateTime(-1999, 7, 6, 19, 30, 33), d));
testST(beforeBC, -18, SysTime(DateTime(-1999, 7, 6, 18, 30, 33), d));
testST(beforeBC, -19, SysTime(DateTime(-1999, 7, 6, 17, 30, 33), d));
testST(beforeBC, -20, SysTime(DateTime(-1999, 7, 6, 16, 30, 33), d));
testST(beforeBC, -21, SysTime(DateTime(-1999, 7, 6, 15, 30, 33), d));
testST(beforeBC, -22, SysTime(DateTime(-1999, 7, 6, 14, 30, 33), d));
testST(beforeBC, -23, SysTime(DateTime(-1999, 7, 6, 13, 30, 33), d));
testST(beforeBC, -24, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d));
testST(beforeBC, -25, SysTime(DateTime(-1999, 7, 6, 11, 30, 33), d));
testST(beforeBC, -50, SysTime(DateTime(-1999, 7, 6, 10, 30, 33), d));
testST(beforeBC, -10_000, SysTime(DateTime(-1999, 7, 6, 20, 30, 33), d));
testST(SysTime(DateTime(-1999, 7, 6, 0, 30, 33), d), 1, SysTime(DateTime(-1999, 7, 6, 1, 30, 33), d));
testST(SysTime(DateTime(-1999, 7, 6, 0, 30, 33), d), 0, SysTime(DateTime(-1999, 7, 6, 0, 30, 33), d));
testST(SysTime(DateTime(-1999, 7, 6, 0, 30, 33), d), -1, SysTime(DateTime(-1999, 7, 6, 23, 30, 33), d));
testST(SysTime(DateTime(-1999, 7, 6, 23, 30, 33), d), 1, SysTime(DateTime(-1999, 7, 6, 0, 30, 33), d));
testST(SysTime(DateTime(-1999, 7, 6, 23, 30, 33), d), 0, SysTime(DateTime(-1999, 7, 6, 23, 30, 33), d));
testST(SysTime(DateTime(-1999, 7, 6, 23, 30, 33), d), -1, SysTime(DateTime(-1999, 7, 6, 22, 30, 33), d));
testST(SysTime(DateTime(-1999, 7, 31, 23, 30, 33), d), 1, SysTime(DateTime(-1999, 7, 31, 0, 30, 33), d));
testST(SysTime(DateTime(-1999, 8, 1, 0, 30, 33), d), -1, SysTime(DateTime(-1999, 8, 1, 23, 30, 33), d));
testST(SysTime(DateTime(-2001, 12, 31, 23, 30, 33), d), 1, SysTime(DateTime(-2001, 12, 31, 0, 30, 33), d));
testST(SysTime(DateTime(-2000, 1, 1, 0, 30, 33), d), -1, SysTime(DateTime(-2000, 1, 1, 23, 30, 33), d));
testST(SysTime(DateTime(-2001, 2, 28, 23, 30, 33), d), 25, SysTime(DateTime(-2001, 2, 28, 0, 30, 33), d));
testST(SysTime(DateTime(-2001, 3, 2, 0, 30, 33), d), -25, SysTime(DateTime(-2001, 3, 2, 23, 30, 33), d));
testST(SysTime(DateTime(-2000, 2, 28, 23, 30, 33), d), 25, SysTime(DateTime(-2000, 2, 28, 0, 30, 33), d));
testST(SysTime(DateTime(-2000, 3, 1, 0, 30, 33), d), -25, SysTime(DateTime(-2000, 3, 1, 23, 30, 33), d));
//Test Both
testST(SysTime(DateTime(-1, 1, 1, 11, 30, 33), d), 17_546, SysTime(DateTime(-1, 1, 1, 13, 30, 33), d));
testST(SysTime(DateTime(1, 1, 1, 13, 30, 33), d), -17_546, SysTime(DateTime(1, 1, 1, 11, 30, 33), d));
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0));
sysTime.roll!"hours"(-1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 23, 0, 0)));
sysTime.roll!"hours"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 0, 0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 59, 59), hnsecs(9_999_999));
sysTime.roll!"hours"(-1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
sysTime.roll!"hours"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 59, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 23, 0, 0));
sysTime.roll!"hours"(1);
assert(sysTime == SysTime(DateTime(0, 12, 31, 0, 0, 0)));
sysTime.roll!"hours"(-1);
assert(sysTime == SysTime(DateTime(0, 12, 31, 23, 0, 0)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999));
sysTime.roll!"hours"(1);
assert(sysTime == SysTime(DateTime(0, 12, 31, 0, 59, 59), hnsecs(9_999_999)));
sysTime.roll!"hours"(-1);
assert(sysTime == SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999));
sysTime.roll!"hours"(1).roll!"hours"(-67);
assert(sysTime == SysTime(DateTime(0, 12, 31, 5, 59, 59), 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)));
}
//Test roll!"minutes"().
unittest
{
static void testST(SysTime orig, int minutes, in SysTime expected, size_t line = __LINE__)
{
import std.format : format;
orig.roll!"minutes"(minutes);
if(orig != expected)
throw new AssertError(format("Failed. actual [%s] != expected [%s]", orig, expected), __FILE__, line);
}
//Test A.D.
immutable d = usecs(7203);
auto beforeAD = SysTime(DateTime(1999, 7, 6, 12, 30, 33), d);
testST(beforeAD, 0, SysTime(DateTime(1999, 7, 6, 12, 30, 33), d));
testST(beforeAD, 1, SysTime(DateTime(1999, 7, 6, 12, 31, 33), d));
testST(beforeAD, 2, SysTime(DateTime(1999, 7, 6, 12, 32, 33), d));
testST(beforeAD, 3, SysTime(DateTime(1999, 7, 6, 12, 33, 33), d));
testST(beforeAD, 4, SysTime(DateTime(1999, 7, 6, 12, 34, 33), d));
testST(beforeAD, 5, SysTime(DateTime(1999, 7, 6, 12, 35, 33), d));
testST(beforeAD, 10, SysTime(DateTime(1999, 7, 6, 12, 40, 33), d));
testST(beforeAD, 15, SysTime(DateTime(1999, 7, 6, 12, 45, 33), d));
testST(beforeAD, 29, SysTime(DateTime(1999, 7, 6, 12, 59, 33), d));
testST(beforeAD, 30, SysTime(DateTime(1999, 7, 6, 12, 0, 33), d));
testST(beforeAD, 45, SysTime(DateTime(1999, 7, 6, 12, 15, 33), d));
testST(beforeAD, 60, SysTime(DateTime(1999, 7, 6, 12, 30, 33), d));
testST(beforeAD, 75, SysTime(DateTime(1999, 7, 6, 12, 45, 33), d));
testST(beforeAD, 90, SysTime(DateTime(1999, 7, 6, 12, 0, 33), d));
testST(beforeAD, 100, SysTime(DateTime(1999, 7, 6, 12, 10, 33), d));
testST(beforeAD, 689, SysTime(DateTime(1999, 7, 6, 12, 59, 33), d));
testST(beforeAD, 690, SysTime(DateTime(1999, 7, 6, 12, 0, 33), d));
testST(beforeAD, 691, SysTime(DateTime(1999, 7, 6, 12, 1, 33), d));
testST(beforeAD, 960, SysTime(DateTime(1999, 7, 6, 12, 30, 33), d));
testST(beforeAD, 1439, SysTime(DateTime(1999, 7, 6, 12, 29, 33), d));
testST(beforeAD, 1440, SysTime(DateTime(1999, 7, 6, 12, 30, 33), d));
testST(beforeAD, 1441, SysTime(DateTime(1999, 7, 6, 12, 31, 33), d));
testST(beforeAD, 2880, SysTime(DateTime(1999, 7, 6, 12, 30, 33), d));
testST(beforeAD, -1, SysTime(DateTime(1999, 7, 6, 12, 29, 33), d));
testST(beforeAD, -2, SysTime(DateTime(1999, 7, 6, 12, 28, 33), d));
testST(beforeAD, -3, SysTime(DateTime(1999, 7, 6, 12, 27, 33), d));
testST(beforeAD, -4, SysTime(DateTime(1999, 7, 6, 12, 26, 33), d));
testST(beforeAD, -5, SysTime(DateTime(1999, 7, 6, 12, 25, 33), d));
testST(beforeAD, -10, SysTime(DateTime(1999, 7, 6, 12, 20, 33), d));
testST(beforeAD, -15, SysTime(DateTime(1999, 7, 6, 12, 15, 33), d));
testST(beforeAD, -29, SysTime(DateTime(1999, 7, 6, 12, 1, 33), d));
testST(beforeAD, -30, SysTime(DateTime(1999, 7, 6, 12, 0, 33), d));
testST(beforeAD, -45, SysTime(DateTime(1999, 7, 6, 12, 45, 33), d));
testST(beforeAD, -60, SysTime(DateTime(1999, 7, 6, 12, 30, 33), d));
testST(beforeAD, -75, SysTime(DateTime(1999, 7, 6, 12, 15, 33), d));
testST(beforeAD, -90, SysTime(DateTime(1999, 7, 6, 12, 0, 33), d));
testST(beforeAD, -100, SysTime(DateTime(1999, 7, 6, 12, 50, 33), d));
testST(beforeAD, -749, SysTime(DateTime(1999, 7, 6, 12, 1, 33), d));
testST(beforeAD, -750, SysTime(DateTime(1999, 7, 6, 12, 0, 33), d));
testST(beforeAD, -751, SysTime(DateTime(1999, 7, 6, 12, 59, 33), d));
testST(beforeAD, -960, SysTime(DateTime(1999, 7, 6, 12, 30, 33), d));
testST(beforeAD, -1439, SysTime(DateTime(1999, 7, 6, 12, 31, 33), d));
testST(beforeAD, -1440, SysTime(DateTime(1999, 7, 6, 12, 30, 33), d));
testST(beforeAD, -1441, SysTime(DateTime(1999, 7, 6, 12, 29, 33), d));
testST(beforeAD, -2880, SysTime(DateTime(1999, 7, 6, 12, 30, 33), d));
testST(SysTime(DateTime(1999, 7, 6, 12, 0, 33), d), 1, SysTime(DateTime(1999, 7, 6, 12, 1, 33), d));
testST(SysTime(DateTime(1999, 7, 6, 12, 0, 33), d), 0, SysTime(DateTime(1999, 7, 6, 12, 0, 33), d));
testST(SysTime(DateTime(1999, 7, 6, 12, 0, 33), d), -1, SysTime(DateTime(1999, 7, 6, 12, 59, 33), d));
testST(SysTime(DateTime(1999, 7, 6, 11, 59, 33), d), 1, SysTime(DateTime(1999, 7, 6, 11, 0, 33), d));
testST(SysTime(DateTime(1999, 7, 6, 11, 59, 33), d), 0, SysTime(DateTime(1999, 7, 6, 11, 59, 33), d));
testST(SysTime(DateTime(1999, 7, 6, 11, 59, 33), d), -1, SysTime(DateTime(1999, 7, 6, 11, 58, 33), d));
testST(SysTime(DateTime(1999, 7, 6, 0, 0, 33), d), 1, SysTime(DateTime(1999, 7, 6, 0, 1, 33), d));
testST(SysTime(DateTime(1999, 7, 6, 0, 0, 33), d), 0, SysTime(DateTime(1999, 7, 6, 0, 0, 33), d));
testST(SysTime(DateTime(1999, 7, 6, 0, 0, 33), d), -1, SysTime(DateTime(1999, 7, 6, 0, 59, 33), d));
testST(SysTime(DateTime(1999, 7, 5, 23, 59, 33), d), 1, SysTime(DateTime(1999, 7, 5, 23, 0, 33), d));
testST(SysTime(DateTime(1999, 7, 5, 23, 59, 33), d), 0, SysTime(DateTime(1999, 7, 5, 23, 59, 33), d));
testST(SysTime(DateTime(1999, 7, 5, 23, 59, 33), d), -1, SysTime(DateTime(1999, 7, 5, 23, 58, 33), d));
testST(SysTime(DateTime(1998, 12, 31, 23, 59, 33), d), 1, SysTime(DateTime(1998, 12, 31, 23, 0, 33), d));
testST(SysTime(DateTime(1998, 12, 31, 23, 59, 33), d), 0, SysTime(DateTime(1998, 12, 31, 23, 59, 33), d));
testST(SysTime(DateTime(1998, 12, 31, 23, 59, 33), d), -1, SysTime(DateTime(1998, 12, 31, 23, 58, 33), d));
//Test B.C.
auto beforeBC = SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d);
testST(beforeBC, 0, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d));
testST(beforeBC, 1, SysTime(DateTime(-1999, 7, 6, 12, 31, 33), d));
testST(beforeBC, 2, SysTime(DateTime(-1999, 7, 6, 12, 32, 33), d));
testST(beforeBC, 3, SysTime(DateTime(-1999, 7, 6, 12, 33, 33), d));
testST(beforeBC, 4, SysTime(DateTime(-1999, 7, 6, 12, 34, 33), d));
testST(beforeBC, 5, SysTime(DateTime(-1999, 7, 6, 12, 35, 33), d));
testST(beforeBC, 10, SysTime(DateTime(-1999, 7, 6, 12, 40, 33), d));
testST(beforeBC, 15, SysTime(DateTime(-1999, 7, 6, 12, 45, 33), d));
testST(beforeBC, 29, SysTime(DateTime(-1999, 7, 6, 12, 59, 33), d));
testST(beforeBC, 30, SysTime(DateTime(-1999, 7, 6, 12, 0, 33), d));
testST(beforeBC, 45, SysTime(DateTime(-1999, 7, 6, 12, 15, 33), d));
testST(beforeBC, 60, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d));
testST(beforeBC, 75, SysTime(DateTime(-1999, 7, 6, 12, 45, 33), d));
testST(beforeBC, 90, SysTime(DateTime(-1999, 7, 6, 12, 0, 33), d));
testST(beforeBC, 100, SysTime(DateTime(-1999, 7, 6, 12, 10, 33), d));
testST(beforeBC, 689, SysTime(DateTime(-1999, 7, 6, 12, 59, 33), d));
testST(beforeBC, 690, SysTime(DateTime(-1999, 7, 6, 12, 0, 33), d));
testST(beforeBC, 691, SysTime(DateTime(-1999, 7, 6, 12, 1, 33), d));
testST(beforeBC, 960, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d));
testST(beforeBC, 1439, SysTime(DateTime(-1999, 7, 6, 12, 29, 33), d));
testST(beforeBC, 1440, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d));
testST(beforeBC, 1441, SysTime(DateTime(-1999, 7, 6, 12, 31, 33), d));
testST(beforeBC, 2880, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d));
testST(beforeBC, -1, SysTime(DateTime(-1999, 7, 6, 12, 29, 33), d));
testST(beforeBC, -2, SysTime(DateTime(-1999, 7, 6, 12, 28, 33), d));
testST(beforeBC, -3, SysTime(DateTime(-1999, 7, 6, 12, 27, 33), d));
testST(beforeBC, -4, SysTime(DateTime(-1999, 7, 6, 12, 26, 33), d));
testST(beforeBC, -5, SysTime(DateTime(-1999, 7, 6, 12, 25, 33), d));
testST(beforeBC, -10, SysTime(DateTime(-1999, 7, 6, 12, 20, 33), d));
testST(beforeBC, -15, SysTime(DateTime(-1999, 7, 6, 12, 15, 33), d));
testST(beforeBC, -29, SysTime(DateTime(-1999, 7, 6, 12, 1, 33), d));
testST(beforeBC, -30, SysTime(DateTime(-1999, 7, 6, 12, 0, 33), d));
testST(beforeBC, -45, SysTime(DateTime(-1999, 7, 6, 12, 45, 33), d));
testST(beforeBC, -60, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d));
testST(beforeBC, -75, SysTime(DateTime(-1999, 7, 6, 12, 15, 33), d));
testST(beforeBC, -90, SysTime(DateTime(-1999, 7, 6, 12, 0, 33), d));
testST(beforeBC, -100, SysTime(DateTime(-1999, 7, 6, 12, 50, 33), d));
testST(beforeBC, -749, SysTime(DateTime(-1999, 7, 6, 12, 1, 33), d));
testST(beforeBC, -750, SysTime(DateTime(-1999, 7, 6, 12, 0, 33), d));
testST(beforeBC, -751, SysTime(DateTime(-1999, 7, 6, 12, 59, 33), d));
testST(beforeBC, -960, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d));
testST(beforeBC, -1439, SysTime(DateTime(-1999, 7, 6, 12, 31, 33), d));
testST(beforeBC, -1440, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d));
testST(beforeBC, -1441, SysTime(DateTime(-1999, 7, 6, 12, 29, 33), d));
testST(beforeBC, -2880, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d));
testST(SysTime(DateTime(-1999, 7, 6, 12, 0, 33), d), 1, SysTime(DateTime(-1999, 7, 6, 12, 1, 33), d));
testST(SysTime(DateTime(-1999, 7, 6, 12, 0, 33), d), 0, SysTime(DateTime(-1999, 7, 6, 12, 0, 33), d));
testST(SysTime(DateTime(-1999, 7, 6, 12, 0, 33), d), -1, SysTime(DateTime(-1999, 7, 6, 12, 59, 33), d));
testST(SysTime(DateTime(-1999, 7, 6, 11, 59, 33), d), 1, SysTime(DateTime(-1999, 7, 6, 11, 0, 33), d));
testST(SysTime(DateTime(-1999, 7, 6, 11, 59, 33), d), 0, SysTime(DateTime(-1999, 7, 6, 11, 59, 33), d));
testST(SysTime(DateTime(-1999, 7, 6, 11, 59, 33), d), -1, SysTime(DateTime(-1999, 7, 6, 11, 58, 33), d));
testST(SysTime(DateTime(-1999, 7, 6, 0, 0, 33), d), 1, SysTime(DateTime(-1999, 7, 6, 0, 1, 33), d));
testST(SysTime(DateTime(-1999, 7, 6, 0, 0, 33), d), 0, SysTime(DateTime(-1999, 7, 6, 0, 0, 33), d));
testST(SysTime(DateTime(-1999, 7, 6, 0, 0, 33), d), -1, SysTime(DateTime(-1999, 7, 6, 0, 59, 33), d));
testST(SysTime(DateTime(-1999, 7, 5, 23, 59, 33), d), 1, SysTime(DateTime(-1999, 7, 5, 23, 0, 33), d));
testST(SysTime(DateTime(-1999, 7, 5, 23, 59, 33), d), 0, SysTime(DateTime(-1999, 7, 5, 23, 59, 33), d));
testST(SysTime(DateTime(-1999, 7, 5, 23, 59, 33), d), -1, SysTime(DateTime(-1999, 7, 5, 23, 58, 33), d));
testST(SysTime(DateTime(-2000, 12, 31, 23, 59, 33), d), 1, SysTime(DateTime(-2000, 12, 31, 23, 0, 33), d));
testST(SysTime(DateTime(-2000, 12, 31, 23, 59, 33), d), 0, SysTime(DateTime(-2000, 12, 31, 23, 59, 33), d));
testST(SysTime(DateTime(-2000, 12, 31, 23, 59, 33), d), -1, SysTime(DateTime(-2000, 12, 31, 23, 58, 33), d));
//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), d), 1_052_760, SysTime(DateTime(-1, 1, 1, 11, 30, 33), d));
testST(SysTime(DateTime(1, 1, 1, 13, 30, 33), d), -1_052_760, SysTime(DateTime(1, 1, 1, 13, 30, 33), d));
testST(SysTime(DateTime(-1, 1, 1, 11, 30, 33), d), 1_052_782, SysTime(DateTime(-1, 1, 1, 11, 52, 33), d));
testST(SysTime(DateTime(1, 1, 1, 13, 52, 33), d), -1_052_782, SysTime(DateTime(1, 1, 1, 13, 30, 33), d));
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0));
sysTime.roll!"minutes"(-1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 59, 0)));
sysTime.roll!"minutes"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 0, 0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 59), hnsecs(9_999_999));
sysTime.roll!"minutes"(-1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 59, 59), hnsecs(9_999_999)));
sysTime.roll!"minutes"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 0, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 23, 59, 0));
sysTime.roll!"minutes"(1);
assert(sysTime == SysTime(DateTime(0, 12, 31, 23, 0, 0)));
sysTime.roll!"minutes"(-1);
assert(sysTime == SysTime(DateTime(0, 12, 31, 23, 59, 0)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999));
sysTime.roll!"minutes"(1);
assert(sysTime == SysTime(DateTime(0, 12, 31, 23, 0, 59), hnsecs(9_999_999)));
sysTime.roll!"minutes"(-1);
assert(sysTime == SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999));
sysTime.roll!"minutes"(1).roll!"minutes"(-79);
assert(sysTime == SysTime(DateTime(0, 12, 31, 23, 41, 59), 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
{
static void testST(SysTime orig, int seconds, in SysTime expected, size_t line = __LINE__)
{
import std.format : format;
orig.roll!"seconds"(seconds);
if(orig != expected)
throw new AssertError(format("Failed. actual [%s] != expected [%s]", orig, expected), __FILE__, line);
}
//Test A.D.
immutable d = msecs(274);
auto beforeAD = SysTime(DateTime(1999, 7, 6, 12, 30, 33), d);
testST(beforeAD, 0, SysTime(DateTime(1999, 7, 6, 12, 30, 33), d));
testST(beforeAD, 1, SysTime(DateTime(1999, 7, 6, 12, 30, 34), d));
testST(beforeAD, 2, SysTime(DateTime(1999, 7, 6, 12, 30, 35), d));
testST(beforeAD, 3, SysTime(DateTime(1999, 7, 6, 12, 30, 36), d));
testST(beforeAD, 4, SysTime(DateTime(1999, 7, 6, 12, 30, 37), d));
testST(beforeAD, 5, SysTime(DateTime(1999, 7, 6, 12, 30, 38), d));
testST(beforeAD, 10, SysTime(DateTime(1999, 7, 6, 12, 30, 43), d));
testST(beforeAD, 15, SysTime(DateTime(1999, 7, 6, 12, 30, 48), d));
testST(beforeAD, 26, SysTime(DateTime(1999, 7, 6, 12, 30, 59), d));
testST(beforeAD, 27, SysTime(DateTime(1999, 7, 6, 12, 30, 0), d));
testST(beforeAD, 30, SysTime(DateTime(1999, 7, 6, 12, 30, 3), d));
testST(beforeAD, 59, SysTime(DateTime(1999, 7, 6, 12, 30, 32), d));
testST(beforeAD, 60, SysTime(DateTime(1999, 7, 6, 12, 30, 33), d));
testST(beforeAD, 61, SysTime(DateTime(1999, 7, 6, 12, 30, 34), d));
testST(beforeAD, 1766, SysTime(DateTime(1999, 7, 6, 12, 30, 59), d));
testST(beforeAD, 1767, SysTime(DateTime(1999, 7, 6, 12, 30, 0), d));
testST(beforeAD, 1768, SysTime(DateTime(1999, 7, 6, 12, 30, 1), d));
testST(beforeAD, 2007, SysTime(DateTime(1999, 7, 6, 12, 30, 0), d));
testST(beforeAD, 3599, SysTime(DateTime(1999, 7, 6, 12, 30, 32), d));
testST(beforeAD, 3600, SysTime(DateTime(1999, 7, 6, 12, 30, 33), d));
testST(beforeAD, 3601, SysTime(DateTime(1999, 7, 6, 12, 30, 34), d));
testST(beforeAD, 7200, SysTime(DateTime(1999, 7, 6, 12, 30, 33), d));
testST(beforeAD, -1, SysTime(DateTime(1999, 7, 6, 12, 30, 32), d));
testST(beforeAD, -2, SysTime(DateTime(1999, 7, 6, 12, 30, 31), d));
testST(beforeAD, -3, SysTime(DateTime(1999, 7, 6, 12, 30, 30), d));
testST(beforeAD, -4, SysTime(DateTime(1999, 7, 6, 12, 30, 29), d));
testST(beforeAD, -5, SysTime(DateTime(1999, 7, 6, 12, 30, 28), d));
testST(beforeAD, -10, SysTime(DateTime(1999, 7, 6, 12, 30, 23), d));
testST(beforeAD, -15, SysTime(DateTime(1999, 7, 6, 12, 30, 18), d));
testST(beforeAD, -33, SysTime(DateTime(1999, 7, 6, 12, 30, 0), d));
testST(beforeAD, -34, SysTime(DateTime(1999, 7, 6, 12, 30, 59), d));
testST(beforeAD, -35, SysTime(DateTime(1999, 7, 6, 12, 30, 58), d));
testST(beforeAD, -59, SysTime(DateTime(1999, 7, 6, 12, 30, 34), d));
testST(beforeAD, -60, SysTime(DateTime(1999, 7, 6, 12, 30, 33), d));
testST(beforeAD, -61, SysTime(DateTime(1999, 7, 6, 12, 30, 32), d));
testST(SysTime(DateTime(1999, 7, 6, 12, 30, 0), d), 1, SysTime(DateTime(1999, 7, 6, 12, 30, 1), d));
testST(SysTime(DateTime(1999, 7, 6, 12, 30, 0), d), 0, SysTime(DateTime(1999, 7, 6, 12, 30, 0), d));
testST(SysTime(DateTime(1999, 7, 6, 12, 30, 0), d), -1, SysTime(DateTime(1999, 7, 6, 12, 30, 59), d));
testST(SysTime(DateTime(1999, 7, 6, 12, 0, 0), d), 1, SysTime(DateTime(1999, 7, 6, 12, 0, 1), d));
testST(SysTime(DateTime(1999, 7, 6, 12, 0, 0), d), 0, SysTime(DateTime(1999, 7, 6, 12, 0, 0), d));
testST(SysTime(DateTime(1999, 7, 6, 12, 0, 0), d), -1, SysTime(DateTime(1999, 7, 6, 12, 0, 59), d));
testST(SysTime(DateTime(1999, 7, 6, 0, 0, 0), d), 1, SysTime(DateTime(1999, 7, 6, 0, 0, 1), d));
testST(SysTime(DateTime(1999, 7, 6, 0, 0, 0), d), 0, SysTime(DateTime(1999, 7, 6, 0, 0, 0), d));
testST(SysTime(DateTime(1999, 7, 6, 0, 0, 0), d), -1, SysTime(DateTime(1999, 7, 6, 0, 0, 59), d));
testST(SysTime(DateTime(1999, 7, 5, 23, 59, 59), d), 1, SysTime(DateTime(1999, 7, 5, 23, 59, 0), d));
testST(SysTime(DateTime(1999, 7, 5, 23, 59, 59), d), 0, SysTime(DateTime(1999, 7, 5, 23, 59, 59), d));
testST(SysTime(DateTime(1999, 7, 5, 23, 59, 59), d), -1, SysTime(DateTime(1999, 7, 5, 23, 59, 58), d));
testST(SysTime(DateTime(1998, 12, 31, 23, 59, 59), d), 1, SysTime(DateTime(1998, 12, 31, 23, 59, 0), d));
testST(SysTime(DateTime(1998, 12, 31, 23, 59, 59), d), 0, SysTime(DateTime(1998, 12, 31, 23, 59, 59), d));
testST(SysTime(DateTime(1998, 12, 31, 23, 59, 59), d), -1, SysTime(DateTime(1998, 12, 31, 23, 59, 58), d));
//Test B.C.
auto beforeBC = SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d);
testST(beforeBC, 0, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d));
testST(beforeBC, 1, SysTime(DateTime(-1999, 7, 6, 12, 30, 34), d));
testST(beforeBC, 2, SysTime(DateTime(-1999, 7, 6, 12, 30, 35), d));
testST(beforeBC, 3, SysTime(DateTime(-1999, 7, 6, 12, 30, 36), d));
testST(beforeBC, 4, SysTime(DateTime(-1999, 7, 6, 12, 30, 37), d));
testST(beforeBC, 5, SysTime(DateTime(-1999, 7, 6, 12, 30, 38), d));
testST(beforeBC, 10, SysTime(DateTime(-1999, 7, 6, 12, 30, 43), d));
testST(beforeBC, 15, SysTime(DateTime(-1999, 7, 6, 12, 30, 48), d));
testST(beforeBC, 26, SysTime(DateTime(-1999, 7, 6, 12, 30, 59), d));
testST(beforeBC, 27, SysTime(DateTime(-1999, 7, 6, 12, 30, 0), d));
testST(beforeBC, 30, SysTime(DateTime(-1999, 7, 6, 12, 30, 3), d));
testST(beforeBC, 59, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), d));
testST(beforeBC, 60, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d));
testST(beforeBC, 61, SysTime(DateTime(-1999, 7, 6, 12, 30, 34), d));
testST(beforeBC, 1766, SysTime(DateTime(-1999, 7, 6, 12, 30, 59), d));
testST(beforeBC, 1767, SysTime(DateTime(-1999, 7, 6, 12, 30, 0), d));
testST(beforeBC, 1768, SysTime(DateTime(-1999, 7, 6, 12, 30, 1), d));
testST(beforeBC, 2007, SysTime(DateTime(-1999, 7, 6, 12, 30, 0), d));
testST(beforeBC, 3599, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), d));
testST(beforeBC, 3600, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d));
testST(beforeBC, 3601, SysTime(DateTime(-1999, 7, 6, 12, 30, 34), d));
testST(beforeBC, 7200, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d));
testST(beforeBC, -1, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), d));
testST(beforeBC, -2, SysTime(DateTime(-1999, 7, 6, 12, 30, 31), d));
testST(beforeBC, -3, SysTime(DateTime(-1999, 7, 6, 12, 30, 30), d));
testST(beforeBC, -4, SysTime(DateTime(-1999, 7, 6, 12, 30, 29), d));
testST(beforeBC, -5, SysTime(DateTime(-1999, 7, 6, 12, 30, 28), d));
testST(beforeBC, -10, SysTime(DateTime(-1999, 7, 6, 12, 30, 23), d));
testST(beforeBC, -15, SysTime(DateTime(-1999, 7, 6, 12, 30, 18), d));
testST(beforeBC, -33, SysTime(DateTime(-1999, 7, 6, 12, 30, 0), d));
testST(beforeBC, -34, SysTime(DateTime(-1999, 7, 6, 12, 30, 59), d));
testST(beforeBC, -35, SysTime(DateTime(-1999, 7, 6, 12, 30, 58), d));
testST(beforeBC, -59, SysTime(DateTime(-1999, 7, 6, 12, 30, 34), d));
testST(beforeBC, -60, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), d));
testST(beforeBC, -61, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), d));
testST(SysTime(DateTime(-1999, 7, 6, 12, 30, 0), d), 1, SysTime(DateTime(-1999, 7, 6, 12, 30, 1), d));
testST(SysTime(DateTime(-1999, 7, 6, 12, 30, 0), d), 0, SysTime(DateTime(-1999, 7, 6, 12, 30, 0), d));
testST(SysTime(DateTime(-1999, 7, 6, 12, 30, 0), d), -1, SysTime(DateTime(-1999, 7, 6, 12, 30, 59), d));
testST(SysTime(DateTime(-1999, 7, 6, 12, 0, 0), d), 1, SysTime(DateTime(-1999, 7, 6, 12, 0, 1), d));
testST(SysTime(DateTime(-1999, 7, 6, 12, 0, 0), d), 0, SysTime(DateTime(-1999, 7, 6, 12, 0, 0), d));
testST(SysTime(DateTime(-1999, 7, 6, 12, 0, 0), d), -1, SysTime(DateTime(-1999, 7, 6, 12, 0, 59), d));
testST(SysTime(DateTime(-1999, 7, 6, 0, 0, 0), d), 1, SysTime(DateTime(-1999, 7, 6, 0, 0, 1), d));
testST(SysTime(DateTime(-1999, 7, 6, 0, 0, 0), d), 0, SysTime(DateTime(-1999, 7, 6, 0, 0, 0), d));
testST(SysTime(DateTime(-1999, 7, 6, 0, 0, 0), d), -1, SysTime(DateTime(-1999, 7, 6, 0, 0, 59), d));
testST(SysTime(DateTime(-1999, 7, 5, 23, 59, 59), d), 1, SysTime(DateTime(-1999, 7, 5, 23, 59, 0), d));
testST(SysTime(DateTime(-1999, 7, 5, 23, 59, 59), d), 0, SysTime(DateTime(-1999, 7, 5, 23, 59, 59), d));
testST(SysTime(DateTime(-1999, 7, 5, 23, 59, 59), d), -1, SysTime(DateTime(-1999, 7, 5, 23, 59, 58), d));
testST(SysTime(DateTime(-2000, 12, 31, 23, 59, 59), d), 1, SysTime(DateTime(-2000, 12, 31, 23, 59, 0), d));
testST(SysTime(DateTime(-2000, 12, 31, 23, 59, 59), d), 0, SysTime(DateTime(-2000, 12, 31, 23, 59, 59), d));
testST(SysTime(DateTime(-2000, 12, 31, 23, 59, 59), d), -1, SysTime(DateTime(-2000, 12, 31, 23, 59, 58), d));
//Test Both
testST(SysTime(DateTime(1, 1, 1, 0, 0, 0), d), -1, SysTime(DateTime(1, 1, 1, 0, 0, 59), d));
testST(SysTime(DateTime(0, 12, 31, 23, 59, 59), d), 1, SysTime(DateTime(0, 12, 31, 23, 59, 0), d));
testST(SysTime(DateTime(0, 1, 1, 0, 0, 0), d), -1, SysTime(DateTime(0, 1, 1, 0, 0, 59), d));
testST(SysTime(DateTime(-1, 12, 31, 23, 59, 59), d), 1, SysTime(DateTime(-1, 12, 31, 23, 59, 0), d));
testST(SysTime(DateTime(-1, 1, 1, 11, 30, 33), d), 63_165_600L, SysTime(DateTime(-1, 1, 1, 11, 30, 33), d));
testST(SysTime(DateTime(1, 1, 1, 13, 30, 33), d), -63_165_600L, SysTime(DateTime(1, 1, 1, 13, 30, 33), d));
testST(SysTime(DateTime(-1, 1, 1, 11, 30, 33), d), 63_165_617L, SysTime(DateTime(-1, 1, 1, 11, 30, 50), d));
testST(SysTime(DateTime(1, 1, 1, 13, 30, 50), d), -63_165_617L, SysTime(DateTime(1, 1, 1, 13, 30, 33), d));
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0));
sysTime.roll!"seconds"(-1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 0, 59)));
sysTime.roll!"seconds"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 0, 0)));
}
{
auto sysTime = SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(9_999_999));
sysTime.roll!"seconds"(-1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 0, 59), hnsecs(9_999_999)));
sysTime.roll!"seconds"(1);
assert(sysTime == SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 23, 59, 59));
sysTime.roll!"seconds"(1);
assert(sysTime == SysTime(DateTime(0, 12, 31, 23, 59, 0)));
sysTime.roll!"seconds"(-1);
assert(sysTime == SysTime(DateTime(0, 12, 31, 23, 59, 59)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999));
sysTime.roll!"seconds"(1);
assert(sysTime == SysTime(DateTime(0, 12, 31, 23, 59, 0), hnsecs(9_999_999)));
sysTime.roll!"seconds"(-1);
assert(sysTime == SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)));
}
{
auto sysTime = SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999));
sysTime.roll!"seconds"(1).roll!"seconds"(-102);
assert(sysTime == SysTime(DateTime(0, 12, 31, 23, 59, 18), 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 roll(string units)(long value) @safe 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;
return this;
}
//Test roll!"msecs"().
unittest
{
static void testST(SysTime orig, int milliseconds, in SysTime expected, size_t line = __LINE__)
{
import std.format : format;
orig.roll!"msecs"(milliseconds);
if(orig != expected)
throw new AssertError(format("Failed. actual [%s] != expected [%s]", orig, expected), __FILE__, line);
}
//Test A.D.
auto beforeAD = SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(274));
testST(beforeAD, 0, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(274)));
testST(beforeAD, 1, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(275)));
testST(beforeAD, 2, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(276)));
testST(beforeAD, 10, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(284)));
testST(beforeAD, 100, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(374)));
testST(beforeAD, 725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(999)));
testST(beforeAD, 726, SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
testST(beforeAD, 1000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(274)));
testST(beforeAD, 1001, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(275)));
testST(beforeAD, 2000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(274)));
testST(beforeAD, 26_725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(999)));
testST(beforeAD, 26_726, SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
testST(beforeAD, 26_727, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(1)));
testST(beforeAD, 1_766_725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(999)));
testST(beforeAD, 1_766_726, SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
testST(beforeAD, -1, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(273)));
testST(beforeAD, -2, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(272)));
testST(beforeAD, -10, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(264)));
testST(beforeAD, -100, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(174)));
testST(beforeAD, -274, SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
testST(beforeAD, -275, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(999)));
testST(beforeAD, -1000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(274)));
testST(beforeAD, -1001, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(273)));
testST(beforeAD, -2000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(274)));
testST(beforeAD, -33_274, SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
testST(beforeAD, -33_275, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(999)));
testST(beforeAD, -1_833_274, SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
testST(beforeAD, -1_833_275, SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(999)));
//Test B.C.
auto beforeBC = SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(274));
testST(beforeBC, 0, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(274)));
testST(beforeBC, 1, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(275)));
testST(beforeBC, 2, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(276)));
testST(beforeBC, 10, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(284)));
testST(beforeBC, 100, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(374)));
testST(beforeBC, 725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(999)));
testST(beforeBC, 726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33)));
testST(beforeBC, 1000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(274)));
testST(beforeBC, 1001, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(275)));
testST(beforeBC, 2000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(274)));
testST(beforeBC, 26_725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(999)));
testST(beforeBC, 26_726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33)));
testST(beforeBC, 26_727, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(1)));
testST(beforeBC, 1_766_725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(999)));
testST(beforeBC, 1_766_726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33)));
testST(beforeBC, -1, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(273)));
testST(beforeBC, -2, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(272)));
testST(beforeBC, -10, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(264)));
testST(beforeBC, -100, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(174)));
testST(beforeBC, -274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33)));
testST(beforeBC, -275, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(999)));
testST(beforeBC, -1000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(274)));
testST(beforeBC, -1001, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(273)));
testST(beforeBC, -2000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(274)));
testST(beforeBC, -33_274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33)));
testST(beforeBC, -33_275, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(999)));
testST(beforeBC, -1_833_274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33)));
testST(beforeBC, -1_833_275, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), msecs(999)));
//Test Both
auto beforeBoth1 = SysTime(DateTime(1, 1, 1, 0, 0, 0));
testST(beforeBoth1, 1, SysTime(DateTime(1, 1, 1, 0, 0, 0), msecs(1)));
testST(beforeBoth1, 0, SysTime(DateTime(1, 1, 1, 0, 0, 0)));
testST(beforeBoth1, -1, SysTime(DateTime(1, 1, 1, 0, 0, 0), msecs(999)));
testST(beforeBoth1, -2, SysTime(DateTime(1, 1, 1, 0, 0, 0), msecs(998)));
testST(beforeBoth1, -1000, SysTime(DateTime(1, 1, 1, 0, 0, 0)));
testST(beforeBoth1, -2000, SysTime(DateTime(1, 1, 1, 0, 0, 0)));
testST(beforeBoth1, -2555, SysTime(DateTime(1, 1, 1, 0, 0, 0), msecs(445)));
auto beforeBoth2 = SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999));
testST(beforeBoth2, -1, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_989_999)));
testST(beforeBoth2, 0, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)));
testST(beforeBoth2, 1, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9999)));
testST(beforeBoth2, 2, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(19_999)));
testST(beforeBoth2, 1000, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)));
testST(beforeBoth2, 2000, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)));
testST(beforeBoth2, 2555, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(5_549_999)));
{
auto st = SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999));
st.roll!"msecs"(1202).roll!"msecs"(-703);
assert(st == SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(4_989_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
{
static void testST(SysTime orig, long microseconds, in SysTime expected, size_t line = __LINE__)
{
import std.format : format;
orig.roll!"usecs"(microseconds);
if(orig != expected)
throw new AssertError(format("Failed. actual [%s] != expected [%s]", orig, expected), __FILE__, line);
}
//Test A.D.
auto beforeAD = SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(274));
testST(beforeAD, 0, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(274)));
testST(beforeAD, 1, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(275)));
testST(beforeAD, 2, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(276)));
testST(beforeAD, 10, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(284)));
testST(beforeAD, 100, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(374)));
testST(beforeAD, 725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(999)));
testST(beforeAD, 726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(1000)));
testST(beforeAD, 1000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(1274)));
testST(beforeAD, 1001, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(1275)));
testST(beforeAD, 2000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(2274)));
testST(beforeAD, 26_725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(26_999)));
testST(beforeAD, 26_726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(27_000)));
testST(beforeAD, 26_727, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(27_001)));
testST(beforeAD, 1_766_725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(766_999)));
testST(beforeAD, 1_766_726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(767_000)));
testST(beforeAD, 1_000_000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(274)));
testST(beforeAD, 60_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(274)));
testST(beforeAD, 3_600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(274)));
testST(beforeAD, -1, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(273)));
testST(beforeAD, -2, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(272)));
testST(beforeAD, -10, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(264)));
testST(beforeAD, -100, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(174)));
testST(beforeAD, -274, SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
testST(beforeAD, -275, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(999_999)));
testST(beforeAD, -1000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(999_274)));
testST(beforeAD, -1001, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(999_273)));
testST(beforeAD, -2000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(998_274)));
testST(beforeAD, -33_274, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(967_000)));
testST(beforeAD, -33_275, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(966_999)));
testST(beforeAD, -1_833_274, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(167_000)));
testST(beforeAD, -1_833_275, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(166_999)));
testST(beforeAD, -1_000_000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(274)));
testST(beforeAD, -60_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(274)));
testST(beforeAD, -3_600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(274)));
//Test B.C.
auto beforeBC = SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(274));
testST(beforeBC, 0, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(274)));
testST(beforeBC, 1, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(275)));
testST(beforeBC, 2, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(276)));
testST(beforeBC, 10, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(284)));
testST(beforeBC, 100, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(374)));
testST(beforeBC, 725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(999)));
testST(beforeBC, 726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(1000)));
testST(beforeBC, 1000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(1274)));
testST(beforeBC, 1001, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(1275)));
testST(beforeBC, 2000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(2274)));
testST(beforeBC, 26_725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(26_999)));
testST(beforeBC, 26_726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(27_000)));
testST(beforeBC, 26_727, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(27_001)));
testST(beforeBC, 1_766_725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(766_999)));
testST(beforeBC, 1_766_726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(767_000)));
testST(beforeBC, 1_000_000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(274)));
testST(beforeBC, 60_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(274)));
testST(beforeBC, 3_600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(274)));
testST(beforeBC, -1, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(273)));
testST(beforeBC, -2, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(272)));
testST(beforeBC, -10, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(264)));
testST(beforeBC, -100, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(174)));
testST(beforeBC, -274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33)));
testST(beforeBC, -275, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(999_999)));
testST(beforeBC, -1000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(999_274)));
testST(beforeBC, -1001, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(999_273)));
testST(beforeBC, -2000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(998_274)));
testST(beforeBC, -33_274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(967_000)));
testST(beforeBC, -33_275, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(966_999)));
testST(beforeBC, -1_833_274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(167_000)));
testST(beforeBC, -1_833_275, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(166_999)));
testST(beforeBC, -1_000_000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(274)));
testST(beforeBC, -60_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(274)));
testST(beforeBC, -3_600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), usecs(274)));
//Test Both
auto beforeBoth1 = SysTime(DateTime(1, 1, 1, 0, 0, 0));
testST(beforeBoth1, 1, SysTime(DateTime(1, 1, 1, 0, 0, 0), usecs(1)));
testST(beforeBoth1, 0, SysTime(DateTime(1, 1, 1, 0, 0, 0)));
testST(beforeBoth1, -1, SysTime(DateTime(1, 1, 1, 0, 0, 0), usecs(999_999)));
testST(beforeBoth1, -2, SysTime(DateTime(1, 1, 1, 0, 0, 0), usecs(999_998)));
testST(beforeBoth1, -1000, SysTime(DateTime(1, 1, 1, 0, 0, 0), usecs(999_000)));
testST(beforeBoth1, -2000, SysTime(DateTime(1, 1, 1, 0, 0, 0), usecs(998_000)));
testST(beforeBoth1, -2555, SysTime(DateTime(1, 1, 1, 0, 0, 0), usecs(997_445)));
testST(beforeBoth1, -1_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0)));
testST(beforeBoth1, -2_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0)));
testST(beforeBoth1, -2_333_333, SysTime(DateTime(1, 1, 1, 0, 0, 0), usecs(666_667)));
auto beforeBoth2 = SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999));
testST(beforeBoth2, -1, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_989)));
testST(beforeBoth2, 0, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)));
testST(beforeBoth2, 1, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9)));
testST(beforeBoth2, 2, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(19)));
testST(beforeBoth2, 1000, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9999)));
testST(beforeBoth2, 2000, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(19_999)));
testST(beforeBoth2, 2555, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(25_549)));
testST(beforeBoth2, 1_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)));
testST(beforeBoth2, 2_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)));
testST(beforeBoth2, 2_333_333, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(3_333_329)));
{
auto st = SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999));
st.roll!"usecs"(9_020_027);
assert(st == SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(200_269)));
}
{
auto st = SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999));
st.roll!"usecs"(9_020_027).roll!"usecs"(-70_034);
assert(st == SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_499_929)));
}
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
{
static void testST(SysTime orig, long hnsecs, in SysTime expected, size_t line = __LINE__)
{
import std.format : format;
orig.roll!"hnsecs"(hnsecs);
if(orig != expected)
throw new AssertError(format("Failed. actual [%s] != expected [%s]", orig, expected), __FILE__, line);
}
//Test A.D.
auto dtAD = DateTime(1999, 7, 6, 12, 30, 33);
auto beforeAD = SysTime(dtAD, hnsecs(274));
testST(beforeAD, 0, SysTime(dtAD, hnsecs(274)));
testST(beforeAD, 1, SysTime(dtAD, hnsecs(275)));
testST(beforeAD, 2, SysTime(dtAD, hnsecs(276)));
testST(beforeAD, 10, SysTime(dtAD, hnsecs(284)));
testST(beforeAD, 100, SysTime(dtAD, hnsecs(374)));
testST(beforeAD, 725, SysTime(dtAD, hnsecs(999)));
testST(beforeAD, 726, SysTime(dtAD, hnsecs(1000)));
testST(beforeAD, 1000, SysTime(dtAD, hnsecs(1274)));
testST(beforeAD, 1001, SysTime(dtAD, hnsecs(1275)));
testST(beforeAD, 2000, SysTime(dtAD, hnsecs(2274)));
testST(beforeAD, 26_725, SysTime(dtAD, hnsecs(26_999)));
testST(beforeAD, 26_726, SysTime(dtAD, hnsecs(27_000)));
testST(beforeAD, 26_727, SysTime(dtAD, hnsecs(27_001)));
testST(beforeAD, 1_766_725, SysTime(dtAD, hnsecs(1_766_999)));
testST(beforeAD, 1_766_726, SysTime(dtAD, hnsecs(1_767_000)));
testST(beforeAD, 1_000_000, SysTime(dtAD, hnsecs(1_000_274)));
testST(beforeAD, 60_000_000L, SysTime(dtAD, hnsecs(274)));
testST(beforeAD, 3_600_000_000L, SysTime(dtAD, hnsecs(274)));
testST(beforeAD, 600_000_000L, SysTime(dtAD, hnsecs(274)));
testST(beforeAD, 36_000_000_000L, SysTime(dtAD, hnsecs(274)));
testST(beforeAD, -1, SysTime(dtAD, hnsecs(273)));
testST(beforeAD, -2, SysTime(dtAD, hnsecs(272)));
testST(beforeAD, -10, SysTime(dtAD, hnsecs(264)));
testST(beforeAD, -100, SysTime(dtAD, hnsecs(174)));
testST(beforeAD, -274, SysTime(dtAD));
testST(beforeAD, -275, SysTime(dtAD, hnsecs(9_999_999)));
testST(beforeAD, -1000, SysTime(dtAD, hnsecs(9_999_274)));
testST(beforeAD, -1001, SysTime(dtAD, hnsecs(9_999_273)));
testST(beforeAD, -2000, SysTime(dtAD, hnsecs(9_998_274)));
testST(beforeAD, -33_274, SysTime(dtAD, hnsecs(9_967_000)));
testST(beforeAD, -33_275, SysTime(dtAD, hnsecs(9_966_999)));
testST(beforeAD, -1_833_274, SysTime(dtAD, hnsecs(8_167_000)));
testST(beforeAD, -1_833_275, SysTime(dtAD, hnsecs(8_166_999)));
testST(beforeAD, -1_000_000, SysTime(dtAD, hnsecs(9_000_274)));
testST(beforeAD, -60_000_000L, SysTime(dtAD, hnsecs(274)));
testST(beforeAD, -3_600_000_000L, SysTime(dtAD, hnsecs(274)));
testST(beforeAD, -600_000_000L, SysTime(dtAD, hnsecs(274)));
testST(beforeAD, -36_000_000_000L, SysTime(dtAD, hnsecs(274)));
//Test B.C.
auto dtBC = DateTime(-1999, 7, 6, 12, 30, 33);
auto beforeBC = SysTime(dtBC, hnsecs(274));
testST(beforeBC, 0, SysTime(dtBC, hnsecs(274)));
testST(beforeBC, 1, SysTime(dtBC, hnsecs(275)));
testST(beforeBC, 2, SysTime(dtBC, hnsecs(276)));
testST(beforeBC, 10, SysTime(dtBC, hnsecs(284)));
testST(beforeBC, 100, SysTime(dtBC, hnsecs(374)));
testST(beforeBC, 725, SysTime(dtBC, hnsecs(999)));
testST(beforeBC, 726, SysTime(dtBC, hnsecs(1000)));
testST(beforeBC, 1000, SysTime(dtBC, hnsecs(1274)));
testST(beforeBC, 1001, SysTime(dtBC, hnsecs(1275)));
testST(beforeBC, 2000, SysTime(dtBC, hnsecs(2274)));
testST(beforeBC, 26_725, SysTime(dtBC, hnsecs(26_999)));
testST(beforeBC, 26_726, SysTime(dtBC, hnsecs(27_000)));
testST(beforeBC, 26_727, SysTime(dtBC, hnsecs(27_001)));
testST(beforeBC, 1_766_725, SysTime(dtBC, hnsecs(1_766_999)));
testST(beforeBC, 1_766_726, SysTime(dtBC, hnsecs(1_767_000)));
testST(beforeBC, 1_000_000, SysTime(dtBC, hnsecs(1_000_274)));
testST(beforeBC, 60_000_000L, SysTime(dtBC, hnsecs(274)));
testST(beforeBC, 3_600_000_000L, SysTime(dtBC, hnsecs(274)));
testST(beforeBC, 600_000_000L, SysTime(dtBC, hnsecs(274)));
testST(beforeBC, 36_000_000_000L, SysTime(dtBC, hnsecs(274)));
testST(beforeBC, -1, SysTime(dtBC, hnsecs(273)));
testST(beforeBC, -2, SysTime(dtBC, hnsecs(272)));
testST(beforeBC, -10, SysTime(dtBC, hnsecs(264)));
testST(beforeBC, -100, SysTime(dtBC, hnsecs(174)));
testST(beforeBC, -274, SysTime(dtBC));
testST(beforeBC, -275, SysTime(dtBC, hnsecs(9_999_999)));
testST(beforeBC, -1000, SysTime(dtBC, hnsecs(9_999_274)));
testST(beforeBC, -1001, SysTime(dtBC, hnsecs(9_999_273)));
testST(beforeBC, -2000, SysTime(dtBC, hnsecs(9_998_274)));
testST(beforeBC, -33_274, SysTime(dtBC, hnsecs(9_967_000)));
testST(beforeBC, -33_275, SysTime(dtBC, hnsecs(9_966_999)));
testST(beforeBC, -1_833_274, SysTime(dtBC, hnsecs(8_167_000)));
testST(beforeBC, -1_833_275, SysTime(dtBC, hnsecs(8_166_999)));
testST(beforeBC, -1_000_000, SysTime(dtBC, hnsecs(9_000_274)));
testST(beforeBC, -60_000_000L, SysTime(dtBC, hnsecs(274)));
testST(beforeBC, -3_600_000_000L, SysTime(dtBC, hnsecs(274)));
testST(beforeBC, -600_000_000L, SysTime(dtBC, hnsecs(274)));
testST(beforeBC, -36_000_000_000L, SysTime(dtBC, hnsecs(274)));
//Test Both
auto dtBoth1 = DateTime(1, 1, 1, 0, 0, 0);
auto beforeBoth1 = SysTime(dtBoth1);
testST(beforeBoth1, 1, SysTime(dtBoth1, hnsecs(1)));
testST(beforeBoth1, 0, SysTime(dtBoth1));
testST(beforeBoth1, -1, SysTime(dtBoth1, hnsecs(9_999_999)));
testST(beforeBoth1, -2, SysTime(dtBoth1, hnsecs(9_999_998)));
testST(beforeBoth1, -1000, SysTime(dtBoth1, hnsecs(9_999_000)));
testST(beforeBoth1, -2000, SysTime(dtBoth1, hnsecs(9_998_000)));
testST(beforeBoth1, -2555, SysTime(dtBoth1, hnsecs(9_997_445)));
testST(beforeBoth1, -1_000_000, SysTime(dtBoth1, hnsecs(9_000_000)));
testST(beforeBoth1, -2_000_000, SysTime(dtBoth1, hnsecs(8_000_000)));
testST(beforeBoth1, -2_333_333, SysTime(dtBoth1, hnsecs(7_666_667)));
testST(beforeBoth1, -10_000_000, SysTime(dtBoth1));
testST(beforeBoth1, -20_000_000, SysTime(dtBoth1));
testST(beforeBoth1, -20_888_888, SysTime(dtBoth1, hnsecs(9_111_112)));
auto dtBoth2 = DateTime(0, 12, 31, 23, 59, 59);
auto beforeBoth2 = SysTime(dtBoth2, hnsecs(9_999_999));
testST(beforeBoth2, -1, SysTime(dtBoth2, hnsecs(9_999_998)));
testST(beforeBoth2, 0, SysTime(dtBoth2, hnsecs(9_999_999)));
testST(beforeBoth2, 1, SysTime(dtBoth2));
testST(beforeBoth2, 2, SysTime(dtBoth2, hnsecs(1)));
testST(beforeBoth2, 1000, SysTime(dtBoth2, hnsecs(999)));
testST(beforeBoth2, 2000, SysTime(dtBoth2, hnsecs(1999)));
testST(beforeBoth2, 2555, SysTime(dtBoth2, hnsecs(2554)));
testST(beforeBoth2, 1_000_000, SysTime(dtBoth2, hnsecs(999_999)));
testST(beforeBoth2, 2_000_000, SysTime(dtBoth2, hnsecs(1_999_999)));
testST(beforeBoth2, 2_333_333, SysTime(dtBoth2, hnsecs(2_333_332)));
testST(beforeBoth2, 10_000_000, SysTime(dtBoth2, hnsecs(9_999_999)));
testST(beforeBoth2, 20_000_000, SysTime(dtBoth2, hnsecs(9_999_999)));
testST(beforeBoth2, 20_888_888, SysTime(dtBoth2, hnsecs(888_887)));
{
auto st = SysTime(dtBoth2, hnsecs(9_999_999));
st.roll!"hnsecs"(70_777_222).roll!"hnsecs"(-222_555_292);
assert(st == SysTime(dtBoth2, hnsecs(8_221_929)));
}
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
$(LREF SysTime).
The legal types of arithmetic for $(LREF 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
$(LREF SysTime).
+/
SysTime opBinary(string op, D)(in D duration) @safe const pure nothrow
if((op == "+" || op == "-") &&
(is(Unqual!D == Duration) ||
is(Unqual!D == TickDuration)))
{
import std.format : format;
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;
mixin(format("retval._stdTime %s= hnsecs;", op));
return retval;
}
unittest
{
auto st = SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(2_345_678));
assert(st + dur!"weeks"(7) == SysTime(DateTime(1999, 8, 24, 12, 30, 33), hnsecs(2_345_678)));
assert(st + dur!"weeks"(-7) == SysTime(DateTime(1999, 5, 18, 12, 30, 33), hnsecs(2_345_678)));
assert(st + dur!"days"(7) == SysTime(DateTime(1999, 7, 13, 12, 30, 33), hnsecs(2_345_678)));
assert(st + dur!"days"(-7) == SysTime(DateTime(1999, 6, 29, 12, 30, 33), hnsecs(2_345_678)));
assert(st + dur!"hours"(7) == SysTime(DateTime(1999, 7, 6, 19, 30, 33), hnsecs(2_345_678)));
assert(st + dur!"hours"(-7) == SysTime(DateTime(1999, 7, 6, 5, 30, 33), hnsecs(2_345_678)));
assert(st + dur!"minutes"(7) == SysTime(DateTime(1999, 7, 6, 12, 37, 33), hnsecs(2_345_678)));
assert(st + dur!"minutes"(-7) == SysTime(DateTime(1999, 7, 6, 12, 23, 33), hnsecs(2_345_678)));
assert(st + dur!"seconds"(7) == SysTime(DateTime(1999, 7, 6, 12, 30, 40), hnsecs(2_345_678)));
assert(st + dur!"seconds"(-7) == SysTime(DateTime(1999, 7, 6, 12, 30, 26), hnsecs(2_345_678)));
assert(st + dur!"msecs"(7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(2_415_678)));
assert(st + dur!"msecs"(-7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(2_275_678)));
assert(st + dur!"usecs"(7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(2_345_748)));
assert(st + dur!"usecs"(-7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(2_345_608)));
assert(st + dur!"hnsecs"(7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(2_345_685)));
assert(st + dur!"hnsecs"(-7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), 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)
{
assert(st + TickDuration.from!"usecs"(7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(2_345_748)));
assert(st + TickDuration.from!"usecs"(-7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(2_345_608)));
}
assert(st - dur!"weeks"(-7) == SysTime(DateTime(1999, 8, 24, 12, 30, 33), hnsecs(2_345_678)));
assert(st - dur!"weeks"(7) == SysTime(DateTime(1999, 5, 18, 12, 30, 33), hnsecs(2_345_678)));
assert(st - dur!"days"(-7) == SysTime(DateTime(1999, 7, 13, 12, 30, 33), hnsecs(2_345_678)));
assert(st - dur!"days"(7) == SysTime(DateTime(1999, 6, 29, 12, 30, 33), hnsecs(2_345_678)));
assert(st - dur!"hours"(-7) == SysTime(DateTime(1999, 7, 6, 19, 30, 33), hnsecs(2_345_678)));
assert(st - dur!"hours"(7) == SysTime(DateTime(1999, 7, 6, 5, 30, 33), hnsecs(2_345_678)));
assert(st - dur!"minutes"(-7) == SysTime(DateTime(1999, 7, 6, 12, 37, 33), hnsecs(2_345_678)));
assert(st - dur!"minutes"(7) == SysTime(DateTime(1999, 7, 6, 12, 23, 33), hnsecs(2_345_678)));
assert(st - dur!"seconds"(-7) == SysTime(DateTime(1999, 7, 6, 12, 30, 40), hnsecs(2_345_678)));
assert(st - dur!"seconds"(7) == SysTime(DateTime(1999, 7, 6, 12, 30, 26), hnsecs(2_345_678)));
assert(st - dur!"msecs"(-7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(2_415_678)));
assert(st - dur!"msecs"(7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(2_275_678)));
assert(st - dur!"usecs"(-7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(2_345_748)));
assert(st - dur!"usecs"(7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(2_345_608)));
assert(st - dur!"hnsecs"(-7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(2_345_685)));
assert(st - dur!"hnsecs"(7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), 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)
{
assert(st - TickDuration.from!"usecs"(-7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(2_345_748)));
assert(st - TickDuration.from!"usecs"(7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(2_345_608)));
}
static void testST(in SysTime orig, long hnsecs, in SysTime expected, size_t line = __LINE__)
{
import std.format : format;
auto result = orig + dur!"hnsecs"(hnsecs);
if(result != expected)
throw new AssertError(format("Failed. actual [%s] != expected [%s]", result, expected), __FILE__, line);
}
//Test A.D.
auto beforeAD = SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(274));
testST(beforeAD, 0, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(274)));
testST(beforeAD, 1, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(275)));
testST(beforeAD, 2, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(276)));
testST(beforeAD, 10, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(284)));
testST(beforeAD, 100, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(374)));
testST(beforeAD, 725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(999)));
testST(beforeAD, 726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(1000)));
testST(beforeAD, 1000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(1274)));
testST(beforeAD, 1001, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(1275)));
testST(beforeAD, 2000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(2274)));
testST(beforeAD, 26_725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(26_999)));
testST(beforeAD, 26_726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(27_000)));
testST(beforeAD, 26_727, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(27_001)));
testST(beforeAD, 1_766_725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(1_766_999)));
testST(beforeAD, 1_766_726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(1_767_000)));
testST(beforeAD, 1_000_000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(1_000_274)));
testST(beforeAD, 60_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 39), hnsecs(274)));
testST(beforeAD, 3_600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 36, 33), hnsecs(274)));
testST(beforeAD, 600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 31, 33), hnsecs(274)));
testST(beforeAD, 36_000_000_000L, SysTime(DateTime(1999, 7, 6, 13, 30, 33), hnsecs(274)));
testST(beforeAD, -1, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(273)));
testST(beforeAD, -2, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(272)));
testST(beforeAD, -10, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(264)));
testST(beforeAD, -100, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(174)));
testST(beforeAD, -274, SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
testST(beforeAD, -275, SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(9_999_999)));
testST(beforeAD, -1000, SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(9_999_274)));
testST(beforeAD, -1001, SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(9_999_273)));
testST(beforeAD, -2000, SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(9_998_274)));
testST(beforeAD, -33_274, SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(9_967_000)));
testST(beforeAD, -33_275, SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(9_966_999)));
testST(beforeAD, -1_833_274, SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(8_167_000)));
testST(beforeAD, -1_833_275, SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(8_166_999)));
testST(beforeAD, -1_000_000, SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(9_000_274)));
testST(beforeAD, -60_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 27), hnsecs(274)));
testST(beforeAD, -3_600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 24, 33), hnsecs(274)));
testST(beforeAD, -600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 29, 33), hnsecs(274)));
testST(beforeAD, -36_000_000_000L, SysTime(DateTime(1999, 7, 6, 11, 30, 33), hnsecs(274)));
//Test B.C.
auto beforeBC = SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(274));
testST(beforeBC, 0, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(274)));
testST(beforeBC, 1, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(275)));
testST(beforeBC, 2, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(276)));
testST(beforeBC, 10, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(284)));
testST(beforeBC, 100, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(374)));
testST(beforeBC, 725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(999)));
testST(beforeBC, 726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(1000)));
testST(beforeBC, 1000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(1274)));
testST(beforeBC, 1001, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(1275)));
testST(beforeBC, 2000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(2274)));
testST(beforeBC, 26_725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(26_999)));
testST(beforeBC, 26_726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(27_000)));
testST(beforeBC, 26_727, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(27_001)));
testST(beforeBC, 1_766_725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(1_766_999)));
testST(beforeBC, 1_766_726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(1_767_000)));
testST(beforeBC, 1_000_000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(1_000_274)));
testST(beforeBC, 60_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 39), hnsecs(274)));
testST(beforeBC, 3_600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 36, 33), hnsecs(274)));
testST(beforeBC, 600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 31, 33), hnsecs(274)));
testST(beforeBC, 36_000_000_000L, SysTime(DateTime(-1999, 7, 6, 13, 30, 33), hnsecs(274)));
testST(beforeBC, -1, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(273)));
testST(beforeBC, -2, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(272)));
testST(beforeBC, -10, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(264)));
testST(beforeBC, -100, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(174)));
testST(beforeBC, -274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33)));
testST(beforeBC, -275, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), hnsecs(9_999_999)));
testST(beforeBC, -1000, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), hnsecs(9_999_274)));
testST(beforeBC, -1001, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), hnsecs(9_999_273)));
testST(beforeBC, -2000, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), hnsecs(9_998_274)));
testST(beforeBC, -33_274, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), hnsecs(9_967_000)));
testST(beforeBC, -33_275, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), hnsecs(9_966_999)));
testST(beforeBC, -1_833_274, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), hnsecs(8_167_000)));
testST(beforeBC, -1_833_275, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), hnsecs(8_166_999)));
testST(beforeBC, -1_000_000, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), hnsecs(9_000_274)));
testST(beforeBC, -60_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 27), hnsecs(274)));
testST(beforeBC, -3_600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 24, 33), hnsecs(274)));
testST(beforeBC, -600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 29, 33), hnsecs(274)));
testST(beforeBC, -36_000_000_000L, SysTime(DateTime(-1999, 7, 6, 11, 30, 33), hnsecs(274)));
//Test Both
auto beforeBoth1 = SysTime(DateTime(1, 1, 1, 0, 0, 0));
testST(beforeBoth1, 1, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(1)));
testST(beforeBoth1, 0, SysTime(DateTime(1, 1, 1, 0, 0, 0)));
testST(beforeBoth1, -1, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)));
testST(beforeBoth1, -2, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_998)));
testST(beforeBoth1, -1000, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_000)));
testST(beforeBoth1, -2000, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_998_000)));
testST(beforeBoth1, -2555, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_997_445)));
testST(beforeBoth1, -1_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_000_000)));
testST(beforeBoth1, -2_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(8_000_000)));
testST(beforeBoth1, -2_333_333, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(7_666_667)));
testST(beforeBoth1, -10_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59)));
testST(beforeBoth1, -20_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 58)));
testST(beforeBoth1, -20_888_888, SysTime(DateTime(0, 12, 31, 23, 59, 57), hnsecs(9_111_112)));
auto beforeBoth2 = SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999));
testST(beforeBoth2, -1, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_998)));
testST(beforeBoth2, 0, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)));
testST(beforeBoth2, 1, SysTime(DateTime(1, 1, 1, 0, 0, 0)));
testST(beforeBoth2, 2, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(1)));
testST(beforeBoth2, 1000, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(999)));
testST(beforeBoth2, 2000, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(1999)));
testST(beforeBoth2, 2555, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(2554)));
testST(beforeBoth2, 1_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(999_999)));
testST(beforeBoth2, 2_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(1_999_999)));
testST(beforeBoth2, 2_333_333, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(2_333_332)));
testST(beforeBoth2, 10_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(9_999_999)));
testST(beforeBoth2, 20_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 1), hnsecs(9_999_999)));
testST(beforeBoth2, 20_888_888, SysTime(DateTime(1, 1, 1, 0, 0, 2), 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
$(LREF SysTime), as well as assigning the result to this $(LREF SysTime).
The legal types of arithmetic for $(LREF 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
$(LREF SysTime).
+/
ref SysTime opOpAssign(string op, D)(in D duration) @safe pure nothrow
if((op == "+" || op == "-") &&
(is(Unqual!D == Duration) ||
is(Unqual!D == TickDuration)))
{
import std.format : format;
static if(is(Unqual!D == Duration))
auto hnsecs = duration.total!"hnsecs";
else static if(is(Unqual!D == TickDuration))
auto hnsecs = duration.hnsecs;
mixin(format("_stdTime %s= hnsecs;", op));
return this;
}
unittest
{
auto before = SysTime(DateTime(1999, 7, 6, 12, 30, 33));
assert(before + dur!"weeks"(7) == SysTime(DateTime(1999, 8, 24, 12, 30, 33)));
assert(before + dur!"weeks"(-7) == SysTime(DateTime(1999, 5, 18, 12, 30, 33)));
assert(before + dur!"days"(7) == SysTime(DateTime(1999, 7, 13, 12, 30, 33)));
assert(before + dur!"days"(-7) == SysTime(DateTime(1999, 6, 29, 12, 30, 33)));
assert(before + dur!"hours"(7) == SysTime(DateTime(1999, 7, 6, 19, 30, 33)));
assert(before + dur!"hours"(-7) == SysTime(DateTime(1999, 7, 6, 5, 30, 33)));
assert(before + dur!"minutes"(7) == SysTime(DateTime(1999, 7, 6, 12, 37, 33)));
assert(before + dur!"minutes"(-7) == SysTime(DateTime(1999, 7, 6, 12, 23, 33)));
assert(before + dur!"seconds"(7) == SysTime(DateTime(1999, 7, 6, 12, 30, 40)));
assert(before + dur!"seconds"(-7) == SysTime(DateTime(1999, 7, 6, 12, 30, 26)));
assert(before + dur!"msecs"(7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(7)));
assert(before + dur!"msecs"(-7) == SysTime(DateTime(1999, 7, 6, 12, 30, 32), msecs(993)));
assert(before + dur!"usecs"(7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(7)));
assert(before + dur!"usecs"(-7) == SysTime(DateTime(1999, 7, 6, 12, 30, 32), usecs(999_993)));
assert(before + dur!"hnsecs"(7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(7)));
assert(before + dur!"hnsecs"(-7) == SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(9_999_993)));
assert(before - dur!"weeks"(-7) == SysTime(DateTime(1999, 8, 24, 12, 30, 33)));
assert(before - dur!"weeks"(7) == SysTime(DateTime(1999, 5, 18, 12, 30, 33)));
assert(before - dur!"days"(-7) == SysTime(DateTime(1999, 7, 13, 12, 30, 33)));
assert(before - dur!"days"(7) == SysTime(DateTime(1999, 6, 29, 12, 30, 33)));
assert(before - dur!"hours"(-7) == SysTime(DateTime(1999, 7, 6, 19, 30, 33)));
assert(before - dur!"hours"(7) == SysTime(DateTime(1999, 7, 6, 5, 30, 33)));
assert(before - dur!"minutes"(-7) == SysTime(DateTime(1999, 7, 6, 12, 37, 33)));
assert(before - dur!"minutes"(7) == SysTime(DateTime(1999, 7, 6, 12, 23, 33)));
assert(before - dur!"seconds"(-7) == SysTime(DateTime(1999, 7, 6, 12, 30, 40)));
assert(before - dur!"seconds"(7) == SysTime(DateTime(1999, 7, 6, 12, 30, 26)));
assert(before - dur!"msecs"(-7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), msecs(7)));
assert(before - dur!"msecs"(7) == SysTime(DateTime(1999, 7, 6, 12, 30, 32), msecs(993)));
assert(before - dur!"usecs"(-7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), usecs(7)));
assert(before - dur!"usecs"(7) == SysTime(DateTime(1999, 7, 6, 12, 30, 32), usecs(999_993)));
assert(before - dur!"hnsecs"(-7) == SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(7)));
assert(before - dur!"hnsecs"(7) == SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(9_999_993)));
static void testST(SysTime orig, long hnsecs, in SysTime expected, size_t line = __LINE__)
{
import std.format : format;
auto r = orig += dur!"hnsecs"(hnsecs);
if(orig != expected)
throw new AssertError(format("Failed 1. actual [%s] != expected [%s]", orig, expected), __FILE__, line);
if(r != expected)
throw new AssertError(format("Failed 2. actual [%s] != expected [%s]", r, expected), __FILE__, line);
}
//Test A.D.
auto beforeAD = SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(274));
testST(beforeAD, 0, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(274)));
testST(beforeAD, 1, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(275)));
testST(beforeAD, 2, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(276)));
testST(beforeAD, 10, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(284)));
testST(beforeAD, 100, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(374)));
testST(beforeAD, 725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(999)));
testST(beforeAD, 726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(1000)));
testST(beforeAD, 1000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(1274)));
testST(beforeAD, 1001, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(1275)));
testST(beforeAD, 2000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(2274)));
testST(beforeAD, 26_725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(26_999)));
testST(beforeAD, 26_726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(27_000)));
testST(beforeAD, 26_727, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(27_001)));
testST(beforeAD, 1_766_725, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(1_766_999)));
testST(beforeAD, 1_766_726, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(1_767_000)));
testST(beforeAD, 1_000_000, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(1_000_274)));
testST(beforeAD, 60_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 39), hnsecs(274)));
testST(beforeAD, 3_600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 36, 33), hnsecs(274)));
testST(beforeAD, 600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 31, 33), hnsecs(274)));
testST(beforeAD, 36_000_000_000L, SysTime(DateTime(1999, 7, 6, 13, 30, 33), hnsecs(274)));
testST(beforeAD, -1, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(273)));
testST(beforeAD, -2, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(272)));
testST(beforeAD, -10, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(264)));
testST(beforeAD, -100, SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(174)));
testST(beforeAD, -274, SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
testST(beforeAD, -275, SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(9_999_999)));
testST(beforeAD, -1000, SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(9_999_274)));
testST(beforeAD, -1001, SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(9_999_273)));
testST(beforeAD, -2000, SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(9_998_274)));
testST(beforeAD, -33_274, SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(9_967_000)));
testST(beforeAD, -33_275, SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(9_966_999)));
testST(beforeAD, -1_833_274, SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(8_167_000)));
testST(beforeAD, -1_833_275, SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(8_166_999)));
testST(beforeAD, -1_000_000, SysTime(DateTime(1999, 7, 6, 12, 30, 32), hnsecs(9_000_274)));
testST(beforeAD, -60_000_000L, SysTime(DateTime(1999, 7, 6, 12, 30, 27), hnsecs(274)));
testST(beforeAD, -3_600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 24, 33), hnsecs(274)));
testST(beforeAD, -600_000_000L, SysTime(DateTime(1999, 7, 6, 12, 29, 33), hnsecs(274)));
testST(beforeAD, -36_000_000_000L, SysTime(DateTime(1999, 7, 6, 11, 30, 33), hnsecs(274)));
//Test B.C.
auto beforeBC = SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(274));
testST(beforeBC, 0, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(274)));
testST(beforeBC, 1, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(275)));
testST(beforeBC, 2, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(276)));
testST(beforeBC, 10, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(284)));
testST(beforeBC, 100, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(374)));
testST(beforeBC, 725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(999)));
testST(beforeBC, 726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(1000)));
testST(beforeBC, 1000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(1274)));
testST(beforeBC, 1001, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(1275)));
testST(beforeBC, 2000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(2274)));
testST(beforeBC, 26_725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(26_999)));
testST(beforeBC, 26_726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(27_000)));
testST(beforeBC, 26_727, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(27_001)));
testST(beforeBC, 1_766_725, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(1_766_999)));
testST(beforeBC, 1_766_726, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(1_767_000)));
testST(beforeBC, 1_000_000, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(1_000_274)));
testST(beforeBC, 60_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 39), hnsecs(274)));
testST(beforeBC, 3_600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 36, 33), hnsecs(274)));
testST(beforeBC, 600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 31, 33), hnsecs(274)));
testST(beforeBC, 36_000_000_000L, SysTime(DateTime(-1999, 7, 6, 13, 30, 33), hnsecs(274)));
testST(beforeBC, -1, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(273)));
testST(beforeBC, -2, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(272)));
testST(beforeBC, -10, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(264)));
testST(beforeBC, -100, SysTime(DateTime(-1999, 7, 6, 12, 30, 33), hnsecs(174)));
testST(beforeBC, -274, SysTime(DateTime(-1999, 7, 6, 12, 30, 33)));
testST(beforeBC, -275, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), hnsecs(9_999_999)));
testST(beforeBC, -1000, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), hnsecs(9_999_274)));
testST(beforeBC, -1001, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), hnsecs(9_999_273)));
testST(beforeBC, -2000, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), hnsecs(9_998_274)));
testST(beforeBC, -33_274, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), hnsecs(9_967_000)));
testST(beforeBC, -33_275, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), hnsecs(9_966_999)));
testST(beforeBC, -1_833_274, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), hnsecs(8_167_000)));
testST(beforeBC, -1_833_275, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), hnsecs(8_166_999)));
testST(beforeBC, -1_000_000, SysTime(DateTime(-1999, 7, 6, 12, 30, 32), hnsecs(9_000_274)));
testST(beforeBC, -60_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 30, 27), hnsecs(274)));
testST(beforeBC, -3_600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 24, 33), hnsecs(274)));
testST(beforeBC, -600_000_000L, SysTime(DateTime(-1999, 7, 6, 12, 29, 33), hnsecs(274)));
testST(beforeBC, -36_000_000_000L, SysTime(DateTime(-1999, 7, 6, 11, 30, 33), hnsecs(274)));
//Test Both
auto beforeBoth1 = SysTime(DateTime(1, 1, 1, 0, 0, 0));
testST(beforeBoth1, 1, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(1)));
testST(beforeBoth1, 0, SysTime(DateTime(1, 1, 1, 0, 0, 0)));
testST(beforeBoth1, -1, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)));
testST(beforeBoth1, -2, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_998)));
testST(beforeBoth1, -1000, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_000)));
testST(beforeBoth1, -2000, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_998_000)));
testST(beforeBoth1, -2555, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_997_445)));
testST(beforeBoth1, -1_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_000_000)));
testST(beforeBoth1, -2_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(8_000_000)));
testST(beforeBoth1, -2_333_333, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(7_666_667)));
testST(beforeBoth1, -10_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 59)));
testST(beforeBoth1, -20_000_000, SysTime(DateTime(0, 12, 31, 23, 59, 58)));
testST(beforeBoth1, -20_888_888, SysTime(DateTime(0, 12, 31, 23, 59, 57), hnsecs(9_111_112)));
auto beforeBoth2 = SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999));
testST(beforeBoth2, -1, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_998)));
testST(beforeBoth2, 0, SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)));
testST(beforeBoth2, 1, SysTime(DateTime(1, 1, 1, 0, 0, 0)));
testST(beforeBoth2, 2, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(1)));
testST(beforeBoth2, 1000, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(999)));
testST(beforeBoth2, 2000, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(1999)));
testST(beforeBoth2, 2555, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(2554)));
testST(beforeBoth2, 1_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(999_999)));
testST(beforeBoth2, 2_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(1_999_999)));
testST(beforeBoth2, 2_333_333, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(2_333_332)));
testST(beforeBoth2, 10_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(9_999_999)));
testST(beforeBoth2, 20_000_000, SysTime(DateTime(1, 1, 1, 0, 0, 1), hnsecs(9_999_999)));
testST(beforeBoth2, 20_888_888, SysTime(DateTime(1, 1, 1, 0, 0, 2), hnsecs(888_887)));
{
auto st = SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999));
(st += dur!"hnsecs"(52)) += dur!"seconds"(-907);
assert(st == SysTime(DateTime(0, 12, 31, 23, 44, 53), hnsecs(51)));
}
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 $(LREF SysTime)s.
The legal types of arithmetic for $(LREF SysTime) using this operator are
$(BOOKTABLE,
$(TR $(TD SysTime) $(TD -) $(TD SysTime) $(TD -->) $(TD duration))
)
+/
Duration opBinary(string op)(in SysTime rhs) @safe const pure nothrow
if(op == "-")
{
return dur!"hnsecs"(_stdTime - rhs._stdTime);
}
unittest
{
assert(SysTime(DateTime(1999, 7, 6, 12, 30, 33)) - SysTime(DateTime(1998, 7, 6, 12, 30, 33)) ==
dur!"seconds"(31_536_000));
assert(SysTime(DateTime(1998, 7, 6, 12, 30, 33)) - SysTime(DateTime(1999, 7, 6, 12, 30, 33)) ==
dur!"seconds"(-31_536_000));
assert(SysTime(DateTime(1999, 8, 6, 12, 30, 33)) - SysTime(DateTime(1999, 7, 6, 12, 30, 33)) ==
dur!"seconds"(26_78_400));
assert(SysTime(DateTime(1999, 7, 6, 12, 30, 33)) - SysTime(DateTime(1999, 8, 6, 12, 30, 33)) ==
dur!"seconds"(-26_78_400));
assert(SysTime(DateTime(1999, 7, 6, 12, 30, 33)) - SysTime(DateTime(1999, 7, 5, 12, 30, 33)) ==
dur!"seconds"(86_400));
assert(SysTime(DateTime(1999, 7, 5, 12, 30, 33)) - SysTime(DateTime(1999, 7, 6, 12, 30, 33)) ==
dur!"seconds"(-86_400));
assert(SysTime(DateTime(1999, 7, 6, 12, 30, 33)) - SysTime(DateTime(1999, 7, 6, 11, 30, 33)) ==
dur!"seconds"(3600));
assert(SysTime(DateTime(1999, 7, 6, 11, 30, 33)) - SysTime(DateTime(1999, 7, 6, 12, 30, 33)) ==
dur!"seconds"(-3600));
assert(SysTime(DateTime(1999, 7, 6, 12, 31, 33)) - SysTime(DateTime(1999, 7, 6, 12, 30, 33)) ==
dur!"seconds"(60));
assert(SysTime(DateTime(1999, 7, 6, 12, 30, 33)) - SysTime(DateTime(1999, 7, 6, 12, 31, 33)) ==
dur!"seconds"(-60));
assert(SysTime(DateTime(1999, 7, 6, 12, 30, 34)) - SysTime(DateTime(1999, 7, 6, 12, 30, 33)) ==
dur!"seconds"(1));
assert(SysTime(DateTime(1999, 7, 6, 12, 30, 33)) - SysTime(DateTime(1999, 7, 6, 12, 30, 34)) ==
dur!"seconds"(-1));
{
auto dt = DateTime(1999, 7, 6, 12, 30, 33);
assert(SysTime(dt, msecs(532)) - SysTime(dt) == msecs(532));
assert(SysTime(dt) - SysTime(dt, msecs(532)) == msecs(-532));
assert(SysTime(dt, usecs(333_347)) - SysTime(dt) == usecs(333_347));
assert(SysTime(dt) - SysTime(dt, usecs(333_347)) == usecs(-333_347));
assert(SysTime(dt, hnsecs(1_234_567)) - SysTime(dt) == hnsecs(1_234_567));
assert(SysTime(dt) - SysTime(dt, hnsecs(1_234_567)) == hnsecs(-1_234_567));
}
assert(SysTime(DateTime(1, 1, 1, 12, 30, 33)) - SysTime(DateTime(1, 1, 1, 0, 0, 0)) == dur!"seconds"(45033));
assert(SysTime(DateTime(1, 1, 1, 0, 0, 0)) - SysTime(DateTime(1, 1, 1, 12, 30, 33)) == dur!"seconds"(-45033));
assert(SysTime(DateTime(0, 12, 31, 12, 30, 33)) - SysTime(DateTime(1, 1, 1, 0, 0, 0)) == dur!"seconds"(-41367));
assert(SysTime(DateTime(1, 1, 1, 0, 0, 0)) - SysTime(DateTime(0, 12, 31, 12, 30, 33)) == dur!"seconds"(41367));
assert(SysTime(DateTime(1, 1, 1, 0, 0, 0)) - SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)) ==
dur!"hnsecs"(1));
assert(SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)) - SysTime(DateTime(1, 1, 1, 0, 0, 0)) ==
dur!"hnsecs"(-1));
auto tz = TimeZone.getTimeZone("America/Los_Angeles");
{
auto dt = DateTime(2011, 1, 13, 8, 17, 2);
auto d = msecs(296);
assert(SysTime(dt, d, tz) - SysTime(dt, d, tz) == Duration.zero);
assert(SysTime(dt, d, tz) - SysTime(dt, d, UTC()) == hours(8));
assert(SysTime(dt, d, UTC()) - SysTime(dt, d, tz) == 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 $(LREF SysTime)s in months.
To get the difference in years, subtract the year property
of two $(LREF SysTime)s. To get the difference in days or weeks,
subtract the $(LREF SysTime)s themselves and use the $(CXREF time, Duration)
that results. Because converting between months and smaller
units requires a specific date (which $(CXREF time, 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 $(LREF SysTime) to subtract from this one.
+/
int diffMonths(in SysTime rhs) @safe const nothrow
{
return (cast(Date)this).diffMonths(cast(Date)rhs);
}
///
unittest
{
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);
}
unittest
{
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)));
}
/++
Whether this $(LREF SysTime) is in a leap year.
+/
@property bool isLeapYear() @safe const nothrow
{
return (cast(Date)this).isLeapYear;
}
unittest
{
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 $(LREF SysTime) is on.
+/
@property DayOfWeek dayOfWeek() @safe const nothrow
{
return getDayOfWeek(dayOfGregorianCal);
}
unittest
{
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 $(LREF SysTime) is on.
+/
@property ushort dayOfYear() @safe const nothrow
{
return (cast(Date)this).dayOfYear;
}
///
unittest
{
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);
}
unittest
{
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));
}
/++
Day of the year.
Params:
day = The day of the year to set which day of the year this
$(LREF SysTime) is on.
+/
@property void dayOfYear(int day) @safe
{
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
{
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 $(LREF SysTime) is on.
+/
@property int dayOfGregorianCal() @safe 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
{
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);
}
unittest
{
//Test A.D.
assert(SysTime(DateTime(1, 1, 1, 0, 0, 0)).dayOfGregorianCal == 1);
assert(SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(1)).dayOfGregorianCal == 1);
assert(SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999)).dayOfGregorianCal == 1);
assert(SysTime(DateTime(1, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 1);
assert(SysTime(DateTime(1, 1, 2, 12, 2, 9), msecs(212)).dayOfGregorianCal == 2);
assert(SysTime(DateTime(1, 2, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 32);
assert(SysTime(DateTime(2, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 366);
assert(SysTime(DateTime(3, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 731);
assert(SysTime(DateTime(4, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 1096);
assert(SysTime(DateTime(5, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 1462);
assert(SysTime(DateTime(50, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 17_898);
assert(SysTime(DateTime(97, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 35_065);
assert(SysTime(DateTime(100, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 36_160);
assert(SysTime(DateTime(101, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 36_525);
assert(SysTime(DateTime(105, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 37_986);
assert(SysTime(DateTime(200, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 72_684);
assert(SysTime(DateTime(201, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 73_049);
assert(SysTime(DateTime(300, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 109_208);
assert(SysTime(DateTime(301, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 109_573);
assert(SysTime(DateTime(400, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 145_732);
assert(SysTime(DateTime(401, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 146_098);
assert(SysTime(DateTime(500, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 182_257);
assert(SysTime(DateTime(501, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 182_622);
assert(SysTime(DateTime(1000, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 364_878);
assert(SysTime(DateTime(1001, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 365_243);
assert(SysTime(DateTime(1600, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 584_023);
assert(SysTime(DateTime(1601, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 584_389);
assert(SysTime(DateTime(1900, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 693_596);
assert(SysTime(DateTime(1901, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 693_961);
assert(SysTime(DateTime(1945, 11, 12, 12, 2, 9), msecs(212)).dayOfGregorianCal == 710_347);
assert(SysTime(DateTime(1999, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 729_755);
assert(SysTime(DateTime(2000, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 730_120);
assert(SysTime(DateTime(2001, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == 730_486);
assert(SysTime(DateTime(2010, 1, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == 733_773);
assert(SysTime(DateTime(2010, 1, 31, 23, 59, 59), msecs(999)).dayOfGregorianCal == 733_803);
assert(SysTime(DateTime(2010, 2, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == 733_804);
assert(SysTime(DateTime(2010, 2, 28, 23, 59, 59), msecs(999)).dayOfGregorianCal == 733_831);
assert(SysTime(DateTime(2010, 3, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == 733_832);
assert(SysTime(DateTime(2010, 3, 31, 23, 59, 59), msecs(999)).dayOfGregorianCal == 733_862);
assert(SysTime(DateTime(2010, 4, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == 733_863);
assert(SysTime(DateTime(2010, 4, 30, 23, 59, 59), msecs(999)).dayOfGregorianCal == 733_892);
assert(SysTime(DateTime(2010, 5, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == 733_893);
assert(SysTime(DateTime(2010, 5, 31, 23, 59, 59), msecs(999)).dayOfGregorianCal == 733_923);
assert(SysTime(DateTime(2010, 6, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == 733_924);
assert(SysTime(DateTime(2010, 6, 30, 23, 59, 59), msecs(999)).dayOfGregorianCal == 733_953);
assert(SysTime(DateTime(2010, 7, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == 733_954);
assert(SysTime(DateTime(2010, 7, 31, 23, 59, 59), msecs(999)).dayOfGregorianCal == 733_984);
assert(SysTime(DateTime(2010, 8, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == 733_985);
assert(SysTime(DateTime(2010, 8, 31, 23, 59, 59), msecs(999)).dayOfGregorianCal == 734_015);
assert(SysTime(DateTime(2010, 9, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == 734_016);
assert(SysTime(DateTime(2010, 9, 30, 23, 59, 59), msecs(999)).dayOfGregorianCal == 734_045);
assert(SysTime(DateTime(2010, 10, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == 734_046);
assert(SysTime(DateTime(2010, 10, 31, 23, 59, 59), msecs(999)).dayOfGregorianCal == 734_076);
assert(SysTime(DateTime(2010, 11, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == 734_077);
assert(SysTime(DateTime(2010, 11, 30, 23, 59, 59), msecs(999)).dayOfGregorianCal == 734_106);
assert(SysTime(DateTime(2010, 12, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == 734_107);
assert(SysTime(DateTime(2010, 12, 31, 23, 59, 59), msecs(999)).dayOfGregorianCal == 734_137);
assert(SysTime(DateTime(2012, 2, 1, 0, 0, 0)).dayOfGregorianCal == 734_534);
assert(SysTime(DateTime(2012, 2, 28, 0, 0, 0)).dayOfGregorianCal == 734_561);
assert(SysTime(DateTime(2012, 2, 29, 0, 0, 0)).dayOfGregorianCal == 734_562);
assert(SysTime(DateTime(2012, 3, 1, 0, 0, 0)).dayOfGregorianCal == 734_563);
//Test B.C.
assert(SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)).dayOfGregorianCal == 0);
assert(SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_998)).dayOfGregorianCal == 0);
assert(SysTime(DateTime(0, 12, 31, 23, 59, 59)).dayOfGregorianCal == 0);
assert(SysTime(DateTime(0, 12, 31, 0, 0, 0), hnsecs(1)).dayOfGregorianCal == 0);
assert(SysTime(DateTime(0, 12, 31, 0, 0, 0)).dayOfGregorianCal == 0);
assert(SysTime(DateTime(-1, 12, 31, 23, 59, 59), hnsecs(9_999_999)).dayOfGregorianCal == -366);
assert(SysTime(DateTime(-1, 12, 31, 23, 59, 59), hnsecs(9_999_998)).dayOfGregorianCal == -366);
assert(SysTime(DateTime(-1, 12, 31, 23, 59, 59)).dayOfGregorianCal == -366);
assert(SysTime(DateTime(-1, 12, 31, 0, 0, 0)).dayOfGregorianCal == -366);
assert(SysTime(DateTime(0, 12, 31, 12, 2, 9), msecs(212)).dayOfGregorianCal == 0);
assert(SysTime(DateTime(0, 12, 30, 12, 2, 9), msecs(212)).dayOfGregorianCal == -1);
assert(SysTime(DateTime(0, 12, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -30);
assert(SysTime(DateTime(0, 11, 30, 12, 2, 9), msecs(212)).dayOfGregorianCal == -31);
assert(SysTime(DateTime(-1, 12, 31, 12, 2, 9), msecs(212)).dayOfGregorianCal == -366);
assert(SysTime(DateTime(-1, 12, 30, 12, 2, 9), msecs(212)).dayOfGregorianCal == -367);
assert(SysTime(DateTime(-1, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -730);
assert(SysTime(DateTime(-2, 12, 31, 12, 2, 9), msecs(212)).dayOfGregorianCal == -731);
assert(SysTime(DateTime(-2, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -1095);
assert(SysTime(DateTime(-3, 12, 31, 12, 2, 9), msecs(212)).dayOfGregorianCal == -1096);
assert(SysTime(DateTime(-3, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -1460);
assert(SysTime(DateTime(-4, 12, 31, 12, 2, 9), msecs(212)).dayOfGregorianCal == -1461);
assert(SysTime(DateTime(-4, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -1826);
assert(SysTime(DateTime(-5, 12, 31, 12, 2, 9), msecs(212)).dayOfGregorianCal == -1827);
assert(SysTime(DateTime(-5, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -2191);
assert(SysTime(DateTime(-9, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -3652);
assert(SysTime(DateTime(-49, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -18_262);
assert(SysTime(DateTime(-50, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -18_627);
assert(SysTime(DateTime(-97, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -35_794);
assert(SysTime(DateTime(-99, 12, 31, 12, 2, 9), msecs(212)).dayOfGregorianCal == -36_160);
assert(SysTime(DateTime(-99, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -36_524);
assert(SysTime(DateTime(-100, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -36_889);
assert(SysTime(DateTime(-101, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -37_254);
assert(SysTime(DateTime(-105, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -38_715);
assert(SysTime(DateTime(-200, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -73_413);
assert(SysTime(DateTime(-201, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -73_778);
assert(SysTime(DateTime(-300, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -109_937);
assert(SysTime(DateTime(-301, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -110_302);
assert(SysTime(DateTime(-400, 12, 31, 12, 2, 9), msecs(212)).dayOfGregorianCal == -146_097);
assert(SysTime(DateTime(-400, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -146_462);
assert(SysTime(DateTime(-401, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -146_827);
assert(SysTime(DateTime(-499, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -182_621);
assert(SysTime(DateTime(-500, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -182_986);
assert(SysTime(DateTime(-501, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -183_351);
assert(SysTime(DateTime(-1000, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -365_607);
assert(SysTime(DateTime(-1001, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -365_972);
assert(SysTime(DateTime(-1599, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -584_387);
assert(SysTime(DateTime(-1600, 12, 31, 12, 2, 9), msecs(212)).dayOfGregorianCal == -584_388);
assert(SysTime(DateTime(-1600, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -584_753);
assert(SysTime(DateTime(-1601, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -585_118);
assert(SysTime(DateTime(-1900, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -694_325);
assert(SysTime(DateTime(-1901, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -694_690);
assert(SysTime(DateTime(-1999, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -730_484);
assert(SysTime(DateTime(-2000, 12, 31, 12, 2, 9), msecs(212)).dayOfGregorianCal == -730_485);
assert(SysTime(DateTime(-2000, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -730_850);
assert(SysTime(DateTime(-2001, 1, 1, 12, 2, 9), msecs(212)).dayOfGregorianCal == -731_215);
assert(SysTime(DateTime(-2010, 1, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_502);
assert(SysTime(DateTime(-2010, 1, 31, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_472);
assert(SysTime(DateTime(-2010, 2, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_471);
assert(SysTime(DateTime(-2010, 2, 28, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_444);
assert(SysTime(DateTime(-2010, 3, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_443);
assert(SysTime(DateTime(-2010, 3, 31, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_413);
assert(SysTime(DateTime(-2010, 4, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_412);
assert(SysTime(DateTime(-2010, 4, 30, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_383);
assert(SysTime(DateTime(-2010, 5, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_382);
assert(SysTime(DateTime(-2010, 5, 31, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_352);
assert(SysTime(DateTime(-2010, 6, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_351);
assert(SysTime(DateTime(-2010, 6, 30, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_322);
assert(SysTime(DateTime(-2010, 7, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_321);
assert(SysTime(DateTime(-2010, 7, 31, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_291);
assert(SysTime(DateTime(-2010, 8, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_290);
assert(SysTime(DateTime(-2010, 8, 31, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_260);
assert(SysTime(DateTime(-2010, 9, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_259);
assert(SysTime(DateTime(-2010, 9, 30, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_230);
assert(SysTime(DateTime(-2010, 10, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_229);
assert(SysTime(DateTime(-2010, 10, 31, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_199);
assert(SysTime(DateTime(-2010, 11, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_198);
assert(SysTime(DateTime(-2010, 11, 30, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_169);
assert(SysTime(DateTime(-2010, 12, 1, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_168);
assert(SysTime(DateTime(-2010, 12, 31, 23, 59, 59), msecs(999)).dayOfGregorianCal == -734_138);
assert(SysTime(DateTime(-2012, 2, 1, 0, 0, 0)).dayOfGregorianCal == -735_202);
assert(SysTime(DateTime(-2012, 2, 28, 0, 0, 0)).dayOfGregorianCal == -735_175);
assert(SysTime(DateTime(-2012, 2, 29, 0, 0, 0)).dayOfGregorianCal == -735_174);
assert(SysTime(DateTime(-2012, 3, 1, 0, 0, 0)).dayOfGregorianCal == -735_173);
// Start of Hebrew Calendar
assert(SysTime(DateTime(-3760, 9, 7, 0, 0, 0)).dayOfGregorianCal == -1_373_427);
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));
}
//Test that the logic for the day of the Gregorian Calendar is consistent
//between Date and SysTime.
unittest
{
void test(Date date, SysTime st, size_t line = __LINE__)
{
import std.format : format;
if(date.dayOfGregorianCal != st.dayOfGregorianCal)
{
throw new AssertError(format("Date [%s] SysTime [%s]", date.dayOfGregorianCal, st.dayOfGregorianCal),
__FILE__, line);
}
}
//Test A.D.
test(Date(1, 1, 1), SysTime(DateTime(1, 1, 1, 0, 0, 0)));
test(Date(1, 1, 2), SysTime(DateTime(1, 1, 2, 0, 0, 0), hnsecs(500)));
test(Date(1, 2, 1), SysTime(DateTime(1, 2, 1, 0, 0, 0), hnsecs(50_000)));
test(Date(2, 1, 1), SysTime(DateTime(2, 1, 1, 0, 0, 0), hnsecs(9_999_999)));
test(Date(3, 1, 1), SysTime(DateTime(3, 1, 1, 12, 13, 14)));
test(Date(4, 1, 1), SysTime(DateTime(4, 1, 1, 12, 13, 14), hnsecs(500)));
test(Date(5, 1, 1), SysTime(DateTime(5, 1, 1, 12, 13, 14), hnsecs(50_000)));
test(Date(50, 1, 1), SysTime(DateTime(50, 1, 1, 12, 13, 14), hnsecs(9_999_999)));
test(Date(97, 1, 1), SysTime(DateTime(97, 1, 1, 23, 59, 59)));
test(Date(100, 1, 1), SysTime(DateTime(100, 1, 1, 23, 59, 59), hnsecs(500)));
test(Date(101, 1, 1), SysTime(DateTime(101, 1, 1, 23, 59, 59), hnsecs(50_000)));
test(Date(105, 1, 1), SysTime(DateTime(105, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
test(Date(200, 1, 1), SysTime(DateTime(200, 1, 1, 0, 0, 0)));
test(Date(201, 1, 1), SysTime(DateTime(201, 1, 1, 0, 0, 0), hnsecs(500)));
test(Date(300, 1, 1), SysTime(DateTime(300, 1, 1, 0, 0, 0), hnsecs(50_000)));
test(Date(301, 1, 1), SysTime(DateTime(301, 1, 1, 0, 0, 0), hnsecs(9_999_999)));
test(Date(400, 1, 1), SysTime(DateTime(400, 1, 1, 12, 13, 14)));
test(Date(401, 1, 1), SysTime(DateTime(401, 1, 1, 12, 13, 14), hnsecs(500)));
test(Date(500, 1, 1), SysTime(DateTime(500, 1, 1, 12, 13, 14), hnsecs(50_000)));
test(Date(501, 1, 1), SysTime(DateTime(501, 1, 1, 12, 13, 14), hnsecs(9_999_999)));
test(Date(1000, 1, 1), SysTime(DateTime(1000, 1, 1, 23, 59, 59)));
test(Date(1001, 1, 1), SysTime(DateTime(1001, 1, 1, 23, 59, 59), hnsecs(500)));
test(Date(1600, 1, 1), SysTime(DateTime(1600, 1, 1, 23, 59, 59), hnsecs(50_000)));
test(Date(1601, 1, 1), SysTime(DateTime(1601, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
test(Date(1900, 1, 1), SysTime(DateTime(1900, 1, 1, 0, 0, 0)));
test(Date(1901, 1, 1), SysTime(DateTime(1901, 1, 1, 0, 0, 0), hnsecs(500)));
test(Date(1945, 11, 12), SysTime(DateTime(1945, 11, 12, 0, 0, 0), hnsecs(50_000)));
test(Date(1999, 1, 1), SysTime(DateTime(1999, 1, 1, 0, 0, 0), hnsecs(9_999_999)));
test(Date(1999, 7, 6), SysTime(DateTime(1999, 7, 6, 12, 13, 14)));
test(Date(2000, 1, 1), SysTime(DateTime(2000, 1, 1, 12, 13, 14), hnsecs(500)));
test(Date(2001, 1, 1), SysTime(DateTime(2001, 1, 1, 12, 13, 14), hnsecs(50_000)));
test(Date(2010, 1, 1), SysTime(DateTime(2010, 1, 1, 12, 13, 14), hnsecs(9_999_999)));
test(Date(2010, 1, 31), SysTime(DateTime(2010, 1, 31, 23, 0, 0)));
test(Date(2010, 2, 1), SysTime(DateTime(2010, 2, 1, 23, 59, 59), hnsecs(500)));
test(Date(2010, 2, 28), SysTime(DateTime(2010, 2, 28, 23, 59, 59), hnsecs(50_000)));
test(Date(2010, 3, 1), SysTime(DateTime(2010, 3, 1, 23, 59, 59), hnsecs(9_999_999)));
test(Date(2010, 3, 31), SysTime(DateTime(2010, 3, 31, 0, 0, 0)));
test(Date(2010, 4, 1), SysTime(DateTime(2010, 4, 1, 0, 0, 0), hnsecs(500)));
test(Date(2010, 4, 30), SysTime(DateTime(2010, 4, 30, 0, 0, 0), hnsecs(50_000)));
test(Date(2010, 5, 1), SysTime(DateTime(2010, 5, 1, 0, 0, 0), hnsecs(9_999_999)));
test(Date(2010, 5, 31), SysTime(DateTime(2010, 5, 31, 12, 13, 14)));
test(Date(2010, 6, 1), SysTime(DateTime(2010, 6, 1, 12, 13, 14), hnsecs(500)));
test(Date(2010, 6, 30), SysTime(DateTime(2010, 6, 30, 12, 13, 14), hnsecs(50_000)));
test(Date(2010, 7, 1), SysTime(DateTime(2010, 7, 1, 12, 13, 14), hnsecs(9_999_999)));
test(Date(2010, 7, 31), SysTime(DateTime(2010, 7, 31, 23, 59, 59)));
test(Date(2010, 8, 1), SysTime(DateTime(2010, 8, 1, 23, 59, 59), hnsecs(500)));
test(Date(2010, 8, 31), SysTime(DateTime(2010, 8, 31, 23, 59, 59), hnsecs(50_000)));
test(Date(2010, 9, 1), SysTime(DateTime(2010, 9, 1, 23, 59, 59), hnsecs(9_999_999)));
test(Date(2010, 9, 30), SysTime(DateTime(2010, 9, 30, 12, 0, 0)));
test(Date(2010, 10, 1), SysTime(DateTime(2010, 10, 1, 0, 12, 0), hnsecs(500)));
test(Date(2010, 10, 31), SysTime(DateTime(2010, 10, 31, 0, 0, 12), hnsecs(50_000)));
test(Date(2010, 11, 1), SysTime(DateTime(2010, 11, 1, 23, 0, 0), hnsecs(9_999_999)));
test(Date(2010, 11, 30), SysTime(DateTime(2010, 11, 30, 0, 59, 0)));
test(Date(2010, 12, 1), SysTime(DateTime(2010, 12, 1, 0, 0, 59), hnsecs(500)));
test(Date(2010, 12, 31), SysTime(DateTime(2010, 12, 31, 0, 59, 59), hnsecs(50_000)));
test(Date(2012, 2, 1), SysTime(DateTime(2012, 2, 1, 23, 0, 59), hnsecs(9_999_999)));
test(Date(2012, 2, 28), SysTime(DateTime(2012, 2, 28, 23, 59, 0)));
test(Date(2012, 2, 29), SysTime(DateTime(2012, 2, 29, 7, 7, 7), hnsecs(7)));
test(Date(2012, 3, 1), SysTime(DateTime(2012, 3, 1, 7, 7, 7), hnsecs(7)));
//Test B.C.
test(Date(0, 12, 31), SysTime(DateTime(0, 12, 31, 0, 0, 0)));
test(Date(0, 12, 30), SysTime(DateTime(0, 12, 30, 0, 0, 0), hnsecs(500)));
test(Date(0, 12, 1), SysTime(DateTime(0, 12, 1, 0, 0, 0), hnsecs(50_000)));
test(Date(0, 11, 30), SysTime(DateTime(0, 11, 30, 0, 0, 0), hnsecs(9_999_999)));
test(Date(-1, 12, 31), SysTime(DateTime(-1, 12, 31, 12, 13, 14)));
test(Date(-1, 12, 30), SysTime(DateTime(-1, 12, 30, 12, 13, 14), hnsecs(500)));
test(Date(-1, 1, 1), SysTime(DateTime(-1, 1, 1, 12, 13, 14), hnsecs(50_000)));
test(Date(-2, 12, 31), SysTime(DateTime(-2, 12, 31, 12, 13, 14), hnsecs(9_999_999)));
test(Date(-2, 1, 1), SysTime(DateTime(-2, 1, 1, 23, 59, 59)));
test(Date(-3, 12, 31), SysTime(DateTime(-3, 12, 31, 23, 59, 59), hnsecs(500)));
test(Date(-3, 1, 1), SysTime(DateTime(-3, 1, 1, 23, 59, 59), hnsecs(50_000)));
test(Date(-4, 12, 31), SysTime(DateTime(-4, 12, 31, 23, 59, 59), hnsecs(9_999_999)));
test(Date(-4, 1, 1), SysTime(DateTime(-4, 1, 1, 0, 0, 0)));
test(Date(-5, 12, 31), SysTime(DateTime(-5, 12, 31, 0, 0, 0), hnsecs(500)));
test(Date(-5, 1, 1), SysTime(DateTime(-5, 1, 1, 0, 0, 0), hnsecs(50_000)));
test(Date(-9, 1, 1), SysTime(DateTime(-9, 1, 1, 0, 0, 0), hnsecs(9_999_999)));
test(Date(-49, 1, 1), SysTime(DateTime(-49, 1, 1, 12, 13, 14)));
test(Date(-50, 1, 1), SysTime(DateTime(-50, 1, 1, 12, 13, 14), hnsecs(500)));
test(Date(-97, 1, 1), SysTime(DateTime(-97, 1, 1, 12, 13, 14), hnsecs(50_000)));
test(Date(-99, 12, 31), SysTime(DateTime(-99, 12, 31, 12, 13, 14), hnsecs(9_999_999)));
test(Date(-99, 1, 1), SysTime(DateTime(-99, 1, 1, 23, 59, 59)));
test(Date(-100, 1, 1), SysTime(DateTime(-100, 1, 1, 23, 59, 59), hnsecs(500)));
test(Date(-101, 1, 1), SysTime(DateTime(-101, 1, 1, 23, 59, 59), hnsecs(50_000)));
test(Date(-105, 1, 1), SysTime(DateTime(-105, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
test(Date(-200, 1, 1), SysTime(DateTime(-200, 1, 1, 0, 0, 0)));
test(Date(-201, 1, 1), SysTime(DateTime(-201, 1, 1, 0, 0, 0), hnsecs(500)));
test(Date(-300, 1, 1), SysTime(DateTime(-300, 1, 1, 0, 0, 0), hnsecs(50_000)));
test(Date(-301, 1, 1), SysTime(DateTime(-301, 1, 1, 0, 0, 0), hnsecs(9_999_999)));
test(Date(-400, 12, 31), SysTime(DateTime(-400, 12, 31, 12, 13, 14)));
test(Date(-400, 1, 1), SysTime(DateTime(-400, 1, 1, 12, 13, 14), hnsecs(500)));
test(Date(-401, 1, 1), SysTime(DateTime(-401, 1, 1, 12, 13, 14), hnsecs(50_000)));
test(Date(-499, 1, 1), SysTime(DateTime(-499, 1, 1, 12, 13, 14), hnsecs(9_999_999)));
test(Date(-500, 1, 1), SysTime(DateTime(-500, 1, 1, 23, 59, 59)));
test(Date(-501, 1, 1), SysTime(DateTime(-501, 1, 1, 23, 59, 59), hnsecs(500)));
test(Date(-1000, 1, 1), SysTime(DateTime(-1000, 1, 1, 23, 59, 59), hnsecs(50_000)));
test(Date(-1001, 1, 1), SysTime(DateTime(-1001, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
test(Date(-1599, 1, 1), SysTime(DateTime(-1599, 1, 1, 0, 0, 0)));
test(Date(-1600, 12, 31), SysTime(DateTime(-1600, 12, 31, 0, 0, 0), hnsecs(500)));
test(Date(-1600, 1, 1), SysTime(DateTime(-1600, 1, 1, 0, 0, 0), hnsecs(50_000)));
test(Date(-1601, 1, 1), SysTime(DateTime(-1601, 1, 1, 0, 0, 0), hnsecs(9_999_999)));
test(Date(-1900, 1, 1), SysTime(DateTime(-1900, 1, 1, 12, 13, 14)));
test(Date(-1901, 1, 1), SysTime(DateTime(-1901, 1, 1, 12, 13, 14), hnsecs(500)));
test(Date(-1999, 1, 1), SysTime(DateTime(-1999, 1, 1, 12, 13, 14), hnsecs(50_000)));
test(Date(-1999, 7, 6), SysTime(DateTime(-1999, 7, 6, 12, 13, 14), hnsecs(9_999_999)));
test(Date(-2000, 12, 31), SysTime(DateTime(-2000, 12, 31, 23, 59, 59)));
test(Date(-2000, 1, 1), SysTime(DateTime(-2000, 1, 1, 23, 59, 59), hnsecs(500)));
test(Date(-2001, 1, 1), SysTime(DateTime(-2001, 1, 1, 23, 59, 59), hnsecs(50_000)));
test(Date(-2010, 1, 1), SysTime(DateTime(-2010, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
test(Date(-2010, 1, 31), SysTime(DateTime(-2010, 1, 31, 0, 0, 0)));
test(Date(-2010, 2, 1), SysTime(DateTime(-2010, 2, 1, 0, 0, 0), hnsecs(500)));
test(Date(-2010, 2, 28), SysTime(DateTime(-2010, 2, 28, 0, 0, 0), hnsecs(50_000)));
test(Date(-2010, 3, 1), SysTime(DateTime(-2010, 3, 1, 0, 0, 0), hnsecs(9_999_999)));
test(Date(-2010, 3, 31), SysTime(DateTime(-2010, 3, 31, 12, 13, 14)));
test(Date(-2010, 4, 1), SysTime(DateTime(-2010, 4, 1, 12, 13, 14), hnsecs(500)));
test(Date(-2010, 4, 30), SysTime(DateTime(-2010, 4, 30, 12, 13, 14), hnsecs(50_000)));
test(Date(-2010, 5, 1), SysTime(DateTime(-2010, 5, 1, 12, 13, 14), hnsecs(9_999_999)));
test(Date(-2010, 5, 31), SysTime(DateTime(-2010, 5, 31, 23, 59, 59)));
test(Date(-2010, 6, 1), SysTime(DateTime(-2010, 6, 1, 23, 59, 59), hnsecs(500)));
test(Date(-2010, 6, 30), SysTime(DateTime(-2010, 6, 30, 23, 59, 59), hnsecs(50_000)));
test(Date(-2010, 7, 1), SysTime(DateTime(-2010, 7, 1, 23, 59, 59), hnsecs(9_999_999)));
test(Date(-2010, 7, 31), SysTime(DateTime(-2010, 7, 31, 0, 0, 0)));
test(Date(-2010, 8, 1), SysTime(DateTime(-2010, 8, 1, 0, 0, 0), hnsecs(500)));
test(Date(-2010, 8, 31), SysTime(DateTime(-2010, 8, 31, 0, 0, 0), hnsecs(50_000)));
test(Date(-2010, 9, 1), SysTime(DateTime(-2010, 9, 1, 0, 0, 0), hnsecs(9_999_999)));
test(Date(-2010, 9, 30), SysTime(DateTime(-2010, 9, 30, 12, 0, 0)));
test(Date(-2010, 10, 1), SysTime(DateTime(-2010, 10, 1, 0, 12, 0), hnsecs(500)));
test(Date(-2010, 10, 31), SysTime(DateTime(-2010, 10, 31, 0, 0, 12), hnsecs(50_000)));
test(Date(-2010, 11, 1), SysTime(DateTime(-2010, 11, 1, 23, 0, 0), hnsecs(9_999_999)));
test(Date(-2010, 11, 30), SysTime(DateTime(-2010, 11, 30, 0, 59, 0)));
test(Date(-2010, 12, 1), SysTime(DateTime(-2010, 12, 1, 0, 0, 59), hnsecs(500)));
test(Date(-2010, 12, 31), SysTime(DateTime(-2010, 12, 31, 0, 59, 59), hnsecs(50_000)));
test(Date(-2012, 2, 1), SysTime(DateTime(-2012, 2, 1, 23, 0, 59), hnsecs(9_999_999)));
test(Date(-2012, 2, 28), SysTime(DateTime(-2012, 2, 28, 23, 59, 0)));
test(Date(-2012, 2, 29), SysTime(DateTime(-2012, 2, 29, 7, 7, 7), hnsecs(7)));
test(Date(-2012, 3, 1), SysTime(DateTime(-2012, 3, 1, 7, 7, 7), hnsecs(7)));
test(Date(-3760, 9, 7), SysTime(DateTime(-3760, 9, 7, 0, 0, 0)));
}
/++
The Xth day of the Gregorian Calendar that this $(LREF SysTime) is on.
Setting this property does not affect the time portion of $(LREF SysTime).
Params:
days = The day of the Gregorian Calendar to set this $(LREF SysTime)
to.
+/
@property void dayOfGregorianCal(int days) @safe 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
{
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)));
}
unittest
{
void testST(SysTime orig, int day, in SysTime expected, size_t line = __LINE__)
{
import std.format : format;
orig.dayOfGregorianCal = day;
if(orig != expected)
throw new AssertError(format("Failed. actual [%s] != expected [%s]", orig, expected), __FILE__, line);
}
//Test A.D.
testST(SysTime(DateTime(1, 1, 1, 0, 0, 0)), 1, SysTime(DateTime(1, 1, 1, 0, 0, 0)));
testST(SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(1)), 1, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(1)));
testST(SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999)), 1,
SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
//Test B.C.
testST(SysTime(DateTime(0, 1, 1, 0, 0, 0)), 0, SysTime(DateTime(0, 12, 31, 0, 0, 0)));
testST(SysTime(DateTime(0, 1, 1, 23, 59, 59), hnsecs(9_999_999)), 0,
SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)));
testST(SysTime(DateTime(0, 1, 1, 23, 59, 59), hnsecs(1)), 0,
SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(1)));
testST(SysTime(DateTime(0, 1, 1, 23, 59, 59)), 0, SysTime(DateTime(0, 12, 31, 23, 59, 59)));
//Test Both.
testST(SysTime(DateTime(-512, 7, 20, 0, 0, 0)), 1, SysTime(DateTime(1, 1, 1, 0, 0, 0)));
testST(SysTime(DateTime(-513, 6, 6, 0, 0, 0), hnsecs(1)), 1, SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(1)));
testST(SysTime(DateTime(-511, 5, 7, 23, 59, 59), hnsecs(9_999_999)), 1,
SysTime(DateTime(1, 1, 1, 23, 59, 59), hnsecs(9_999_999)));
testST(SysTime(DateTime(1607, 4, 8, 0, 0, 0)), 0, SysTime(DateTime(0, 12, 31, 0, 0, 0)));
testST(SysTime(DateTime(1500, 3, 9, 23, 59, 59), hnsecs(9_999_999)), 0,
SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999)));
testST(SysTime(DateTime(999, 2, 10, 23, 59, 59), hnsecs(1)), 0,
SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(1)));
testST(SysTime(DateTime(2007, 12, 11, 23, 59, 59)), 0, SysTime(DateTime(0, 12, 31, 23, 59, 59)));
auto st = SysTime(DateTime(1, 1, 1, 12, 2, 9), msecs(212));
void testST2(int day, in SysTime expected, size_t line = __LINE__)
{
import std.format : format;
st.dayOfGregorianCal = day;
if(st != expected)
throw new AssertError(format("Failed. actual [%s] != expected [%s]", st, expected), __FILE__, line);
}
//Test A.D.
testST2(1, SysTime(DateTime(1, 1, 1, 12, 2, 9), msecs(212)));
testST2(2, SysTime(DateTime(1, 1, 2, 12, 2, 9), msecs(212)));
testST2(32, SysTime(DateTime(1, 2, 1, 12, 2, 9), msecs(212)));
testST2(366, SysTime(DateTime(2, 1, 1, 12, 2, 9), msecs(212)));
testST2(731, SysTime(DateTime(3, 1, 1, 12, 2, 9), msecs(212)));
testST2(1096, SysTime(DateTime(4, 1, 1, 12, 2, 9), msecs(212)));
testST2(1462, SysTime(DateTime(5, 1, 1, 12, 2, 9), msecs(212)));
testST2(17_898, SysTime(DateTime(50, 1, 1, 12, 2, 9), msecs(212)));
testST2(35_065, SysTime(DateTime(97, 1, 1, 12, 2, 9), msecs(212)));
testST2(36_160, SysTime(DateTime(100, 1, 1, 12, 2, 9), msecs(212)));
testST2(36_525, SysTime(DateTime(101, 1, 1, 12, 2, 9), msecs(212)));
testST2(37_986, SysTime(DateTime(105, 1, 1, 12, 2, 9), msecs(212)));
testST2(72_684, SysTime(DateTime(200, 1, 1, 12, 2, 9), msecs(212)));
testST2(73_049, SysTime(DateTime(201, 1, 1, 12, 2, 9), msecs(212)));
testST2(109_208, SysTime(DateTime(300, 1, 1, 12, 2, 9), msecs(212)));
testST2(109_573, SysTime(DateTime(301, 1, 1, 12, 2, 9), msecs(212)));
testST2(145_732, SysTime(DateTime(400, 1, 1, 12, 2, 9), msecs(212)));
testST2(146_098, SysTime(DateTime(401, 1, 1, 12, 2, 9), msecs(212)));
testST2(182_257, SysTime(DateTime(500, 1, 1, 12, 2, 9), msecs(212)));
testST2(182_622, SysTime(DateTime(501, 1, 1, 12, 2, 9), msecs(212)));
testST2(364_878, SysTime(DateTime(1000, 1, 1, 12, 2, 9), msecs(212)));
testST2(365_243, SysTime(DateTime(1001, 1, 1, 12, 2, 9), msecs(212)));
testST2(584_023, SysTime(DateTime(1600, 1, 1, 12, 2, 9), msecs(212)));
testST2(584_389, SysTime(DateTime(1601, 1, 1, 12, 2, 9), msecs(212)));
testST2(693_596, SysTime(DateTime(1900, 1, 1, 12, 2, 9), msecs(212)));
testST2(693_961, SysTime(DateTime(1901, 1, 1, 12, 2, 9), msecs(212)));
testST2(729_755, SysTime(DateTime(1999, 1, 1, 12, 2, 9), msecs(212)));
testST2(730_120, SysTime(DateTime(2000, 1, 1, 12, 2, 9), msecs(212)));
testST2(730_486, SysTime(DateTime(2001, 1, 1, 12, 2, 9), msecs(212)));
testST2(733_773, SysTime(DateTime(2010, 1, 1, 12, 2, 9), msecs(212)));
testST2(733_803, SysTime(DateTime(2010, 1, 31, 12, 2, 9), msecs(212)));
testST2(733_804, SysTime(DateTime(2010, 2, 1, 12, 2, 9), msecs(212)));
testST2(733_831, SysTime(DateTime(2010, 2, 28, 12, 2, 9), msecs(212)));
testST2(733_832, SysTime(DateTime(2010, 3, 1, 12, 2, 9), msecs(212)));
testST2(733_862, SysTime(DateTime(2010, 3, 31, 12, 2, 9), msecs(212)));
testST2(733_863, SysTime(DateTime(2010, 4, 1, 12, 2, 9), msecs(212)));
testST2(733_892, SysTime(DateTime(2010, 4, 30, 12, 2, 9), msecs(212)));
testST2(733_893, SysTime(DateTime(2010, 5, 1, 12, 2, 9), msecs(212)));
testST2(733_923, SysTime(DateTime(2010, 5, 31, 12, 2, 9), msecs(212)));
testST2(733_924, SysTime(DateTime(2010, 6, 1, 12, 2, 9), msecs(212)));
testST2(733_953, SysTime(DateTime(2010, 6, 30, 12, 2, 9), msecs(212)));
testST2(733_954, SysTime(DateTime(2010, 7, 1, 12, 2, 9), msecs(212)));
testST2(733_984, SysTime(DateTime(2010, 7, 31, 12, 2, 9), msecs(212)));
testST2(733_985, SysTime(DateTime(2010, 8, 1, 12, 2, 9), msecs(212)));
testST2(734_015, SysTime(DateTime(2010, 8, 31, 12, 2, 9), msecs(212)));
testST2(734_016, SysTime(DateTime(2010, 9, 1, 12, 2, 9), msecs(212)));
testST2(734_045, SysTime(DateTime(2010, 9, 30, 12, 2, 9), msecs(212)));
testST2(734_046, SysTime(DateTime(2010, 10, 1, 12, 2, 9), msecs(212)));
testST2(734_076, SysTime(DateTime(2010, 10, 31, 12, 2, 9), msecs(212)));
testST2(734_077, SysTime(DateTime(2010, 11, 1, 12, 2, 9), msecs(212)));
testST2(734_106, SysTime(DateTime(2010, 11, 30, 12, 2, 9), msecs(212)));
testST2(734_107, SysTime(DateTime(2010, 12, 1, 12, 2, 9), msecs(212)));
testST2(734_137, SysTime(DateTime(2010, 12, 31, 12, 2, 9), msecs(212)));
testST2(734_534, SysTime(DateTime(2012, 2, 1, 12, 2, 9), msecs(212)));
testST2(734_561, SysTime(DateTime(2012, 2, 28, 12, 2, 9), msecs(212)));
testST2(734_562, SysTime(DateTime(2012, 2, 29, 12, 2, 9), msecs(212)));
testST2(734_563, SysTime(DateTime(2012, 3, 1, 12, 2, 9), msecs(212)));
testST2(734_534, SysTime(DateTime(2012, 2, 1, 12, 2, 9), msecs(212)));
testST2(734_561, SysTime(DateTime(2012, 2, 28, 12, 2, 9), msecs(212)));
testST2(734_562, SysTime(DateTime(2012, 2, 29, 12, 2, 9), msecs(212)));
testST2(734_563, SysTime(DateTime(2012, 3, 1, 12, 2, 9), msecs(212)));
//Test B.C.
testST2(0, SysTime(DateTime(0, 12, 31, 12, 2, 9), msecs(212)));
testST2(-1, SysTime(DateTime(0, 12, 30, 12, 2, 9), msecs(212)));
testST2(-30, SysTime(DateTime(0, 12, 1, 12, 2, 9), msecs(212)));
testST2(-31, SysTime(DateTime(0, 11, 30, 12, 2, 9), msecs(212)));
testST2(-366, SysTime(DateTime(-1, 12, 31, 12, 2, 9), msecs(212)));
testST2(-367, SysTime(DateTime(-1, 12, 30, 12, 2, 9), msecs(212)));
testST2(-730, SysTime(DateTime(-1, 1, 1, 12, 2, 9), msecs(212)));
testST2(-731, SysTime(DateTime(-2, 12, 31, 12, 2, 9), msecs(212)));
testST2(-1095, SysTime(DateTime(-2, 1, 1, 12, 2, 9), msecs(212)));
testST2(-1096, SysTime(DateTime(-3, 12, 31, 12, 2, 9), msecs(212)));
testST2(-1460, SysTime(DateTime(-3, 1, 1, 12, 2, 9), msecs(212)));
testST2(-1461, SysTime(DateTime(-4, 12, 31, 12, 2, 9), msecs(212)));
testST2(-1826, SysTime(DateTime(-4, 1, 1, 12, 2, 9), msecs(212)));
testST2(-1827, SysTime(DateTime(-5, 12, 31, 12, 2, 9), msecs(212)));
testST2(-2191, SysTime(DateTime(-5, 1, 1, 12, 2, 9), msecs(212)));
testST2(-3652, SysTime(DateTime(-9, 1, 1, 12, 2, 9), msecs(212)));
testST2(-18_262, SysTime(DateTime(-49, 1, 1, 12, 2, 9), msecs(212)));
testST2(-18_627, SysTime(DateTime(-50, 1, 1, 12, 2, 9), msecs(212)));
testST2(-35_794, SysTime(DateTime(-97, 1, 1, 12, 2, 9), msecs(212)));
testST2(-36_160, SysTime(DateTime(-99, 12, 31, 12, 2, 9), msecs(212)));
testST2(-36_524, SysTime(DateTime(-99, 1, 1, 12, 2, 9), msecs(212)));
testST2(-36_889, SysTime(DateTime(-100, 1, 1, 12, 2, 9), msecs(212)));
testST2(-37_254, SysTime(DateTime(-101, 1, 1, 12, 2, 9), msecs(212)));
testST2(-38_715, SysTime(DateTime(-105, 1, 1, 12, 2, 9), msecs(212)));
testST2(-73_413, SysTime(DateTime(-200, 1, 1, 12, 2, 9), msecs(212)));
testST2(-73_778, SysTime(DateTime(-201, 1, 1, 12, 2, 9), msecs(212)));
testST2(-109_937, SysTime(DateTime(-300, 1, 1, 12, 2, 9), msecs(212)));
testST2(-110_302, SysTime(DateTime(-301, 1, 1, 12, 2, 9), msecs(212)));
testST2(-146_097, SysTime(DateTime(-400, 12, 31, 12, 2, 9), msecs(212)));
testST2(-146_462, SysTime(DateTime(-400, 1, 1, 12, 2, 9), msecs(212)));
testST2(-146_827, SysTime(DateTime(-401, 1, 1, 12, 2, 9), msecs(212)));
testST2(-182_621, SysTime(DateTime(-499, 1, 1, 12, 2, 9), msecs(212)));
testST2(-182_986, SysTime(DateTime(-500, 1, 1, 12, 2, 9), msecs(212)));
testST2(-183_351, SysTime(DateTime(-501, 1, 1, 12, 2, 9), msecs(212)));
testST2(-365_607, SysTime(DateTime(-1000, 1, 1, 12, 2, 9), msecs(212)));
testST2(-365_972, SysTime(DateTime(-1001, 1, 1, 12, 2, 9), msecs(212)));
testST2(-584_387, SysTime(DateTime(-1599, 1, 1, 12, 2, 9), msecs(212)));
testST2(-584_388, SysTime(DateTime(-1600, 12, 31, 12, 2, 9), msecs(212)));
testST2(-584_753, SysTime(DateTime(-1600, 1, 1, 12, 2, 9), msecs(212)));
testST2(-585_118, SysTime(DateTime(-1601, 1, 1, 12, 2, 9), msecs(212)));
testST2(-694_325, SysTime(DateTime(-1900, 1, 1, 12, 2, 9), msecs(212)));
testST2(-694_690, SysTime(DateTime(-1901, 1, 1, 12, 2, 9), msecs(212)));
testST2(-730_484, SysTime(DateTime(-1999, 1, 1, 12, 2, 9), msecs(212)));
testST2(-730_485, SysTime(DateTime(-2000, 12, 31, 12, 2, 9), msecs(212)));
testST2(-730_850, SysTime(DateTime(-2000, 1, 1, 12, 2, 9), msecs(212)));
testST2(-731_215, SysTime(DateTime(-2001, 1, 1, 12, 2, 9), msecs(212)));
testST2(-734_502, SysTime(DateTime(-2010, 1, 1, 12, 2, 9), msecs(212)));
testST2(-734_472, SysTime(DateTime(-2010, 1, 31, 12, 2, 9), msecs(212)));
testST2(-734_471, SysTime(DateTime(-2010, 2, 1, 12, 2, 9), msecs(212)));
testST2(-734_444, SysTime(DateTime(-2010, 2, 28, 12, 2, 9), msecs(212)));
testST2(-734_443, SysTime(DateTime(-2010, 3, 1, 12, 2, 9), msecs(212)));
testST2(-734_413, SysTime(DateTime(-2010, 3, 31, 12, 2, 9), msecs(212)));
testST2(-734_412, SysTime(DateTime(-2010, 4, 1, 12, 2, 9), msecs(212)));
testST2(-734_383, SysTime(DateTime(-2010, 4, 30, 12, 2, 9), msecs(212)));
testST2(-734_382, SysTime(DateTime(-2010, 5, 1, 12, 2, 9), msecs(212)));
testST2(-734_352, SysTime(DateTime(-2010, 5, 31, 12, 2, 9), msecs(212)));
testST2(-734_351, SysTime(DateTime(-2010, 6, 1, 12, 2, 9), msecs(212)));
testST2(-734_322, SysTime(DateTime(-2010, 6, 30, 12, 2, 9), msecs(212)));
testST2(-734_321, SysTime(DateTime(-2010, 7, 1, 12, 2, 9), msecs(212)));
testST2(-734_291, SysTime(DateTime(-2010, 7, 31, 12, 2, 9), msecs(212)));
testST2(-734_290, SysTime(DateTime(-2010, 8, 1, 12, 2, 9), msecs(212)));
testST2(-734_260, SysTime(DateTime(-2010, 8, 31, 12, 2, 9), msecs(212)));
testST2(-734_259, SysTime(DateTime(-2010, 9, 1, 12, 2, 9), msecs(212)));
testST2(-734_230, SysTime(DateTime(-2010, 9, 30, 12, 2, 9), msecs(212)));
testST2(-734_229, SysTime(DateTime(-2010, 10, 1, 12, 2, 9), msecs(212)));
testST2(-734_199, SysTime(DateTime(-2010, 10, 31, 12, 2, 9), msecs(212)));
testST2(-734_198, SysTime(DateTime(-2010, 11, 1, 12, 2, 9), msecs(212)));
testST2(-734_169, SysTime(DateTime(-2010, 11, 30, 12, 2, 9), msecs(212)));
testST2(-734_168, SysTime(DateTime(-2010, 12, 1, 12, 2, 9), msecs(212)));
testST2(-734_138, SysTime(DateTime(-2010, 12, 31, 12, 2, 9), msecs(212)));
testST2(-735_202, SysTime(DateTime(-2012, 2, 1, 12, 2, 9), msecs(212)));
testST2(-735_175, SysTime(DateTime(-2012, 2, 28, 12, 2, 9), msecs(212)));
testST2(-735_174, SysTime(DateTime(-2012, 2, 29, 12, 2, 9), msecs(212)));
testST2(-735_173, SysTime(DateTime(-2012, 3, 1, 12, 2, 9), 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));
}
/++
The ISO 8601 week of the year that this $(LREF SysTime) is in.
See_Also:
$(WEB en.wikipedia.org/wiki/ISO_week_date, ISO Week Date).
+/
@property ubyte isoWeek() @safe const nothrow
{
return (cast(Date)this).isoWeek;
}
unittest
{
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));
}
/++
$(LREF SysTime) for the last day in the month that this Date is in.
The time portion of endOfMonth is always 23:59:59.9999999.
+/
@property SysTime endOfMonth() @safe 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
{
assert(SysTime(DateTime(1999, 1, 6, 0, 0, 0)).endOfMonth ==
SysTime(DateTime(1999, 1, 31, 23, 59, 59),
hnsecs(9_999_999)));
assert(SysTime(DateTime(1999, 2, 7, 19, 30, 0),
msecs(24)).endOfMonth ==
SysTime(DateTime(1999, 2, 28, 23, 59, 59),
hnsecs(9_999_999)));
assert(SysTime(DateTime(2000, 2, 7, 5, 12, 27),
usecs(5203)).endOfMonth ==
SysTime(DateTime(2000, 2, 29, 23, 59, 59),
hnsecs(9_999_999)));
assert(SysTime(DateTime(2000, 6, 4, 12, 22, 9),
hnsecs(12345)).endOfMonth ==
SysTime(DateTime(2000, 6, 30, 23, 59, 59),
hnsecs(9_999_999)));
}
unittest
{
//Test A.D.
assert(SysTime(Date(1999, 1, 1)).endOfMonth == SysTime(DateTime(1999, 1, 31, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(1999, 2, 1)).endOfMonth == SysTime(DateTime(1999, 2, 28, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(2000, 2, 1)).endOfMonth == SysTime(DateTime(2000, 2, 29, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(1999, 3, 1)).endOfMonth == SysTime(DateTime(1999, 3, 31, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(1999, 4, 1)).endOfMonth == SysTime(DateTime(1999, 4, 30, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(1999, 5, 1)).endOfMonth == SysTime(DateTime(1999, 5, 31, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(1999, 6, 1)).endOfMonth == SysTime(DateTime(1999, 6, 30, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(1999, 7, 1)).endOfMonth == SysTime(DateTime(1999, 7, 31, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(1999, 8, 1)).endOfMonth == SysTime(DateTime(1999, 8, 31, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(1999, 9, 1)).endOfMonth == SysTime(DateTime(1999, 9, 30, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(1999, 10, 1)).endOfMonth == SysTime(DateTime(1999, 10, 31, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(1999, 11, 1)).endOfMonth == SysTime(DateTime(1999, 11, 30, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(1999, 12, 1)).endOfMonth == SysTime(DateTime(1999, 12, 31, 23, 59, 59), hnsecs(9_999_999)));
//Test B.C.
assert(SysTime(Date(-1999, 1, 1)).endOfMonth == SysTime(DateTime(-1999, 1, 31, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(-1999, 2, 1)).endOfMonth == SysTime(DateTime(-1999, 2, 28, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(-2000, 2, 1)).endOfMonth == SysTime(DateTime(-2000, 2, 29, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(-1999, 3, 1)).endOfMonth == SysTime(DateTime(-1999, 3, 31, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(-1999, 4, 1)).endOfMonth == SysTime(DateTime(-1999, 4, 30, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(-1999, 5, 1)).endOfMonth == SysTime(DateTime(-1999, 5, 31, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(-1999, 6, 1)).endOfMonth == SysTime(DateTime(-1999, 6, 30, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(-1999, 7, 1)).endOfMonth == SysTime(DateTime(-1999, 7, 31, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(-1999, 8, 1)).endOfMonth == SysTime(DateTime(-1999, 8, 31, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(-1999, 9, 1)).endOfMonth == SysTime(DateTime(-1999, 9, 30, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(-1999, 10, 1)).endOfMonth ==
SysTime(DateTime(-1999, 10, 31, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(-1999, 11, 1)).endOfMonth ==
SysTime(DateTime(-1999, 11, 30, 23, 59, 59), hnsecs(9_999_999)));
assert(SysTime(Date(-1999, 12, 1)).endOfMonth ==
SysTime(DateTime(-1999, 12, 31, 23, 59, 59), 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));
}
/++
The last day in the month that this $(LREF SysTime) is in.
+/
@property ubyte daysInMonth() @safe const nothrow
{
return Date(dayOfGregorianCal).daysInMonth;
}
///
unittest
{
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);
}
unittest
{
//Test A.D.
assert(SysTime(DateTime(1999, 1, 1, 12, 1, 13)).daysInMonth == 31);
assert(SysTime(DateTime(1999, 2, 1, 17, 13, 12)).daysInMonth == 28);
assert(SysTime(DateTime(2000, 2, 1, 13, 2, 12)).daysInMonth == 29);
assert(SysTime(DateTime(1999, 3, 1, 12, 13, 12)).daysInMonth == 31);
assert(SysTime(DateTime(1999, 4, 1, 12, 6, 13)).daysInMonth == 30);
assert(SysTime(DateTime(1999, 5, 1, 15, 13, 12)).daysInMonth == 31);
assert(SysTime(DateTime(1999, 6, 1, 13, 7, 12)).daysInMonth == 30);
assert(SysTime(DateTime(1999, 7, 1, 12, 13, 17)).daysInMonth == 31);
assert(SysTime(DateTime(1999, 8, 1, 12, 3, 13)).daysInMonth == 31);
assert(SysTime(DateTime(1999, 9, 1, 12, 13, 12)).daysInMonth == 30);
assert(SysTime(DateTime(1999, 10, 1, 13, 19, 12)).daysInMonth == 31);
assert(SysTime(DateTime(1999, 11, 1, 12, 13, 17)).daysInMonth == 30);
assert(SysTime(DateTime(1999, 12, 1, 12, 52, 13)).daysInMonth == 31);
//Test B.C.
assert(SysTime(DateTime(-1999, 1, 1, 12, 1, 13)).daysInMonth == 31);
assert(SysTime(DateTime(-1999, 2, 1, 7, 13, 12)).daysInMonth == 28);
assert(SysTime(DateTime(-2000, 2, 1, 13, 2, 12)).daysInMonth == 29);
assert(SysTime(DateTime(-1999, 3, 1, 12, 13, 12)).daysInMonth == 31);
assert(SysTime(DateTime(-1999, 4, 1, 12, 6, 13)).daysInMonth == 30);
assert(SysTime(DateTime(-1999, 5, 1, 5, 13, 12)).daysInMonth == 31);
assert(SysTime(DateTime(-1999, 6, 1, 13, 7, 12)).daysInMonth == 30);
assert(SysTime(DateTime(-1999, 7, 1, 12, 13, 17)).daysInMonth == 31);
assert(SysTime(DateTime(-1999, 8, 1, 12, 3, 13)).daysInMonth == 31);
assert(SysTime(DateTime(-1999, 9, 1, 12, 13, 12)).daysInMonth == 30);
assert(SysTime(DateTime(-1999, 10, 1, 13, 19, 12)).daysInMonth == 31);
assert(SysTime(DateTime(-1999, 11, 1, 12, 13, 17)).daysInMonth == 30);
assert(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));
}
/++
Whether the current year is a date in A.D.
+/
@property bool isAD() @safe const nothrow
{
return adjTime >= 0;
}
///
unittest
{
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);
}
unittest
{
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));
}
/++
The $(WEB en.wikipedia.org/wiki/Julian_day, Julian day)
for this $(LREF 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() @safe const nothrow
{
immutable jd = dayOfGregorianCal + 1_721_425;
return hour < 12 ? jd - 1 : jd;
}
unittest
{
assert(SysTime(DateTime(-4713, 11, 24, 0, 0, 0)).julianDay == -1);
assert(SysTime(DateTime(-4713, 11, 24, 12, 0, 0)).julianDay == 0);
assert(SysTime(DateTime(0, 12, 31, 0, 0, 0)).julianDay == 1_721_424);
assert(SysTime(DateTime(0, 12, 31, 12, 0, 0)).julianDay == 1_721_425);
assert(SysTime(DateTime(1, 1, 1, 0, 0, 0)).julianDay == 1_721_425);
assert(SysTime(DateTime(1, 1, 1, 12, 0, 0)).julianDay == 1_721_426);
assert(SysTime(DateTime(1582, 10, 15, 0, 0, 0)).julianDay == 2_299_160);
assert(SysTime(DateTime(1582, 10, 15, 12, 0, 0)).julianDay == 2_299_161);
assert(SysTime(DateTime(1858, 11, 17, 0, 0, 0)).julianDay == 2_400_000);
assert(SysTime(DateTime(1858, 11, 17, 12, 0, 0)).julianDay == 2_400_001);
assert(SysTime(DateTime(1982, 1, 4, 0, 0, 0)).julianDay == 2_444_973);
assert(SysTime(DateTime(1982, 1, 4, 12, 0, 0)).julianDay == 2_444_974);
assert(SysTime(DateTime(1996, 3, 31, 0, 0, 0)).julianDay == 2_450_173);
assert(SysTime(DateTime(1996, 3, 31, 12, 0, 0)).julianDay == 2_450_174);
assert(SysTime(DateTime(2010, 8, 24, 0, 0, 0)).julianDay == 2_455_432);
assert(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 $(WEB en.wikipedia.org/wiki/Julian_day, Julian day) for any time on this date (since, the modified
Julian day changes at midnight).
+/
@property long modJulianDay() @safe const nothrow
{
return (dayOfGregorianCal + 1_721_425) - 2_400_001;
}
unittest
{
assert(SysTime(DateTime(1858, 11, 17, 0, 0, 0)).modJulianDay == 0);
assert(SysTime(DateTime(1858, 11, 17, 12, 0, 0)).modJulianDay == 0);
assert(SysTime(DateTime(2010, 8, 24, 0, 0, 0)).modJulianDay == 55_432);
assert(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 $(LREF Date) equivalent to this $(LREF SysTime).
+/
Date opCast(T)() @safe const nothrow
if(is(Unqual!T == Date))
{
return Date(dayOfGregorianCal);
}
unittest
{
assert(cast(Date)SysTime(Date(1999, 7, 6)) == Date(1999, 7, 6));
assert(cast(Date)SysTime(Date(2000, 12, 31)) == Date(2000, 12, 31));
assert(cast(Date)SysTime(Date(2001, 1, 1)) == Date(2001, 1, 1));
assert(cast(Date)SysTime(DateTime(1999, 7, 6, 12, 10, 9)) == Date(1999, 7, 6));
assert(cast(Date)SysTime(DateTime(2000, 12, 31, 13, 11, 10)) == Date(2000, 12, 31));
assert(cast(Date)SysTime(DateTime(2001, 1, 1, 14, 12, 11)) == Date(2001, 1, 1));
assert(cast(Date)SysTime(Date(-1999, 7, 6)) == Date(-1999, 7, 6));
assert(cast(Date)SysTime(Date(-2000, 12, 31)) == Date(-2000, 12, 31));
assert(cast(Date)SysTime(Date(-2001, 1, 1)) == Date(-2001, 1, 1));
assert(cast(Date)SysTime(DateTime(-1999, 7, 6, 12, 10, 9)) == Date(-1999, 7, 6));
assert(cast(Date)SysTime(DateTime(-2000, 12, 31, 13, 11, 10)) == Date(-2000, 12, 31));
assert(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 $(LREF DateTime) equivalent to this $(LREF SysTime).
+/
DateTime opCast(T)() @safe 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
{
assert(cast(DateTime)SysTime(DateTime(1, 1, 6, 7, 12, 22)) == DateTime(1, 1, 6, 7, 12, 22));
assert(cast(DateTime)SysTime(DateTime(1, 1, 6, 7, 12, 22), msecs(22)) == DateTime(1, 1, 6, 7, 12, 22));
assert(cast(DateTime)SysTime(Date(1999, 7, 6)) == DateTime(1999, 7, 6, 0, 0, 0));
assert(cast(DateTime)SysTime(Date(2000, 12, 31)) == DateTime(2000, 12, 31, 0, 0, 0));
assert(cast(DateTime)SysTime(Date(2001, 1, 1)) == DateTime(2001, 1, 1, 0, 0, 0));
assert(cast(DateTime)SysTime(DateTime(1999, 7, 6, 12, 10, 9)) == DateTime(1999, 7, 6, 12, 10, 9));
assert(cast(DateTime)SysTime(DateTime(2000, 12, 31, 13, 11, 10)) == DateTime(2000, 12, 31, 13, 11, 10));
assert(cast(DateTime)SysTime(DateTime(2001, 1, 1, 14, 12, 11)) == DateTime(2001, 1, 1, 14, 12, 11));
assert(cast(DateTime)SysTime(DateTime(-1, 1, 6, 7, 12, 22)) == DateTime(-1, 1, 6, 7, 12, 22));
assert(cast(DateTime)SysTime(DateTime(-1, 1, 6, 7, 12, 22), msecs(22)) == DateTime(-1, 1, 6, 7, 12, 22));
assert(cast(DateTime)SysTime(Date(-1999, 7, 6)) == DateTime(-1999, 7, 6, 0, 0, 0));
assert(cast(DateTime)SysTime(Date(-2000, 12, 31)) == DateTime(-2000, 12, 31, 0, 0, 0));
assert(cast(DateTime)SysTime(Date(-2001, 1, 1)) == DateTime(-2001, 1, 1, 0, 0, 0));
assert(cast(DateTime)SysTime(DateTime(-1999, 7, 6, 12, 10, 9)) == DateTime(-1999, 7, 6, 12, 10, 9));
assert(cast(DateTime)SysTime(DateTime(-2000, 12, 31, 13, 11, 10)) == DateTime(-2000, 12, 31, 13, 11, 10));
assert(cast(DateTime)SysTime(DateTime(-2001, 1, 1, 14, 12, 11)) == DateTime(-2001, 1, 1, 14, 12, 11));
assert(cast(DateTime)SysTime(DateTime(2011, 1, 13, 8, 17, 2), 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 $(LREF TimeOfDay) equivalent to this $(LREF SysTime).
+/
TimeOfDay opCast(T)() @safe 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
{
assert(cast(TimeOfDay)SysTime(Date(1999, 7, 6)) == TimeOfDay(0, 0, 0));
assert(cast(TimeOfDay)SysTime(Date(2000, 12, 31)) == TimeOfDay(0, 0, 0));
assert(cast(TimeOfDay)SysTime(Date(2001, 1, 1)) == TimeOfDay(0, 0, 0));
assert(cast(TimeOfDay)SysTime(DateTime(1999, 7, 6, 12, 10, 9)) == TimeOfDay(12, 10, 9));
assert(cast(TimeOfDay)SysTime(DateTime(2000, 12, 31, 13, 11, 10)) == TimeOfDay(13, 11, 10));
assert(cast(TimeOfDay)SysTime(DateTime(2001, 1, 1, 14, 12, 11)) == TimeOfDay(14, 12, 11));
assert(cast(TimeOfDay)SysTime(Date(-1999, 7, 6)) == TimeOfDay(0, 0, 0));
assert(cast(TimeOfDay)SysTime(Date(-2000, 12, 31)) == TimeOfDay(0, 0, 0));
assert(cast(TimeOfDay)SysTime(Date(-2001, 1, 1)) == TimeOfDay(0, 0, 0));
assert(cast(TimeOfDay)SysTime(DateTime(-1999, 7, 6, 12, 10, 9)) == TimeOfDay(12, 10, 9));
assert(cast(TimeOfDay)SysTime(DateTime(-2000, 12, 31, 13, 11, 10)) == TimeOfDay(13, 11, 10));
assert(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)() @safe const pure nothrow
if(is(Unqual!T == SysTime))
{
return SysTime(_stdTime, _timezone);
}
/++
Converts this $(LREF 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 $(LREF SysTime)'s time zone is $(LREF 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.
+/
string toISOString() @safe const nothrow
{
import std.format : format;
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 = fracSecsToISOString(cast(int)hnsecs);
if(_timezone is LocalTime())
return dateTime.toISOString() ~ fracSecsToISOString(cast(int)hnsecs);
if(_timezone is UTC())
return dateTime.toISOString() ~ fracSecsToISOString(cast(int)hnsecs) ~ "Z";
immutable utcOffset = dur!"hnsecs"(adjustedTime - stdTime);
return format("%s%s%s",
dateTime.toISOString(),
fracSecsToISOString(cast(int)hnsecs),
SimpleTimeZone.toISOString(utcOffset));
}
catch(Exception e)
assert(0, "format() threw.");
}
///
unittest
{
assert(SysTime(DateTime(2010, 7, 4, 7, 6, 12)).toISOString() ==
"20100704T070612");
assert(SysTime(DateTime(1998, 12, 25, 2, 15, 0),
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),
hnsecs(520_920)).toISOString() ==
"-00040105T000002.052092");
}
unittest
{
//Test A.D.
assert(SysTime(DateTime.init, UTC()).toISOString() == "00010101T000000Z");
assert(SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(1), UTC()).toISOString() == "00010101T000000.0000001Z");
assert(SysTime(DateTime(9, 12, 4, 0, 0, 0)).toISOString() == "00091204T000000");
assert(SysTime(DateTime(99, 12, 4, 5, 6, 12)).toISOString() == "00991204T050612");
assert(SysTime(DateTime(999, 12, 4, 13, 44, 59)).toISOString() == "09991204T134459");
assert(SysTime(DateTime(9999, 7, 4, 23, 59, 59)).toISOString() == "99990704T235959");
assert(SysTime(DateTime(10000, 10, 20, 1, 1, 1)).toISOString() == "+100001020T010101");
assert(SysTime(DateTime(9, 12, 4, 0, 0, 0), msecs(42)).toISOString() == "00091204T000000.042");
assert(SysTime(DateTime(99, 12, 4, 5, 6, 12), msecs(100)).toISOString() == "00991204T050612.1");
assert(SysTime(DateTime(999, 12, 4, 13, 44, 59), usecs(45020)).toISOString() == "09991204T134459.04502");
assert(SysTime(DateTime(9999, 7, 4, 23, 59, 59), hnsecs(12)).toISOString() == "99990704T235959.0000012");
assert(SysTime(DateTime(10000, 10, 20, 1, 1, 1), hnsecs(507890)).toISOString() == "+100001020T010101.050789");
assert(SysTime(DateTime(2012, 12, 21, 12, 12, 12),
new immutable SimpleTimeZone(dur!"minutes"(-360))).toISOString() ==
"20121221T121212-06:00");
assert(SysTime(DateTime(2012, 12, 21, 12, 12, 12),
new immutable SimpleTimeZone(dur!"minutes"(420))).toISOString() ==
"20121221T121212+07:00");
//Test B.C.
assert(SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999), UTC()).toISOString() ==
"00001231T235959.9999999Z");
assert(SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(1), UTC()).toISOString() == "00001231T235959.0000001Z");
assert(SysTime(DateTime(0, 12, 31, 23, 59, 59), UTC()).toISOString() == "00001231T235959Z");
assert(SysTime(DateTime(0, 12, 4, 0, 12, 4)).toISOString() == "00001204T001204");
assert(SysTime(DateTime(-9, 12, 4, 0, 0, 0)).toISOString() == "-00091204T000000");
assert(SysTime(DateTime(-99, 12, 4, 5, 6, 12)).toISOString() == "-00991204T050612");
assert(SysTime(DateTime(-999, 12, 4, 13, 44, 59)).toISOString() == "-09991204T134459");
assert(SysTime(DateTime(-9999, 7, 4, 23, 59, 59)).toISOString() == "-99990704T235959");
assert(SysTime(DateTime(-10000, 10, 20, 1, 1, 1)).toISOString() == "-100001020T010101");
assert(SysTime(DateTime(0, 12, 4, 0, 0, 0), msecs(7)).toISOString() == "00001204T000000.007");
assert(SysTime(DateTime(-9, 12, 4, 0, 0, 0), msecs(42)).toISOString() == "-00091204T000000.042");
assert(SysTime(DateTime(-99, 12, 4, 5, 6, 12), msecs(100)).toISOString() == "-00991204T050612.1");
assert(SysTime(DateTime(-999, 12, 4, 13, 44, 59), usecs(45020)).toISOString() == "-09991204T134459.04502");
assert(SysTime(DateTime(-9999, 7, 4, 23, 59, 59), hnsecs(12)).toISOString() == "-99990704T235959.0000012");
assert(SysTime(DateTime(-10000, 10, 20, 1, 1, 1), 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));
}
/++
Converts this $(LREF 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 $(LREF SysTime)'s time zone is $(LREF 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.
+/
string toISOExtString() @safe const nothrow
{
import std.format : format;
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 = fracSecsToISOString(cast(int)hnsecs);
if(_timezone is LocalTime())
return dateTime.toISOExtString() ~ fracSecsToISOString(cast(int)hnsecs);
if(_timezone is UTC())
return dateTime.toISOExtString() ~ fracSecsToISOString(cast(int)hnsecs) ~ "Z";
immutable utcOffset = dur!"hnsecs"(adjustedTime - stdTime);
return format("%s%s%s",
dateTime.toISOExtString(),
fracSecsToISOString(cast(int)hnsecs),
SimpleTimeZone.toISOString(utcOffset));
}
catch(Exception e)
assert(0, "format() threw.");
}
///
unittest
{
assert(SysTime(DateTime(2010, 7, 4, 7, 6, 12)).toISOExtString() ==
"2010-07-04T07:06:12");
assert(SysTime(DateTime(1998, 12, 25, 2, 15, 0),
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),
hnsecs(520_920)).toISOExtString() ==
"-0004-01-05T00:00:02.052092");
}
unittest
{
//Test A.D.
assert(SysTime(DateTime.init, UTC()).toISOExtString() == "0001-01-01T00:00:00Z");
assert(SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(1), UTC()).toISOExtString() ==
"0001-01-01T00:00:00.0000001Z");
assert(SysTime(DateTime(9, 12, 4, 0, 0, 0)).toISOExtString() == "0009-12-04T00:00:00");
assert(SysTime(DateTime(99, 12, 4, 5, 6, 12)).toISOExtString() == "0099-12-04T05:06:12");
assert(SysTime(DateTime(999, 12, 4, 13, 44, 59)).toISOExtString() == "0999-12-04T13:44:59");
assert(SysTime(DateTime(9999, 7, 4, 23, 59, 59)).toISOExtString() == "9999-07-04T23:59:59");
assert(SysTime(DateTime(10000, 10, 20, 1, 1, 1)).toISOExtString() == "+10000-10-20T01:01:01");
assert(SysTime(DateTime(9, 12, 4, 0, 0, 0), msecs(42)).toISOExtString() == "0009-12-04T00:00:00.042");
assert(SysTime(DateTime(99, 12, 4, 5, 6, 12), msecs(100)).toISOExtString() == "0099-12-04T05:06:12.1");
assert(SysTime(DateTime(999, 12, 4, 13, 44, 59), usecs(45020)).toISOExtString() == "0999-12-04T13:44:59.04502");
assert(SysTime(DateTime(9999, 7, 4, 23, 59, 59), hnsecs(12)).toISOExtString() == "9999-07-04T23:59:59.0000012");
assert(SysTime(DateTime(10000, 10, 20, 1, 1, 1), hnsecs(507890)).toISOExtString() ==
"+10000-10-20T01:01:01.050789");
assert(SysTime(DateTime(2012, 12, 21, 12, 12, 12),
new immutable SimpleTimeZone(dur!"minutes"(-360))).toISOExtString() ==
"2012-12-21T12:12:12-06:00");
assert(SysTime(DateTime(2012, 12, 21, 12, 12, 12),
new immutable SimpleTimeZone(dur!"minutes"(420))).toISOExtString() ==
"2012-12-21T12:12:12+07:00");
//Test B.C.
assert(SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999), UTC()).toISOExtString() ==
"0000-12-31T23:59:59.9999999Z");
assert(SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(1), UTC()).toISOExtString() ==
"0000-12-31T23:59:59.0000001Z");
assert(SysTime(DateTime(0, 12, 31, 23, 59, 59), UTC()).toISOExtString() == "0000-12-31T23:59:59Z");
assert(SysTime(DateTime(0, 12, 4, 0, 12, 4)).toISOExtString() == "0000-12-04T00:12:04");
assert(SysTime(DateTime(-9, 12, 4, 0, 0, 0)).toISOExtString() == "-0009-12-04T00:00:00");
assert(SysTime(DateTime(-99, 12, 4, 5, 6, 12)).toISOExtString() == "-0099-12-04T05:06:12");
assert(SysTime(DateTime(-999, 12, 4, 13, 44, 59)).toISOExtString() == "-0999-12-04T13:44:59");
assert(SysTime(DateTime(-9999, 7, 4, 23, 59, 59)).toISOExtString() == "-9999-07-04T23:59:59");
assert(SysTime(DateTime(-10000, 10, 20, 1, 1, 1)).toISOExtString() == "-10000-10-20T01:01:01");
assert(SysTime(DateTime(0, 12, 4, 0, 0, 0), msecs(7)).toISOExtString() == "0000-12-04T00:00:00.007");
assert(SysTime(DateTime(-9, 12, 4, 0, 0, 0), msecs(42)).toISOExtString() == "-0009-12-04T00:00:00.042");
assert(SysTime(DateTime(-99, 12, 4, 5, 6, 12), msecs(100)).toISOExtString() == "-0099-12-04T05:06:12.1");
assert(SysTime(DateTime(-999, 12, 4, 13, 44, 59), usecs(45020)).toISOExtString() ==
"-0999-12-04T13:44:59.04502");
assert(SysTime(DateTime(-9999, 7, 4, 23, 59, 59), hnsecs(12)).toISOExtString() ==
"-9999-07-04T23:59:59.0000012");
assert(SysTime(DateTime(-10000, 10, 20, 1, 1, 1), 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));
}
/++
Converts this $(LREF 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 $(LREF SysTime)'s time zone is $(LREF 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.
+/
string toSimpleString() @safe const nothrow
{
import std.format : format;
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 = fracSecsToISOString(cast(int)hnsecs);
if(_timezone is LocalTime())
return dateTime.toSimpleString() ~ fracSecsToISOString(cast(int)hnsecs);
if(_timezone is UTC())
return dateTime.toSimpleString() ~ fracSecsToISOString(cast(int)hnsecs) ~ "Z";
immutable utcOffset = dur!"hnsecs"(adjustedTime - stdTime);
return format("%s%s%s",
dateTime.toSimpleString(),
fracSecsToISOString(cast(int)hnsecs),
SimpleTimeZone.toISOString(utcOffset));
}
catch(Exception e)
assert(0, "format() threw.");
}
///
unittest
{
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),
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),
hnsecs(520_920)).toSimpleString() ==
"-0004-Jan-05 00:00:02.052092");
}
unittest
{
//Test A.D.
assert(SysTime(DateTime.init, UTC()).toString() == "0001-Jan-01 00:00:00Z");
assert(SysTime(DateTime(1, 1, 1, 0, 0, 0), hnsecs(1), UTC()).toString() == "0001-Jan-01 00:00:00.0000001Z");
assert(SysTime(DateTime(9, 12, 4, 0, 0, 0)).toSimpleString() == "0009-Dec-04 00:00:00");
assert(SysTime(DateTime(99, 12, 4, 5, 6, 12)).toSimpleString() == "0099-Dec-04 05:06:12");
assert(SysTime(DateTime(999, 12, 4, 13, 44, 59)).toSimpleString() == "0999-Dec-04 13:44:59");
assert(SysTime(DateTime(9999, 7, 4, 23, 59, 59)).toSimpleString() == "9999-Jul-04 23:59:59");
assert(SysTime(DateTime(10000, 10, 20, 1, 1, 1)).toSimpleString() == "+10000-Oct-20 01:01:01");
assert(SysTime(DateTime(9, 12, 4, 0, 0, 0), msecs(42)).toSimpleString() == "0009-Dec-04 00:00:00.042");
assert(SysTime(DateTime(99, 12, 4, 5, 6, 12), msecs(100)).toSimpleString() == "0099-Dec-04 05:06:12.1");
assert(SysTime(DateTime(999, 12, 4, 13, 44, 59), usecs(45020)).toSimpleString() ==
"0999-Dec-04 13:44:59.04502");
assert(SysTime(DateTime(9999, 7, 4, 23, 59, 59), hnsecs(12)).toSimpleString() ==
"9999-Jul-04 23:59:59.0000012");
assert(SysTime(DateTime(10000, 10, 20, 1, 1, 1), hnsecs(507890)).toSimpleString() ==
"+10000-Oct-20 01:01:01.050789");
assert(SysTime(DateTime(2012, 12, 21, 12, 12, 12),
new immutable SimpleTimeZone(dur!"minutes"(-360))).toSimpleString() ==
"2012-Dec-21 12:12:12-06:00");
assert(SysTime(DateTime(2012, 12, 21, 12, 12, 12),
new immutable SimpleTimeZone(dur!"minutes"(420))).toSimpleString() ==
"2012-Dec-21 12:12:12+07:00");
//Test B.C.
assert(SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(9_999_999), UTC()).toSimpleString() ==
"0000-Dec-31 23:59:59.9999999Z");
assert(SysTime(DateTime(0, 12, 31, 23, 59, 59), hnsecs(1), UTC()).toSimpleString() ==
"0000-Dec-31 23:59:59.0000001Z");
assert(SysTime(DateTime(0, 12, 31, 23, 59, 59), UTC()).toSimpleString() == "0000-Dec-31 23:59:59Z");
assert(SysTime(DateTime(0, 12, 4, 0, 12, 4)).toSimpleString() == "0000-Dec-04 00:12:04");
assert(SysTime(DateTime(-9, 12, 4, 0, 0, 0)).toSimpleString() == "-0009-Dec-04 00:00:00");
assert(SysTime(DateTime(-99, 12, 4, 5, 6, 12)).toSimpleString() == "-0099-Dec-04 05:06:12");
assert(SysTime(DateTime(-999, 12, 4, 13, 44, 59)).toSimpleString() == "-0999-Dec-04 13:44:59");
assert(SysTime(DateTime(-9999, 7, 4, 23, 59, 59)).toSimpleString() == "-9999-Jul-04 23:59:59");
assert(SysTime(DateTime(-10000, 10, 20, 1, 1, 1)).toSimpleString() == "-10000-Oct-20 01:01:01");
assert(SysTime(DateTime(0, 12, 4, 0, 0, 0), msecs(7)).toSimpleString() == "0000-Dec-04 00:00:00.007");
assert(SysTime(DateTime(-9, 12, 4, 0, 0, 0), msecs(42)).toSimpleString() == "-0009-Dec-04 00:00:00.042");
assert(SysTime(DateTime(-99, 12, 4, 5, 6, 12), msecs(100)).toSimpleString() == "-0099-Dec-04 05:06:12.1");
assert(SysTime(DateTime(-999, 12, 4, 13, 44, 59), usecs(45020)).toSimpleString() ==
"-0999-Dec-04 13:44:59.04502");
assert(SysTime(DateTime(-9999, 7, 4, 23, 59, 59), hnsecs(12)).toSimpleString() ==
"-9999-Jul-04 23:59:59.0000012");
assert(SysTime(DateTime(-10000, 10, 20, 1, 1, 1), 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));
}
/++
Converts this $(LREF SysTime) to a string.
+/
string toString() @safe const nothrow
{
return toSimpleString();
}
unittest
{
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 $(LREF 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 $(LREF 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 $(LREF SysTime) to be a particular time
zone, pass in that time zone and the $(LREF 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:
$(LREF DateTimeException) if the given string is not in the ISO format
or if the resulting $(LREF SysTime) would not be valid.
+/
static SysTime fromISOString(S)(in S isoString, immutable TimeZone tz = null) @safe
if(isSomeString!S)
{
import std.string : strip;
import std.conv : to;
import std.algorithm : startsWith, find;
import std.format : format;
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 = fracSecsFromISOString(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
{
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), msecs(7)));
assert(SysTime.fromISOString("00000105T230959.00002") ==
SysTime(DateTime(0, 1, 5, 23, 9, 59), 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 immutable SimpleTimeZone(dur!"hours"(-8))));
assert(SysTime.fromISOString("20100704T070612+8:00") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12),
new immutable SimpleTimeZone(dur!"hours"(8))));
}
unittest
{
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"));
assert(SysTime.fromISOString("20101222T172201") == SysTime(DateTime(2010, 12, 22, 17, 22, 01)));
assert(SysTime.fromISOString("19990706T123033") == SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
assert(SysTime.fromISOString("-19990706T123033") == SysTime(DateTime(-1999, 7, 6, 12, 30, 33)));
assert(SysTime.fromISOString("+019990706T123033") == SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
assert(SysTime.fromISOString("19990706T123033 ") == SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
assert(SysTime.fromISOString(" 19990706T123033") == SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
assert(SysTime.fromISOString(" 19990706T123033 ") == SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
assert(SysTime.fromISOString("19070707T121212.0") == SysTime(DateTime(1907, 07, 07, 12, 12, 12)));
assert(SysTime.fromISOString("19070707T121212.0000000") == SysTime(DateTime(1907, 07, 07, 12, 12, 12)));
assert(SysTime.fromISOString("19070707T121212.0000001") ==
SysTime(DateTime(1907, 07, 07, 12, 12, 12), hnsecs(1)));
assert(SysTime.fromISOString("19070707T121212.000001") ==
SysTime(DateTime(1907, 07, 07, 12, 12, 12), usecs(1)));
assert(SysTime.fromISOString("19070707T121212.0000010") ==
SysTime(DateTime(1907, 07, 07, 12, 12, 12), usecs(1)));
assert(SysTime.fromISOString("19070707T121212.001") == SysTime(DateTime(1907, 07, 07, 12, 12, 12), msecs(1)));
assert(SysTime.fromISOString("19070707T121212.0010000") ==
SysTime(DateTime(1907, 07, 07, 12, 12, 12), msecs(1)));
assert(SysTime.fromISOString("20101222T172201Z") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), UTC()));
assert(SysTime.fromISOString("20101222T172201-1:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(-60))));
assert(SysTime.fromISOString("20101222T172201-1") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(-60))));
assert(SysTime.fromISOString("20101222T172201-1:30") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(-90))));
assert(SysTime.fromISOString("20101222T172201-8:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(-480))));
assert(SysTime.fromISOString("20101222T172201+1:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(60))));
assert(SysTime.fromISOString("20101222T172201+1") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(60))));
assert(SysTime.fromISOString("20101222T172201+1:30") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(90))));
assert(SysTime.fromISOString("20101222T172201+8:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(480))));
assert(SysTime.fromISOString("20101103T065106.57159Z") ==
SysTime(DateTime(2010, 11, 3, 6, 51, 6), hnsecs(5715900), UTC()));
assert(SysTime.fromISOString("20101222T172201.23412Z") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(2_341_200), UTC()));
assert(SysTime.fromISOString("20101222T172201.23112-1:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(2_311_200),
new immutable SimpleTimeZone(dur!"minutes"(-60))));
assert(SysTime.fromISOString("20101222T172201.45-1") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(4_500_000),
new immutable SimpleTimeZone(dur!"minutes"(-60))));
assert(SysTime.fromISOString("20101222T172201.1-1:30") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(1_000_000),
new immutable SimpleTimeZone(dur!"minutes"(-90))));
assert(SysTime.fromISOString("20101222T172201.55-8:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(5_500_000),
new immutable SimpleTimeZone(dur!"minutes"(-480))));
assert(SysTime.fromISOString("20101222T172201.1234567+1:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(1_234_567),
new immutable SimpleTimeZone(dur!"minutes"(60))));
assert(SysTime.fromISOString("20101222T172201.0+1") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01),
new immutable SimpleTimeZone(dur!"minutes"(60))));
assert(SysTime.fromISOString("20101222T172201.0000000+1:30") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01),
new immutable SimpleTimeZone(dur!"minutes"(90))));
assert(SysTime.fromISOString("20101222T172201.45+8:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(4_500_000),
new immutable SimpleTimeZone(dur!"minutes"(480))));
}
/++
Creates a $(LREF 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 $(LREF 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 $(LREF SysTime) to be a particular time
zone, pass in that time zone and the $(LREF 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:
isoExtString = 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:
$(LREF DateTimeException) if the given string is not in the ISO format
or if the resulting $(LREF SysTime) would not be valid.
+/
static SysTime fromISOExtString(S)(in S isoExtString, immutable TimeZone tz = null) @safe
if(isSomeString!(S))
{
import std.string : strip;
import std.conv : to;
import std.algorithm : countUntil, find;
import std.format : format;
auto dstr = to!dstring(strip(isoExtString));
auto tIndex = dstr.countUntil('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 = fracSecsFromISOString(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
{
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), msecs(7)));
assert(SysTime.fromISOExtString("0000-01-05T23:09:59.00002") ==
SysTime(DateTime(0, 1, 5, 23, 9, 59), 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 immutable SimpleTimeZone(dur!"hours"(-8))));
assert(SysTime.fromISOExtString("2010-07-04T07:06:12+8:00") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12),
new immutable SimpleTimeZone(dur!"hours"(8))));
}
unittest
{
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"));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01") == SysTime(DateTime(2010, 12, 22, 17, 22, 01)));
assert(SysTime.fromISOExtString("1999-07-06T12:30:33") == SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
assert(SysTime.fromISOExtString("-1999-07-06T12:30:33") == SysTime(DateTime(-1999, 7, 6, 12, 30, 33)));
assert(SysTime.fromISOExtString("+01999-07-06T12:30:33") == SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
assert(SysTime.fromISOExtString("1999-07-06T12:30:33 ") == SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
assert(SysTime.fromISOExtString(" 1999-07-06T12:30:33") == SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
assert(SysTime.fromISOExtString(" 1999-07-06T12:30:33 ") == SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
assert(SysTime.fromISOExtString("1907-07-07T12:12:12.0") == SysTime(DateTime(1907, 07, 07, 12, 12, 12)));
assert(SysTime.fromISOExtString("1907-07-07T12:12:12.0000000") == SysTime(DateTime(1907, 07, 07, 12, 12, 12)));
assert(SysTime.fromISOExtString("1907-07-07T12:12:12.0000001") ==
SysTime(DateTime(1907, 07, 07, 12, 12, 12), hnsecs(1)));
assert(SysTime.fromISOExtString("1907-07-07T12:12:12.000001") ==
SysTime(DateTime(1907, 07, 07, 12, 12, 12), usecs(1)));
assert(SysTime.fromISOExtString("1907-07-07T12:12:12.0000010") ==
SysTime(DateTime(1907, 07, 07, 12, 12, 12), usecs(1)));
assert(SysTime.fromISOExtString("1907-07-07T12:12:12.001") ==
SysTime(DateTime(1907, 07, 07, 12, 12, 12), msecs(1)));
assert(SysTime.fromISOExtString("1907-07-07T12:12:12.0010000") ==
SysTime(DateTime(1907, 07, 07, 12, 12, 12), msecs(1)));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01Z") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), UTC()));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01-1:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(-60))));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01-1") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(-60))));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01-1:30") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(-90))));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01-8:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(-480))));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01+1:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(60))));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01+1") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(60))));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01+1:30") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(90))));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01+8:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(480))));
assert(SysTime.fromISOExtString("2010-11-03T06:51:06.57159Z") ==
SysTime(DateTime(2010, 11, 3, 6, 51, 6), hnsecs(5715900), UTC()));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01.23412Z") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(2_341_200), UTC()));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01.23112-1:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(2_311_200),
new immutable SimpleTimeZone(dur!"minutes"(-60))));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01.45-1") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(4_500_000),
new immutable SimpleTimeZone(dur!"minutes"(-60))));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01.1-1:30") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(1_000_000),
new immutable SimpleTimeZone(dur!"minutes"(-90))));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01.55-8:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(5_500_000),
new immutable SimpleTimeZone(dur!"minutes"(-480))));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01.1234567+1:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(1_234_567),
new immutable SimpleTimeZone(dur!"minutes"(60))));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01.0+1") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01),
new immutable SimpleTimeZone(dur!"minutes"(60))));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01.0000000+1:30") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01),
new immutable SimpleTimeZone(dur!"minutes"(90))));
assert(SysTime.fromISOExtString("2010-12-22T17:22:01.45+8:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(4_500_000),
new immutable SimpleTimeZone(dur!"minutes"(480))));
}
/++
Creates a $(LREF 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 $(LREF 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 $(LREF SysTime) to be a particular time
zone, pass in that time zone and the $(LREF 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:
$(LREF DateTimeException) if the given string is not in the ISO format
or if the resulting $(LREF SysTime) would not be valid.
+/
static SysTime fromSimpleString(S)(in S simpleString, immutable TimeZone tz = null) @safe
if(isSomeString!(S))
{
import std.string : strip;
import std.conv : to;
import std.algorithm : countUntil, find;
import std.format : format;
auto dstr = to!dstring(strip(simpleString));
auto spaceIndex = dstr.countUntil(' ');
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 = fracSecsFromISOString(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
{
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), msecs(7)));
assert(SysTime.fromSimpleString("0000-Jan-05 23:09:59.00002") ==
SysTime(DateTime(0, 1, 5, 23, 9, 59), 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 immutable SimpleTimeZone(dur!"hours"(-8))));
assert(SysTime.fromSimpleString("2010-Jul-04 07:06:12+8:00") ==
SysTime(DateTime(2010, 7, 4, 7, 6, 12),
new immutable SimpleTimeZone(dur!"hours"(8))));
}
unittest
{
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"));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01") == SysTime(DateTime(2010, 12, 22, 17, 22, 01)));
assert(SysTime.fromSimpleString("1999-Jul-06 12:30:33") == SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
assert(SysTime.fromSimpleString("-1999-Jul-06 12:30:33") == SysTime(DateTime(-1999, 7, 6, 12, 30, 33)));
assert(SysTime.fromSimpleString("+01999-Jul-06 12:30:33") == SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
assert(SysTime.fromSimpleString("1999-Jul-06 12:30:33 ") == SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
assert(SysTime.fromSimpleString(" 1999-Jul-06 12:30:33") == SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
assert(SysTime.fromSimpleString(" 1999-Jul-06 12:30:33 ") == SysTime(DateTime(1999, 7, 6, 12, 30, 33)));
assert(SysTime.fromSimpleString("1907-Jul-07 12:12:12.0") == SysTime(DateTime(1907, 07, 07, 12, 12, 12)));
assert(SysTime.fromSimpleString("1907-Jul-07 12:12:12.0000000") == SysTime(DateTime(1907, 07, 07, 12, 12, 12)));
assert(SysTime.fromSimpleString("1907-Jul-07 12:12:12.0000001") ==
SysTime(DateTime(1907, 07, 07, 12, 12, 12), hnsecs(1)));
assert(SysTime.fromSimpleString("1907-Jul-07 12:12:12.000001") ==
SysTime(DateTime(1907, 07, 07, 12, 12, 12), usecs(1)));
assert(SysTime.fromSimpleString("1907-Jul-07 12:12:12.0000010") ==
SysTime(DateTime(1907, 07, 07, 12, 12, 12), usecs(1)));
assert(SysTime.fromSimpleString("1907-Jul-07 12:12:12.001") ==
SysTime(DateTime(1907, 07, 07, 12, 12, 12), msecs(1)));
assert(SysTime.fromSimpleString("1907-Jul-07 12:12:12.0010000") ==
SysTime(DateTime(1907, 07, 07, 12, 12, 12), msecs(1)));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01Z") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), UTC()));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01-1:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(-60))));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01-1") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(-60))));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01-1:30") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(-90))));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01-8:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(-480))));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01+1:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(60))));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01+1") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(60))));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01+1:30") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(90))));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01+8:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), new immutable SimpleTimeZone(dur!"minutes"(480))));
assert(SysTime.fromSimpleString("2010-Nov-03 06:51:06.57159Z") ==
SysTime(DateTime(2010, 11, 3, 6, 51, 6), hnsecs(5715900), UTC()));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01.23412Z") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(2_341_200), UTC()));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01.23112-1:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(2_311_200),
new immutable SimpleTimeZone(dur!"minutes"(-60))));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01.45-1") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(4_500_000),
new immutable SimpleTimeZone(dur!"minutes"(-60))));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01.1-1:30") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(1_000_000),
new immutable SimpleTimeZone(dur!"minutes"(-90))));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01.55-8:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(5_500_000),
new immutable SimpleTimeZone(dur!"minutes"(-480))));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01.1234567+1:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(1_234_567),
new immutable SimpleTimeZone(dur!"minutes"(60))));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01.0+1") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01),
new immutable SimpleTimeZone(dur!"minutes"(60))));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01.0000000+1:30") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01),
new immutable SimpleTimeZone(dur!"minutes"(90))));
assert(SysTime.fromSimpleString("2010-Dec-22 17:22:01.45+8:00") ==
SysTime(DateTime(2010, 12, 22, 17, 22, 01), hnsecs(4_500_000),
new immutable SimpleTimeZone(dur!"minutes"(480))));
}
/++
Returns the $(LREF SysTime) farthest in the past which is representable
by $(LREF SysTime).
The $(LREF SysTime) which is returned is in UTC.
+/
@property static SysTime min() @safe pure nothrow
{
return SysTime(long.min, UTC());
}
unittest
{
assert(SysTime.min.year < 0);
assert(SysTime.min < SysTime.max);
}
/++
Returns the $(LREF SysTime) farthest in the future which is representable
by $(LREF SysTime).
The $(LREF SysTime) which is returned is in UTC.
+/
@property static SysTime max() @safe pure nothrow
{
return SysTime(long.max, UTC());
}
unittest
{
assert(SysTime.max.year > 0);
assert(SysTime.max > SysTime.min);
}
private:
/+
Returns $(D stdTime) converted to $(LREF SysTime)'s time zone.
+/
@property long adjTime() @safe const nothrow
{
return _timezone.utcToTZ(_stdTime);
}
/+
Converts the given hnsecs from $(LREF SysTime)'s time zone to std time.
+/
@property void adjTime(long adjTime) @safe 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
$(WEB en.wikipedia.org/wiki/Proleptic_Gregorian_calendar, 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. As per
$(WEB en.wikipedia.org/wiki/ISO_8601, ISO 8601), it treats 1 B.C. as
year 0, i.e. 1 B.C. is 0, 2 B.C. is -1, etc. Use $(LREF yearBC) to use 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:
$(LREF DateTimeException) if the resulting $(LREF 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) @safe 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
{
assert(Date(1, 1, 1) == Date.init);
static void testDate(in Date date, int year, int month, int day)
{
assert(date._year == year);
assert(date._month == month);
assert(date._day == day);
}
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
$(LREF Date) will be for.
+/
this(int day) @safe 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.");
}
}
}
unittest
{
import std.range;
//Test A.D.
foreach(gd; chain(testGregDaysBC, testGregDaysAD))
assert(Date(gd.day) == gd.date);
}
/++
Compares this $(LREF Date) with the given $(LREF 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) @safe 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
{
//Test A.D.
assert(Date(1, 1, 1).opCmp(Date.init) == 0);
assert(Date(1999, 1, 1).opCmp(Date(1999, 1, 1)) == 0);
assert(Date(1, 7, 1).opCmp(Date(1, 7, 1)) == 0);
assert(Date(1, 1, 6).opCmp(Date(1, 1, 6)) == 0);
assert(Date(1999, 7, 1).opCmp(Date(1999, 7, 1)) == 0);
assert(Date(1999, 7, 6).opCmp(Date(1999, 7, 6)) == 0);
assert(Date(1, 7, 6).opCmp(Date(1, 7, 6)) == 0);
assert(Date(1999, 7, 6).opCmp(Date(2000, 7, 6)) < 0);
assert(Date(2000, 7, 6).opCmp(Date(1999, 7, 6)) > 0);
assert(Date(1999, 7, 6).opCmp(Date(1999, 8, 6)) < 0);
assert(Date(1999, 8, 6).opCmp(Date(1999, 7, 6)) > 0);
assert(Date(1999, 7, 6).opCmp(Date(1999, 7, 7)) < 0);
assert(Date(1999, 7, 7).opCmp(Date(1999, 7, 6)) > 0);
assert(Date(1999, 8, 7).opCmp(Date(2000, 7, 6)) < 0);
assert(Date(2000, 8, 6).opCmp(Date(1999, 7, 7)) > 0);
assert(Date(1999, 7, 7).opCmp(Date(2000, 7, 6)) < 0);
assert(Date(2000, 7, 6).opCmp(Date(1999, 7, 7)) > 0);
assert(Date(1999, 7, 7).opCmp(Date(1999, 8, 6)) < 0);
assert(Date(1999, 8, 6).opCmp(Date(1999, 7, 7)) > 0);
//Test B.C.
assert(Date(0, 1, 1).opCmp(Date(0, 1, 1)) == 0);
assert(Date(-1, 1, 1).opCmp(Date(-1, 1, 1)) == 0);
assert(Date(-1, 7, 1).opCmp(Date(-1, 7, 1)) == 0);
assert(Date(-1, 1, 6).opCmp(Date(-1, 1, 6)) == 0);
assert(Date(-1999, 7, 1).opCmp(Date(-1999, 7, 1)) == 0);
assert(Date(-1999, 7, 6).opCmp(Date(-1999, 7, 6)) == 0);
assert(Date(-1, 7, 6).opCmp(Date(-1, 7, 6)) == 0);
assert(Date(-2000, 7, 6).opCmp(Date(-1999, 7, 6)) < 0);
assert(Date(-1999, 7, 6).opCmp(Date(-2000, 7, 6)) > 0);
assert(Date(-1999, 7, 6).opCmp(Date(-1999, 8, 6)) < 0);
assert(Date(-1999, 8, 6).opCmp(Date(-1999, 7, 6)) > 0);
assert(Date(-1999, 7, 6).opCmp(Date(-1999, 7, 7)) < 0);
assert(Date(-1999, 7, 7).opCmp(Date(-1999, 7, 6)) > 0);
assert(Date(-2000, 8, 6).opCmp(Date(-1999, 7, 7)) < 0);
assert(Date(-1999, 8, 7).opCmp(Date(-2000, 7, 6)) > 0);
assert(Date(-2000, 7, 6).opCmp(Date(-1999, 7, 7)) < 0);
assert(Date(-1999, 7, 7).opCmp(Date(-2000, 7, 6)) > 0);
assert(Date(-1999, 7, 7).opCmp(Date(-1999, 8, 6)) < 0);
assert(Date(-1999, 8, 6).opCmp(Date(-1999, 7, 7)) > 0);
//Test Both
assert(Date(-1999, 7, 6).opCmp(Date(1999, 7, 6)) < 0);
assert(Date(1999, 7, 6).opCmp(Date(-1999, 7, 6)) > 0);
assert(Date(-1999, 8, 6).opCmp(Date(1999, 7, 6)) < 0);
assert(Date(1999, 7, 6).opCmp(Date(-1999, 8, 6)) > 0);
assert(Date(-1999, 7, 7).opCmp(Date(1999, 7, 6)) < 0);
assert(Date(1999, 7, 6).opCmp(Date(-1999, 7, 7)) > 0);
assert(Date(-1999, 8, 7).opCmp(Date(1999, 7, 6)) < 0);
assert(Date(1999, 7, 6).opCmp(Date(-1999, 8, 7)) > 0);
assert(Date(-1999, 8, 6).opCmp(Date(1999, 6, 6)) < 0);
assert(Date(1999, 6, 8).opCmp(Date(-1999, 7, 6)) > 0);
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.
+/
@property short year() @safe const pure nothrow
{
return _year;
}
///
unittest
{
assert(Date(1999, 7, 6).year == 1999);
assert(Date(2010, 10, 4).year == 2010);
assert(Date(-7, 4, 5).year == -7);
}
unittest
{
assert(Date.init.year == 1);
assert(Date(1999, 7, 6).year == 1999);
assert(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));
}
/++
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:
$(LREF DateTimeException) if the new year is not a leap year and the
resulting date would be on February 29th.
+/
@property void year(int year) @safe pure
{
enforceValid!"days"(year, _month, _day);
_year = cast(short)year;
}
///
unittest
{
assert(Date(1999, 7, 6).year == 1999);
assert(Date(2010, 10, 4).year == 2010);
assert(Date(-7, 4, 5).year == -7);
}
unittest
{
static void testDateInvalid(Date date, int year)
{
date.year = year;
}
static void testDate(Date date, int year, in Date expected)
{
date.year = year;
assert(date == expected);
}
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));
}
/++
Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.
Throws:
$(LREF DateTimeException) if $(D isAD) is true.
+/
@property ushort yearBC() @safe const pure
{
import std.format : format;
if(isAD)
throw new DateTimeException(format("Year %s is A.D.", _year));
return cast(ushort)((_year * -1) + 1);
}
///
unittest
{
assert(Date(0, 1, 1).yearBC == 1);
assert(Date(-1, 1, 1).yearBC == 2);
assert(Date(-100, 1, 1).yearBC == 101);
}
unittest
{
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));
}
/++
Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.
Params:
year = The year B.C. to set this $(LREF Date)'s year to.
Throws:
$(LREF DateTimeException) if a non-positive value is given.
+/
@property void yearBC(int year) @safe pure
{
if(year <= 0)
throw new DateTimeException("The given year is not a year B.C.");
_year = cast(short)((year - 1) * -1);
}
///
unittest
{
auto date = Date(2010, 1, 1);
date.yearBC = 1;
assert(date == Date(0, 1, 1));
date.yearBC = 10;
assert(date == Date(-9, 1, 1));
}
unittest
{
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));
}
/++
Month of a Gregorian Year.
+/
@property Month month() @safe const pure nothrow
{
return _month;
}
///
unittest
{
assert(Date(1999, 7, 6).month == 7);
assert(Date(2010, 10, 4).month == 10);
assert(Date(-7, 4, 5).month == 4);
}
unittest
{
assert(Date.init.month == 1);
assert(Date(1999, 7, 6).month == 7);
assert(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));
}
/++
Month of a Gregorian Year.
Params:
month = The month to set this $(LREF Date)'s month to.
Throws:
$(LREF 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) @safe pure
{
enforceValid!"months"(month);
enforceValid!"days"(_year, month, _day);
_month = cast(Month)month;
}
unittest
{
static void testDate(Date date, Month month, in Date expected = Date.init)
{
date.month = month;
assert(expected != Date.init);
assert(date == expected);
}
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.
+/
@property ubyte day() @safe const pure nothrow
{
return _day;
}
///
unittest
{
assert(Date(1999, 7, 6).day == 6);
assert(Date(2010, 10, 4).day == 4);
assert(Date(-7, 4, 5).day == 5);
}
unittest
{
import std.range;
import std.format : format;
static void test(Date date, int expected)
{
assert(date.day == expected,
format("Value given: %s", date));
}
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 $(LREF Date)'s day to.
Throws:
$(LREF DateTimeException) if the given day is not a valid day of the
current month.
+/
@property void day(int day) @safe pure
{
enforceValid!"days"(_year, _month, day);
_day = cast(ubyte)day;
}
unittest
{
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;
assert(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;
assert(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 $(LREF 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
$(LREF Date).
allowOverflow = Whether the day should be allowed to overflow,
causing the month to increment.
+/
ref Date add(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) @safe 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;
}
return this;
}
///
unittest
{
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
{
//Test A.D.
{
auto date = Date(1999, 7, 6);
date.add!"years"(7);
assert(date == Date(2006, 7, 6));
date.add!"years"(-9);
assert(date == Date(1997, 7, 6));
}
{
auto date = Date(1999, 2, 28);
date.add!"years"(1);
assert(date == Date(2000, 2, 28));
}
{
auto date = Date(2000, 2, 29);
date.add!"years"(-1);
assert(date == Date(1999, 3, 1));
}
//Test B.C.
{
auto date = Date(-1999, 7, 6);
date.add!"years"(-7);
assert(date == Date(-2006, 7, 6));
date.add!"years"(9);
assert(date == Date(-1997, 7, 6));
}
{
auto date = Date(-1999, 2, 28);
date.add!"years"(-1);
assert(date == Date(-2000, 2, 28));
}
{
auto date = Date(-2000, 2, 29);
date.add!"years"(1);
assert(date == Date(-1999, 3, 1));
}
//Test Both
{
auto date = Date(4, 7, 6);
date.add!"years"(-5);
assert(date == Date(-1, 7, 6));
date.add!"years"(5);
assert(date == Date(4, 7, 6));
}
{
auto date = Date(-4, 7, 6);
date.add!"years"(5);
assert(date == Date(1, 7, 6));
date.add!"years"(-5);
assert(date == Date(-4, 7, 6));
}
{
auto date = Date(4, 7, 6);
date.add!"years"(-8);
assert(date == Date(-4, 7, 6));
date.add!"years"(8);
assert(date == Date(4, 7, 6));
}
{
auto date = Date(-4, 7, 6);
date.add!"years"(8);
assert(date == Date(4, 7, 6));
date.add!"years"(-8);
assert(date == Date(-4, 7, 6));
}
{
auto date = Date(-4, 2, 29);
date.add!"years"(5);
assert(date == Date(1, 3, 1));
}
{
auto date = Date(4, 2, 29);
date.add!"years"(-5);
assert(date == Date(-1, 3, 1));
}
{
auto date = Date(4, 2, 29);
date.add!"years"(-5).add!"years"(7);
assert(date == Date(6, 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
{
//Test A.D.
{
auto date = Date(1999, 7, 6);
date.add!"years"(7, AllowDayOverflow.no);
assert(date == Date(2006, 7, 6));
date.add!"years"(-9, AllowDayOverflow.no);
assert(date == Date(1997, 7, 6));
}
{
auto date = Date(1999, 2, 28);
date.add!"years"(1, AllowDayOverflow.no);
assert(date == Date(2000, 2, 28));
}
{
auto date = Date(2000, 2, 29);
date.add!"years"(-1, AllowDayOverflow.no);
assert(date == Date(1999, 2, 28));
}
//Test B.C.
{
auto date = Date(-1999, 7, 6);
date.add!"years"(-7, AllowDayOverflow.no);
assert(date == Date(-2006, 7, 6));
date.add!"years"(9, AllowDayOverflow.no);
assert(date == Date(-1997, 7, 6));
}
{
auto date = Date(-1999, 2, 28);
date.add!"years"(-1, AllowDayOverflow.no);
assert(date == Date(-2000, 2, 28));
}
{
auto date = Date(-2000, 2, 29);
date.add!"years"(1, AllowDayOverflow.no);
assert(date == Date(-1999, 2, 28));
}
//Test Both
{
auto date = Date(4, 7, 6);
date.add!"years"(-5, AllowDayOverflow.no);
assert(date == Date(-1, 7, 6));
date.add!"years"(5, AllowDayOverflow.no);
assert(date == Date(4, 7, 6));
}
{
auto date = Date(-4, 7, 6);
date.add!"years"(5, AllowDayOverflow.no);
assert(date == Date(1, 7, 6));
date.add!"years"(-5, AllowDayOverflow.no);
assert(date == Date(-4, 7, 6));
}
{
auto date = Date(4, 7, 6);
date.add!"years"(-8, AllowDayOverflow.no);
assert(date == Date(-4, 7, 6));
date.add!"years"(8, AllowDayOverflow.no);
assert(date == Date(4, 7, 6));
}
{
auto date = Date(-4, 7, 6);
date.add!"years"(8, AllowDayOverflow.no);
assert(date == Date(4, 7, 6));
date.add!"years"(-8, AllowDayOverflow.no);
assert(date == Date(-4, 7, 6));
}
{
auto date = Date(-4, 2, 29);
date.add!"years"(5, AllowDayOverflow.no);
assert(date == Date(1, 2, 28));
}
{
auto date = Date(4, 2, 29);
date.add!"years"(-5, AllowDayOverflow.no);
assert(date == Date(-1, 2, 28));
}
{
auto date = Date(4, 2, 29);
date.add!"years"(-5, AllowDayOverflow.no).add!"years"(7, AllowDayOverflow.no);
assert(date == Date(6, 2, 28));
}
}
//Shares documentation with "years" version.
ref Date add(string units)(long months, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) @safe 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;
}
return this;
}
//Test add!"months"() with AllowDayOverlow.yes
unittest
{
//Test A.D.
{
auto date = Date(1999, 7, 6);
date.add!"months"(3);
assert(date == Date(1999, 10, 6));
date.add!"months"(-4);
assert(date == Date(1999, 6, 6));
}
{
auto date = Date(1999, 7, 6);
date.add!"months"(6);
assert(date == Date(2000, 1, 6));
date.add!"months"(-6);
assert(date == Date(1999, 7, 6));
}
{
auto date = Date(1999, 7, 6);
date.add!"months"(27);
assert(date == Date(2001, 10, 6));
date.add!"months"(-28);
assert(date == Date(1999, 6, 6));
}
{
auto date = Date(1999, 5, 31);
date.add!"months"(1);
assert(date == Date(1999, 7, 1));
}
{
auto date = Date(1999, 5, 31);
date.add!"months"(-1);
assert(date == Date(1999, 5, 1));
}
{
auto date = Date(1999, 2, 28);
date.add!"months"(12);
assert(date == Date(2000, 2, 28));
}
{
auto date = Date(2000, 2, 29);
date.add!"months"(12);
assert(date == Date(2001, 3, 1));
}
{
auto date = Date(1999, 7, 31);
date.add!"months"(1);
assert(date == Date(1999, 8, 31));
date.add!"months"(1);
assert(date == Date(1999, 10, 1));
}
{
auto date = Date(1998, 8, 31);
date.add!"months"(13);
assert(date == Date(1999, 10, 1));
date.add!"months"(-13);
assert(date == Date(1998, 9, 1));
}
{
auto date = Date(1997, 12, 31);
date.add!"months"(13);
assert(date == Date(1999, 1, 31));
date.add!"months"(-13);
assert(date == Date(1997, 12, 31));
}
{
auto date = Date(1997, 12, 31);
date.add!"months"(14);
assert(date == Date(1999, 3, 3));
date.add!"months"(-14);
assert(date == Date(1998, 1, 3));
}
{
auto date = Date(1998, 12, 31);
date.add!"months"(14);
assert(date == Date(2000, 3, 2));
date.add!"months"(-14);
assert(date == Date(1999, 1, 2));
}
{
auto date = Date(1999, 12, 31);
date.add!"months"(14);
assert(date == Date(2001, 3, 3));
date.add!"months"(-14);
assert(date == Date(2000, 1, 3));
}
//Test B.C.
{
auto date = Date(-1999, 7, 6);
date.add!"months"(3);
assert(date == Date(-1999, 10, 6));
date.add!"months"(-4);
assert(date == Date(-1999, 6, 6));
}
{
auto date = Date(-1999, 7, 6);
date.add!"months"(6);
assert(date == Date(-1998, 1, 6));
date.add!"months"(-6);
assert(date == Date(-1999, 7, 6));
}
{
auto date = Date(-1999, 7, 6);
date.add!"months"(-27);
assert(date == Date(-2001, 4, 6));
date.add!"months"(28);
assert(date == Date(-1999, 8, 6));
}
{
auto date = Date(-1999, 5, 31);
date.add!"months"(1);
assert(date == Date(-1999, 7, 1));
}
{
auto date = Date(-1999, 5, 31);
date.add!"months"(-1);
assert(date == Date(-1999, 5, 1));
}
{
auto date = Date(-1999, 2, 28);
date.add!"months"(-12);
assert(date == Date(-2000, 2, 28));
}
{
auto date = Date(-2000, 2, 29);
date.add!"months"(-12);
assert(date == Date(-2001, 3, 1));
}
{
auto date = Date(-1999, 7, 31);
date.add!"months"(1);
assert(date == Date(-1999, 8, 31));
date.add!"months"(1);
assert(date == Date(-1999, 10, 1));
}
{
auto date = Date(-1998, 8, 31);
date.add!"months"(13);
assert(date == Date(-1997, 10, 1));
date.add!"months"(-13);
assert(date == Date(-1998, 9, 1));
}
{
auto date = Date(-1997, 12, 31);
date.add!"months"(13);
assert(date == Date(-1995, 1, 31));
date.add!"months"(-13);
assert(date == Date(-1997, 12, 31));
}
{
auto date = Date(-1997, 12, 31);
date.add!"months"(14);
assert(date == Date(-1995, 3, 3));
date.add!"months"(-14);
assert(date == Date(-1996, 1, 3));
}
{
auto date = Date(-2002, 12, 31);
date.add!"months"(14);
assert(date == Date(-2000, 3, 2));
date.add!"months"(-14);
assert(date == Date(-2001, 1, 2));
}
{
auto date = Date(-2001, 12, 31);
date.add!"months"(14);
assert(date == Date(-1999, 3, 3));
date.add!"months"(-14);
assert(date == Date(-2000, 1, 3));
}
//Test Both
{
auto date = Date(1, 1, 1);
date.add!"months"(-1);
assert(date == Date(0, 12, 1));
date.add!"months"(1);
assert(date == Date(1, 1, 1));
}
{
auto date = Date(4, 1, 1);
date.add!"months"(-48);
assert(date == Date(0, 1, 1));
date.add!"months"(48);
assert(date == Date(4, 1, 1));
}
{
auto date = Date(4, 3, 31);
date.add!"months"(-49);
assert(date == Date(0, 3, 2));
date.add!"months"(49);
assert(date == Date(4, 4, 2));
}
{
auto date = Date(4, 3, 31);
date.add!"months"(-85);
assert(date == Date(-3, 3, 3));
date.add!"months"(85);
assert(date == Date(4, 4, 3));
}
{
auto date = Date(-3, 3, 31);
date.add!"months"(85).add!"months"(-83);
assert(date == Date(-3, 6, 1));
}
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
{
//Test A.D.
{
auto date = Date(1999, 7, 6);
date.add!"months"(3, AllowDayOverflow.no);
assert(date == Date(1999, 10, 6));
date.add!"months"(-4, AllowDayOverflow.no);
assert(date == Date(1999, 6, 6));
}
{
auto date = Date(1999, 7, 6);
date.add!"months"(6, AllowDayOverflow.no);
assert(date == Date(2000, 1, 6));
date.add!"months"(-6, AllowDayOverflow.no);
assert(date == Date(1999, 7, 6));
}
{
auto date = Date(1999, 7, 6);
date.add!"months"(27, AllowDayOverflow.no);
assert(date == Date(2001, 10, 6));
date.add!"months"(-28, AllowDayOverflow.no);
assert(date == Date(1999, 6, 6));
}
{
auto date = Date(1999, 5, 31);
date.add!"months"(1, AllowDayOverflow.no);
assert(date == Date(1999, 6, 30));
}
{
auto date = Date(1999, 5, 31);
date.add!"months"(-1, AllowDayOverflow.no);
assert(date == Date(1999, 4, 30));
}
{
auto date = Date(1999, 2, 28);
date.add!"months"(12, AllowDayOverflow.no);
assert(date == Date(2000, 2, 28));
}
{
auto date = Date(2000, 2, 29);
date.add!"months"(12, AllowDayOverflow.no);
assert(date == Date(2001, 2, 28));
}
{
auto date = Date(1999, 7, 31);
date.add!"months"(1, AllowDayOverflow.no);
assert(date == Date(1999, 8, 31));
date.add!"months"(1, AllowDayOverflow.no);
assert(date == Date(1999, 9, 30));
}
{
auto date = Date(1998, 8, 31);
date.add!"months"(13, AllowDayOverflow.no);
assert(date == Date(1999, 9, 30));
date.add!"months"(-13, AllowDayOverflow.no);
assert(date == Date(1998, 8, 30));
}
{
auto date = Date(1997, 12, 31);
date.add!"months"(13, AllowDayOverflow.no);
assert(date == Date(1999, 1, 31));
date.add!"months"(-13, AllowDayOverflow.no);
assert(date == Date(1997, 12, 31));
}
{
auto date = Date(1997, 12, 31);
date.add!"months"(14, AllowDayOverflow.no);
assert(date == Date(1999, 2, 28));
date.add!"months"(-14, AllowDayOverflow.no);
assert(date == Date(1997, 12, 28));
}
{
auto date = Date(1998, 12, 31);
date.add!"months"(14, AllowDayOverflow.no);
assert(date == Date(2000, 2, 29));
date.add!"months"(-14, AllowDayOverflow.no);
assert(date == Date(1998, 12, 29));
}
{
auto date = Date(1999, 12, 31);
date.add!"months"(14, AllowDayOverflow.no);
assert(date == Date(2001, 2, 28));
date.add!"months"(-14, AllowDayOverflow.no);
assert(date == Date(1999, 12, 28));
}
//Test B.C.
{
auto date = Date(-1999, 7, 6);
date.add!"months"(3, AllowDayOverflow.no);
assert(date == Date(-1999, 10, 6));
date.add!"months"(-4, AllowDayOverflow.no);
assert(date == Date(-1999, 6, 6));
}
{
auto date = Date(-1999, 7, 6);
date.add!"months"(6, AllowDayOverflow.no);
assert(date == Date(-1998, 1, 6));
date.add!"months"(-6, AllowDayOverflow.no);
assert(date == Date(-1999, 7, 6));
}
{
auto date = Date(-1999, 7, 6);
date.add!"months"(-27, AllowDayOverflow.no);
assert(date == Date(-2001, 4, 6));
date.add!"months"(28, AllowDayOverflow.no);
assert(date == Date(-1999, 8, 6));
}
{
auto date = Date(-1999, 5, 31);
date.add!"months"(1, AllowDayOverflow.no);
assert(date == Date(-1999, 6, 30));
}
{
auto date = Date(-1999, 5, 31);
date.add!"months"(-1, AllowDayOverflow.no);
assert(date == Date(-1999, 4, 30));
}
{
auto date = Date(-1999, 2, 28);
date.add!"months"(-12, AllowDayOverflow.no);
assert(date == Date(-2000, 2, 28));
}
{
auto date = Date(-2000, 2, 29);
date.add!"months"(-12, AllowDayOverflow.no);
assert(date == Date(-2001, 2, 28));
}
{
auto date = Date(-1999, 7, 31);
date.add!"months"(1, AllowDayOverflow.no);
assert(date == Date(-1999, 8, 31));
date.add!"months"(1, AllowDayOverflow.no);
assert(date == Date(-1999, 9, 30));
}
{
auto date = Date(-1998, 8, 31);
date.add!"months"(13, AllowDayOverflow.no);
assert(date == Date(-1997, 9, 30));
date.add!"months"(-13, AllowDayOverflow.no);
assert(date == Date(-1998, 8, 30));
}
{
auto date = Date(-1997, 12, 31);
date.add!"months"(13, AllowDayOverflow.no);
assert(date == Date(-1995, 1, 31));
date.add!"months"(-13, AllowDayOverflow.no);
assert(date == Date(-1997, 12, 31));
}
{
auto date = Date(-1997, 12, 31);
date.add!"months"(14, AllowDayOverflow.no);
assert(date == Date(-1995, 2, 28));
date.add!"months"(-14, AllowDayOverflow.no);
assert(date == Date(-1997, 12, 28));
}
{
auto date = Date(-2002, 12, 31);
date.add!"months"(14, AllowDayOverflow.no);
assert(date == Date(-2000, 2, 29));
date.add!"months"(-14, AllowDayOverflow.no);
assert(date == Date(-2002, 12, 29));
}
{
auto date = Date(-2001, 12, 31);
date.add!"months"(14, AllowDayOverflow.no);
assert(date == Date(-1999, 2, 28));
date.add!"months"(-14, AllowDayOverflow.no);
assert(date == Date(-2001, 12, 28));
}
//Test Both
{
auto date = Date(1, 1, 1);
date.add!"months"(-1, AllowDayOverflow.no);
assert(date == Date(0, 12, 1));
date.add!"months"(1, AllowDayOverflow.no);
assert(date == Date(1, 1, 1));
}
{
auto date = Date(4, 1, 1);
date.add!"months"(-48, AllowDayOverflow.no);
assert(date == Date(0, 1, 1));
date.add!"months"(48, AllowDayOverflow.no);
assert(date == Date(4, 1, 1));
}
{
auto date = Date(4, 3, 31);
date.add!"months"(-49, AllowDayOverflow.no);
assert(date == Date(0, 2, 29));
date.add!"months"(49, AllowDayOverflow.no);
assert(date == Date(4, 3, 29));
}
{
auto date = Date(4, 3, 31);
date.add!"months"(-85, AllowDayOverflow.no);
assert(date == Date(-3, 2, 28));
date.add!"months"(85, AllowDayOverflow.no);
assert(date == Date(4, 3, 28));
}
{
auto date = Date(-3, 3, 31);
date.add!"months"(85, AllowDayOverflow.no).add!"months"(-83, AllowDayOverflow.no);
assert(date == Date(-3, 5, 30));
}
}
/++
Adds the given number of years or months to this $(LREF Date). A negative
number will subtract.
The difference between rolling and adding is that rolling does not
affect larger units. Rolling a $(LREF Date) 12 months gets
the exact same $(LREF 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
$(LREF Date).
allowOverflow = Whether the day should be allowed to overflow,
causing the month to increment.
+/
ref Date roll(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) @safe pure nothrow
if(units == "years")
{
return add!"years"(value, allowOverflow);
}
///
unittest
{
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
{
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 roll(string units)(long months, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) @safe 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;
}
return this;
}
//Test roll!"months"() with AllowDayOverlow.yes
unittest
{
//Test A.D.
{
auto date = Date(1999, 7, 6);
date.roll!"months"(3);
assert(date == Date(1999, 10, 6));
date.roll!"months"(-4);
assert(date == Date(1999, 6, 6));
}
{
auto date = Date(1999, 7, 6);
date.roll!"months"(6);
assert(date == Date(1999, 1, 6));
date.roll!"months"(-6);
assert(date == Date(1999, 7, 6));
}
{
auto date = Date(1999, 7, 6);
date.roll!"months"(27);
assert(date == Date(1999, 10, 6));
date.roll!"months"(-28);
assert(date == Date(1999, 6, 6));
}
{
auto date = Date(1999, 5, 31);
date.roll!"months"(1);
assert(date == Date(1999, 7, 1));
}
{
auto date = Date(1999, 5, 31);
date.roll!"months"(-1);
assert(date == Date(1999, 5, 1));
}
{
auto date = Date(1999, 2, 28);
date.roll!"months"(12);
assert(date == Date(1999, 2, 28));
}
{
auto date = Date(2000, 2, 29);
date.roll!"months"(12);
assert(date == Date(2000, 2, 29));
}
{
auto date = Date(1999, 7, 31);
date.roll!"months"(1);
assert(date == Date(1999, 8, 31));
date.roll!"months"(1);
assert(date == Date(1999, 10, 1));
}
{
auto date = Date(1998, 8, 31);
date.roll!"months"(13);
assert(date == Date(1998, 10, 1));
date.roll!"months"(-13);
assert(date == Date(1998, 9, 1));
}
{
auto date = Date(1997, 12, 31);
date.roll!"months"(13);
assert(date == Date(1997, 1, 31));
date.roll!"months"(-13);
assert(date == Date(1997, 12, 31));
}
{
auto date = Date(1997, 12, 31);
date.roll!"months"(14);
assert(date == Date(1997, 3, 3));
date.roll!"months"(-14);
assert(date == Date(1997, 1, 3));
}
{
auto date = Date(1998, 12, 31);
date.roll!"months"(14);
assert(date == Date(1998, 3, 3));
date.roll!"months"(-14);
assert(date == Date(1998, 1, 3));
}
{
auto date = Date(1999, 12, 31);
date.roll!"months"(14);
assert(date == Date(1999, 3, 3));
date.roll!"months"(-14);
assert(date == Date(1999, 1, 3));
}
//Test B.C.
{
auto date = Date(-1999, 7, 6);
date.roll!"months"(3);
assert(date == Date(-1999, 10, 6));
date.roll!"months"(-4);
assert(date == Date(-1999, 6, 6));
}
{
auto date = Date(-1999, 7, 6);
date.roll!"months"(6);
assert(date == Date(-1999, 1, 6));
date.roll!"months"(-6);
assert(date == Date(-1999, 7, 6));
}
{
auto date = Date(-1999, 7, 6);
date.roll!"months"(-27);
assert(date == Date(-1999, 4, 6));
date.roll!"months"(28);
assert(date == Date(-1999, 8, 6));
}
{
auto date = Date(-1999, 5, 31);
date.roll!"months"(1);
assert(date == Date(-1999, 7, 1));
}
{
auto date = Date(-1999, 5, 31);
date.roll!"months"(-1);
assert(date == Date(-1999, 5, 1));
}
{
auto date = Date(-1999, 2, 28);
date.roll!"months"(-12);
assert(date == Date(-1999, 2, 28));
}
{
auto date = Date(-2000, 2, 29);
date.roll!"months"(-12);
assert(date == Date(-2000, 2, 29));
}
{
auto date = Date(-1999, 7, 31);
date.roll!"months"(1);
assert(date == Date(-1999, 8, 31));
date.roll!"months"(1);
assert(date == Date(-1999, 10, 1));
}
{
auto date = Date(-1998, 8, 31);
date.roll!"months"(13);
assert(date == Date(-1998, 10, 1));
date.roll!"months"(-13);
assert(date == Date(-1998, 9, 1));
}
{
auto date = Date(-1997, 12, 31);
date.roll!"months"(13);
assert(date == Date(-1997, 1, 31));
date.roll!"months"(-13);
assert(date == Date(-1997, 12, 31));
}
{
auto date = Date(-1997, 12, 31);
date.roll!"months"(14);
assert(date == Date(-1997, 3, 3));
date.roll!"months"(-14);
assert(date == Date(-1997, 1, 3));
}
{
auto date = Date(-2002, 12, 31);
date.roll!"months"(14);
assert(date == Date(-2002, 3, 3));
date.roll!"months"(-14);
assert(date == Date(-2002, 1, 3));
}
{
auto date = Date(-2001, 12, 31);
date.roll!"months"(14);
assert(date == Date(-2001, 3, 3));
date.roll!"months"(-14);
assert(date == Date(-2001, 1, 3));
}
//Test Both
{
auto date = Date(1, 1, 1);
date.roll!"months"(-1);
assert(date == Date(1, 12, 1));
date.roll!"months"(1);
assert(date == Date(1, 1, 1));
}
{
auto date = Date(4, 1, 1);
date.roll!"months"(-48);
assert(date == Date(4, 1, 1));
date.roll!"months"(48);
assert(date == Date(4, 1, 1));
}
{
auto date = Date(4, 3, 31);
date.roll!"months"(-49);
assert(date == Date(4, 3, 2));
date.roll!"months"(49);
assert(date == Date(4, 4, 2));
}
{
auto date = Date(4, 3, 31);
date.roll!"months"(-85);
assert(date == Date(4, 3, 2));
date.roll!"months"(85);
assert(date == Date(4, 4, 2));
}
{
auto date = Date(-1, 1, 1);
date.roll!"months"(-1);
assert(date == Date(-1, 12, 1));
date.roll!"months"(1);
assert(date == Date(-1, 1, 1));
}
{
auto date = Date(-4, 1, 1);
date.roll!"months"(-48);
assert(date == Date(-4, 1, 1));
date.roll!"months"(48);
assert(date == Date(-4, 1, 1));
}
{
auto date = Date(-4, 3, 31);
date.roll!"months"(-49);
assert(date == Date(-4, 3, 2));
date.roll!"months"(49);
assert(date == Date(-4, 4, 2));
}
{
auto date = Date(-4, 3, 31);
date.roll!"months"(-85);
assert(date == Date(-4, 3, 2));
date.roll!"months"(85);
assert(date == Date(-4, 4, 2));
}
{
auto date = Date(-3, 3, 31);
date.roll!"months"(85).roll!"months"(-83);
assert(date == Date(-3, 6, 1));
}
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)));
}
//Test roll!"months"() with AllowDayOverlow.no
unittest
{
//Test A.D.
{
auto date = Date(1999, 7, 6);
date.roll!"months"(3, AllowDayOverflow.no);
assert(date == Date(1999, 10, 6));
date.roll!"months"(-4, AllowDayOverflow.no);
assert(date == Date(1999, 6, 6));
}
{
auto date = Date(1999, 7, 6);
date.roll!"months"(6, AllowDayOverflow.no);
assert(date == Date(1999, 1, 6));
date.roll!"months"(-6, AllowDayOverflow.no);
assert(date == Date(1999, 7, 6));
}
{
auto date = Date(1999, 7, 6);
date.roll!"months"(27, AllowDayOverflow.no);
assert(date == Date(1999, 10, 6));
date.roll!"months"(-28, AllowDayOverflow.no);
assert(date == Date(1999, 6, 6));
}
{
auto date = Date(1999, 5, 31);
date.roll!"months"(1, AllowDayOverflow.no);
assert(date == Date(1999, 6, 30));
}
{
auto date = Date(1999, 5, 31);
date.roll!"months"(-1, AllowDayOverflow.no);
assert(date == Date(1999, 4, 30));
}
{
auto date = Date(1999, 2, 28);
date.roll!"months"(12, AllowDayOverflow.no);
assert(date == Date(1999, 2, 28));
}
{
auto date = Date(2000, 2, 29);
date.roll!"months"(12, AllowDayOverflow.no);
assert(date == Date(2000, 2, 29));
}
{
auto date = Date(1999, 7, 31);
date.roll!"months"(1, AllowDayOverflow.no);
assert(date == Date(1999, 8, 31));
date.roll!"months"(1, AllowDayOverflow.no);
assert(date == Date(1999, 9, 30));
}
{
auto date = Date(1998, 8, 31);
date.roll!"months"(13, AllowDayOverflow.no);
assert(date == Date(1998, 9, 30));
date.roll!"months"(-13, AllowDayOverflow.no);
assert(date == Date(1998, 8, 30));
}
{
auto date = Date(1997, 12, 31);
date.roll!"months"(13, AllowDayOverflow.no);
assert(date == Date(1997, 1, 31));
date.roll!"months"(-13, AllowDayOverflow.no);
assert(date == Date(1997, 12, 31));
}
{
auto date = Date(1997, 12, 31);
date.roll!"months"(14, AllowDayOverflow.no);
assert(date == Date(1997, 2, 28));
date.roll!"months"(-14, AllowDayOverflow.no);
assert(date == Date(1997, 12, 28));
}
{
auto date = Date(1998, 12, 31);
date.roll!"months"(14, AllowDayOverflow.no);
assert(date == Date(1998, 2, 28));
date.roll!"months"(-14, AllowDayOverflow.no);
assert(date == Date(1998, 12, 28));
}
{
auto date = Date(1999, 12, 31);
date.roll!"months"(14, AllowDayOverflow.no);
assert(date == Date(1999, 2, 28));
date.roll!"months"(-14, AllowDayOverflow.no);
assert(date == Date(1999, 12, 28));
}
//Test B.C.
{
auto date = Date(-1999, 7, 6);
date.roll!"months"(3, AllowDayOverflow.no);
assert(date == Date(-1999, 10, 6));
date.roll!"months"(-4, AllowDayOverflow.no);
assert(date == Date(-1999, 6, 6));
}
{
auto date = Date(-1999, 7, 6);
date.roll!"months"(6, AllowDayOverflow.no);
assert(date == Date(-1999, 1, 6));
date.roll!"months"(-6, AllowDayOverflow.no);
assert(date == Date(-1999, 7, 6));
}
{
auto date = Date(-1999, 7, 6);
date.roll!"months"(-27, AllowDayOverflow.no);
assert(date == Date(-1999, 4, 6));
date.roll!"months"(28, AllowDayOverflow.no);
assert(date == Date(-1999, 8, 6));
}
{
auto date = Date(-1999, 5, 31);
date.roll!"months"(1, AllowDayOverflow.no);
assert(date == Date(-1999, 6, 30));
}
{
auto date = Date(-1999, 5, 31);
date.roll!"months"(-1, AllowDayOverflow.no);
assert(date == Date(-1999, 4, 30));
}
{
auto date = Date(-1999, 2, 28);
date.roll!"months"(-12, AllowDayOverflow.no);
assert(date == Date(-1999, 2, 28));
}
{
auto date = Date(-2000, 2, 29);
date.roll!"months"(-12, AllowDayOverflow.no);
assert(date == Date(-2000, 2, 29));
}
{
auto date = Date(-1999, 7, 31);
date.roll!"months"(1, AllowDayOverflow.no);
assert(date == Date(-1999, 8, 31));
date.roll!"months"(1, AllowDayOverflow.no);
assert(date == Date(-1999, 9, 30));
}
{
auto date = Date(-1998, 8, 31);
date.roll!"months"(13, AllowDayOverflow.no);
assert(date == Date(-1998, 9, 30));
date.roll!"months"(-13, AllowDayOverflow.no);
assert(date == Date(-1998, 8, 30));
}
{
auto date = Date(-1997, 12, 31);
date.roll!"months"(13, AllowDayOverflow.no);
assert(date == Date(-1997, 1, 31));
date.roll!"months"(-13, AllowDayOverflow.no);
assert(date == Date(-1997, 12, 31));
}
{
auto date = Date(-1997, 12, 31);
date.roll!"months"(14, AllowDayOverflow.no);
assert(date == Date(-1997, 2, 28));
date.roll!"months"(-14, AllowDayOverflow.no);
assert(date == Date(-1997, 12, 28));
}
{
auto date = Date(-2002, 12, 31);
date.roll!"months"(14, AllowDayOverflow.no);
assert(date == Date(-2002, 2, 28));
date.roll!"months"(-14, AllowDayOverflow.no);
assert(date == Date(-2002, 12, 28));
}
{
auto date = Date(-2001, 12, 31);
date.roll!"months"(14, AllowDayOverflow.no);
assert(date == Date(-2001, 2, 28));
date.roll!"months"(-14, AllowDayOverflow.no);
assert(date == Date(-2001, 12, 28));
}
//Test Both
{
auto date = Date(1, 1, 1);
date.roll!"months"(-1, AllowDayOverflow.no);
assert(date == Date(1, 12, 1));
date.roll!"months"(1, AllowDayOverflow.no);
assert(date == Date(1, 1, 1));
}
{
auto date = Date(4, 1, 1);
date.roll!"months"(-48, AllowDayOverflow.no);
assert(date == Date(4, 1, 1));
date.roll!"months"(48, AllowDayOverflow.no);
assert(date == Date(4, 1, 1));
}
{
auto date = Date(4, 3, 31);
date.roll!"months"(-49, AllowDayOverflow.no);
assert(date == Date(4, 2, 29));
date.roll!"months"(49, AllowDayOverflow.no);
assert(date == Date(4, 3, 29));
}
{
auto date = Date(4, 3, 31);
date.roll!"months"(-85, AllowDayOverflow.no);
assert(date == Date(4, 2, 29));
date.roll!"months"(85, AllowDayOverflow.no);
assert(date == Date(4, 3, 29));
}
{
auto date = Date(-1, 1, 1);
date.roll!"months"(-1, AllowDayOverflow.no);
assert(date == Date(-1, 12, 1));
date.roll!"months"(1, AllowDayOverflow.no);
assert(date == Date(-1, 1, 1));
}
{
auto date = Date(-4, 1, 1);
date.roll!"months"(-48, AllowDayOverflow.no);
assert(date == Date(-4, 1, 1));
date.roll!"months"(48, AllowDayOverflow.no);
assert(date == Date(-4, 1, 1));
}
{
auto date = Date(-4, 3, 31);
date.roll!"months"(-49, AllowDayOverflow.no);
assert(date == Date(-4, 2, 29));
date.roll!"months"(49, AllowDayOverflow.no);
assert(date == Date(-4, 3, 29));
}
{
auto date = Date(-4, 3, 31);
date.roll!"months"(-85, AllowDayOverflow.no);
assert(date == Date(-4, 2, 29));
date.roll!"months"(85, AllowDayOverflow.no);
assert(date == Date(-4, 3, 29));
}
{
auto date = Date(-3, 3, 31);
date.roll!"months"(85, AllowDayOverflow.no).roll!"months"(-83, AllowDayOverflow.no);
assert(date == Date(-3, 5, 30));
}
}
/++
Adds the given number of units to this $(LREF Date). A negative number will
subtract.
The difference between rolling and adding is that rolling does not
affect larger units. For instance, rolling a $(LREF Date) one
year's worth of days gets the exact same $(LREF Date).
The only accepted units are $(D "days").
Params:
units = The units to add. Must be $(D "days").
days = The number of days to add to this $(LREF Date).
+/
ref Date roll(string units)(long days) @safe 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;
return this;
}
///
unittest
{
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
{
//Test A.D.
{
auto date = Date(1999, 2, 28);
date.roll!"days"(1);
assert(date == Date(1999, 2, 1));
date.roll!"days"(-1);
assert(date == Date(1999, 2, 28));
}
{
auto date = Date(2000, 2, 28);
date.roll!"days"(1);
assert(date == Date(2000, 2, 29));
date.roll!"days"(1);
assert(date == Date(2000, 2, 1));
date.roll!"days"(-1);
assert(date == Date(2000, 2, 29));
}
{
auto date = Date(1999, 6, 30);
date.roll!"days"(1);
assert(date == Date(1999, 6, 1));
date.roll!"days"(-1);
assert(date == Date(1999, 6, 30));
}
{
auto date = Date(1999, 7, 31);
date.roll!"days"(1);
assert(date == Date(1999, 7, 1));
date.roll!"days"(-1);
assert(date == Date(1999, 7, 31));
}
{
auto date = Date(1999, 1, 1);
date.roll!"days"(-1);
assert(date == Date(1999, 1, 31));
date.roll!"days"(1);
assert(date == Date(1999, 1, 1));
}
{
auto date = Date(1999, 7, 6);
date.roll!"days"(9);
assert(date == Date(1999, 7, 15));
date.roll!"days"(-11);
assert(date == Date(1999, 7, 4));
date.roll!"days"(30);
assert(date == Date(1999, 7, 3));
date.roll!"days"(-3);
assert(date == Date(1999, 7, 31));
}
{
auto date = Date(1999, 7, 6);
date.roll!"days"(365);
assert(date == Date(1999, 7, 30));
date.roll!"days"(-365);
assert(date == Date(1999, 7, 6));
date.roll!"days"(366);
assert(date == Date(1999, 7, 31));
date.roll!"days"(730);
assert(date == Date(1999, 7, 17));
date.roll!"days"(-1096);
assert(date == Date(1999, 7, 6));
}
{
auto date = Date(1999, 2, 6);
date.roll!"days"(365);
assert(date == Date(1999, 2, 7));
date.roll!"days"(-365);
assert(date == Date(1999, 2, 6));
date.roll!"days"(366);
assert(date == Date(1999, 2, 8));
date.roll!"days"(730);
assert(date == Date(1999, 2, 10));
date.roll!"days"(-1096);
assert(date == Date(1999, 2, 6));
}
//Test B.C.
{
auto date = Date(-1999, 2, 28);
date.roll!"days"(1);
assert(date == Date(-1999, 2, 1));
date.roll!"days"(-1);
assert(date == Date(-1999, 2, 28));
}
{
auto date = Date(-2000, 2, 28);
date.roll!"days"(1);
assert(date == Date(-2000, 2, 29));
date.roll!"days"(1);
assert(date == Date(-2000, 2, 1));
date.roll!"days"(-1);
assert(date == Date(-2000, 2, 29));
}
{
auto date = Date(-1999, 6, 30);
date.roll!"days"(1);
assert(date == Date(-1999, 6, 1));
date.roll!"days"(-1);
assert(date == Date(-1999, 6, 30));
}
{
auto date = Date(-1999, 7, 31);
date.roll!"days"(1);
assert(date == Date(-1999, 7, 1));
date.roll!"days"(-1);
assert(date == Date(-1999, 7, 31));
}
{
auto date = Date(-1999, 1, 1);
date.roll!"days"(-1);
assert(date == Date(-1999, 1, 31));
date.roll!"days"(1);
assert(date == Date(-1999, 1, 1));
}
{
auto date = Date(-1999, 7, 6);
date.roll!"days"(9);
assert(date == Date(-1999, 7, 15));
date.roll!"days"(-11);
assert(date == Date(-1999, 7, 4));
date.roll!"days"(30);
assert(date == Date(-1999, 7, 3));
date.roll!"days"(-3);
assert(date == Date(-1999, 7, 31));
}
{
auto date = Date(-1999, 7, 6);
date.roll!"days"(365);
assert(date == Date(-1999, 7, 30));
date.roll!"days"(-365);
assert(date == Date(-1999, 7, 6));
date.roll!"days"(366);
assert(date == Date(-1999, 7, 31));
date.roll!"days"(730);
assert(date == Date(-1999, 7, 17));
date.roll!"days"(-1096);
assert(date == Date(-1999, 7, 6));
}
//Test Both
{
auto date = Date(1, 7, 6);
date.roll!"days"(-365);
assert(date == Date(1, 7, 13));
date.roll!"days"(365);
assert(date == Date(1, 7, 6));
date.roll!"days"(-731);
assert(date == Date(1, 7, 19));
date.roll!"days"(730);
assert(date == Date(1, 7, 5));
}
{
auto date = Date(0, 7, 6);
date.roll!"days"(-365);
assert(date == Date(0, 7, 13));
date.roll!"days"(365);
assert(date == Date(0, 7, 6));
date.roll!"days"(-731);
assert(date == Date(0, 7, 19));
date.roll!"days"(730);
assert(date == Date(0, 7, 5));
}
{
auto date = Date(0, 7, 6);
date.roll!"days"(-365).roll!"days"(362).roll!"days"(-12).roll!"days"(730);
assert(date == Date(0, 7, 8));
}
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)));
}
/++
Gives the result of adding or subtracting a duration from this
$(LREF 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 $(LREF Date).
+/
Date opBinary(string op, D)(in D duration) @safe const pure nothrow
if((op == "+" || op == "-") &&
(is(Unqual!D == Duration) ||
is(Unqual!D == TickDuration)))
{
import std.format : format;
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);
mixin(format("return retval._addDays(%sdays);", op));
}
unittest
{
auto date = Date(1999, 7, 6);
assert(date + dur!"weeks"(7) == Date(1999, 8, 24));
assert(date + dur!"weeks"(-7) == Date(1999, 5, 18));
assert(date + dur!"days"(7) == Date(1999, 7, 13));
assert(date + dur!"days"(-7) == Date(1999, 6, 29));
assert(date + dur!"hours"(24) == Date(1999, 7, 7));
assert(date + dur!"hours"(-24) == Date(1999, 7, 5));
assert(date + dur!"minutes"(1440) == Date(1999, 7, 7));
assert(date + dur!"minutes"(-1440) == Date(1999, 7, 5));
assert(date + dur!"seconds"(86_400) == Date(1999, 7, 7));
assert(date + dur!"seconds"(-86_400) == Date(1999, 7, 5));
assert(date + dur!"msecs"(86_400_000) == Date(1999, 7, 7));
assert(date + dur!"msecs"(-86_400_000) == Date(1999, 7, 5));
assert(date + dur!"usecs"(86_400_000_000) == Date(1999, 7, 7));
assert(date + dur!"usecs"(-86_400_000_000) == Date(1999, 7, 5));
assert(date + dur!"hnsecs"(864_000_000_000) == Date(1999, 7, 7));
assert(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)
{
assert(date + TickDuration.from!"usecs"(86_400_000_000) == Date(1999, 7, 7));
assert(date + TickDuration.from!"usecs"(-86_400_000_000) == Date(1999, 7, 5));
}
assert(date - dur!"weeks"(-7) == Date(1999, 8, 24));
assert(date - dur!"weeks"(7) == Date(1999, 5, 18));
assert(date - dur!"days"(-7) == Date(1999, 7, 13));
assert(date - dur!"days"(7) == Date(1999, 6, 29));
assert(date - dur!"hours"(-24) == Date(1999, 7, 7));
assert(date - dur!"hours"(24) == Date(1999, 7, 5));
assert(date - dur!"minutes"(-1440) == Date(1999, 7, 7));
assert(date - dur!"minutes"(1440) == Date(1999, 7, 5));
assert(date - dur!"seconds"(-86_400) == Date(1999, 7, 7));
assert(date - dur!"seconds"(86_400) == Date(1999, 7, 5));
assert(date - dur!"msecs"(-86_400_000) == Date(1999, 7, 7));
assert(date - dur!"msecs"(86_400_000) == Date(1999, 7, 5));
assert(date - dur!"usecs"(-86_400_000_000) == Date(1999, 7, 7));
assert(date - dur!"usecs"(86_400_000_000) == Date(1999, 7, 5));
assert(date - dur!"hnsecs"(-864_000_000_000) == Date(1999, 7, 7));
assert(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)
{
assert(date - TickDuration.from!"usecs"(-86_400_000_000) == Date(1999, 7, 7));
assert(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
$(LREF Date), as well as assigning the result to this $(LREF Date).
The legal types of arithmetic for $(LREF 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 $(LREF Date).
+/
ref Date opOpAssign(string op, D)(in D duration) @safe pure nothrow
if((op == "+" || op == "-") &&
(is(Unqual!D == Duration) ||
is(Unqual!D == TickDuration)))
{
import std.format : format;
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);
mixin(format("return _addDays(%sdays);", op));
}
unittest
{
assert(Date(1999, 7, 6) + dur!"weeks"(7) == Date(1999, 8, 24));
assert(Date(1999, 7, 6) + dur!"weeks"(-7) == Date(1999, 5, 18));
assert(Date(1999, 7, 6) + dur!"days"(7) == Date(1999, 7, 13));
assert(Date(1999, 7, 6) + dur!"days"(-7) == Date(1999, 6, 29));
assert(Date(1999, 7, 6) + dur!"hours"(24) == Date(1999, 7, 7));
assert(Date(1999, 7, 6) + dur!"hours"(-24) == Date(1999, 7, 5));
assert(Date(1999, 7, 6) + dur!"minutes"(1440) == Date(1999, 7, 7));
assert(Date(1999, 7, 6) + dur!"minutes"(-1440) == Date(1999, 7, 5));
assert(Date(1999, 7, 6) + dur!"seconds"(86_400) == Date(1999, 7, 7));
assert(Date(1999, 7, 6) + dur!"seconds"(-86_400) == Date(1999, 7, 5));
assert(Date(1999, 7, 6) + dur!"msecs"(86_400_000) == Date(1999, 7, 7));
assert(Date(1999, 7, 6) + dur!"msecs"(-86_400_000) == Date(1999, 7, 5));
assert(Date(1999, 7, 6) + dur!"usecs"(86_400_000_000) == Date(1999, 7, 7));
assert(Date(1999, 7, 6) + dur!"usecs"(-86_400_000_000) == Date(1999, 7, 5));
assert(Date(1999, 7, 6) + dur!"hnsecs"(864_000_000_000) == Date(1999, 7, 7));
assert(Date(1999, 7, 6) + dur!"hnsecs"(-864_000_000_000) == Date(1999, 7, 5));
assert(Date(1999, 7, 6) - dur!"weeks"(-7) == Date(1999, 8, 24));
assert(Date(1999, 7, 6) - dur!"weeks"(7) == Date(1999, 5, 18));
assert(Date(1999, 7, 6) - dur!"days"(-7) == Date(1999, 7, 13));
assert(Date(1999, 7, 6) - dur!"days"(7) == Date(1999, 6, 29));
assert(Date(1999, 7, 6) - dur!"hours"(-24) == Date(1999, 7, 7));
assert(Date(1999, 7, 6) - dur!"hours"(24) == Date(1999, 7, 5));
assert(Date(1999, 7, 6) - dur!"minutes"(-1440) == Date(1999, 7, 7));
assert(Date(1999, 7, 6) - dur!"minutes"(1440) == Date(1999, 7, 5));
assert(Date(1999, 7, 6) - dur!"seconds"(-86_400) == Date(1999, 7, 7));
assert(Date(1999, 7, 6) - dur!"seconds"(86_400) == Date(1999, 7, 5));
assert(Date(1999, 7, 6) - dur!"msecs"(-86_400_000) == Date(1999, 7, 7));
assert(Date(1999, 7, 6) - dur!"msecs"(86_400_000) == Date(1999, 7, 5));
assert(Date(1999, 7, 6) - dur!"usecs"(-86_400_000_000) == Date(1999, 7, 7));
assert(Date(1999, 7, 6) - dur!"usecs"(86_400_000_000) == Date(1999, 7, 5));
assert(Date(1999, 7, 6) - dur!"hnsecs"(-864_000_000_000) == Date(1999, 7, 7));
assert(Date(1999, 7, 6) - dur!"hnsecs"(864_000_000_000) == Date(1999, 7, 5));
{
auto date = Date(0, 1, 31);
(date += dur!"days"(507)) += dur!"days"(-2);
assert(date == Date(1, 6, 19));
}
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 $(LREF 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) @safe const pure nothrow
if(op == "-")
{
return dur!"days"(this.dayOfGregorianCal - rhs.dayOfGregorianCal);
}
unittest
{
auto date = Date(1999, 7, 6);
assert(Date(1999, 7, 6) - Date(1998, 7, 6) == dur!"days"(365));
assert(Date(1998, 7, 6) - Date(1999, 7, 6) == dur!"days"(-365));
assert(Date(1999, 6, 6) - Date(1999, 5, 6) == dur!"days"(31));
assert(Date(1999, 5, 6) - Date(1999, 6, 6) == dur!"days"(-31));
assert(Date(1999, 1, 1) - Date(1998, 12, 31) == dur!"days"(1));
assert(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 $(LREF Date)s in months.
To get the difference in years, subtract the year property
of two $(LREF SysTime)s. To get the difference in days or weeks,
subtract the $(LREF SysTime)s themselves and use the $(CXREF time, Duration)
that results. Because converting between months and smaller
units requires a specific date (which $(CXREF time, 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 $(LREF 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 $(LREF Date) to subtract from this one.
+/
int diffMonths(in Date rhs) @safe const pure nothrow
{
immutable yearDiff = _year - rhs._year;
immutable monthDiff = _month - rhs._month;
return yearDiff * 12 + monthDiff;
}
///
unittest
{
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);
}
unittest
{
auto date = Date(1999, 7, 6);
//Test A.D.
assert(date.diffMonths(Date(1998, 6, 5)) == 13);
assert(date.diffMonths(Date(1998, 7, 5)) == 12);
assert(date.diffMonths(Date(1998, 8, 5)) == 11);
assert(date.diffMonths(Date(1998, 9, 5)) == 10);
assert(date.diffMonths(Date(1998, 10, 5)) == 9);
assert(date.diffMonths(Date(1998, 11, 5)) == 8);
assert(date.diffMonths(Date(1998, 12, 5)) == 7);
assert(date.diffMonths(Date(1999, 1, 5)) == 6);
assert(date.diffMonths(Date(1999, 2, 6)) == 5);
assert(date.diffMonths(Date(1999, 3, 6)) == 4);
assert(date.diffMonths(Date(1999, 4, 6)) == 3);
assert(date.diffMonths(Date(1999, 5, 6)) == 2);
assert(date.diffMonths(Date(1999, 6, 6)) == 1);
assert(date.diffMonths(date) == 0);
assert(date.diffMonths(Date(1999, 8, 6)) == -1);
assert(date.diffMonths(Date(1999, 9, 6)) == -2);
assert(date.diffMonths(Date(1999, 10, 6)) == -3);
assert(date.diffMonths(Date(1999, 11, 6)) == -4);
assert(date.diffMonths(Date(1999, 12, 6)) == -5);
assert(date.diffMonths(Date(2000, 1, 6)) == -6);
assert(date.diffMonths(Date(2000, 2, 6)) == -7);
assert(date.diffMonths(Date(2000, 3, 6)) == -8);
assert(date.diffMonths(Date(2000, 4, 6)) == -9);
assert(date.diffMonths(Date(2000, 5, 6)) == -10);
assert(date.diffMonths(Date(2000, 6, 6)) == -11);
assert(date.diffMonths(Date(2000, 7, 6)) == -12);
assert(date.diffMonths(Date(2000, 8, 6)) == -13);
assert(Date(1998, 6, 5).diffMonths(date) == -13);
assert(Date(1998, 7, 5).diffMonths(date) == -12);
assert(Date(1998, 8, 5).diffMonths(date) == -11);
assert(Date(1998, 9, 5).diffMonths(date) == -10);
assert(Date(1998, 10, 5).diffMonths(date) == -9);
assert(Date(1998, 11, 5).diffMonths(date) == -8);
assert(Date(1998, 12, 5).diffMonths(date) == -7);
assert(Date(1999, 1, 5).diffMonths(date) == -6);
assert(Date(1999, 2, 6).diffMonths(date) == -5);
assert(Date(1999, 3, 6).diffMonths(date) == -4);
assert(Date(1999, 4, 6).diffMonths(date) == -3);
assert(Date(1999, 5, 6).diffMonths(date) == -2);
assert(Date(1999, 6, 6).diffMonths(date) == -1);
assert(Date(1999, 8, 6).diffMonths(date) == 1);
assert(Date(1999, 9, 6).diffMonths(date) == 2);
assert(Date(1999, 10, 6).diffMonths(date) == 3);
assert(Date(1999, 11, 6).diffMonths(date) == 4);
assert(Date(1999, 12, 6).diffMonths(date) == 5);
assert(Date(2000, 1, 6).diffMonths(date) == 6);
assert(Date(2000, 2, 6).diffMonths(date) == 7);
assert(Date(2000, 3, 6).diffMonths(date) == 8);
assert(Date(2000, 4, 6).diffMonths(date) == 9);
assert(Date(2000, 5, 6).diffMonths(date) == 10);
assert(Date(2000, 6, 6).diffMonths(date) == 11);
assert(Date(2000, 7, 6).diffMonths(date) == 12);
assert(Date(2000, 8, 6).diffMonths(date) == 13);
assert(date.diffMonths(Date(1999, 6, 30)) == 1);
assert(date.diffMonths(Date(1999, 7, 1)) == 0);
assert(date.diffMonths(Date(1999, 7, 6)) == 0);
assert(date.diffMonths(Date(1999, 7, 11)) == 0);
assert(date.diffMonths(Date(1999, 7, 16)) == 0);
assert(date.diffMonths(Date(1999, 7, 21)) == 0);
assert(date.diffMonths(Date(1999, 7, 26)) == 0);
assert(date.diffMonths(Date(1999, 7, 31)) == 0);
assert(date.diffMonths(Date(1999, 8, 1)) == -1);
assert(date.diffMonths(Date(1990, 6, 30)) == 109);
assert(date.diffMonths(Date(1990, 7, 1)) == 108);
assert(date.diffMonths(Date(1990, 7, 6)) == 108);
assert(date.diffMonths(Date(1990, 7, 11)) == 108);
assert(date.diffMonths(Date(1990, 7, 16)) == 108);
assert(date.diffMonths(Date(1990, 7, 21)) == 108);
assert(date.diffMonths(Date(1990, 7, 26)) == 108);
assert(date.diffMonths(Date(1990, 7, 31)) == 108);
assert(date.diffMonths(Date(1990, 8, 1)) == 107);
assert(Date(1999, 6, 30).diffMonths(date) == -1);
assert(Date(1999, 7, 1).diffMonths(date) == 0);
assert(Date(1999, 7, 6).diffMonths(date) == 0);
assert(Date(1999, 7, 11).diffMonths(date) == 0);
assert(Date(1999, 7, 16).diffMonths(date) == 0);
assert(Date(1999, 7, 21).diffMonths(date) == 0);
assert(Date(1999, 7, 26).diffMonths(date) == 0);
assert(Date(1999, 7, 31).diffMonths(date) == 0);
assert(Date(1999, 8, 1).diffMonths(date) == 1);
assert(Date(1990, 6, 30).diffMonths(date) == -109);
assert(Date(1990, 7, 1).diffMonths(date) == -108);
assert(Date(1990, 7, 6).diffMonths(date) == -108);
assert(Date(1990, 7, 11).diffMonths(date) == -108);
assert(Date(1990, 7, 16).diffMonths(date) == -108);
assert(Date(1990, 7, 21).diffMonths(date) == -108);
assert(Date(1990, 7, 26).diffMonths(date) == -108);
assert(Date(1990, 7, 31).diffMonths(date) == -108);
assert(Date(1990, 8, 1).diffMonths(date) == -107);
//Test B.C.
auto dateBC = Date(-1999, 7, 6);
assert(dateBC.diffMonths(Date(-2000, 6, 5)) == 13);
assert(dateBC.diffMonths(Date(-2000, 7, 5)) == 12);
assert(dateBC.diffMonths(Date(-2000, 8, 5)) == 11);
assert(dateBC.diffMonths(Date(-2000, 9, 5)) == 10);
assert(dateBC.diffMonths(Date(-2000, 10, 5)) == 9);
assert(dateBC.diffMonths(Date(-2000, 11, 5)) == 8);
assert(dateBC.diffMonths(Date(-2000, 12, 5)) == 7);
assert(dateBC.diffMonths(Date(-1999, 1, 5)) == 6);
assert(dateBC.diffMonths(Date(-1999, 2, 6)) == 5);
assert(dateBC.diffMonths(Date(-1999, 3, 6)) == 4);
assert(dateBC.diffMonths(Date(-1999, 4, 6)) == 3);
assert(dateBC.diffMonths(Date(-1999, 5, 6)) == 2);
assert(dateBC.diffMonths(Date(-1999, 6, 6)) == 1);
assert(dateBC.diffMonths(dateBC) == 0);
assert(dateBC.diffMonths(Date(-1999, 8, 6)) == -1);
assert(dateBC.diffMonths(Date(-1999, 9, 6)) == -2);
assert(dateBC.diffMonths(Date(-1999, 10, 6)) == -3);
assert(dateBC.diffMonths(Date(-1999, 11, 6)) == -4);
assert(dateBC.diffMonths(Date(-1999, 12, 6)) == -5);
assert(dateBC.diffMonths(Date(-1998, 1, 6)) == -6);
assert(dateBC.diffMonths(Date(-1998, 2, 6)) == -7);
assert(dateBC.diffMonths(Date(-1998, 3, 6)) == -8);
assert(dateBC.diffMonths(Date(-1998, 4, 6)) == -9);
assert(dateBC.diffMonths(Date(-1998, 5, 6)) == -10);
assert(dateBC.diffMonths(Date(-1998, 6, 6)) == -11);
assert(dateBC.diffMonths(Date(-1998, 7, 6)) == -12);
assert(dateBC.diffMonths(Date(-1998, 8, 6)) == -13);
assert(Date(-2000, 6, 5).diffMonths(dateBC) == -13);
assert(Date(-2000, 7, 5).diffMonths(dateBC) == -12);
assert(Date(-2000, 8, 5).diffMonths(dateBC) == -11);
assert(Date(-2000, 9, 5).diffMonths(dateBC) == -10);
assert(Date(-2000, 10, 5).diffMonths(dateBC) == -9);
assert(Date(-2000, 11, 5).diffMonths(dateBC) == -8);
assert(Date(-2000, 12, 5).diffMonths(dateBC) == -7);
assert(Date(-1999, 1, 5).diffMonths(dateBC) == -6);
assert(Date(-1999, 2, 6).diffMonths(dateBC) == -5);
assert(Date(-1999, 3, 6).diffMonths(dateBC) == -4);
assert(Date(-1999, 4, 6).diffMonths(dateBC) == -3);
assert(Date(-1999, 5, 6).diffMonths(dateBC) == -2);
assert(Date(-1999, 6, 6).diffMonths(dateBC) == -1);
assert(Date(-1999, 8, 6).diffMonths(dateBC) == 1);
assert(Date(-1999, 9, 6).diffMonths(dateBC) == 2);
assert(Date(-1999, 10, 6).diffMonths(dateBC) == 3);
assert(Date(-1999, 11, 6).diffMonths(dateBC) == 4);
assert(Date(-1999, 12, 6).diffMonths(dateBC) == 5);
assert(Date(-1998, 1, 6).diffMonths(dateBC) == 6);
assert(Date(-1998, 2, 6).diffMonths(dateBC) == 7);
assert(Date(-1998, 3, 6).diffMonths(dateBC) == 8);
assert(Date(-1998, 4, 6).diffMonths(dateBC) == 9);
assert(Date(-1998, 5, 6).diffMonths(dateBC) == 10);
assert(Date(-1998, 6, 6).diffMonths(dateBC) == 11);
assert(Date(-1998, 7, 6).diffMonths(dateBC) == 12);
assert(Date(-1998, 8, 6).diffMonths(dateBC) == 13);
assert(dateBC.diffMonths(Date(-1999, 6, 30)) == 1);
assert(dateBC.diffMonths(Date(-1999, 7, 1)) == 0);
assert(dateBC.diffMonths(Date(-1999, 7, 6)) == 0);
assert(dateBC.diffMonths(Date(-1999, 7, 11)) == 0);
assert(dateBC.diffMonths(Date(-1999, 7, 16)) == 0);
assert(dateBC.diffMonths(Date(-1999, 7, 21)) == 0);
assert(dateBC.diffMonths(Date(-1999, 7, 26)) == 0);
assert(dateBC.diffMonths(Date(-1999, 7, 31)) == 0);
assert(dateBC.diffMonths(Date(-1999, 8, 1)) == -1);
assert(dateBC.diffMonths(Date(-2008, 6, 30)) == 109);
assert(dateBC.diffMonths(Date(-2008, 7, 1)) == 108);
assert(dateBC.diffMonths(Date(-2008, 7, 6)) == 108);
assert(dateBC.diffMonths(Date(-2008, 7, 11)) == 108);
assert(dateBC.diffMonths(Date(-2008, 7, 16)) == 108);
assert(dateBC.diffMonths(Date(-2008, 7, 21)) == 108);
assert(dateBC.diffMonths(Date(-2008, 7, 26)) == 108);
assert(dateBC.diffMonths(Date(-2008, 7, 31)) == 108);
assert(dateBC.diffMonths(Date(-2008, 8, 1)) == 107);
assert(Date(-1999, 6, 30).diffMonths(dateBC) == -1);
assert(Date(-1999, 7, 1).diffMonths(dateBC) == 0);
assert(Date(-1999, 7, 6).diffMonths(dateBC) == 0);
assert(Date(-1999, 7, 11).diffMonths(dateBC) == 0);
assert(Date(-1999, 7, 16).diffMonths(dateBC) == 0);
assert(Date(-1999, 7, 21).diffMonths(dateBC) == 0);
assert(Date(-1999, 7, 26).diffMonths(dateBC) == 0);
assert(Date(-1999, 7, 31).diffMonths(dateBC) == 0);
assert(Date(-1999, 8, 1).diffMonths(dateBC) == 1);
assert(Date(-2008, 6, 30).diffMonths(dateBC) == -109);
assert(Date(-2008, 7, 1).diffMonths(dateBC) == -108);
assert(Date(-2008, 7, 6).diffMonths(dateBC) == -108);
assert(Date(-2008, 7, 11).diffMonths(dateBC) == -108);
assert(Date(-2008, 7, 16).diffMonths(dateBC) == -108);
assert(Date(-2008, 7, 21).diffMonths(dateBC) == -108);
assert(Date(-2008, 7, 26).diffMonths(dateBC) == -108);
assert(Date(-2008, 7, 31).diffMonths(dateBC) == -108);
assert(Date(-2008, 8, 1).diffMonths(dateBC) == -107);
//Test Both
assert(Date(3, 3, 3).diffMonths(Date(-5, 5, 5)) == 94);
assert(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)));
}
/++
Whether this $(LREF Date) is in a leap year.
+/
@property bool isLeapYear() @safe const pure nothrow
{
return yearIsLeapYear(_year);
}
unittest
{
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 $(LREF Date) is on.
+/
@property DayOfWeek dayOfWeek() @safe const pure nothrow
{
return getDayOfWeek(dayOfGregorianCal);
}
unittest
{
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 $(LREF Date) is on.
+/
@property ushort dayOfYear() @safe 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.");
}
///
unittest
{
assert(Date(1999, 1, 1).dayOfYear == 1);
assert(Date(1999, 12, 31).dayOfYear == 365);
assert(Date(2000, 12, 31).dayOfYear == 366);
}
unittest
{
import std.range;
foreach(year; filter!((a){return !yearIsLeapYear(a);})
(chain(testYearsBC, testYearsAD)))
{
foreach(doy; testDaysOfYear)
{
assert(Date(year, doy.md.month, doy.md.day).dayOfYear ==
doy.day);
}
}
foreach(year; filter!((a){return yearIsLeapYear(a);})
(chain(testYearsBC, testYearsAD)))
{
foreach(doy; testDaysOfLeapYear)
{
assert(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
$(LREF Date) is on.
Throws:
$(LREF DateTimeException) if the given day is an invalid day of the
year.
+/
@property void dayOfYear(int day) @safe 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.");
}
unittest
{
static void test(Date date, int day, MonthDay expected, size_t line = __LINE__)
{
date.dayOfYear = day;
assert(date.month == expected.month);
assert(date.day == expected.day);
}
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 $(LREF Date) is on.
+/
@property int dayOfGregorianCal() @safe 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;
}
}
///
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);
}
unittest
{
import std.range;
foreach(gd; chain(testGregDaysBC, testGregDaysAD))
assert(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 $(LREF Date) is on.
Params:
day = The day of the Gregorian Calendar to set this $(LREF Date) to.
+/
@property void dayOfGregorianCal(int day) @safe pure nothrow
{
this = Date(day);
}
///
unittest
{
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));
}
unittest
{
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));
}
/++
The ISO 8601 week of the year that this $(LREF Date) is in.
See_Also:
$(WEB en.wikipedia.org/wiki/ISO_week_date, ISO Week Date)
+/
@property ubyte isoWeek() @safe 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
{
//Test A.D.
assert(Date(2009, 12, 28).isoWeek == 53);
assert(Date(2009, 12, 29).isoWeek == 53);
assert(Date(2009, 12, 30).isoWeek == 53);
assert(Date(2009, 12, 31).isoWeek == 53);
assert(Date(2010, 1, 1).isoWeek == 53);
assert(Date(2010, 1, 2).isoWeek == 53);
assert(Date(2010, 1, 3).isoWeek == 53);
assert(Date(2010, 1, 4).isoWeek == 1);
assert(Date(2010, 1, 5).isoWeek == 1);
assert(Date(2010, 1, 6).isoWeek == 1);
assert(Date(2010, 1, 7).isoWeek == 1);
assert(Date(2010, 1, 8).isoWeek == 1);
assert(Date(2010, 1, 9).isoWeek == 1);
assert(Date(2010, 1, 10).isoWeek == 1);
assert(Date(2010, 1, 11).isoWeek == 2);
assert(Date(2010, 12, 31).isoWeek == 52);
assert(Date(2004, 12, 26).isoWeek == 52);
assert(Date(2004, 12, 27).isoWeek == 53);
assert(Date(2004, 12, 28).isoWeek == 53);
assert(Date(2004, 12, 29).isoWeek == 53);
assert(Date(2004, 12, 30).isoWeek == 53);
assert(Date(2004, 12, 31).isoWeek == 53);
assert(Date(2005, 1, 1).isoWeek == 53);
assert(Date(2005, 1, 2).isoWeek == 53);
assert(Date(2005, 12, 31).isoWeek == 52);
assert(Date(2007, 1, 1).isoWeek == 1);
assert(Date(2007, 12, 30).isoWeek == 52);
assert(Date(2007, 12, 31).isoWeek == 1);
assert(Date(2008, 1, 1).isoWeek == 1);
assert(Date(2008, 12, 28).isoWeek == 52);
assert(Date(2008, 12, 29).isoWeek == 1);
assert(Date(2008, 12, 30).isoWeek == 1);
assert(Date(2008, 12, 31).isoWeek == 1);
assert(Date(2009, 1, 1).isoWeek == 1);
assert(Date(2009, 1, 2).isoWeek == 1);
assert(Date(2009, 1, 3).isoWeek == 1);
assert(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.
assert(Date(0, 12, 31).isoWeek == 52);
assert(Date(0, 1, 4).isoWeek == 1);
assert(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));
}
/++
$(LREF Date) for the last day in the month that this $(LREF Date) is in.
+/
@property Date endOfMonth() @safe const pure nothrow
{
try
return Date(_year, _month, maxDay(_year, _month));
catch(Exception e)
assert(0, "Date's constructor threw.");
}
///
unittest
{
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));
}
unittest
{
//Test A.D.
assert(Date(1999, 1, 1).endOfMonth == Date(1999, 1, 31));
assert(Date(1999, 2, 1).endOfMonth == Date(1999, 2, 28));
assert(Date(2000, 2, 1).endOfMonth == Date(2000, 2, 29));
assert(Date(1999, 3, 1).endOfMonth == Date(1999, 3, 31));
assert(Date(1999, 4, 1).endOfMonth == Date(1999, 4, 30));
assert(Date(1999, 5, 1).endOfMonth == Date(1999, 5, 31));
assert(Date(1999, 6, 1).endOfMonth == Date(1999, 6, 30));
assert(Date(1999, 7, 1).endOfMonth == Date(1999, 7, 31));
assert(Date(1999, 8, 1).endOfMonth == Date(1999, 8, 31));
assert(Date(1999, 9, 1).endOfMonth == Date(1999, 9, 30));
assert(Date(1999, 10, 1).endOfMonth == Date(1999, 10, 31));
assert(Date(1999, 11, 1).endOfMonth == Date(1999, 11, 30));
assert(Date(1999, 12, 1).endOfMonth == Date(1999, 12, 31));
//Test B.C.
assert(Date(-1999, 1, 1).endOfMonth == Date(-1999, 1, 31));
assert(Date(-1999, 2, 1).endOfMonth == Date(-1999, 2, 28));
assert(Date(-2000, 2, 1).endOfMonth == Date(-2000, 2, 29));
assert(Date(-1999, 3, 1).endOfMonth == Date(-1999, 3, 31));
assert(Date(-1999, 4, 1).endOfMonth == Date(-1999, 4, 30));
assert(Date(-1999, 5, 1).endOfMonth == Date(-1999, 5, 31));
assert(Date(-1999, 6, 1).endOfMonth == Date(-1999, 6, 30));
assert(Date(-1999, 7, 1).endOfMonth == Date(-1999, 7, 31));
assert(Date(-1999, 8, 1).endOfMonth == Date(-1999, 8, 31));
assert(Date(-1999, 9, 1).endOfMonth == Date(-1999, 9, 30));
assert(Date(-1999, 10, 1).endOfMonth == Date(-1999, 10, 31));
assert(Date(-1999, 11, 1).endOfMonth == Date(-1999, 11, 30));
assert(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)));
}
/++
The last day in the month that this $(LREF Date) is in.
+/
@property ubyte daysInMonth() @safe const pure nothrow
{
return maxDay(_year, _month);
}
///
unittest
{
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);
}
unittest
{
//Test A.D.
assert(Date(1999, 1, 1).daysInMonth == 31);
assert(Date(1999, 2, 1).daysInMonth == 28);
assert(Date(2000, 2, 1).daysInMonth == 29);
assert(Date(1999, 3, 1).daysInMonth == 31);
assert(Date(1999, 4, 1).daysInMonth == 30);
assert(Date(1999, 5, 1).daysInMonth == 31);
assert(Date(1999, 6, 1).daysInMonth == 30);
assert(Date(1999, 7, 1).daysInMonth == 31);
assert(Date(1999, 8, 1).daysInMonth == 31);
assert(Date(1999, 9, 1).daysInMonth == 30);
assert(Date(1999, 10, 1).daysInMonth == 31);
assert(Date(1999, 11, 1).daysInMonth == 30);
assert(Date(1999, 12, 1).daysInMonth == 31);
//Test B.C.
assert(Date(-1999, 1, 1).daysInMonth == 31);
assert(Date(-1999, 2, 1).daysInMonth == 28);
assert(Date(-2000, 2, 1).daysInMonth == 29);
assert(Date(-1999, 3, 1).daysInMonth == 31);
assert(Date(-1999, 4, 1).daysInMonth == 30);
assert(Date(-1999, 5, 1).daysInMonth == 31);
assert(Date(-1999, 6, 1).daysInMonth == 30);
assert(Date(-1999, 7, 1).daysInMonth == 31);
assert(Date(-1999, 8, 1).daysInMonth == 31);
assert(Date(-1999, 9, 1).daysInMonth == 30);
assert(Date(-1999, 10, 1).daysInMonth == 31);
assert(Date(-1999, 11, 1).daysInMonth == 30);
assert(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));
}
/++
Whether the current year is a date in A.D.
+/
@property bool isAD() @safe const pure nothrow
{
return _year > 0;
}
///
unittest
{
assert(Date(1, 1, 1).isAD);
assert(Date(2010, 12, 31).isAD);
assert(!Date(0, 12, 31).isAD);
assert(!Date(-2010, 1, 1).isAD);
}
unittest
{
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));
}
/++
The $(WEB en.wikipedia.org/wiki/Julian_day, Julian day) for this $(LREF Date) at noon (since the Julian day changes
at noon).
+/
@property long julianDay() @safe const pure nothrow
{
return dayOfGregorianCal + 1_721_425;
}
unittest
{
assert(Date(-4713, 11, 24).julianDay == 0);
assert(Date(0, 12, 31).julianDay == 1_721_425);
assert(Date(1, 1, 1).julianDay == 1_721_426);
assert(Date(1582, 10, 15).julianDay == 2_299_161);
assert(Date(1858, 11, 17).julianDay == 2_400_001);
assert(Date(1982, 1, 4).julianDay == 2_444_974);
assert(Date(1996, 3, 31).julianDay == 2_450_174);
assert(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 $(WEB en.wikipedia.org/wiki/Julian_day, Julian day) for any time on this date (since, the modified
Julian day changes at midnight).
+/
@property long modJulianDay() @safe const pure nothrow
{
return julianDay - 2_400_001;
}
unittest
{
assert(Date(1858, 11, 17).modJulianDay == 0);
assert(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 $(LREF Date) to a string with the format YYYYMMDD.
+/
string toISOString() @safe const pure nothrow
{
import std.format : format;
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
{
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");
}
unittest
{
//Test A.D.
assert(Date(9, 12, 4).toISOString() == "00091204");
assert(Date(99, 12, 4).toISOString() == "00991204");
assert(Date(999, 12, 4).toISOString() == "09991204");
assert(Date(9999, 7, 4).toISOString() == "99990704");
assert(Date(10000, 10, 20).toISOString() == "+100001020");
//Test B.C.
assert(Date(0, 12, 4).toISOString() == "00001204");
assert(Date(-9, 12, 4).toISOString() == "-00091204");
assert(Date(-99, 12, 4).toISOString() == "-00991204");
assert(Date(-999, 12, 4).toISOString() == "-09991204");
assert(Date(-9999, 7, 4).toISOString() == "-99990704");
assert(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()));
}
/++
Converts this $(LREF Date) to a string with the format YYYY-MM-DD.
+/
string toISOExtString() @safe const pure nothrow
{
import std.format : format;
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
{
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");
}
unittest
{
//Test A.D.
assert(Date(9, 12, 4).toISOExtString() == "0009-12-04");
assert(Date(99, 12, 4).toISOExtString() == "0099-12-04");
assert(Date(999, 12, 4).toISOExtString() == "0999-12-04");
assert(Date(9999, 7, 4).toISOExtString() == "9999-07-04");
assert(Date(10000, 10, 20).toISOExtString() == "+10000-10-20");
//Test B.C.
assert(Date(0, 12, 4).toISOExtString() == "0000-12-04");
assert(Date(-9, 12, 4).toISOExtString() == "-0009-12-04");
assert(Date(-99, 12, 4).toISOExtString() == "-0099-12-04");
assert(Date(-999, 12, 4).toISOExtString() == "-0999-12-04");
assert(Date(-9999, 7, 4).toISOExtString() == "-9999-07-04");
assert(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()));
}
/++
Converts this $(LREF Date) to a string with the format YYYY-Mon-DD.
+/
string toSimpleString() @safe const pure nothrow
{
import std.format : format;
try
{
if(_year >= 0)
{
if(_year < 10_000)
return format("%04d-%s-%02d", _year, monthToString(_month), _day);
else
return format("+%05d-%s-%02d", _year, monthToString(_month), _day);
}
else if(_year > -10_000)
return format("%05d-%s-%02d", _year, monthToString(_month), _day);
else
return format("%06d-%s-%02d", _year, monthToString(_month), _day);
}
catch(Exception e)
assert(0, "format() threw.");
}
///
unittest
{
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");
}
unittest
{
//Test A.D.
assert(Date(9, 12, 4).toSimpleString() == "0009-Dec-04");
assert(Date(99, 12, 4).toSimpleString() == "0099-Dec-04");
assert(Date(999, 12, 4).toSimpleString() == "0999-Dec-04");
assert(Date(9999, 7, 4).toSimpleString() == "9999-Jul-04");
assert(Date(10000, 10, 20).toSimpleString() == "+10000-Oct-20");
//Test B.C.
assert(Date(0, 12, 4).toSimpleString() == "0000-Dec-04");
assert(Date(-9, 12, 4).toSimpleString() == "-0009-Dec-04");
assert(Date(-99, 12, 4).toSimpleString() == "-0099-Dec-04");
assert(Date(-999, 12, 4).toSimpleString() == "-0999-Dec-04");
assert(Date(-9999, 7, 4).toSimpleString() == "-9999-Jul-04");
assert(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()));
}
/++
Converts this $(LREF Date) to a string.
+/
string toString() @safe const pure nothrow
{
return toSimpleString();
}
unittest
{
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 $(LREF 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:
$(LREF DateTimeException) if the given string is not in the ISO format
or if the resulting $(LREF Date) would not be valid.
+/
static Date fromISOString(S)(in S isoString) @safe pure
if(isSomeString!S)
{
import std.ascii : isDigit;
import std.string : strip;
import std.conv : to;
import std.algorithm : all, startsWith;
import std.format : format;
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(all!isDigit(day), new DateTimeException(format("Invalid ISO String: %s", isoString)));
enforce(all!isDigit(month), new DateTimeException(format("Invalid ISO String: %s", isoString)));
if(year.length > 4)
{
enforce(year.startsWith('-', '+'),
new DateTimeException(format("Invalid ISO String: %s", isoString)));
enforce(all!isDigit(year[1..$]),
new DateTimeException(format("Invalid ISO String: %s", isoString)));
}
else
enforce(all!isDigit(year), new DateTimeException(format("Invalid ISO String: %s", isoString)));
return Date(to!short(year), to!ubyte(month), to!ubyte(day));
}
///
unittest
{
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));
}
unittest
{
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"));
assert(Date.fromISOString("19990706") == Date(1999, 7, 6));
assert(Date.fromISOString("-19990706") == Date(-1999, 7, 6));
assert(Date.fromISOString("+019990706") == Date(1999, 7, 6));
assert(Date.fromISOString("19990706 ") == Date(1999, 7, 6));
assert(Date.fromISOString(" 19990706") == Date(1999, 7, 6));
assert(Date.fromISOString(" 19990706 ") == Date(1999, 7, 6));
}
/++
Creates a $(LREF 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:
$(LREF DateTimeException) if the given string is not in the ISO
Extended format or if the resulting $(LREF Date) would not be valid.
+/
static Date fromISOExtString(S)(in S isoExtString) @safe pure
if(isSomeString!(S))
{
import std.ascii : isDigit;
import std.string : strip;
import std.conv : to;
import std.algorithm : all, startsWith;
import std.format : format;
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(all!isDigit(day),
new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
enforce(all!isDigit(month),
new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
if(year.length > 4)
{
enforce(year.startsWith('-', '+'),
new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
enforce(all!isDigit(year[1..$]),
new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
}
else
enforce(all!isDigit(year),
new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
return Date(to!short(year), to!ubyte(month), to!ubyte(day));
}
///
unittest
{
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));
}
unittest
{
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"));
assert(Date.fromISOExtString("1999-07-06") == Date(1999, 7, 6));
assert(Date.fromISOExtString("-1999-07-06") == Date(-1999, 7, 6));
assert(Date.fromISOExtString("+01999-07-06") == Date(1999, 7, 6));
assert(Date.fromISOExtString("1999-07-06 ") == Date(1999, 7, 6));
assert(Date.fromISOExtString(" 1999-07-06") == Date(1999, 7, 6));
assert(Date.fromISOExtString(" 1999-07-06 ") == Date(1999, 7, 6));
}
/++
Creates a $(LREF 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:
$(LREF DateTimeException) if the given string is not in the correct
format or if the resulting $(LREF Date) would not be valid.
+/
static Date fromSimpleString(S)(in S simpleString) @safe pure
if(isSomeString!(S))
{
import std.ascii : isDigit;
import std.string : strip;
import std.conv : to;
import std.algorithm : all, startsWith;
import std.format : format;
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(all!isDigit(day), new DateTimeException(format("Invalid string format: %s", simpleString)));
if(year.length > 4)
{
enforce(year.startsWith('-', '+'),
new DateTimeException(format("Invalid string format: %s", simpleString)));
enforce(all!isDigit(year[1..$]),
new DateTimeException(format("Invalid string format: %s", simpleString)));
}
else
enforce(all!isDigit(year),
new DateTimeException(format("Invalid string format: %s", simpleString)));
return Date(to!short(year), month, to!ubyte(day));
}
///
unittest
{
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));
}
unittest
{
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"));
assert(Date.fromSimpleString("1999-Jul-06") == Date(1999, 7, 6));
assert(Date.fromSimpleString("-1999-Jul-06") == Date(-1999, 7, 6));
assert(Date.fromSimpleString("+01999-Jul-06") == Date(1999, 7, 6));
assert(Date.fromSimpleString("1999-Jul-06 ") == Date(1999, 7, 6));
assert(Date.fromSimpleString(" 1999-Jul-06") == Date(1999, 7, 6));
assert(Date.fromSimpleString(" 1999-Jul-06 ") == Date(1999, 7, 6));
}
/++
Returns the $(LREF Date) farthest in the past which is representable by
$(LREF Date).
+/
@property static Date min() @safe pure nothrow
{
auto date = Date.init;
date._year = short.min;
date._month = Month.jan;
date._day = 1;
return date;
}
unittest
{
assert(Date.min.year < 0);
assert(Date.min < Date.max);
}
/++
Returns the $(LREF Date) farthest in the future which is representable by
$(LREF Date).
+/
@property static Date max() @safe pure nothrow
{
auto date = Date.init;
date._year = short.max;
date._month = Month.dec;
date._day = 31;
return date;
}
unittest
{
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) @safe pure nothrow
{
if(!valid!"months"(month))
return false;
return valid!"days"(year, month, day);
}
/+
Adds the given number of days to this $(LREF 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) return @safe pure nothrow
{
dayOfGregorianCal = cast(int)(dayOfGregorianCal + days);
return this;
}
unittest
{
//Test A.D.
{
auto date = Date(1999, 2, 28);
date._addDays(1);
assert(date == Date(1999, 3, 1));
date._addDays(-1);
assert(date == Date(1999, 2, 28));
}
{
auto date = Date(2000, 2, 28);
date._addDays(1);
assert(date == Date(2000, 2, 29));
date._addDays(1);
assert(date == Date(2000, 3, 1));
date._addDays(-1);
assert(date == Date(2000, 2, 29));
}
{
auto date = Date(1999, 6, 30);
date._addDays(1);
assert(date == Date(1999, 7, 1));
date._addDays(-1);
assert(date == Date(1999, 6, 30));
}
{
auto date = Date(1999, 7, 31);
date._addDays(1);
assert(date == Date(1999, 8, 1));
date._addDays(-1);
assert(date == Date(1999, 7, 31));
}
{
auto date = Date(1999, 1, 1);
date._addDays(-1);
assert(date == Date(1998, 12, 31));
date._addDays(1);
assert(date == Date(1999, 1, 1));
}
{
auto date = Date(1999, 7, 6);
date._addDays(9);
assert(date == Date(1999, 7, 15));
date._addDays(-11);
assert(date == Date(1999, 7, 4));
date._addDays(30);
assert(date == Date(1999, 8, 3));
date._addDays(-3);
assert(date == Date(1999, 7, 31));
}
{
auto date = Date(1999, 7, 6);
date._addDays(365);
assert(date == Date(2000, 7, 5));
date._addDays(-365);
assert(date == Date(1999, 7, 6));
date._addDays(366);
assert(date == Date(2000, 7, 6));
date._addDays(730);
assert(date == Date(2002, 7, 6));
date._addDays(-1096);
assert(date == Date(1999, 7, 6));
}
//Test B.C.
{
auto date = Date(-1999, 2, 28);
date._addDays(1);
assert(date == Date(-1999, 3, 1));
date._addDays(-1);
assert(date == Date(-1999, 2, 28));
}
{
auto date = Date(-2000, 2, 28);
date._addDays(1);
assert(date == Date(-2000, 2, 29));
date._addDays(1);
assert(date == Date(-2000, 3, 1));
date._addDays(-1);
assert(date == Date(-2000, 2, 29));
}
{
auto date = Date(-1999, 6, 30);
date._addDays(1);
assert(date == Date(-1999, 7, 1));
date._addDays(-1);
assert(date == Date(-1999, 6, 30));
}
{
auto date = Date(-1999, 7, 31);
date._addDays(1);
assert(date == Date(-1999, 8, 1));
date._addDays(-1);
assert(date == Date(-1999, 7, 31));
}
{
auto date = Date(-1999, 1, 1);
date._addDays(-1);
assert(date == Date(-2000, 12, 31));
date._addDays(1);
assert(date == Date(-1999, 1, 1));
}
{
auto date = Date(-1999, 7, 6);
date._addDays(9);
assert(date == Date(-1999, 7, 15));
date._addDays(-11);
assert(date == Date(-1999, 7, 4));
date._addDays(30);
assert(date == Date(-1999, 8, 3));
date._addDays(-3);
}
{
auto date = Date(-1999, 7, 6);
date._addDays(365);
assert(date == Date(-1998, 7, 6));
date._addDays(-365);
assert(date == Date(-1999, 7, 6));
date._addDays(366);
assert(date == Date(-1998, 7, 7));
date._addDays(730);
assert(date == Date(-1996, 7, 6));
date._addDays(-1096);
assert(date == Date(-1999, 7, 6));
}
//Test Both
{
auto date = Date(1, 7, 6);
date._addDays(-365);
assert(date == Date(0, 7, 6));
date._addDays(365);
assert(date == Date(1, 7, 6));
date._addDays(-731);
assert(date == Date(-1, 7, 6));
date._addDays(730);
assert(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)));
}
@safe pure invariant()
{
import std.format : format;
assert(valid!"months"(_month),
format("Invariant Failure: year [%s] month [%s] day [%s]", _year, _month, _day));
assert(valid!"days"(_year, _month, _day),
format("Invariant Failure: year [%s] month [%s] day [%s]", _year, _month, _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:
$(LREF DateTimeException) if the resulting $(LREF TimeOfDay) would be not
be valid.
+/
this(int hour, int minute, int second = 0) @safe pure
{
enforceValid!"hours"(hour);
enforceValid!"minutes"(minute);
enforceValid!"seconds"(second);
_hour = cast(ubyte)hour;
_minute = cast(ubyte)minute;
_second = cast(ubyte)second;
}
unittest
{
assert(TimeOfDay(0, 0) == TimeOfDay.init);
{
auto tod = TimeOfDay(0, 0);
assert(tod._hour == 0);
assert(tod._minute == 0);
assert(tod._second == 0);
}
{
auto tod = TimeOfDay(12, 30, 33);
assert(tod._hour == 12);
assert(tod._minute == 30);
assert(tod._second == 33);
}
{
auto tod = TimeOfDay(23, 59, 59);
assert(tod._hour == 23);
assert(tod._minute == 59);
assert(tod._second == 59);
}
assertThrown!DateTimeException(TimeOfDay(24, 0, 0));
assertThrown!DateTimeException(TimeOfDay(0, 60, 0));
assertThrown!DateTimeException(TimeOfDay(0, 0, 60));
}
/++
Compares this $(LREF TimeOfDay) with the given $(LREF 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) @safe 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
{
assert(TimeOfDay(0, 0, 0).opCmp(TimeOfDay.init) == 0);
assert(TimeOfDay(0, 0, 0).opCmp(TimeOfDay(0, 0, 0)) == 0);
assert(TimeOfDay(12, 0, 0).opCmp(TimeOfDay(12, 0, 0)) == 0);
assert(TimeOfDay(0, 30, 0).opCmp(TimeOfDay(0, 30, 0)) == 0);
assert(TimeOfDay(0, 0, 33).opCmp(TimeOfDay(0, 0, 33)) == 0);
assert(TimeOfDay(12, 30, 0).opCmp(TimeOfDay(12, 30, 0)) == 0);
assert(TimeOfDay(12, 30, 33).opCmp(TimeOfDay(12, 30, 33)) == 0);
assert(TimeOfDay(0, 30, 33).opCmp(TimeOfDay(0, 30, 33)) == 0);
assert(TimeOfDay(0, 0, 33).opCmp(TimeOfDay(0, 0, 33)) == 0);
assert(TimeOfDay(12, 30, 33).opCmp(TimeOfDay(13, 30, 33)) < 0);
assert(TimeOfDay(13, 30, 33).opCmp(TimeOfDay(12, 30, 33)) > 0);
assert(TimeOfDay(12, 30, 33).opCmp(TimeOfDay(12, 31, 33)) < 0);
assert(TimeOfDay(12, 31, 33).opCmp(TimeOfDay(12, 30, 33)) > 0);
assert(TimeOfDay(12, 30, 33).opCmp(TimeOfDay(12, 30, 34)) < 0);
assert(TimeOfDay(12, 30, 34).opCmp(TimeOfDay(12, 30, 33)) > 0);
assert(TimeOfDay(13, 30, 33).opCmp(TimeOfDay(12, 30, 34)) > 0);
assert(TimeOfDay(12, 30, 34).opCmp(TimeOfDay(13, 30, 33)) < 0);
assert(TimeOfDay(13, 30, 33).opCmp(TimeOfDay(12, 31, 33)) > 0);
assert(TimeOfDay(12, 31, 33).opCmp(TimeOfDay(13, 30, 33)) < 0);
assert(TimeOfDay(12, 31, 33).opCmp(TimeOfDay(12, 30, 34)) > 0);
assert(TimeOfDay(12, 30, 34).opCmp(TimeOfDay(12, 31, 33)) < 0);
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 past midnight.
+/
@property ubyte hour() @safe const pure nothrow
{
return _hour;
}
unittest
{
assert(TimeOfDay.init.hour == 0);
assert(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 past midnight.
Params:
hour = The hour of the day to set this $(LREF TimeOfDay)'s hour to.
Throws:
$(LREF DateTimeException) if the given hour would result in an invalid
$(LREF TimeOfDay).
+/
@property void hour(int hour) @safe pure
{
enforceValid!"hours"(hour);
_hour = cast(ubyte)hour;
}
unittest
{
assertThrown!DateTimeException((){TimeOfDay(0, 0, 0).hour = 24;}());
auto tod = TimeOfDay(0, 0, 0);
tod.hour = 12;
assert(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 past the hour.
+/
@property ubyte minute() @safe const pure nothrow
{
return _minute;
}
unittest
{
assert(TimeOfDay.init.minute == 0);
assert(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 past the hour.
Params:
minute = The minute to set this $(LREF TimeOfDay)'s minute to.
Throws:
$(LREF DateTimeException) if the given minute would result in an
invalid $(LREF TimeOfDay).
+/
@property void minute(int minute) @safe pure
{
enforceValid!"minutes"(minute);
_minute = cast(ubyte)minute;
}
unittest
{
assertThrown!DateTimeException((){TimeOfDay(0, 0, 0).minute = 60;}());
auto tod = TimeOfDay(0, 0, 0);
tod.minute = 30;
assert(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 past the minute.
+/
@property ubyte second() @safe const pure nothrow
{
return _second;
}
unittest
{
assert(TimeOfDay.init.second == 0);
assert(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 past the minute.
Params:
second = The second to set this $(LREF TimeOfDay)'s second to.
Throws:
$(LREF DateTimeException) if the given second would result in an
invalid $(LREF TimeOfDay).
+/
@property void second(int second) @safe pure
{
enforceValid!"seconds"(second);
_second = cast(ubyte)second;
}
unittest
{
assertThrown!DateTimeException((){TimeOfDay(0, 0, 0).second = 60;}());
auto tod = TimeOfDay(0, 0, 0);
tod.second = 33;
assert(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 $(LREF TimeOfDay). A negative number
will subtract.
The difference between rolling and adding is that rolling does not
affect larger units. For instance, rolling a $(LREF TimeOfDay)
one hours's worth of minutes gets the exact same
$(LREF 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
$(LREF TimeOfDay).
+/
ref TimeOfDay roll(string units)(long value) @safe pure nothrow
if(units == "hours")
{
return this += dur!"hours"(value);
}
///
unittest
{
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
{
auto tod = TimeOfDay(12, 27, 2);
tod.roll!"hours"(22).roll!"hours"(-7);
assert(tod == TimeOfDay(3, 27, 2));
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 roll(string units)(long value) @safe pure nothrow
if(units == "minutes" ||
units == "seconds")
{
import std.format : format;
enum memberVarStr = units[0 .. $ - 1];
value %= 60;
mixin(format("auto newVal = cast(ubyte)(_%s) + value;", memberVarStr));
if(value < 0)
{
if(newVal < 0)
newVal += 60;
}
else if(newVal >= 60)
newVal -= 60;
mixin(format("_%s = cast(ubyte)newVal;", memberVarStr));
return this;
}
//Test roll!"minutes"().
unittest
{
static void testTOD(TimeOfDay orig, int minutes, in TimeOfDay expected, size_t line = __LINE__)
{
orig.roll!"minutes"(minutes);
assert(orig == expected);
}
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));
auto tod = TimeOfDay(12, 27, 2);
tod.roll!"minutes"(97).roll!"minutes"(-102);
assert(tod == TimeOfDay(12, 22, 2));
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)));
}
//Test roll!"seconds"().
unittest
{
static void testTOD(TimeOfDay orig, int seconds, in TimeOfDay expected, size_t line = __LINE__)
{
orig.roll!"seconds"(seconds);
assert(orig == expected);
}
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));
auto tod = TimeOfDay(12, 27, 2);
tod.roll!"seconds"(105).roll!"seconds"(-77);
assert(tod == TimeOfDay(12, 27, 30));
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
$(LREF TimeOfDay).
The legal types of arithmetic for $(LREF 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
$(LREF TimeOfDay).
+/
TimeOfDay opBinary(string op, D)(in D duration) @safe const pure nothrow
if((op == "+" || op == "-") &&
(is(Unqual!D == Duration) ||
is(Unqual!D == TickDuration)))
{
import std.format : format;
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;
mixin(format(`return retval._addSeconds(convert!("hnsecs", "seconds")(%shnsecs));`, op));
}
unittest
{
auto tod = TimeOfDay(12, 30, 33);
assert(tod + dur!"hours"(7) == TimeOfDay(19, 30, 33));
assert(tod + dur!"hours"(-7) == TimeOfDay(5, 30, 33));
assert(tod + dur!"minutes"(7) == TimeOfDay(12, 37, 33));
assert(tod + dur!"minutes"(-7) == TimeOfDay(12, 23, 33));
assert(tod + dur!"seconds"(7) == TimeOfDay(12, 30, 40));
assert(tod + dur!"seconds"(-7) == TimeOfDay(12, 30, 26));
assert(tod + dur!"msecs"(7000) == TimeOfDay(12, 30, 40));
assert(tod + dur!"msecs"(-7000) == TimeOfDay(12, 30, 26));
assert(tod + dur!"usecs"(7_000_000) == TimeOfDay(12, 30, 40));
assert(tod + dur!"usecs"(-7_000_000) == TimeOfDay(12, 30, 26));
assert(tod + dur!"hnsecs"(70_000_000) == TimeOfDay(12, 30, 40));
assert(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)
{
assert(tod + TickDuration.from!"usecs"(7_000_000) == TimeOfDay(12, 30, 40));
assert(tod + TickDuration.from!"usecs"(-7_000_000) == TimeOfDay(12, 30, 26));
}
assert(tod - dur!"hours"(-7) == TimeOfDay(19, 30, 33));
assert(tod - dur!"hours"(7) == TimeOfDay(5, 30, 33));
assert(tod - dur!"minutes"(-7) == TimeOfDay(12, 37, 33));
assert(tod - dur!"minutes"(7) == TimeOfDay(12, 23, 33));
assert(tod - dur!"seconds"(-7) == TimeOfDay(12, 30, 40));
assert(tod - dur!"seconds"(7) == TimeOfDay(12, 30, 26));
assert(tod - dur!"msecs"(-7000) == TimeOfDay(12, 30, 40));
assert(tod - dur!"msecs"(7000) == TimeOfDay(12, 30, 26));
assert(tod - dur!"usecs"(-7_000_000) == TimeOfDay(12, 30, 40));
assert(tod - dur!"usecs"(7_000_000) == TimeOfDay(12, 30, 26));
assert(tod - dur!"hnsecs"(-70_000_000) == TimeOfDay(12, 30, 40));
assert(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)
{
assert(tod - TickDuration.from!"usecs"(-7_000_000) == TimeOfDay(12, 30, 40));
assert(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
$(LREF TimeOfDay), as well as assigning the result to this
$(LREF TimeOfDay).
The legal types of arithmetic for $(LREF 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
$(LREF TimeOfDay).
+/
ref TimeOfDay opOpAssign(string op, D)(in D duration) @safe pure nothrow
if((op == "+" || op == "-") &&
(is(Unqual!D == Duration) ||
is(Unqual!D == TickDuration)))
{
import std.format : format;
static if(is(Unqual!D == Duration))
immutable hnsecs = duration.total!"hnsecs";
else static if(is(Unqual!D == TickDuration))
immutable hnsecs = duration.hnsecs;
mixin(format(`return _addSeconds(convert!("hnsecs", "seconds")(%shnsecs));`, op));
}
unittest
{
auto duration = dur!"hours"(12);
assert(TimeOfDay(12, 30, 33) + dur!"hours"(7) == TimeOfDay(19, 30, 33));
assert(TimeOfDay(12, 30, 33) + dur!"hours"(-7) == TimeOfDay(5, 30, 33));
assert(TimeOfDay(12, 30, 33) + dur!"minutes"(7) == TimeOfDay(12, 37, 33));
assert(TimeOfDay(12, 30, 33) + dur!"minutes"(-7) == TimeOfDay(12, 23, 33));
assert(TimeOfDay(12, 30, 33) + dur!"seconds"(7) == TimeOfDay(12, 30, 40));
assert(TimeOfDay(12, 30, 33) + dur!"seconds"(-7) == TimeOfDay(12, 30, 26));
assert(TimeOfDay(12, 30, 33) + dur!"msecs"(7000) == TimeOfDay(12, 30, 40));
assert(TimeOfDay(12, 30, 33) + dur!"msecs"(-7000) == TimeOfDay(12, 30, 26));
assert(TimeOfDay(12, 30, 33) + dur!"usecs"(7_000_000) == TimeOfDay(12, 30, 40));
assert(TimeOfDay(12, 30, 33) + dur!"usecs"(-7_000_000) == TimeOfDay(12, 30, 26));
assert(TimeOfDay(12, 30, 33) + dur!"hnsecs"(70_000_000) == TimeOfDay(12, 30, 40));
assert(TimeOfDay(12, 30, 33) + dur!"hnsecs"(-70_000_000) == TimeOfDay(12, 30, 26));
assert(TimeOfDay(12, 30, 33) - dur!"hours"(-7) == TimeOfDay(19, 30, 33));
assert(TimeOfDay(12, 30, 33) - dur!"hours"(7) == TimeOfDay(5, 30, 33));
assert(TimeOfDay(12, 30, 33) - dur!"minutes"(-7) == TimeOfDay(12, 37, 33));
assert(TimeOfDay(12, 30, 33) - dur!"minutes"(7) == TimeOfDay(12, 23, 33));
assert(TimeOfDay(12, 30, 33) - dur!"seconds"(-7) == TimeOfDay(12, 30, 40));
assert(TimeOfDay(12, 30, 33) - dur!"seconds"(7) == TimeOfDay(12, 30, 26));
assert(TimeOfDay(12, 30, 33) - dur!"msecs"(-7000) == TimeOfDay(12, 30, 40));
assert(TimeOfDay(12, 30, 33) - dur!"msecs"(7000) == TimeOfDay(12, 30, 26));
assert(TimeOfDay(12, 30, 33) - dur!"usecs"(-7_000_000) == TimeOfDay(12, 30, 40));
assert(TimeOfDay(12, 30, 33) - dur!"usecs"(7_000_000) == TimeOfDay(12, 30, 26));
assert(TimeOfDay(12, 30, 33) - dur!"hnsecs"(-70_000_000) == TimeOfDay(12, 30, 40));
assert(TimeOfDay(12, 30, 33) - dur!"hnsecs"(70_000_000) == TimeOfDay(12, 30, 26));
auto tod = TimeOfDay(19, 17, 22);
(tod += dur!"seconds"(9)) += dur!"seconds"(-7292);
assert(tod == TimeOfDay(17, 15, 59));
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 $(LREF TimeOfDay)s.
The legal types of arithmetic for $(LREF TimeOfDay) using this operator are
$(BOOKTABLE,
$(TR $(TD TimeOfDay) $(TD -) $(TD TimeOfDay) $(TD -->) $(TD duration))
)
Params:
rhs = The $(LREF TimeOfDay) to subtract from this one.
+/
Duration opBinary(string op)(in TimeOfDay rhs) @safe 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
{
auto tod = TimeOfDay(12, 30, 33);
assert(TimeOfDay(7, 12, 52) - TimeOfDay(12, 30, 33) == dur!"seconds"(-19_061));
assert(TimeOfDay(12, 30, 33) - TimeOfDay(7, 12, 52) == dur!"seconds"(19_061));
assert(TimeOfDay(12, 30, 33) - TimeOfDay(14, 30, 33) == dur!"seconds"(-7200));
assert(TimeOfDay(14, 30, 33) - TimeOfDay(12, 30, 33) == dur!"seconds"(7200));
assert(TimeOfDay(12, 30, 33) - TimeOfDay(12, 34, 33) == dur!"seconds"(-240));
assert(TimeOfDay(12, 34, 33) - TimeOfDay(12, 30, 33) == dur!"seconds"(240));
assert(TimeOfDay(12, 30, 33) - TimeOfDay(12, 30, 34) == dur!"seconds"(-1));
assert(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 $(LREF TimeOfDay) to a string with the format HHMMSS.
+/
string toISOString() @safe const pure nothrow
{
import std.format : format;
try
return format("%02d%02d%02d", _hour, _minute, _second);
catch(Exception e)
assert(0, "format() threw.");
}
///
unittest
{
assert(TimeOfDay(0, 0, 0).toISOString() == "000000");
assert(TimeOfDay(12, 30, 33).toISOString() == "123033");
}
unittest
{
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()));
}
/++
Converts this $(LREF TimeOfDay) to a string with the format HH:MM:SS.
+/
string toISOExtString() @safe const pure nothrow
{
import std.format : format;
try
return format("%02d:%02d:%02d", _hour, _minute, _second);
catch(Exception e)
assert(0, "format() threw.");
}
///
unittest
{
assert(TimeOfDay(0, 0, 0).toISOExtString() == "00:00:00");
assert(TimeOfDay(12, 30, 33).toISOExtString() == "12:30:33");
}
unittest
{
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()));
}
/++
Converts this TimeOfDay to a string.
+/
string toString() @safe const pure nothrow
{
return toISOExtString();
}
unittest
{
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()));
}
/++
Creates a $(LREF 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:
$(LREF DateTimeException) if the given string is not in the ISO format
or if the resulting $(LREF TimeOfDay) would not be valid.
+/
static TimeOfDay fromISOString(S)(in S isoString) @safe pure
if(isSomeString!S)
{
import std.ascii : isDigit;
import std.string : strip;
import std.conv : to;
import std.algorithm : all;
import std.format : format;
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(all!isDigit(hours), new DateTimeException(format("Invalid ISO String: %s", isoString)));
enforce(all!isDigit(minutes), new DateTimeException(format("Invalid ISO String: %s", isoString)));
enforce(all!isDigit(seconds), new DateTimeException(format("Invalid ISO String: %s", isoString)));
return TimeOfDay(to!int(hours), to!int(minutes), to!int(seconds));
}
///
unittest
{
assert(TimeOfDay.fromISOString("000000") == TimeOfDay(0, 0, 0));
assert(TimeOfDay.fromISOString("123033") == TimeOfDay(12, 30, 33));
assert(TimeOfDay.fromISOString(" 123033 ") == TimeOfDay(12, 30, 33));
}
unittest
{
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"));
assert(TimeOfDay.fromISOString("011217") == TimeOfDay(1, 12, 17));
assert(TimeOfDay.fromISOString("001412") == TimeOfDay(0, 14, 12));
assert(TimeOfDay.fromISOString("000007") == TimeOfDay(0, 0, 7));
assert(TimeOfDay.fromISOString("011217 ") == TimeOfDay(1, 12, 17));
assert(TimeOfDay.fromISOString(" 011217") == TimeOfDay(1, 12, 17));
assert(TimeOfDay.fromISOString(" 011217 ") == TimeOfDay(1, 12, 17));
}
/++
Creates a $(LREF TimeOfDay) from a string with the format HH:MM:SS.
Whitespace is stripped from the given string.
Params:
isoExtString = A string formatted in the ISO Extended format for times.
Throws:
$(LREF DateTimeException) if the given string is not in the ISO
Extended format or if the resulting $(LREF TimeOfDay) would not be
valid.
+/
static TimeOfDay fromISOExtString(S)(in S isoExtString) @safe pure
if(isSomeString!S)
{
import std.ascii : isDigit;
import std.string : strip;
import std.conv : to;
import std.algorithm : all;
import std.format : format;
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(all!isDigit(hours),
new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
enforce(all!isDigit(minutes),
new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
enforce(all!isDigit(seconds),
new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
return TimeOfDay(to!int(hours), to!int(minutes), to!int(seconds));
}
///
unittest
{
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));
}
unittest
{
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"));
assert(TimeOfDay.fromISOExtString("01:12:17") == TimeOfDay(1, 12, 17));
assert(TimeOfDay.fromISOExtString("00:14:12") == TimeOfDay(0, 14, 12));
assert(TimeOfDay.fromISOExtString("00:00:07") == TimeOfDay(0, 0, 7));
assert(TimeOfDay.fromISOExtString("01:12:17 ") == TimeOfDay(1, 12, 17));
assert(TimeOfDay.fromISOExtString(" 01:12:17") == TimeOfDay(1, 12, 17));
assert(TimeOfDay.fromISOExtString(" 01:12:17 ") == TimeOfDay(1, 12, 17));
}
/++
Returns midnight.
+/
@property static TimeOfDay min() @safe pure nothrow
{
return TimeOfDay.init;
}
unittest
{
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() @safe pure nothrow
{
auto tod = TimeOfDay.init;
tod._hour = maxHour;
tod._minute = maxMinute;
tod._second = maxSecond;
return tod;
}
unittest
{
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) return @safe 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
{
static void testTOD(TimeOfDay orig, int seconds, in TimeOfDay expected, size_t line = __LINE__)
{
orig._addSeconds(seconds);
assert(orig == expected);
}
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 $(LREF TimeOfDay).
+/
static bool _valid(int hour, int minute, int second) @safe pure nothrow
{
return valid!"hours"(hour) && valid!"minutes"(minute) && valid!"seconds"(second);
}
@safe pure invariant()
{
import std.format : format;
assert(_valid(_hour, _minute, _second),
format("Invariant Failure: hour [%s] minute [%s] second [%s]", _hour, _minute, _second));
}
ubyte _hour;
ubyte _minute;
ubyte _second;
enum ubyte maxHour = 24 - 1;
enum ubyte maxMinute = 60 - 1;
enum ubyte maxSecond = 60 - 1;
}
/++
Combines the $(LREF Date) and $(LREF 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
$(LREF SysTime). $(LREF 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 $(LREF DateTime).
tod = The time portion of $(LREF DateTime).
+/
this(in Date date, in TimeOfDay tod = TimeOfDay.init) @safe pure nothrow
{
_date = date;
_tod = tod;
}
unittest
{
{
auto dt = DateTime.init;
assert(dt._date == Date.init);
assert(dt._tod == TimeOfDay.init);
}
{
auto dt = DateTime(Date(1999, 7 ,6));
assert(dt._date == Date(1999, 7, 6));
assert(dt._tod == TimeOfDay.init);
}
{
auto dt = DateTime(Date(1999, 7 ,6), TimeOfDay(12, 30, 33));
assert(dt._date == Date(1999, 7, 6));
assert(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) @safe pure
{
_date = Date(year, month, day);
_tod = TimeOfDay(hour, minute, second);
}
unittest
{
{
auto dt = DateTime(1999, 7 ,6);
assert(dt._date == Date(1999, 7, 6));
assert(dt._tod == TimeOfDay.init);
}
{
auto dt = DateTime(1999, 7 ,6, 12, 30, 33);
assert(dt._date == Date(1999, 7, 6));
assert(dt._tod == TimeOfDay(12, 30, 33));
}
}
/++
Compares this $(LREF 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) @safe const pure nothrow
{
immutable dateResult = _date.opCmp(rhs._date);
if(dateResult != 0)
return dateResult;
return _tod.opCmp(rhs._tod);
}
unittest
{
//Test A.D.
assert(DateTime(Date.init, TimeOfDay.init).opCmp(DateTime.init) == 0);
assert(DateTime(Date(1999, 1, 1)).opCmp(DateTime(Date(1999, 1, 1))) == 0);
assert(DateTime(Date(1, 7, 1)).opCmp(DateTime(Date(1, 7, 1))) == 0);
assert(DateTime(Date(1, 1, 6)).opCmp(DateTime(Date(1, 1, 6))) == 0);
assert(DateTime(Date(1999, 7, 1)).opCmp(DateTime(Date(1999, 7, 1))) == 0);
assert(DateTime(Date(1999, 7, 6)).opCmp(DateTime(Date(1999, 7, 6))) == 0);
assert(DateTime(Date(1, 7, 6)).opCmp(DateTime(Date(1, 7, 6))) == 0);
assert(DateTime(Date(1999, 7, 6)).opCmp(DateTime(Date(2000, 7, 6))) < 0);
assert(DateTime(Date(2000, 7, 6)).opCmp(DateTime(Date(1999, 7, 6))) > 0);
assert(DateTime(Date(1999, 7, 6)).opCmp(DateTime(Date(1999, 8, 6))) < 0);
assert(DateTime(Date(1999, 8, 6)).opCmp(DateTime(Date(1999, 7, 6))) > 0);
assert(DateTime(Date(1999, 7, 6)).opCmp(DateTime(Date(1999, 7, 7))) < 0);
assert(DateTime(Date(1999, 7, 7)).opCmp(DateTime(Date(1999, 7, 6))) > 0);
assert(DateTime(Date(1999, 8, 7)).opCmp(DateTime(Date(2000, 7, 6))) < 0);
assert(DateTime(Date(2000, 8, 6)).opCmp(DateTime(Date(1999, 7, 7))) > 0);
assert(DateTime(Date(1999, 7, 7)).opCmp(DateTime(Date(2000, 7, 6))) < 0);
assert(DateTime(Date(2000, 7, 6)).opCmp(DateTime(Date(1999, 7, 7))) > 0);
assert(DateTime(Date(1999, 7, 7)).opCmp(DateTime(Date(1999, 8, 6))) < 0);
assert(DateTime(Date(1999, 8, 6)).opCmp(DateTime(Date(1999, 7, 7))) > 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 0)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 0))) == 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 0)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 0, 0))) == 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(0, 30, 0)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(0, 30, 0))) == 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 33))) == 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 0)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 0))) == 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33))) == 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(0, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(0, 30, 33))) == 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 33))) == 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33))) < 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33))) > 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33))) < 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33))) > 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34))) < 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33))) > 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34))) > 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33))) < 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33))) > 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33))) < 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34))) > 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33))) < 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)).opCmp(
DateTime(Date(2000, 7, 6), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(2000, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33))) > 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)).opCmp(
DateTime(Date(2000, 7, 6), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(2000, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33))) > 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)).opCmp(
DateTime(Date(2000, 7, 6), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(2000, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34))) > 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)).opCmp(
DateTime(Date(1999, 8, 6), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(1999, 8, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33))) > 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)).opCmp(
DateTime(Date(1999, 8, 6), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(1999, 8, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33))) > 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)).opCmp(
DateTime(Date(1999, 8, 6), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(1999, 8, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34))) > 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33)).opCmp(
DateTime(Date(1999, 7, 7), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(1999, 7, 7), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(13, 30, 33))) > 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)).opCmp(
DateTime(Date(1999, 7, 7), TimeOfDay(12, 31, 33))) < 0);
assert(DateTime(Date(1999, 7, 7), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33))) > 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)).opCmp(
DateTime(Date(1999, 7, 7), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(1999, 7, 7), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34))) > 0);
//Test B.C.
assert(DateTime(Date(-1, 1, 1), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1, 1, 1), TimeOfDay(12, 30, 33))) == 0);
assert(DateTime(Date(-1, 7, 1), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1, 7, 1), TimeOfDay(12, 30, 33))) == 0);
assert(DateTime(Date(-1, 1, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1, 1, 6), TimeOfDay(12, 30, 33))) == 0);
assert(DateTime(Date(-1999, 7, 1), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1999, 7, 1), TimeOfDay(12, 30, 33))) == 0);
assert(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33))) == 0);
assert(DateTime(Date(-1, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1, 7, 6), TimeOfDay(12, 30, 33))) == 0);
assert(DateTime(Date(-2000, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-2000, 7, 6), TimeOfDay(12, 30, 33))) > 0);
assert(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1999, 8, 6), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(-1999, 8, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33))) > 0);
assert(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1999, 7, 7), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(-1999, 7, 7), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33))) > 0);
assert(DateTime(Date(-2000, 8, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1999, 7, 7), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(-1999, 8, 7), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-2000, 7, 6), TimeOfDay(12, 30, 33))) > 0);
assert(DateTime(Date(-2000, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1999, 7, 7), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(-1999, 7, 7), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-2000, 7, 6), TimeOfDay(12, 30, 33))) > 0);
assert(DateTime(Date(-1999, 7, 7), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1999, 8, 6), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(-1999, 8, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1999, 7, 7), TimeOfDay(12, 30, 33))) > 0);
//Test Both
assert(DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33))) > 0);
assert(DateTime(Date(-1999, 8, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1999, 8, 6), TimeOfDay(12, 30, 33))) > 0);
assert(DateTime(Date(-1999, 7, 7), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1999, 7, 7), TimeOfDay(12, 30, 33))) > 0);
assert(DateTime(Date(-1999, 8, 7), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1999, 8, 7), TimeOfDay(12, 30, 33))) > 0);
assert(DateTime(Date(-1999, 8, 6), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(1999, 6, 6), TimeOfDay(12, 30, 33))) < 0);
assert(DateTime(Date(1999, 6, 8), TimeOfDay(12, 30, 33)).opCmp(
DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33))) > 0);
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 $(LREF DateTime).
+/
@property Date date() @safe const pure nothrow
{
return _date;
}
unittest
{
{
auto dt = DateTime.init;
assert(dt.date == Date.init);
}
{
auto dt = DateTime(Date(1999, 7, 6));
assert(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 $(LREF DateTime).
Params:
date = The Date to set this $(LREF DateTime)'s date portion to.
+/
@property void date(in Date date) @safe pure nothrow
{
_date = date;
}
unittest
{
auto dt = DateTime.init;
dt.date = Date(1999, 7, 6);
assert(dt._date == Date(1999, 7, 6));
assert(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 $(LREF DateTime).
+/
@property TimeOfDay timeOfDay() @safe const pure nothrow
{
return _tod;
}
unittest
{
{
auto dt = DateTime.init;
assert(dt.timeOfDay == TimeOfDay.init);
}
{
auto dt = DateTime(Date.init, TimeOfDay(12, 30, 33));
assert(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 $(LREF DateTime).
Params:
tod = The $(LREF TimeOfDay) to set this $(LREF DateTime)'s time portion
to.
+/
@property void timeOfDay(in TimeOfDay tod) @safe pure nothrow
{
_tod = tod;
}
unittest
{
auto dt = DateTime.init;
dt.timeOfDay = TimeOfDay(12, 30, 33);
assert(dt._date == Date.init);
assert(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() @safe const pure nothrow
{
return _date.year;
}
unittest
{
assert(Date.init.year == 1);
assert(Date(1999, 7, 6).year == 1999);
assert(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 $(LREF DateTime)'s year to.
Throws:
$(LREF DateTimeException) if the new year is not a leap year and if the
resulting date would be on February 29th.
+/
@property void year(int year) @safe pure
{
_date.year = year;
}
///
unittest
{
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);
}
unittest
{
static void testDT(DateTime dt, int year, in DateTime expected, size_t line = __LINE__)
{
dt.year = year;
assert(dt == expected);
}
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));
}
/++
Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.
Throws:
$(LREF DateTimeException) if $(D isAD) is true.
+/
@property short yearBC() @safe const pure
{
return _date.yearBC;
}
///
unittest
{
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);
}
unittest
{
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));
}
/++
Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.
Params:
year = The year B.C. to set this $(LREF DateTime)'s year to.
Throws:
$(LREF DateTimeException) if a non-positive value is given.
+/
@property void yearBC(int year) @safe pure
{
_date.yearBC = year;
}
///
unittest
{
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)));
}
unittest
{
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));
}
/++
Month of a Gregorian Year.
+/
@property Month month() @safe const pure nothrow
{
return _date.month;
}
///
unittest
{
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);
}
unittest
{
assert(DateTime.init.month == 1);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)).month == 7);
assert(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));
}
/++
Month of a Gregorian Year.
Params:
month = The month to set this $(LREF DateTime)'s month to.
Throws:
$(LREF DateTimeException) if the given month is not a valid month.
+/
@property void month(Month month) @safe pure
{
_date.month = month;
}
unittest
{
static void testDT(DateTime dt, Month month, in DateTime expected = DateTime.init, size_t line = __LINE__)
{
dt.month = month;
assert(expected != DateTime.init);
assert(dt == expected);
}
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.
+/
@property ubyte day() @safe const pure nothrow
{
return _date.day;
}
///
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);
}
unittest
{
import std.range;
import std.format : format;
static void test(DateTime dateTime, int expected)
{
assert(dateTime.day == expected, format("Value given: %s", dateTime));
}
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 $(LREF DateTime)'s day to.
Throws:
$(LREF DateTimeException) if the given day is not a valid day of the
current month.
+/
@property void day(int day) @safe pure
{
_date.day = day;
}
unittest
{
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;
assert(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;
assert(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 past midnight.
+/
@property ubyte hour() @safe const pure nothrow
{
return _tod.hour;
}
unittest
{
assert(DateTime.init.hour == 0);
assert(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 past midnight.
Params:
hour = The hour of the day to set this $(LREF DateTime)'s hour to.
Throws:
$(LREF DateTimeException) if the given hour would result in an invalid
$(LREF DateTime).
+/
@property void hour(int hour) @safe pure
{
_tod.hour = hour;
}
unittest
{
assertThrown!DateTimeException((){DateTime(Date(1999, 7, 6), TimeOfDay(0, 0, 0)).hour = 24;}());
auto dt = DateTime.init;
dt.hour = 12;
assert(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 past the hour.
+/
@property ubyte minute() @safe const pure nothrow
{
return _tod.minute;
}
unittest
{
assert(DateTime.init.minute == 0);
assert(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 past the hour.
Params:
minute = The minute to set this $(LREF DateTime)'s minute to.
Throws:
$(LREF DateTimeException) if the given minute would result in an
invalid $(LREF DateTime).
+/
@property void minute(int minute) @safe pure
{
_tod.minute = minute;
}
unittest
{
assertThrown!DateTimeException((){DateTime.init.minute = 60;}());
auto dt = DateTime.init;
dt.minute = 30;
assert(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 past the minute.
+/
@property ubyte second() @safe const pure nothrow
{
return _tod.second;
}
unittest
{
assert(DateTime.init.second == 0);
assert(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 past the minute.
Params:
second = The second to set this $(LREF DateTime)'s second to.
Throws:
$(LREF DateTimeException) if the given seconds would result in an
invalid $(LREF DateTime).
+/
@property void second(int second) @safe pure
{
_tod.second = second;
}
unittest
{
assertThrown!DateTimeException((){DateTime.init.second = 60;}());
auto dt = DateTime.init;
dt.second = 33;
assert(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 $(LREF 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
$(LREF DateTime).
allowOverflow = Whether the days should be allowed to overflow,
causing the month to increment.
+/
ref DateTime add(string units)
(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) @safe pure nothrow
if(units == "years" ||
units == "months")
{
_date.add!units(value, allowOverflow);
return this;
}
///
unittest
{
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
{
auto dt = DateTime(2000, 1, 31);
dt.add!"years"(7).add!"months"(-4);
assert(dt == DateTime(2006, 10, 1));
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 $(LREF DateTime). A
negative number will subtract.
The difference between rolling and adding is that rolling does not
affect larger units. Rolling a $(LREF DateTime) 12 months
gets the exact same $(LREF 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
$(LREF DateTime).
allowOverflow = Whether the days should be allowed to overflow,
causing the month to increment.
+/
ref DateTime roll(string units)
(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) @safe pure nothrow
if(units == "years" ||
units == "months")
{
_date.roll!units(value, allowOverflow);
return this;
}
///
unittest
{
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
{
auto dt = DateTime(2000, 1, 31);
dt.roll!"years"(7).roll!"months"(-4);
assert(dt == DateTime(2007, 10, 1));
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)));
}
/++
Adds the given number of units to this $(LREF DateTime). A negative number
will subtract.
The difference between rolling and adding is that rolling does not
affect larger units. For instance, rolling a $(LREF DateTime) one
year's worth of days gets the exact same $(LREF 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 $(LREF DateTime).
+/
ref DateTime roll(string units)(long value) @safe pure nothrow
if(units == "days")
{
_date.roll!"days"(value);
return this;
}
///
unittest
{
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
{
auto dt = DateTime(2000, 1, 31);
dt.roll!"days"(7).roll!"days"(-4);
assert(dt == DateTime(2000, 1, 3));
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 roll(string units)(long value) @safe pure nothrow
if(units == "hours" ||
units == "minutes" ||
units == "seconds")
{
_tod.roll!units(value);
return this;
}
//Test roll!"hours"().
unittest
{
static void testDT(DateTime orig, int hours, in DateTime expected, size_t line = __LINE__)
{
orig.roll!"hours"(hours);
assert(orig == expected);
}
//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)));
auto dt = DateTime(2000, 1, 31, 9, 7, 6);
dt.roll!"hours"(27).roll!"hours"(-9);
assert(dt == DateTime(2000, 1, 31, 3, 7, 6));
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)));
}
//Test roll!"minutes"().
unittest
{
static void testDT(DateTime orig, int minutes, in DateTime expected, size_t line = __LINE__)
{
orig.roll!"minutes"(minutes);
assert(orig == expected);
}
//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)));
auto dt = DateTime(2000, 1, 31, 9, 7, 6);
dt.roll!"minutes"(92).roll!"minutes"(-292);
assert(dt == DateTime(2000, 1, 31, 9, 47, 6));
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
{
static void testDT(DateTime orig, int seconds, in DateTime expected, size_t line = __LINE__)
{
orig.roll!"seconds"(seconds);
assert(orig == expected);
}
//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)));
auto dt = DateTime(2000, 1, 31, 9, 7, 6);
dt.roll!"seconds"(92).roll!"seconds"(-292);
assert(dt == DateTime(2000, 1, 31, 9, 7, 46));
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
$(LREF DateTime).
The legal types of arithmetic for $(LREF 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
$(LREF DateTime).
+/
DateTime opBinary(string op, D)(in D duration) @safe const pure nothrow
if((op == "+" || op == "-") &&
(is(Unqual!D == Duration) ||
is(Unqual!D == TickDuration)))
{
import std.format : format;
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;
mixin(format(`return retval._addSeconds(convert!("hnsecs", "seconds")(%shnsecs));`, op));
}
unittest
{
auto dt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));
assert(dt + dur!"weeks"(7) == DateTime(Date(1999, 8, 24), TimeOfDay(12, 30, 33)));
assert(dt + dur!"weeks"(-7) == DateTime(Date(1999, 5, 18), TimeOfDay(12, 30, 33)));
assert(dt + dur!"days"(7) == DateTime(Date(1999, 7, 13), TimeOfDay(12, 30, 33)));
assert(dt + dur!"days"(-7) == DateTime(Date(1999, 6, 29), TimeOfDay(12, 30, 33)));
assert(dt + dur!"hours"(7) == DateTime(Date(1999, 7, 6), TimeOfDay(19, 30, 33)));
assert(dt + dur!"hours"(-7) == DateTime(Date(1999, 7, 6), TimeOfDay(5, 30, 33)));
assert(dt + dur!"minutes"(7) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 37, 33)));
assert(dt + dur!"minutes"(-7) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 23, 33)));
assert(dt + dur!"seconds"(7) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
assert(dt + dur!"seconds"(-7) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
assert(dt + dur!"msecs"(7_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
assert(dt + dur!"msecs"(-7_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
assert(dt + dur!"usecs"(7_000_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
assert(dt + dur!"usecs"(-7_000_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
assert(dt + dur!"hnsecs"(70_000_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
assert(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)
{
assert(dt + TickDuration.from!"usecs"(7_000_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
assert(dt + TickDuration.from!"usecs"(-7_000_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
}
assert(dt - dur!"weeks"(-7) == DateTime(Date(1999, 8, 24), TimeOfDay(12, 30, 33)));
assert(dt - dur!"weeks"(7) == DateTime(Date(1999, 5, 18), TimeOfDay(12, 30, 33)));
assert(dt - dur!"days"(-7) == DateTime(Date(1999, 7, 13), TimeOfDay(12, 30, 33)));
assert(dt - dur!"days"(7) == DateTime(Date(1999, 6, 29), TimeOfDay(12, 30, 33)));
assert(dt - dur!"hours"(-7) == DateTime(Date(1999, 7, 6), TimeOfDay(19, 30, 33)));
assert(dt - dur!"hours"(7) == DateTime(Date(1999, 7, 6), TimeOfDay(5, 30, 33)));
assert(dt - dur!"minutes"(-7) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 37, 33)));
assert(dt - dur!"minutes"(7) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 23, 33)));
assert(dt - dur!"seconds"(-7) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
assert(dt - dur!"seconds"(7) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
assert(dt - dur!"msecs"(-7_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
assert(dt - dur!"msecs"(7_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
assert(dt - dur!"usecs"(-7_000_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
assert(dt - dur!"usecs"(7_000_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
assert(dt - dur!"hnsecs"(-70_000_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
assert(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)
{
assert(dt - TickDuration.from!"usecs"(-7_000_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
assert(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
$(LREF DateTime), as well as assigning the result to this $(LREF DateTime).
The legal types of arithmetic for $(LREF 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
$(LREF DateTime).
+/
ref DateTime opOpAssign(string op, D)(in D duration) @safe pure nothrow
if((op == "+" || op == "-") &&
(is(Unqual!D == Duration) ||
is(Unqual!D == TickDuration)))
{
import std.format : format;
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;
mixin(format(`return _addSeconds(convert!("hnsecs", "seconds")(%shnsecs));`, op));
}
unittest
{
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) + dur!"weeks"(7) == DateTime(Date(1999, 8, 24), TimeOfDay(12, 30, 33)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) + dur!"weeks"(-7) == DateTime(Date(1999, 5, 18), TimeOfDay(12, 30, 33)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) + dur!"days"(7) == DateTime(Date(1999, 7, 13), TimeOfDay(12, 30, 33)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) + dur!"days"(-7) == DateTime(Date(1999, 6, 29), TimeOfDay(12, 30, 33)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) + dur!"hours"(7) == DateTime(Date(1999, 7, 6), TimeOfDay(19, 30, 33)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) + dur!"hours"(-7) == DateTime(Date(1999, 7, 6), TimeOfDay(5, 30, 33)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) + dur!"minutes"(7) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 37, 33)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) + dur!"minutes"(-7) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 23, 33)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) + dur!"seconds"(7) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) + dur!"seconds"(-7) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) + dur!"msecs"(7_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) + dur!"msecs"(-7_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) + dur!"usecs"(7_000_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) + dur!"usecs"(-7_000_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) + dur!"hnsecs"(70_000_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) + dur!"hnsecs"(-70_000_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) - dur!"weeks"(-7) == DateTime(Date(1999, 8, 24), TimeOfDay(12, 30, 33)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) - dur!"weeks"(7) == DateTime(Date(1999, 5, 18), TimeOfDay(12, 30, 33)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) - dur!"days"(-7) == DateTime(Date(1999, 7, 13), TimeOfDay(12, 30, 33)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) - dur!"days"(7) == DateTime(Date(1999, 6, 29), TimeOfDay(12, 30, 33)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) - dur!"hours"(-7) == DateTime(Date(1999, 7, 6), TimeOfDay(19, 30, 33)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) - dur!"hours"(7) == DateTime(Date(1999, 7, 6), TimeOfDay(5, 30, 33)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) - dur!"minutes"(-7) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 37, 33)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) - dur!"minutes"(7) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 23, 33)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) - dur!"seconds"(-7) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) - dur!"seconds"(7) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) - dur!"msecs"(-7_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) - dur!"msecs"(7_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) - dur!"usecs"(-7_000_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) - dur!"usecs"(7_000_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) - dur!"hnsecs"(-70_000_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 40)));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) - dur!"hnsecs"(70_000_000) == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 26)));
auto dt = DateTime(2000, 1, 31, 9, 7, 6);
(dt += dur!"seconds"(92)) -= dur!"days"(-500);
assert(dt == DateTime(2001, 6, 14, 9, 8, 38));
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 $(LREF DateTime)s.
The legal types of arithmetic for $(LREF DateTime) using this operator are
$(BOOKTABLE,
$(TR $(TD DateTime) $(TD -) $(TD DateTime) $(TD -->) $(TD duration))
)
+/
Duration opBinary(string op)(in DateTime rhs) @safe 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
{
auto dt = DateTime(1999, 7, 6, 12, 30, 33);
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) -
DateTime(Date(1998, 7, 6), TimeOfDay(12, 30, 33)) ==
dur!"seconds"(31_536_000));
assert(DateTime(Date(1998, 7, 6), TimeOfDay(12, 30, 33)) -
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) ==
dur!"seconds"(-31_536_000));
assert(DateTime(Date(1999, 8, 6), TimeOfDay(12, 30, 33)) -
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) ==
dur!"seconds"(26_78_400));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) -
DateTime(Date(1999, 8, 6), TimeOfDay(12, 30, 33)) ==
dur!"seconds"(-26_78_400));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) -
DateTime(Date(1999, 7, 5), TimeOfDay(12, 30, 33)) ==
dur!"seconds"(86_400));
assert(DateTime(Date(1999, 7, 5), TimeOfDay(12, 30, 33)) -
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) ==
dur!"seconds"(-86_400));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) -
DateTime(Date(1999, 7, 6), TimeOfDay(11, 30, 33)) ==
dur!"seconds"(3600));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(11, 30, 33)) -
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) ==
dur!"seconds"(-3600));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)) -
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) ==
dur!"seconds"(60));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) -
DateTime(Date(1999, 7, 6), TimeOfDay(12, 31, 33)) ==
dur!"seconds"(-60));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)) -
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) ==
dur!"seconds"(1));
assert(DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)) -
DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 34)) ==
dur!"seconds"(-1));
assert(DateTime(1, 1, 1, 12, 30, 33) - DateTime(1, 1, 1, 0, 0, 0) == dur!"seconds"(45033));
assert(DateTime(1, 1, 1, 0, 0, 0) - DateTime(1, 1, 1, 12, 30, 33) == dur!"seconds"(-45033));
assert(DateTime(0, 12, 31, 12, 30, 33) - DateTime(1, 1, 1, 0, 0, 0) == dur!"seconds"(-41367));
assert(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 $(LREF DateTime)s in months.
To get the difference in years, subtract the year property
of two $(LREF SysTime)s. To get the difference in days or weeks,
subtract the $(LREF SysTime)s themselves and use the $(CXREF time, Duration)
that results. Because converting between months and smaller
units requires a specific date (which $(CXREF time, 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 $(LREF DateTime) to subtract from this one.
+/
int diffMonths(in DateTime rhs) @safe const pure nothrow
{
return _date.diffMonths(rhs._date);
}
///
unittest
{
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);
}
unittest
{
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)));
}
/++
Whether this $(LREF DateTime) is in a leap year.
+/
@property bool isLeapYear() @safe const pure nothrow
{
return _date.isLeapYear;
}
unittest
{
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 $(LREF DateTime) is on.
+/
@property DayOfWeek dayOfWeek() @safe const pure nothrow
{
return _date.dayOfWeek;
}
unittest
{
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 $(LREF DateTime) is on.
+/
@property ushort dayOfYear() @safe const pure nothrow
{
return _date.dayOfYear;
}
///
unittest
{
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);
}
unittest
{
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));
}
/++
Day of the year.
Params:
day = The day of the year to set which day of the year this
$(LREF DateTime) is on.
+/
@property void dayOfYear(int day) @safe pure
{
_date.dayOfYear = day;
}
unittest
{
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 $(LREF DateTime) is on.
+/
@property int dayOfGregorianCal() @safe const pure nothrow
{
return _date.dayOfGregorianCal;
}
///
unittest
{
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);
}
unittest
{
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));
}
/++
The Xth day of the Gregorian Calendar that this $(LREF DateTime) is on.
Setting this property does not affect the time portion of
$(LREF DateTime).
Params:
days = The day of the Gregorian Calendar to set this $(LREF DateTime)
to.
+/
@property void dayOfGregorianCal(int days) @safe pure nothrow
{
_date.dayOfGregorianCal = days;
}
///
unittest
{
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)));
}
unittest
{
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));
}
/++
The ISO 8601 week of the year that this $(LREF DateTime) is in.
See_Also:
$(WEB en.wikipedia.org/wiki/ISO_week_date, ISO Week Date)
+/
@property ubyte isoWeek() @safe const pure nothrow
{
return _date.isoWeek;
}
unittest
{
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));
}
/++
$(LREF DateTime) for the last day in the month that this $(LREF DateTime) is
in. The time portion of endOfMonth is always 23:59:59.
+/
@property DateTime endOfMonth() @safe const pure nothrow
{
try
return DateTime(_date.endOfMonth, TimeOfDay(23, 59, 59));
catch(Exception e)
assert(0, "DateTime constructor threw.");
}
///
unittest
{
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)));
}
unittest
{
//Test A.D.
assert(DateTime(1999, 1, 1, 0, 13, 26).endOfMonth == DateTime(1999, 1, 31, 23, 59, 59));
assert(DateTime(1999, 2, 1, 1, 14, 27).endOfMonth == DateTime(1999, 2, 28, 23, 59, 59));
assert(DateTime(2000, 2, 1, 2, 15, 28).endOfMonth == DateTime(2000, 2, 29, 23, 59, 59));
assert(DateTime(1999, 3, 1, 3, 16, 29).endOfMonth == DateTime(1999, 3, 31, 23, 59, 59));
assert(DateTime(1999, 4, 1, 4, 17, 30).endOfMonth == DateTime(1999, 4, 30, 23, 59, 59));
assert(DateTime(1999, 5, 1, 5, 18, 31).endOfMonth == DateTime(1999, 5, 31, 23, 59, 59));
assert(DateTime(1999, 6, 1, 6, 19, 32).endOfMonth == DateTime(1999, 6, 30, 23, 59, 59));
assert(DateTime(1999, 7, 1, 7, 20, 33).endOfMonth == DateTime(1999, 7, 31, 23, 59, 59));
assert(DateTime(1999, 8, 1, 8, 21, 34).endOfMonth == DateTime(1999, 8, 31, 23, 59, 59));
assert(DateTime(1999, 9, 1, 9, 22, 35).endOfMonth == DateTime(1999, 9, 30, 23, 59, 59));
assert(DateTime(1999, 10, 1, 10, 23, 36).endOfMonth == DateTime(1999, 10, 31, 23, 59, 59));
assert(DateTime(1999, 11, 1, 11, 24, 37).endOfMonth == DateTime(1999, 11, 30, 23, 59, 59));
assert(DateTime(1999, 12, 1, 12, 25, 38).endOfMonth == DateTime(1999, 12, 31, 23, 59, 59));
//Test B.C.
assert(DateTime(-1999, 1, 1, 0, 13, 26).endOfMonth == DateTime(-1999, 1, 31, 23, 59, 59));
assert(DateTime(-1999, 2, 1, 1, 14, 27).endOfMonth == DateTime(-1999, 2, 28, 23, 59, 59));
assert(DateTime(-2000, 2, 1, 2, 15, 28).endOfMonth == DateTime(-2000, 2, 29, 23, 59, 59));
assert(DateTime(-1999, 3, 1, 3, 16, 29).endOfMonth == DateTime(-1999, 3, 31, 23, 59, 59));
assert(DateTime(-1999, 4, 1, 4, 17, 30).endOfMonth == DateTime(-1999, 4, 30, 23, 59, 59));
assert(DateTime(-1999, 5, 1, 5, 18, 31).endOfMonth == DateTime(-1999, 5, 31, 23, 59, 59));
assert(DateTime(-1999, 6, 1, 6, 19, 32).endOfMonth == DateTime(-1999, 6, 30, 23, 59, 59));
assert(DateTime(-1999, 7, 1, 7, 20, 33).endOfMonth == DateTime(-1999, 7, 31, 23, 59, 59));
assert(DateTime(-1999, 8, 1, 8, 21, 34).endOfMonth == DateTime(-1999, 8, 31, 23, 59, 59));
assert(DateTime(-1999, 9, 1, 9, 22, 35).endOfMonth == DateTime(-1999, 9, 30, 23, 59, 59));
assert(DateTime(-1999, 10, 1, 10, 23, 36).endOfMonth == DateTime(-1999, 10, 31, 23, 59, 59));
assert(DateTime(-1999, 11, 1, 11, 24, 37).endOfMonth == DateTime(-1999, 11, 30, 23, 59, 59));
assert(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));
}
/++
The last day in the month that this $(LREF DateTime) is in.
+/
@property ubyte daysInMonth() @safe const pure nothrow
{
return _date.daysInMonth;
}
///
unittest
{
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);
}
unittest
{
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));
}
/++
Whether the current year is a date in A.D.
+/
@property bool isAD() @safe const pure nothrow
{
return _date.isAD;
}
///
unittest
{
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);
}
unittest
{
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));
}
/++
The $(WEB en.wikipedia.org/wiki/Julian_day, Julian day) for this
$(LREF 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() @safe const pure nothrow
{
if(_tod._hour < 12)
return _date.julianDay - 1;
else
return _date.julianDay;
}
unittest
{
assert(DateTime(Date(-4713, 11, 24), TimeOfDay(0, 0, 0)).julianDay == -1);
assert(DateTime(Date(-4713, 11, 24), TimeOfDay(12, 0, 0)).julianDay == 0);
assert(DateTime(Date(0, 12, 31), TimeOfDay(0, 0, 0)).julianDay == 1_721_424);
assert(DateTime(Date(0, 12, 31), TimeOfDay(12, 0, 0)).julianDay == 1_721_425);
assert(DateTime(Date(1, 1, 1), TimeOfDay(0, 0, 0)).julianDay == 1_721_425);
assert(DateTime(Date(1, 1, 1), TimeOfDay(12, 0, 0)).julianDay == 1_721_426);
assert(DateTime(Date(1582, 10, 15), TimeOfDay(0, 0, 0)).julianDay == 2_299_160);
assert(DateTime(Date(1582, 10, 15), TimeOfDay(12, 0, 0)).julianDay == 2_299_161);
assert(DateTime(Date(1858, 11, 17), TimeOfDay(0, 0, 0)).julianDay == 2_400_000);
assert(DateTime(Date(1858, 11, 17), TimeOfDay(12, 0, 0)).julianDay == 2_400_001);
assert(DateTime(Date(1982, 1, 4), TimeOfDay(0, 0, 0)).julianDay == 2_444_973);
assert(DateTime(Date(1982, 1, 4), TimeOfDay(12, 0, 0)).julianDay == 2_444_974);
assert(DateTime(Date(1996, 3, 31), TimeOfDay(0, 0, 0)).julianDay == 2_450_173);
assert(DateTime(Date(1996, 3, 31), TimeOfDay(12, 0, 0)).julianDay == 2_450_174);
assert(DateTime(Date(2010, 8, 24), TimeOfDay(0, 0, 0)).julianDay == 2_455_432);
assert(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 $(WEB en.wikipedia.org/wiki/Julian_day, Julian day) for any
time on this date (since, the modified Julian day changes at midnight).
+/
@property long modJulianDay() @safe const pure nothrow
{
return _date.modJulianDay;
}
unittest
{
assert(DateTime(Date(1858, 11, 17), TimeOfDay(0, 0, 0)).modJulianDay == 0);
assert(DateTime(Date(1858, 11, 17), TimeOfDay(12, 0, 0)).modJulianDay == 0);
assert(DateTime(Date(2010, 8, 24), TimeOfDay(0, 0, 0)).modJulianDay == 55_432);
assert(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 $(LREF DateTime) to a string with the format YYYYMMDDTHHMMSS.
+/
string toISOString() @safe const pure nothrow
{
import std.format : format;
try
return format("%sT%s", _date.toISOString(), _tod.toISOString());
catch(Exception e)
assert(0, "format() threw.");
}
///
unittest
{
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");
}
unittest
{
//Test A.D.
assert(DateTime(Date(9, 12, 4), TimeOfDay(0, 0, 0)).toISOString() == "00091204T000000");
assert(DateTime(Date(99, 12, 4), TimeOfDay(5, 6, 12)).toISOString() == "00991204T050612");
assert(DateTime(Date(999, 12, 4), TimeOfDay(13, 44, 59)).toISOString() == "09991204T134459");
assert(DateTime(Date(9999, 7, 4), TimeOfDay(23, 59, 59)).toISOString() == "99990704T235959");
assert(DateTime(Date(10000, 10, 20), TimeOfDay(1, 1, 1)).toISOString() == "+100001020T010101");
//Test B.C.
assert(DateTime(Date(0, 12, 4), TimeOfDay(0, 12, 4)).toISOString() == "00001204T001204");
assert(DateTime(Date(-9, 12, 4), TimeOfDay(0, 0, 0)).toISOString() == "-00091204T000000");
assert(DateTime(Date(-99, 12, 4), TimeOfDay(5, 6, 12)).toISOString() == "-00991204T050612");
assert(DateTime(Date(-999, 12, 4), TimeOfDay(13, 44, 59)).toISOString() == "-09991204T134459");
assert(DateTime(Date(-9999, 7, 4), TimeOfDay(23, 59, 59)).toISOString() == "-99990704T235959");
assert(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()));
}
/++
Converts this $(LREF DateTime) to a string with the format
YYYY-MM-DDTHH:MM:SS.
+/
string toISOExtString() @safe const pure nothrow
{
import std.format : format;
try
return format("%sT%s", _date.toISOExtString(), _tod.toISOExtString());
catch(Exception e)
assert(0, "format() threw.");
}
///
unittest
{
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");
}
unittest
{
//Test A.D.
assert(DateTime(Date(9, 12, 4), TimeOfDay(0, 0, 0)).toISOExtString() == "0009-12-04T00:00:00");
assert(DateTime(Date(99, 12, 4), TimeOfDay(5, 6, 12)).toISOExtString() == "0099-12-04T05:06:12");
assert(DateTime(Date(999, 12, 4), TimeOfDay(13, 44, 59)).toISOExtString() == "0999-12-04T13:44:59");
assert(DateTime(Date(9999, 7, 4), TimeOfDay(23, 59, 59)).toISOExtString() == "9999-07-04T23:59:59");
assert(DateTime(Date(10000, 10, 20), TimeOfDay(1, 1, 1)).toISOExtString() == "+10000-10-20T01:01:01");
//Test B.C.
assert(DateTime(Date(0, 12, 4), TimeOfDay(0, 12, 4)).toISOExtString() == "0000-12-04T00:12:04");
assert(DateTime(Date(-9, 12, 4), TimeOfDay(0, 0, 0)).toISOExtString() == "-0009-12-04T00:00:00");
assert(DateTime(Date(-99, 12, 4), TimeOfDay(5, 6, 12)).toISOExtString() == "-0099-12-04T05:06:12");
assert(DateTime(Date(-999, 12, 4), TimeOfDay(13, 44, 59)).toISOExtString() == "-0999-12-04T13:44:59");
assert(DateTime(Date(-9999, 7, 4), TimeOfDay(23, 59, 59)).toISOExtString() == "-9999-07-04T23:59:59");
assert(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()));
}
/++
Converts this $(LREF DateTime) to a string with the format
YYYY-Mon-DD HH:MM:SS.
+/
string toSimpleString() @safe const pure nothrow
{
import std.format : format;
try
return format("%s %s", _date.toSimpleString(), _tod.toString());
catch(Exception e)
assert(0, "format() threw.");
}
///
unittest
{
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");
}
unittest
{
//Test A.D.
assert(DateTime(Date(9, 12, 4), TimeOfDay(0, 0, 0)).toSimpleString() == "0009-Dec-04 00:00:00");
assert(DateTime(Date(99, 12, 4), TimeOfDay(5, 6, 12)).toSimpleString() == "0099-Dec-04 05:06:12");
assert(DateTime(Date(999, 12, 4), TimeOfDay(13, 44, 59)).toSimpleString() == "0999-Dec-04 13:44:59");
assert(DateTime(Date(9999, 7, 4), TimeOfDay(23, 59, 59)).toSimpleString() == "9999-Jul-04 23:59:59");
assert(DateTime(Date(10000, 10, 20), TimeOfDay(1, 1, 1)).toSimpleString() == "+10000-Oct-20 01:01:01");
//Test B.C.
assert(DateTime(Date(0, 12, 4), TimeOfDay(0, 12, 4)).toSimpleString() == "0000-Dec-04 00:12:04");
assert(DateTime(Date(-9, 12, 4), TimeOfDay(0, 0, 0)).toSimpleString() == "-0009-Dec-04 00:00:00");
assert(DateTime(Date(-99, 12, 4), TimeOfDay(5, 6, 12)).toSimpleString() == "-0099-Dec-04 05:06:12");
assert(DateTime(Date(-999, 12, 4), TimeOfDay(13, 44, 59)).toSimpleString() == "-0999-Dec-04 13:44:59");
assert(DateTime(Date(-9999, 7, 4), TimeOfDay(23, 59, 59)).toSimpleString() == "-9999-Jul-04 23:59:59");
assert(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()));
}
/++
Converts this $(LREF DateTime) to a string.
+/
string toString() @safe const pure nothrow
{
return toSimpleString();
}
unittest
{
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 $(LREF 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:
$(LREF DateTimeException) if the given string is not in the ISO format
or if the resulting $(LREF DateTime) would not be valid.
+/
static DateTime fromISOString(S)(in S isoString) @safe pure
if(isSomeString!S)
{
import std.string : strip;
import std.conv : to;
import std.algorithm : countUntil;
import std.format : format;
immutable dstr = to!dstring(strip(isoString));
enforce(dstr.length >= 15, new DateTimeException(format("Invalid ISO String: %s", isoString)));
auto t = dstr.countUntil('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
{
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)));
}
unittest
{
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"));
assert(DateTime.fromISOString("20101222T172201") == DateTime(Date(2010, 12, 22), TimeOfDay(17, 22, 01)));
assert(DateTime.fromISOString("19990706T123033") == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
assert(DateTime.fromISOString("-19990706T123033") == DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
assert(DateTime.fromISOString("+019990706T123033") == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
assert(DateTime.fromISOString("19990706T123033 ") == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
assert(DateTime.fromISOString(" 19990706T123033") == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
assert(DateTime.fromISOString(" 19990706T123033 ") == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
}
/++
Creates a $(LREF DateTime) from a string with the format
YYYY-MM-DDTHH:MM:SS. Whitespace is stripped from the given string.
Params:
isoExtString = A string formatted in the ISO Extended format for dates
and times.
Throws:
$(LREF DateTimeException) if the given string is not in the ISO
Extended format or if the resulting $(LREF DateTime) would not be
valid.
+/
static DateTime fromISOExtString(S)(in S isoExtString) @safe pure
if(isSomeString!(S))
{
import std.string : strip;
import std.conv : to;
import std.algorithm : countUntil;
import std.format : format;
immutable dstr = to!dstring(strip(isoExtString));
enforce(dstr.length >= 15, new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)));
auto t = dstr.countUntil('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
{
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)));
}
unittest
{
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"));
assert(DateTime.fromISOExtString("2010-12-22T17:22:01") == DateTime(Date(2010, 12, 22), TimeOfDay(17, 22, 01)));
assert(DateTime.fromISOExtString("1999-07-06T12:30:33") == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
assert(DateTime.fromISOExtString("-1999-07-06T12:30:33") == DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
assert(DateTime.fromISOExtString("+01999-07-06T12:30:33") == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
assert(DateTime.fromISOExtString("1999-07-06T12:30:33 ") == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
assert(DateTime.fromISOExtString(" 1999-07-06T12:30:33") == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
assert(DateTime.fromISOExtString(" 1999-07-06T12:30:33 ") == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
}
/++
Creates a $(LREF 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:
$(LREF DateTimeException) if the given string is not in the correct
format or if the resulting $(LREF DateTime) would not be valid.
+/
static DateTime fromSimpleString(S)(in S simpleString) @safe pure
if(isSomeString!(S))
{
import std.string : strip;
import std.conv : to;
import std.algorithm : countUntil;
import std.format : format;
immutable dstr = to!dstring(strip(simpleString));
enforce(dstr.length >= 15, new DateTimeException(format("Invalid string format: %s", simpleString)));
auto t = dstr.countUntil(' ');
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
{
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)));
}
unittest
{
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"));
assert(DateTime.fromSimpleString("2010-Dec-22 17:22:01") == DateTime(Date(2010, 12, 22), TimeOfDay(17, 22, 01)));
assert(DateTime.fromSimpleString("1999-Jul-06 12:30:33") == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
assert(DateTime.fromSimpleString("-1999-Jul-06 12:30:33") == DateTime(Date(-1999, 7, 6), TimeOfDay(12, 30, 33)));
assert(DateTime.fromSimpleString("+01999-Jul-06 12:30:33") == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
assert(DateTime.fromSimpleString("1999-Jul-06 12:30:33 ") == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
assert(DateTime.fromSimpleString(" 1999-Jul-06 12:30:33") == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
assert(DateTime.fromSimpleString(" 1999-Jul-06 12:30:33 ") == DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33)));
}
/++
Returns the $(LREF DateTime) farthest in the past which is representable by
$(LREF DateTime).
+/
@property static DateTime min() @safe 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
{
assert(DateTime.min.year < 0);
assert(DateTime.min < DateTime.max);
}
/++
Returns the $(LREF DateTime) farthest in the future which is representable
by $(LREF DateTime).
+/
@property static DateTime max() @safe 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
{
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 $(LREF DateTime).
+/
ref DateTime _addSeconds(long seconds) return @safe 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
{
static void testDT(DateTime orig, int seconds, in DateTime expected, size_t line = __LINE__)
{
orig._addSeconds(seconds);
assert(orig == expected);
}
//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:
$(LREF 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:
$(LREF 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 $(LREF2 .Interval, 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 $(LREF2 .Interval, 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:
$(LREF 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:
$(LREF 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 auto 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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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
{
import std.format : format;
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:
$(LREF 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
{
import std.format : format;
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:
$(LREF 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
{
import std.format : format;
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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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
{
import std.format : format;
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:
$(LREF 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
{
import std.format : format;
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:
$(LREF 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
{
import std.format : format;
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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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.
dir = The direction in time to expand the interval.
Throws:
$(LREF 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 $(LREF 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:
$(LREF 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 $(LREF 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:
$(LREF 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
{
import std.format : format;
try
return format("[%s - %s)", _begin, _end);
catch(Exception e)
assert(0, "format() threw.");
}
/+
Throws:
$(LREF 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
{
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
{
assert(Interval!Date(Date(1, 1, 1), Date(2010, 1, 1)).begin == Date(1, 1, 1));
assert(Interval!Date(Date(2010, 1, 1), Date(2010, 1, 1)).begin == Date(2010, 1, 1));
assert(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
{
assert(Interval!Date(Date(1, 1, 1), Date(2010, 1, 1)).end == Date(2010, 1, 1));
assert(Interval!Date(Date(2010, 1, 1), Date(2010, 1, 1)).end == Date(2010, 1, 1));
assert(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
{
assert(Interval!Date(Date(2010, 1, 1), Date(2010, 1, 1)).length == dur!"days"(0));
assert(Interval!Date(Date(2010, 1, 1), Date(2010, 4, 1)).length == dur!"days"(90));
assert(Interval!TimeOfDay(TimeOfDay(0, 30, 0), TimeOfDay(12, 22, 7)).length == dur!"seconds"(42_727));
assert(Interval!DateTime(DateTime(2010, 1, 1, 0, 30, 0), DateTime(2010, 1, 2, 12, 22, 7)).length == dur!"seconds"(129_127));
assert(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
{
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
{
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
{
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
{
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
{
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
{
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
{
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
{
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
{
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))));
assert(interval.intersection(interval) == interval);
assert(interval.intersection(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(interval.intersection(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))) ==
Interval!Date(Date(2010, 7, 4), Date(2010, 7, 5)));
assert(interval.intersection(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(interval.intersection(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(interval.intersection(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))) ==
Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)));
assert(interval.intersection(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))) ==
Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)));
assert(interval.intersection(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))) ==
Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)));
assert(interval.intersection(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))) ==
Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)));
assert(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)).intersection(interval) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5)).intersection(interval) ==
Interval!Date(Date(2010, 7, 4), Date(2010, 7, 5)));
assert(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)).intersection(interval) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)).intersection(interval) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)).intersection(interval) ==
Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)));
assert(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)).intersection(interval) ==
Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)));
assert(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)).intersection(interval) ==
Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)));
assert(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8)).intersection(interval) ==
Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)));
assert(interval.intersection(PosInfInterval!Date(Date(2010, 7, 3))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(interval.intersection(PosInfInterval!Date(Date(2010, 7, 4))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(interval.intersection(PosInfInterval!Date(Date(2010, 7, 5))) ==
Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)));
assert(interval.intersection(PosInfInterval!Date(Date(2012, 1, 6))) ==
Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)));
assert(interval.intersection(NegInfInterval!Date(Date(2010, 7, 5))) ==
Interval!Date(Date(2010, 7, 4), Date(2010, 7, 5)));
assert(interval.intersection(NegInfInterval!Date(Date(2012, 1, 6))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 6)));
assert(interval.intersection(NegInfInterval!Date(Date(2012, 1, 7))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(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
{
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
{
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))));
assert(interval.merge(interval) == interval);
assert(interval.merge(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))) ==
Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)));
assert(interval.merge(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
assert(interval.merge(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
assert(interval.merge(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
assert(interval.merge(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)));
assert(interval.merge(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(interval.merge(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(interval.merge(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(interval.merge(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
assert(interval.merge(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
assert(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)).merge(interval) ==
Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)));
assert(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4)).merge(interval) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
assert(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5)).merge(interval) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
assert(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)).merge(interval) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
assert(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)).merge(interval) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)));
assert(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)).merge(interval) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)).merge(interval) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)).merge(interval) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8)).merge(interval) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
assert(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8)).merge(interval) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
assert(interval.merge(PosInfInterval!Date(Date(2010, 7, 3))) ==
PosInfInterval!Date(Date(2010, 7, 3)));
assert(interval.merge(PosInfInterval!Date(Date(2010, 7, 4))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(interval.merge(PosInfInterval!Date(Date(2010, 7, 5))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(interval.merge(PosInfInterval!Date(Date(2012, 1, 6))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(interval.merge(PosInfInterval!Date(Date(2012, 1, 7))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(interval.merge(NegInfInterval!Date(Date(2010, 7, 4))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(interval.merge(NegInfInterval!Date(Date(2010, 7, 5))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(interval.merge(NegInfInterval!Date(Date(2012, 1, 6))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(interval.merge(NegInfInterval!Date(Date(2012, 1, 7))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(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
{
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))));
assert(interval.span(interval) == interval);
assert(interval.span(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))) ==
Interval!Date(Date(2010, 7, 1), Date(2012, 1, 7)));
assert(interval.span(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))) ==
Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)));
assert(interval.span(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
assert(interval.span(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
assert(interval.span(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
assert(interval.span(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)));
assert(interval.span(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(interval.span(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(interval.span(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(interval.span(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
assert(interval.span(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
assert(interval.span(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 9)));
assert(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3)).span(interval) ==
Interval!Date(Date(2010, 7, 1), Date(2012, 1, 7)));
assert(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)).span(interval) ==
Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3)));
assert(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4)).span(interval) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
assert(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5)).span(interval) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
assert(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)).span(interval) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
assert(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)).span(interval) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8)));
assert(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)).span(interval) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)).span(interval) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)).span(interval) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8)).span(interval) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
assert(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8)).span(interval) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
assert(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9)).span(interval) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 9)));
assert(interval.span(PosInfInterval!Date(Date(2010, 7, 3))) ==
PosInfInterval!Date(Date(2010, 7, 3)));
assert(interval.span(PosInfInterval!Date(Date(2010, 7, 4))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(interval.span(PosInfInterval!Date(Date(2010, 7, 5))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(interval.span(PosInfInterval!Date(Date(2012, 1, 6))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(interval.span(PosInfInterval!Date(Date(2012, 1, 7))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(interval.span(PosInfInterval!Date(Date(2012, 1, 8))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(interval.span(NegInfInterval!Date(Date(2010, 7, 3))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(interval.span(NegInfInterval!Date(Date(2010, 7, 4))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(interval.span(NegInfInterval!Date(Date(2010, 7, 5))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(interval.span(NegInfInterval!Date(Date(2012, 1, 6))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(interval.span(NegInfInterval!Date(Date(2012, 1, 7))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(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
{
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);
assert(interval == expected);
}
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
{
{
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);
assert(interval == expected);
}
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
{
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);
assert(interval == expected);
}
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
{
{
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);
assert(interval == expected);
}
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
{
{
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);
assert(Interval!Date(Date(2010, 9, 12), Date(2010, 10, 1)).fwdRange(everyDayOfWeek!Date(DayOfWeek.fri)).front ==
Date(2010, 9, 12));
assert(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
{
{
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);
assert(Interval!Date(Date(2010, 9, 19), Date(2010, 10, 1)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri)).front ==
Date(2010, 10, 1));
assert(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
{
assert(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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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
{
import std.format : format;
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:
$(LREF 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
{
import std.format : format;
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:
$(LREF 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:
$(LREF 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
{
import std.format : format;
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:
$(LREF 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:
$(LREF 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.
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:
$(LREF 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 $(LREF 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:
$(LREF 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
{
import std.format : format;
try
return format("[%s - ∞)", _begin);
catch(Exception e)
assert(0, "format() threw.");
}
TP _begin;
}
//Test PosInfInterval's constructor.
unittest
{
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
{
assert(PosInfInterval!Date(Date(1, 1, 1)).begin == Date(1, 1, 1));
assert(PosInfInterval!Date(Date(2010, 1, 1)).begin == Date(2010, 1, 1));
assert(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
{
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
{
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
{
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
{
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
{
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
{
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
{
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
{
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
{
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))));
assert(posInfInterval.intersection(posInfInterval) ==
posInfInterval);
assert(posInfInterval.intersection(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))) ==
Interval!Date(Date(2010, 7, 4), Date(2013, 7, 3)));
assert(posInfInterval.intersection(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))) ==
Interval!Date(Date(2010, 7, 4), Date(2010, 7, 5)));
assert(posInfInterval.intersection(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(posInfInterval.intersection(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 8)));
assert(posInfInterval.intersection(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))) ==
Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)));
assert(posInfInterval.intersection(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))) ==
Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)));
assert(posInfInterval.intersection(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))) ==
Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)));
assert(posInfInterval.intersection(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))) ==
Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8)));
assert(posInfInterval.intersection(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))) ==
Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8)));
assert(posInfInterval.intersection(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))) ==
Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9)));
assert(posInfInterval.intersection(PosInfInterval!Date(Date(2010, 7, 3))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.intersection(PosInfInterval!Date(Date(2010, 7, 4))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.intersection(PosInfInterval!Date(Date(2010, 7, 5))) ==
PosInfInterval!Date(Date(2010, 7, 5)));
assert(posInfInterval.intersection(PosInfInterval!Date(Date(2012, 1, 6))) ==
PosInfInterval!Date(Date(2012, 1, 6)));
assert(posInfInterval.intersection(PosInfInterval!Date(Date(2012, 1, 7))) ==
PosInfInterval!Date(Date(2012, 1, 7)));
assert(posInfInterval.intersection(PosInfInterval!Date(Date(2012, 1, 8))) ==
PosInfInterval!Date(Date(2012, 1, 8)));
assert(PosInfInterval!Date(Date(2010, 7, 3)).intersection(posInfInterval) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(PosInfInterval!Date(Date(2010, 7, 4)).intersection(posInfInterval) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(PosInfInterval!Date(Date(2010, 7, 5)).intersection(posInfInterval) ==
PosInfInterval!Date(Date(2010, 7, 5)));
assert(PosInfInterval!Date(Date(2012, 1, 6)).intersection(posInfInterval) ==
PosInfInterval!Date(Date(2012, 1, 6)));
assert(PosInfInterval!Date(Date(2012, 1, 7)).intersection(posInfInterval) ==
PosInfInterval!Date(Date(2012, 1, 7)));
assert(PosInfInterval!Date(Date(2012, 1, 8)).intersection(posInfInterval) ==
PosInfInterval!Date(Date(2012, 1, 8)));
assert(posInfInterval.intersection(NegInfInterval!Date(Date(2010, 7, 5))) ==
Interval!Date(Date(2010, 7, 4), Date(2010, 7, 5)));
assert(posInfInterval.intersection(NegInfInterval!Date(Date(2012, 1, 6))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 6)));
assert(posInfInterval.intersection(NegInfInterval!Date(Date(2012, 1, 7))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1, 7)));
assert(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
{
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
{
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))));
assert(posInfInterval.merge(posInfInterval) ==
posInfInterval);
assert(posInfInterval.merge(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))) ==
PosInfInterval!Date(Date(2010, 7, 1)));
assert(posInfInterval.merge(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))) ==
PosInfInterval!Date(Date(2010, 7, 3)));
assert(posInfInterval.merge(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))) ==
PosInfInterval!Date(Date(2010, 7, 3)));
assert(posInfInterval.merge(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))) ==
PosInfInterval!Date(Date(2010, 7, 3)));
assert(posInfInterval.merge(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))) ==
PosInfInterval!Date(Date(2010, 7, 3)));
assert(posInfInterval.merge(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.merge(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.merge(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.merge(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.merge(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.merge(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.merge(PosInfInterval!Date(Date(2010, 7, 3))) ==
PosInfInterval!Date(Date(2010, 7, 3)));
assert(posInfInterval.merge(PosInfInterval!Date(Date(2010, 7, 4))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.merge(PosInfInterval!Date(Date(2010, 7, 5))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.merge(PosInfInterval!Date(Date(2012, 1, 6))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.merge(PosInfInterval!Date(Date(2012, 1, 7))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.merge(PosInfInterval!Date(Date(2012, 1, 8))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(PosInfInterval!Date(Date(2010, 7, 3)).merge(posInfInterval) ==
PosInfInterval!Date(Date(2010, 7, 3)));
assert(PosInfInterval!Date(Date(2010, 7, 4)).merge(posInfInterval) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(PosInfInterval!Date(Date(2010, 7, 5)).merge(posInfInterval) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(PosInfInterval!Date(Date(2012, 1, 6)).merge(posInfInterval) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(PosInfInterval!Date(Date(2012, 1, 7)).merge(posInfInterval) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(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
{
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))));
assert(posInfInterval.span(posInfInterval) ==
posInfInterval);
assert(posInfInterval.span(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))) ==
PosInfInterval!Date(Date(2010, 7, 1)));
assert(posInfInterval.span(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))) ==
PosInfInterval!Date(Date(2010, 7, 1)));
assert(posInfInterval.span(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))) ==
PosInfInterval!Date(Date(2010, 7, 3)));
assert(posInfInterval.span(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))) ==
PosInfInterval!Date(Date(2010, 7, 3)));
assert(posInfInterval.span(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))) ==
PosInfInterval!Date(Date(2010, 7, 3)));
assert(posInfInterval.span(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))) ==
PosInfInterval!Date(Date(2010, 7, 3)));
assert(posInfInterval.span(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.span(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.span(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.span(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.span(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.span(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.span(PosInfInterval!Date(Date(2010, 7, 3))) ==
PosInfInterval!Date(Date(2010, 7, 3)));
assert(posInfInterval.span(PosInfInterval!Date(Date(2010, 7, 4))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.span(PosInfInterval!Date(Date(2010, 7, 5))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.span(PosInfInterval!Date(Date(2012, 1, 6))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.span(PosInfInterval!Date(Date(2012, 1, 7))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(posInfInterval.span(PosInfInterval!Date(Date(2012, 1, 8))) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(PosInfInterval!Date(Date(2010, 7, 3)).span(posInfInterval) ==
PosInfInterval!Date(Date(2010, 7, 3)));
assert(PosInfInterval!Date(Date(2010, 7, 4)).span(posInfInterval) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(PosInfInterval!Date(Date(2010, 7, 5)).span(posInfInterval) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(PosInfInterval!Date(Date(2012, 1, 6)).span(posInfInterval) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(PosInfInterval!Date(Date(2012, 1, 7)).span(posInfInterval) ==
PosInfInterval!Date(Date(2010, 7, 4)));
assert(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
{
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);
assert(interval == expected);
}
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
{
{
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);
assert(interval == expected);
}
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
{
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);
assert(interval == expected);
}
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
{
{
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);
assert(interval == expected);
}
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
{
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));
assert(PosInfInterval!Date(Date(2010, 9, 12)).fwdRange(everyDayOfWeek!Date(DayOfWeek.fri)).front ==
Date(2010, 9, 12));
assert(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
{
assert(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:
end = The time point which ends 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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF 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
{
import std.format : format;
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:
$(LREF 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
{
import std.format : format;
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:
$(LREF 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:
$(LREF 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
{
import std.format : format;
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:
$(LREF 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:
$(LREF 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.
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:
$(LREF 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 $(LREF 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:
$(LREF 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
{
import std.format : format;
try
return format("[-∞ - %s)", _end);
catch(Exception e)
assert(0, "format() threw.");
}
TP _end;
}
//Test NegInfInterval's constructor.
unittest
{
NegInfInterval!Date(Date.init);
NegInfInterval!TimeOfDay(TimeOfDay.init);
NegInfInterval!DateTime(DateTime.init);
NegInfInterval!SysTime(SysTime(0));
}
//Test NegInfInterval's end.
unittest
{
assert(NegInfInterval!Date(Date(2010, 1, 1)).end == Date(2010, 1, 1));
assert(NegInfInterval!Date(Date(2010, 1, 1)).end == Date(2010, 1, 1));
assert(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
{
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
{
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
{
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
{
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
{
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
{
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
{
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
{
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
{
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))));
assert(negInfInterval.intersection(negInfInterval) ==
negInfInterval);
assert(negInfInterval.intersection(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))) ==
Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3)));
assert(negInfInterval.intersection(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))) ==
Interval!Date(Date(2010, 7, 1), Date(2012, 1, 7)));
assert(negInfInterval.intersection(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))) ==
Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4)));
assert(negInfInterval.intersection(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))) ==
Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5)));
assert(negInfInterval.intersection(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
assert(negInfInterval.intersection(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7)));
assert(negInfInterval.intersection(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))) ==
Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6)));
assert(negInfInterval.intersection(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))) ==
Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7)));
assert(negInfInterval.intersection(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))) ==
Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)));
assert(negInfInterval.intersection(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))) ==
Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7)));
assert(negInfInterval.intersection(NegInfInterval!Date(Date(2010, 7, 3))) ==
NegInfInterval!Date(Date(2010, 7, 3)));
assert(negInfInterval.intersection(NegInfInterval!Date(Date(2010, 7, 4))) ==
NegInfInterval!Date(Date(2010, 7, 4)));
assert(negInfInterval.intersection(NegInfInterval!Date(Date(2010, 7, 5))) ==
NegInfInterval!Date(Date(2010, 7, 5)));
assert(negInfInterval.intersection(NegInfInterval!Date(Date(2012, 1, 6))) ==
NegInfInterval!Date(Date(2012, 1, 6)));
assert(negInfInterval.intersection(NegInfInterval!Date(Date(2012, 1, 7))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.intersection(NegInfInterval!Date(Date(2012, 1, 8))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(NegInfInterval!Date(Date(2010, 7, 3)).intersection(negInfInterval) ==
NegInfInterval!Date(Date(2010, 7, 3)));
assert(NegInfInterval!Date(Date(2010, 7, 4)).intersection(negInfInterval) ==
NegInfInterval!Date(Date(2010, 7, 4)));
assert(NegInfInterval!Date(Date(2010, 7, 5)).intersection(negInfInterval) ==
NegInfInterval!Date(Date(2010, 7, 5)));
assert(NegInfInterval!Date(Date(2012, 1, 6)).intersection(negInfInterval) ==
NegInfInterval!Date(Date(2012, 1, 6)));
assert(NegInfInterval!Date(Date(2012, 1, 7)).intersection(negInfInterval) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(NegInfInterval!Date(Date(2012, 1, 8)).intersection(negInfInterval) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.intersection(PosInfInterval!Date(Date(2010, 7, 3))) ==
Interval!Date(Date(2010, 7, 3), Date(2012, 1 ,7)));
assert(negInfInterval.intersection(PosInfInterval!Date(Date(2010, 7, 4))) ==
Interval!Date(Date(2010, 7, 4), Date(2012, 1 ,7)));
assert(negInfInterval.intersection(PosInfInterval!Date(Date(2010, 7, 5))) ==
Interval!Date(Date(2010, 7, 5), Date(2012, 1 ,7)));
assert(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
{
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
{
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))));
assert(negInfInterval.merge(negInfInterval) ==
negInfInterval);
assert(negInfInterval.merge(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.merge(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))) ==
NegInfInterval!Date(Date(2013, 7, 3)));
assert(negInfInterval.merge(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.merge(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.merge(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.merge(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))) ==
NegInfInterval!Date(Date(2012, 1, 8)));
assert(negInfInterval.merge(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.merge(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.merge(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.merge(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))) ==
NegInfInterval!Date(Date(2012, 1, 8)));
assert(negInfInterval.merge(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))) ==
NegInfInterval!Date(Date(2012, 1, 8)));
assert(negInfInterval.merge(NegInfInterval!Date(Date(2010, 7, 3))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.merge(NegInfInterval!Date(Date(2010, 7, 4))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.merge(NegInfInterval!Date(Date(2010, 7, 5))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.merge(NegInfInterval!Date(Date(2012, 1, 6))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.merge(NegInfInterval!Date(Date(2012, 1, 7))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.merge(NegInfInterval!Date(Date(2012, 1, 8))) ==
NegInfInterval!Date(Date(2012, 1, 8)));
assert(NegInfInterval!Date(Date(2010, 7, 3)).merge(negInfInterval) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(NegInfInterval!Date(Date(2010, 7, 4)).merge(negInfInterval) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(NegInfInterval!Date(Date(2010, 7, 5)).merge(negInfInterval) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(NegInfInterval!Date(Date(2012, 1, 6)).merge(negInfInterval) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(NegInfInterval!Date(Date(2012, 1, 7)).merge(negInfInterval) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(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
{
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))));
assert(negInfInterval.span(negInfInterval) ==
negInfInterval);
assert(negInfInterval.span(Interval!Date(Date(2010, 7, 1), Date(2010, 7, 3))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.span(Interval!Date(Date(2010, 7, 1), Date(2013, 7, 3))) ==
NegInfInterval!Date(Date(2013, 7, 3)));
assert(negInfInterval.span(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 4))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.span(Interval!Date(Date(2010, 7, 3), Date(2010, 7, 5))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.span(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 7))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.span(Interval!Date(Date(2010, 7, 3), Date(2012, 1, 8))) ==
NegInfInterval!Date(Date(2012, 1, 8)));
assert(negInfInterval.span(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 6))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.span(Interval!Date(Date(2010, 7, 5), Date(2012, 1, 7))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.span(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 7))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.span(Interval!Date(Date(2012, 1, 6), Date(2012, 1, 8))) ==
NegInfInterval!Date(Date(2012, 1, 8)));
assert(negInfInterval.span(Interval!Date(Date(2012, 1, 7), Date(2012, 1, 8))) ==
NegInfInterval!Date(Date(2012, 1, 8)));
assert(negInfInterval.span(Interval!Date(Date(2012, 1, 8), Date(2012, 1, 9))) ==
NegInfInterval!Date(Date(2012, 1, 9)));
assert(negInfInterval.span(NegInfInterval!Date(Date(2010, 7, 3))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.span(NegInfInterval!Date(Date(2010, 7, 4))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.span(NegInfInterval!Date(Date(2010, 7, 5))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.span(NegInfInterval!Date(Date(2012, 1, 6))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.span(NegInfInterval!Date(Date(2012, 1, 7))) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(negInfInterval.span(NegInfInterval!Date(Date(2012, 1, 8))) ==
NegInfInterval!Date(Date(2012, 1, 8)));
assert(NegInfInterval!Date(Date(2010, 7, 3)).span(negInfInterval) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(NegInfInterval!Date(Date(2010, 7, 4)).span(negInfInterval) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(NegInfInterval!Date(Date(2010, 7, 5)).span(negInfInterval) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(NegInfInterval!Date(Date(2012, 1, 6)).span(negInfInterval) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(NegInfInterval!Date(Date(2012, 1, 7)).span(negInfInterval) ==
NegInfInterval!Date(Date(2012, 1, 7)));
assert(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
{
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);
assert(interval == expected);
}
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
{
{
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);
assert(interval == expected);
}
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
{
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);
assert(interval == expected);
}
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
{
{
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);
assert(interval == expected);
}
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
{
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));
assert(NegInfInterval!Date(Date(2010, 10, 1)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.fri)).front ==
Date(2010, 10, 1));
assert(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
{
assert(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.
+/
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(typeof(TP.dayOfWeek) == DayOfWeek))
{
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
{
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);
}
unittest
{
auto funcFwd = everyDayOfWeek!Date(DayOfWeek.mon);
auto funcBwd = everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.mon);
assert(funcFwd(Date(2010, 8, 28)) == Date(2010, 8, 30));
assert(funcFwd(Date(2010, 8, 29)) == Date(2010, 8, 30));
assert(funcFwd(Date(2010, 8, 30)) == Date(2010, 9, 6));
assert(funcFwd(Date(2010, 8, 31)) == Date(2010, 9, 6));
assert(funcFwd(Date(2010, 9, 1)) == Date(2010, 9, 6));
assert(funcFwd(Date(2010, 9, 2)) == Date(2010, 9, 6));
assert(funcFwd(Date(2010, 9, 3)) == Date(2010, 9, 6));
assert(funcFwd(Date(2010, 9, 4)) == Date(2010, 9, 6));
assert(funcFwd(Date(2010, 9, 5)) == Date(2010, 9, 6));
assert(funcFwd(Date(2010, 9, 6)) == Date(2010, 9, 13));
assert(funcFwd(Date(2010, 9, 7)) == Date(2010, 9, 13));
assert(funcBwd(Date(2010, 8, 28)) == Date(2010, 8, 23));
assert(funcBwd(Date(2010, 8, 29)) == Date(2010, 8, 23));
assert(funcBwd(Date(2010, 8, 30)) == Date(2010, 8, 23));
assert(funcBwd(Date(2010, 8, 31)) == Date(2010, 8, 30));
assert(funcBwd(Date(2010, 9, 1)) == Date(2010, 8, 30));
assert(funcBwd(Date(2010, 9, 2)) == Date(2010, 8, 30));
assert(funcBwd(Date(2010, 9, 3)) == Date(2010, 8, 30));
assert(funcBwd(Date(2010, 9, 4)) == Date(2010, 8, 30));
assert(funcBwd(Date(2010, 9, 5)) == Date(2010, 8, 30));
assert(funcBwd(Date(2010, 9, 6)) == Date(2010, 8, 30));
assert(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)));
}
/++
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.
+/
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(typeof(TP.month) == Month))
{
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
{
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);
}
unittest
{
auto funcFwd = everyMonth!Date(Month.jun);
auto funcBwd = everyMonth!(Date, Direction.bwd)(Month.jun);
assert(funcFwd(Date(2010, 5, 31)) == Date(2010, 6, 30));
assert(funcFwd(Date(2010, 6, 30)) == Date(2011, 6, 30));
assert(funcFwd(Date(2010, 7, 31)) == Date(2011, 6, 30));
assert(funcFwd(Date(2010, 8, 31)) == Date(2011, 6, 30));
assert(funcFwd(Date(2010, 9, 30)) == Date(2011, 6, 30));
assert(funcFwd(Date(2010, 10, 31)) == Date(2011, 6, 30));
assert(funcFwd(Date(2010, 11, 30)) == Date(2011, 6, 30));
assert(funcFwd(Date(2010, 12, 31)) == Date(2011, 6, 30));
assert(funcFwd(Date(2011, 1, 31)) == Date(2011, 6, 30));
assert(funcFwd(Date(2011, 2, 28)) == Date(2011, 6, 28));
assert(funcFwd(Date(2011, 3, 31)) == Date(2011, 6, 30));
assert(funcFwd(Date(2011, 4, 30)) == Date(2011, 6, 30));
assert(funcFwd(Date(2011, 5, 31)) == Date(2011, 6, 30));
assert(funcFwd(Date(2011, 6, 30)) == Date(2012, 6, 30));
assert(funcFwd(Date(2011, 7, 31)) == Date(2012, 6, 30));
assert(funcBwd(Date(2010, 5, 31)) == Date(2009, 6, 30));
assert(funcBwd(Date(2010, 6, 30)) == Date(2009, 6, 30));
assert(funcBwd(Date(2010, 7, 31)) == Date(2010, 6, 30));
assert(funcBwd(Date(2010, 8, 31)) == Date(2010, 6, 30));
assert(funcBwd(Date(2010, 9, 30)) == Date(2010, 6, 30));
assert(funcBwd(Date(2010, 10, 31)) == Date(2010, 6, 30));
assert(funcBwd(Date(2010, 11, 30)) == Date(2010, 6, 30));
assert(funcBwd(Date(2010, 12, 31)) == Date(2010, 6, 30));
assert(funcBwd(Date(2011, 1, 31)) == Date(2010, 6, 30));
assert(funcBwd(Date(2011, 2, 28)) == Date(2010, 6, 28));
assert(funcBwd(Date(2011, 3, 31)) == Date(2010, 6, 30));
assert(funcBwd(Date(2011, 4, 30)) == Date(2010, 6, 30));
assert(funcBwd(Date(2011, 5, 31)) == Date(2010, 6, 30));
assert(funcBwd(Date(2011, 6, 30)) == Date(2010, 6, 30));
assert(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)));
}
/++
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.
+/
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
{
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);
}
unittest
{
auto funcFwd = everyDuration!Date(dur!"days"(27));
auto funcBwd = everyDuration!(Date, Direction.bwd)(dur!"days"(27));
assert(funcFwd(Date(2009, 12, 25)) == Date(2010, 1, 21));
assert(funcFwd(Date(2009, 12, 26)) == Date(2010, 1, 22));
assert(funcFwd(Date(2009, 12, 27)) == Date(2010, 1, 23));
assert(funcFwd(Date(2009, 12, 28)) == Date(2010, 1, 24));
assert(funcBwd(Date(2010, 1, 21)) == Date(2009, 12, 25));
assert(funcBwd(Date(2010, 1, 22)) == Date(2009, 12, 26));
assert(funcBwd(Date(2010, 1, 23)) == Date(2009, 12, 27));
assert(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))));
}
/++
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 $(CXREF time, 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.
+/
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
{
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);
}
unittest
{
{
auto funcFwd = everyDuration!Date(1, 2, AllowDayOverflow.yes, dur!"days"(3));
auto funcBwd = everyDuration!(Date, Direction.bwd)(1, 2, AllowDayOverflow.yes, dur!"days"(3));
assert(funcFwd(Date(2009, 12, 25)) == Date(2011, 2, 28));
assert(funcFwd(Date(2009, 12, 26)) == Date(2011, 3, 1));
assert(funcFwd(Date(2009, 12, 27)) == Date(2011, 3, 2));
assert(funcFwd(Date(2009, 12, 28)) == Date(2011, 3, 3));
assert(funcFwd(Date(2009, 12, 29)) == Date(2011, 3, 4));
assert(funcBwd(Date(2011, 2, 28)) == Date(2009, 12, 25));
assert(funcBwd(Date(2011, 3, 1)) == Date(2009, 12, 26));
assert(funcBwd(Date(2011, 3, 2)) == Date(2009, 12, 27));
assert(funcBwd(Date(2011, 3, 3)) == Date(2009, 12, 28));
assert(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));
assert(funcFwd(Date(2009, 12, 25)) == Date(2011, 2, 28));
assert(funcFwd(Date(2009, 12, 26)) == Date(2011, 3, 1));
assert(funcFwd(Date(2009, 12, 27)) == Date(2011, 3, 2));
assert(funcFwd(Date(2009, 12, 28)) == Date(2011, 3, 3));
assert(funcFwd(Date(2009, 12, 29)) == Date(2011, 3, 3));
assert(funcBwd(Date(2011, 2, 28)) == Date(2009, 12, 25));
assert(funcBwd(Date(2011, 3, 1)) == Date(2009, 12, 26));
assert(funcBwd(Date(2011, 3, 2)) == Date(2009, 12, 27));
assert(funcBwd(Date(2011, 3, 3)) == Date(2009, 12, 28));
assert(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))));
}
//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 $(LREF2 .Interval, Interval).
$(D IntervalRange) is only ever constructed by $(LREF2 .Interval, 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 $(LREF2 .Interval, Interval)'s $(D fwdRange)
where that function took a $(LREF Date) and returned a $(LREF Date) which was one
day later. That function would then be used by $(D IntervalRange)'s
$(D popFront) to iterate over the $(LREF 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
$(LREF 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
$(LREF 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
$(LREF2 .Interval, 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 $(LREF2 .Interval, 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;
}
/++ Ditto +/
ref IntervalRange opAssign(IntervalRange rhs) pure nothrow
{
return this = rhs;
}
/++
Whether this $(D IntervalRange) is empty.
+/
@property bool empty() const pure nothrow
{
return _interval.empty;
}
/++
The first time point in the range.
Throws:
$(LREF 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:
$(LREF 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:
$(LREF 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:
$(LREF DateTimeException) if $(D_PARAM newTP) is in the wrong
direction.
+/
void _enforceCorrectDirection(in TP newTP, size_t line = __LINE__) const
{
import std.format : format;
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
{
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
{
{
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
{
//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
{
//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));
assert(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);
assert(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));
assert(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);
assert(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
{
//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)
{
assert(date == expected);
expected += dur!"days"(7);
}
assert(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)
{
assert(date == expected);
expected += dur!"days"(-7);
}
assert(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
{
//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
{
//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
{
//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
{
//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 $(LREF Date) and
returned a $(LREF Date) which was one day later. That function would then be
used by $(D PosInfIntervalRange)'s $(D popFront) to iterate over the
$(LREF 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 $(LREF 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 $(LREF 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;
}
/++ Ditto +/
ref PosInfIntervalRange opAssign(PosInfIntervalRange rhs) pure nothrow
{
return this = rhs;
}
/++
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:
$(LREF 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:
$(LREF DateTimeException) if $(D_PARAME newTP) is in the wrong
direction.
+/
void _enforceCorrectDirection(in TP newTP, size_t line = __LINE__) const
{
import std.format : format;
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
{
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
{
{
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
{
auto range = PosInfInterval!Date(Date(2010, 7, 4)).fwdRange(everyDayOfWeek!Date(DayOfWeek.wed));
assert(range.front == Date(2010, 7, 4));
auto poppedRange = PosInfInterval!Date(Date(2010, 7, 4)).fwdRange(everyDayOfWeek!Date(DayOfWeek.wed), PopFirst.yes);
assert(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
{
import std.range;
auto range = PosInfInterval!Date(Date(2010, 7, 4)).fwdRange(everyDayOfWeek!Date(DayOfWeek.wed), PopFirst.yes);
auto expected = range.front;
foreach(date; take(range, 79))
{
assert(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
{
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
{
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
{
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 $(LREF Date) and
returned a $(LREF Date) which was one day earlier. That function would then be
used by $(D NegInfIntervalRange)'s $(D popFront) to iterate over the
$(LREF 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 $(LREF 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
$(LREF 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;
}
/++ Ditto +/
ref NegInfIntervalRange opAssign(NegInfIntervalRange rhs) pure nothrow
{
return this = rhs;
}
/++
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:
$(LREF 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:
$(LREF DateTimeException) if $(D_PARAM newTP) is in the wrong
direction.
+/
void _enforceCorrectDirection(in TP newTP, size_t line = __LINE__) const
{
import std.format : format;
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
{
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
{
{
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
{
auto range = NegInfInterval!Date(Date(2012, 1, 7)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.wed));
assert(range.front == Date(2012, 1, 7));
auto poppedRange = NegInfInterval!Date(Date(2012, 1, 7)).bwdRange(everyDayOfWeek!(Date, Direction.bwd)(DayOfWeek.wed), PopFirst.yes);
assert(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
{
import std.range;
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))
{
assert(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
{
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
{
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
{
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 $(LREF SysTime) to indicate the time
zone of a $(LREF SysTime).
+/
abstract class TimeZone
{
public:
/++
The name of the time zone per the TZ Database. This is the name used to
get a $(LREF2 .TimeZone, 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() @safe 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() @safe 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() @safe 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() @safe 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) @safe 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) @safe 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) @safe 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) @safe const nothrow
{
return dur!"hnsecs"(utcToTZ(stdTime) - stdTime);
}
/++
Returns a $(LREF2 .TimeZone, TimeZone) with the give name per the TZ Database.
This returns a $(LREF PosixTimeZone) on Posix systems and a
$(LREF WindowsTimeZone) on Windows systems. For
$(LREF 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:
$(LREF DateTimeException) if the given time zone could not be found.
Examples:
--------------------
auto tz = TimeZone.getTimeZone("America/Los_Angeles");
--------------------
+/
static immutable(TimeZone) getTimeZone(string name) @safe
{
version(Posix)
return PosixTimeZone.getTimeZone(name);
else version(Windows)
{
import std.format : format;
auto windowsTZName = tzDatabaseNameToWindowsTZName(name);
if(windowsTZName != null)
{
try
return WindowsTimeZone.getTimeZone(windowsTZName);
catch(DateTimeException dte)
{
auto oldName = _getOldName(windowsTZName);
if(oldName != null)
return WindowsTimeZone.getTimeZone(oldName);
throw dte;
}
}
else
throw new DateTimeException(format("%s does not have an equivalent Windows time zone.", name));
}
}
// The purpose of this is to handle the case where a Windows time zone is
// new and exists on an up-to-date Windows box but does not exist on Windows
// boxes which have not been properly updated. The "date added" is included
// on the theory that we'll be able to remove them at some point in the
// the future once enough time has passed, and that way, we know how much
// time has passed.
private static string _getOldName(string windowsTZName) @safe pure nothrow
{
switch(windowsTZName)
{
case "Belarus Standard Time": return "Kaliningrad Standard Time"; // Added 2014-10-08
case "Russia Time Zone 10": return "Magadan Standard Time"; // Added 2014-10-08
case "Russia Time Zone 11": return "Magadan Standard Time"; // Added 2014-10-08
case "Russia Time Zone 3": return "Russian Standard Time"; // Added 2014-10-08
default: return null;
}
}
//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.
unittest
{
import std.path : chainPath;
import std.file : exists, isFile;
import std.conv : to;
import std.format : format;
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)
assert(tz.name == tzName);
else version(Windows)
assert(tz.name == stdName);
//assert(tz.stdName == stdName); //Locale-dependent
//assert(tz.dstName == dstName); //Locale-dependent
assert(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);
assert(dst.dstInEffect == hasDST);
assert(tz.utcOffsetAt(std.stdTime) == utcOffset);
assert(tz.utcOffsetAt(dst.stdTime) == utcOffset + dstOffset);
assert(cast(DateTime)std == stdDate);
assert(cast(DateTime)dst == dstDate);
assert(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();
assert(ourTimeInfo.tm_sec == osTimeInfo.tm_sec);
assert(ourTimeInfo.tm_min == osTimeInfo.tm_min);
assert(ourTimeInfo.tm_hour == osTimeInfo.tm_hour);
assert(ourTimeInfo.tm_mday == osTimeInfo.tm_mday);
assert(ourTimeInfo.tm_mon == osTimeInfo.tm_mon);
assert(ourTimeInfo.tm_year == osTimeInfo.tm_year);
assert(ourTimeInfo.tm_wday == osTimeInfo.tm_wday);
assert(ourTimeInfo.tm_yday == osTimeInfo.tm_yday);
assert(ourTimeInfo.tm_isdst == osTimeInfo.tm_isdst);
assert(ourTimeInfo.tm_gmtoff == osTimeInfo.tm_gmtoff);
assert(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 (chainPath(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);
assert(leapSTD.stdTime == std.stdTime);
assert(leapDST.stdTime == dst.stdTime);
//Whenever a leap second is added/removed,
//this will have to be adjusted.
//enum leapDiff = convert!("seconds", "hnsecs")(25);
//assert(leapSTD.adjTime - leapDiff == std.adjTime);
//assert(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";
else version(linux) enum utcZone = "UTC";
else version(OSX) enum utcZone = "UTC";
else static assert(0, "The location of the UTC timezone file on this Posix platform must be set.");
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.
$(LREF DateTimeException) on Windows systems if it fails to read the
registry.
+/
static string[] getInstalledTZNames(string subName = "") @safe
{
version(Posix)
return PosixTimeZone.getInstalledTZNames(subName);
else version(Windows)
{
import std.array : appender;
import std.algorithm : startsWith, sort;
import std.format : format;
auto windowsNames = WindowsTimeZone.getInstalledTZNames();
auto retval = appender!(string[])();
foreach(winName; windowsNames)
{
auto tzName = windowsTZNameToTZDatabaseName(winName);
version(unittest)
{
import std.string;
assert(tzName !is null, format("TZName which is missing: %s", winName));
}
if(tzName !is null && tzName.startsWith(subName))
retval.put(tzName);
}
sort(retval.data);
return retval.data;
}
}
unittest
{
static void testPZSuccess(string tzName)
{
scope(failure) writefln("TZName which threw: %s", tzName);
TimeZone.getTimeZone(tzName);
}
auto tzNames = getInstalledTZNames();
// This was not previously tested, and it's currently failing, so I'm
// leaving it commented out until I can sort it out.
//assert(equal(tzNames, tzNames.uniq()));
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) @safe 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
$(LREF PosixTimeZone) and $(LREF 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:
/++
$(LREF LocalTime) is a singleton class. $(LREF LocalTime) returns its only
instance.
+/
static immutable(LocalTime) opCall() @trusted pure nothrow
{
alias FuncType = @safe pure nothrow immutable(LocalTime) function();
return (cast(FuncType)&singleton)();
}
version(StdDdoc)
{
/++
The name of the time zone per the TZ Database. This is the name used to
get a $(LREF2 .TimeZone, 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() @safe 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() @trusted const nothrow
{
version(Posix)
{
import std.conv : to;
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
{
assert(LocalTime().stdName !is null);
version(Posix)
{
scope(exit) clearTZEnvVar();
setTZEnvVar("America/Los_Angeles");
assert(LocalTime().stdName == "PST");
setTZEnvVar("America/New_York");
assert(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() @trusted const nothrow
{
version(Posix)
{
import std.conv : to;
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
{
assert(LocalTime().dstName !is null);
version(Posix)
{
scope(exit) clearTZEnvVar();
version(FreeBSD)
{
// A bug on FreeBSD 9+ makes it so that this test fails.
// https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=168862
}
else
{
setTZEnvVar("America/Los_Angeles");
assert(LocalTime().dstName == "PDT");
}
setTZEnvVar("America/New_York");
assert(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() @trusted 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), cast(immutable)this).stdTime -
SysTime(Date(currYear, 1, 4), UTC()).stdTime;
auto julyOffset = SysTime(Date(currYear, 7, 4), cast(immutable)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
{
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) @trusted 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
{
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) @trusted 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
{
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) @trusted 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
{
import std.format : format;
assert(LocalTime().tzToUTC(LocalTime().utcToTZ(0)) == 0);
assert(LocalTime().utcToTZ(LocalTime().tzToUTC(0)) == 0);
assert(LocalTime().tzToUTC(LocalTime().utcToTZ(0)) == 0);
assert(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() @safe immutable pure
{
super("", "", "");
}
// This is done so that we can maintain purity in spite of doing an impure
// operation the first time that LocalTime() is called.
static immutable(LocalTime) singleton() @trusted
{
import std.concurrency : initOnce;
static instance = new immutable(LocalTime)();
static shared bool guard;
initOnce!guard({tzset(); return true;}());
return instance;
}
}
/++
A $(LREF2 .TimeZone, 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() @safe pure nothrow
{
return _utc;
}
/++
Always returns false.
+/
@property override bool hasDST() @safe const nothrow
{
return false;
}
/++
Always returns false.
+/
override bool dstInEffect(long stdTime) @safe 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) @safe const nothrow
{
return stdTime;
}
unittest
{
assert(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));
assert(UTC().utcToTZ(std.stdTime) == std.stdTime);
assert(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) @safe const nothrow
{
return adjTime;
}
unittest
{
assert(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));
assert(UTC().tzToUTC(std.stdTime) == std.stdTime);
assert(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) @safe const nothrow
{
return dur!"hnsecs"(0);
}
private:
this() @safe immutable pure
{
super("UTC", "UTC", "UTC");
}
static immutable UTC _utc = new immutable(UTC)();
}
/++
Represents a time zone with an offset (in minutes, west is negative) from
UTC but no DST.
It's primarily used as the time zone in the result of $(LREF 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() @safe const nothrow
{
return false;
}
/++
Always returns false.
+/
override bool dstInEffect(long stdTime) @safe 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) @safe const nothrow
{
return stdTime + _utcOffset.total!"hnsecs";
}
unittest
{
auto west = new immutable SimpleTimeZone(dur!"hours"(-8));
auto east = new immutable 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) @safe const nothrow
{
return adjTime - _utcOffset.total!"hnsecs";
}
unittest
{
auto west = new immutable SimpleTimeZone(dur!"hours"(-8));
auto east = new immutable 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) @safe const nothrow
{
return _utcOffset;
}
/++
Params:
utcOffset = This time zone's offset from UTC 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 = "") @safe immutable pure
{
//FIXME This probably needs to be changed to something like (-12 - 13).
enforce!DateTimeException(abs(utcOffset) < dur!"minutes"(1440),
"Offset from UTC must be within range (-24:00 - 24:00).");
super("", stdName, "");
this._utcOffset = utcOffset;
}
/++
$(RED Deprecated. Please use the overload which takes a Duration. This
overload will be removed in December 2014).
Params:
utcOffset = This time zone's offset from UTC in minutes with west of
negative (it is added to UTC to get the adjusted time).
stdName = The $(D stdName) for this time zone.
+/
deprecated("Please use the overload which takes a Duration.")
this(int utcOffset, string stdName = "") @safe immutable pure
{
this(dur!"minutes"(utcOffset), stdName);
}
unittest
{
auto stz = new immutable SimpleTimeZone(dur!"hours"(-8), "PST");
assert(stz.name == "");
assert(stz.stdName == "PST");
assert(stz.dstName == "");
assert(stz.utcOffset == dur!"hours"(-8));
}
/++
The amount of time the offset from UTC is (negative is west of UTC,
positive is east).
+/
@property Duration utcOffset() @safe const pure nothrow
{
return _utcOffset;
}
private:
/+
Returns a time zone as a string with an offset from UTC.
Time zone offsets will be in the form +HH:MM or -HH:MM.
Params:
utcOffset = The number of minutes offset from UTC (negative means
west).
+/
static string toISOString(Duration utcOffset) @safe pure
{
import std.format : format;
immutable absOffset = abs(utcOffset);
enforce!DateTimeException(absOffset < dur!"minutes"(1440),
"Offset from UTC must be within range (-24:00 - 24:00).");
int hours;
int minutes;
absOffset.split!("hours", "minutes")(hours, minutes);
return format(utcOffset < Duration.zero ? "-%02d:%02d" : "+%02d:%02d", hours, minutes);
}
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) @safe pure
if(isSomeString!S)
{
import std.ascii : isDigit;
import std.string : strip;
import std.conv : to;
import std.algorithm : startsWith, countUntil, all;
import std.format : format;
auto dstr = to!dstring(strip(isoString));
enforce(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.countUntil(':');
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(all!isDigit(hoursStr), new DateTimeException(format("Invalid ISO String: %s", dstr)));
enforce(all!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 immutable SimpleTimeZone(sign * (dur!"hours"(hours) + dur!"minutes"(minutes)));
}
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 immutable SimpleTimeZone(dur!"minutes"(0))).utcOffset);
assert(SimpleTimeZone.fromISOString("+00:01").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(1))).utcOffset);
assert(SimpleTimeZone.fromISOString("+00:10").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(10))).utcOffset);
assert(SimpleTimeZone.fromISOString("+00:59").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(59))).utcOffset);
assert(SimpleTimeZone.fromISOString("+01:00").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(60))).utcOffset);
assert(SimpleTimeZone.fromISOString("+01:30").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(90))).utcOffset);
assert(SimpleTimeZone.fromISOString("+02:00").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(120))).utcOffset);
assert(SimpleTimeZone.fromISOString("+08:00").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(480))).utcOffset);
assert(SimpleTimeZone.fromISOString("+23:59").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(1439))).utcOffset);
assert(SimpleTimeZone.fromISOString("-00:01").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(-1))).utcOffset);
assert(SimpleTimeZone.fromISOString("-00:10").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(-10))).utcOffset);
assert(SimpleTimeZone.fromISOString("-00:59").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(-59))).utcOffset);
assert(SimpleTimeZone.fromISOString("-01:00").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(-60))).utcOffset);
assert(SimpleTimeZone.fromISOString("-01:30").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(-90))).utcOffset);
assert(SimpleTimeZone.fromISOString("-02:00").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(-120))).utcOffset);
assert(SimpleTimeZone.fromISOString("-08:00").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(-480))).utcOffset);
assert(SimpleTimeZone.fromISOString("-23:59").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(-1439))).utcOffset);
assert(SimpleTimeZone.fromISOString("+0").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(0))).utcOffset);
assert(SimpleTimeZone.fromISOString("+1").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(60))).utcOffset);
assert(SimpleTimeZone.fromISOString("+2").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(120))).utcOffset);
assert(SimpleTimeZone.fromISOString("+23").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(1380))).utcOffset);
assert(SimpleTimeZone.fromISOString("+2").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(120))).utcOffset);
assert(SimpleTimeZone.fromISOString("+0").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(0))).utcOffset);
assert(SimpleTimeZone.fromISOString("+1").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(60))).utcOffset);
assert(SimpleTimeZone.fromISOString("+2").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(120))).utcOffset);
assert(SimpleTimeZone.fromISOString("+23").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(1380))).utcOffset);
assert(SimpleTimeZone.fromISOString("+1:00").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(60))).utcOffset);
assert(SimpleTimeZone.fromISOString("+1:01").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(61))).utcOffset);
assert(SimpleTimeZone.fromISOString("-0").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(0))).utcOffset);
assert(SimpleTimeZone.fromISOString("-1").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(-60))).utcOffset);
assert(SimpleTimeZone.fromISOString("-2").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(-120))).utcOffset);
assert(SimpleTimeZone.fromISOString("-23").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(-1380))).utcOffset);
assert(SimpleTimeZone.fromISOString("-1:00").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(-60))).utcOffset);
assert(SimpleTimeZone.fromISOString("-1:01").utcOffset ==
(new immutable SimpleTimeZone(dur!"minutes"(-61))).utcOffset);
}
//Test that converting from an ISO string to a SimpleTimeZone to an ISO String works properly.
unittest
{
static void testSTZ(in string isoString, int expectedOffset, size_t line = __LINE__)
{
auto stz = SimpleTimeZone.fromISOString(isoString);
assert(stz.utcOffset == dur!"minutes"(expectedOffset));
auto result = SimpleTimeZone.toISOString(stz.utcOffset);
assert(result == isoString);
}
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 $(D 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 $(LREF 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 $(LREF PosixTimeZone) with a
time zone whose name starts with "right/". Those time zone files do
include leap seconds, and $(LREF 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
{
import std.stdio : File;
import std.path : extension;
import std.file : isDir, isFile, exists, dirEntries, SpanMode, DirEntry;
import std.string : strip, representation;
import std.algorithm : countUntil, canFind, startsWith;
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() @safe 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) @safe const nothrow
{
assert(!_transitions.empty);
immutable unixTime = stdTimeToUnixTime(stdTime);
immutable found = countUntil!"b < a.timeT"(_transitions, unixTime);
if(found == -1)
return _transitions.back.ttInfo.isDST;
immutable transition = found == 0 ? _transitions[0] : _transitions[found - 1];
return transition.ttInfo.isDST;
}
/++
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) @safe const nothrow
{
assert(!_transitions.empty);
immutable leapSecs = calculateLeapSeconds(stdTime);
immutable unixTime = stdTimeToUnixTime(stdTime);
immutable found = countUntil!"b < a.timeT"(_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);
}
/++
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) @safe const nothrow
{
assert(!_transitions.empty);
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"(_transitions, past);
if(pastFound == -1)
return adjTime - convert!("seconds", "hnsecs")(_transitions.back.ttInfo.utcOffset + leapSecs);
immutable futureFound = countUntil!"b < a.timeT"(_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"(_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);
}
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 $(LREF2 .TimeZone, 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 $(LREF PosixTimeZone)s.
Throws:
$(LREF 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) @trusted
{
import std.algorithm : sort;
import std.range : retro;
import std.format : format;
import std.path : toNormalizedPath, chainPath;
import std.conv : to;
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)));
const file = toNormalizedPath(chainPath(tzDatabaseDir, name)).to!string;
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.representation().canFind("GMT");
try
{
_enforceValidTZFile(readVal!(char[])(tzFile, 4) == "TZif");
immutable char tzFileVersion = readVal!char(tzFile);
_enforceValidTZFile(tzFileVersion == '\0' || tzFileVersion == '2' || tzFileVersion == '3');
{
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 or 3, the information is duplicated in 64-bit.
if(tzFileVersion == '2' || tzFileVersion == '3')
{
_enforceValidTZFile(readVal!(char[])(tzFile, 4) == "TZif");
immutable char tzFileVersion2 = readVal!(char)(tzFile);
_enforceValidTZFile(tzFileVersion2 == '2' || tzFileVersion2 == '3');
{
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.countUntil('\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 immutable 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.
tzDatabaseDir = The directory where the TZ Database files are
located.
Throws:
$(D FileException) if it fails to read from disk.
+/
static string[] getInstalledTZNames(string subName = "", string tzDatabaseDir = defaultTZDatabaseDir) @trusted
{
import std.array : appender;
import std.algorithm : sort;
import std.format : format;
version(Posix)
subName = strip(subName);
else version(Windows)
{
import std.array : replace;
import std.path : dirSeparator;
subName = replace(strip(subName), "/", 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;
}
version(Posix) unittest
{
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 past the transition.
+/
struct Transition
{
this(long timeT, immutable (TTInfo)* ttInfo) @safe pure
{
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) @safe pure
{
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) @safe immutable pure
{
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) @safe pure
{
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) @safe pure
{
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) @safe pure
{
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) @trusted
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) @trusted
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) @safe
if(is(T == TempTTInfo))
{
return TempTTInfo(readVal!int(tzFile),
readVal!bool(tzFile),
readVal!ubyte(tzFile));
}
/+
Throws:
$(LREF DateTimeException) if $(D result) is false.
+/
static void _enforceValidTZFile(bool result, size_t line = __LINE__) @safe pure
{
if(!result)
throw new DateTimeException("Not a valid tzdata file.", __FILE__, line);
}
int calculateLeapSeconds(long stdTime) @safe const pure nothrow
{
if(_leapSeconds.empty)
return 0;
immutable unixTime = stdTimeToUnixTime(stdTime);
if(_leapSeconds.front.timeT >= unixTime)
return 0;
immutable found = countUntil!"b < a.timeT"(_leapSeconds, unixTime);
if(found == -1)
return _leapSeconds.back.total;
immutable leapSecond = found == 0 ? _leapSeconds[0] : _leapSeconds[found - 1];
return leapSecond.total;
}
this(immutable Transition[] transitions,
immutable LeapSecond[] leapSeconds,
string name,
string stdName,
string dstName,
bool hasDST) @safe immutable pure
{
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 $(LREF WindowsTimeZone). However, because
$(LREF 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.
$(LREF WindowsTimeZone) does not exist on Posix systems.
To get a $(LREF WindowsTimeZone), either call
$(D WindowsTimeZone.getTimeZone) or call $(D TimeZone.getTimeZone)
(which will give a $(LREF PosixTimeZone) on Posix systems and a
$(LREF 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() @safe 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) @safe 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) @safe 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) @safe const nothrow;
/++
Returns a $(LREF2 .TimeZone, 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:
$(LREF DateTimeException) if the given time zone could not be
found.
Examples:
--------------------
auto tz = TimeZone.getTimeZone("America/Los_Angeles");
--------------------
+/
static immutable(WindowsTimeZone) getTimeZone(string name) @safe;
/++
Returns a list of the names of the time zones installed on the
system. The list returned by WindowsTimeZone contains the Windows
TZ names, not the TZ Database names. However,
$(D TimeZone.getinstalledTZNames) will return the TZ Database names
which are equivalent to the Windows TZ names.
+/
static string[] getInstalledTZNames() @safe;
private:
version(Windows) {}
else
alias TIME_ZONE_INFORMATION = void*;
static bool _dstInEffect(const TIME_ZONE_INFORMATION* tzInfo, long stdTime) nothrow;
static long _utcToTZ(const TIME_ZONE_INFORMATION* tzInfo, long stdTime, bool hasDST) nothrow;
static long _tzToUTC(const TIME_ZONE_INFORMATION* tzInfo, long adjTime, bool hasDST) nothrow;
this() immutable pure
{
super("", "", "");
}
}
}
else version(Windows)
{
final class WindowsTimeZone : TimeZone
{
import std.format : format;
import std.conv : to;
import std.algorithm : sort;
import std.array : appender;
public:
@property override bool hasDST() @safe const nothrow
{
return _tzInfo.DaylightDate.wMonth != 0;
}
override bool dstInEffect(long stdTime) @safe const nothrow
{
return _dstInEffect(&_tzInfo, stdTime);
}
override long utcToTZ(long stdTime) @safe const nothrow
{
return _utcToTZ(&_tzInfo, stdTime, hasDST);
}
override long tzToUTC(long adjTime) @safe const nothrow
{
return _tzToUTC(&_tzInfo, adjTime, hasDST);
}
static immutable(WindowsTimeZone) getTimeZone(string name) @trusted
{
import std.utf : toUTF16;
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 immutable WindowsTimeZone(name, tzInfo);
}
throw new DateTimeException(format("Failed to find time zone: %s", name));
}
static string[] getInstalledTZNames() @trusted
{
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
{
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) @trusted 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.");
}
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) @safe 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) @trusted 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) @safe immutable pure
{
super(name, to!string(tzInfo.StandardName.ptr), to!string(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) @safe nothrow;
/++
$(BLUE This function is Posix-Only.)
Clears the TZ environment variable.
+/
void clearTZEnvVar() @safe nothrow;
}
else version(Posix)
{
void setTZEnvVar(string tzDatabaseName) @trusted nothrow
{
import std.internal.cstring : tempCString;
import std.path : toNormalizedPath, chainPath;
import core.sys.posix.stdlib : setenv;
import core.sys.posix.time : tzset;
auto value = toNormalizedPath(chainPath(PosixTimeZone.defaultTZDatabaseDir, tzDatabaseName));
setenv("TZ", value.tempCString(), 1);
tzset();
}
void clearTZEnvVar() @trusted nothrow
{
import core.sys.posix.stdlib : unsetenv;
import core.sys.posix.time : tzset;
unsetenv("TZ");
tzset();
}
}
/++
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.
Returns null if the given time zone name cannot be converted.
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.
+/
string tzDatabaseNameToWindowsTZName(string tzName) @safe pure nothrow @nogc
{
switch(tzName)
{
case "Africa/Abidjan": return "Greenwich Standard Time";
case "Africa/Accra": return "Greenwich Standard Time";
case "Africa/Addis_Ababa": return "E. Africa Standard Time";
case "Africa/Algiers": return "W. Central Africa Standard Time";
case "Africa/Asmera": return "E. Africa Standard Time";
case "Africa/Bamako": return "Greenwich Standard Time";
case "Africa/Bangui": return "W. Central Africa Standard Time";
case "Africa/Banjul": return "Greenwich Standard Time";
case "Africa/Bissau": return "Greenwich Standard Time";
case "Africa/Blantyre": return "South Africa Standard Time";
case "Africa/Brazzaville": return "W. Central Africa Standard Time";
case "Africa/Bujumbura": return "South Africa Standard Time";
case "Africa/Cairo": return "Egypt Standard Time";
case "Africa/Casablanca": return "Morocco Standard Time";
case "Africa/Ceuta": return "Romance Standard Time";
case "Africa/Conakry": return "Greenwich Standard Time";
case "Africa/Dakar": return "Greenwich Standard Time";
case "Africa/Dar_es_Salaam": return "E. Africa Standard Time";
case "Africa/Djibouti": return "E. Africa Standard Time";
case "Africa/Douala": return "W. Central Africa Standard Time";
case "Africa/El_Aaiun": return "Morocco Standard Time";
case "Africa/Freetown": return "Greenwich Standard Time";
case "Africa/Gaborone": return "South Africa Standard Time";
case "Africa/Harare": return "South Africa Standard Time";
case "Africa/Johannesburg": return "South Africa Standard Time";
case "Africa/Juba": return "E. Africa Standard Time";
case "Africa/Kampala": return "E. Africa Standard Time";
case "Africa/Khartoum": return "E. Africa Standard Time";
case "Africa/Kigali": return "South Africa Standard Time";
case "Africa/Kinshasa": return "W. Central Africa Standard Time";
case "Africa/Lagos": return "W. Central Africa Standard Time";
case "Africa/Libreville": return "W. Central Africa Standard Time";
case "Africa/Lome": return "Greenwich Standard Time";
case "Africa/Luanda": return "W. Central Africa Standard Time";
case "Africa/Lubumbashi": return "South Africa Standard Time";
case "Africa/Lusaka": return "South Africa Standard Time";
case "Africa/Malabo": return "W. Central Africa Standard Time";
case "Africa/Maputo": return "South Africa Standard Time";
case "Africa/Maseru": return "South Africa Standard Time";
case "Africa/Mbabane": return "South Africa Standard Time";
case "Africa/Mogadishu": return "E. Africa Standard Time";
case "Africa/Monrovia": return "Greenwich Standard Time";
case "Africa/Nairobi": return "E. Africa Standard Time";
case "Africa/Ndjamena": return "W. Central Africa Standard Time";
case "Africa/Niamey": return "W. Central Africa Standard Time";
case "Africa/Nouakchott": return "Greenwich Standard Time";
case "Africa/Ouagadougou": return "Greenwich Standard Time";
case "Africa/Porto-Novo": return "W. Central Africa Standard Time";
case "Africa/Sao_Tome": return "Greenwich Standard Time";
case "Africa/Tripoli": return "Libya Standard Time";
case "Africa/Tunis": return "W. Central Africa Standard Time";
case "Africa/Windhoek": return "Namibia Standard Time";
case "America/Anchorage": return "Alaskan Standard Time";
case "America/Anguilla": return "SA Western Standard Time";
case "America/Antigua": return "SA Western Standard Time";
case "America/Araguaina": return "SA Eastern Standard Time";
case "America/Argentina/La_Rioja": return "Argentina Standard Time";
case "America/Argentina/Rio_Gallegos": return "Argentina Standard Time";
case "America/Argentina/Salta": return "Argentina Standard Time";
case "America/Argentina/San_Juan": return "Argentina Standard Time";
case "America/Argentina/San_Luis": return "Argentina Standard Time";
case "America/Argentina/Tucuman": return "Argentina Standard Time";
case "America/Argentina/Ushuaia": return "Argentina Standard Time";
case "America/Aruba": return "SA Western Standard Time";
case "America/Asuncion": return "Paraguay Standard Time";
case "America/Bahia": return "Bahia Standard Time";
case "America/Bahia_Banderas": return "Central Standard Time (Mexico)";
case "America/Barbados": return "SA Western Standard Time";
case "America/Belem": return "SA Eastern Standard Time";
case "America/Belize": return "Central America Standard Time";
case "America/Blanc-Sablon": return "SA Western Standard Time";
case "America/Boa_Vista": return "SA Western Standard Time";
case "America/Bogota": return "SA Pacific Standard Time";
case "America/Boise": return "Mountain Standard Time";
case "America/Buenos_Aires": return "Argentina Standard Time";
case "America/Cambridge_Bay": return "Mountain Standard Time";
case "America/Campo_Grande": return "Central Brazilian Standard Time";
case "America/Cancun": return "Central Standard Time (Mexico)";
case "America/Caracas": return "Venezuela Standard Time";
case "America/Catamarca": return "Argentina Standard Time";
case "America/Cayenne": return "SA Eastern Standard Time";
case "America/Cayman": return "SA Pacific Standard Time";
case "America/Chicago": return "Central Standard Time";
case "America/Chihuahua": return "Mountain Standard Time (Mexico)";
case "America/Coral_Harbour": return "SA Pacific Standard Time";
case "America/Cordoba": return "Argentina Standard Time";
case "America/Costa_Rica": return "Central America Standard Time";
case "America/Creston": return "US Mountain Standard Time";
case "America/Cuiaba": return "Central Brazilian Standard Time";
case "America/Curacao": return "SA Western Standard Time";
case "America/Danmarkshavn": return "UTC";
case "America/Dawson": return "Pacific Standard Time";
case "America/Dawson_Creek": return "US Mountain Standard Time";
case "America/Denver": return "Mountain Standard Time";
case "America/Detroit": return "Eastern Standard Time";
case "America/Dominica": return "SA Western Standard Time";
case "America/Edmonton": return "Mountain Standard Time";
case "America/Eirunepe": return "SA Pacific Standard Time";
case "America/El_Salvador": return "Central America Standard Time";
case "America/Fortaleza": return "SA Eastern Standard Time";
case "America/Glace_Bay": return "Atlantic Standard Time";
case "America/Godthab": return "Greenland Standard Time";
case "America/Goose_Bay": return "Atlantic Standard Time";
case "America/Grand_Turk": return "SA Western Standard Time";
case "America/Grenada": return "SA Western Standard Time";
case "America/Guadeloupe": return "SA Western Standard Time";
case "America/Guatemala": return "Central America Standard Time";
case "America/Guayaquil": return "SA Pacific Standard Time";
case "America/Guyana": return "SA Western Standard Time";
case "America/Halifax": return "Atlantic Standard Time";
case "America/Havana": return "Eastern Standard Time";
case "America/Hermosillo": return "US Mountain Standard Time";
case "America/Indiana/Knox": return "Central Standard Time";
case "America/Indiana/Marengo": return "US Eastern Standard Time";
case "America/Indiana/Petersburg": return "Eastern Standard Time";
case "America/Indiana/Tell_City": return "Central Standard Time";
case "America/Indiana/Vevay": return "US Eastern Standard Time";
case "America/Indiana/Vincennes": return "Eastern Standard Time";
case "America/Indiana/Winamac": return "Eastern Standard Time";
case "America/Indianapolis": return "US Eastern Standard Time";
case "America/Inuvik": return "Mountain Standard Time";
case "America/Iqaluit": return "Eastern Standard Time";
case "America/Jamaica": return "SA Pacific Standard Time";
case "America/Jujuy": return "Argentina Standard Time";
case "America/Juneau": return "Alaskan Standard Time";
case "America/Kentucky/Monticello": return "Eastern Standard Time";
case "America/Kralendijk": return "SA Western Standard Time";
case "America/La_Paz": return "SA Western Standard Time";
case "America/Lima": return "SA Pacific Standard Time";
case "America/Los_Angeles": return "Pacific Standard Time";
case "America/Louisville": return "Eastern Standard Time";
case "America/Lower_Princes": return "SA Western Standard Time";
case "America/Maceio": return "SA Eastern Standard Time";
case "America/Managua": return "Central America Standard Time";
case "America/Manaus": return "SA Western Standard Time";
case "America/Marigot": return "SA Western Standard Time";
case "America/Martinique": return "SA Western Standard Time";
case "America/Matamoros": return "Central Standard Time";
case "America/Mazatlan": return "Mountain Standard Time (Mexico)";
case "America/Mendoza": return "Argentina Standard Time";
case "America/Menominee": return "Central Standard Time";
case "America/Merida": return "Central Standard Time (Mexico)";
case "America/Mexico_City": return "Central Standard Time (Mexico)";
case "America/Moncton": return "Atlantic Standard Time";
case "America/Monterrey": return "Central Standard Time (Mexico)";
case "America/Montevideo": return "Montevideo Standard Time";
case "America/Montreal": return "Eastern Standard Time";
case "America/Montserrat": return "SA Western Standard Time";
case "America/Nassau": return "Eastern Standard Time";
case "America/New_York": return "Eastern Standard Time";
case "America/Nipigon": return "Eastern Standard Time";
case "America/Nome": return "Alaskan Standard Time";
case "America/Noronha": return "UTC-02";
case "America/North_Dakota/Beulah": return "Central Standard Time";
case "America/North_Dakota/Center": return "Central Standard Time";
case "America/North_Dakota/New_Salem": return "Central Standard Time";
case "America/Ojinaga": return "Mountain Standard Time";
case "America/Panama": return "SA Pacific Standard Time";
case "America/Pangnirtung": return "Eastern Standard Time";
case "America/Paramaribo": return "SA Eastern Standard Time";
case "America/Phoenix": return "US Mountain Standard Time";
case "America/Port-au-Prince": return "Eastern Standard Time";
case "America/Port_of_Spain": return "SA Western Standard Time";
case "America/Porto_Velho": return "SA Western Standard Time";
case "America/Puerto_Rico": return "SA Western Standard Time";
case "America/Rainy_River": return "Central Standard Time";
case "America/Rankin_Inlet": return "Central Standard Time";
case "America/Recife": return "SA Eastern Standard Time";
case "America/Regina": return "Canada Central Standard Time";
case "America/Resolute": return "Central Standard Time";
case "America/Rio_Branco": return "SA Pacific Standard Time";
case "America/Santa_Isabel": return "Pacific Standard Time (Mexico)";
case "America/Santarem": return "SA Eastern Standard Time";
case "America/Santiago": return "Pacific SA Standard Time";
case "America/Santo_Domingo": return "SA Western Standard Time";
case "America/Sao_Paulo": return "E. South America Standard Time";
case "America/Scoresbysund": return "Azores Standard Time";
case "America/Sitka": return "Alaskan Standard Time";
case "America/St_Barthelemy": return "SA Western Standard Time";
case "America/St_Johns": return "Newfoundland Standard Time";
case "America/St_Kitts": return "SA Western Standard Time";
case "America/St_Lucia": return "SA Western Standard Time";
case "America/St_Thomas": return "SA Western Standard Time";
case "America/St_Vincent": return "SA Western Standard Time";
case "America/Swift_Current": return "Canada Central Standard Time";
case "America/Tegucigalpa": return "Central America Standard Time";
case "America/Thule": return "Atlantic Standard Time";
case "America/Thunder_Bay": return "Eastern Standard Time";
case "America/Tijuana": return "Pacific Standard Time";
case "America/Toronto": return "Eastern Standard Time";
case "America/Tortola": return "SA Western Standard Time";
case "America/Vancouver": return "Pacific Standard Time";
case "America/Whitehorse": return "Pacific Standard Time";
case "America/Winnipeg": return "Central Standard Time";
case "America/Yakutat": return "Alaskan Standard Time";
case "America/Yellowknife": return "Mountain Standard Time";
case "Antarctica/Casey": return "W. Australia Standard Time";
case "Antarctica/Davis": return "SE Asia Standard Time";
case "Antarctica/DumontDUrville": return "West Pacific Standard Time";
case "Antarctica/Macquarie": return "Central Pacific Standard Time";
case "Antarctica/Mawson": return "West Asia Standard Time";
case "Antarctica/McMurdo": return "New Zealand Standard Time";
case "Antarctica/Palmer": return "Pacific SA Standard Time";
case "Antarctica/Rothera": return "SA Eastern Standard Time";
case "Antarctica/Syowa": return "E. Africa Standard Time";
case "Antarctica/Vostok": return "Central Asia Standard Time";
case "Arctic/Longyearbyen": return "W. Europe Standard Time";
case "Asia/Aden": return "Arab Standard Time";
case "Asia/Almaty": return "Central Asia Standard Time";
case "Asia/Amman": return "Jordan Standard Time";
case "Asia/Anadyr": return "Russia Time Zone 11";
case "Asia/Aqtau": return "West Asia Standard Time";
case "Asia/Aqtobe": return "West Asia Standard Time";
case "Asia/Ashgabat": return "West Asia Standard Time";
case "Asia/Baghdad": return "Arabic Standard Time";
case "Asia/Bahrain": return "Arab 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/Bishkek": return "Central Asia Standard Time";
case "Asia/Brunei": return "Singapore Standard Time";
case "Asia/Calcutta": return "India Standard Time";
case "Asia/Chita": return "North Asia East Standard Time";
case "Asia/Choibalsan": return "Ulaanbaatar 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/Dili": return "Tokyo Standard Time";
case "Asia/Dubai": return "Arabian Standard Time";
case "Asia/Dushanbe": return "West Asia Standard Time";
case "Asia/Hong_Kong": return "China Standard Time";
case "Asia/Hovd": return "SE Asia Standard Time";
case "Asia/Irkutsk": return "North Asia East Standard Time";
case "Asia/Jakarta": return "SE Asia Standard Time";
case "Asia/Jayapura": return "Tokyo Standard Time";
case "Asia/Jerusalem": return "Israel Standard Time";
case "Asia/Kabul": return "Afghanistan Standard Time";
case "Asia/Kamchatka": return "Russia Time Zone 11";
case "Asia/Karachi": return "Pakistan Standard Time";
case "Asia/Katmandu": return "Nepal Standard Time";
case "Asia/Khandyga": return "Yakutsk Standard Time";
case "Asia/Krasnoyarsk": return "North Asia Standard Time";
case "Asia/Kuala_Lumpur": return "Singapore Standard Time";
case "Asia/Kuching": return "Singapore Standard Time";
case "Asia/Kuwait": return "Arab Standard Time";
case "Asia/Macau": return "China Standard Time";
case "Asia/Magadan": return "Magadan Standard Time";
case "Asia/Makassar": return "Singapore Standard Time";
case "Asia/Manila": return "Singapore Standard Time";
case "Asia/Muscat": return "Arabian Standard Time";
case "Asia/Nicosia": return "GTB Standard Time";
case "Asia/Novokuznetsk": return "North Asia Standard Time";
case "Asia/Novosibirsk": return "N. Central Asia Standard Time";
case "Asia/Omsk": return "N. Central Asia Standard Time";
case "Asia/Oral": return "West Asia Standard Time";
case "Asia/Phnom_Penh": return "SE Asia Standard Time";
case "Asia/Pontianak": return "SE Asia Standard Time";
case "Asia/Pyongyang": return "Korea Standard Time";
case "Asia/Qatar": return "Arab Standard Time";
case "Asia/Qyzylorda": return "Central Asia Standard Time";
case "Asia/Rangoon": return "Myanmar Standard Time";
case "Asia/Riyadh": return "Arab Standard Time";
case "Asia/Saigon": return "SE Asia Standard Time";
case "Asia/Sakhalin": return "Vladivostok Standard Time";
case "Asia/Samarkand": return "West Asia 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/Srednekolymsk": return "Russia Time Zone 10";
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/Thimphu": return "Bangladesh Standard Time";
case "Asia/Tokyo": return "Tokyo Standard Time";
case "Asia/Ulaanbaatar": return "Ulaanbaatar Standard Time";
case "Asia/Urumqi": return "Central Asia Standard Time";
case "Asia/Ust-Nera": return "Vladivostok Standard Time";
case "Asia/Vientiane": return "SE Asia 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/Bermuda": return "Atlantic Standard Time";
case "Atlantic/Canary": return "GMT Standard Time";
case "Atlantic/Cape_Verde": return "Cape Verde Standard Time";
case "Atlantic/Faeroe": return "GMT Standard Time";
case "Atlantic/Madeira": return "GMT Standard Time";
case "Atlantic/Reykjavik": return "Greenwich Standard Time";
case "Atlantic/South_Georgia": return "UTC-02";
case "Atlantic/St_Helena": return "Greenwich Standard Time";
case "Atlantic/Stanley": return "SA Eastern Standard Time";
case "Australia/Adelaide": return "Cen. Australia Standard Time";
case "Australia/Brisbane": return "E. Australia Standard Time";
case "Australia/Broken_Hill": return "Cen. Australia Standard Time";
case "Australia/Currie": return "Tasmania Standard Time";
case "Australia/Darwin": return "AUS Central Standard Time";
case "Australia/Hobart": return "Tasmania Standard Time";
case "Australia/Lindeman": return "E. Australia Standard Time";
case "Australia/Melbourne": return "AUS Eastern Standard Time";
case "Australia/Perth": return "W. Australia Standard Time";
case "Australia/Sydney": return "AUS Eastern Standard Time";
case "CST6CDT": return "Central Standard Time";
case "EST5EDT": return "Eastern Standard Time";
case "Etc/GMT": return "UTC";
case "Etc/GMT+1": return "Cape Verde Standard Time";
case "Etc/GMT+10": return "Hawaiian Standard Time";
case "Etc/GMT+11": return "UTC-11";
case "Etc/GMT+12": return "Dateline Standard Time";
case "Etc/GMT+2": return "UTC-02";
case "Etc/GMT+3": return "SA Eastern Standard Time";
case "Etc/GMT+4": return "SA Western Standard Time";
case "Etc/GMT+5": return "SA Pacific Standard Time";
case "Etc/GMT+6": return "Central America Standard Time";
case "Etc/GMT+7": return "US Mountain Standard Time";
case "Etc/GMT-1": return "W. Central Africa Standard Time";
case "Etc/GMT-10": return "West Pacific Standard Time";
case "Etc/GMT-11": return "Central Pacific Standard Time";
case "Etc/GMT-12": return "UTC+12";
case "Etc/GMT-13": return "Tonga Standard Time";
case "Etc/GMT-14": return "Line Islands Standard Time";
case "Etc/GMT-2": return "South Africa Standard Time";
case "Etc/GMT-3": return "E. Africa Standard Time";
case "Etc/GMT-4": return "Arabian Standard Time";
case "Etc/GMT-5": return "West Asia Standard Time";
case "Etc/GMT-6": return "Central Asia Standard Time";
case "Etc/GMT-7": return "SE Asia Standard Time";
case "Etc/GMT-8": return "Singapore Standard Time";
case "Etc/GMT-9": return "Tokyo Standard Time";
case "Europe/Amsterdam": return "W. Europe Standard Time";
case "Europe/Andorra": return "W. Europe Standard Time";
case "Europe/Athens": return "GTB Standard Time";
case "Europe/Belgrade": return "Central Europe Standard Time";
case "Europe/Berlin": return "W. Europe Standard Time";
case "Europe/Bratislava": return "Central Europe Standard Time";
case "Europe/Brussels": return "Romance Standard Time";
case "Europe/Bucharest": return "GTB Standard Time";
case "Europe/Budapest": return "Central Europe Standard Time";
case "Europe/Busingen": return "W. Europe Standard Time";
case "Europe/Chisinau": return "GTB Standard Time";
case "Europe/Copenhagen": return "Romance Standard Time";
case "Europe/Dublin": return "GMT Standard Time";
case "Europe/Gibraltar": return "W. Europe Standard Time";
case "Europe/Guernsey": return "GMT Standard Time";
case "Europe/Helsinki": return "FLE Standard Time";
case "Europe/Isle_of_Man": return "GMT Standard Time";
case "Europe/Istanbul": return "Turkey Standard Time";
case "Europe/Jersey": return "GMT Standard Time";
case "Europe/Kaliningrad": return "Kaliningrad Standard Time";
case "Europe/Kiev": return "FLE Standard Time";
case "Europe/Lisbon": return "GMT Standard Time";
case "Europe/Ljubljana": return "Central Europe Standard Time";
case "Europe/London": return "GMT Standard Time";
case "Europe/Luxembourg": return "W. Europe Standard Time";
case "Europe/Madrid": return "Romance Standard Time";
case "Europe/Malta": return "W. Europe Standard Time";
case "Europe/Mariehamn": return "FLE Standard Time";
case "Europe/Minsk": return "Belarus Standard Time";
case "Europe/Monaco": return "W. Europe Standard Time";
case "Europe/Moscow": return "Russian Standard Time";
case "Europe/Oslo": return "W. Europe Standard Time";
case "Europe/Paris": return "Romance Standard Time";
case "Europe/Podgorica": return "Central Europe Standard Time";
case "Europe/Prague": return "Central Europe Standard Time";
case "Europe/Riga": return "FLE Standard Time";
case "Europe/Rome": return "W. Europe Standard Time";
case "Europe/Samara": return "Russia Time Zone 3";
case "Europe/San_Marino": return "W. Europe Standard Time";
case "Europe/Sarajevo": return "Central European Standard Time";
case "Europe/Simferopol": return "Russian Standard Time";
case "Europe/Skopje": return "Central European Standard Time";
case "Europe/Sofia": return "FLE Standard Time";
case "Europe/Stockholm": return "W. Europe Standard Time";
case "Europe/Tallinn": return "FLE Standard Time";
case "Europe/Tirane": return "Central Europe Standard Time";
case "Europe/Uzhgorod": return "FLE Standard Time";
case "Europe/Vaduz": return "W. Europe Standard Time";
case "Europe/Vatican": return "W. Europe Standard Time";
case "Europe/Vienna": return "W. Europe Standard Time";
case "Europe/Vilnius": return "FLE Standard Time";
case "Europe/Volgograd": return "Russian Standard Time";
case "Europe/Warsaw": return "Central European Standard Time";
case "Europe/Zagreb": return "Central European Standard Time";
case "Europe/Zaporozhye": return "FLE Standard Time";
case "Europe/Zurich": return "W. Europe Standard Time";
case "Indian/Antananarivo": return "E. Africa Standard Time";
case "Indian/Chagos": return "Central Asia Standard Time";
case "Indian/Christmas": return "SE Asia Standard Time";
case "Indian/Cocos": return "Myanmar Standard Time";
case "Indian/Comoro": return "E. Africa Standard Time";
case "Indian/Kerguelen": return "West Asia Standard Time";
case "Indian/Mahe": return "Mauritius Standard Time";
case "Indian/Maldives": return "West Asia Standard Time";
case "Indian/Mauritius": return "Mauritius Standard Time";
case "Indian/Mayotte": return "E. Africa Standard Time";
case "Indian/Reunion": return "Mauritius Standard Time";
case "MST7MDT": return "Mountain Standard Time";
case "PST8PDT": return "Pacific Standard Time";
case "Pacific/Apia": return "Samoa Standard Time";
case "Pacific/Auckland": return "New Zealand Standard Time";
case "Pacific/Efate": return "Central Pacific Standard Time";
case "Pacific/Enderbury": return "Tonga Standard Time";
case "Pacific/Fakaofo": return "Tonga Standard Time";
case "Pacific/Fiji": return "Fiji Standard Time";
case "Pacific/Funafuti": return "UTC+12";
case "Pacific/Galapagos": return "Central America Standard Time";
case "Pacific/Guadalcanal": return "Central Pacific Standard Time";
case "Pacific/Guam": return "West Pacific Standard Time";
case "Pacific/Honolulu": return "Hawaiian Standard Time";
case "Pacific/Johnston": return "Hawaiian Standard Time";
case "Pacific/Kiritimati": return "Line Islands Standard Time";
case "Pacific/Kosrae": return "Central Pacific Standard Time";
case "Pacific/Kwajalein": return "UTC+12";
case "Pacific/Majuro": return "UTC+12";
case "Pacific/Midway": return "UTC-11";
case "Pacific/Nauru": return "UTC+12";
case "Pacific/Niue": return "UTC-11";
case "Pacific/Noumea": return "Central Pacific Standard Time";
case "Pacific/Pago_Pago": return "UTC-11";
case "Pacific/Palau": return "Tokyo Standard Time";
case "Pacific/Ponape": return "Central Pacific Standard Time";
case "Pacific/Port_Moresby": return "West Pacific Standard Time";
case "Pacific/Rarotonga": return "Hawaiian Standard Time";
case "Pacific/Saipan": return "West Pacific Standard Time";
case "Pacific/Tahiti": return "Hawaiian Standard Time";
case "Pacific/Tarawa": return "UTC+12";
case "Pacific/Tongatapu": return "Tonga Standard Time";
case "Pacific/Truk": return "West Pacific Standard Time";
case "Pacific/Wake": return "UTC+12";
case "Pacific/Wallis": return "UTC+12";
default: return null;
}
}
version(Windows) unittest
{
import std.format : format;
foreach(tzName; TimeZone.getInstalledTZNames())
assert(tzDatabaseNameToWindowsTZName(tzName) !is null, format("TZName which failed: %s", tzName));
}
/++
Converts the given Windows time zone name to a corresponding TZ Database
name.
Returns null if the given time zone name cannot be converted.
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.
+/
string windowsTZNameToTZDatabaseName(string tzName) @safe pure nothrow @nogc
{
switch(tzName)
{
case "AUS Central Standard Time": return "Australia/Darwin";
case "AUS Eastern Standard Time": return "Australia/Sydney";
case "Afghanistan Standard Time": return "Asia/Kabul";
case "Alaskan Standard Time": return "America/Anchorage";
case "Arab Standard Time": return "Asia/Riyadh";
case "Arabian Standard Time": return "Asia/Dubai";
case "Arabic Standard Time": return "Asia/Baghdad";
case "Argentina Standard Time": return "America/Buenos_Aires";
case "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 "Belarus Standard Time": return "Europe/Minsk";
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";
// This doesn't appear to be in the current stuff from MS, but the autotester
// is failing without it (probably because its time zone data hasn't been
// updated recently enough).
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/Athens";
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";
// Same as with E. Europe Standard Time.
case "Kamchatka Standard Time": return "Asia/Kamchatka";
case "Korea Standard Time": return "Asia/Seoul";
case "Libya Standard Time": return "Africa/Tripoli";
case "Line Islands Standard Time": return "Pacific/Kiritimati";
case "Magadan Standard Time": return "Asia/Magadan";
case "Mauritius Standard Time": return "Indian/Mauritius";
// Same as with E. Europe Standard Time.
case "Mexico Standard Time": return "America/Mexico_City";
// Same as with E. Europe Standard Time.
case "Mexico Standard Time 2": return "America/Chihuahua";
// Same as with E. Europe Standard Time.
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 "Russia Time Zone 10": return "Asia/Srednekolymsk";
case "Russia Time Zone 11": return "Asia/Anadyr";
case "Russia Time Zone 3": return "Europe/Samara";
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 "America/Indianapolis";
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: return null;
}
}
version(Windows) unittest
{
import std.format : format;
foreach(tzName; WindowsTimeZone.getInstalledTZNames())
assert(windowsTZNameToTZDatabaseName(tzName) !is null, format("TZName which failed: %s", 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();
}
@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;
}
@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;
}
@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;
}
@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;
}
@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;
}
@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;
}
@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;
}
/++
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.
Note that casting the TickDurations to $(CXREF time, Duration)s will make
the results easier to deal with (and it may change in the future that
benchmark will return an array of Durations rather than TickDurations).
See_Also:
$(LREF measureTime)
+/
TickDuration[fun.length] benchmark(fun...)(uint n)
{
TickDuration[fun.length] result;
StopWatch sw;
sw.start();
foreach(i, unused; fun)
{
sw.reset();
foreach(j; 0 .. n)
fun[i]();
result[i] = sw.peek();
}
return result;
}
///
unittest
{
import std.conv : to;
int a;
void f0() {}
void f1() {auto b = a;}
void f2() {auto b = to!string(a);}
auto r = benchmark!(f0, f1, f2)(10_000);
auto f0Result = to!Duration(r[0]); // time f0 took to run 10,000 times
auto f1Result = to!Duration(r[1]); // time f1 took to run 10,000 times
auto f2Result = to!Duration(r[2]); // time f2 took to run 10,000 times
}
@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]);
}
@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
}
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
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
{
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) @safe pure nothrow
{
if(year % 400 == 0)
return true;
if(year % 100 == 0)
return false;
return year % 4 == 0;
}
unittest
{
import std.format : format;
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 from unix time (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).
The C standard does not specify the representation of time_t, so it is
implementation defined. On POSIX systems, unix time is equivalent to
time_t, but that's not necessarily true on other systems (e.g. it is
not true for the Digital Mars C runtime). So, be careful when using unix
time with C functions on non-POSIX systems.
"std time"'s epoch is based on the Proleptic Gregorian Calendar per ISO
8601 and is what $(LREF SysTime) uses internally. However, holding the time
as an integer in hnescs since that epoch technically isn't actually part of
the standard, much as it's based on it, so the name "std time" isn't
particularly good, but there isn't an official name for it. C# uses "ticks"
for the same thing, but they aren't actually clock ticks, and the term
"ticks" $(I is) used for actual clock ticks for $(CXREF time, MonoTime), so
it didn't make sense to use the term ticks here. So, for better or worse,
std.datetime uses the term "std time" for this.
Params:
unixTime = The unix time to convert.
See_Also:
SysTime.fromUnixTime
+/
long unixTimeToStdTime(long unixTime) @safe pure nothrow
{
return 621_355_968_000_000_000L + convert!("seconds", "hnsecs")(unixTime);
}
///
unittest
{
// Midnight, January 1st, 1970
assert(unixTimeToStdTime(0) == 621_355_968_000_000_000L);
assert(SysTime(unixTimeToStdTime(0)) ==
SysTime(DateTime(1970, 1, 1), UTC()));
assert(unixTimeToStdTime(int.max) == 642_830_804_470_000_000L);
assert(SysTime(unixTimeToStdTime(int.max)) ==
SysTime(DateTime(2038, 1, 19, 3, 14, 07), UTC()));
assert(unixTimeToStdTime(-127_127) == 621_354_696_730_000_000L);
assert(SysTime(unixTimeToStdTime(-127_127)) ==
SysTime(DateTime(1969, 12, 30, 12, 41, 13), UTC()));
}
unittest
{
// Midnight, January 2nd, 1970
assert(unixTimeToStdTime(86_400) == 621_355_968_000_000_000L + 864_000_000_000L);
// Midnight, December 31st, 1969
assert(unixTimeToStdTime(-86_400) == 621_355_968_000_000_000L - 864_000_000_000L);
assert(unixTimeToStdTime(0) == (Date(1970, 1, 1) - Date(1, 1, 1)).total!"hnsecs");
assert(unixTimeToStdTime(0) == (DateTime(1970, 1, 1) - DateTime(1, 1, 1)).total!"hnsecs");
foreach(dt; [DateTime(2010, 11, 1, 19, 5, 22), DateTime(1952, 7, 6, 2, 17, 9)])
assert(unixTimeToStdTime((dt - DateTime(1970, 1, 1)).total!"seconds") == (dt - DateTime.init).total!"hnsecs");
}
/++
Converts std time (which uses midnight, January 1st, 1 A.D. UTC as its epoch
and hnsecs as its units) to unix time (which uses midnight, January 1st,
1970 UTC as its epoch and seconds as its units).
The C standard does not specify the representation of time_t, so it is
implementation defined. On POSIX systems, unix time is equivalent to
time_t, but that's not necessarily true on other systems (e.g. it is
not true for the Digital Mars C runtime). So, be careful when using unix
time with C functions on non-POSIX systems.
"std time"'s epoch is based on the Proleptic Gregorian Calendar per ISO
8601 and is what $(LREF SysTime) uses internally. However, holding the time
as an integer in hnescs since that epoch technically isn't actually part of
the standard, much as it's based on it, so the name "std time" isn't
particularly good, but there isn't an official name for it. C# uses "ticks"
for the same thing, but they aren't actually clock ticks, and the term
"ticks" $(I is) used for actual clock ticks for $(CXREF time, MonoTime), so
it didn't make sense to use the term ticks here. So, for better or worse,
std.datetime uses the term "std time" for this.
By default, the return type is time_t (which is normally an alias for
int on 32-bit systems and long on 64-bit systems), but if a different
size is required than either int or long can be passed as a template
argument to get the desired size.
If the return type is int, and the result can't fit in an int, then the
closest value that can be held in 32 bits will be used (so $(D int.max)
if it goes over and $(D int.min) if it goes under). However, no attempt
is made to deal with integer overflow if the return type is long.
Params:
T = The return type (int or long). It defaults to time_t, which is
normally 32 bits on a 32-bit system and 64 bits on a 64-bit
system.
stdTime = The std time to convert.
Returns:
A signed integer representing the unix time which is equivalent to
the given std time.
See_Also:
SysTime.toUnixTime
+/
T stdTimeToUnixTime(T = time_t)(long stdTime) @safe pure nothrow
if(is(T == int) || is(T == long))
{
immutable unixTime = convert!("hnsecs", "seconds")(stdTime - 621_355_968_000_000_000L);
static assert(is(time_t == int) || is(time_t == long),
"Currently, std.datetime only supports systems where time_t is int or long");
static if(is(T == long))
return unixTime;
else static if(is(T == int))
{
if(unixTime > int.max)
return int.max;
return unixTime < int.min ? int.min : cast(int)unixTime;
}
else static assert(0, "Bug in template constraint. Only int and long allowed.");
}
///
unittest
{
// Midnight, January 1st, 1970 UTC
assert(stdTimeToUnixTime(621_355_968_000_000_000L) == 0);
// 2038-01-19 03:14:07 UTC
assert(stdTimeToUnixTime(642_830_804_470_000_000L) == int.max);
}
unittest
{
enum unixEpochAsStdTime = (Date(1970, 1, 1) - Date.init).total!"hnsecs";
assert(stdTimeToUnixTime(unixEpochAsStdTime) == 0); //Midnight, January 1st, 1970
assert(stdTimeToUnixTime(unixEpochAsStdTime + 864_000_000_000L) == 86_400); //Midnight, January 2nd, 1970
assert(stdTimeToUnixTime(unixEpochAsStdTime - 864_000_000_000L) == -86_400); //Midnight, December 31st, 1969
assert(stdTimeToUnixTime((Date(1970, 1, 1) - Date(1, 1, 1)).total!"hnsecs") == 0);
assert(stdTimeToUnixTime((DateTime(1970, 1, 1) - DateTime(1, 1, 1)).total!"hnsecs") == 0);
foreach(dt; [DateTime(2010, 11, 1, 19, 5, 22), DateTime(1952, 7, 6, 2, 17, 9)])
assert(stdTimeToUnixTime((dt - DateTime.init).total!"hnsecs") == (dt - DateTime(1970, 1, 1)).total!"seconds");
enum max = convert!("seconds", "hnsecs")(int.max);
enum min = convert!("seconds", "hnsecs")(int.min);
enum one = convert!("seconds", "hnsecs")(1);
assert(stdTimeToUnixTime!long(unixEpochAsStdTime + max) == int.max);
assert(stdTimeToUnixTime!int(unixEpochAsStdTime + max) == int.max);
assert(stdTimeToUnixTime!long(unixEpochAsStdTime + max + one) == int.max + 1L);
assert(stdTimeToUnixTime!int(unixEpochAsStdTime + max + one) == int.max);
assert(stdTimeToUnixTime!long(unixEpochAsStdTime + max + 9_999_999) == int.max);
assert(stdTimeToUnixTime!int(unixEpochAsStdTime + max + 9_999_999) == int.max);
assert(stdTimeToUnixTime!long(unixEpochAsStdTime + min) == int.min);
assert(stdTimeToUnixTime!int(unixEpochAsStdTime + min) == int.min);
assert(stdTimeToUnixTime!long(unixEpochAsStdTime + min - one) == int.min - 1L);
assert(stdTimeToUnixTime!int(unixEpochAsStdTime + min - one) == int.min);
assert(stdTimeToUnixTime!long(unixEpochAsStdTime + min - 9_999_999) == int.min);
assert(stdTimeToUnixTime!int(unixEpochAsStdTime + min - 9_999_999) == int.min);
}
version(StdDdoc)
{
version(Windows) {}
else
{
alias SYSTEMTIME = void*;
alias FILETIME = void*;
}
/++
$(BLUE This function is Windows-Only.)
Converts a $(D SYSTEMTIME) struct to a $(LREF 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:
$(LREF DateTimeException) if the given $(D SYSTEMTIME) will not fit in
a $(LREF 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()) @safe;
/++
$(BLUE This function is Windows-Only.)
Converts a $(LREF SysTime) to a $(D SYSTEMTIME) struct.
The $(D SYSTEMTIME) which is returned will be set using the given
$(LREF SysTime)'s time zone, so to get the $(D SYSTEMTIME) in
UTC, set the $(LREF SysTime)'s time zone to UTC.
Params:
sysTime = The $(LREF SysTime) to convert.
Throws:
$(LREF DateTimeException) if the given $(LREF SysTime) will not fit in a
$(D SYSTEMTIME). This will only happen if the $(LREF SysTime)'s date is
prior to 1601 A.D.
+/
SYSTEMTIME SysTimeToSYSTEMTIME(in SysTime sysTime) @safe;
/++
$(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:
$(LREF DateTimeException) if the given $(D FILETIME) cannot be
represented as the return value.
+/
long FILETIMEToStdTime(const FILETIME* ft) @safe;
/++
$(BLUE This function is Windows-Only.)
Converts a $(D FILETIME) struct to a $(LREF SysTime).
Params:
ft = The $(D FILETIME) struct to convert.
tz = The time zone that the $(LREF SysTime) will be in ($(D FILETIME)s
are in UTC).
Throws:
$(LREF DateTimeException) if the given $(D FILETIME) will not fit in a
$(LREF SysTime).
+/
SysTime FILETIMEToSysTime(const FILETIME* ft, immutable TimeZone tz = LocalTime()) @safe;
/++
$(BLUE This function is Windows-Only.)
Converts a number of hnsecs since midnight, January 1st, 1 A.D. to a
$(D FILETIME) struct.
Params:
stdTime = The number of hnsecs since midnight, January 1st, 1 A.D. UTC.
Throws:
$(LREF DateTimeException) if the given value will not fit in a
$(D FILETIME).
+/
FILETIME stdTimeToFILETIME(long stdTime) @safe;
/++
$(BLUE This function is Windows-Only.)
Converts a $(LREF SysTime) to a $(D FILETIME) struct.
$(D FILETIME)s are always in UTC.
Params:
sysTime = The $(LREF SysTime) to convert.
Throws:
$(LREF DateTimeException) if the given $(LREF SysTime) will not fit in a
$(D FILETIME).
+/
FILETIME SysTimeToFILETIME(SysTime sysTime) @safe;
}
else version(Windows)
{
SysTime SYSTEMTIMEToSysTime(const SYSTEMTIME* st, immutable TimeZone tz = LocalTime()) @safe
{
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.fracSecs.total!"msecs")
throwLaterThanMax();
}
}
}
}
}
}
auto dt = DateTime(st.wYear, st.wMonth, st.wDay,
st.wHour, st.wMinute, st.wSecond);
return SysTime(dt, msecs(st.wMilliseconds), tz);
}
unittest
{
auto sysTime = Clock.currTime(UTC());
SYSTEMTIME st = void;
GetSystemTime(&st);
auto converted = SYSTEMTIMEToSysTime(&st, UTC());
assert(abs((converted - sysTime)) <= dur!"seconds"(2));
}
SYSTEMTIME SysTimeToSYSTEMTIME(in SysTime sysTime) @safe
{
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.fracSecs.total!"msecs";
return st;
}
unittest
{
SYSTEMTIME st = void;
GetSystemTime(&st);
auto sysTime = SYSTEMTIMEToSysTime(&st, UTC());
SYSTEMTIME result = SysTimeToSYSTEMTIME(sysTime);
assert(st.wYear == result.wYear);
assert(st.wMonth == result.wMonth);
assert(st.wDayOfWeek == result.wDayOfWeek);
assert(st.wDay == result.wDay);
assert(st.wHour == result.wHour);
assert(st.wMinute == result.wMinute);
assert(st.wSecond == result.wSecond);
assert(st.wMilliseconds == result.wMilliseconds);
}
private enum hnsecsFrom1601 = 504_911_232_000_000_000L;
long FILETIMEToStdTime(const FILETIME* ft) @safe
{
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()) @safe
{
auto sysTime = SysTime(FILETIMEToStdTime(ft), UTC());
sysTime.timezone = tz;
return sysTime;
}
unittest
{
auto sysTime = Clock.currTime(UTC());
SYSTEMTIME st = void;
GetSystemTime(&st);
FILETIME ft = void;
SystemTimeToFileTime(&st, &ft);
auto converted = FILETIMEToSysTime(&ft);
assert(abs((converted - sysTime)) <= dur!"seconds"(2));
}
FILETIME stdTimeToFILETIME(long stdTime) @safe
{
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) @safe
{
return stdTimeToFILETIME(sysTime.stdTime);
}
unittest
{
SYSTEMTIME st = void;
GetSystemTime(&st);
FILETIME ft = void;
SystemTimeToFileTime(&st, &ft);
auto sysTime = FILETIMEToSysTime(&ft, UTC());
FILETIME result = SysTimeToFILETIME(sysTime);
assert(ft.dwLowDateTime == result.dwLowDateTime);
assert(ft.dwHighDateTime == result.dwHighDateTime);
}
}
/++
Type representing the DOS file date/time format.
+/
alias DosFileTime = uint;
/++
Converts from DOS file date/time to $(LREF SysTime).
Params:
dft = The DOS file time to convert.
tz = The time zone which the DOS file time is assumed to be in.
Throws:
$(LREF DateTimeException) if the $(D DosFileTime) is invalid.
+/
SysTime DosFileTimeToSysTime(DosFileTime dft, immutable TimeZone tz = LocalTime()) @safe
{
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)
try
return SysTime(DateTime(year, month, dayOfMonth, hour, minute, second), tz);
catch(DateTimeException dte)
throw new DateTimeException("Invalid DosFileTime", __FILE__, __LINE__, dte);
}
unittest
{
assert(DosFileTimeToSysTime(0b00000000001000010000000000000000) ==
SysTime(DateTime(1980, 1, 1, 0, 0, 0)));
assert(DosFileTimeToSysTime(0b11111111100111111011111101111101) ==
SysTime(DateTime(2107, 12, 31, 23, 59, 58)));
assert(DosFileTimeToSysTime(0x3E3F8456) ==
SysTime(DateTime(2011, 1, 31, 16, 34, 44)));
}
/++
Converts from $(LREF SysTime) to DOS file date/time.
Params:
sysTime = The $(LREF SysTime) to convert.
Throws:
$(LREF DateTimeException) if the given $(LREF SysTime) cannot be converted to
a $(D DosFileTime).
+/
DosFileTime SysTimeToDosFileTime(SysTime sysTime) @safe
{
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 past 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
{
assert(SysTimeToDosFileTime(SysTime(DateTime(1980, 1, 1, 0, 0, 0))) ==
0b00000000001000010000000000000000);
assert(SysTimeToDosFileTime(SysTime(DateTime(2107, 12, 31, 23, 59, 58))) ==
0b11111111100111111011111101111101);
assert(SysTimeToDosFileTime(SysTime(DateTime(2011, 1, 31, 16, 34, 44))) ==
0x3E3F8456);
}
/++
The given array of $(D char) or random-access range of $(D char) or
$(D ubyte) is expected to be in the format specified in
$(WEB tools.ietf.org/html/rfc5322, RFC 5322) section 3.3 with the
grammar rule $(I date-time). It is the date-time format commonly used in
internet messages such as e-mail and HTTP. The corresponding
$(LREF SysTime) will be returned.
RFC 822 was the original spec (hence the function's name), whereas RFC 5322
is the current spec.
The day of the week is ignored beyond verifying that it's a valid day of the
week, as the day of the week can be inferred from the date. It is not
checked whether the given day of the week matches the actual day of the week
of the given date (though it is technically invalid per the spec if the
day of the week doesn't match the actual day of the week of the given date).
If the time zone is $(D "-0000") (or considered to be equivalent to
$(D "-0000") by section 4.3 of the spec), a $(LREF SimpleTimeZone) with a
utc offset of $(D 0) is used rather than $(LREF UTC), whereas $(D "+0000")
uses $(LREF UTC).
Note that because $(LREF SysTime) does not currently support having a second
value of 60 (as is sometimes done for leap seconds), if the date-time value
does have a value of 60 for the seconds, it is treated as 59.
The one area in which this function violates RFC 5322 is that it accepts
$(D "\n") in folding whitespace in the place of $(D "\r\n"), because the
HTTP spec requires it.
Throws:
$(LREF DateTimeException) if the given string doesn't follow the grammar
for a date-time field or if the resulting $(LREF SysTime) is invalid.
+/
SysTime parseRFC822DateTime()(in char[] value) @safe
{
import std.string : representation;
return parseRFC822DateTime(value.representation);
}
/++ Ditto +/
SysTime parseRFC822DateTime(R)(R value) @safe
if(isRandomAccessRange!R && hasSlicing!R && hasLength!R &&
(is(Unqual!(ElementType!R) == char) || is(Unqual!(ElementType!R) == ubyte)))
{
import std.functional : not;
import std.ascii : isDigit;
import std.typecons : Rebindable;
import std.string : capitalize, format;
import std.conv : to;
import std.algorithm : find, all;
void stripAndCheckLen(R valueBefore, size_t minLen, size_t line = __LINE__)
{
value = _stripCFWS(valueBefore);
if(value.length < minLen)
throw new DateTimeException("date-time value too short", __FILE__, line);
}
stripAndCheckLen(value, "7Dec1200:00A".length);
static if(isArray!R && (is(ElementEncodingType!R == char) || is(ElementEncodingType!R == ubyte)))
{
static string sliceAsString(R str) @trusted
{
return cast(string)str;
}
}
else
{
char[4] temp;
char[] sliceAsString(R str) @trusted
{
size_t i = 0;
foreach(c; str)
temp[i++] = cast(char)c;
return temp[0 .. str.length];
}
}
// day-of-week
if(std.ascii.isAlpha(value[0]))
{
auto dowStr = sliceAsString(value[0 .. 3]);
switch(dowStr)
{
foreach(dow; EnumMembers!DayOfWeek)
{
enum dowC = capitalize(to!string(dow));
case dowC:
goto afterDoW;
}
default: throw new DateTimeException(format("Invalid day-of-week: %s", dowStr));
}
afterDoW: stripAndCheckLen(value[3 .. value.length], ",7Dec1200:00A".length);
if(value[0] != ',')
throw new DateTimeException("day-of-week missing comma");
stripAndCheckLen(value[1 .. value.length], "7Dec1200:00A".length);
}
// day
immutable digits = std.ascii.isDigit(value[1]) ? 2 : 1;
immutable day = _convDigits!short(value[0 .. digits]);
if(day == -1)
throw new DateTimeException("Invalid day");
stripAndCheckLen(value[digits .. value.length], "Dec1200:00A".length);
// month
Month month;
{
auto monStr = sliceAsString(value[0 .. 3]);
switch(monStr)
{
foreach(mon; EnumMembers!Month)
{
enum monC = capitalize(to!string(mon));
case monC:
{
month = mon;
goto afterMon;
}
}
default: throw new DateTimeException(format("Invalid month: %s", monStr));
}
afterMon: stripAndCheckLen(value[3 .. value.length], "1200:00A".length);
}
// year
auto found = value[2 .. value.length].find!(not!(std.ascii.isDigit))();
size_t yearLen = value.length - found.length;
if(found.length == 0)
throw new DateTimeException("Invalid year");
if(found[0] == ':')
yearLen -= 2;
auto year = _convDigits!short(value[0 .. yearLen]);
if(year < 1900)
{
if(year == -1)
throw new DateTimeException("Invalid year");
if(yearLen < 4)
{
if(yearLen == 3)
year += 1900;
else if(yearLen == 2)
year += year < 50 ? 2000 : 1900;
else
throw new DateTimeException("Invalid year. Too few digits.");
}
else
throw new DateTimeException("Invalid year. Cannot be earlier than 1900.");
}
stripAndCheckLen(value[yearLen .. value.length], "00:00A".length);
// hour
immutable hour = _convDigits!short(value[0 .. 2]);
stripAndCheckLen(value[2 .. value.length], ":00A".length);
if(value[0] != ':')
throw new DateTimeException("Invalid hour");
stripAndCheckLen(value[1 .. value.length], "00A".length);
// minute
immutable minute = _convDigits!short(value[0 .. 2]);
stripAndCheckLen(value[2 .. value.length], "A".length);
// second
short second;
if(value[0] == ':')
{
stripAndCheckLen(value[1 .. value.length], "00A".length);
second = _convDigits!short(value[0 .. 2]);
// this is just if/until SysTime is sorted out to fully support leap seconds
if(second == 60)
second = 59;
stripAndCheckLen(value[2 .. value.length], "A".length);
}
immutable(TimeZone) parseTZ(int sign)
{
if(value.length < 5)
throw new DateTimeException("Invalid timezone");
immutable zoneHours = _convDigits!short(value[1 .. 3]);
immutable zoneMinutes = _convDigits!short(value[3 .. 5]);
if(zoneHours == -1 || zoneMinutes == -1 || zoneMinutes > 59)
throw new DateTimeException("Invalid timezone");
value = value[5 .. value.length];
immutable utcOffset = (dur!"hours"(zoneHours) + dur!"minutes"(zoneMinutes)) * sign;
if(utcOffset == Duration.zero)
{
return sign == 1 ? cast(immutable(TimeZone))UTC()
: cast(immutable(TimeZone))new immutable SimpleTimeZone(Duration.zero);
}
return new immutable(SimpleTimeZone)(utcOffset);
}
// zone
Rebindable!(immutable TimeZone) tz;
if(value[0] == '-')
tz = parseTZ(-1);
else if(value[0] == '+')
tz = parseTZ(1);
else
{
// obs-zone
immutable tzLen = value.length - find(value, ' ', '\t', '(')[0].length;
switch(sliceAsString(value[0 .. tzLen <= 4 ? tzLen : 4]))
{
case "UT": case "GMT": tz = UTC(); break;
case "EST": tz = new immutable SimpleTimeZone(dur!"hours"(-5)); break;
case "EDT": tz = new immutable SimpleTimeZone(dur!"hours"(-4)); break;
case "CST": tz = new immutable SimpleTimeZone(dur!"hours"(-6)); break;
case "CDT": tz = new immutable SimpleTimeZone(dur!"hours"(-5)); break;
case "MST": tz = new immutable SimpleTimeZone(dur!"hours"(-7)); break;
case "MDT": tz = new immutable SimpleTimeZone(dur!"hours"(-6)); break;
case "PST": tz = new immutable SimpleTimeZone(dur!"hours"(-8)); break;
case "PDT": tz = new immutable SimpleTimeZone(dur!"hours"(-7)); break;
case "J": case "j": throw new DateTimeException("Invalid timezone");
default:
{
if(all!(std.ascii.isAlpha)(value[0 .. tzLen]))
{
tz = new immutable SimpleTimeZone(Duration.zero);
break;
}
throw new DateTimeException("Invalid timezone");
}
}
value = value[tzLen .. value.length];
}
// This is kind of arbitrary. Technically, nothing but CFWS is legal past
// the end of the timezone, but we don't want to be picky about that in a
// function that's just parsing rather than validating. So, the idea here is
// that if the next character is printable (and not part of CFWS), then it
// might be part of the timezone and thus affect what the timezone was
// supposed to be, so we'll throw, but otherwise, we'll just ignore it.
if(!value.empty && std.ascii.isPrintable(value[0]) && value[0] != ' ' && value[0] != '(')
throw new DateTimeException("Invalid timezone");
try
return SysTime(DateTime(year, month, day, hour, minute, second), tz);
catch(DateTimeException dte)
throw new DateTimeException("date-time format is correct, but the resulting SysTime is invalid.", dte);
}
///
unittest
{
auto tz = new immutable SimpleTimeZone(hours(-8));
assert(parseRFC822DateTime("Sat, 6 Jan 1990 12:14:19 -0800") ==
SysTime(DateTime(1990, 1, 6, 12, 14, 19), tz));
assert(parseRFC822DateTime("9 Jul 2002 13:11 +0000") ==
SysTime(DateTime(2002, 7, 9, 13, 11, 0), UTC()));
auto badStr = "29 Feb 2001 12:17:16 +0200";
assertThrown!DateTimeException(parseRFC822DateTime(badStr));
}
version(unittest) void testParse822(alias cr)(string str, SysTime expected, size_t line = __LINE__)
{
import std.string;
import std.format : format;
auto value = cr(str);
auto result = parseRFC822DateTime(value);
if(result != expected)
throw new AssertError(format("wrong result. expected [%s], actual[%s]", expected, result), __FILE__, line);
}
version(unittest) void testBadParse822(alias cr)(string str, size_t line = __LINE__)
{
try
parseRFC822DateTime(cr(str));
catch(DateTimeException)
return;
throw new AssertError("No DateTimeException was thrown", __FILE__, line);
}
unittest
{
import std.algorithm;
import std.ascii;
import std.format : format;
import std.range;
import std.string;
import std.typecons;
import std.typetuple;
static struct Rand3Letters
{
enum empty = false;
@property auto front() { return _mon; }
void popFront()
{
import std.random;
_mon = rndGen.map!(a => letters[a % letters.length])().take(3).array().assumeUnique();
}
string _mon;
static auto start() { Rand3Letters retval; retval.popFront(); return retval; }
}
foreach(cr; TypeTuple!(function(string a){return cast(char[])a;},
function(string a){return cast(ubyte[])a;},
function(string a){return a;},
function(string a){return map!(b => cast(char)b)(a.representation);}))
(){ // avoid slow optimizations for large functions @@@BUG@@@ 2396
scope(failure) writeln(typeof(cr).stringof);
alias test = testParse822!cr;
alias testBad = testBadParse822!cr;
immutable std1 = DateTime(2012, 12, 21, 13, 14, 15);
immutable std2 = DateTime(2012, 12, 21, 13, 14, 0);
immutable dst1 = DateTime(1976, 7, 4, 5, 4, 22);
immutable dst2 = DateTime(1976, 7, 4, 5, 4, 0);
test("21 Dec 2012 13:14:15 +0000", SysTime(std1, UTC()));
test("21 Dec 2012 13:14 +0000", SysTime(std2, UTC()));
test("Fri, 21 Dec 2012 13:14 +0000", SysTime(std2, UTC()));
test("Fri, 21 Dec 2012 13:14:15 +0000", SysTime(std1, UTC()));
test("04 Jul 1976 05:04:22 +0000", SysTime(dst1, UTC()));
test("04 Jul 1976 05:04 +0000", SysTime(dst2, UTC()));
test("Sun, 04 Jul 1976 05:04 +0000", SysTime(dst2, UTC()));
test("Sun, 04 Jul 1976 05:04:22 +0000", SysTime(dst1, UTC()));
test("4 Jul 1976 05:04:22 +0000", SysTime(dst1, UTC()));
test("4 Jul 1976 05:04 +0000", SysTime(dst2, UTC()));
test("Sun, 4 Jul 1976 05:04 +0000", SysTime(dst2, UTC()));
test("Sun, 4 Jul 1976 05:04:22 +0000", SysTime(dst1, UTC()));
auto badTZ = new immutable SimpleTimeZone(Duration.zero);
test("21 Dec 2012 13:14:15 -0000", SysTime(std1, badTZ));
test("21 Dec 2012 13:14 -0000", SysTime(std2, badTZ));
test("Fri, 21 Dec 2012 13:14 -0000", SysTime(std2, badTZ));
test("Fri, 21 Dec 2012 13:14:15 -0000", SysTime(std1, badTZ));
test("04 Jul 1976 05:04:22 -0000", SysTime(dst1, badTZ));
test("04 Jul 1976 05:04 -0000", SysTime(dst2, badTZ));
test("Sun, 04 Jul 1976 05:04 -0000", SysTime(dst2, badTZ));
test("Sun, 04 Jul 1976 05:04:22 -0000", SysTime(dst1, badTZ));
test("4 Jul 1976 05:04:22 -0000", SysTime(dst1, badTZ));
test("4 Jul 1976 05:04 -0000", SysTime(dst2, badTZ));
test("Sun, 4 Jul 1976 05:04 -0000", SysTime(dst2, badTZ));
test("Sun, 4 Jul 1976 05:04:22 -0000", SysTime(dst1, badTZ));
auto pst = new immutable SimpleTimeZone(dur!"hours"(-8));
auto pdt = new immutable SimpleTimeZone(dur!"hours"(-7));
test("21 Dec 2012 13:14:15 -0800", SysTime(std1, pst));
test("21 Dec 2012 13:14 -0800", SysTime(std2, pst));
test("Fri, 21 Dec 2012 13:14 -0800", SysTime(std2, pst));
test("Fri, 21 Dec 2012 13:14:15 -0800", SysTime(std1, pst));
test("04 Jul 1976 05:04:22 -0700", SysTime(dst1, pdt));
test("04 Jul 1976 05:04 -0700", SysTime(dst2, pdt));
test("Sun, 04 Jul 1976 05:04 -0700", SysTime(dst2, pdt));
test("Sun, 04 Jul 1976 05:04:22 -0700", SysTime(dst1, pdt));
test("4 Jul 1976 05:04:22 -0700", SysTime(dst1, pdt));
test("4 Jul 1976 05:04 -0700", SysTime(dst2, pdt));
test("Sun, 4 Jul 1976 05:04 -0700", SysTime(dst2, pdt));
test("Sun, 4 Jul 1976 05:04:22 -0700", SysTime(dst1, pdt));
auto cet = new immutable SimpleTimeZone(dur!"hours"(1));
auto cest = new immutable SimpleTimeZone(dur!"hours"(2));
test("21 Dec 2012 13:14:15 +0100", SysTime(std1, cet));
test("21 Dec 2012 13:14 +0100", SysTime(std2, cet));
test("Fri, 21 Dec 2012 13:14 +0100", SysTime(std2, cet));
test("Fri, 21 Dec 2012 13:14:15 +0100", SysTime(std1, cet));
test("04 Jul 1976 05:04:22 +0200", SysTime(dst1, cest));
test("04 Jul 1976 05:04 +0200", SysTime(dst2, cest));
test("Sun, 04 Jul 1976 05:04 +0200", SysTime(dst2, cest));
test("Sun, 04 Jul 1976 05:04:22 +0200", SysTime(dst1, cest));
test("4 Jul 1976 05:04:22 +0200", SysTime(dst1, cest));
test("4 Jul 1976 05:04 +0200", SysTime(dst2, cest));
test("Sun, 4 Jul 1976 05:04 +0200", SysTime(dst2, cest));
test("Sun, 4 Jul 1976 05:04:22 +0200", SysTime(dst1, cest));
// dst and std times are switched in the Southern Hemisphere which is why the
// time zone names and DateTime variables don't match.
auto cstStd = new immutable SimpleTimeZone(dur!"hours"(9) + dur!"minutes"(30));
auto cstDST = new immutable SimpleTimeZone(dur!"hours"(10) + dur!"minutes"(30));
test("21 Dec 2012 13:14:15 +1030", SysTime(std1, cstDST));
test("21 Dec 2012 13:14 +1030", SysTime(std2, cstDST));
test("Fri, 21 Dec 2012 13:14 +1030", SysTime(std2, cstDST));
test("Fri, 21 Dec 2012 13:14:15 +1030", SysTime(std1, cstDST));
test("04 Jul 1976 05:04:22 +0930", SysTime(dst1, cstStd));
test("04 Jul 1976 05:04 +0930", SysTime(dst2, cstStd));
test("Sun, 04 Jul 1976 05:04 +0930", SysTime(dst2, cstStd));
test("Sun, 04 Jul 1976 05:04:22 +0930", SysTime(dst1, cstStd));
test("4 Jul 1976 05:04:22 +0930", SysTime(dst1, cstStd));
test("4 Jul 1976 05:04 +0930", SysTime(dst2, cstStd));
test("Sun, 4 Jul 1976 05:04 +0930", SysTime(dst2, cstStd));
test("Sun, 4 Jul 1976 05:04:22 +0930", SysTime(dst1, cstStd));
foreach(int i, mon; _monthNames)
{
test(format("17 %s 2012 00:05:02 +0000", mon), SysTime(DateTime(2012, i + 1, 17, 0, 5, 2), UTC()));
test(format("17 %s 2012 00:05 +0000", mon), SysTime(DateTime(2012, i + 1, 17, 0, 5, 0), UTC()));
}
import std.uni;
foreach(mon; chain(_monthNames[].map!(a => toLower(a))(),
_monthNames[].map!(a => toUpper(a))(),
["Jam", "Jen", "Fec", "Fdb", "Mas", "Mbr", "Aps", "Aqr", "Mai", "Miy",
"Jum", "Jbn", "Jup", "Jal", "Aur", "Apg", "Sem", "Sap", "Ocm", "Odt",
"Nom", "Nav", "Dem", "Dac"],
Rand3Letters.start().take(20)))
{
scope(failure) writefln("Month: %s", mon);
testBad(format("17 %s 2012 00:05:02 +0000", mon));
testBad(format("17 %s 2012 00:05 +0000", mon));
}
immutable string[7] daysOfWeekNames = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
{
auto start = SysTime(DateTime(2012, 11, 11, 9, 42, 0), UTC());
int day = 11;
foreach(int i, dow; daysOfWeekNames)
{
auto curr = start + dur!"days"(i);
test(format("%s, %s Nov 2012 09:42:00 +0000", dow, day), curr);
test(format("%s, %s Nov 2012 09:42 +0000", dow, day++), curr);
// Whether the day of the week matches the date is ignored.
test(format("%s, 11 Nov 2012 09:42:00 +0000", dow), start);
test(format("%s, 11 Nov 2012 09:42 +0000", dow), start);
}
}
foreach(dow; chain(daysOfWeekNames[].map!(a => toLower(a))(),
daysOfWeekNames[].map!(a => toUpper(a))(),
["Sum", "Spn", "Mom", "Man", "Tuf", "Tae", "Wem", "Wdd", "The", "Tur",
"Fro", "Fai", "San", "Sut"],
Rand3Letters.start().take(20)))
{
scope(failure) writefln("Day of Week: %s", dow);
testBad(format("%s, 11 Nov 2012 09:42:00 +0000", dow));
testBad(format("%s, 11 Nov 2012 09:42 +0000", dow));
}
testBad("31 Dec 1899 23:59:59 +0000");
test("01 Jan 1900 00:00:00 +0000", SysTime(Date(1900, 1, 1), UTC()));
test("01 Jan 1900 00:00:00 -0000", SysTime(Date(1900, 1, 1),
new immutable SimpleTimeZone(Duration.zero)));
test("01 Jan 1900 00:00:00 -0700", SysTime(Date(1900, 1, 1),
new immutable SimpleTimeZone(dur!"hours"(-7))));
{
auto st1 = SysTime(Date(1900, 1, 1), UTC());
auto st2 = SysTime(Date(1900, 1, 1), new immutable SimpleTimeZone(dur!"hours"(-11)));
foreach(i; 1900 .. 2102)
{
test(format("1 Jan %05d 00:00 +0000", i), st1);
test(format("1 Jan %05d 00:00 -1100", i), st2);
st1.add!"years"(1);
st2.add!"years"(1);
}
st1.year = 9998;
st2.year = 9998;
foreach(i; 9998 .. 11_002)
{
test(format("1 Jan %05d 00:00 +0000", i), st1);
test(format("1 Jan %05d 00:00 -1100", i), st2);
st1.add!"years"(1);
st2.add!"years"(1);
}
}
testBad("12 Feb 1907 23:17:09 0000");
testBad("12 Feb 1907 23:17:09 +000");
testBad("12 Feb 1907 23:17:09 -000");
testBad("12 Feb 1907 23:17:09 +00000");
testBad("12 Feb 1907 23:17:09 -00000");
testBad("12 Feb 1907 23:17:09 +A");
testBad("12 Feb 1907 23:17:09 +PST");
testBad("12 Feb 1907 23:17:09 -A");
testBad("12 Feb 1907 23:17:09 -PST");
// test trailing stuff that gets ignored
{
foreach(c; chain(iota(0, 33), ['('], iota(127, ubyte.max + 1)))
{
scope(failure) writefln("c: %d", c);
test(format("21 Dec 2012 13:14:15 +0000%c", cast(char)c), SysTime(std1, UTC()));
test(format("21 Dec 2012 13:14:15 +0000%c ", cast(char)c), SysTime(std1, UTC()));
test(format("21 Dec 2012 13:14:15 +0000%chello", cast(char)c), SysTime(std1, UTC()));
}
}
// test trailing stuff that doesn't get ignored
{
foreach(c; chain(iota(33, '('), iota('(' + 1, 127)))
{
scope(failure) writefln("c: %d", c);
testBad(format("21 Dec 2012 13:14:15 +0000%c", cast(char)c));
testBad(format("21 Dec 2012 13:14:15 +0000%c ", cast(char)c));
testBad(format("21 Dec 2012 13:14:15 +0000%chello", cast(char)c));
}
}
testBad("32 Jan 2012 12:13:14 -0800");
testBad("31 Jan 2012 24:13:14 -0800");
testBad("31 Jan 2012 12:60:14 -0800");
testBad("31 Jan 2012 12:13:61 -0800");
testBad("31 Jan 2012 12:13:14 -0860");
test("31 Jan 2012 12:13:14 -0859",
SysTime(DateTime(2012, 1, 31, 12, 13, 14),
new immutable SimpleTimeZone(dur!"hours"(-8) + dur!"minutes"(-59))));
// leap-seconds
test("21 Dec 2012 15:59:60 -0800", SysTime(DateTime(2012, 12, 21, 15, 59, 59), pst));
// FWS
test("Sun,4 Jul 1976 05:04 +0930", SysTime(dst2, cstStd));
test("Sun,4 Jul 1976 05:04:22 +0930", SysTime(dst1, cstStd));
test("Sun,4 Jul 1976 05:04 +0930 (foo)", SysTime(dst2, cstStd));
test("Sun,4 Jul 1976 05:04:22 +0930 (foo)", SysTime(dst1, cstStd));
test("Sun,4 \r\n Jul \r\n 1976 \r\n 05:04 \r\n +0930 \r\n (foo)", SysTime(dst2, cstStd));
test("Sun,4 \r\n Jul \r\n 1976 \r\n 05:04:22 \r\n +0930 \r\n (foo)", SysTime(dst1, cstStd));
auto str = "01 Jan 2012 12:13:14 -0800 ";
test(str, SysTime(DateTime(2012, 1, 1, 12, 13, 14), new immutable SimpleTimeZone(hours(-8))));
foreach(i; 0 .. str.length)
{
auto currStr = str.dup;
currStr[i] = 'x';
scope(failure) writefln("failed: %s", currStr);
testBad(cast(string)currStr);
}
foreach(i; 2 .. str.length)
{
auto currStr = str[0 .. $ - i];
scope(failure) writefln("failed: %s", currStr);
testBad(cast(string)currStr);
testBad((cast(string)currStr) ~ " ");
}
}();
}
// Obsolete Format per section 4.3 of RFC 5322.
unittest
{
import std.algorithm;
import std.ascii;
import std.format : format;
import std.range;
import std.string;
import std.typecons;
import std.typetuple;
auto std1 = SysTime(DateTime(2012, 12, 21, 13, 14, 15), UTC());
auto std2 = SysTime(DateTime(2012, 12, 21, 13, 14, 0), UTC());
auto std3 = SysTime(DateTime(1912, 12, 21, 13, 14, 15), UTC());
auto std4 = SysTime(DateTime(1912, 12, 21, 13, 14, 0), UTC());
auto dst1 = SysTime(DateTime(1976, 7, 4, 5, 4, 22), UTC());
auto dst2 = SysTime(DateTime(1976, 7, 4, 5, 4, 0), UTC());
auto tooLate1 = SysTime(Date(10_000, 1, 1), UTC());
auto tooLate2 = SysTime(DateTime(12_007, 12, 31, 12, 22, 19), UTC());
foreach(cr; TypeTuple!(function(string a){return cast(char[])a;},
function(string a){return cast(ubyte[])a;},
function(string a){return a;},
function(string a){return map!(b => cast(char)b)(a.representation);}))
(){ // avoid slow optimizations for large functions @@@BUG@@@ 2396
scope(failure) writeln(typeof(cr).stringof);
alias test = testParse822!cr;
{
auto list = ["", " ", " \r\n\t", "\t\r\n (hello world( frien(dog)) silly \r\n ) \t\t \r\n ()",
" \n ", "\t\n\t", " \n\t (foo) \n (bar) \r\n (baz) \n "];
foreach(i, cfws; list)
{
scope(failure) writefln("i: %s", i);
test(format("%1$s21%1$sDec%1$s2012%1$s13:14:15%1$s+0000%1$s", cfws), std1);
test(format("%1$s21%1$sDec%1$s2012%1$s13:14%1$s+0000%1$s", cfws), std2);
test(format("%1$sFri%1$s,%1$s21%1$sDec%1$s2012%1$s13:14%1$s+0000%1$s", cfws), std2);
test(format("%1$sFri%1$s,%1$s21%1$sDec%1$s2012%1$s13:14:15%1$s+0000%1$s", cfws), std1);
test(format("%1$s04%1$sJul%1$s1976%1$s05:04:22%1$s+0000%1$s", cfws), dst1);
test(format("%1$s04%1$sJul%1$s1976%1$s05:04%1$s+0000%1$s", cfws), dst2);
test(format("%1$sSun%1$s,%1$s04%1$sJul%1$s1976%1$s05:04%1$s+0000%1$s", cfws), dst2);
test(format("%1$sSun%1$s,%1$s04%1$sJul%1$s1976%1$s05:04:22 +0000%1$s", cfws), dst1);
test(format("%1$s4%1$sJul%1$s1976%1$s05:04:22%1$s+0000%1$s", cfws), dst1);
test(format("%1$s4%1$sJul%1$s1976%1$s05:04%1$s+0000%1$s", cfws), dst2);
test(format("%1$sSun%1$s,%1$s4%1$sJul%1$s1976%1$s05:04%1$s+0000%1$s", cfws), dst2);
test(format("%1$sSun%1$s,%1$s4%1$sJul%1$s1976%1$s05:04:22%1$s+0000%1$s", cfws), dst1);
test(format("%1$s21%1$sDec%1$s12%1$s13:14:15%1$s+0000%1$s", cfws), std1);
test(format("%1$s21%1$sDec%1$s12%1$s13:14%1$s+0000%1$s", cfws), std2);
test(format("%1$sFri%1$s,%1$s21%1$sDec%1$s12%1$s13:14%1$s+0000%1$s", cfws), std2);
test(format("%1$sFri%1$s,%1$s21%1$sDec%1$s12%1$s13:14:15%1$s+0000%1$s", cfws), std1);
test(format("%1$s04%1$sJul%1$s76%1$s05:04:22%1$s+0000%1$s", cfws), dst1);
test(format("%1$s04%1$sJul%1$s76%1$s05:04%1$s+0000%1$s", cfws), dst2);
test(format("%1$sSun%1$s,%1$s04%1$sJul%1$s76%1$s05:04%1$s+0000%1$s", cfws), dst2);
test(format("%1$sSun%1$s,%1$s04%1$sJul%1$s76%1$s05:04:22%1$s+0000%1$s", cfws), dst1);
test(format("%1$s4%1$sJul%1$s76 05:04:22%1$s+0000%1$s", cfws), dst1);
test(format("%1$s4%1$sJul%1$s76 05:04%1$s+0000%1$s", cfws), dst2);
test(format("%1$sSun%1$s,%1$s4%1$sJul%1$s76%1$s05:04%1$s+0000%1$s", cfws), dst2);
test(format("%1$sSun%1$s,%1$s4%1$sJul%1$s76%1$s05:04:22%1$s+0000%1$s", cfws), dst1);
test(format("%1$s21%1$sDec%1$s012%1$s13:14:15%1$s+0000%1$s", cfws), std3);
test(format("%1$s21%1$sDec%1$s012%1$s13:14%1$s+0000%1$s", cfws), std4);
test(format("%1$sFri%1$s,%1$s21%1$sDec%1$s012%1$s13:14%1$s+0000%1$s", cfws), std4);
test(format("%1$sFri%1$s,%1$s21%1$sDec%1$s012%1$s13:14:15%1$s+0000%1$s", cfws), std3);
test(format("%1$s04%1$sJul%1$s076%1$s05:04:22%1$s+0000%1$s", cfws), dst1);
test(format("%1$s04%1$sJul%1$s076%1$s05:04%1$s+0000%1$s", cfws), dst2);
test(format("%1$sSun%1$s,%1$s04%1$sJul%1$s076%1$s05:04%1$s+0000%1$s", cfws), dst2);
test(format("%1$sSun%1$s,%1$s04%1$sJul%1$s076%1$s05:04:22%1$s+0000%1$s", cfws), dst1);
test(format("%1$s4%1$sJul%1$s076%1$s05:04:22%1$s+0000%1$s", cfws), dst1);
test(format("%1$s4%1$sJul%1$s076%1$s05:04%1$s+0000%1$s", cfws), dst2);
test(format("%1$sSun%1$s,%1$s4%1$sJul%1$s076%1$s05:04%1$s+0000%1$s", cfws), dst2);
test(format("%1$sSun%1$s,%1$s4%1$sJul%1$s076%1$s05:04:22%1$s+0000%1$s", cfws), dst1);
test(format("%1$s1%1$sJan%1$s10000%1$s00:00:00%1$s+0000%1$s", cfws), tooLate1);
test(format("%1$s31%1$sDec%1$s12007%1$s12:22:19%1$s+0000%1$s", cfws), tooLate2);
test(format("%1$sSat%1$s,%1$s1%1$sJan%1$s10000%1$s00:00:00%1$s+0000%1$s", cfws), tooLate1);
test(format("%1$sSun%1$s,%1$s31%1$sDec%1$s12007%1$s12:22:19%1$s+0000%1$s", cfws), tooLate2);
}
}
// test years of 1, 2, and 3 digits.
{
auto st1 = SysTime(Date(2000, 1, 1), UTC());
auto st2 = SysTime(Date(2000, 1, 1), new immutable SimpleTimeZone(dur!"hours"(-12)));
foreach(i; 0 .. 50)
{
test(format("1 Jan %02d 00:00 GMT", i), st1);
test(format("1 Jan %02d 00:00 -1200", i), st2);
st1.add!"years"(1);
st2.add!"years"(1);
}
}
{
auto st1 = SysTime(Date(1950, 1, 1), UTC());
auto st2 = SysTime(Date(1950, 1, 1), new immutable SimpleTimeZone(dur!"hours"(-12)));
foreach(i; 50 .. 100)
{
test(format("1 Jan %02d 00:00 GMT", i), st1);
test(format("1 Jan %02d 00:00 -1200", i), st2);
st1.add!"years"(1);
st2.add!"years"(1);
}
}
{
auto st1 = SysTime(Date(1900, 1, 1), UTC());
auto st2 = SysTime(Date(1900, 1, 1), new immutable SimpleTimeZone(dur!"hours"(-11)));
foreach(i; 0 .. 1000)
{
test(format("1 Jan %03d 00:00 GMT", i), st1);
test(format("1 Jan %03d 00:00 -1100", i), st2);
st1.add!"years"(1);
st2.add!"years"(1);
}
}
foreach(i; 0 .. 10)
{
auto str1 = cr(format("1 Jan %d 00:00 GMT", i));
auto str2 = cr(format("1 Jan %d 00:00 -1200", i));
assertThrown!DateTimeException(parseRFC822DateTime(str1));
assertThrown!DateTimeException(parseRFC822DateTime(str1));
}
// test time zones
{
auto dt = DateTime(1982, 05, 03, 12, 22, 04);
test("Wed, 03 May 1982 12:22:04 UT", SysTime(dt, UTC()));
test("Wed, 03 May 1982 12:22:04 GMT", SysTime(dt, UTC()));
test("Wed, 03 May 1982 12:22:04 EST", SysTime(dt, new immutable SimpleTimeZone(dur!"hours"(-5))));
test("Wed, 03 May 1982 12:22:04 EDT", SysTime(dt, new immutable SimpleTimeZone(dur!"hours"(-4))));
test("Wed, 03 May 1982 12:22:04 CST", SysTime(dt, new immutable SimpleTimeZone(dur!"hours"(-6))));
test("Wed, 03 May 1982 12:22:04 CDT", SysTime(dt, new immutable SimpleTimeZone(dur!"hours"(-5))));
test("Wed, 03 May 1982 12:22:04 MST", SysTime(dt, new immutable SimpleTimeZone(dur!"hours"(-7))));
test("Wed, 03 May 1982 12:22:04 MDT", SysTime(dt, new immutable SimpleTimeZone(dur!"hours"(-6))));
test("Wed, 03 May 1982 12:22:04 PST", SysTime(dt, new immutable SimpleTimeZone(dur!"hours"(-8))));
test("Wed, 03 May 1982 12:22:04 PDT", SysTime(dt, new immutable SimpleTimeZone(dur!"hours"(-7))));
auto badTZ = new immutable SimpleTimeZone(Duration.zero);
foreach(dchar c; filter!(a => a != 'j' && a != 'J')(letters))
{
scope(failure) writefln("c: %s", c);
test(format("Wed, 03 May 1982 12:22:04 %s", c), SysTime(dt, badTZ));
test(format("Wed, 03 May 1982 12:22:04%s", c), SysTime(dt, badTZ));
}
foreach(dchar c; ['j', 'J'])
{
scope(failure) writefln("c: %s", c);
assertThrown!DateTimeException(parseRFC822DateTime(cr(format("Wed, 03 May 1982 12:22:04 %s", c))));
assertThrown!DateTimeException(parseRFC822DateTime(cr(format("Wed, 03 May 1982 12:22:04%s", c))));
}
foreach(string s; ["AAA", "GQW", "DDT", "PDA", "GT", "GM"])
{
scope(failure) writefln("s: %s", s);
test(format("Wed, 03 May 1982 12:22:04 %s", s), SysTime(dt, badTZ));
}
// test trailing stuff that gets ignored
{
foreach(c; chain(iota(0, 33), ['('], iota(127, ubyte.max + 1)))
{
scope(failure) writefln("c: %d", c);
test(format("21Dec1213:14:15+0000%c", cast(char)c), std1);
test(format("21Dec1213:14:15+0000%c ", cast(char)c), std1);
test(format("21Dec1213:14:15+0000%chello", cast(char)c), std1);
}
}
// test trailing stuff that doesn't get ignored
{
foreach(c; chain(iota(33, '('), iota('(' + 1, 127)))
{
scope(failure) writefln("c: %d", c);
assertThrown!DateTimeException(parseRFC822DateTime(cr(format("21Dec1213:14:15+0000%c", cast(char)c))));
assertThrown!DateTimeException(parseRFC822DateTime(cr(format("21Dec1213:14:15+0000%c ", cast(char)c))));
assertThrown!DateTimeException(parseRFC822DateTime(cr(format("21Dec1213:14:15+0000%chello", cast(char)c))));
}
}
}
// test that the checks for minimum length work correctly and avoid
// any RangeErrors.
test("7Dec1200:00A", SysTime(DateTime(2012, 12, 7, 00, 00, 00),
new immutable SimpleTimeZone(Duration.zero)));
test("Fri,7Dec1200:00A", SysTime(DateTime(2012, 12, 7, 00, 00, 00),
new immutable SimpleTimeZone(Duration.zero)));
test("7Dec1200:00:00A", SysTime(DateTime(2012, 12, 7, 00, 00, 00),
new immutable SimpleTimeZone(Duration.zero)));
test("Fri,7Dec1200:00:00A", SysTime(DateTime(2012, 12, 7, 00, 00, 00),
new immutable SimpleTimeZone(Duration.zero)));
auto tooShortMsg = collectExceptionMsg!DateTimeException(parseRFC822DateTime(""));
foreach(str; ["Fri,7Dec1200:00:00", "7Dec1200:00:00"])
{
foreach(i; 0 .. str.length)
{
auto value = str[0 .. $ - i];
scope(failure) writeln(value);
assert(collectExceptionMsg!DateTimeException(parseRFC822DateTime(value)) == tooShortMsg);
}
}
}();
}
/++
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...) @safe pure nothrow
{
import std.algorithm : canFind;
foreach(str; units)
{
if(!canFind(timeStrings[], 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:
$(LREF DateTimeException) if either of the given strings is not a valid
time unit string.
+/
int cmpTimeUnits(string lhs, string rhs) @safe pure
{
import std.format : format;
import std.algorithm : countUntil;
auto tstrings = timeStrings;
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
{
foreach(i, outerUnits; timeStrings)
{
assert(cmpTimeUnits(outerUnits, outerUnits) == 0);
//For some reason, $ won't compile.
foreach(innerUnits; timeStrings[i+1 .. timeStrings.length])
assert(cmpTimeUnits(outerUnits, innerUnits) == -1);
}
foreach(i, outerUnits; timeStrings)
{
foreach(innerUnits; timeStrings[0 .. i])
assert(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) @safe pure nothrow
{
import std.algorithm : countUntil;
auto tstrings = timeStrings;
immutable indexOfLHS = countUntil(tstrings, lhs);
immutable indexOfRHS = countUntil(tstrings, rhs);
if(indexOfLHS < indexOfRHS)
return -1;
if(indexOfLHS > indexOfRHS)
return 1;
return 0;
}
unittest
{
import std.format : format;
import std.string;
import std.typecons;
import std.typetuple;
static string genTest(size_t index)
{
auto currUnits = timeStrings[index];
auto test = format(`assert(CmpTimeUnits!("%s", "%s") == 0);`, currUnits, currUnits);
foreach(units; timeStrings[index + 1 .. $])
test ~= format(`assert(CmpTimeUnits!("%s", "%s") == -1);`, currUnits, units);
foreach(units; timeStrings[0 .. index])
test ~= format(`assert(CmpTimeUnits!("%s", "%s") == 1);`, currUnits, units);
return test;
}
static assert(timeStrings.length == 10);
foreach(n; TypeTuple!(0, 1, 2, 3, 4, 5, 6, 7, 8, 9))
mixin(genTest(n));
}
/++
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.
+/
bool valid(string units)(int value) @safe 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
{
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) @safe 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 $(LREF DateTimeException) will list if thrown.
line = The line number that the $(LREF DateTimeException) will list if
thrown.
Throws:
$(LREF DateTimeException) if $(D valid!units(value)) is false.
+/
void enforceValid(string units)(int value, string file = __FILE__, size_t line = __LINE__) @safe pure
if(units == "months" ||
units == "hours" ||
units == "minutes" ||
units == "seconds")
{
import std.format : format;
static if(units == "months")
{
if(!valid!units(value))
throw new DateTimeException(format("%s is not a valid month of the year.", value), file, line);
}
else static if(units == "hours")
{
if(!valid!units(value))
throw new DateTimeException(format("%s is not a valid hour of the day.", value), file, line);
}
else static if(units == "minutes")
{
if(!valid!units(value))
throw new DateTimeException(format("%s is not a valid minute of an hour.", value), file, line);
}
else static if(units == "seconds")
{
if(!valid!units(value))
throw new DateTimeException(format("%s is not a valid second of a minute.", value), 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 $(LREF DateTimeException) will list if thrown.
line = The line number that the $(LREF DateTimeException) will list if
thrown.
Throws:
$(LREF 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__) @safe pure
if(units == "days")
{
import std.format : format;
if(!valid!"days"(year, month, day))
throw new DateTimeException(format("%s is not a valid day in %s in %s", day, month, 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) @safe pure
{
enforceValid!"months"(currMonth);
enforceValid!"months"(month);
if(currMonth == month)
return 0;
if(currMonth < month)
return month - currMonth;
return (Month.dec - currMonth) + month;
}
unittest
{
assert(monthsToMonth(Month.jan, Month.jan) == 0);
assert(monthsToMonth(Month.jan, Month.feb) == 1);
assert(monthsToMonth(Month.jan, Month.mar) == 2);
assert(monthsToMonth(Month.jan, Month.apr) == 3);
assert(monthsToMonth(Month.jan, Month.may) == 4);
assert(monthsToMonth(Month.jan, Month.jun) == 5);
assert(monthsToMonth(Month.jan, Month.jul) == 6);
assert(monthsToMonth(Month.jan, Month.aug) == 7);
assert(monthsToMonth(Month.jan, Month.sep) == 8);
assert(monthsToMonth(Month.jan, Month.oct) == 9);
assert(monthsToMonth(Month.jan, Month.nov) == 10);
assert(monthsToMonth(Month.jan, Month.dec) == 11);
assert(monthsToMonth(Month.may, Month.jan) == 8);
assert(monthsToMonth(Month.may, Month.feb) == 9);
assert(monthsToMonth(Month.may, Month.mar) == 10);
assert(monthsToMonth(Month.may, Month.apr) == 11);
assert(monthsToMonth(Month.may, Month.may) == 0);
assert(monthsToMonth(Month.may, Month.jun) == 1);
assert(monthsToMonth(Month.may, Month.jul) == 2);
assert(monthsToMonth(Month.may, Month.aug) == 3);
assert(monthsToMonth(Month.may, Month.sep) == 4);
assert(monthsToMonth(Month.may, Month.oct) == 5);
assert(monthsToMonth(Month.may, Month.nov) == 6);
assert(monthsToMonth(Month.may, Month.dec) == 7);
assert(monthsToMonth(Month.oct, Month.jan) == 3);
assert(monthsToMonth(Month.oct, Month.feb) == 4);
assert(monthsToMonth(Month.oct, Month.mar) == 5);
assert(monthsToMonth(Month.oct, Month.apr) == 6);
assert(monthsToMonth(Month.oct, Month.may) == 7);
assert(monthsToMonth(Month.oct, Month.jun) == 8);
assert(monthsToMonth(Month.oct, Month.jul) == 9);
assert(monthsToMonth(Month.oct, Month.aug) == 10);
assert(monthsToMonth(Month.oct, Month.sep) == 11);
assert(monthsToMonth(Month.oct, Month.oct) == 0);
assert(monthsToMonth(Month.oct, Month.nov) == 1);
assert(monthsToMonth(Month.oct, Month.dec) == 2);
assert(monthsToMonth(Month.dec, Month.jan) == 1);
assert(monthsToMonth(Month.dec, Month.feb) == 2);
assert(monthsToMonth(Month.dec, Month.mar) == 3);
assert(monthsToMonth(Month.dec, Month.apr) == 4);
assert(monthsToMonth(Month.dec, Month.may) == 5);
assert(monthsToMonth(Month.dec, Month.jun) == 6);
assert(monthsToMonth(Month.dec, Month.jul) == 7);
assert(monthsToMonth(Month.dec, Month.aug) == 8);
assert(monthsToMonth(Month.dec, Month.sep) == 9);
assert(monthsToMonth(Month.dec, Month.oct) == 10);
assert(monthsToMonth(Month.dec, Month.nov) == 11);
assert(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) @safe pure nothrow
{
if(currDoW == dow)
return 0;
if(currDoW < dow)
return dow - currDoW;
return (DayOfWeek.sat - currDoW) + dow + 1;
}
unittest
{
assert(daysToDayOfWeek(DayOfWeek.sun, DayOfWeek.sun) == 0);
assert(daysToDayOfWeek(DayOfWeek.sun, DayOfWeek.mon) == 1);
assert(daysToDayOfWeek(DayOfWeek.sun, DayOfWeek.tue) == 2);
assert(daysToDayOfWeek(DayOfWeek.sun, DayOfWeek.wed) == 3);
assert(daysToDayOfWeek(DayOfWeek.sun, DayOfWeek.thu) == 4);
assert(daysToDayOfWeek(DayOfWeek.sun, DayOfWeek.fri) == 5);
assert(daysToDayOfWeek(DayOfWeek.sun, DayOfWeek.sat) == 6);
assert(daysToDayOfWeek(DayOfWeek.mon, DayOfWeek.sun) == 6);
assert(daysToDayOfWeek(DayOfWeek.mon, DayOfWeek.mon) == 0);
assert(daysToDayOfWeek(DayOfWeek.mon, DayOfWeek.tue) == 1);
assert(daysToDayOfWeek(DayOfWeek.mon, DayOfWeek.wed) == 2);
assert(daysToDayOfWeek(DayOfWeek.mon, DayOfWeek.thu) == 3);
assert(daysToDayOfWeek(DayOfWeek.mon, DayOfWeek.fri) == 4);
assert(daysToDayOfWeek(DayOfWeek.mon, DayOfWeek.sat) == 5);
assert(daysToDayOfWeek(DayOfWeek.tue, DayOfWeek.sun) == 5);
assert(daysToDayOfWeek(DayOfWeek.tue, DayOfWeek.mon) == 6);
assert(daysToDayOfWeek(DayOfWeek.tue, DayOfWeek.tue) == 0);
assert(daysToDayOfWeek(DayOfWeek.tue, DayOfWeek.wed) == 1);
assert(daysToDayOfWeek(DayOfWeek.tue, DayOfWeek.thu) == 2);
assert(daysToDayOfWeek(DayOfWeek.tue, DayOfWeek.fri) == 3);
assert(daysToDayOfWeek(DayOfWeek.tue, DayOfWeek.sat) == 4);
assert(daysToDayOfWeek(DayOfWeek.wed, DayOfWeek.sun) == 4);
assert(daysToDayOfWeek(DayOfWeek.wed, DayOfWeek.mon) == 5);
assert(daysToDayOfWeek(DayOfWeek.wed, DayOfWeek.tue) == 6);
assert(daysToDayOfWeek(DayOfWeek.wed, DayOfWeek.wed) == 0);
assert(daysToDayOfWeek(DayOfWeek.wed, DayOfWeek.thu) == 1);
assert(daysToDayOfWeek(DayOfWeek.wed, DayOfWeek.fri) == 2);
assert(daysToDayOfWeek(DayOfWeek.wed, DayOfWeek.sat) == 3);
assert(daysToDayOfWeek(DayOfWeek.thu, DayOfWeek.sun) == 3);
assert(daysToDayOfWeek(DayOfWeek.thu, DayOfWeek.mon) == 4);
assert(daysToDayOfWeek(DayOfWeek.thu, DayOfWeek.tue) == 5);
assert(daysToDayOfWeek(DayOfWeek.thu, DayOfWeek.wed) == 6);
assert(daysToDayOfWeek(DayOfWeek.thu, DayOfWeek.thu) == 0);
assert(daysToDayOfWeek(DayOfWeek.thu, DayOfWeek.fri) == 1);
assert(daysToDayOfWeek(DayOfWeek.thu, DayOfWeek.sat) == 2);
assert(daysToDayOfWeek(DayOfWeek.fri, DayOfWeek.sun) == 2);
assert(daysToDayOfWeek(DayOfWeek.fri, DayOfWeek.mon) == 3);
assert(daysToDayOfWeek(DayOfWeek.fri, DayOfWeek.tue) == 4);
assert(daysToDayOfWeek(DayOfWeek.fri, DayOfWeek.wed) == 5);
assert(daysToDayOfWeek(DayOfWeek.fri, DayOfWeek.thu) == 6);
assert(daysToDayOfWeek(DayOfWeek.fri, DayOfWeek.fri) == 0);
assert(daysToDayOfWeek(DayOfWeek.fri, DayOfWeek.sat) == 1);
assert(daysToDayOfWeek(DayOfWeek.sat, DayOfWeek.sun) == 1);
assert(daysToDayOfWeek(DayOfWeek.sat, DayOfWeek.mon) == 2);
assert(daysToDayOfWeek(DayOfWeek.sat, DayOfWeek.tue) == 3);
assert(daysToDayOfWeek(DayOfWeek.sat, DayOfWeek.wed) == 4);
assert(daysToDayOfWeek(DayOfWeek.sat, DayOfWeek.thu) == 5);
assert(daysToDayOfWeek(DayOfWeek.sat, DayOfWeek.fri) == 6);
assert(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:
--------------------
{
auto mt = measureTime!((TickDuration a)
{ /+ do something when the scope is exited +/ });
// do something that needs to be timed
}
--------------------
which is functionally equivalent to
--------------------
{
auto sw = StopWatch(AutoStart.yes);
scope(exit)
{
TickDuration a = sw.peek();
/+ do something when the scope is exited +/
}
// do something that needs to be timed
}
--------------------
See_Also:
$(LREF benchmark)
+/
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);
}
}
// Verify Example.
unittest
{
{
auto mt = measureTime!((TickDuration a)
{ /+ do something when the scope is exited +/ });
// do something that needs to be timed
}
{
auto sw = StopWatch(AutoStart.yes);
scope(exit)
{
TickDuration a = sw.peek();
/+ do something when the scope is exited +/
}
// do something that needs to be timed
}
}
@safe unittest
{
import std.math : isNaN;
@safe static void func(TickDuration td)
{
assert(!td.to!("seconds", real)().isNaN());
}
auto mt = measureTime!(func)();
/+
with (measureTime!((a){assert(a.seconds);}))
{
// doSomething();
// @@@BUG@@@ doesn't work yet.
}
+/
}
unittest
{
import std.math : isNaN;
static void func(TickDuration td)
{
assert(!td.to!("seconds", real)().isNaN());
}
auto mt = measureTime!(func)();
/+
with (measureTime!((a){assert(a.seconds);}))
{
// doSomething();
// @@@BUG@@@ doesn't work yet.
}
+/
}
//Bug# 8450
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.
/+
Array of integers representing the last days of each month in a year.
+/
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.
+/
immutable int[13] lastDayLeap = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366];
/+
Array of the short (three letter) names of each month.
+/
immutable string[12] _monthNames = ["Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"];
//==============================================================================
// 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.
+/
long splitUnitsFromHNSecs(string units)(ref long hnsecs) @safe pure nothrow
if(validTimeUnits(units) &&
CmpTimeUnits!(units, "months") < 0)
{
immutable value = convert!("hnsecs", units)(hnsecs);
hnsecs -= convert!(units, "hnsecs")(value);
return value;
}
unittest
{
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.
+/
long getUnitsFromHNSecs(string units)(long hnsecs) @safe pure nothrow
if(validTimeUnits(units) &&
CmpTimeUnits!(units, "months") < 0)
{
return convert!("hnsecs", units)(hnsecs);
}
unittest
{
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.
+/
long removeUnitsFromHNSecs(string units)(long hnsecs) @safe pure nothrow
if(validTimeUnits(units) &&
CmpTimeUnits!(units, "months") < 0)
{
immutable value = convert!("hnsecs", units)(hnsecs);
return hnsecs - convert!(units, "hnsecs")(value);
}
unittest
{
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) @safe 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
{
//Test A.D.
assert(maxDay(1999, 1) == 31);
assert(maxDay(1999, 2) == 28);
assert(maxDay(1999, 3) == 31);
assert(maxDay(1999, 4) == 30);
assert(maxDay(1999, 5) == 31);
assert(maxDay(1999, 6) == 30);
assert(maxDay(1999, 7) == 31);
assert(maxDay(1999, 8) == 31);
assert(maxDay(1999, 9) == 30);
assert(maxDay(1999, 10) == 31);
assert(maxDay(1999, 11) == 30);
assert(maxDay(1999, 12) == 31);
assert(maxDay(2000, 1) == 31);
assert(maxDay(2000, 2) == 29);
assert(maxDay(2000, 3) == 31);
assert(maxDay(2000, 4) == 30);
assert(maxDay(2000, 5) == 31);
assert(maxDay(2000, 6) == 30);
assert(maxDay(2000, 7) == 31);
assert(maxDay(2000, 8) == 31);
assert(maxDay(2000, 9) == 30);
assert(maxDay(2000, 10) == 31);
assert(maxDay(2000, 11) == 30);
assert(maxDay(2000, 12) == 31);
//Test B.C.
assert(maxDay(-1999, 1) == 31);
assert(maxDay(-1999, 2) == 28);
assert(maxDay(-1999, 3) == 31);
assert(maxDay(-1999, 4) == 30);
assert(maxDay(-1999, 5) == 31);
assert(maxDay(-1999, 6) == 30);
assert(maxDay(-1999, 7) == 31);
assert(maxDay(-1999, 8) == 31);
assert(maxDay(-1999, 9) == 30);
assert(maxDay(-1999, 10) == 31);
assert(maxDay(-1999, 11) == 30);
assert(maxDay(-1999, 12) == 31);
assert(maxDay(-2000, 1) == 31);
assert(maxDay(-2000, 2) == 29);
assert(maxDay(-2000, 3) == 31);
assert(maxDay(-2000, 4) == 30);
assert(maxDay(-2000, 5) == 31);
assert(maxDay(-2000, 6) == 30);
assert(maxDay(-2000, 7) == 31);
assert(maxDay(-2000, 8) == 31);
assert(maxDay(-2000, 9) == 30);
assert(maxDay(-2000, 10) == 31);
assert(maxDay(-2000, 11) == 30);
assert(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) @safe 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
{
//Test A.D.
assert(getDayOfWeek(SysTime(Date(1, 1, 1)).dayOfGregorianCal) == DayOfWeek.mon);
assert(getDayOfWeek(SysTime(Date(1, 1, 2)).dayOfGregorianCal) == DayOfWeek.tue);
assert(getDayOfWeek(SysTime(Date(1, 1, 3)).dayOfGregorianCal) == DayOfWeek.wed);
assert(getDayOfWeek(SysTime(Date(1, 1, 4)).dayOfGregorianCal) == DayOfWeek.thu);
assert(getDayOfWeek(SysTime(Date(1, 1, 5)).dayOfGregorianCal) == DayOfWeek.fri);
assert(getDayOfWeek(SysTime(Date(1, 1, 6)).dayOfGregorianCal) == DayOfWeek.sat);
assert(getDayOfWeek(SysTime(Date(1, 1, 7)).dayOfGregorianCal) == DayOfWeek.sun);
assert(getDayOfWeek(SysTime(Date(1, 1, 8)).dayOfGregorianCal) == DayOfWeek.mon);
assert(getDayOfWeek(SysTime(Date(1, 1, 9)).dayOfGregorianCal) == DayOfWeek.tue);
assert(getDayOfWeek(SysTime(Date(2, 1, 1)).dayOfGregorianCal) == DayOfWeek.tue);
assert(getDayOfWeek(SysTime(Date(3, 1, 1)).dayOfGregorianCal) == DayOfWeek.wed);
assert(getDayOfWeek(SysTime(Date(4, 1, 1)).dayOfGregorianCal) == DayOfWeek.thu);
assert(getDayOfWeek(SysTime(Date(5, 1, 1)).dayOfGregorianCal) == DayOfWeek.sat);
assert(getDayOfWeek(SysTime(Date(2000, 1, 1)).dayOfGregorianCal) == DayOfWeek.sat);
assert(getDayOfWeek(SysTime(Date(2010, 8, 22)).dayOfGregorianCal) == DayOfWeek.sun);
assert(getDayOfWeek(SysTime(Date(2010, 8, 23)).dayOfGregorianCal) == DayOfWeek.mon);
assert(getDayOfWeek(SysTime(Date(2010, 8, 24)).dayOfGregorianCal) == DayOfWeek.tue);
assert(getDayOfWeek(SysTime(Date(2010, 8, 25)).dayOfGregorianCal) == DayOfWeek.wed);
assert(getDayOfWeek(SysTime(Date(2010, 8, 26)).dayOfGregorianCal) == DayOfWeek.thu);
assert(getDayOfWeek(SysTime(Date(2010, 8, 27)).dayOfGregorianCal) == DayOfWeek.fri);
assert(getDayOfWeek(SysTime(Date(2010, 8, 28)).dayOfGregorianCal) == DayOfWeek.sat);
assert(getDayOfWeek(SysTime(Date(2010, 8, 29)).dayOfGregorianCal) == DayOfWeek.sun);
//Test B.C.
assert(getDayOfWeek(SysTime(Date(0, 12, 31)).dayOfGregorianCal) == DayOfWeek.sun);
assert(getDayOfWeek(SysTime(Date(0, 12, 30)).dayOfGregorianCal) == DayOfWeek.sat);
assert(getDayOfWeek(SysTime(Date(0, 12, 29)).dayOfGregorianCal) == DayOfWeek.fri);
assert(getDayOfWeek(SysTime(Date(0, 12, 28)).dayOfGregorianCal) == DayOfWeek.thu);
assert(getDayOfWeek(SysTime(Date(0, 12, 27)).dayOfGregorianCal) == DayOfWeek.wed);
assert(getDayOfWeek(SysTime(Date(0, 12, 26)).dayOfGregorianCal) == DayOfWeek.tue);
assert(getDayOfWeek(SysTime(Date(0, 12, 25)).dayOfGregorianCal) == DayOfWeek.mon);
assert(getDayOfWeek(SysTime(Date(0, 12, 24)).dayOfGregorianCal) == DayOfWeek.sun);
assert(getDayOfWeek(SysTime(Date(0, 12, 23)).dayOfGregorianCal) == DayOfWeek.sat);
}
/+
Returns the string representation of the given month.
+/
string monthToString(Month month) @safe pure
{
import std.format : format;
assert(month >= Month.jan && month <= Month.dec, format("Invalid month: %s", month));
return _monthNames[month - Month.jan];
}
unittest
{
assert(monthToString(Month.jan) == "Jan");
assert(monthToString(Month.feb) == "Feb");
assert(monthToString(Month.mar) == "Mar");
assert(monthToString(Month.apr) == "Apr");
assert(monthToString(Month.may) == "May");
assert(monthToString(Month.jun) == "Jun");
assert(monthToString(Month.jul) == "Jul");
assert(monthToString(Month.aug) == "Aug");
assert(monthToString(Month.sep) == "Sep");
assert(monthToString(Month.oct) == "Oct");
assert(monthToString(Month.nov) == "Nov");
assert(monthToString(Month.dec) == "Dec");
}
/+
Returns the Month corresponding to the given string.
Params:
monthStr = The string representation of the month to get the Month for.
Throws:
$(LREF DateTimeException) if the given month is not a valid month string.
+/
Month monthFromString(string monthStr) @safe pure
{
import std.format : format;
switch(monthStr)
{
case "Jan":
return Month.jan;
case "Feb":
return Month.feb;
case "Mar":
return Month.mar;
case "Apr":
return Month.apr;
case "May":
return Month.may;
case "Jun":
return Month.jun;
case "Jul":
return Month.jul;
case "Aug":
return Month.aug;
case "Sep":
return Month.sep;
case "Oct":
return Month.oct;
case "Nov":
return Month.nov;
case "Dec":
return Month.dec;
default:
throw new DateTimeException(format("Invalid month %s", monthStr));
}
}
unittest
{
foreach(badStr; ["Ja", "Janu", "Januar", "Januarys", "JJanuary", "JANUARY",
"JAN", "january", "jaNuary", "jaN", "jaNuaRy", "jAn"])
{
scope(failure) writeln(badStr);
assertThrown!DateTimeException(monthFromString(badStr));
}
foreach(month; EnumMembers!Month)
{
scope(failure) writeln(month);
assert(monthFromString(monthToString(month)) == month);
}
}
/+
The time units which are one step smaller than the given units.
+/
template nextSmallerTimeUnits(string units)
if(validTimeUnits(units) &&
timeStrings.front != units)
{
import std.algorithm : countUntil;
enum nextSmallerTimeUnits = timeStrings[countUntil(timeStrings, units) - 1];
}
unittest
{
assert(nextSmallerTimeUnits!"years" == "months");
assert(nextSmallerTimeUnits!"months" == "weeks");
assert(nextSmallerTimeUnits!"weeks" == "days");
assert(nextSmallerTimeUnits!"days" == "hours");
assert(nextSmallerTimeUnits!"hours" == "minutes");
assert(nextSmallerTimeUnits!"minutes" == "seconds");
assert(nextSmallerTimeUnits!"seconds" == "msecs");
assert(nextSmallerTimeUnits!"msecs" == "usecs");
assert(nextSmallerTimeUnits!"usecs" == "hnsecs");
static assert(!__traits(compiles, nextSmallerTimeUnits!"hnsecs"));
}
/+
The time units which are one step larger than the given units.
+/
template nextLargerTimeUnits(string units)
if(validTimeUnits(units) &&
timeStrings.back != units)
{
import std.algorithm : countUntil;
enum nextLargerTimeUnits = timeStrings[countUntil(timeStrings, units) + 1];
}
unittest
{
assert(nextLargerTimeUnits!"hnsecs" == "usecs");
assert(nextLargerTimeUnits!"usecs" == "msecs");
assert(nextLargerTimeUnits!"msecs" == "seconds");
assert(nextLargerTimeUnits!"seconds" == "minutes");
assert(nextLargerTimeUnits!"minutes" == "hours");
assert(nextLargerTimeUnits!"hours" == "days");
assert(nextLargerTimeUnits!"days" == "weeks");
assert(nextLargerTimeUnits!"weeks" == "months");
assert(nextLargerTimeUnits!"months" == "years");
static assert(!__traits(compiles, nextLargerTimeUnits!"years"));
}
/+
Returns the given hnsecs as an ISO string of fractional seconds.
+/
static string fracSecsToISOString(int hnsecs) @safe pure nothrow
{
import std.format : format;
assert(hnsecs >= 0);
try
{
if(hnsecs == 0)
return "";
string isoString = format(".%07d", hnsecs);
while(isoString[$ - 1] == '0')
isoString.popBack();
return isoString;
}
catch(Exception e)
assert(0, "format() threw.");
}
unittest
{
assert(fracSecsToISOString(0) == "");
assert(fracSecsToISOString(1) == ".0000001");
assert(fracSecsToISOString(10) == ".000001");
assert(fracSecsToISOString(100) == ".00001");
assert(fracSecsToISOString(1000) == ".0001");
assert(fracSecsToISOString(10_000) == ".001");
assert(fracSecsToISOString(100_000) == ".01");
assert(fracSecsToISOString(1_000_000) == ".1");
assert(fracSecsToISOString(1_000_001) == ".1000001");
assert(fracSecsToISOString(1_001_001) == ".1001001");
assert(fracSecsToISOString(1_071_601) == ".1071601");
assert(fracSecsToISOString(1_271_641) == ".1271641");
assert(fracSecsToISOString(9_999_999) == ".9999999");
assert(fracSecsToISOString(9_999_990) == ".999999");
assert(fracSecsToISOString(9_999_900) == ".99999");
assert(fracSecsToISOString(9_999_000) == ".9999");
assert(fracSecsToISOString(9_990_000) == ".999");
assert(fracSecsToISOString(9_900_000) == ".99");
assert(fracSecsToISOString(9_000_000) == ".9");
assert(fracSecsToISOString(999) == ".0000999");
assert(fracSecsToISOString(9990) == ".000999");
assert(fracSecsToISOString(99_900) == ".00999");
assert(fracSecsToISOString(999_000) == ".0999");
}
/+
Returns a Duration corresponding to to the given ISO string of
fractional seconds.
+/
static Duration fracSecsFromISOString(S)(in S isoString) @trusted pure
if(isSomeString!S)
{
import std.ascii : isDigit;
import std.string : representation;
import std.conv : to;
import std.algorithm : all;
if(isoString.empty)
return Duration.zero;
auto str = isoString.representation;
enforce(str[0] == '.', new DateTimeException("Invalid ISO String"));
str.popFront();
enforce(!str.empty && str.length <= 7, new DateTimeException("Invalid ISO String"));
enforce(all!isDigit(str), new DateTimeException("Invalid ISO String"));
dchar[7] fullISOString = void;
foreach(i, ref dchar c; fullISOString)
{
if(i < str.length)
c = str[i];
else
c = '0';
}
return hnsecs(to!int(fullISOString[]));
}
unittest
{
static void testFSInvalid(string isoString)
{
fracSecsFromISOString(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"));
assert(fracSecsFromISOString("") == Duration.zero);
assert(fracSecsFromISOString(".0000001") == hnsecs(1));
assert(fracSecsFromISOString(".000001") == hnsecs(10));
assert(fracSecsFromISOString(".00001") == hnsecs(100));
assert(fracSecsFromISOString(".0001") == hnsecs(1000));
assert(fracSecsFromISOString(".001") == hnsecs(10_000));
assert(fracSecsFromISOString(".01") == hnsecs(100_000));
assert(fracSecsFromISOString(".1") == hnsecs(1_000_000));
assert(fracSecsFromISOString(".1000001") == hnsecs(1_000_001));
assert(fracSecsFromISOString(".1001001") == hnsecs(1_001_001));
assert(fracSecsFromISOString(".1071601") == hnsecs(1_071_601));
assert(fracSecsFromISOString(".1271641") == hnsecs(1_271_641));
assert(fracSecsFromISOString(".9999999") == hnsecs(9_999_999));
assert(fracSecsFromISOString(".9999990") == hnsecs(9_999_990));
assert(fracSecsFromISOString(".999999") == hnsecs(9_999_990));
assert(fracSecsFromISOString(".9999900") == hnsecs(9_999_900));
assert(fracSecsFromISOString(".99999") == hnsecs(9_999_900));
assert(fracSecsFromISOString(".9999000") == hnsecs(9_999_000));
assert(fracSecsFromISOString(".9999") == hnsecs(9_999_000));
assert(fracSecsFromISOString(".9990000") == hnsecs(9_990_000));
assert(fracSecsFromISOString(".999") == hnsecs(9_990_000));
assert(fracSecsFromISOString(".9900000") == hnsecs(9_900_000));
assert(fracSecsFromISOString(".9900") == hnsecs(9_900_000));
assert(fracSecsFromISOString(".99") == hnsecs(9_900_000));
assert(fracSecsFromISOString(".9000000") == hnsecs(9_000_000));
assert(fracSecsFromISOString(".9") == hnsecs(9_000_000));
assert(fracSecsFromISOString(".0000999") == hnsecs(999));
assert(fracSecsFromISOString(".0009990") == hnsecs(9990));
assert(fracSecsFromISOString(".000999") == hnsecs(9990));
assert(fracSecsFromISOString(".0099900") == hnsecs(99_900));
assert(fracSecsFromISOString(".00999") == hnsecs(99_900));
assert(fracSecsFromISOString(".0999000") == hnsecs(999_000));
assert(fracSecsFromISOString(".0999") == hnsecs(999_000));
}
/+
Strips what RFC 5322, section 3.2.2 refers to as CFWS from the left-hand
side of the given range (it strips comments delimited by $(D '(') and
$(D ')') as well as folding whitespace).
It is assumed that the given range contains the value of a header field and
no terminating CRLF for the line (though the CRLF for folding whitespace is
of course expected and stripped) and thus that the only case of CR or LF is
in folding whitespace.
If a comment does not terminate correctly (e.g. mismatched parens) or if the
the FWS is malformed, then the range will be empty when stripCWFS is done.
However, only minimal validation of the content is done (e.g. quoted pairs
within a comment aren't validated beyond \$LPAREN or \$RPAREN, because
they're inside a comment, and thus their value doesn't matter anyway). It's
only when the content does not conform to the grammar rules for FWS and thus
literally cannot be parsed that content is considered invalid, and an empty
range is returned.
Note that _stripCFWS is eager, not lazy. It does not create a new range.
Rather, it pops off the CFWS from the range and returns it.
+/
R _stripCFWS(R)(R range)
if(isRandomAccessRange!R && hasSlicing!R && hasLength!R &&
(is(Unqual!(ElementType!R) == char) || is(Unqual!(ElementType!R) == ubyte)))
{
immutable e = range.length;
outer: for(size_t i = 0; i < e; )
{
switch(range[i])
{
case ' ': case '\t':
{
++i;
break;
}
case '\r':
{
if(i + 2 < e && range[i + 1] == '\n' && (range[i + 2] == ' ' || range[i + 2] == '\t'))
{
i += 3;
break;
}
break outer;
}
case '\n':
{
if(i + 1 < e && (range[i + 1] == ' ' || range[i + 1] == '\t'))
{
i += 2;
break;
}
break outer;
}
case '(':
{
++i;
size_t commentLevel = 1;
while(i < e)
{
if(range[i] == '(')
++commentLevel;
else if(range[i] == ')')
{
++i;
if(--commentLevel == 0)
continue outer;
continue;
}
else if(range[i] == '\\')
{
if(++i == e)
break outer;
}
++i;
}
break outer;
}
default: return range[i .. e];
}
}
return range[e .. e];
}
unittest
{
import std.algorithm;
import std.string;
import std.typecons;
import std.typetuple;
foreach(cr; TypeTuple!(function(string a){return cast(ubyte[])a;},
function(string a){return map!(b => cast(char)b)(a.representation);}))
(){ // avoid slow optimizations for large functions @@@BUG@@@ 2396
scope(failure) writeln(typeof(cr).stringof);
assert(_stripCFWS(cr("")).empty);
assert(_stripCFWS(cr("\r")).empty);
assert(_stripCFWS(cr("\r\n")).empty);
assert(_stripCFWS(cr("\r\n ")).empty);
assert(_stripCFWS(cr(" \t\r\n")).empty);
assert(equal(_stripCFWS(cr(" \t\r\n hello")), cr("hello")));
assert(_stripCFWS(cr(" \t\r\nhello")).empty);
assert(_stripCFWS(cr(" \t\r\n\v")).empty);
assert(equal(_stripCFWS(cr("\v \t\r\n\v")), cr("\v \t\r\n\v")));
assert(_stripCFWS(cr("()")).empty);
assert(_stripCFWS(cr("(hello world)")).empty);
assert(_stripCFWS(cr("(hello world)(hello world)")).empty);
assert(_stripCFWS(cr("(hello world\r\n foo\r where's\nwaldo)")).empty);
assert(_stripCFWS(cr(" \t (hello \tworld\r\n foo\r where's\nwaldo)\t\t ")).empty);
assert(_stripCFWS(cr(" ")).empty);
assert(_stripCFWS(cr("\t\t\t")).empty);
assert(_stripCFWS(cr("\t \r\n\r \n")).empty);
assert(_stripCFWS(cr("(hello world) (can't find waldo) (he's lost)")).empty);
assert(_stripCFWS(cr("(hello\\) world) (can't \\(find waldo) (he's \\(\\)lost)")).empty);
assert(_stripCFWS(cr("(((((")).empty);
assert(_stripCFWS(cr("(((()))")).empty);
assert(_stripCFWS(cr("(((())))")).empty);
assert(equal(_stripCFWS(cr("(((()))))")), cr(")")));
assert(equal(_stripCFWS(cr(")))))")), cr(")))))")));
assert(equal(_stripCFWS(cr("()))))")), cr("))))")));
assert(equal(_stripCFWS(cr(" hello hello ")), cr("hello hello ")));
assert(equal(_stripCFWS(cr("\thello (world)")), cr("hello (world)")));
assert(equal(_stripCFWS(cr(" \r\n \\((\\)) foo")), cr("\\((\\)) foo")));
assert(equal(_stripCFWS(cr(" \r\n (\\((\\))) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" \r\n (\\(())) foo")), cr(") foo")));
assert(_stripCFWS(cr(" \r\n (((\\))) foo")).empty);
assert(_stripCFWS(cr("(hello)(hello)")).empty);
assert(_stripCFWS(cr(" \r\n (hello)\r\n (hello)")).empty);
assert(_stripCFWS(cr(" \r\n (hello) \r\n (hello) \r\n ")).empty);
assert(_stripCFWS(cr("\t\t\t\t(hello)\t\t\t\t(hello)\t\t\t\t")).empty);
assert(equal(_stripCFWS(cr(" \r\n (hello)\r\n (hello) \r\n hello")), cr("hello")));
assert(equal(_stripCFWS(cr(" \r\n (hello) \r\n (hello) \r\n hello")), cr("hello")));
assert(equal(_stripCFWS(cr("\t\r\n\t(hello)\r\n\t(hello)\t\r\n hello")), cr("hello")));
assert(equal(_stripCFWS(cr("\t\r\n\t(hello)\t\r\n\t(hello)\t\r\n hello")), cr("hello")));
assert(equal(_stripCFWS(cr(" \r\n (hello) \r\n \r\n (hello) \r\n hello")), cr("hello")));
assert(equal(_stripCFWS(cr(" \r\n (hello) \r\n (hello) \r\n \r\n hello")), cr("hello")));
assert(equal(_stripCFWS(cr(" \r\n \r\n (hello)\t\r\n (hello) \r\n hello")), cr("hello")));
assert(equal(_stripCFWS(cr(" \r\n\t\r\n\t(hello)\t\r\n (hello) \r\n hello")), cr("hello")));
assert(equal(_stripCFWS(cr(" (\r\n ( \r\n ) \r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" ( \r\n ( \r\n ) \r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" (\t\r\n ( \r\n ) \r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" (\r\n\t( \r\n ) \r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" ( \r\n (\t\r\n ) \r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" ( \r\n (\r\n ) \r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" ( \r\n (\r\n\t) \r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" ( \r\n ( \r\n) \r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" ( \r\n ( \r\n )\t\r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" ( \r\n ( \r\n )\r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" ( \r\n ( \r\n ) \r\n) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" ( \r\n ( \r\n ) \r\n\t) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" ( \r\n ( \r\n ) \r\n ) \r\n foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" ( \r\n ( \r\n ) \r\n )\t\r\n foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" ( \r\n ( \r\n ) \r\n )\r\n foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" ( \r\n \r\n ( \r\n \r\n ) \r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" ( \r\n \r\n ( \r\n \r\n ) \r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" (\t\r\n \r\n ( \r\n \r\n ) \r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" (\r\n \r\n\t( \r\n \r\n ) \r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" (\r\n \r\n( \r\n \r\n ) \r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" (\r\n \r\n ( \r\n \r\n\t) \r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" (\r\n \r\n ( \r\n \r\n )\t\r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" (\r\n \r\n ( \r\n \r\n )\r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" ( \r\n bar \r\n ( \r\n bar \r\n ) \r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" ( \r\n () \r\n ( \r\n () \r\n ) \r\n ) foo")), cr("foo")));
assert(equal(_stripCFWS(cr(" ( \r\n \\\\ \r\n ( \r\n \\\\ \r\n ) \r\n ) foo")), cr("foo")));
assert(_stripCFWS(cr("(hello)(hello)")).empty);
assert(_stripCFWS(cr(" \n (hello)\n (hello) \n ")).empty);
assert(_stripCFWS(cr(" \n (hello) \n (hello) \n ")).empty);
assert(equal(_stripCFWS(cr(" \n (hello)\n (hello) \n hello")), cr("hello")));
assert(equal(_stripCFWS(cr(" \n (hello) \n (hello) \n hello")), cr("hello")));
assert(equal(_stripCFWS(cr("\t\n\t(hello)\n\t(hello)\t\n hello")), cr("hello")));
assert(equal(_stripCFWS(cr("\t\n\t(hello)\t\n\t(hello)\t\n hello")), cr("hello")));
assert(equal(_stripCFWS(cr(" \n (hello) \n \n (hello) \n hello")), cr("hello")));
assert(equal(_stripCFWS(cr(" \n (hello) \n (hello) \n \n hello")), cr("hello")));
assert(equal(_stripCFWS(cr(" \n \n (hello)\t\n (hello) \n hello")), cr("hello")));
assert(equal(_stripCFWS(cr(" \n\t\n\t(hello)\t\n (hello) \n hello")), cr("hello")));
}();
}
// This is so that we don't have to worry about std.conv.to throwing. It also
// doesn't have to worry about quite as many cases as std.conv.to, since it
// doesn't have to worry about a sign on the value or about whether it fits.
T _convDigits(T, R)(R str)
if(isIntegral!T && isSigned!T) // The constraints on R were already covered by parseRFC822DateTime.
{
import std.ascii : isDigit;
assert(!str.empty);
T num = 0;
foreach(i; 0 .. str.length)
{
if(i != 0)
num *= 10;
if(!std.ascii.isDigit(str[i]))
return -1;
num += str[i] - '0';
}
return num;
}
unittest
{
import std.conv : to;
import std.range;
foreach(i; chain(iota(0, 101), [250, 999, 1000, 1001, 2345, 9999]))
{
scope(failure) writeln(i);
assert(_convDigits!int(to!string(i)) == i);
}
foreach(str; ["-42", "+42", "1a", "1 ", " ", " 42 "])
{
scope(failure) writeln(str);
assert(_convDigits!int(str) == -1);
}
}
/+
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(typeof(T.min) == Unqual!T);
}
unittest
{
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(typeof(T.max) == Unqual!T);
}
unittest
{
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
{
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
{
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
{
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));
}
version(unittest)
{
import std.typecons;
import std.algorithm;
//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;
Duration[] 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 = [0L, lt, ot];
auto diffAA = [0L : Rebindable!(immutable TimeZone)(UTC())];
diffAA[lt] = Rebindable!(immutable TimeZone)(LocalTime());
diffAA[ot] = Rebindable!(immutable TimeZone)(otherTZ);
sort(diffs);
testTZs = [diffAA[diffs[0]], diffAA[diffs[1]], diffAA[diffs[2]]];
testFracSecs = [Duration.zero, hnsecs(1), hnsecs(5007), 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);
}
}
}
}
unittest
{
/* Issue 6642 */
static assert(!hasUnsharedAliasing!Date);
static assert(!hasUnsharedAliasing!TimeOfDay);
static assert(!hasUnsharedAliasing!DateTime);
static assert(!hasUnsharedAliasing!SysTime);
}
// This script is for regenerating tzDatabaseNameToWindowsTZName and
// windowsTZNameToTZDatabaseName from
// http://unicode.org/cldr/data/common/supplemental/windowsZones.xml
/+
#!/bin/rdmd
import std.algorithm;
import std.array;
import std.conv;
import std.datetime;
import std.exception;
import std.path;
import std.stdio;
import std.string;
int main(string[] args)
{
if(args.length != 4 || args[1].baseName != "windowsZones.xml")
{
stderr.writeln("genTZs.d windowsZones.xml <nix2WinFile> <win2NixFile>");
return -1;
}
string[][string] win2Nix;
string[][string] nix2Win;
immutable f1 = `<mapZone other="`;
immutable f2 = `type="`;
auto file = File(args[1]);
foreach(line; file.byLine())
{
line = line.find(f1);
if(line.empty)
continue;
line = line[f1.length .. $];
auto next = line.find('"');
auto win = to!string(line[0 .. $ - next.length]);
line = next.find(f2);
line = line[f2.length .. $];
next = line.find('"');
auto nixes = to!string(line[0 .. $ - next.length]).split();
if(auto l = win in win2Nix)
*l ~= nixes;
else
win2Nix[win] = nixes;
foreach(nix; nixes)
{
if(auto w = nix in nix2Win)
*w ~= win;
else
nix2Win[nix] = [win];
}
}
foreach(nix; nix2Win.byKey())
{
auto wins = nix2Win[nix];
nix2Win[nix] = wins.sort().uniq().array();
}
foreach(win; win2Nix.byKey())
{
auto nixes = win2Nix[win];
win2Nix[win] = nixes.sort().uniq().array();
}
// AFAIK, there should be no cases of a TZ Database time zone converting to
// multiple windows time zones.
foreach(nix, wins; nix2Win)
enforce(wins.length == 1, format("%s -> %s", nix, wins));
// We'll try to eliminate multiples by favoring a conversion if it's already
// in Phobos, but if it's new, then the correct one will have to be chosen
// manually from the results.
string[] haveMultiple;
foreach(win, nixes; win2Nix)
{
if(nixes.length > 1)
haveMultiple ~= win;
}
bool[string] haveConflicts;
foreach(win; haveMultiple)
{
if(auto curr = windowsTZNameToTZDatabaseName(win))
{
if(auto other = curr in nix2Win)
{
if((*other)[0] == win)
{
win2Nix[win] = [curr];
continue;
}
}
}
haveConflicts[win] = true;
writefln("Warning: %s -> %s", win, win2Nix[win]);
}
string[] nix2WinLines = [
`string tzDatabaseNameToWindowsTZName(string tzName) @safe pure nothrow @nogc`,
`{`,
` switch(tzName)`,
` {`];
foreach(nix; nix2Win.keys.sort())
nix2WinLines ~= format(` case "%s": return "%s";`, nix, nix2Win[nix][0]);
nix2WinLines ~= [
` default: return null;`,
` }`,
`}`];
string[] win2NixLines = [
`string windowsTZNameToTZDatabaseName(string tzName) @safe pure nothrow @nogc`,
`{`,
` switch(tzName)`,
` {`];
foreach(win; win2Nix.keys.sort())
{
immutable hasMultiple = cast(bool)(win in haveConflicts);
foreach(nix; win2Nix[win])
win2NixLines ~= format(` case "%s": return "%s";%s`, win, nix, hasMultiple ? " FIXME" : "");
}
win2NixLines ~= [
` default: return null;`,
` }`,
`}`];
auto nix2WinFile = args[2];
std.file.write(nix2WinFile, nix2WinLines.join("\n"));
auto win2NixFile = args[3];
std.file.write(win2NixFile, win2NixLines.join("\n"));
return 0;
}
+/
|
D
|
/**
* Compiler implementation of the
* $(LINK2 http://www.dlang.org, D programming language).
*
* Copyright: Copyright (c) 1999-2017 by Digital Mars, 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: $(DMDSRC _hdrgen.d)
*/
module ddmd.hdrgen;
import core.stdc.ctype;
import core.stdc.stdio;
import core.stdc.string;
import ddmd.aggregate;
import ddmd.aliasthis;
import ddmd.arraytypes;
import ddmd.attrib;
import ddmd.complex;
import ddmd.cond;
import ddmd.ctfeexpr;
import ddmd.dclass;
import ddmd.declaration;
import ddmd.denum;
import ddmd.dimport;
import ddmd.dmodule;
import ddmd.doc;
import ddmd.dstruct;
import ddmd.dsymbol;
import ddmd.dtemplate;
import ddmd.dversion;
import ddmd.expression;
import ddmd.func;
import ddmd.globals;
import ddmd.id;
import ddmd.identifier;
import ddmd.init;
import ddmd.mtype;
import ddmd.nspace;
import ddmd.parse;
import ddmd.root.ctfloat;
import ddmd.root.outbuffer;
import ddmd.root.rootobject;
import ddmd.statement;
import ddmd.staticassert;
import ddmd.target;
import ddmd.tokens;
import ddmd.utils;
import ddmd.visitor;
struct HdrGenState
{
bool hdrgen; /// true if generating header file
bool ddoc; /// true if generating Ddoc file
bool fullDump; /// true if generating a full AST dump file
bool fullQual; /// fully qualify types when printing
int tpltMember;
int autoMember;
int forStmtInit;
}
enum TEST_EMIT_ALL = 0;
extern (C++) void genhdrfile(Module m)
{
OutBuffer buf;
buf.doindent = 1;
buf.printf("// D import file generated from '%s'", m.srcfile.toChars());
buf.writenl();
HdrGenState hgs;
hgs.hdrgen = true;
toCBuffer(m, &buf, &hgs);
// Transfer image to file
m.hdrfile.setbuffer(buf.data, buf.offset);
buf.extractData();
ensurePathToNameExists(Loc(), m.hdrfile.toChars());
writeFile(m.loc, m.hdrfile);
}
extern (C++) final class PrettyPrintVisitor : Visitor
{
alias visit = super.visit;
public:
OutBuffer* buf;
HdrGenState* hgs;
bool declstring; // set while declaring alias for string,wstring or dstring
EnumDeclaration inEnumDecl;
extern (D) this(OutBuffer* buf, HdrGenState* hgs)
{
this.buf = buf;
this.hgs = hgs;
}
override void visit(Statement s)
{
buf.printf("Statement::toCBuffer()");
buf.writenl();
assert(0);
}
override void visit(ErrorStatement s)
{
buf.printf("__error__");
buf.writenl();
}
override void visit(ExpStatement s)
{
if (s.exp && s.exp.op == TOKdeclaration)
{
// bypass visit(DeclarationExp)
(cast(DeclarationExp)s.exp).declaration.accept(this);
return;
}
if (s.exp)
s.exp.accept(this);
buf.writeByte(';');
if (!hgs.forStmtInit)
buf.writenl();
}
override void visit(CompileStatement s)
{
buf.writestring("mixin(");
s.exp.accept(this);
buf.writestring(");");
if (!hgs.forStmtInit)
buf.writenl();
}
override void visit(CompoundStatement s)
{
foreach (sx; *s.statements)
{
if (sx)
sx.accept(this);
}
}
override void visit(CompoundDeclarationStatement s)
{
bool anywritten = false;
foreach (sx; *s.statements)
{
auto ds = sx ? sx.isExpStatement() : null;
if (ds && ds.exp.op == TOKdeclaration)
{
auto d = (cast(DeclarationExp)ds.exp).declaration;
assert(d.isDeclaration());
if (auto v = d.isVarDeclaration())
visitVarDecl(v, anywritten);
else
d.accept(this);
anywritten = true;
}
}
buf.writeByte(';');
if (!hgs.forStmtInit)
buf.writenl();
}
override void visit(UnrolledLoopStatement s)
{
buf.writestring("/*unrolled*/ {");
buf.writenl();
buf.level++;
foreach (sx; *s.statements)
{
if (sx)
sx.accept(this);
}
buf.level--;
buf.writeByte('}');
buf.writenl();
}
override void visit(ScopeStatement s)
{
buf.writeByte('{');
buf.writenl();
buf.level++;
if (s.statement)
s.statement.accept(this);
buf.level--;
buf.writeByte('}');
buf.writenl();
}
override void visit(WhileStatement s)
{
buf.writestring("while (");
s.condition.accept(this);
buf.writeByte(')');
buf.writenl();
if (s._body)
s._body.accept(this);
}
override void visit(DoStatement s)
{
buf.writestring("do");
buf.writenl();
if (s._body)
s._body.accept(this);
buf.writestring("while (");
s.condition.accept(this);
buf.writestring(");");
buf.writenl();
}
override void visit(ForStatement s)
{
buf.writestring("for (");
if (s._init)
{
hgs.forStmtInit++;
s._init.accept(this);
hgs.forStmtInit--;
}
else
buf.writeByte(';');
if (s.condition)
{
buf.writeByte(' ');
s.condition.accept(this);
}
buf.writeByte(';');
if (s.increment)
{
buf.writeByte(' ');
s.increment.accept(this);
}
buf.writeByte(')');
buf.writenl();
buf.writeByte('{');
buf.writenl();
buf.level++;
if (s._body)
s._body.accept(this);
buf.level--;
buf.writeByte('}');
buf.writenl();
}
override void visit(ForeachStatement s)
{
buf.writestring(Token.toString(s.op));
buf.writestring(" (");
foreach (i, p; *s.parameters)
{
if (i)
buf.writestring(", ");
if (stcToBuffer(buf, p.storageClass))
buf.writeByte(' ');
if (p.type)
typeToBuffer(p.type, p.ident);
else
buf.writestring(p.ident.toChars());
}
buf.writestring("; ");
s.aggr.accept(this);
buf.writeByte(')');
buf.writenl();
buf.writeByte('{');
buf.writenl();
buf.level++;
if (s._body)
s._body.accept(this);
buf.level--;
buf.writeByte('}');
buf.writenl();
}
override void visit(ForeachRangeStatement s)
{
buf.writestring(Token.toString(s.op));
buf.writestring(" (");
if (s.prm.type)
typeToBuffer(s.prm.type, s.prm.ident);
else
buf.writestring(s.prm.ident.toChars());
buf.writestring("; ");
s.lwr.accept(this);
buf.writestring(" .. ");
s.upr.accept(this);
buf.writeByte(')');
buf.writenl();
buf.writeByte('{');
buf.writenl();
buf.level++;
if (s._body)
s._body.accept(this);
buf.level--;
buf.writeByte('}');
buf.writenl();
}
override void visit(IfStatement s)
{
buf.writestring("if (");
if (Parameter p = s.prm)
{
StorageClass stc = p.storageClass;
if (!p.type && !stc)
stc = STCauto;
if (stcToBuffer(buf, stc))
buf.writeByte(' ');
if (p.type)
typeToBuffer(p.type, p.ident);
else
buf.writestring(p.ident.toChars());
buf.writestring(" = ");
}
s.condition.accept(this);
buf.writeByte(')');
buf.writenl();
if (!s.ifbody.isScopeStatement())
buf.level++;
s.ifbody.accept(this);
if (!s.ifbody.isScopeStatement())
buf.level--;
if (s.elsebody)
{
buf.writestring("else");
if (!s.elsebody.isIfStatement)
{
buf.writenl();
}
else
{
buf.writeByte(' ');
}
if (!s.elsebody.isScopeStatement() && !s.elsebody.isIfStatement)
buf.level++;
s.elsebody.accept(this);
if (!s.elsebody.isScopeStatement() && !s.elsebody.isIfStatement)
buf.level--;
}
}
override void visit(ConditionalStatement s)
{
s.condition.accept(this);
buf.writenl();
buf.writeByte('{');
buf.writenl();
buf.level++;
if (s.ifbody)
s.ifbody.accept(this);
buf.level--;
buf.writeByte('}');
buf.writenl();
if (s.elsebody)
{
buf.writestring("else");
buf.writenl();
buf.writeByte('{');
buf.level++;
buf.writenl();
s.elsebody.accept(this);
buf.level--;
buf.writeByte('}');
}
buf.writenl();
}
override void visit(PragmaStatement s)
{
buf.writestring("pragma (");
buf.writestring(s.ident.toChars());
if (s.args && s.args.dim)
{
buf.writestring(", ");
argsToBuffer(s.args);
}
buf.writeByte(')');
if (s._body)
{
buf.writenl();
buf.writeByte('{');
buf.writenl();
buf.level++;
s._body.accept(this);
buf.level--;
buf.writeByte('}');
buf.writenl();
}
else
{
buf.writeByte(';');
buf.writenl();
}
}
override void visit(StaticAssertStatement s)
{
s.sa.accept(this);
}
override void visit(SwitchStatement s)
{
buf.writestring(s.isFinal ? "final switch (" : "switch (");
s.condition.accept(this);
buf.writeByte(')');
buf.writenl();
if (s._body)
{
if (!s._body.isScopeStatement())
{
buf.writeByte('{');
buf.writenl();
buf.level++;
s._body.accept(this);
buf.level--;
buf.writeByte('}');
buf.writenl();
}
else
{
s._body.accept(this);
}
}
}
override void visit(CaseStatement s)
{
buf.writestring("case ");
s.exp.accept(this);
buf.writeByte(':');
buf.writenl();
s.statement.accept(this);
}
override void visit(CaseRangeStatement s)
{
buf.writestring("case ");
s.first.accept(this);
buf.writestring(": .. case ");
s.last.accept(this);
buf.writeByte(':');
buf.writenl();
s.statement.accept(this);
}
override void visit(DefaultStatement s)
{
buf.writestring("default:");
buf.writenl();
s.statement.accept(this);
}
override void visit(GotoDefaultStatement s)
{
buf.writestring("goto default;");
buf.writenl();
}
override void visit(GotoCaseStatement s)
{
buf.writestring("goto case");
if (s.exp)
{
buf.writeByte(' ');
s.exp.accept(this);
}
buf.writeByte(';');
buf.writenl();
}
override void visit(SwitchErrorStatement s)
{
buf.writestring("SwitchErrorStatement::toCBuffer()");
buf.writenl();
}
override void visit(ReturnStatement s)
{
buf.printf("return ");
if (s.exp)
s.exp.accept(this);
buf.writeByte(';');
buf.writenl();
}
override void visit(BreakStatement s)
{
buf.writestring("break");
if (s.ident)
{
buf.writeByte(' ');
buf.writestring(s.ident.toChars());
}
buf.writeByte(';');
buf.writenl();
}
override void visit(ContinueStatement s)
{
buf.writestring("continue");
if (s.ident)
{
buf.writeByte(' ');
buf.writestring(s.ident.toChars());
}
buf.writeByte(';');
buf.writenl();
}
override void visit(SynchronizedStatement s)
{
buf.writestring("synchronized");
if (s.exp)
{
buf.writeByte('(');
s.exp.accept(this);
buf.writeByte(')');
}
if (s._body)
{
buf.writeByte(' ');
s._body.accept(this);
}
}
override void visit(WithStatement s)
{
buf.writestring("with (");
s.exp.accept(this);
buf.writestring(")");
buf.writenl();
if (s._body)
s._body.accept(this);
}
override void visit(TryCatchStatement s)
{
buf.writestring("try");
buf.writenl();
if (s._body)
s._body.accept(this);
foreach (c; *s.catches)
{
visit(c);
}
}
override void visit(TryFinallyStatement s)
{
buf.writestring("try");
buf.writenl();
buf.writeByte('{');
buf.writenl();
buf.level++;
s._body.accept(this);
buf.level--;
buf.writeByte('}');
buf.writenl();
buf.writestring("finally");
buf.writenl();
buf.writeByte('{');
buf.writenl();
buf.level++;
s.finalbody.accept(this);
buf.level--;
buf.writeByte('}');
buf.writenl();
}
override void visit(OnScopeStatement s)
{
buf.writestring(Token.toString(s.tok));
buf.writeByte(' ');
s.statement.accept(this);
}
override void visit(ThrowStatement s)
{
buf.printf("throw ");
s.exp.accept(this);
buf.writeByte(';');
buf.writenl();
}
override void visit(DebugStatement s)
{
if (s.statement)
{
s.statement.accept(this);
}
}
override void visit(GotoStatement s)
{
buf.writestring("goto ");
buf.writestring(s.ident.toChars());
buf.writeByte(';');
buf.writenl();
}
override void visit(LabelStatement s)
{
buf.writestring(s.ident.toChars());
buf.writeByte(':');
buf.writenl();
if (s.statement)
s.statement.accept(this);
}
override void visit(AsmStatement s)
{
buf.writestring("asm { ");
Token* t = s.tokens;
buf.level++;
while (t)
{
buf.writestring(t.toChars());
if (t.next &&
t.value != TOKmin &&
t.value != TOKcomma && t.next.value != TOKcomma &&
t.value != TOKlbracket && t.next.value != TOKlbracket &&
t.next.value != TOKrbracket &&
t.value != TOKlparen && t.next.value != TOKlparen &&
t.next.value != TOKrparen &&
t.value != TOKdot && t.next.value != TOKdot)
{
buf.writeByte(' ');
}
t = t.next;
}
buf.level--;
buf.writestring("; }");
buf.writenl();
}
override void visit(ImportStatement s)
{
foreach (imp; *s.imports)
{
imp.accept(this);
}
}
void visit(Catch c)
{
buf.writestring("catch");
if (c.type)
{
buf.writeByte('(');
typeToBuffer(c.type, c.ident);
buf.writeByte(')');
}
buf.writenl();
buf.writeByte('{');
buf.writenl();
buf.level++;
if (c.handler)
c.handler.accept(this);
buf.level--;
buf.writeByte('}');
buf.writenl();
}
////////////////////////////////////////////////////////////////////////////
/**************************************************
* An entry point to pretty-print type.
*/
void typeToBuffer(Type t, Identifier ident)
{
if (t.ty == Tfunction)
{
visitFuncIdentWithPrefix(cast(TypeFunction)t, ident, null, true);
return;
}
visitWithMask(t, 0);
if (ident)
{
buf.writeByte(' ');
buf.writestring(ident.toChars());
}
}
void visitWithMask(Type t, ubyte modMask)
{
// Tuples and functions don't use the type constructor syntax
if (modMask == t.mod || t.ty == Tfunction || t.ty == Ttuple)
{
t.accept(this);
}
else
{
ubyte m = t.mod & ~(t.mod & modMask);
if (m & MODshared)
{
MODtoBuffer(buf, MODshared);
buf.writeByte('(');
}
if (m & MODwild)
{
MODtoBuffer(buf, MODwild);
buf.writeByte('(');
}
if (m & (MODconst | MODimmutable))
{
MODtoBuffer(buf, m & (MODconst | MODimmutable));
buf.writeByte('(');
}
t.accept(this);
if (m & (MODconst | MODimmutable))
buf.writeByte(')');
if (m & MODwild)
buf.writeByte(')');
if (m & MODshared)
buf.writeByte(')');
}
}
override void visit(Type t)
{
printf("t = %p, ty = %d\n", t, t.ty);
assert(0);
}
override void visit(TypeError t)
{
buf.writestring("_error_");
}
override void visit(TypeBasic t)
{
//printf("TypeBasic::toCBuffer2(t.mod = %d)\n", t.mod);
buf.writestring(t.dstring);
}
override void visit(TypeVector t)
{
//printf("TypeVector::toCBuffer2(t.mod = %d)\n", t.mod);
buf.writestring("__vector(");
visitWithMask(t.basetype, t.mod);
buf.writestring(")");
}
override void visit(TypeSArray t)
{
visitWithMask(t.next, t.mod);
buf.writeByte('[');
sizeToBuffer(t.dim);
buf.writeByte(']');
}
override void visit(TypeDArray t)
{
Type ut = t.castMod(0);
if (declstring)
goto L1;
if (ut.equals(Type.tstring))
buf.writestring("string");
else if (ut.equals(Type.twstring))
buf.writestring("wstring");
else if (ut.equals(Type.tdstring))
buf.writestring("dstring");
else
{
L1:
visitWithMask(t.next, t.mod);
buf.writestring("[]");
}
}
override void visit(TypeAArray t)
{
visitWithMask(t.next, t.mod);
buf.writeByte('[');
visitWithMask(t.index, 0);
buf.writeByte(']');
}
override void visit(TypePointer t)
{
//printf("TypePointer::toCBuffer2() next = %d\n", t.next.ty);
if (t.next.ty == Tfunction)
visitFuncIdentWithPostfix(cast(TypeFunction)t.next, "function");
else
{
visitWithMask(t.next, t.mod);
buf.writeByte('*');
}
}
override void visit(TypeReference t)
{
visitWithMask(t.next, t.mod);
buf.writeByte('&');
}
override void visit(TypeFunction t)
{
//printf("TypeFunction::toCBuffer2() t = %p, ref = %d\n", t, t.isref);
visitFuncIdentWithPostfix(t, null);
}
// callback for TypeFunction::attributesApply
struct PrePostAppendStrings
{
OutBuffer* buf;
bool isPostfixStyle;
bool isCtor;
extern (C++) static int fp(void* param, const(char)* str)
{
PrePostAppendStrings* p = cast(PrePostAppendStrings*)param;
// don't write 'ref' for ctors
if (p.isCtor && strcmp(str, "ref") == 0)
return 0;
if (p.isPostfixStyle)
p.buf.writeByte(' ');
p.buf.writestring(str);
if (!p.isPostfixStyle)
p.buf.writeByte(' ');
return 0;
}
}
void visitFuncIdentWithPostfix(TypeFunction t, const(char)* ident)
{
if (t.inuse)
{
t.inuse = 2; // flag error to caller
return;
}
t.inuse++;
PrePostAppendStrings pas;
pas.buf = buf;
pas.isCtor = false;
pas.isPostfixStyle = true;
if (t.linkage > LINKd && hgs.ddoc != 1 && !hgs.hdrgen)
{
linkageToBuffer(buf, t.linkage);
buf.writeByte(' ');
}
if (t.next)
{
typeToBuffer(t.next, null);
if (ident)
buf.writeByte(' ');
}
else if (hgs.ddoc)
buf.writestring("auto ");
if (ident)
buf.writestring(ident);
parametersToBuffer(t.parameters, t.varargs);
/* Use postfix style for attributes
*/
if (t.mod)
{
buf.writeByte(' ');
MODtoBuffer(buf, t.mod);
}
t.attributesApply(&pas, &PrePostAppendStrings.fp);
t.inuse--;
}
void visitFuncIdentWithPrefix(TypeFunction t, Identifier ident, TemplateDeclaration td, bool isPostfixStyle)
{
if (t.inuse)
{
t.inuse = 2; // flag error to caller
return;
}
t.inuse++;
PrePostAppendStrings pas;
pas.buf = buf;
pas.isCtor = (ident == Id.ctor);
pas.isPostfixStyle = false;
/* Use 'storage class' (prefix) style for attributes
*/
if (t.mod)
{
MODtoBuffer(buf, t.mod);
buf.writeByte(' ');
}
t.attributesApply(&pas, &PrePostAppendStrings.fp);
if (t.linkage > LINKd && hgs.ddoc != 1 && !hgs.hdrgen)
{
linkageToBuffer(buf, t.linkage);
buf.writeByte(' ');
}
if (ident && ident.toHChars2() != ident.toChars())
{
// Don't print return type for ctor, dtor, unittest, etc
}
else if (t.next)
{
typeToBuffer(t.next, null);
if (ident)
buf.writeByte(' ');
}
else if (hgs.ddoc)
buf.writestring("auto ");
if (ident)
buf.writestring(ident.toHChars2());
if (td)
{
buf.writeByte('(');
foreach (i, p; *td.origParameters)
{
if (i)
buf.writestring(", ");
p.accept(this);
}
buf.writeByte(')');
}
parametersToBuffer(t.parameters, t.varargs);
t.inuse--;
}
override void visit(TypeDelegate t)
{
visitFuncIdentWithPostfix(cast(TypeFunction)t.next, "delegate");
}
void visitTypeQualifiedHelper(TypeQualified t)
{
foreach (id; t.idents)
{
if (id.dyncast() == DYNCAST.dsymbol)
{
buf.writeByte('.');
TemplateInstance ti = cast(TemplateInstance)id;
ti.accept(this);
}
else if (id.dyncast() == DYNCAST.expression)
{
buf.writeByte('[');
(cast(Expression)id).accept(this);
buf.writeByte(']');
}
else if (id.dyncast() == DYNCAST.type)
{
buf.writeByte('[');
(cast(Type)id).accept(this);
buf.writeByte(']');
}
else
{
buf.writeByte('.');
buf.writestring(id.toChars());
}
}
}
override void visit(TypeIdentifier t)
{
buf.writestring(t.ident.toChars());
visitTypeQualifiedHelper(t);
}
override void visit(TypeInstance t)
{
t.tempinst.accept(this);
visitTypeQualifiedHelper(t);
}
override void visit(TypeTypeof t)
{
buf.writestring("typeof(");
t.exp.accept(this);
buf.writeByte(')');
visitTypeQualifiedHelper(t);
}
override void visit(TypeReturn t)
{
buf.writestring("typeof(return)");
visitTypeQualifiedHelper(t);
}
override void visit(TypeEnum t)
{
buf.writestring(t.sym.toChars());
}
override void visit(TypeStruct t)
{
// https://issues.dlang.org/show_bug.cgi?id=13776
// Don't use ti.toAlias() to avoid forward reference error
// while printing messages.
TemplateInstance ti = t.sym.parent ? t.sym.parent.isTemplateInstance() : null;
if (ti && ti.aliasdecl == t.sym)
buf.writestring(hgs.fullQual ? ti.toPrettyChars() : ti.toChars());
else
buf.writestring(hgs.fullQual ? t.sym.toPrettyChars() : t.sym.toChars());
}
override void visit(TypeClass t)
{
// https://issues.dlang.org/show_bug.cgi?id=13776
// Don't use ti.toAlias() to avoid forward reference error
// while printing messages.
TemplateInstance ti = t.sym.parent.isTemplateInstance();
if (ti && ti.aliasdecl == t.sym)
buf.writestring(hgs.fullQual ? ti.toPrettyChars() : ti.toChars());
else
buf.writestring(hgs.fullQual ? t.sym.toPrettyChars() : t.sym.toChars());
}
override void visit(TypeTuple t)
{
parametersToBuffer(t.arguments, 0);
}
override void visit(TypeSlice t)
{
visitWithMask(t.next, t.mod);
buf.writeByte('[');
sizeToBuffer(t.lwr);
buf.writestring(" .. ");
sizeToBuffer(t.upr);
buf.writeByte(']');
}
override void visit(TypeNull t)
{
buf.writestring("typeof(null)");
}
////////////////////////////////////////////////////////////////////////////
override void visit(Dsymbol s)
{
buf.writestring(s.toChars());
}
override void visit(StaticAssert s)
{
buf.writestring(s.kind());
buf.writeByte('(');
s.exp.accept(this);
if (s.msg)
{
buf.writestring(", ");
s.msg.accept(this);
}
buf.writestring(");");
buf.writenl();
}
override void visit(DebugSymbol s)
{
buf.writestring("debug = ");
if (s.ident)
buf.writestring(s.ident.toChars());
else
buf.printf("%u", s.level);
buf.writestring(";");
buf.writenl();
}
override void visit(VersionSymbol s)
{
buf.writestring("version = ");
if (s.ident)
buf.writestring(s.ident.toChars());
else
buf.printf("%u", s.level);
buf.writestring(";");
buf.writenl();
}
override void visit(EnumMember em)
{
if (em.type)
typeToBuffer(em.type, em.ident);
else
buf.writestring(em.ident.toChars());
if (em.value)
{
buf.writestring(" = ");
em.value.accept(this);
}
}
override void visit(Import imp)
{
if (hgs.hdrgen && imp.id == Id.object)
return; // object is imported by default
if (imp.isstatic)
buf.writestring("static ");
buf.writestring("import ");
if (imp.aliasId)
{
buf.printf("%s = ", imp.aliasId.toChars());
}
if (imp.packages && imp.packages.dim)
{
foreach (const pid; *imp.packages)
{
buf.printf("%s.", pid.toChars());
}
}
buf.printf("%s", imp.id.toChars());
if (imp.names.dim)
{
buf.writestring(" : ");
foreach (const i, const name; imp.names)
{
if (i)
buf.writestring(", ");
const _alias = imp.aliases[i];
if (_alias)
buf.printf("%s = %s", _alias.toChars(), name.toChars());
else
buf.printf("%s", name.toChars());
}
}
buf.printf(";");
buf.writenl();
}
override void visit(AliasThis d)
{
buf.writestring("alias ");
buf.writestring(d.ident.toChars());
buf.writestring(" this;\n");
}
override void visit(AttribDeclaration d)
{
if (!d.decl)
{
buf.writeByte(';');
buf.writenl();
return;
}
if (d.decl.dim == 0)
buf.writestring("{}");
else if (hgs.hdrgen && d.decl.dim == 1 && (*d.decl)[0].isUnitTestDeclaration())
{
// hack for bugzilla 8081
buf.writestring("{}");
}
else if (d.decl.dim == 1)
{
(*d.decl)[0].accept(this);
return;
}
else
{
buf.writenl();
buf.writeByte('{');
buf.writenl();
buf.level++;
foreach (de; *d.decl)
de.accept(this);
buf.level--;
buf.writeByte('}');
}
buf.writenl();
}
override void visit(StorageClassDeclaration d)
{
if (stcToBuffer(buf, d.stc))
buf.writeByte(' ');
visit(cast(AttribDeclaration)d);
}
override void visit(DeprecatedDeclaration d)
{
buf.writestring("deprecated(");
d.msg.accept(this);
buf.writestring(") ");
visit(cast(AttribDeclaration)d);
}
override void visit(LinkDeclaration d)
{
const(char)* p;
switch (d.linkage)
{
case LINKd:
p = "D";
break;
case LINKc:
p = "C";
break;
case LINKcpp:
p = "C++";
break;
case LINKwindows:
p = "Windows";
break;
case LINKpascal:
p = "Pascal";
break;
case LINKobjc:
p = "Objective-C";
break;
default:
assert(0);
}
buf.writestring("extern (");
buf.writestring(p);
buf.writestring(") ");
visit(cast(AttribDeclaration)d);
}
override void visit(CPPMangleDeclaration d)
{
const(char)* p;
switch (d.cppmangle)
{
case CPPMANGLE.asClass:
p = "class";
break;
case CPPMANGLE.asStruct:
p = "struct";
break;
default:
assert(0);
}
buf.writestring("extern (C++, ");
buf.writestring(p);
buf.writestring(") ");
visit(cast(AttribDeclaration)d);
}
override void visit(ProtDeclaration d)
{
protectionToBuffer(buf, d.protection);
buf.writeByte(' ');
visit(cast(AttribDeclaration)d);
}
override void visit(AlignDeclaration d)
{
if (!d.ealign)
buf.printf("align ");
else
buf.printf("align (%s) ", d.ealign.toChars());
visit(cast(AttribDeclaration)d);
}
override void visit(AnonDeclaration d)
{
buf.printf(d.isunion ? "union" : "struct");
buf.writenl();
buf.writestring("{");
buf.writenl();
buf.level++;
if (d.decl)
{
foreach (de; *d.decl)
de.accept(this);
}
buf.level--;
buf.writestring("}");
buf.writenl();
}
override void visit(PragmaDeclaration d)
{
buf.printf("pragma (%s", d.ident.toChars());
if (d.args && d.args.dim)
{
buf.writestring(", ");
argsToBuffer(d.args);
}
buf.writeByte(')');
visit(cast(AttribDeclaration)d);
}
override void visit(ConditionalDeclaration d)
{
d.condition.accept(this);
if (d.decl || d.elsedecl)
{
buf.writenl();
buf.writeByte('{');
buf.writenl();
buf.level++;
if (d.decl)
{
foreach (de; *d.decl)
de.accept(this);
}
buf.level--;
buf.writeByte('}');
if (d.elsedecl)
{
buf.writenl();
buf.writestring("else");
buf.writenl();
buf.writeByte('{');
buf.writenl();
buf.level++;
foreach (de; *d.elsedecl)
de.accept(this);
buf.level--;
buf.writeByte('}');
}
}
else
buf.writeByte(':');
buf.writenl();
}
override void visit(CompileDeclaration d)
{
buf.writestring("mixin(");
d.exp.accept(this);
buf.writestring(");");
buf.writenl();
}
override void visit(UserAttributeDeclaration d)
{
buf.writestring("@(");
argsToBuffer(d.atts);
buf.writeByte(')');
visit(cast(AttribDeclaration)d);
}
override void visit(TemplateDeclaration d)
{
version (none)
{
// Should handle template functions for doc generation
if (onemember && onemember.isFuncDeclaration())
buf.writestring("foo ");
}
if ((hgs.hdrgen || hgs.fullDump) && visitEponymousMember(d))
return;
if (hgs.ddoc)
buf.writestring(d.kind());
else
buf.writestring("template");
buf.writeByte(' ');
buf.writestring(d.ident.toChars());
buf.writeByte('(');
visitTemplateParameters(hgs.ddoc ? d.origParameters : d.parameters);
buf.writeByte(')');
visitTemplateConstraint(d.constraint);
if (hgs.hdrgen || hgs.fullDump)
{
hgs.tpltMember++;
buf.writenl();
buf.writeByte('{');
buf.writenl();
buf.level++;
foreach (s; *d.members)
s.accept(this);
buf.level--;
buf.writeByte('}');
buf.writenl();
hgs.tpltMember--;
}
}
bool visitEponymousMember(TemplateDeclaration d)
{
if (!d.members || d.members.dim != 1)
return false;
Dsymbol onemember = (*d.members)[0];
if (onemember.ident != d.ident)
return false;
if (FuncDeclaration fd = onemember.isFuncDeclaration())
{
assert(fd.type);
if (stcToBuffer(buf, fd.storage_class))
buf.writeByte(' ');
functionToBufferFull(cast(TypeFunction)fd.type, buf, d.ident, hgs, d);
visitTemplateConstraint(d.constraint);
hgs.tpltMember++;
bodyToBuffer(fd);
hgs.tpltMember--;
return true;
}
if (AggregateDeclaration ad = onemember.isAggregateDeclaration())
{
buf.writestring(ad.kind());
buf.writeByte(' ');
buf.writestring(ad.ident.toChars());
buf.writeByte('(');
visitTemplateParameters(hgs.ddoc ? d.origParameters : d.parameters);
buf.writeByte(')');
visitTemplateConstraint(d.constraint);
visitBaseClasses(ad.isClassDeclaration());
hgs.tpltMember++;
if (ad.members)
{
buf.writenl();
buf.writeByte('{');
buf.writenl();
buf.level++;
foreach (s; *ad.members)
s.accept(this);
buf.level--;
buf.writeByte('}');
}
else
buf.writeByte(';');
buf.writenl();
hgs.tpltMember--;
return true;
}
if (VarDeclaration vd = onemember.isVarDeclaration())
{
if (d.constraint)
return false;
if (stcToBuffer(buf, vd.storage_class))
buf.writeByte(' ');
if (vd.type)
typeToBuffer(vd.type, vd.ident);
else
buf.writestring(vd.ident.toChars());
buf.writeByte('(');
visitTemplateParameters(hgs.ddoc ? d.origParameters : d.parameters);
buf.writeByte(')');
if (vd._init)
{
buf.writestring(" = ");
ExpInitializer ie = vd._init.isExpInitializer();
if (ie && (ie.exp.op == TOKconstruct || ie.exp.op == TOKblit))
(cast(AssignExp)ie.exp).e2.accept(this);
else
vd._init.accept(this);
}
buf.writeByte(';');
buf.writenl();
return true;
}
return false;
}
void visitTemplateParameters(TemplateParameters* parameters)
{
if (!parameters || !parameters.dim)
return;
foreach (i, p; *parameters)
{
if (i)
buf.writestring(", ");
p.accept(this);
}
}
void visitTemplateConstraint(Expression constraint)
{
if (!constraint)
return;
buf.writestring(" if (");
constraint.accept(this);
buf.writeByte(')');
}
override void visit(TemplateInstance ti)
{
buf.writestring(ti.name.toChars());
tiargsToBuffer(ti);
if (hgs.fullDump)
{
buf.writenl();
dumpTemplateInstance(ti);
}
}
override void visit(TemplateMixin tm)
{
buf.writestring("mixin ");
typeToBuffer(tm.tqual, null);
tiargsToBuffer(tm);
if (tm.ident && memcmp(tm.ident.toChars(), cast(const(char)*)"__mixin", 7) != 0)
{
buf.writeByte(' ');
buf.writestring(tm.ident.toChars());
}
buf.writeByte(';');
buf.writenl();
if (hgs.fullDump)
dumpTemplateInstance(tm);
}
void dumpTemplateInstance(TemplateInstance ti)
{
buf.writeByte('{');
buf.writenl();
buf.level++;
if (ti.aliasdecl)
{
ti.aliasdecl.accept(this);
buf.writenl();
}
else if (ti.members)
{
foreach(m;*ti.members)
m.accept(this);
}
buf.level--;
buf.writeByte('}');
buf.writenl();
}
void tiargsToBuffer(TemplateInstance ti)
{
buf.writeByte('!');
if (ti.nest)
{
buf.writestring("(...)");
return;
}
if (!ti.tiargs)
{
buf.writestring("()");
return;
}
if (ti.tiargs.dim == 1)
{
RootObject oarg = (*ti.tiargs)[0];
if (Type t = isType(oarg))
{
if (t.equals(Type.tstring) || t.equals(Type.twstring) || t.equals(Type.tdstring) || t.mod == 0 && (t.isTypeBasic() || t.ty == Tident && (cast(TypeIdentifier)t).idents.dim == 0))
{
buf.writestring(t.toChars());
return;
}
}
else if (Expression e = isExpression(oarg))
{
if (e.op == TOKint64 || e.op == TOKfloat64 || e.op == TOKnull || e.op == TOKstring || e.op == TOKthis)
{
buf.writestring(e.toChars());
return;
}
}
}
buf.writeByte('(');
ti.nest++;
foreach (i, arg; *ti.tiargs)
{
if (i)
buf.writestring(", ");
objectToBuffer(arg);
}
ti.nest--;
buf.writeByte(')');
}
/****************************************
* This makes a 'pretty' version of the template arguments.
* It's analogous to genIdent() which makes a mangled version.
*/
void objectToBuffer(RootObject oarg)
{
//printf("objectToBuffer()\n");
/* The logic of this should match what genIdent() does. The _dynamic_cast()
* function relies on all the pretty strings to be unique for different classes
* See https://issues.dlang.org/show_bug.cgi?id=7375
* Perhaps it would be better to demangle what genIdent() does.
*/
if (auto t = isType(oarg))
{
//printf("\tt: %s ty = %d\n", t.toChars(), t.ty);
typeToBuffer(t, null);
}
else if (auto e = isExpression(oarg))
{
if (e.op == TOKvar)
e = e.optimize(WANTvalue); // added to fix https://issues.dlang.org/show_bug.cgi?id=7375
e.accept(this);
}
else if (Dsymbol s = isDsymbol(oarg))
{
const p = s.ident ? s.ident.toChars() : s.toChars();
buf.writestring(p);
}
else if (auto v = isTuple(oarg))
{
auto args = &v.objects;
foreach (i, arg; *args)
{
if (i)
buf.writestring(", ");
objectToBuffer(arg);
}
}
else if (!oarg)
{
buf.writestring("NULL");
}
else
{
debug
{
printf("bad Object = %p\n", oarg);
}
assert(0);
}
}
override void visit(EnumDeclaration d)
{
auto oldInEnumDecl = inEnumDecl;
scope(exit) inEnumDecl = oldInEnumDecl;
inEnumDecl = d;
buf.writestring("enum ");
if (d.ident)
{
buf.writestring(d.ident.toChars());
buf.writeByte(' ');
}
if (d.memtype)
{
buf.writestring(": ");
typeToBuffer(d.memtype, null);
}
if (!d.members)
{
buf.writeByte(';');
buf.writenl();
return;
}
buf.writenl();
buf.writeByte('{');
buf.writenl();
buf.level++;
foreach (em; *d.members)
{
if (!em)
continue;
em.accept(this);
buf.writeByte(',');
buf.writenl();
}
buf.level--;
buf.writeByte('}');
buf.writenl();
}
override void visit(Nspace d)
{
buf.writestring("extern (C++, ");
buf.writestring(d.ident.toChars());
buf.writeByte(')');
buf.writenl();
buf.writeByte('{');
buf.writenl();
buf.level++;
foreach (s; *d.members)
s.accept(this);
buf.level--;
buf.writeByte('}');
buf.writenl();
}
override void visit(StructDeclaration d)
{
buf.printf("%s ", d.kind());
if (!d.isAnonymous())
buf.writestring(d.toChars());
if (!d.members)
{
buf.writeByte(';');
buf.writenl();
return;
}
buf.writenl();
buf.writeByte('{');
buf.writenl();
buf.level++;
foreach (s; *d.members)
s.accept(this);
buf.level--;
buf.writeByte('}');
buf.writenl();
}
override void visit(ClassDeclaration d)
{
if (!d.isAnonymous())
{
buf.writestring(d.kind());
buf.writeByte(' ');
buf.writestring(d.ident.toChars());
}
visitBaseClasses(d);
if (d.members)
{
buf.writenl();
buf.writeByte('{');
buf.writenl();
buf.level++;
foreach (s; *d.members)
s.accept(this);
buf.level--;
buf.writeByte('}');
}
else
buf.writeByte(';');
buf.writenl();
}
void visitBaseClasses(ClassDeclaration d)
{
if (!d || !d.baseclasses.dim)
return;
buf.writestring(" : ");
foreach (i, b; *d.baseclasses)
{
if (i)
buf.writestring(", ");
typeToBuffer(b.type, null);
}
}
override void visit(AliasDeclaration d)
{
buf.writestring("alias ");
if (d.aliassym)
{
buf.writestring(d.ident.toChars());
buf.writestring(" = ");
if (stcToBuffer(buf, d.storage_class))
buf.writeByte(' ');
d.aliassym.accept(this);
}
else if (d.type.ty == Tfunction)
{
if (stcToBuffer(buf, d.storage_class))
buf.writeByte(' ');
typeToBuffer(d.type, d.ident);
}
else
{
declstring = (d.ident == Id.string || d.ident == Id.wstring || d.ident == Id.dstring);
buf.writestring(d.ident.toChars());
buf.writestring(" = ");
if (stcToBuffer(buf, d.storage_class))
buf.writeByte(' ');
typeToBuffer(d.type, null);
declstring = false;
}
buf.writeByte(';');
buf.writenl();
}
override void visit(VarDeclaration d)
{
visitVarDecl(d, false);
buf.writeByte(';');
buf.writenl();
}
void visitVarDecl(VarDeclaration v, bool anywritten)
{
if (anywritten)
{
buf.writestring(", ");
buf.writestring(v.ident.toChars());
}
else
{
if (stcToBuffer(buf, v.storage_class))
buf.writeByte(' ');
if (v.type)
typeToBuffer(v.type, v.ident);
else
buf.writestring(v.ident.toChars());
}
if (v._init)
{
buf.writestring(" = ");
auto ie = v._init.isExpInitializer();
if (ie && (ie.exp.op == TOKconstruct || ie.exp.op == TOKblit))
(cast(AssignExp)ie.exp).e2.accept(this);
else
v._init.accept(this);
}
}
override void visit(FuncDeclaration f)
{
//printf("FuncDeclaration::toCBuffer() '%s'\n", f.toChars());
if (stcToBuffer(buf, f.storage_class))
buf.writeByte(' ');
auto tf = cast(TypeFunction)f.type;
typeToBuffer(tf, f.ident);
if (hgs.hdrgen)
{
// if the return type is missing (e.g. ref functions or auto)
if (!tf.next || f.storage_class & STCauto)
{
hgs.autoMember++;
bodyToBuffer(f);
hgs.autoMember--;
}
else if (hgs.tpltMember == 0 && global.params.hdrStripPlainFunctions)
{
buf.writeByte(';');
buf.writenl();
}
else
bodyToBuffer(f);
}
else
bodyToBuffer(f);
}
void bodyToBuffer(FuncDeclaration f)
{
if (!f.fbody || (hgs.hdrgen && global.params.hdrStripPlainFunctions && !hgs.autoMember && !hgs.tpltMember))
{
buf.writeByte(';');
buf.writenl();
return;
}
int savetlpt = hgs.tpltMember;
int saveauto = hgs.autoMember;
hgs.tpltMember = 0;
hgs.autoMember = 0;
buf.writenl();
// in{}
if (f.frequire)
{
buf.writestring("in");
buf.writenl();
f.frequire.accept(this);
}
// out{}
if (f.fensure)
{
buf.writestring("out");
if (f.outId)
{
buf.writeByte('(');
buf.writestring(f.outId.toChars());
buf.writeByte(')');
}
buf.writenl();
f.fensure.accept(this);
}
if (f.frequire || f.fensure)
{
buf.writestring("body");
buf.writenl();
}
buf.writeByte('{');
buf.writenl();
buf.level++;
f.fbody.accept(this);
buf.level--;
buf.writeByte('}');
buf.writenl();
hgs.tpltMember = savetlpt;
hgs.autoMember = saveauto;
}
override void visit(FuncLiteralDeclaration f)
{
if (f.type.ty == Terror)
{
buf.writestring("__error");
return;
}
if (f.tok != TOKreserved)
{
buf.writestring(f.kind());
buf.writeByte(' ');
}
TypeFunction tf = cast(TypeFunction)f.type;
// Don't print tf.mod, tf.trust, and tf.linkage
if (!f.inferRetType && tf.next)
typeToBuffer(tf.next, null);
parametersToBuffer(tf.parameters, tf.varargs);
CompoundStatement cs = f.fbody.isCompoundStatement();
Statement s1;
if (f.semanticRun >= PASSsemantic3done && cs)
{
s1 = (*cs.statements)[cs.statements.dim - 1];
}
else
s1 = !cs ? f.fbody : null;
ReturnStatement rs = s1 ? s1.isReturnStatement() : null;
if (rs && rs.exp)
{
buf.writestring(" => ");
rs.exp.accept(this);
}
else
{
hgs.tpltMember++;
bodyToBuffer(f);
hgs.tpltMember--;
}
}
override void visit(PostBlitDeclaration d)
{
if (stcToBuffer(buf, d.storage_class))
buf.writeByte(' ');
buf.writestring("this(this)");
bodyToBuffer(d);
}
override void visit(DtorDeclaration d)
{
if (d.storage_class & STCtrusted)
buf.writestring("@trusted ");
if (d.storage_class & STCsafe)
buf.writestring("@safe ");
if (d.storage_class & STCnogc)
buf.writestring("@nogc ");
if (d.storage_class & STCdisable)
buf.writestring("@disable ");
buf.writestring("~this()");
bodyToBuffer(d);
}
override void visit(StaticCtorDeclaration d)
{
if (stcToBuffer(buf, d.storage_class & ~STCstatic))
buf.writeByte(' ');
if (d.isSharedStaticCtorDeclaration())
buf.writestring("shared ");
buf.writestring("static this()");
if (hgs.hdrgen && !hgs.tpltMember)
{
buf.writeByte(';');
buf.writenl();
}
else
bodyToBuffer(d);
}
override void visit(StaticDtorDeclaration d)
{
if (hgs.hdrgen)
return;
if (stcToBuffer(buf, d.storage_class & ~STCstatic))
buf.writeByte(' ');
if (d.isSharedStaticDtorDeclaration())
buf.writestring("shared ");
buf.writestring("static ~this()");
bodyToBuffer(d);
}
override void visit(InvariantDeclaration d)
{
if (hgs.hdrgen)
return;
if (stcToBuffer(buf, d.storage_class))
buf.writeByte(' ');
buf.writestring("invariant");
bodyToBuffer(d);
}
override void visit(UnitTestDeclaration d)
{
if (hgs.hdrgen)
return;
if (stcToBuffer(buf, d.storage_class))
buf.writeByte(' ');
buf.writestring("unittest");
bodyToBuffer(d);
}
override void visit(NewDeclaration d)
{
if (stcToBuffer(buf, d.storage_class & ~STCstatic))
buf.writeByte(' ');
buf.writestring("new");
parametersToBuffer(d.parameters, d.varargs);
bodyToBuffer(d);
}
override void visit(DeleteDeclaration d)
{
if (stcToBuffer(buf, d.storage_class & ~STCstatic))
buf.writeByte(' ');
buf.writestring("delete");
parametersToBuffer(d.parameters, 0);
bodyToBuffer(d);
}
////////////////////////////////////////////////////////////////////////////
override void visit(ErrorInitializer iz)
{
buf.writestring("__error__");
}
override void visit(VoidInitializer iz)
{
buf.writestring("void");
}
override void visit(StructInitializer si)
{
//printf("StructInitializer::toCBuffer()\n");
buf.writeByte('{');
foreach (i, const id; si.field)
{
if (i)
buf.writestring(", ");
if (id)
{
buf.writestring(id.toChars());
buf.writeByte(':');
}
if (auto iz = si.value[i])
iz.accept(this);
}
buf.writeByte('}');
}
override void visit(ArrayInitializer ai)
{
buf.writeByte('[');
foreach (i, ex; ai.index)
{
if (i)
buf.writestring(", ");
if (ex)
{
ex.accept(this);
buf.writeByte(':');
}
if (auto iz = ai.value[i])
iz.accept(this);
}
buf.writeByte(']');
}
override void visit(ExpInitializer ei)
{
ei.exp.accept(this);
}
////////////////////////////////////////////////////////////////////////////
/**************************************************
* Write out argument list to buf.
*/
void argsToBuffer(Expressions* expressions, Expression basis = null)
{
if (!expressions || !expressions.dim)
return;
version (all)
{
foreach (i, el; *expressions)
{
if (i)
buf.writestring(", ");
if (!el)
el = basis;
if (el)
expToBuffer(el, PREC.assign);
}
}
else
{
// Sparse style formatting, for debug use only
// [0..dim: basis, 1: e1, 5: e5]
if (basis)
{
buf.printf("0..%llu: ", cast(ulong)expressions.dim);
expToBuffer(basis, PREC.assign);
}
foreach (i, el; *expressions)
{
if (el)
{
if (basis)
buf.printf(", %llu: ", cast(ulong)i);
else if (i)
buf.writestring(", ");
expToBuffer(el, PREC.assign);
}
}
}
}
void sizeToBuffer(Expression e)
{
if (e.type == Type.tsize_t)
{
Expression ex = (e.op == TOKcast ? (cast(CastExp)e).e1 : e);
ex = ex.optimize(WANTvalue);
dinteger_t uval = ex.op == TOKint64 ? ex.toInteger() : cast(dinteger_t)-1;
if (cast(sinteger_t)uval >= 0)
{
dinteger_t sizemax;
if (Target.ptrsize == 4)
sizemax = 0xFFFFFFFFU;
else if (Target.ptrsize == 8)
sizemax = 0xFFFFFFFFFFFFFFFFUL;
else
assert(0);
if (uval <= sizemax && uval <= 0x7FFFFFFFFFFFFFFFUL)
{
buf.printf("%llu", uval);
return;
}
}
}
expToBuffer(e, PREC.assign);
}
/**************************************************
* Write expression out to buf, but wrap it
* in ( ) if its precedence is less than pr.
*/
void expToBuffer(Expression e, PREC pr)
{
debug
{
if (precedence[e.op] == PREC.zero)
printf("precedence not defined for token '%s'\n", Token.toChars(e.op));
}
assert(precedence[e.op] != PREC.zero);
assert(pr != PREC.zero);
//if (precedence[e.op] == 0) e.print();
/* Despite precedence, we don't allow a<b<c expressions.
* They must be parenthesized.
*/
if (precedence[e.op] < pr || (pr == PREC.rel && precedence[e.op] == pr))
{
buf.writeByte('(');
e.accept(this);
buf.writeByte(')');
}
else
e.accept(this);
}
override void visit(Expression e)
{
buf.writestring(Token.toString(e.op));
}
override void visit(IntegerExp e)
{
dinteger_t v = e.toInteger();
if (e.type)
{
Type t = e.type;
L1:
switch (t.ty)
{
case Tenum:
{
TypeEnum te = cast(TypeEnum)t;
if (hgs.fullDump)
{
auto sym = te.sym;
if (inEnumDecl != sym) foreach(i;0 .. sym.members.dim)
{
EnumMember em = cast(EnumMember) (*sym.members)[i];
if (em.value.toInteger == v)
{
buf.printf("%s.%s", sym.toChars(), em.ident.toChars());
return ;
}
}
//assert(0, "We could not find the EmumMember");// for some reason it won't append char* ~ e.toChars() ~ " in " ~ sym.toChars() );
}
buf.printf("cast(%s)", te.sym.toChars());
t = te.sym.memtype;
goto L1;
}
case Twchar:
// BUG: need to cast(wchar)
case Tdchar:
// BUG: need to cast(dchar)
if (cast(uinteger_t)v > 0xFF)
{
buf.printf("'\\U%08x'", v);
break;
}
goto case;
case Tchar:
{
size_t o = buf.offset;
if (v == '\'')
buf.writestring("'\\''");
else if (isprint(cast(int)v) && v != '\\')
buf.printf("'%c'", cast(int)v);
else
buf.printf("'\\x%02x'", cast(int)v);
if (hgs.ddoc)
escapeDdocString(buf, o);
break;
}
case Tint8:
buf.writestring("cast(byte)");
goto L2;
case Tint16:
buf.writestring("cast(short)");
goto L2;
case Tint32:
L2:
buf.printf("%d", cast(int)v);
break;
case Tuns8:
buf.writestring("cast(ubyte)");
goto L3;
case Tuns16:
buf.writestring("cast(ushort)");
goto L3;
case Tuns32:
L3:
buf.printf("%uu", cast(uint)v);
break;
case Tint64:
buf.printf("%lldL", v);
break;
case Tuns64:
L4:
buf.printf("%lluLU", v);
break;
case Tbool:
buf.writestring(v ? "true" : "false");
break;
case Tpointer:
buf.writestring("cast(");
buf.writestring(t.toChars());
buf.writeByte(')');
if (Target.ptrsize == 4)
goto L3;
else if (Target.ptrsize == 8)
goto L4;
else
assert(0);
default:
/* This can happen if errors, such as
* the type is painted on like in fromConstInitializer().
*/
if (!global.errors)
{
debug
{
t.print();
}
assert(0);
}
break;
}
}
else if (v & 0x8000000000000000L)
buf.printf("0x%llx", v);
else
buf.printf("%lld", v);
}
override void visit(ErrorExp e)
{
buf.writestring("__error");
}
void floatToBuffer(Type type, real_t value)
{
/** sizeof(value)*3 is because each byte of mantissa is max
of 256 (3 characters). The string will be "-M.MMMMe-4932".
(ie, 8 chars more than mantissa). Plus one for trailing \0.
Plus one for rounding. */
const(size_t) BUFFER_LEN = value.sizeof * 3 + 8 + 1 + 1;
char[BUFFER_LEN] buffer;
CTFloat.sprint(buffer.ptr, 'g', value);
assert(strlen(buffer.ptr) < BUFFER_LEN);
if (hgs.hdrgen)
{
real_t r = CTFloat.parse(buffer.ptr);
if (r != value) // if exact duplication
CTFloat.sprint(buffer.ptr, 'a', value);
}
buf.writestring(buffer.ptr);
if (type)
{
Type t = type.toBasetype();
switch (t.ty)
{
case Tfloat32:
case Timaginary32:
case Tcomplex32:
buf.writeByte('F');
break;
case Tfloat80:
case Timaginary80:
case Tcomplex80:
buf.writeByte('L');
break;
default:
break;
}
if (t.isimaginary())
buf.writeByte('i');
}
}
override void visit(RealExp e)
{
floatToBuffer(e.type, e.value);
}
override void visit(ComplexExp e)
{
/* Print as:
* (re+imi)
*/
buf.writeByte('(');
floatToBuffer(e.type, creall(e.value));
buf.writeByte('+');
floatToBuffer(e.type, cimagl(e.value));
buf.writestring("i)");
}
override void visit(IdentifierExp e)
{
if (hgs.hdrgen || hgs.ddoc)
buf.writestring(e.ident.toHChars2());
else
buf.writestring(e.ident.toChars());
}
override void visit(DsymbolExp e)
{
buf.writestring(e.s.toChars());
}
override void visit(ThisExp e)
{
buf.writestring("this");
}
override void visit(SuperExp e)
{
buf.writestring("super");
}
override void visit(NullExp e)
{
buf.writestring("null");
}
override void visit(StringExp e)
{
buf.writeByte('"');
size_t o = buf.offset;
for (size_t i = 0; i < e.len; i++)
{
uint c = e.charAt(i);
switch (c)
{
case '"':
case '\\':
buf.writeByte('\\');
goto default;
default:
if (c <= 0xFF)
{
if (c <= 0x7F && isprint(c))
buf.writeByte(c);
else
buf.printf("\\x%02x", c);
}
else if (c <= 0xFFFF)
buf.printf("\\x%02x\\x%02x", c & 0xFF, c >> 8);
else
buf.printf("\\x%02x\\x%02x\\x%02x\\x%02x", c & 0xFF, (c >> 8) & 0xFF, (c >> 16) & 0xFF, c >> 24);
break;
}
}
if (hgs.ddoc)
escapeDdocString(buf, o);
buf.writeByte('"');
if (e.postfix)
buf.writeByte(e.postfix);
}
override void visit(ArrayLiteralExp e)
{
buf.writeByte('[');
argsToBuffer(e.elements, e.basis);
buf.writeByte(']');
}
override void visit(AssocArrayLiteralExp e)
{
buf.writeByte('[');
foreach (i, key; *e.keys)
{
if (i)
buf.writestring(", ");
expToBuffer(key, PREC.assign);
buf.writeByte(':');
auto value = (*e.values)[i];
expToBuffer(value, PREC.assign);
}
buf.writeByte(']');
}
override void visit(StructLiteralExp e)
{
buf.writestring(e.sd.toChars());
buf.writeByte('(');
// CTFE can generate struct literals that contain an AddrExp pointing
// to themselves, need to avoid infinite recursion:
// struct S { this(int){ this.s = &this; } S* s; }
// const foo = new S(0);
if (e.stageflags & stageToCBuffer)
buf.writestring("<recursion>");
else
{
int old = e.stageflags;
e.stageflags |= stageToCBuffer;
argsToBuffer(e.elements);
e.stageflags = old;
}
buf.writeByte(')');
}
override void visit(TypeExp e)
{
typeToBuffer(e.type, null);
}
override void visit(ScopeExp e)
{
if (e.sds.isTemplateInstance())
{
e.sds.accept(this);
}
else if (hgs !is null && hgs.ddoc)
{
// fixes bug 6491
Module m = e.sds.isModule();
if (m)
buf.writestring(m.md.toChars());
else
buf.writestring(e.sds.toChars());
}
else
{
buf.writestring(e.sds.kind());
buf.writeByte(' ');
buf.writestring(e.sds.toChars());
}
}
override void visit(TemplateExp e)
{
buf.writestring(e.td.toChars());
}
override void visit(NewExp e)
{
if (e.thisexp)
{
expToBuffer(e.thisexp, PREC.primary);
buf.writeByte('.');
}
buf.writestring("new ");
if (e.newargs && e.newargs.dim)
{
buf.writeByte('(');
argsToBuffer(e.newargs);
buf.writeByte(')');
}
typeToBuffer(e.newtype, null);
if (e.arguments && e.arguments.dim)
{
buf.writeByte('(');
argsToBuffer(e.arguments);
buf.writeByte(')');
}
}
override void visit(NewAnonClassExp e)
{
if (e.thisexp)
{
expToBuffer(e.thisexp, PREC.primary);
buf.writeByte('.');
}
buf.writestring("new");
if (e.newargs && e.newargs.dim)
{
buf.writeByte('(');
argsToBuffer(e.newargs);
buf.writeByte(')');
}
buf.writestring(" class ");
if (e.arguments && e.arguments.dim)
{
buf.writeByte('(');
argsToBuffer(e.arguments);
buf.writeByte(')');
}
if (e.cd)
e.cd.accept(this);
}
override void visit(SymOffExp e)
{
if (e.offset)
buf.printf("(& %s+%u)", e.var.toChars(), e.offset);
else if (e.var.isTypeInfoDeclaration())
buf.printf("%s", e.var.toChars());
else
buf.printf("& %s", e.var.toChars());
}
override void visit(VarExp e)
{
buf.writestring(e.var.toChars());
}
override void visit(OverExp e)
{
buf.writestring(e.vars.ident.toChars());
}
override void visit(TupleExp e)
{
if (e.e0)
{
buf.writeByte('(');
e.e0.accept(this);
buf.writestring(", tuple(");
argsToBuffer(e.exps);
buf.writestring("))");
}
else
{
buf.writestring("tuple(");
argsToBuffer(e.exps);
buf.writeByte(')');
}
}
override void visit(FuncExp e)
{
e.fd.accept(this);
//buf.writestring(e.fd.toChars());
}
override void visit(DeclarationExp e)
{
/* Normal dmd execution won't reach here - regular variable declarations
* are handled in visit(ExpStatement), so here would be used only when
* we'll directly call Expression.toChars() for debugging.
*/
if (auto v = e.declaration.isVarDeclaration())
{
// For debugging use:
// - Avoid printing newline.
// - Intentionally use the format (Type var;)
// which isn't correct as regular D code.
buf.writeByte('(');
visitVarDecl(v, false);
buf.writeByte(';');
buf.writeByte(')');
}
else
e.declaration.accept(this);
}
override void visit(TypeidExp e)
{
buf.writestring("typeid(");
objectToBuffer(e.obj);
buf.writeByte(')');
}
override void visit(TraitsExp e)
{
buf.writestring("__traits(");
buf.writestring(e.ident.toChars());
if (e.args)
{
foreach (arg; *e.args)
{
buf.writestring(", ");
objectToBuffer(arg);
}
}
buf.writeByte(')');
}
override void visit(HaltExp e)
{
buf.writestring("halt");
}
override void visit(IsExp e)
{
buf.writestring("is(");
typeToBuffer(e.targ, e.id);
if (e.tok2 != TOKreserved)
{
buf.printf(" %s %s", Token.toChars(e.tok), Token.toChars(e.tok2));
}
else if (e.tspec)
{
if (e.tok == TOKcolon)
buf.writestring(" : ");
else
buf.writestring(" == ");
typeToBuffer(e.tspec, null);
}
if (e.parameters && e.parameters.dim)
{
buf.writestring(", ");
visitTemplateParameters(e.parameters);
}
buf.writeByte(')');
}
override void visit(UnaExp e)
{
buf.writestring(Token.toString(e.op));
expToBuffer(e.e1, precedence[e.op]);
}
override void visit(BinExp e)
{
expToBuffer(e.e1, precedence[e.op]);
buf.writeByte(' ');
buf.writestring(Token.toString(e.op));
buf.writeByte(' ');
expToBuffer(e.e2, cast(PREC)(precedence[e.op] + 1));
}
override void visit(CompileExp e)
{
buf.writestring("mixin(");
expToBuffer(e.e1, PREC.assign);
buf.writeByte(')');
}
override void visit(ImportExp e)
{
buf.writestring("import(");
expToBuffer(e.e1, PREC.assign);
buf.writeByte(')');
}
override void visit(AssertExp e)
{
buf.writestring("assert(");
expToBuffer(e.e1, PREC.assign);
if (e.msg)
{
buf.writestring(", ");
expToBuffer(e.msg, PREC.assign);
}
buf.writeByte(')');
}
override void visit(DotIdExp e)
{
expToBuffer(e.e1, PREC.primary);
buf.writeByte('.');
buf.writestring(e.ident.toChars());
}
override void visit(DotTemplateExp e)
{
expToBuffer(e.e1, PREC.primary);
buf.writeByte('.');
buf.writestring(e.td.toChars());
}
override void visit(DotVarExp e)
{
expToBuffer(e.e1, PREC.primary);
buf.writeByte('.');
buf.writestring(e.var.toChars());
}
override void visit(DotTemplateInstanceExp e)
{
expToBuffer(e.e1, PREC.primary);
buf.writeByte('.');
e.ti.accept(this);
}
override void visit(DelegateExp e)
{
buf.writeByte('&');
if (!e.func.isNested())
{
expToBuffer(e.e1, PREC.primary);
buf.writeByte('.');
}
buf.writestring(e.func.toChars());
}
override void visit(DotTypeExp e)
{
expToBuffer(e.e1, PREC.primary);
buf.writeByte('.');
buf.writestring(e.sym.toChars());
}
override void visit(CallExp e)
{
if (e.e1.op == TOKtype)
{
/* Avoid parens around type to prevent forbidden cast syntax:
* (sometype)(arg1)
* This is ok since types in constructor calls
* can never depend on parens anyway
*/
e.e1.accept(this);
}
else
expToBuffer(e.e1, precedence[e.op]);
buf.writeByte('(');
argsToBuffer(e.arguments);
buf.writeByte(')');
}
override void visit(PtrExp e)
{
buf.writeByte('*');
expToBuffer(e.e1, precedence[e.op]);
}
override void visit(DeleteExp e)
{
buf.writestring("delete ");
expToBuffer(e.e1, precedence[e.op]);
}
override void visit(CastExp e)
{
buf.writestring("cast(");
if (e.to)
typeToBuffer(e.to, null);
else
{
MODtoBuffer(buf, e.mod);
}
buf.writeByte(')');
expToBuffer(e.e1, precedence[e.op]);
}
override void visit(VectorExp e)
{
buf.writestring("cast(");
typeToBuffer(e.to, null);
buf.writeByte(')');
expToBuffer(e.e1, precedence[e.op]);
}
override void visit(SliceExp e)
{
expToBuffer(e.e1, precedence[e.op]);
buf.writeByte('[');
if (e.upr || e.lwr)
{
if (e.lwr)
sizeToBuffer(e.lwr);
else
buf.writeByte('0');
buf.writestring("..");
if (e.upr)
sizeToBuffer(e.upr);
else
buf.writeByte('$');
}
buf.writeByte(']');
}
override void visit(ArrayLengthExp e)
{
expToBuffer(e.e1, PREC.primary);
buf.writestring(".length");
}
override void visit(IntervalExp e)
{
expToBuffer(e.lwr, PREC.assign);
buf.writestring("..");
expToBuffer(e.upr, PREC.assign);
}
override void visit(DelegatePtrExp e)
{
expToBuffer(e.e1, PREC.primary);
buf.writestring(".ptr");
}
override void visit(DelegateFuncptrExp e)
{
expToBuffer(e.e1, PREC.primary);
buf.writestring(".funcptr");
}
override void visit(ArrayExp e)
{
expToBuffer(e.e1, PREC.primary);
buf.writeByte('[');
argsToBuffer(e.arguments);
buf.writeByte(']');
}
override void visit(DotExp e)
{
expToBuffer(e.e1, PREC.primary);
buf.writeByte('.');
expToBuffer(e.e2, PREC.primary);
}
override void visit(IndexExp e)
{
expToBuffer(e.e1, PREC.primary);
buf.writeByte('[');
sizeToBuffer(e.e2);
buf.writeByte(']');
}
override void visit(PostExp e)
{
expToBuffer(e.e1, precedence[e.op]);
buf.writestring(Token.toString(e.op));
}
override void visit(PreExp e)
{
buf.writestring(Token.toString(e.op));
expToBuffer(e.e1, precedence[e.op]);
}
override void visit(RemoveExp e)
{
expToBuffer(e.e1, PREC.primary);
buf.writestring(".remove(");
expToBuffer(e.e2, PREC.assign);
buf.writeByte(')');
}
override void visit(CondExp e)
{
expToBuffer(e.econd, PREC.oror);
buf.writestring(" ? ");
expToBuffer(e.e1, PREC.expr);
buf.writestring(" : ");
expToBuffer(e.e2, PREC.cond);
}
override void visit(DefaultInitExp e)
{
buf.writestring(Token.toString(e.subop));
}
override void visit(ClassReferenceExp e)
{
buf.writestring(e.value.toChars());
}
////////////////////////////////////////////////////////////////////////////
override void visit(TemplateTypeParameter tp)
{
buf.writestring(tp.ident.toChars());
if (tp.specType)
{
buf.writestring(" : ");
typeToBuffer(tp.specType, null);
}
if (tp.defaultType)
{
buf.writestring(" = ");
typeToBuffer(tp.defaultType, null);
}
}
override void visit(TemplateThisParameter tp)
{
buf.writestring("this ");
visit(cast(TemplateTypeParameter)tp);
}
override void visit(TemplateAliasParameter tp)
{
buf.writestring("alias ");
if (tp.specType)
typeToBuffer(tp.specType, tp.ident);
else
buf.writestring(tp.ident.toChars());
if (tp.specAlias)
{
buf.writestring(" : ");
objectToBuffer(tp.specAlias);
}
if (tp.defaultAlias)
{
buf.writestring(" = ");
objectToBuffer(tp.defaultAlias);
}
}
override void visit(TemplateValueParameter tp)
{
typeToBuffer(tp.valType, tp.ident);
if (tp.specValue)
{
buf.writestring(" : ");
tp.specValue.accept(this);
}
if (tp.defaultValue)
{
buf.writestring(" = ");
tp.defaultValue.accept(this);
}
}
override void visit(TemplateTupleParameter tp)
{
buf.writestring(tp.ident.toChars());
buf.writestring("...");
}
////////////////////////////////////////////////////////////////////////////
override void visit(DebugCondition c)
{
if (c.ident)
buf.printf("debug (%s)", c.ident.toChars());
else
buf.printf("debug (%u)", c.level);
}
override void visit(VersionCondition c)
{
if (c.ident)
buf.printf("version (%s)", c.ident.toChars());
else
buf.printf("version (%u)", c.level);
}
override void visit(StaticIfCondition c)
{
buf.writestring("static if (");
c.exp.accept(this);
buf.writeByte(')');
}
////////////////////////////////////////////////////////////////////////////
override void visit(Parameter p)
{
if (p.storageClass & STCauto)
buf.writestring("auto ");
if (p.storageClass & STCreturn)
buf.writestring("return ");
if (p.storageClass & STCout)
buf.writestring("out ");
else if (p.storageClass & STCref)
buf.writestring("ref ");
else if (p.storageClass & STCin)
buf.writestring("in ");
else if (p.storageClass & STClazy)
buf.writestring("lazy ");
else if (p.storageClass & STCalias)
buf.writestring("alias ");
StorageClass stc = p.storageClass;
if (p.type && p.type.mod & MODshared)
stc &= ~STCshared;
if (stcToBuffer(buf, stc & (STCconst | STCimmutable | STCwild | STCshared | STCscope)))
buf.writeByte(' ');
if (p.storageClass & STCalias)
{
if (p.ident)
buf.writestring(p.ident.toChars());
}
else if (p.type.ty == Tident &&
(cast(TypeIdentifier)p.type).ident.toString().length > 3 &&
strncmp((cast(TypeIdentifier)p.type).ident.toChars(), "__T", 3) == 0)
{
// print parameter name, instead of undetermined type parameter
buf.writestring(p.ident.toChars());
}
else
typeToBuffer(p.type, p.ident);
if (p.defaultArg)
{
buf.writestring(" = ");
p.defaultArg.accept(this);
}
}
void parametersToBuffer(Parameters* parameters, int varargs)
{
buf.writeByte('(');
if (parameters)
{
size_t dim = Parameter.dim(parameters);
foreach (i; 0 .. dim)
{
if (i)
buf.writestring(", ");
Parameter fparam = Parameter.getNth(parameters, i);
fparam.accept(this);
}
if (varargs)
{
if (parameters.dim && varargs == 1)
buf.writestring(", ");
buf.writestring("...");
}
}
buf.writeByte(')');
}
override void visit(Module m)
{
if (m.md)
{
if (m.userAttribDecl)
{
buf.writestring("@(");
argsToBuffer(m.userAttribDecl.atts);
buf.writeByte(')');
buf.writenl();
}
if (m.md.isdeprecated)
{
if (m.md.msg)
{
buf.writestring("deprecated(");
m.md.msg.accept(this);
buf.writestring(") ");
}
else
buf.writestring("deprecated ");
}
buf.writestring("module ");
buf.writestring(m.md.toChars());
buf.writeByte(';');
buf.writenl();
}
foreach (s; *m.members)
{
s.accept(this);
}
}
}
extern (C++) void toCBuffer(Statement s, OutBuffer* buf, HdrGenState* hgs)
{
scope PrettyPrintVisitor v = new PrettyPrintVisitor(buf, hgs);
s.accept(v);
}
extern (C++) void toCBuffer(Type t, OutBuffer* buf, Identifier ident, HdrGenState* hgs)
{
scope PrettyPrintVisitor v = new PrettyPrintVisitor(buf, hgs);
v.typeToBuffer(t, ident);
}
extern (C++) void toCBuffer(Dsymbol s, OutBuffer* buf, HdrGenState* hgs)
{
scope PrettyPrintVisitor v = new PrettyPrintVisitor(buf, hgs);
s.accept(v);
}
// used from TemplateInstance::toChars() and TemplateMixin::toChars()
extern (C++) void toCBufferInstance(TemplateInstance ti, OutBuffer* buf, bool qualifyTypes = false)
{
HdrGenState hgs;
hgs.fullQual = qualifyTypes;
scope PrettyPrintVisitor v = new PrettyPrintVisitor(buf, &hgs);
v.visit(ti);
}
extern (C++) void toCBuffer(Initializer iz, OutBuffer* buf, HdrGenState* hgs)
{
scope PrettyPrintVisitor v = new PrettyPrintVisitor(buf, hgs);
iz.accept(v);
}
extern (C++) bool stcToBuffer(OutBuffer* buf, StorageClass stc)
{
bool result = false;
if ((stc & (STCreturn | STCscope)) == (STCreturn | STCscope))
stc &= ~STCscope;
while (stc)
{
const(char)* p = stcToChars(stc);
if (!p) // there's no visible storage classes
break;
if (!result)
result = true;
else
buf.writeByte(' ');
buf.writestring(p);
}
return result;
}
/*************************************************
* Pick off one of the storage classes from stc,
* and return a pointer to a string representation of it.
* stc is reduced by the one picked.
*/
extern (C++) const(char)* stcToChars(ref StorageClass stc)
{
struct SCstring
{
StorageClass stc;
TOK tok;
const(char)* id;
}
static __gshared SCstring* table =
[
SCstring(STCauto, TOKauto),
SCstring(STCscope, TOKscope),
SCstring(STCstatic, TOKstatic),
SCstring(STCextern, TOKextern),
SCstring(STCconst, TOKconst),
SCstring(STCfinal, TOKfinal),
SCstring(STCabstract, TOKabstract),
SCstring(STCsynchronized, TOKsynchronized),
SCstring(STCdeprecated, TOKdeprecated),
SCstring(STCoverride, TOKoverride),
SCstring(STClazy, TOKlazy),
SCstring(STCalias, TOKalias),
SCstring(STCout, TOKout),
SCstring(STCin, TOKin),
SCstring(STCmanifest, TOKenum),
SCstring(STCimmutable, TOKimmutable),
SCstring(STCshared, TOKshared),
SCstring(STCnothrow, TOKnothrow),
SCstring(STCwild, TOKwild),
SCstring(STCpure, TOKpure),
SCstring(STCref, TOKref),
SCstring(STCtls),
SCstring(STCgshared, TOKgshared),
SCstring(STCnogc, TOKat, "@nogc"),
SCstring(STCproperty, TOKat, "@property"),
SCstring(STCsafe, TOKat, "@safe"),
SCstring(STCtrusted, TOKat, "@trusted"),
SCstring(STCsystem, TOKat, "@system"),
SCstring(STCdisable, TOKat, "@disable"),
SCstring(0, TOKreserved)
];
for (int i = 0; table[i].stc; i++)
{
StorageClass tbl = table[i].stc;
assert(tbl & STCStorageClass);
if (stc & tbl)
{
stc &= ~tbl;
if (tbl == STCtls) // TOKtls was removed
return "__thread";
TOK tok = table[i].tok;
if (tok == TOKat)
return table[i].id;
else
return Token.toChars(tok);
}
}
//printf("stc = %llx\n", stc);
return null;
}
extern (C++) void trustToBuffer(OutBuffer* buf, TRUST trust)
{
const(char)* p = trustToChars(trust);
if (p)
buf.writestring(p);
}
extern (C++) const(char)* trustToChars(TRUST trust)
{
switch (trust)
{
case TRUSTdefault:
return null;
case TRUSTsystem:
return "@system";
case TRUSTtrusted:
return "@trusted";
case TRUSTsafe:
return "@safe";
default:
assert(0);
}
}
extern (C++) void linkageToBuffer(OutBuffer* buf, LINK linkage)
{
const(char)* p = linkageToChars(linkage);
if (p)
{
buf.writestring("extern (");
buf.writestring(p);
buf.writeByte(')');
}
}
extern (C++) const(char)* linkageToChars(LINK linkage)
{
switch (linkage)
{
case LINKdefault:
return null;
case LINKd:
return "D";
case LINKc:
return "C";
case LINKcpp:
return "C++";
case LINKwindows:
return "Windows";
case LINKpascal:
return "Pascal";
case LINKobjc:
return "Objective-C";
case LINKsystem:
return "System";
default:
assert(0);
}
}
extern (C++) void protectionToBuffer(OutBuffer* buf, Prot prot)
{
const(char)* p = protectionToChars(prot.kind);
if (p)
buf.writestring(p);
if (prot.kind == PROTpackage && prot.pkg)
{
buf.writeByte('(');
buf.writestring(prot.pkg.toPrettyChars(true));
buf.writeByte(')');
}
}
extern (C++) const(char)* protectionToChars(PROTKIND kind)
{
switch (kind)
{
case PROTundefined:
return null;
case PROTnone:
return "none";
case PROTprivate:
return "private";
case PROTpackage:
return "package";
case PROTprotected:
return "protected";
case PROTpublic:
return "public";
case PROTexport:
return "export";
default:
assert(0);
}
}
// Print the full function signature with correct ident, attributes and template args
extern (C++) void functionToBufferFull(TypeFunction tf, OutBuffer* buf, Identifier ident, HdrGenState* hgs, TemplateDeclaration td)
{
//printf("TypeFunction::toCBuffer() this = %p\n", this);
scope PrettyPrintVisitor v = new PrettyPrintVisitor(buf, hgs);
v.visitFuncIdentWithPrefix(tf, ident, td, true);
}
// ident is inserted before the argument list and will be "function" or "delegate" for a type
extern (C++) void functionToBufferWithIdent(TypeFunction tf, OutBuffer* buf, const(char)* ident)
{
HdrGenState hgs;
scope PrettyPrintVisitor v = new PrettyPrintVisitor(buf, &hgs);
v.visitFuncIdentWithPostfix(tf, ident);
}
extern (C++) void toCBuffer(Expression e, OutBuffer* buf, HdrGenState* hgs)
{
scope PrettyPrintVisitor v = new PrettyPrintVisitor(buf, hgs);
e.accept(v);
}
/**************************************************
* Write out argument types to buf.
*/
extern (C++) void argExpTypesToCBuffer(OutBuffer* buf, Expressions* arguments)
{
if (!arguments || !arguments.dim)
return;
HdrGenState hgs;
scope PrettyPrintVisitor v = new PrettyPrintVisitor(buf, &hgs);
foreach (i, arg; *arguments)
{
if (i)
buf.writestring(", ");
v.typeToBuffer(arg.type, null);
}
}
extern (C++) void toCBuffer(TemplateParameter tp, OutBuffer* buf, HdrGenState* hgs)
{
scope PrettyPrintVisitor v = new PrettyPrintVisitor(buf, hgs);
tp.accept(v);
}
extern (C++) void arrayObjectsToBuffer(OutBuffer* buf, Objects* objects)
{
if (!objects || !objects.dim)
return;
HdrGenState hgs;
scope PrettyPrintVisitor v = new PrettyPrintVisitor(buf, &hgs);
foreach (i, o; *objects)
{
if (i)
buf.writestring(", ");
v.objectToBuffer(o);
}
}
extern (C++) const(char)* parametersTypeToChars(Parameters* parameters, int varargs)
{
OutBuffer buf;
HdrGenState hgs;
scope PrettyPrintVisitor v = new PrettyPrintVisitor(&buf, &hgs);
v.parametersToBuffer(parameters, varargs);
return buf.extractString();
}
|
D
|
/Users/olegp/Desktop/XCoordinatorPlayground/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RxSwift.build/Objects-normal/x86_64/Switch.o : /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Amb.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/SingleAsync.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/DistinctUntilChanged.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Deferred.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Deprecated.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Enumerated.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/Maybe.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/AsMaybe.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Sequence.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/DataStructures/InfiniteSequence.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/ObservableType+PrimitiveSequence.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/PrimitiveSequence.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Debounce.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Reduce.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Range.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Merge.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Take.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Cancelable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/Completable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/GroupedObservable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/Single.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/AsSingle.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/TakeWhile.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/SkipWhile.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Sample.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Throttle.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/ShareReplayScope.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/ObservableType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/ConnectableObservableType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/SchedulerType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/ObserverType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Subjects/SubjectType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Create.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Generate.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/DataStructures/Queue.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/DataStructures/PriorityQueue.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Reactive.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Materialize.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Dematerialize.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/AddRef.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/DataStructures/Bag.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Using.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Debug.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Catch.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Switch.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/StartWith.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Concurrency/Lock.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/RecursiveLock.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Sink.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Optional.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/TakeUntil.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/SkipUntil.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/WithLatestFrom.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/SubscribeOn.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/ObserveOn.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Scan.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/Completable+AndThen.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/RetryWhen.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/Platform.Darwin.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/Internal/DispatchQueueConfiguration.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Zip+Collection.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/CombineLatest+Collection.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/DelaySubscription.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Do.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Map.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Zip.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Skip.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Producer.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Buffer.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Timer.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/DeprecationWarner.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Filter.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Never.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/AnyObserver.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Error.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/Disposables.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/ObservableType+Extensions.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/DispatchQueue+Extensions.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Errors.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/ElementAt.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Concat.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Repeat.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Subjects/AsyncSubject.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Subjects/PublishSubject.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Subjects/BehaviorSubject.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Subjects/ReplaySubject.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/AtomicInt.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Event.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/SwiftSupport/SwiftSupport.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/TakeLast.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Multicast.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/CombineLatest.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/First.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Just.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Timeout.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Window.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Extensions/Bag+Rx.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Rx.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/RxMutableBox.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/Platform.Linux.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/GroupBy.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Delay.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/ToArray.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/PrimitiveSequence+Zip+arity.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Zip+arity.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/CombineLatest+arity.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Empty.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/SwitchIfEmpty.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/DefaultIfEmpty.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/olegp/Desktop/XCoordinatorPlayground/Pods/Target\ Support\ Files/RxSwift/RxSwift-umbrella.h /Users/olegp/Desktop/XCoordinatorPlayground/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RxSwift.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/olegp/Desktop/XCoordinatorPlayground/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RxSwift.build/Objects-normal/x86_64/Switch~partial.swiftmodule : /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Amb.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/SingleAsync.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/DistinctUntilChanged.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Deferred.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Deprecated.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Enumerated.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/Maybe.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/AsMaybe.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Sequence.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/DataStructures/InfiniteSequence.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/ObservableType+PrimitiveSequence.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/PrimitiveSequence.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Debounce.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Reduce.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Range.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Merge.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Take.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Cancelable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/Completable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/GroupedObservable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/Single.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/AsSingle.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/TakeWhile.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/SkipWhile.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Sample.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Throttle.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/ShareReplayScope.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/ObservableType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/ConnectableObservableType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/SchedulerType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/ObserverType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Subjects/SubjectType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Create.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Generate.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/DataStructures/Queue.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/DataStructures/PriorityQueue.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Reactive.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Materialize.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Dematerialize.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/AddRef.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/DataStructures/Bag.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Using.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Debug.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Catch.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Switch.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/StartWith.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Concurrency/Lock.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/RecursiveLock.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Sink.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Optional.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/TakeUntil.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/SkipUntil.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/WithLatestFrom.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/SubscribeOn.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/ObserveOn.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Scan.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/Completable+AndThen.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/RetryWhen.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/Platform.Darwin.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/Internal/DispatchQueueConfiguration.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Zip+Collection.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/CombineLatest+Collection.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/DelaySubscription.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Do.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Map.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Zip.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Skip.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Producer.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Buffer.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Timer.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/DeprecationWarner.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Filter.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Never.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/AnyObserver.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Error.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/Disposables.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/ObservableType+Extensions.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/DispatchQueue+Extensions.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Errors.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/ElementAt.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Concat.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Repeat.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Subjects/AsyncSubject.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Subjects/PublishSubject.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Subjects/BehaviorSubject.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Subjects/ReplaySubject.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/AtomicInt.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Event.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/SwiftSupport/SwiftSupport.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/TakeLast.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Multicast.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/CombineLatest.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/First.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Just.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Timeout.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Window.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Extensions/Bag+Rx.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Rx.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/RxMutableBox.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/Platform.Linux.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/GroupBy.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Delay.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/ToArray.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/PrimitiveSequence+Zip+arity.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Zip+arity.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/CombineLatest+arity.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Empty.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/SwitchIfEmpty.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/DefaultIfEmpty.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/olegp/Desktop/XCoordinatorPlayground/Pods/Target\ Support\ Files/RxSwift/RxSwift-umbrella.h /Users/olegp/Desktop/XCoordinatorPlayground/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RxSwift.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
/Users/olegp/Desktop/XCoordinatorPlayground/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RxSwift.build/Objects-normal/x86_64/Switch~partial.swiftdoc : /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Amb.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/SingleAsync.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/DistinctUntilChanged.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Deferred.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Deprecated.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Enumerated.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/Maybe.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/AsMaybe.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Sequence.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/DataStructures/InfiniteSequence.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/ObservableType+PrimitiveSequence.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/PrimitiveSequence.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Debounce.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Reduce.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Range.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Merge.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Take.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Cancelable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/Completable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/GroupedObservable.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/Single.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/AsSingle.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/TakeWhile.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/SkipWhile.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Sample.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Throttle.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/ShareReplayScope.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/ObservableType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/ConnectableObservableType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/SchedulerType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/ObserverType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Subjects/SubjectType.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Create.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Generate.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/DataStructures/Queue.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/DataStructures/PriorityQueue.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Reactive.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Materialize.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Dematerialize.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/AddRef.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/DataStructures/Bag.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Using.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Debug.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Catch.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Switch.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/StartWith.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Concurrency/Lock.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/RecursiveLock.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Sink.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Optional.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/TakeUntil.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/SkipUntil.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/WithLatestFrom.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/SubscribeOn.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/ObserveOn.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Scan.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/Completable+AndThen.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/RetryWhen.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/Platform.Darwin.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/Internal/DispatchQueueConfiguration.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Zip+Collection.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/CombineLatest+Collection.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/DelaySubscription.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Do.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Map.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Zip.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Skip.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Producer.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Buffer.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Timer.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/DeprecationWarner.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Filter.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Never.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/AnyObserver.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Error.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Disposables/Disposables.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/ObservableType+Extensions.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/DispatchQueue+Extensions.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Errors.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/ElementAt.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Concat.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Repeat.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Subjects/AsyncSubject.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Subjects/PublishSubject.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Subjects/BehaviorSubject.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Subjects/ReplaySubject.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/AtomicInt.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Event.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/SwiftSupport/SwiftSupport.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/TakeLast.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Multicast.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/CombineLatest.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/First.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Just.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Timeout.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Window.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Extensions/Bag+Rx.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Rx.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/RxMutableBox.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/Platform/Platform.Linux.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/GroupBy.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Delay.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/ToArray.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Traits/PrimitiveSequence+Zip+arity.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Zip+arity.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/CombineLatest+arity.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/Empty.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/SwitchIfEmpty.swift /Users/olegp/Desktop/XCoordinatorPlayground/Pods/RxSwift/RxSwift/Observables/DefaultIfEmpty.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/olegp/Desktop/XCoordinatorPlayground/Pods/Target\ Support\ Files/RxSwift/RxSwift-umbrella.h /Users/olegp/Desktop/XCoordinatorPlayground/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RxSwift.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
|
D
|
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 3.0.0
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */
module vtkDoubleColor4T;
static import vtkd_im;
static import core.stdc.config;
static import std.conv;
static import std.string;
static import std.conv;
static import std.string;
static import vtkDoubleTuple4TN;
class vtkDoubleColor4T : vtkDoubleTuple4TN.vtkDoubleTuple4TN {
private void* swigCPtr;
public this(void* cObject, bool ownCObject) {
super(vtkd_im.vtkDoubleColor4T_Upcast(cObject), ownCObject);
swigCPtr = cObject;
}
public static void* swigGetCPtr(vtkDoubleColor4T obj) {
return (obj is null) ? null : obj.swigCPtr;
}
mixin vtkd_im.SwigOperatorDefinitions;
~this() {
dispose();
}
public override void dispose() {
synchronized(this) {
if (swigCPtr !is null) {
if (swigCMemOwn) {
swigCMemOwn = false;
vtkd_im.delete_vtkDoubleColor4T(cast(void*)swigCPtr);
}
swigCPtr = null;
super.dispose();
}
}
}
public this() {
this(vtkd_im.new_vtkDoubleColor4T__SWIG_0(), true);
}
public this(double scalar) {
this(vtkd_im.new_vtkDoubleColor4T__SWIG_1(scalar), true);
}
public this(double* init) {
this(vtkd_im.new_vtkDoubleColor4T__SWIG_2(cast(void*)init), true);
}
public this(double red, double green, double blue, double alpha) {
this(vtkd_im.new_vtkDoubleColor4T__SWIG_3(red, green, blue, alpha), true);
}
public void Set(double red, double green, double blue) {
vtkd_im.vtkDoubleColor4T_Set__SWIG_0(cast(void*)swigCPtr, red, green, blue);
}
public void Set(double red, double green, double blue, double alpha) {
vtkd_im.vtkDoubleColor4T_Set__SWIG_1(cast(void*)swigCPtr, red, green, blue, alpha);
}
public void SetRed(double red) {
vtkd_im.vtkDoubleColor4T_SetRed(cast(void*)swigCPtr, red);
}
public double GetRed() const {
auto ret = vtkd_im.vtkDoubleColor4T_GetRed(cast(void*)swigCPtr);
return ret;
}
public void SetGreen(double green) {
vtkd_im.vtkDoubleColor4T_SetGreen(cast(void*)swigCPtr, green);
}
public double GetGreen() const {
auto ret = vtkd_im.vtkDoubleColor4T_GetGreen(cast(void*)swigCPtr);
return ret;
}
public void SetBlue(double blue) {
vtkd_im.vtkDoubleColor4T_SetBlue(cast(void*)swigCPtr, blue);
}
public double GetBlue() const {
auto ret = vtkd_im.vtkDoubleColor4T_GetBlue(cast(void*)swigCPtr);
return ret;
}
public void SetAlpha(double alpha) {
vtkd_im.vtkDoubleColor4T_SetAlpha(cast(void*)swigCPtr, alpha);
}
public double GetAlpha() const {
auto ret = vtkd_im.vtkDoubleColor4T_GetAlpha(cast(void*)swigCPtr);
return ret;
}
public double Red() const {
auto ret = vtkd_im.vtkDoubleColor4T_Red(cast(void*)swigCPtr);
return ret;
}
public double Green() const {
auto ret = vtkd_im.vtkDoubleColor4T_Green(cast(void*)swigCPtr);
return ret;
}
public double Blue() const {
auto ret = vtkd_im.vtkDoubleColor4T_Blue(cast(void*)swigCPtr);
return ret;
}
public double Alpha() const {
auto ret = vtkd_im.vtkDoubleColor4T_Alpha(cast(void*)swigCPtr);
return ret;
}
}
|
D
|
module dcv.imgproc.convolution;
/**
* Module introduces array convolution functions.
*
* v0.1 norm:
* conv (done)
* separable_conv
*
* v0.1+ plans:
* 1d_conv_simd
*/
private import dcv.core.memory;
private import dcv.core.utils;
private import std.traits : isAssignable;
private import std.range;
private import std.algorithm.comparison : equal;
private import std.experimental.ndslice;
private import std.algorithm.iteration : reduce;
private import std.algorithm.comparison : max, min;
private import std.exception : enforce;
private import std.parallelism : parallel;
private import std.math : abs, floor;
/**
* Perform convolution to given range, using given kernel.
* Convolution is supported for 1, 2, and 3D slices.
*
* params:
* range = Input range slice (1D, 2D, and 3D slice supported)
* kernel = Convolution kernel slice. For 1D range, 1D kernel is expected.
* For 2D range, 2D kernele is expected. For 3D range, 2D or 3D kernel is expected -
* if 2D kernel is given, each item in kernel matrix is applied to each value in
* corresponding 2D coordinate in the range.
* prealloc = Pre-allocated array where convolution result can be stored. Default
* value is emptySlice, where resulting array will be newly allocated. Also if
* prealloc is not of same shape as input range, resulting array will be newly allocated.
* mask = Masking range. Convolution will skip each element where mask is 0. Default value
* is empty slice, which tells that convolution will be performed on the whole range.
*/
Slice!(N, V*) conv(V, K, size_t N, size_t NK)(Slice!(N, V*) range, Slice!(NK, K*) kernel,
Slice!(N, V*) prealloc = emptySlice!(N, V),
Slice!(NK, V*) mask = emptySlice!(NK, V))
{
static assert(isAssignable!(V, K), "Uncompatible types for range and kernel");
if (!mask.empty && !mask.shape[].equal(range.shape[])) {
import std.conv : to;
throw new Exception("Invalid mask shape: " ~ mask.shape[].to!string ~
", range shape: " ~ range.shape[].to!string);
}
static if (N == 1) {
static assert(NK == 1, "Invalid kernel dimension");
return conv1Impl(range, kernel, prealloc, mask);
} else static if (N == 2) {
static assert(NK == 2, "Invalid kernel dimension");
return conv2Impl(range, kernel, prealloc, mask);
} else static if (N == 3) {
static assert(NK == 2 || NK == 3, "Invalid kernel dimension");
return conv3Impl(range, kernel, prealloc, mask);
} else {
import std.conv : to;
static assert(0, "Convolution over " ~ N.to!string ~ "D ranges is not implemented");
}
}
unittest {
auto r1 = [0., 1., 2., 3., 4., 5.].sliced(6);
auto k1 = [-1., 0., 1.].sliced(3);
auto res1 = r1.conv(k1);
assert(res1.equal([0., 2., 2., 2., 2., 0.]));
/*
k1 = [0.3333, 0.3333, 0.3333].sliced(3);
auto res2 = r1.conv(k1);
assert(res2.equal([2. / 3., 1., 2., 3., 4., 13. / 3.]));
*/
}
/**
*
*/
void calcPartialDerivatives(T)(Slice!(2, T*) image,
ref Slice!(2, T*) fx, ref Slice!(2, T*) fy) {
assert(!image.empty);
auto itemLength = image.shape.reduce!"a*b";
if (!fx.shape[].equal(image.shape[]))
fx = uninitializedArray!(T[])(itemLength).sliced(image.shape);
if (!fy.shape[].equal(image.shape[]))
fy = uninitializedArray!(T[])(itemLength).sliced(image.shape);
auto rows = image.length!0;
auto cols = image.length!1;
// calc mid-ground
foreach (r ; 1.iota(rows)) {
auto x_row = fx[r, 0..$];
auto y_row = fy[r, 0..$];
foreach (c; 1.iota(cols)) {
auto imrc = image[r, c];
x_row[c] = cast(T)(-1. * image[r, c - 1] + imrc);
y_row[c] = cast(T)(-1. * image[r - 1, c] + imrc);
}
}
// calc border edges
auto x_row = fx[0, 0..$];
auto y_row = fy[0, 0..$];
foreach (c; 0.iota(cols - 1)) {
auto im_0c = image[0, c];
x_row[c] = cast(T)(-1. * im_0c + image[0, c + 1]);
y_row[c] = cast(T)(-1. * im_0c + image[1, c]);
}
auto x_col = fx[0..$, 0];
auto y_col = fy[0..$, 0];
foreach (r; iota(rows - 1)) {
auto im_r_0 = image[r, 0];
x_col[r] = cast(T)(-1. * im_r_0 + image[r, 1]);
y_col[r] = cast(T)(-1. * im_r_0 + image[r + 1, 0]);
}
// edges corner pixels
fx[0, cols-1] = cast(T)(-1* image[0, cols-2] + image[0, cols-1]);
fy[0, cols-1] = cast(T)(-1*image[0, cols-1] + image[1, cols-1]);
fx[rows-1, 0] = cast(T)(-1*image[rows-1, 0] + image[rows-1, 1]);
fy[rows-1, 0] = cast(T)(-1*image[rows-2, 0] + image[rows-1, 0]);
}
private:
// TODO: implement SIMD
Slice!(1, V*) conv1Impl(V, K)(Slice!(1, V*) range, Slice!(1, K*) kernel,
Slice!(1, V*) prealloc, Slice!(1, V*) mask) {
if (prealloc.empty || prealloc.shape != range.shape)
prealloc = uninitializedArray!(V[])(cast(ulong)range.length).sliced(range.shape);
enforce(&range[0] != &prealloc[0],
"Preallocated has to contain different data from that of a input range.");
auto rl = range.length;
int ks = cast(int)kernel.length; // kernel size
int kh = max(1, cast(int)(floor(cast(float)ks / 2.))); // kernel size half
int ke = cast(int)(ks % 2 == 0 ? kh-1 : kh);
int rt = cast(int)(ks % 2 == 0 ? rl - 1 - kh : rl - kh); // range top
bool useMask = !mask.empty;
// run main (inner) loop
foreach(i; kh.iota(rt).parallel) {
if (useMask && !mask[i])
continue;
V v = 0;
V *rp = &range[i];
for(int j = -kh; j < ke+1; ++j) {
v += rp[j]*kernel[j+kh];
}
prealloc[i] = v;
}
// run starting edge with mirror (symmetric) indexing.
foreach(i; 0 .. kh) {
if (useMask && !mask[i])
continue;
V v_start = 0;
for(int j = -kh; j < ke+1; ++j) {
v_start += range[abs(i+j)]*kernel[j+kh];
}
prealloc[i] = v_start;
}
// run ending edge with mirror (symmetric) indexing.
foreach(i; rt .. rl) {
if (useMask && !mask[i])
continue;
V v_end = 0;
for(int j = -kh; j < ke+1; ++j) {
v_end += range[(rl-1)-abs(j)]*kernel[j+kh];
}
prealloc[i] = v_end;
}
return prealloc;
}
Slice!(2, V*) conv2Impl(V, K)(Slice!(2, V*) range, Slice!(2, K*) kernel,
Slice!(2, V*) prealloc, Slice!(2, V*) mask) {
if (prealloc.empty || prealloc.shape != range.shape)
prealloc = uninitializedArray!(V[])(cast(ulong)range.shape.reduce!"a*b").sliced(range.shape);
enforce(&range[0, 0] != &prealloc[0, 0],
"Preallocated has to contain different data from that of a input range.");
auto rr = range.length!0; // range rows
auto rc = range.length!1; // range columns
int krs = cast(int)kernel.length!0; // kernel rows
int kcs = cast(int)kernel.length!1; // kernel rows
int krh = max(1, cast(int)(floor(cast(float)krs / 2.))); // kernel rows size half
int kch = max(1, cast(int)(floor(cast(float)kcs / 2.))); // kernel rows size half
int kre = cast(int)(krs % 2 == 0 ? krh-1 : krh);
int kce = cast(int)(kcs % 2 == 0 ? kch-1 : kch);
int rrt = cast(int)(krs % 2 == 0 ? rr - 1 - krh : rr - krh); // range top
int rct = cast(int)(kcs % 2 == 0 ? rc - 1 - kch : rc - kch); // range top
bool useMask = !mask.empty;
// run inner body convolution of the matrix.
foreach(i; krh.iota(rrt).parallel) {
auto row = prealloc[i, 0..rc];
foreach(j; kch.iota(rct)) {
if (useMask && !mask[i, j])
continue;
V v = 0;
for(int ii = -krh; ii < krh+1; ++ii) {
for(int jj = -kch; jj < kch+1; ++jj) {
v += range[i+ii, j+jj]*kernel[ii+krh, jj+kch];
}
}
row[j] = v;
}
}
// run upper edge with mirror (symmetric) indexing.
auto row = prealloc[0, 0..rc];
foreach(j; 0.iota(rc).parallel) {
if (useMask && !mask[0, j])
continue;
V v = 0;
for(int ii = -krh; ii < krh+1; ++ii) {
for(int jj = -kch; jj < kch+1; ++jj) {
immutable jjj = j+jj;
immutable jj_pos = jjj < 0 ? abs(jjj) : jjj > rc-1 ? rc-1-abs(jj) : jjj;
v += range[abs(ii), jj_pos]*kernel[ii+krh, jj+kch];
}
}
row[j] = v;
}
// run lower edge with mirror (symmetric) indexing.
row = prealloc[rr-1, 0..rc];
foreach(j; 0.iota(rc).parallel) {
if (useMask && !mask[rr-1, j])
continue;
V v = 0;
for(int ii = -krh; ii < krh+1; ++ii) {
for(int jj = -kch; jj < kch+1; ++jj) {
immutable jjj = j+jj;
immutable jj_pos = jjj < 0 ? abs(jjj) : jjj > rc-1 ? rc-1-abs(jj) : jjj;
v += range[(rr-1)-abs(ii), jj_pos]*kernel[ii+krh, jj+kch];
}
}
row[j] = v;
}
// run left edge with mirror (symmetric) indexing.
auto col = prealloc[0..rr, 0];
foreach(i; 0.iota(rr).parallel) {
if (useMask && !mask[i, 0])
continue;
V v = 0;
for(int ii = -krh; ii < krh+1; ++ii) {
for(int jj = -kch; jj < kch+1; ++jj) {
immutable iii = i+ii;
immutable ii_pos = iii < 0 ? abs(iii) : iii > rr - 1 ? rr-1-abs(ii) : iii;
v += range[ii_pos, abs(jj)]*kernel[ii+krh, jj+kch];
}
}
col[i] = v;
}
// run right edge with mirror (symmetric) indexing.
col = prealloc[0..rr, rc-1];
foreach(i; 0.iota(rr).parallel) {
if (useMask && !mask[i, rc-1])
continue;
V v = 0;
for(int ii = -krh; ii < krh+1; ++ii) {
for(int jj = -kch; jj < kch+1; ++jj) {
immutable iii = i+ii;
immutable ii_pos = iii < 0 ? abs(iii) : iii > rr - 1 ? rr-1-abs(ii) : iii;
v += range[ii_pos, (rc-1)-abs(jj)]*kernel[ii+krh, jj+kch];
}
}
col[i] = v;
}
return prealloc;
}
// TODO: think of less boilerplate implementation.
Slice!(3, V*) conv3Impl(V, K, size_t NK)(Slice!(3, V*) range, Slice!(NK, K*) kernel,
Slice!(3, V*) prealloc, Slice!(NK, V*) mask)
{
static if (NK == 2) {
return conv3Impl_kernel2(range, kernel, prealloc, mask);
} else if (NK == 3) {
return conv3Impl_kernel3(range, kernel, prealloc, mask);
} // else other is statically checked in the main conv call.
}
Slice!(3, V*) conv3Impl_kernel2(V, K)(Slice!(3, V*) range, Slice!(2, K*) kernel,
Slice!(3, V*) prealloc, Slice!(2, V*) mask)
{
if (prealloc.empty || prealloc.shape != range.shape)
prealloc = uninitializedArray!(V[])(cast(ulong)range.shape.reduce!"a*b").sliced(range.shape);
enforce(&range[0, 0, 0] != &prealloc[0, 0, 0],
"Preallocated has to contain different data from that of a input range.");
auto rr = range.length!0; // range rows
auto rc = range.length!1; // range columns
auto rch = range.length!2; // range channels
int krs = cast(int)kernel.length!0; // kernel rows
int kcs = cast(int)kernel.length!1; // kernel rows
int krh = max(1, cast(int)(floor(cast(float)krs / 2.))); // kernel rows size half
int kch = max(1, cast(int)(floor(cast(float)kcs / 2.))); // kernel rows size half
int kre = cast(int)(krs % 2 == 0 ? krh-1 : krh);
int kce = cast(int)(kcs % 2 == 0 ? kch-1 : kch);
int rrt = cast(int)(krs % 2 == 0 ? rr - 1 - krh : rr - krh); // range top
int rct = cast(int)(kcs % 2 == 0 ? rc - 1 - kch : rc - kch); // range top
bool useMask = !mask.empty;
// run inner body convolution of the matrix.
foreach(i; krh.iota(rrt).parallel) {
auto row = prealloc[i, 0..rc, 0..rch];
foreach(j; kch.iota(rct)) {
if (useMask && !mask[i, j])
continue;
row[j, 0..rch][] = 0;
for(int ii = -krh; ii < krh+1; ++ii) {
for(int jj = -kch; jj < kch+1; ++jj) {
foreach(c; 0.iota(rch)) {
row[j, c] += range[i+ii, j+jj, c]*kernel[ii+krh, jj+kch];
}
}
}
}
}
// run upper edge with mirror (symmetric) indexing.
foreach(i; 0.iota(krh+1)) {
auto row = prealloc[i, 0..rc, 0..rch];
foreach(j; 0.iota(rc).parallel) {
if (useMask && !mask[0, j])
continue;
row[j, 0..rch][] = 0;
for(int ii = -krh; ii < krh+1; ++ii) {
for(int jj = -kch; jj < kch+1; ++jj) {
immutable jjj = j+jj;
immutable jj_pos = jjj < 0 ? abs(jjj) : jjj > rc-1 ? rc-1-abs(jj) : jjj;
foreach(c; 0.iota(rch)) {
row[j, c] += range[abs(ii), jj_pos, c]*kernel[ii+krh, jj+kch];
}
}
}
}
}
// run lower edge with mirror (symmetric) indexing.
foreach(i; rrt.iota(rr)) {
auto row = prealloc[i, 0..rc, 0..rch];
foreach(j; 0.iota(rc).parallel) {
if (useMask && !mask[rr-1, j])
continue;
row[j, 0..rch][] = 0;
for(int ii = -krh; ii < krh+1; ++ii) {
for(int jj = -kch; jj < kch+1; ++jj) {
immutable jjj = j+jj;
immutable jj_pos = jjj < 0 ? abs(jjj) : jjj > rc-1 ? rc-1-abs(jj) : jjj;
foreach(c; 0.iota(rch)) {
row[j, c] += range[(rr-1)-abs(ii), jj_pos, c]*kernel[ii+krh, jj+kch];
}
}
}
}
}
// run left edge with mirror (symmetric) indexing.
foreach(j; 0.iota(kch)) {
auto col = prealloc[0..rr, j, 0..rch];
foreach(i; 0.iota(rr).parallel) {
if (useMask && !mask[i, 0])
continue;
col[i, 0..rch][] = 0;
for(int ii = -krh; ii < krh+1; ++ii) {
for(int jj = -kch; jj < kch+1; ++jj) {
immutable iii = i+ii;
immutable ii_pos = iii < 0 ? abs(iii) : iii > rr - 1 ? rr-1-abs(ii) : iii;
foreach(c; 0.iota(rch)) {
col[i, c] += range[ii_pos, abs(jj), c]*kernel[ii+krh, jj+kch];
}
}
}
}
}
// run right edge with mirror (symmetric) indexing.
foreach(j; rct.iota(rc)) {
auto col = prealloc[0..rr, j, 0..rch];
foreach(i; 0.iota(rr).parallel) {
if (useMask && !mask[i, rc-1])
continue;
col[i, 0..rch][] = 0;
for(int ii = -krh; ii < krh+1; ++ii) {
for(int jj = -kch; jj < kch+1; ++jj) {
immutable iii = i+ii;
immutable ii_pos = iii < 0 ? abs(iii) : iii > rr - 1 ? rr-1-abs(ii) : iii;
foreach(c; 0.iota(rch)) {
col[i, c] += range[ii_pos, (rc-1)-abs(jj), c]*kernel[ii+krh, jj+kch];
}
}
}
}
}
return prealloc;
}
Slice!(3, V*) conv3Impl_kernel3(V, K)(Slice!(3, V*) range, Slice!(3, K*) kernel,
Slice!(3, V*) prealloc, Slice!(3, V*) mask)
{
if (prealloc.empty || prealloc.shape != range.shape)
prealloc = uninitializedArray!(V[])(cast(ulong)range.shape.reduce!"a*b").sliced(range.shape);
enforce(&range[0, 0, 0] != &prealloc[0, 0, 0],
"Preallocated has to contain different data from that of a input range.");
auto rr = range.length!0; // range rows
auto rc = range.length!1; // range columns
auto rch = range.length!2; // range channels
int krs = cast(int)kernel.length!0; // kernel rows
int kcs = cast(int)kernel.length!1; // kernel rows
int krh = max(1, cast(int)(floor(cast(float)krs / 2.))); // kernel rows size half
int kch = max(1, cast(int)(floor(cast(float)kcs / 2.))); // kernel cols size half
int kre = cast(int)(krs % 2 == 0 ? krh-1 : krh);
int kce = cast(int)(kcs % 2 == 0 ? kch-1 : kch);
int rrt = cast(int)(krs % 2 == 0 ? rr - 1 - krh : rr - krh); // range top
int rct = cast(int)(kcs % 2 == 0 ? rc - 1 - kch : rc - kch); // range top
bool useMask = !mask.empty;
// run inner body convolution of the matrix.
foreach(i; krh.iota(rrt).parallel) {
auto row = prealloc[i, 0..rc, 0..rch];
foreach(j; kch.iota(rct)) {
foreach(c; 0.iota(rch)) {
if (useMask && !mask[i, j, c])
continue;
V v = 0;
for(int ii = -krh; ii < krh+1; ++ii) {
for(int jj = -kch; jj < kch+1; ++jj) {
v += range[i+ii, j+jj, c]*kernel[ii+krh, jj+kch, c];
}
}
row[j, c] = v;
}
}
}
// run upper edge with mirror (symmetric) indexing.
foreach(i; 0.iota(krh+1)) {
auto row = prealloc[i, 0..rc, 0..rch];
foreach(j; 0.iota(rc).parallel) {
foreach(c; 0.iota(rch)) {
if (useMask && !mask[0, j, c])
continue;
V v = 0;
for(int ii = -krh; ii < krh+1; ++ii) {
for(int jj = -kch; jj < kch+1; ++jj) {
immutable jjj = j+jj;
immutable jj_pos = jjj < 0 ? abs(jjj) : jjj > rc-1 ? rc-1-abs(jj) : jjj;
v += range[abs(ii), jj_pos, c]*kernel[ii+krh, jj+kch, c];
}
}
row[j, c] = v;
}
}
}
// run lower edge with mirror (symmetric) indexing.
foreach(i; rrt.iota(rr)) {
auto row = prealloc[i, 0..rc, 0..rch];
foreach(j; 0.iota(rc).parallel) {
foreach(c; 0.iota(rch)) {
if (useMask && !mask[rr-1, j, c])
continue;
V v = 0;
for(int ii = -krh; ii < krh+1; ++ii) {
for(int jj = -kch; jj < kch+1; ++jj) {
immutable jjj = j+jj;
immutable jj_pos = jjj < 0 ? abs(jjj) : jjj > rc-1 ? rc-1-abs(jj) : jjj;
v += range[(rr-1)-abs(ii), jj_pos, c]*kernel[ii+krh, jj+kch, c];
}
}
row[j, c] = v;
}
}
}
// run left edge with mirror (symmetric) indexing.
foreach(j; 0.iota(kch)) {
auto col = prealloc[0..rr, j, 0..rch];
foreach(i; 0.iota(rr).parallel) {
foreach(c; 0.iota(rch)) {
if (useMask && !mask[i, 0, c])
continue;
V v = 0;
for(int ii = -krh; ii < krh+1; ++ii) {
for(int jj = -kch; jj < kch+1; ++jj) {
immutable iii = i+ii;
immutable ii_pos = iii < 0 ? abs(iii) : iii > rr - 1 ? rr-1-abs(ii) : iii;
v += range[ii_pos, abs(jj), c]*kernel[ii+krh, jj+kch, c];
}
}
col[i, c] = v;
}
}
}
// run right edge with mirror (symmetric) indexing.
foreach(j; rct.iota(rc)) {
auto col = prealloc[0..rr, j, 0..rch];
foreach(i; 0.iota(rr).parallel) {
foreach(c; 0.iota(rch)) {
if (useMask && !mask[i, rc-1, c])
continue;
V v = 0;
for(int ii = -krh; ii < krh+1; ++ii) {
for(int jj = -kch; jj < kch+1; ++jj) {
immutable iii = i+ii;
immutable ii_pos = iii < 0 ? abs(iii) : iii > rr - 1 ? rr-1-abs(ii) : iii;
v += range[ii_pos, (rc-1)-abs(jj), c]*kernel[ii+krh, jj+kch, c];
}
}
col[i, c] = v;
}
}
}
return prealloc;
}
|
D
|
import os = std.stdio: File, writeln;
import digest = std.digest.sha: sha256Of, toHexString, LetterCase;
enum SEGSIZE = 64;
pure nothrow @safe auto merkleRoot(in ubyte[32][] hashes) {
if (hashes.length == 1) {
return hashes[0];
}
ulong i = 1;
while (i * 2 < hashes.length) {
i *= 2;
}
return sha256Of(hashes[0..i].merkleRoot, hashes[i..$].merkleRoot);
}
void main() {
auto f = os.File("test.dat", "r");
ubyte[32] hashes[];
auto buf = new ubyte[SEGSIZE];
while (!f.eof()) {
hashes ~= digest.sha256Of(f.rawRead(buf));
}
os.writeln(digest.toHexString!(digest.LetterCase.lower)(hashes.merkleRoot));
}
|
D
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.