Example #1
0
        private static bool HasError(string data, Column column)
        {
            switch (column.TypeName)
            {
            case "datetime": return(!Times.InRange(data.ToDateTime()));

            default: return(data == null);
            }
        }
Example #2
0
        private static bool HasError(SqlParam sqlParam, Column column)
        {
            if (sqlParam.Name == column.ColumnName)
            {
                switch (column.TypeName)
                {
                case "datetime": return(!Times.InRange(sqlParam.Value.ToDateTime()));

                default: return(sqlParam.Value == null);
                }
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        private HtmlBuilder LimitText(HtmlBuilder hb)
        {
            var value = Value.ToLocal();

            if (!Times.InRange(value))
            {
                return(hb);
            }
            var now = VerType == Versions.VerTypes.Latest
                ? DateTime.Now.ToLocal()
                : UpdatedTime.ToLocal();
            var css   = LimitCss(now, value);
            var years = Times.DateDiff(Times.Types.Years, now, value);

            if (Math.Abs(years) >= 2)
            {
                return(years > 0
                    ? hb.P(css: css, action: () => hb
                           .Text(text: Displays.LimitAfterYears(years.ToString())))
                    : hb.P(css: css, action: () => hb
                           .Text(text: Displays.LimitBeforeYears((years * -1).ToString()))));
            }
            var months = Times.DateDiff(Times.Types.Months, now, value);

            if (Math.Abs(months) >= 2)
            {
                return(months > 0
                    ? hb.P(css: css, action: () => hb
                           .Text(text: Displays.LimitAfterMonths(months.ToString())))
                    : hb.P(css: css, action: () => hb
                           .Text(text: Displays.LimitBeforeMonths((months * -1).ToString()))));
            }
            var days = Times.DateDiff(Times.Types.Days, now, value);

            if ((days >= 0 && days >= 2) || (days < 0))
            {
                return(days > 0
                    ? hb.P(css: css, action: () => hb
                           .Text(text: Displays.LimitAfterDays((days - 1).ToString())))
                    : hb.P(css: css, action: () => hb
                           .Text(text: Displays.LimitBeforeDays(((days * -1) + 1).ToString()))));
            }
            var hours = Times.DateDiff(Times.Types.Hours, now, value);

            if (Math.Abs(hours) >= 3)
            {
                return(hours > 0
                    ? hb.P(css: css, action: () => hb
                           .Text(text: Displays.LimitAfterHours(hours.ToString())))
                    : hb.P(css: css, action: () => hb
                           .Text(text: Displays.LimitBeforeHours((hours * -1).ToString()))));
            }
            var minutes = Times.DateDiff(Times.Types.Minutes, now, value);

            if (Math.Abs(minutes) >= 3)
            {
                return(minutes > 0
                    ? hb.P(css: css, action: () => hb
                           .Text(text: Displays.LimitAfterMinutes(minutes.ToString())))
                    : hb.P(css: css, action: () => hb
                           .Text(text: Displays.LimitBeforeMinutes((minutes * -1).ToString()))));
            }
            var seconds = Times.DateDiff(Times.Types.Seconds, now, value);

            if (Math.Abs(seconds) >= 1)
            {
                return(seconds > 0
                    ? hb.P(css: css, action: () => hb
                           .Text(text: Displays.LimitAfterSeconds(seconds.ToString())))
                    : hb.P(css: css, action: () => hb
                           .Text(text: Displays.LimitBeforeSeconds((seconds * -1).ToString()))));
            }
            return(hb.P(css: "Display-just", action: () => hb
                        .Text(text: Displays.LimitJust())));
        }
Example #4
0
        public static HtmlBuilder ElapsedTime(this HtmlBuilder hb, DateTime value)
        {
            if (!Times.InRange(value))
            {
                return(hb);
            }
            var now = DateTime.Now.ToLocal();
            var css = "elapsed-time" +
                      ((DateTime.Now - value).Days > Parameters.General.SiteMenuHotSpan
                    ? " old"
                    : string.Empty);
            var displayTime = Displays.UpdatedTime() + " " +
                              value.ToString(Sessions.CultureInfo());
            var years = Times.DateDiff(Times.Types.Years, value, now);

            if (years >= 2)
            {
                return(hb.Span(
                           attributes: new HtmlAttributes()
                           .Class(css)
                           .Title(displayTime),
                           action: () => hb
                           .Text(text: Displays.YearsAgo(years.ToString()))));
            }
            var months = Times.DateDiff(Times.Types.Months, value, now);

            if (months >= 2)
            {
                return(hb.Span(
                           attributes: new HtmlAttributes()
                           .Class(css)
                           .Title(displayTime),
                           action: () => hb
                           .Text(text: Displays.MonthsAgo(months.ToString()))));
            }
            var days = Times.DateDiff(Times.Types.Days, value, now);

            if (days >= 3)
            {
                return(hb.Span(
                           attributes: new HtmlAttributes()
                           .Class(css)
                           .Title(displayTime),
                           action: () => hb
                           .Text(text: Displays.DaysAgo(days.ToString()))));
            }
            var hours = Times.DateDiff(Times.Types.Hours, value, now);

            if (hours >= 3)
            {
                return(hb.Span(
                           attributes: new HtmlAttributes()
                           .Class(css)
                           .Title(displayTime),
                           action: () => hb
                           .Text(text: Displays.HoursAgo(hours.ToString()))));
            }
            var minutes = Times.DateDiff(Times.Types.Minutes, value, now);

            if (minutes >= 3)
            {
                return(hb.Span(
                           attributes: new HtmlAttributes()
                           .Class(css)
                           .Title(displayTime),
                           action: () => hb
                           .Text(text: Displays.MinutesAgo(minutes.ToString()))));
            }
            var seconds = Times.DateDiff(Times.Types.Seconds, value, now);

            if (seconds >= 1)
            {
                return(hb.Span(
                           attributes: new HtmlAttributes()
                           .Class(css)
                           .Title(displayTime),
                           action: () => hb
                           .Text(text: Displays.SecondsAgo(seconds.ToString()))));
            }
            return(hb.Span(css: css, action: () => hb
                           .Text(text: Displays.LimitJust())));
        }