Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 20 12:57
    jskeet commented #1415
  • Sep 20 12:07
    benmccallum commented #1415
  • Sep 20 12:06

    jskeet on master

    More general package descriptio… (compare)

  • Sep 20 12:06
    jskeet closed #1415
  • Sep 20 12:06
    jskeet commented #1415
  • Sep 20 11:37
    codecov-io commented #1415
  • Sep 20 11:27
    benmccallum opened #1415
  • Sep 18 20:31
    mickeyjf closed #1414
  • Sep 18 20:31
    mickeyjf commented #1414
  • Sep 18 16:13
    jskeet commented #1414
  • Sep 18 16:13
    jskeet commented #1414
  • Sep 18 16:09
    mickeyjf opened #1414
  • Sep 18 11:14

    jskeet on master

    Treat warnings as errors for al… Add lots of missing braces More braces and 2 more (compare)

  • Sep 18 11:14
    jskeet closed #1413
  • Sep 18 10:51
    codecov-io commented #1413
  • Sep 18 10:37
    jskeet assigned #1413
  • Sep 18 10:37
    jskeet opened #1413
  • Sep 18 07:32

    jskeet on master

    Update SharpCompress (compare)

  • Sep 18 07:32
    jskeet closed #1412
  • Sep 18 07:31
    codecov-io commented #1412
Stephen A. Imhoff
@Clockwork-Muse

I'm in Chicago and still have no idea how to get current GMT time In Australia for example.

Well, the first thing would be that there's no such thing as "GMT time in Australia".
You can get an offset from GMT/UTC at a specific instant (or some "local" times). Which is best accomplished by getting the time zone you want first, anyways:

// Olson TZDB zones: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
DateTimeZone zone = DateTimeZoneProviders.Tzdb["Australia/Sydney"];
Offset offset = zone.GetUtcOffset(someInjectedClock.GetCurrentInstant());

.... the fact that you might be in Chicago is irrelevant.

