Ejemplo n.º 1
0
            public void InvalidDate()
            {
                DateTime result;
                bool     success = DateTimeFunctions.TryCreate("2000", "2", "31", out result);

                Assert.IsFalse(success);
            }
Ejemplo n.º 2
0
        //public void __construct(string isostr, int options = 0)
        //{
        //    // https://en.wikipedia.org/wiki/ISO_8601#Repeating_intervals
        //    // "R5/2008-03-01T13:00:00Z/P1Y2M10DT2H30M"
        //    throw new NotImplementedException();
        //}

        IEnumerator <DateTimeInterface> IEnumerable <DateTimeInterface> .GetEnumerator()
        {
            DateTimeImmutable current = start as DateTimeImmutable ?? (start as DateTime)?.AsDateTimeImmutable() ?? throw new InvalidOperationException();

            if (include_start_date)
            {
                yield return(current);
            }

            if (end == null && recurrences == 0)
            {
                yield break;
            }

            if (interval.IsZero)
            {
                yield break;
            }

            for (int index = 0; ; index++)
            {
                current = current.add(interval);

                if (end != null && DateTimeFunctions.GetDateTimeFromInterface(end, out var end_datetime, out _))
                {
                    if (current.Time > end_datetime)
                    {
                        yield break;
                    }
                }
Ejemplo n.º 3
0
            public void AllNull()
            {
                DateTime result;
                bool     success = DateTimeFunctions.TryCreate(null, null, null, out result);

                Assert.IsFalse(success);
            }
Ejemplo n.º 4
0
            public void NotANumber()
            {
                DateTime result;
                bool     success = DateTimeFunctions.TryCreate("a", "b", "c", out result);

                Assert.IsFalse(success);
            }
Ejemplo n.º 5
0
            public void AllEmptyStrings()
            {
                DateTime result;
                bool     success = DateTimeFunctions.TryCreate("", "", "", out result);

                Assert.IsFalse(success);
            }
Ejemplo n.º 6
0
            public void OneNull()
            {
                DateTime result;
                bool     success = DateTimeFunctions.TryCreate("2000", "07", null, out result);

                Assert.IsFalse(success);
            }
Ejemplo n.º 7
0
            public void OneEmptyString()
            {
                DateTime result;
                bool     success = DateTimeFunctions.TryCreate("2000", "07", "", out result);

                Assert.IsFalse(success);
            }
Ejemplo n.º 8
0
        public void TestFunctions(string input, int output)
        {
            IDateTimeFunctions _functions = new DateTimeFunctions();
            var x = _functions.PadDate(input);

            Assert.AreEqual(output, x);
        }
Ejemplo n.º 9
0
            public void Default()
            {
                DateTime result;

                DateTimeFunctions.TryCreate("2000", "07", "05", out result);

                Assert.AreEqual(new DateTime(2000, 7, 5), result);
            }
Ejemplo n.º 10
0
        private void hsClone_Click(object sender, EventArgs e)
        {
            _dbReg       = _dbReg.Clone();
            _dbReg.Alias = $@"{_dbReg.Alias}_clone{DateTimeFunctions.GetMSecondsFromNow()}";
            DataToEdit();

            BearbeitenMode = EditStateClass.eBearbeiten.eInsert;
            EditToData();
        }
Ejemplo n.º 11
0
        public string format(string format)
        {
            if (format == null)
            {
                //PhpException.ArgumentNull("format");
                //return false;
                throw new ArgumentNullException();
            }

            return(DateTimeFunctions.FormatDate(format, this.Time, this.TimeZone));
        }
Ejemplo n.º 12
0
        internal static System_DateTime StrToTime(Context ctx, string timestr, System_DateTime time)
        {
            if (string.IsNullOrEmpty(timestr) || timestr.EqualsOrdinalIgnoreCase("now"))
            {
                return(System_DateTime.UtcNow);
            }

            var result = DateTimeFunctions.strtotime(ctx, timestr, DateTimeUtils.UtcToUnixTimeStamp(time));

            return((result >= 0) ? DateTimeUtils.UnixTimeStampToUtc(result) : System_DateTime.UtcNow);
        }
Ejemplo n.º 13
0
    private static System_DateTime StrToTime(string timestr, System_DateTime time)
    {
        if (string.IsNullOrEmpty(timestr) || timestr.Equals("now", StringComparison.OrdinalIgnoreCase))
        {
            return(System_DateTime.UtcNow);
        }

        var result = DateTimeFunctions.strtotime(timestr, DateTimeUtils.UtcToUnixTimeStamp(time));

        return((result >= 0) ? DateTimeUtils.UnixTimeStampToUtc(result) : System_DateTime.UtcNow);
    }
        public void Test_Epoch_Header_Date_Parse()
        {
            string line = " 97 10 24 14  2 45.0000000  0  7 17 27 26  2 10 13 19                0.000044137";

            IDateTimeFunctions p      = new DateTimeFunctions();
            DateTime?          output = p.ExtractEpochDateAndTime(line);

            DateTime expected = new DateTime(1997, 10, 24, 14, 2, 45);

            Assert.AreEqual(true, output.HasValue);
            Assert.AreEqual(expected, output);
        }
            public void ConvertString24HrTimeToSecondsTest()
            {
                // Arrange
                double refSeconds   = 44614.235;
                string target24Time = "12:23:34.235";

                // Act
                double resultSecs = DateTimeFunctions.ConvertString24HrTimeToSeconds(target24Time);

                // Assert
                Assert.AreEqual(refSeconds, resultSecs);
            }
            public void ConvertSecondsToDateTimeObjTest()
            {
                // Arrange
                double   refSeconds  = 44614.235;
                DateTime refDateTime = DateTime.Today.AddSeconds(refSeconds);

                // Act
                DateTime resultDateTime = DateTimeFunctions.ConvertSecondsToDateTimeObj(refSeconds);

                // Assert
                Assert.AreEqual(refDateTime, resultDateTime);
            }
Ejemplo n.º 17
0
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            // Html.ValidationMessageFor() requires an errorMessage (over an exception) to be set when adding errors to the ModelState

            DateTime result;

            if (bindingContext == null)
            {
                throw new ArgumentNullException("bindingContext");
            }

            // datetime split over 3 inputs
            if (bindingContext.ValueProvider.ContainsPrefix(bindingContext.ModelName + ".Year") &&
                bindingContext.ValueProvider.ContainsPrefix(bindingContext.ModelName + ".Month") &&
                bindingContext.ValueProvider.ContainsPrefix(bindingContext.ModelName + ".Day"))
            {
                string year, month, day;

                if (bindingContext.TryGetValue(".Year", out year) &&
                    bindingContext.TryGetValue(".Month", out month) &&
                    bindingContext.TryGetValue(".Day", out day))
                {
                    if (DateTimeFunctions.TryCreate(year, month, day, out result))
                    {
                        return(result);
                    }

                    bindingContext.ModelState.AddModelError(bindingContext.ModelName, string.Format(@"""{0}/{1}/{2}"" is not a valid date", year, month, day));
                    return(null);
                }
            }

            // normal datetime
            if (bindingContext.ValueProvider.ContainsPrefix(bindingContext.ModelName))
            {
                string date;

                if (bindingContext.TryGetValue(out date))
                {
                    if (DateTime.TryParse(date, out result))
                    {
                        return(result);
                    }

                    bindingContext.ModelState.AddModelError(bindingContext.ModelName, string.Format(@"""{0}"" is not a valid date", date));
                    return(null);
                }
            }

            bindingContext.ModelState.AddModelError(bindingContext.ModelName, "Unable to bind the date/time");
            return(null);
        }
            public void ConvertDateTimeObjToSecondsTest()
            {
                // Arrange
                double refSeconds = 44614.235;
                // use current date staring from midnight today andd add seconds
                DateTime targetDateTime = DateTime.Today.AddSeconds(refSeconds);

                // Act
                double resultSecs = DateTimeFunctions.ConvertDateTimeObjToSeconds(targetDateTime);

                // Assert
                Assert.AreEqual(refSeconds, resultSecs);
            }
Ejemplo n.º 19
0
            public void LocalizationGB()
            {
                CultureInfo currentCultureInfo = Thread.CurrentThread.CurrentCulture;

                Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");

                DateTime result;

                DateTimeFunctions.TryCreate("2000", "07", "05", out result);

                Assert.AreEqual(new DateTime(2000, 7, 5), result);

                Thread.CurrentThread.CurrentCulture = currentCultureInfo;
            }
Ejemplo n.º 20
0
    public virtual object format(string format)
    {
        if (format == null)
        {
            //PhpException.ArgumentNull("format");
            //return false;
            throw new ArgumentNullException();
        }

        string fm = format.ToString();

        if (string.IsNullOrEmpty(fm))
        {
            return(false);
        }

        return(DateTimeFunctions.FormatDate(fm, this.Time, this.TimeZone));
    }
        private void SetHeaderContentDatagridview()
        {
            List <string> ListHeader    = DateTimeFunctions.ListDateInPeriodDate(dtpk_from.Value, dtpk_to.Value);
            List <string> ListDayofWeek = DateTimeFunctions.ListDateNameInPeriodDate(dtpk_from.Value, dtpk_to.Value);

            if (dtgv_WorkingTime.Rows.Count > 0)
            {
                dtgv_WorkingTime.Columns[0].HeaderText = "Code";
                dtgv_WorkingTime.Columns[1].HeaderText = "Name";
                for (int i = 2; i < dtgv_WorkingTime.Columns.Count; i++)
                {
                    if (ListHeader.Count > (i - 2))
                    {
                        dtgv_WorkingTime.Columns[i].HeaderText = ListHeader[i - 2] + Environment.NewLine + "[ " + ListDayofWeek[i - 2] + " ]";
                    }
                    else
                    {
                        dtgv_WorkingTime.Columns[i].HeaderText = "";
                    }
                }
            }
        }
Ejemplo n.º 22
0
        //public void __construct(string isostr, int options = 0)
        //{
        //    // https://en.wikipedia.org/wiki/ISO_8601#Repeating_intervals
        //    // "R5/2008-03-01T13:00:00Z/P1Y2M10DT2H30M"
        //    throw new NotImplementedException();
        //}

        IEnumerator <DateTimeInterface> IEnumerable <DateTimeInterface> .GetEnumerator()
        {
            var current = DateTimeImmutable.createFromInterface(start);

            if (include_start_date)
            {
                yield return(current);
            }

            if (end == null && recurrences == 0)
            {
                yield break;
            }

            if (interval.IsZero)
            {
                yield break;
            }

            for (int index = 0; ; index++)
            {
                current = current.add(interval);

                if (end != null && DateTimeFunctions.CompareTime(current, end) > 0)
                {
                    yield break;
                }

                if (index >= recurrences)
                {
                    yield break;
                }

                //
                yield return(current);
            }
        }
Ejemplo n.º 23
0
 int IPhpComparable.Compare(PhpValue obj) => DateTimeFunctions.CompareTime(this.Time, obj);
Ejemplo n.º 24
0
 /// <summary>
 /// Returns the difference between two DateTime objects
 /// </summary>
 public virtual DateInterval diff(DateTimeInterface datetime2, bool absolute = false) => DateTimeFunctions.date_diff(this, datetime2, absolute);
Ejemplo n.º 25
0
        public string format(string format)
        {
            // TODO: YearOffset

            return(DateTimeFunctions.FormatDate(format, LocalTime, LocalTimeZone));
        }
Ejemplo n.º 26
0
        private void AnalyzeFilesAction(Object o)
        {
            EnDsCommands(CommandSet.csStop);

            ProgressPosition = Items.Count();
            ProgressMax      = Items.Count();
            ProgressStatus   = "Running...";

            foreach (ItemType file in Items)
            {
                Interlocked.Increment(ref TasksCounter);
                Task task = new Task(() =>
                {
                    file.Status = StatusType.stInProgress;

                    PdfFunctions pdfFunctions           = new PdfFunctions();
                    DateTimeFunctions dateTimeFunctions = new DateTimeFunctions();

                    PdfReader pdfFile = null;
                    try
                    {
                        string value = "";

                        if (file.TypeOfItem == PdfLocation.plFile)
                        {
                            pdfFile = pdfFunctions.GetPdf(file.FileName);
                        }
                        else
                        {
                            throw new NotImplementedException();
                        }

                        if (pdfFile != null)
                        {
                            //
                            file.FileLength = pdfFile.FileLength;

                            file.Encrypted = pdfFile.IsEncrypted();

                            file.NumberOfPages = pdfFile.NumberOfPages;

                            //
                            value = pdfFunctions.GetValue(pdfFile, "Author");

                            if (!String.IsNullOrEmpty(value))
                            {
                                file.Author = value;
                            }

                            //
                            value = pdfFunctions.GetValue(pdfFile, "Title");

                            if (!String.IsNullOrEmpty(value))
                            {
                                file.Title = value;
                            }

                            //
                            value = pdfFunctions.GetValue(pdfFile, "Producer");

                            if (!String.IsNullOrEmpty(value))
                            {
                                file.Producer = value;
                            }

                            //
                            value = pdfFunctions.GetValue(pdfFile, "EBX_PUBLISHER");

                            if (!String.IsNullOrEmpty(value))
                            {
                                file.Publisher = value;
                            }

                            //
                            value = pdfFunctions.GetValue(pdfFile, "CreationDate");

                            if (!String.IsNullOrEmpty(value))
                            {
                                file.CreationDate = dateTimeFunctions.FixDateTime(value);
                            }

                            //
                            value = pdfFunctions.GetValue(pdfFile, "ModDate");

                            if (!String.IsNullOrEmpty(value))
                            {
                                file.ModificationDate = dateTimeFunctions.FixDateTime(value);
                            }

                            file.Status = StatusType.stDone;
                        }
                        else
                        {
                            file.Status = StatusType.stError;
                        }
                    }
                    finally
                    {
                        pdfFile?.Close();
                        pdfFile?.Dispose();

                        GC.Collect();
                    }

                    Interlocked.Decrement(ref TasksCounter);
                    TaskCompleted();
                });
                task.Start();
            }
        }
Ejemplo n.º 27
0
        public IEnumerable <DadosImovel> GetListImoveisPrenotacao(long IdPrenotacao)
        {
            List <DadosImovel> lista   = new List <DadosImovel>();
            string             dataTmp = DateTimeFunctions.GetDataPorExtenso("São Paulo");

            var qryImoveis =
                from mi in this._contextRepository.DbMATRIMO.Where(m => (m.SEQPRE == IdPrenotacao) && (m.TIPO.Trim() == "1"))
                join pre in this._contextRepository.DbPREIMO.Where(p => (p.SEQPRE == IdPrenotacao)) on mi.NUMERO equals pre.MATRI into mi_pre
                from pre in mi_pre.DefaultIfEmpty()
                orderby mi.NUMERO
                select new
            {
                IdPrenotacao     = IdPrenotacao,
                NumMatricula     = mi.NUMERO,
                DataAtualExtenso = dataTmp,
                APTO             = pre.APTO,
                BLOCO            = pre.BLOCO,
                CONTRIB          = pre.CONTRIB,
                EDIF             = pre.EDIF,
                ENDER            = pre.ENDER,
                HIPO             = pre.HIPO,
                INSCR            = pre.INSCR,
                LOTE             = pre.LOTE,
                MATRI            = pre.MATRI,
                NUM    = pre.NUM,
                OUTROS = pre.OUTROS,
                QUADRA = pre.QUADRA,
                RD     = pre.RD,
                SEQIMO = pre.SEQIMO,
                SEQPRE = pre.SEQPRE,
                SUBD   = pre.SUBD,
                TIPO   = pre.TIPO,
                TITULO = pre.TITULO,
                TRANS  = pre.TRANS,
                VAGA   = pre.VAGA
            };

            foreach (var imovel in qryImoveis)
            {
                lista.Add(new DadosImovel
                {
                    IdPrenotacao = imovel.IdPrenotacao,
                    NumMatricula = imovel.NumMatricula.ToString(),
                    APTO         = imovel.APTO.Trim(),
                    BLOCO        = imovel.BLOCO.Trim(),
                    CONTRIB      = imovel.CONTRIB,
                    EDIF         = imovel.EDIF.Trim(),
                    ENDER        = imovel.ENDER.Trim(),
                    HIPO         = imovel.HIPO,
                    INSCR        = imovel.INSCR,
                    LOTE         = imovel.LOTE.Trim(),
                    MATRI        = imovel.MATRI,
                    NUM          = imovel.NUM.Trim(),
                    OUTROS       = imovel.OUTROS.Trim(),
                    QUADRA       = imovel.QUADRA.Trim(),
                    RD           = imovel.RD,
                    SEQIMO       = imovel.SEQIMO,
                    SEQPRE       = imovel.SEQPRE,
                    SUBD         = imovel.SUBD,
                    TIPO         = imovel.TIPO.Trim(),
                    TITULO       = imovel.TITULO.Trim(),
                    TRANS        = imovel.TRANS,
                    VAGA         = imovel.VAGA.Trim()
                });
            }

            return(lista);
        }