Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "io"
- "os"
- "time"
- "code.google.com/p/sre2/sre2"
- "bufio"
- )
- func main() {
- file, _ := os.Open("SearchRequest.xml")
- reader := bufio.NewReader(file)
- re := sre2.MustParse("<created>(.*)</created>")
- for line, _, e := reader.ReadLine(); e != io.EOF; line, _, e = reader.ReadLine() {
- 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