Jon Skeet
@jonskeet_twitter
And for the someInjectedClock part, for the production dependency, you'd normally use SystemClock.Instance. Noda Time treats both time zone provision and "what's the current instant?" as services that should be injected to make testing much easier. There's a separate NodaTime.Testing package that contains a FakeClock and a (less commonly used) FakeDateTimeZoneSource so that you can inject both IClock and IDateTimeZoneProvider - then your unit tests can be completely deterministic, regardless of system time or any changes to DateTimeZoneProviders.Tzdb over the course of different Noda Time releases.
Douglas Stridsberg
@Doggie52
I'm at a loss - I believe my AtLeniently produced an unexpected result on Friday. I am not familiar with the kind of edge cases that AtLeniently makes assumptions about, would anyone have the time to look over a MWE? https://dotnetfiddle.net/0jFTax
I don't see any reason why 19 Apr would have caused any edge cases to crop up between America/New_York and Europe/London, even on tzdb2014e
Jon Skeet
@jonskeet_twitter
I'm afraid I'm finding it hard to follow your example.
The output of that is 10am London.
Which is what you said it should be in the comments.
I suggest you ask a question on Stack Overflow with clearer requirements - it'll be easier to reply there than to switch between Gitter and dotnetfiddle
Douglas Stridsberg
@Doggie52
Makes sense, and this is why I've been at a loss, I don't think this code could produce anything than 10am London, and I'm fairly sure I've boiled it down to a MWE properly. I'm increasing verbosity of my logs for the next 2 weeks and hoping I can catch it
Stephen A. Imhoff
@Clockwork-Muse
@Doggie52 - I'm suspicious of the intent in that code, though. It's implying that you're deriving the date to be closed off of the "current" date of some specific location. If close is run too late (or early, for locations east of London), that's going to change the date that gets reported (so you might close the same day twice). Business dates are only kinda related to actual calendar dates - I would normally prefer to use an explicitly chosen date for open/close (you can derive the date for user confirmation, though).
Stephen A. Imhoff
@Clockwork-Muse
It also makes me suspicious of the use of 10:00AM. Either you have an arbitrary "business date" that you explicitly open/close and bucket sales into, and thus "bucket start/end time" is irrelevant, or you're bucketing based on the absolute Instant(even if the buckets are based off of home office local time), and the time in any individual location is irrelevant.
Douglas Stridsberg
@Doggie52
Hey @Clockwork-Muse - FYI this is part of a trading algorithm where a decision needs to be made at a specific time of day, every day. This decision time of day is 10AM Ldn time and is explicit. My input is a current datetime from the system that I know the timezone of. The reason I'm using the date part of the input to get the decision time is to avoid DST ambiguities.
I understand the MWE prompts a lot of questions but I did my best to remove things that didn't factor in.
I've done some further digging and I believe the error lies elsewhere and in how I assumed my input to be a 0-tick "whole" hour whereas in reality it was often a few ticks after the hour.
Shimmy
@weitzhandler
Hi, I'm working with genealogical data and I need to be able to store a dynamic date portion, that can either be a full DateTime, Date, AnnualDate etc, all stored with EF Core.
1) Is there a generalized entity that can hold this piece of data?
2) Is there a way to store such a column with EF Core and sort rows by it?
Thank you!
Stephen A. Imhoff
@Clockwork-Muse
1) No. In a functional language you'd want what's known as a discriminated union, so you probably want to mimic that. Keep in mind that the moment somebody is born is technically an Instant, although for historical/legal reasons it's stated as some sort of ZonedDateTime (with resolution in minutes).
2) Not by default. For one thing, what meaningful sorting are you planning on doing between LocalDateTime values and AnnualDate values? LocalDateTime naturally sorts by year first. From the database side, your best bet is likely a set of nullable columns (setting less precise ones if a more precise one is specified), plus a set of separated, derived columns to perform searching/sorting on.
Shimmy
@weitzhandler
Hey and thanks for your detailed reply!
Let me narrow it down and say I want to have month/day + optional year, then be able to search whos birth-day or memorial-day happens today, so year is irrelevant to my query, but I need to be able to store and retrieve it. Are two separate columns the only solution?
Stephen A. Imhoff
@Clockwork-Muse
If you have an "optional" piece of data, in SQL-land that's a nullable column. You can abstract it by creating a custom type (which is a feature underutilized in most deployed applications) that does things like auto-convert from a date-time. Doing separate columns would also help with querying independently from year (that is, have another index on that particular column/pair).
Or, if you can guarantee that you always have a full date (birthdays always fall into this category, and for memorial dates you could use the first occurrence), you can construct all possible "first" dates with the use of a number/calendar table.
John Knoop
@johnknoop
Hi! Anyone here who by any chance remember that original video from a talk that the creator of Nodatime gave, about how the BCL datetime construct is essentially broken and introducing Nodatime? I wanna show it to a coworker, and I want to be sure I find the same video I once saw because it was very good.
Jon Skeet
@jonskeet_twitter
In terms of critiquing the BCL construction, this blog post is probably the best option: https://blog.nodatime.org/2011/08/what-wrong-with-datetime-anyway.html
If you mean the "Humanity: Epic Fail" talk, I don't think the video of that exists any more, but I have a blog post about it: https://codeblog.jonskeet.uk/2009/11/02/omg-ponies-aka-humanity-epic-fail/ (With currently broken pictures - I need to fix that...)
John Knoop
@johnknoop
Thanks
Hadi Eskandari
@HEskandari
Hello...Who's the best person to contact about the website on nodatime.org (specifically dotnet try stuff?)
Jon Skeet
@jonskeet_twitter
@HEskandari: Depending on the reason for contact, either email me directly (skeet@pobox.com), email the Google group, or file an issue in GitHub.
Hadi Eskandari
@HEskandari
@jonskeet_twitter thanks, I'll send you an email momentarily
Artur Malendowicz
@artur-malendowicz-gain

hello. quick question: wanted to use NodaTime to detect current IANA on iOS (xamarin) - I am based in Poland, but for me using:
DateTimeZoneProviders.Tzdb.GetSystemDefault();

always returns Europe/Zurich

