Skip to content

Commit

Permalink
change date format to YYYY-MM-DD, fixes #12
Browse files Browse the repository at this point in the history
  • Loading branch information
freetonik committed Nov 1, 2019
1 parent 3440a70 commit cfabdd9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
25 changes: 14 additions & 11 deletions app/cmd/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ func NewPost(filename string) Post {
verifyFilenameBaseFormat(filenameBase)

// Get date and slug from filename
day := filenameBase[0:2]
month := filenameBase[3:5]
year := filenameBase[6:10]
date, err := time.Parse("02-01-2006", day+"-"+month+"-"+year)
year := filenameBase[0:4]
month := filenameBase[5:7]
day := filenameBase[8:10]
date, err := time.Parse("2006-01-02", year+"-"+month+"-"+day)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -98,23 +98,26 @@ func verifyFilenameBaseFormat(f string) {
os.Exit(1)
}

// day is int?
_, err := strconv.Atoi(f[0:2])
if err != nil {
// 2019-10-24-Slug.md
//[0 45 78 10]

// year is int?
_, err3 := strconv.Atoi(f[0:4])
if err3 != nil {
fmt.Println(errorDescription)
os.Exit(1)
}

// month is int?
_, err2 := strconv.Atoi(f[3:5])
_, err2 := strconv.Atoi(f[5:7])
if err2 != nil {
fmt.Println(errorDescription)
os.Exit(1)
}

// year is int?
_, err3 := strconv.Atoi(f[6:10])
if err3 != nil {
// day is int?
_, err := strconv.Atoi(f[8:10])
if err != nil {
fmt.Println(errorDescription)
os.Exit(1)
}
Expand Down
2 changes: 1 addition & 1 deletion app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"
)

var revision = "0.2"
var revision = "0.2.2"

func main() {
fmt.Printf("Underblog %s\n", revision)
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions example/markdown/2019-10-25-Test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# The First Triumvirate

In 60 BC, Caesar, Crassus and Pompey formed the First Triumvirate, a political alliance that dominated Roman politics for several years. Their attempts to amass power as Populares were opposed by the Optimates within the Roman Senate, among them Cato the Younger with the frequent support of Cicero. Caesar rose to become one of the most powerful politicians in the Roman Republic through a number of his accomplishments, notably his victories in the Gallic Wars, completed by 51 BC. During this time, Caesar became the first Roman general to cross both the English Channel and the Rhine River, when he built a bridge across the Rhine and crossed the Channel to invade Britain. Caesar's wars extended Rome's territory to Britain and past Gaul. These achievements granted him unmatched military power and threatened to eclipse the standing of Pompey, who had realigned himself with the Senate after the death of Crassus in 53 BC. With the Gallic Wars concluded, the Senate ordered Caesar to step down from his military command and return to Rome. Leaving his command in Gaul meant losing his immunity from being charged as a criminal for waging unsanctioned wars. As a result, Caesar found himself with no other options but to cross the Rubicon with the 13th Legion in 49 BC, leaving his province and illegally entering Roman Italy under arms. This began Caesar's civil war, and his victory in the war put him in an unrivalled position of power and influence.

After assuming control of government, Caesar began a program of social and governmental reforms, including the creation of the Julian calendar. He gave citizenship to many residents of far regions of the Roman Empire. He initiated land reform and support for veterans. He centralized the bureaucracy of the Republic and was eventually proclaimed "dictator for life" (Latin: "dictator perpetuo"), giving him additional authority. His populist and authoritarian reforms angered the elites, who began to conspire against him. On the Ides of March (15 March), 44 BC, Caesar was assassinated by a group of rebellious senators led by Gaius Cassius Longinus, Marcus Junius Brutus and Decimus Junius Brutus, who stabbed him to death. A new series of civil wars broke out and the constitutional government of the Republic was never fully restored. Caesar's adopted heir Octavian, later known as Augustus, rose to sole power after defeating his opponents in the civil war. Octavian set about solidifying his power, and the era of the Roman Empire began.
2 changes: 1 addition & 1 deletion version.mk
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION ?= 0.2
VERSION ?= 0.2.2

0 comments on commit cfabdd9

Please sign in to comment.