Git Product home page Git Product logo

csharp-date's People

Contributors

lpreiner avatar supersonicclay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

csharp-date's Issues

Binary Serialization does not work

I am using this Date struct in a SortedDictionary and it is throwing a SerializationException. I see that this is using the ISerializable interface but does not have the serialization constructor. I added the [Serializable] attribute in order to get it to serialize but when it tries to deserialize I get the following exception:
The constructor to deserialize an object of type 'System.Date' was not found.

Bug when comparing two dates

Hi,

Not sure if this project is still active but I've been using it and have found a bug. If you write the following code:

Date date1 = DateTime.Now.ToDate();
System.Threading.Thread.Sleep(1000);
Date date2 = DateTime.Now().ToDate();

The date comparison functions will fail:

Assert.AreEqual(date1, date2);
Assert.IsTrue(date1==date2);
Assert.IsTrue(date1.Equals(date2));

This is because there is still a small time portion in the structure in the form of Ticks.

Fortunately there is a way round it - if you change the constructors to no longer Add hours, days etc and change them both to use ".Date":

public Date(DateTime dateTime)
{
    this._dt = dateTime.Date;
}

Apparently using

dateTime.Subtract(dateTime.TimeOfDay)

also works, but I haven't tried that.

Cheers,
Dan.

No Ticks property defined.

I noticed that your implementation does not include a Ticks property. My guess at your reasoning would be that Ticks are far too precise for an object that represents 24-hour intervals. However, I have found that including Ticks helps with some of my code that expects this property and so I think that this property is still useful to keep around. My implementation is included below.

What are your thoughts on this? Do you have any strong arguments against including this property?

public long Ticks
{
	get
	{
		return this._dt.Date.Ticks;
	}
}

ISO 8601 and NuGet

Hi,

Great work on this.

Got a couple of ideas on this:

  1. If someone does date.ToString("o") I think it should output yyyy-MM-dd rather than including the time component like it does at the moment. (maybe the same when using .ToString("s"))
  2. It would be awesome if there were a NuGet package to install it

Thanks!

CoreFx lab has a Date implementation

FYI.

I just discovered that System.Time package from https://github.com/dotnet/corefxlab

System.Time. This project augments the date and time APIs in .NET. It adds two new core types: Date and TimeOfDay. It also provides extension methods to enhance the functionality of the existing DateTime, DateTimeOffset and TimeZoneInfo types.

CoreFx is experimental features that the team is trialling, there is no guarantee that they'll be included in the BCL or supported.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.