NodaTime | better date-time library | Data Labeling library
kandi X-RAY | NodaTime Summary
kandi X-RAY | NodaTime Summary
A better date-time library for .Net by Mr Skeet and Mr Colebourne
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of NodaTime
NodaTime Key Features
NodaTime Examples and Code Snippets
Community Discussions
Trending Discussions on NodaTime
QUESTION
I am trying to migrate a project from .NET Core 3.1 to .NET 6. I have followed the official migration guide from Microsoft.
During build in startup.Configure I get
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Linq, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.'
This is .csproj:
...ANSWER
Answered 2022-Feb-28 at 10:46I had to update AzureFunctionsVersion
from v3
to v4
. That solved the issue.
Upgrading Azure Functions wasn't mentioned in the official migration guide from Microsoft.
QUESTION
So I'm running into a rather odd issue here. I've got a PostgreSQL 14 server and I'm using the Npgsql Entity Framework Core provider to access it. If I have an Entity Framework Core entity that contains a date as a NodaTime Instant
type (which becomes timestamp with time zone
in the database) and try to project that via .InZone(timeZone).LocalDateTime
, I run into 3 situations.
Actual example query would be something like this:
...ANSWER
Answered 2022-Feb-25 at 21:53The NodaTime plugin doesn't support passing parameterized time zones from .NET; you can only use a constant expression such as DateTimeZoneProviders.Tzdb["Europe/Berlin"]
(see these docs for supported translations). You can use this to convert a PG timestamp with time zone
into a timestamp without time zone
in PG, and then retrieve the result as a timestamp without time zone
, which can be read as a NodaTime LocalDateTime.
However, if what you're looking for is to get a ZonedDateTime/LocalDateTime with the time zone of the client machine (where .NET is executing), then doing .InUtc().LocalDateTime
is the way to do that - any reason you're trying to avoid it?
A bit more context (as well as a full code sample) could shed some more light on what you're trying to achieve.
QUESTION
I would like to look up a timezone based on an ISO region code or coordinates.
I have a collection of data points with coordinates, county and region codes, eg:
33.942501,-118.407997,"US","US-CA"
I want to find the IANA timezone identifier, eg. America/Los_Angeles
, based on the above info.
Is it possible to do that with NodaTime
? I cannot see a way to look up DateTimeZone
or timezone identifier from a region code or location.
ANSWER
Answered 2022-Feb-18 at 15:18The GeoTimeZone NuGet package can provide a lookup by lat/long to IANA ID, and then you can use DateTimeZoneProviders.Tzdb[id]
to get the DateTimeZone
from that. See the project home page for more details.
Within Noda Time itself, you can use TzdbDateTimeZoneSource.Default
(or one that you've loaded) and then the ZoneLocations
or Zone1970Locations
properties to find zones for specific ISO-3166 countries... but they doesn't go below the "country" level (although they do have exemplar lat/long values). They're based on zone.tab and zone1970.tab - so any information not in that file isn't present in Noda Time either.
It sounds like GeoTimeZone is probably your best option here.
QUESTION
I have completed the below tutorial to correctly configure a working elsa server
Part 2 of Building Workflow Driven .NET Applications with Elsa 2
I made modifications for running it with docker-compose allong with the dependant services.
Everything works as expected except the intellisense in the designer window.
Ive noticed a couple of errors in the browser console as below
this is my startup class
...ANSWER
Answered 2022-Jan-07 at 11:11Most likely the issue is that the docker image for the dashboard is not compatible with the workflow server hosted by your application.
The cause of this mismatch is that the blog post references Elsa 2.3 NuGet packages, while the dashboard docker image is built from the latest source code in the master branch (which is something that should be fixed to avoid confusion like you're experiencing).
To make the dashboard work (which is built against latest source code), you need to update your workflow server app to reference the latest Elsa preview packages from MyGet (which are also built against latest source code from the master branch).
The following documentation describes how to reference the MyGet feed: https://elsa-workflows.github.io/elsa-core/docs/next/installation/installing-feeds#myget
QUESTION
I have the following message in C# code:
...ANSWER
Answered 2021-Dec-21 at 08:00I've found the answer on MassTransit discord. In addition to configuring serializer it is necessary to configure deserializer as well:
QUESTION
I am using EF Core + Npgsql + NodaTime. In db configuration I use .UseNodaTime()
option and so far it was working ok - all entity props of type NodaTime.Instant
are properly mapped to timestamp
PG type. However now I wanted to add prop of type NodaTime.Duration
which, according to the docs, should map to PG interval
:
ANSWER
Answered 2021-Oct-30 at 08:10Support for mapping NodaTime Duration to PostgreSQL interval
was only added in version 5 of the provider, you'll have to upgrade in order to use it. Note that the upcoming version 6 (to be released in a couple weeks) substantially improves NodaTime support in various ways - I'd recommend waiting and switching to that.
QUESTION
Is it possible to directly bind command line input to NodaTime.Duration
(or System.TimeSpan
) using System.CommandLine
? Maybe by supplying a custom converter somewhere?
ANSWER
Answered 2021-Oct-17 at 07:05I haven't worked with System.CommandLine
much, and there's not much documentation around custom parsing, but I believe what you want is a ParseArgument
. Fortunately it's fairly easy to write that an extension method on the NodaTime IPattern
to create an instance of that.
Here's a not-very-thoroughly-tested extension method:
QUESTION
I'm using EF Core with
I've just added a NodaTime.LocalDate
field to my entity which uses a package called NodaTime:
The field:
...ANSWER
Answered 2021-Oct-01 at 14:26The above works for me as-is using 5.0.10, without a value converter:
QUESTION
Using NodaTime, and I'm looking to deconstruct a ZonedDateTime
in order to save it to a SQL database. It seems to me there are a few options. I could deconstruct it to Instant
and DateTimeZone
and save it as a datetime2
and nvarchar(50)
. I could deconstruct it to DateTimeOffset
and DateTimeZone
or LocalDateTime
and DateTimeZone
and, in either case, save it as datetimeoffset
and nvarchar(5)
.
Is there a difference, or reason to chose one over the other?
The only think I can think of is that the datetimeoffset
plus nvarchar(50)
might be better in case the db is ever read by a service that doesn't have as robust a timezone -> offset conversion system as NodaTime. In that situation I've at least capture what the offset was, in that timezone, at that point in time, which is lost (or at needs to be recalculated from historical timezone information) with a datetime2
plus nvarchar(50)
approach.
Are there other considerations I'm missing?
...ANSWER
Answered 2021-Sep-22 at 07:20I would suggest using a datetimeoffset
and a separate time zone ID. I'm assuming datetimeoffset
still allows you to perform a total ordering (i.e. by instant) - although I suppose it's possible that that is less efficient than if you've stored a datetime2
. It also may well take more space in the database, given that it's storing more data.
Even if the database is read by a service that does have time zone conversion operations, storing the offset in the database allows you to perform queries over the data based on the local date, e.g. "Show me all my appointments on Tuesday". You can't perform that query purely database-side if you only have instants.
One other thing you might want to consider if you're storing future date/time values is that the predicated time zone offset may change due to changes in rules. If your original input data was as a local date/time (which is usually the case if you're working with ZonedDateTime
) then the datetimeoffset
approach is storing "what the user gave you" plus the inferred offset - you can easily then update all the data with a later version of the time zone database if necessary. If you only have the computed instant, you'd need to work out what the original local date/time was in the "old" time zone database before adjusting it to the "new" time zone database. That may also have lost information, e.g. if the input value used to be ambiguous (so you picked one offset or the other) but no longer is.
QUESTION
I've been learning how to use NodaTime
, as I think it is a far superior "all things temporal" library that the handful of structs in the BCL. Reading the docs and experimenting.
This experiment has me flummoxed. I started out just trying to parse a ZonedDateTime
.
The things I was trying were not successful, so I thought I'd try something which should be "bulletproof". The following code represents that attempt:
ANSWER
Answered 2021-Sep-04 at 07:23Any ideas what I am doing wrong?
You're using ZonedDateTimePattern.GeneralFormatOnlyIso
, which is (as the name suggests) only for formatting, not for parsing.
To get a pattern which is able to parse time zones, you need to specify an IDateTimeZoneProvider
. The easiest way to do that is to start with a format-only pattern, and use WithZoneProvider
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install NodaTime
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page