示例#1
0
        public TimeZoneInfo GetUserTimeZone(UserEntity user)
        {
            TimeZoneInfo timeZoneInfo = null;

            if (_systemSettings.AllowUsersToSetTimeZone)
            {
                var timeZoneId = string.Empty;
                if (user != null)
                {
                    timeZoneId = _userAttributeService.GetValue(user, UserAttribute.TimeZoneId, "", false, true);
                }

                if (PatternValidator.IsValidTimeZoneId(timeZoneId))
                {
                    timeZoneInfo = FindTimeZoneById(timeZoneId);
                }
            }

            return(timeZoneInfo ?? DefaultTimeZone);
        }
示例#2
0
 public static IChainableConstraint <IStringConstraints> IsTimeZoneId(this IStringConstraints constraints, bool ignoreEmpty = true)
 {
     return(constraints.Satisfy(v => (ignoreEmpty && string.IsNullOrEmpty(v)) || PatternValidator.IsValidTimeZoneId(v)));
 }