-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NaN shown instead of Create and Modify Datetime #308
Comments
I don't want to overload JS script trying to handle cases "for all occasions". There is a defined format for expected timestamp, so I would prefer the fix for ASP.NET Core connector. If you are able to create a PR (or provide a code snippet at least) for ASP.NET Core connector I would accept it and include into the package. |
I fully understand that and completely agree. I know I presented this as a Windows fix but it might still be valuable. Are there situations where a date will parse but shouldn't be displayed? I'm working with the ASP.NET connector and there are other changes already. What is the proper date format the UI code is expecting? |
Unix timestamp in seconds
Ok, makes sense. I would propose it in a different manner. The code snippet below should handle seconds timestamp as well as milliseconds, and also make attempt to turn string into the var formatTimestamp = function (datetime) {
var isString = typeof datetime === "string";
var isInteger = typeof datetime === "number" && Math.floor(datetime) === datetime;
// invalid argument
if (!(isString || isInteger)) return '';
// value look like seconds, while Date() accepts milliseconds
if (isInteger && datetime < 10000000000) {
datetime = datetime * 1000
}
var date = new Date(datetime);
// invalid Date() object, display datetime without formatting
if (!(date instanceof Date) || isNaN(date)) {
return datetime;
}
// Timezone support requires "iana-tz-data" package:
// https://github.com/globalizejs/globalize/blob/master/README.md#3-iana-time-zone-data
return globalize.formatDate(date, config.formatter.datetime);
}; Looking forward your feedback.
Awesome! If you will provide a changelog along with PR it would speed up a review. |
This looks pretty bullet proof to me. :) I've updated the connector to return GMT time in Unix format. It seems to work well with your existing code. It even works correctly with the globalize library. |
Added Recursive Searching support Added GetInfo() function for completeness Fixes psolom#308 - NaN shown instead of Create and Modify Datetime Fixed bug psolom#314, [Object:Object] instead of cannot find file/dir messages, etc Reduced the overhead of the Summarize() function ** Image height and width information is not returned.
In raising this issue, I confirm the following (please check boxes):
I use the following server-side connector (check one):
My familiarity with the project is as follows (check one):
Hello,
I am leveraging the ASP.NET Core connector on a windows 2008 R2 server. I would see a 'NaN' for the modified file dates. The issue come from the connector returning a human readable date in the timestamp, which then gets multiplied by 1000. This creates a undefined value. Below is one potential fix written against the javascript library. I also considered updating the connector so that it returns a UNIX timestamp, but I thought this was best as long as it doesn't mess up everyone.
The text was updated successfully, but these errors were encountered: