Linq Select DateTime returns local time #1274
-
class Data
{
public DateTime Date { get; set; }
} Query: DateTime is indexed via duplicated field and |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@f1nzer could you check https://www.npgsql.org/doc/types/datetime.html? It seems to be that it looks like default Npgsql behaviour. See also more in: #1179 |
Beta Was this translation helpful? Give feedback.
-
Are you saying it is converting the date to the local timezone in the second case? That might indeed be a bug. I'd expect the DateTime Kind set to If In other words, either conversion method will always result in a converted value when Kind is Unspecified, which is probably not what you want in this case. When you know the source is in UTC, you can make ToUniversalTime "safe" by calling DateTime.SpecifyKind to set Kind to Utc. |
Beta Was this translation helpful? Give feedback.
@f1nzer could you check https://www.npgsql.org/doc/types/datetime.html? It seems to be that it looks like default Npgsql behaviour. See also more in: #1179