Jon Skeet
@jonskeet_twitter
I suspect that's because there are no differences between Switzerland and Poland "around now" (IIRC, we detect based on offsets for two years ago to two years in the future).
(I assume TimeZoneInfo.Local.Id returns "Local" or something similarly useless? I think we use the ID or name if possible.)
(It might be worth asking about this on GitHub - I actually get notified of changes on GitHub much quicker than on Gitter... and it leaves a more lasting record.)
Stephen A. Imhoff
@Clockwork-Muse
@jonskeet_twitter - Even though Warsaw is +2/+3, and Zurich is +1/+2?
Jon Skeet
@jonskeet_twitter
Hmm... that's odd then.
(Hadn't actually checked.)
@artur-malendowicz-gain: Could you check what DateTime.Now returns on the device? Definitely worth filing a GitHub issue with a lot more information.
Fred Zhang
@falinelli_twitter
Hi, I have a question: what is the biggest year NZD file can reach?
the latest NZD file I got is published on 2019 but it can only reach 2025.
I am wondering if we can get a file that can reach 2050
Jon Skeet
@jskeet
Could you explain what you mean by "it can only reach 2025"? All nzd files should cover all of history. This is probably some problem with your code rather than the nzd file. It's probably best to file a github issue or ask a Stack Overflow question.
Andrew Kondratiuk
@Alantoo
Hi all. I really like NodaTime and would like to use it. But I need some help to find answers to a few questions. It would be awesome if you can help with it. Is it possible to use NodaTime with AspNetCore? I'm trying to recieve query param of type Instant but with no success. It looks like there are no ModelBinder and I can't find it. Environment is: Windows 10, AspNetCore 2.2 and NodaTime 2.4.6. JSON parsing works. But unfortunatelly with query/path/form params does not. Thank you in advance
Jon Skeet
@jonskeet_twitter
These would be better questions for Stack Overflow, including showing exactly what you've tried. Yes, it works fine with ASP.NET Core, but you need to configure Json.NET to use NodaTime.Serialization.JsonNet
Andrew Kondratiuk
@Alantoo
Thank you for quick reply. It might be quick fix. But if does not - sure, I will create question on SO. If you never mind I'll try to explain what problem I got. JSON serialization and deserialization works fine. I can't receive plain arguments (Instant in this case). Exception message told me that there are no ModelBinder. Should I register comething special for it? Thank you again.
Jon Skeet
@jonskeet_twitter
No, please create a question on SO, with example code so it's easy to reproduce, and the exact exception including a stack trace.
Andrew Kondratiuk
@Alantoo
Okay, thanks.
Andrew Kondratiuk
@Alantoo
Hi all. I'm using nodatime beta1 in my project and I got problem with parsing ZonedDateTime. It looks like there are no TypeConverter for it. Instant, OffsetDateTime, LocalDate works great. But for ZonedDateTime I got error: Could not create an instance of type 'NodaTime.ZonedDateTime'. Model bound complex types must not be abstract or value types and must have a parameterless constructor. Is it by design and I should create ModelBinder for it or this is a bug? Thanks in advance
Jon Skeet
@jonskeet_twitter
ZonedDateTime would be tricky to do in a general way - which time zone provider should it use? I admit I didn't spot that it was missing when the TypeConverter PR came in.
I've filed nodatime/nodatime#1407 to track that
Andrew Kondratiuk
@Alantoo
Understood. I'll create ModelBinder for it for now. Thanks.
ekwus
@ekwus

Hey does anyone know if NodaTime Instant serialises/deserialises correctly when using Json.net and ASP.NET Core 3.0 Preview 9? I'm not able to get things to work at all when using the ConfigureForNodatime extension

services.AddMvc().AddNewtonsoftJson((options) => options.SerializerSettings.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb));

and if I just ignore adding the extension I just get 1 January 1970 as the Instant values - looking at Fiddler, the serialisation for the field is empty. Interestingly, Duration does serialise correctly in the same object over the same Http Get.

I'm calling the controller from a Blazor client side app if that makes a differenc too?

Jon Skeet
@jonskeet_twitter
@ekwus: This would be best asked on Stack Overflow. You might want to look at the question slightly earlier in the chat though: https://stackoverflow.com/questions/57753258
ekwus
@ekwus
@jonskeet_twitter Thanks I'll post it on SO. I did see the question above however it answers it for ASP.NE Core 2.2 and the AddJsonOptions extension is gone from 3.0. I've tried a few ways around using it with the AddNewtonsoftJson extension but nothing works. Anyway, I'll put it all on SO to ensure it gets captured for others too. Cheers
ekwus
@ekwus
@jonskeet_twitter Further update. I create a clean ASP.NET Core 3.0 project to push to Github as a reference for the StackOverflow question but the serialisation was working correctly after I figured out the new extensions. Looks like its a setup issue in my other project. I'm also pulling the values from LiteDB in that app so possibly an area for me to look at too. Cheers