Skip to content

Commit

Permalink
Use the pure function instead of the separated util package
Browse files Browse the repository at this point in the history
  • Loading branch information
f9n committed Mar 24, 2019
1 parent 47bd458 commit 8c43b97
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
9 changes: 4 additions & 5 deletions models/date.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ package models

import (
"fmt"
"strconv"
"strings"

"github.com/GnuYtuce/ytuyemekhane-api/util"
)

type Date struct {
Expand All @@ -25,9 +24,9 @@ const (
func NewDate(dateStr string) *Date {
var d Date
temp := strings.Split(dateStr, ".")
d.Day, _ = util.StringToInt(temp[0])
d.Month, _ = util.StringToInt(strings.TrimLeft(temp[1], "0"))
d.Year, _ = util.StringToInt(temp[2])
d.Day, _ = strconv.Atoi(temp[0])
d.Month, _ = strconv.Atoi(strings.TrimLeft(temp[1], "0"))
d.Year, _ = strconv.Atoi(temp[2])
return &d
}

Expand Down
14 changes: 7 additions & 7 deletions routers/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package routers
import (
"errors"
"net/http"
"strconv"
"sync"
"time"

"github.com/GnuYtuce/ytuyemekhane-api/crawler"
"github.com/GnuYtuce/ytuyemekhane-api/models"
"github.com/GnuYtuce/ytuyemekhane-api/sender"
"github.com/GnuYtuce/ytuyemekhane-api/util"
"github.com/julienschmidt/httprouter"
)

Expand Down Expand Up @@ -37,7 +37,7 @@ func FoodListByCurrentTime(w http.ResponseWriter, r *http.Request, p httprouter.

// FoodListByCertainYear : belli bir yila gore yemek listesi donulecek.
func FoodListByCertainYear(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
year, _ := util.StringToInt(p.ByName("year"))
year, _ := strconv.Atoi(p.ByName("year"))
date := models.Date{
Day: 0,
Month: 0,
Expand Down Expand Up @@ -75,8 +75,8 @@ func FoodListByCertainYear(w http.ResponseWriter, r *http.Request, p httprouter.

// FoodListByCertainYearAndMonth : belli bir yil ve aya gore yemek listesi donulecek.
func FoodListByCertainYearAndMonth(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
month, _ := util.StringToInt(p.ByName("month"))
year, _ := util.StringToInt(p.ByName("year"))
month, _ := strconv.Atoi(p.ByName("month"))
year, _ := strconv.Atoi(p.ByName("year"))
date := models.Date{
Day: 0,
Month: month,
Expand All @@ -93,9 +93,9 @@ func FoodListByCertainYearAndMonth(w http.ResponseWriter, r *http.Request, p htt

// FoodListByCertainTime : belli bir zamana gore yemek listesi donulecek.
func FoodListByCertainTime(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
day, _ := util.StringToInt(p.ByName("day"))
month, _ := util.StringToInt(p.ByName("month"))
year, _ := util.StringToInt(p.ByName("year"))
day, _ := strconv.Atoi(p.ByName("day"))
month, _ := strconv.Atoi(p.ByName("month"))
year, _ := strconv.Atoi(p.ByName("year"))
date := models.Date{
Day: day,
Month: month,
Expand Down
10 changes: 0 additions & 10 deletions util/util.go

This file was deleted.

0 comments on commit 8c43b97

Please sign in to comment.