View source code
Display the source code in std/datetime/date.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

std.datetime.date.Date.yearBC - multiple declarations

Function Date.yearBC

Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.

ushort yearBC() pure @property @safe const;

Throws

DateTimeException if isAD is true.

Example

writeln(Date(0, 1, 1).yearBC); // 1
writeln(Date(-1, 1, 1).yearBC); // 2
writeln(Date(-100, 1, 1).yearBC); // 101

Function Date.yearBC

Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.

void yearBC (
  int year
) pure @property @safe;

Parameters

NameDescription
year The year B.C. to set this Date's year to.

Throws

DateTimeException if a non-positive value is given.

Example

auto date = Date(2010, 1, 1);
date.yearBC = 1;
writeln(date); // Date(0, 1, 1)

date.yearBC = 10;
writeln(date); // Date(-9, 1, 1)

Authors

Jonathan M Davis

License

Boost License 1.0.