protected override void Execute(CodeActivityContext executionContext)
        {
            var      dateString = DateString.Get <string>(executionContext);
            var      dateFormat = DateFormat.Get <string>(executionContext);
            DateTime date;

            if (!String.IsNullOrWhiteSpace(dateString))
            {
                var provider = CultureInfo.InvariantCulture;

                if (!DateTime.TryParseExact(dateString, dateFormat, provider, DateTimeStyles.None, out date))
                {
                    date = Date.Get <DateTime>(executionContext);
                }
            }
            else
            {
                date = Date.Get <DateTime>(executionContext);
            }

            bool am;

            var hour = date.Hour;

            Year.Set(executionContext, date.Year);
            YearText.Set(executionContext, date.Year.ToString());
            Month.Set(executionContext, date.Month);
            Day.Set(executionContext, date.Day);
            Hour24.Set(executionContext, date.Hour);

            var cultureInfo = GetCultureInfo(executionContext, LanguageCode.Get <int>(executionContext));

            MonthText.Set(executionContext, date.ToString("MMMM", cultureInfo.DateTimeFormat));
            DayOfWeekString.Set(executionContext, date.ToString("dddd", cultureInfo.DateTimeFormat));


            if (date.Hour >= 12)
            {
                am   = false;
                hour = date.Hour - 12;
            }
            else
            {
                am = true;
            }

            Hour.Set(executionContext, hour);
            IsAM.Set(executionContext, am);
            IsPM.Set(executionContext, !am);
            Minute.Set(executionContext, date.Minute);

            DayOfWeek.Set(executionContext, (int)date.DayOfWeek);
            DayOfYear.Set(executionContext, date.DayOfYear);
            Week.Set(executionContext, GetWeek(date));
        }
Example #2
0
        /// <inheritdoc />
        protected override void Execute(Context context)
        {
            var dateTime = InputDateTime.Get(context);

            DateAsDT.Set(context, new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, 0, 0, 0));
            TimeAsDT.Set(context, new DateTime(1, 1, 1, dateTime.Hour, dateTime.Minute, dateTime.Second));
            Day.Set(context, dateTime.Day);
            Month.Set(context, dateTime.Month);
            Year.Set(context, dateTime.Year);
            YearAsString.Set(context, dateTime.Year.ToString());
            Hour.Set(context, dateTime.Hour);
            Minute.Set(context, dateTime.Minute);
            Second.Set(context, dateTime.Second);
            Kind.Set(context, dateTime.Kind.ToString());
        }