DateTimeExtensions | This project is a merge of several common DateTime operations on the form of extensions to System.D | Date Time Utils library
kandi X-RAY | DateTimeExtensions Summary
kandi X-RAY | DateTimeExtensions Summary
This project is a merge of several common DateTime operations on the form of extensions to System.DateTime, including natural date difference text (precise and human rounded), holidays and working days calculations on several culture locales.
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 DateTimeExtensions
DateTimeExtensions Key Features
DateTimeExtensions Examples and Code Snippets
Community Discussions
Trending Discussions on DateTimeExtensions
QUESTION
I'm trying to convert milliseconds timestamp to a DateTime, but it throws an exception at reader.GetString()
:
System.InvalidOperationException: 'Cannot get the value of a token type 'Number' as a string.'
It means I'm trying to read it as a string when it is a value. If I replace it with reader.GetInt64()
or reader.GetDouble()
, it works, but the reason I'm writing that question here is because I took this class from one of dotnet's open source projects on GitHub and I doubt that I really need to change the class. I believe the problem could be in my JsonSerializerOptions
.
https://pastebin.com/9AjwSp5L (Pastebin because it exceeds SO's limits)
Snippet ...ANSWER
Answered 2021-Nov-17 at 20:26Let's try to make your converter a bit more forgiving:
QUESTION
We are seeking to convert everything to DateTimeZone Pacific Standard time.
- Database team is not utilizing sql
datetimeoffset
- Web team could have set dates to Pacific Standard Timezone with Moment.Js Angular application settings, however is using Dates instead.
Many of this is too late to change, across database, 1000s of tables, and application code.
I am asked to resolve this, so any dates stored in database is converted to PST before each API .
I created static function called, DateTimeExtensions.ToPacificTimeZone(newDateTime)
.
1) We created method ObjectDateTimeConverter, which traverses through All class DTO members, nested classes, It finds Any Datetime class member, and runs the PacificTimeZone static function.
2) The method is called automatically before each API request, converting all the data automatically, with an ActionFilter Method before POST request.
a) I am curious if Microsoft has a Nuget package or setting to automatically convert everything to a certain time zone, before an API. b) Is there perhaps a data serialization technique or optimal way? This way, I do not have to write custom code .
...ANSWER
Answered 2020-Jun-15 at 16:53You can use JsonConverter for your problem . JsonDateTimeConverter convert every datetime in your api requests and responses to specific date timezone .
Try this :
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install DateTimeExtensions
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