ToDateTime() public static method

public static ToDateTime ( long time ) : System.DateTime
time long
return System.DateTime
Exemplo n.º 1
0
        IEnumerable <ITaskCore> TaskListTaskCollectionRepo.GetAll(
            ITaskListCore container)
        {
            var command =
                "SELECT ID, Name, DueDate, CompletionDate, Priority, State " +
                "FROM Tasks WHERE Category=@id;";

            using (var cmd = new SqliteCommand(database.Connection)) {
                cmd.CommandText = command;
                cmd.Parameters.AddIdParameter(container);
                using (var dataReader = cmd.ExecuteReader()) {
                    while (dataReader.Read())
                    {
                        var id             = dataReader.GetInt32(0).ToString();
                        var name           = dataReader.GetString(1);
                        var state          = (TaskState)dataReader.GetInt32(5);
                        var completionDate =
                            Database.ToDateTime(dataReader.GetInt64(3));

                        ITaskCore task;
                        if (state == TaskState.Active)
                        {
                            task = backend.Factory.CreateTask(id, name);
                        }
                        else if (state == TaskState.Completed)
                        {
                            task = backend.Factory.CreateCompletedTask(
                                id, name, completionDate);
                        }
                        else
                        {
                            task = backend.Factory.CreateDiscardedTask(
                                id, name);
                        }
                        task.Priority = (TaskPriority)dataReader.GetInt32(4);
                        task.DueDate  =
                            Database.ToDateTime(dataReader.GetInt64(2));

                        yield return(task);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public DateTime GetDateTime(string command)
        {
            long     longValue;
            DateTime dtValue;

            try{
                longValue = GetSingleLong(command);
                if (longValue == 0)
                {
                    dtValue = DateTime.MinValue;
                }
                else
                {
                    dtValue = Database.ToDateTime(longValue);
                }
            } catch (Exception e) {
                Logger.Debug("Exception Thrown {0}", e);
                dtValue = DateTime.MinValue;
            }
            return(dtValue);
        }