private DateTime TimestampToDateTimeUtc(long timestamp) { // Firefox stores expiry timestamps as unix time seconds. // DateTime is not capable of representing the same range of dates as the browser's timestamps. if (timestamp > DateUtilities.ToUnixTimeSeconds(DateTimeOffset.MaxValue)) { return(DateTime.MaxValue); } return(DateUtilities.FromUnixTimeSeconds(timestamp).DateTime); }
private DateTime TimestampToDateTimeUtc(long timestamp) { // CHrome's epoch starts at 1601-01-01T00:00:00Z, and the timestamp is in nanoseconds: // https://stackoverflow.com/a/43520042 long timestampSeconds = timestamp / 1000000; timestampSeconds -= 11644473600; // 1601-01-01T00:00:00Z is 11644473600 seconds before the unix epoch // DateTime is not capable of representing the same range of dates as the browser's timestamps. if (timestampSeconds > DateUtilities.ToUnixTimeSeconds(DateTimeOffset.MaxValue)) { return(DateTime.MaxValue); } return(DateUtilities.FromUnixTimeSeconds(timestampSeconds).DateTime); }