Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "io/ioutil"
- "os"
- "time"
- "code.google.com/p/sre2/sre2"
- "strings"
- )
- func main() {
- file, _ := os.Open("SearchRequest.xml")
- data, _ := ioutil.ReadAll(file)
- lines := strings.Split(string(data), "\n")
- re := sre2.MustParse("<created>(.*)</created>")
- for _, line := range lines {
- idxs := re.MatchIndex(string(line))
- if len(idxs) > 0 {
- date := line[idxs[2]:idxs[3]]
- t, e := time.Parse("Mon, 2 Jan 2006 15:04:05 -0700", string(date))
- if e != nil {
- fmt.Fprintf(os.Stderr, "Unable to parse %s\n", string(date))
- } else {
- fmt.Printf(t.Format("2006/01/02 15:04:05\n"))
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement