This commit is contained in:
7
devdocs/specs/core-time-and-dates.txt
Normal file
7
devdocs/specs/core-time-and-dates.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
TIME (DATE AND TIME handling)
|
||||||
|
|
||||||
|
RAVEN stores all times and dates in UTC in DB and internally all is UTC
|
||||||
|
User has a timezone offset setting which is used to format dates for display at the client
|
||||||
|
Dates coming from the client are all assumed to be in UTC format (i.e. converted at the client from input)
|
||||||
|
TimeZoneOffset is also used for relative date filters in list filter retrieval.
|
||||||
|
- i.e. "NextMonth" is assumed to be client relative, so the server will use their offset to calculate what next month meens to them in the query builder
|
||||||
@@ -355,11 +355,12 @@ namespace AyaNova
|
|||||||
var ct = context.RequestServices.GetService<AyContext>();
|
var ct = context.RequestServices.GetService<AyContext>();
|
||||||
|
|
||||||
//get the user record
|
//get the user record
|
||||||
var u = ct.User.AsNoTracking().Where(a => a.Id == userId).Select(m => new { roles = m.Roles, name = m.Name, id = m.Id, localeId = m.LocaleId }).First();
|
var u = ct.User.AsNoTracking().Where(a => a.Id == userId).Select(m => new { roles = m.Roles, name = m.Name, id = m.Id, localeId = m.LocaleId, tzOffset = m.UserOptions.TimeZoneOffset }).First();
|
||||||
context.Request.HttpContext.Items["AY_ROLES"] = u.roles;
|
context.Request.HttpContext.Items["AY_ROLES"] = u.roles;
|
||||||
context.Request.HttpContext.Items["AY_USERNAME"] = u.name;
|
context.Request.HttpContext.Items["AY_USERNAME"] = u.name;
|
||||||
context.Request.HttpContext.Items["AY_USER_ID"] = u.id;
|
context.Request.HttpContext.Items["AY_USER_ID"] = u.id;
|
||||||
context.Request.HttpContext.Items["AY_LOCALE_ID"] = u.localeId;
|
context.Request.HttpContext.Items["AY_LOCALE_ID"] = u.localeId;
|
||||||
|
context.Request.HttpContext.Items["AY_USER_TZ_OFFSET"] = u.tzOffset;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace AyaNova.Biz
|
|||||||
public static class FilterSqlCriteriaBuilder
|
public static class FilterSqlCriteriaBuilder
|
||||||
{
|
{
|
||||||
//"SELECT *, xmin FROM AWIDGET name Like 'BoolDataFilterTest%' AND active = true AND "
|
//"SELECT *, xmin FROM AWIDGET name Like 'BoolDataFilterTest%' AND active = true AND "
|
||||||
public static string DataFilterToSQLCriteria(AyaNova.Models.DataFilter dataFilter, FilterOptions filterOptions)
|
public static string DataFilterToSQLCriteria(AyaNova.Models.DataFilter dataFilter, FilterOptions filterOptions, decimal timeZoneOffset)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(dataFilter.Filter))
|
if (string.IsNullOrWhiteSpace(dataFilter.Filter))
|
||||||
@@ -38,7 +38,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
var dataType = filterOptions.Flds.Find(x => x.Fld == fld).Type;
|
var dataType = filterOptions.Flds.Find(x => x.Fld == fld).Type;
|
||||||
|
|
||||||
sb.Append(DataFilterToColumnCriteria(fld, dataType, opType, val, tagList));
|
sb.Append(DataFilterToColumnCriteria(fld, dataType, opType, val, tagList, timeZoneOffset));
|
||||||
if (i < FilterArray.Count - 1)
|
if (i < FilterArray.Count - 1)
|
||||||
{
|
{
|
||||||
sb.Append(" AND ");
|
sb.Append(" AND ");
|
||||||
@@ -51,7 +51,7 @@ namespace AyaNova.Biz
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Translate DataFilter to Postgres friendly SQL criteria
|
/// Translate DataFilter to Postgres friendly SQL criteria
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static string DataFilterToColumnCriteria(string sColumn, string sDataType, string sOperator, string sValue, List<string> sTags)//, bool IsCompound)
|
private static string DataFilterToColumnCriteria(string sColumn, string sDataType, string sOperator, string sValue, List<string> sTags, decimal timeZoneOffset)//, bool IsCompound)
|
||||||
{
|
{
|
||||||
bool TagFilter = sTags.Count < 0;
|
bool TagFilter = sTags.Count < 0;
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|||||||
@@ -16,6 +16,12 @@ namespace AyaNova.Models
|
|||||||
//-------------
|
//-------------
|
||||||
[EmailAddress]
|
[EmailAddress]
|
||||||
public string EmailAddress { get; set; }
|
public string EmailAddress { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// As of today Dec 10 2018 all time zones in the world are either on the hour, half hour or 45 minute mark from utc so
|
||||||
|
/// keeping this value as decimal hours for back compatibility with v7 and easier for user to enter
|
||||||
|
/// 8.5 for 8:30 time difference or 12.75 for 12:45 time differnce for example
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
public decimal TimeZoneOffset { get; set; }
|
public decimal TimeZoneOffset { get; set; }
|
||||||
public int UiColor { get; set; }
|
public int UiColor { get; set; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user