forked from OrgGo/Tasks
now we display created timestamp on tasks
This commit is contained in:
parent
59ab7953e5
commit
77104f4e06
14
db/db.go
14
db/db.go
|
@ -6,13 +6,11 @@ import (
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
"github.com/thewhitetulip/task/types"
|
"github.com/thewhitetulip/task/types"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var database *sql.DB
|
var database *sql.DB
|
||||||
var err error
|
var err error
|
||||||
var tag string
|
|
||||||
var name string
|
|
||||||
var tags string
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
database, err = sql.Open("sqlite3", "./tasks.db")
|
database, err = sql.Open("sqlite3", "./tasks.db")
|
||||||
|
@ -30,11 +28,12 @@ func GetTasks(deleted bool) []types.Task {
|
||||||
var TaskId int
|
var TaskId int
|
||||||
var TaskTitle string
|
var TaskTitle string
|
||||||
var TaskContent string
|
var TaskContent string
|
||||||
|
var TaskCreated time.Time
|
||||||
var getTasksql string
|
var getTasksql string
|
||||||
if deleted == true {
|
if deleted == true {
|
||||||
getTasksql = "select id, title, content from task where is_deleted!='Y' order by created_date asc"
|
getTasksql = "select id, title, content, created_date from task where is_deleted!='Y' order by created_date asc"
|
||||||
} else {
|
} else {
|
||||||
getTasksql = "select id, title, content from task where is_deleted='Y' order by created_date asc"
|
getTasksql = "select id, title, content, created_date from task where is_deleted='Y' order by created_date asc"
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := database.Query(getTasksql)
|
rows, err := database.Query(getTasksql)
|
||||||
|
@ -43,11 +42,12 @@ func GetTasks(deleted bool) []types.Task {
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
err := rows.Scan(&TaskId, &TaskTitle, &TaskContent)
|
err := rows.Scan(&TaskId, &TaskTitle, &TaskContent, &TaskCreated)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
a := types.Task{Id: TaskId, Title: TaskTitle, Content: TaskContent}
|
TaskCreated = TaskCreated.Local()
|
||||||
|
a := types.Task{Id: TaskId, Title: TaskTitle, Content: TaskContent, Created: TaskCreated.Format(time.UnixDate)[0:20]}
|
||||||
task = append(task, a)
|
task = append(task, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,10 +149,10 @@
|
||||||
<p class="noteContent">{{.Content}}</p>
|
<p class="noteContent">{{.Content}}</p>
|
||||||
<span class="notefooter">
|
<span class="notefooter">
|
||||||
<ul class="menu">
|
<ul class="menu">
|
||||||
<!-- <li role="presentation">
|
|
||||||
<a role="menuitem" tabindex="-1" href="/share/{{.Id}}">
|
|
||||||
<span class="glyphicon glyphicon-share"></span> Share</a></li>
|
|
||||||
<li role="presentation">
|
<li role="presentation">
|
||||||
|
<!-- <a role="menuitem" tabindex="-1" href="/share/{{.Id}}"> </a>-->
|
||||||
|
<span class="glyphicon glyphicon-time"></span> {{.Created}}</li>
|
||||||
|
<!-- <li role="presentation">
|
||||||
<a role="menuitem" tabindex="-1" href="/mask/{{.Id}}">
|
<a role="menuitem" tabindex="-1" href="/mask/{{.Id}}">
|
||||||
<span class="glyphicon glyphicon-lock"></span> Mask</a></li> !-->
|
<span class="glyphicon glyphicon-lock"></span> Mask</a></li> !-->
|
||||||
<li role="presentation"><a role="menuitem" tabindex="-1" href="/edit/{{.Id}}">
|
<li role="presentation"><a role="menuitem" tabindex="-1" href="/edit/{{.Id}}">
|
||||||
|
|
|
@ -4,4 +4,5 @@ type Task struct {
|
||||||
Id int
|
Id int
|
||||||
Title string
|
Title string
|
||||||
Content string
|
Content string
|
||||||
|
Created string
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue