Class Date
Represents a whole or partial calendar date, e.g. a birthday. The time of day
and time zone are either specified elsewhere or are not significant. The date
is relative to the Proleptic Gregorian Calendar. This can represent:
- A full date, with non-zero year, month and day values
- A month and day value, with a zero year, e.g. an anniversary
- A year on its own, with zero month and day values
- A year and month value, with a zero day, e.g. a credit card expiration date
Related types are [google.type.TimeOfDay][google.type.TimeOfDay] and google.protobuf.Timestamp
.
Inheritance
System.Object
Date
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
Assembly: Google.Api.CommonProtos.dll
Syntax
public sealed class Date : IMessage<Date>, IMessage, IEquatable<Date>, IDeepCloneable<Date>
Constructors
Date()
Declaration
Date(Date)
Declaration
Parameters
Type |
Name |
Description |
Date |
other |
|
Fields
DayFieldNumber
Field number for the "day" field.
Declaration
public const int DayFieldNumber = 3
Field Value
Type |
Description |
System.Int32 |
|
MonthFieldNumber
Field number for the "month" field.
Declaration
public const int MonthFieldNumber = 2
Field Value
Type |
Description |
System.Int32 |
|
YearFieldNumber
Field number for the "year" field.
Declaration
public const int YearFieldNumber = 1
Field Value
Type |
Description |
System.Int32 |
|
Properties
Day
Day of month. Must be from 1 to 31 and valid for the year and month, or 0
if specifying a year by itself or a year and month where the day is not
significant.
Declaration
public int Day { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
Descriptor
Declaration
public static MessageDescriptor Descriptor { get; }
Property Value
Month
Month of year. Must be from 1 to 12, or 0 if specifying a year without a
month and day.
Declaration
public int Month { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
Parser
Declaration
public static MessageParser<Date> Parser { get; }
Property Value
Year
Year of date. Must be from 1 to 9999, or 0 if specifying a date without
a year.
Declaration
public int Year { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
Methods
CalculateSize()
Declaration
public int CalculateSize()
Returns
Type |
Description |
System.Int32 |
|
Implements
Clone()
Declaration
Returns
Implements
Equals(Date)
Declaration
public bool Equals(Date other)
Parameters
Type |
Name |
Description |
Date |
other |
|
Returns
Type |
Description |
System.Boolean |
|
Implements
System.IEquatable<T>.Equals(T)
Equals(Object)
Declaration
public override bool Equals(object other)
Parameters
Type |
Name |
Description |
System.Object |
other |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
System.Object.Equals(System.Object)
FromDateTime(DateTime)
Creates a Date instance from the System.DateTime.Date part of System.DateTime.
Declaration
public static Date FromDateTime(DateTime dateTime)
Parameters
Type |
Name |
Description |
System.DateTime |
dateTime |
The System.DateTime value being converted.
|
Returns
FromDateTimeOffset(DateTimeOffset)
Creates a Date instance from the System.DateTimeOffset.Date part of System.DateTimeOffset.
Declaration
public static Date FromDateTimeOffset(DateTimeOffset dateTimeOffset)
Parameters
Type |
Name |
Description |
System.DateTimeOffset |
dateTimeOffset |
The System.DateTimeOffset value being converted.
|
Returns
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
Overrides
System.Object.GetHashCode()
Declaration
public void MergeFrom(CodedInputStream input)
Parameters
Implements
MergeFrom(Date)
Declaration
public void MergeFrom(Date other)
Parameters
Type |
Name |
Description |
Date |
other |
|
Implements
ToDateTime()
Converts Date to System.DateTime.
Declaration
public DateTime ToDateTime()
Returns
Type |
Description |
System.DateTime |
The converted System.DateTime with time at midnight and System.DateTime.Kind of System.DateTimeKind.Unspecified.
|
Exceptions
Type |
Condition |
System.InvalidOperationException |
Thrown when Year, Month, and/or Day are not within the valid range.
|
ToDateTimeOffset()
Converts Date to System.DateTimeOffset.
Declaration
public DateTimeOffset ToDateTimeOffset()
Returns
Type |
Description |
System.DateTimeOffset |
The converted System.DateTimeOffset with time at midnight, System.DateTime.Kind of System.DateTimeKind.Unspecified, and an System.DateTimeOffset.Offset of System.TimeSpan.Zero.
|
Exceptions
Type |
Condition |
System.InvalidOperationException |
Thrown when Year, Month, and/or Day are not within the valid range.
|
ToString()
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
System.Object.ToString()
WriteTo(CodedOutputStream)
Declaration
public void WriteTo(CodedOutputStream output)
Parameters
Implements
Explicit Interface Implementations
IMessage.Descriptor
Declaration
MessageDescriptor IMessage.Descriptor { get; }
Returns
Implements