Skip to content

Commit

Permalink
Merge pull request #5 from claycephas/binary
Browse files Browse the repository at this point in the history
Ability to binary serialize
  • Loading branch information
Clay Anderson authored Oct 17, 2017
2 parents 3b1778e + effb3b6 commit 210dcd4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CSharpDate/Date.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

using System;
using System.Globalization;
using System.Runtime.Serialization;

namespace System
{
[Serializable]
public struct Date : IComparable, IFormattable, ISerializable, IComparable<Date>, IEquatable<Date>
{
private DateTime _dt;
Expand All @@ -43,6 +45,11 @@ public Date(DateTime dateTime)
{
this._dt = dateTime.AddTicks(-dateTime.Ticks % TimeSpan.TicksPerDay);
}

private Date(SerializationInfo info, StreamingContext context)
{
this._dt = DateTime.FromFileTime(info.GetInt64("ticks"));
}

public static TimeSpan operator -(Date d1, Date d2)
{
Expand Down

0 comments on commit 210dcd4

Please sign in to comment.