Skip to content

Commit

Permalink
Merge pull request #31 from jamf/v006_timestamps
Browse files Browse the repository at this point in the history
fixed timestamps to conform to iso format
  • Loading branch information
stuartjash committed Sep 21, 2022
2 parents c1eb9a8 + 1505b8c commit e794091
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions aftermath/Aftermath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Aftermath {

let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US")
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)

let dateString = dateFormatter.string(from: date as Date)
Expand All @@ -66,15 +66,15 @@ class Aftermath {
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)

if let date = dateFormatter.date(from: timeStamp) {
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
let dateString = dateFormatter.string(from: date as Date)
return dateString
}

dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"

if let date = dateFormatter.date(from: timeStamp) {
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
let dateString = dateFormatter.string(from: date as Date)
return dateString
} else {
Expand Down
6 changes: 3 additions & 3 deletions analysis/LogParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class LogParser: AftermathModule {
sanatizeInfo(&info)

guard let dateZone = dateFormatter.date(from: unformattedDate) else { continue }
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
let formattedDate = dateFormatter.string(from: dateZone)
let text = "\(formattedDate), INSTALL, \(info)"
self.addTextToFile(atUrl: logsFile, text: text)
Expand Down Expand Up @@ -100,7 +100,7 @@ class LogParser: AftermathModule {
let unformattedTimestamp = "\(month) \(date) \(currentYear!) \(time)"

guard let formatted = dateFormatter.date(from: unformattedTimestamp) else { continue } //Ex: 2022-08-26 00:01:40 UTC
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
let dateString = dateFormatter.string(from: formatted)

let text = "\(dateString), SYSLOG, \(info)"
Expand Down Expand Up @@ -141,7 +141,7 @@ class LogParser: AftermathModule {
sanatizeInfo(&info)

guard let dateZome = dateFormatter.date(from: unformattedDate) else { continue }
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
let formattedDate = dateFormatter.string(from: dateZome)
let text = "\(formattedDate), XPROTECT_REMEDIATOR, \(info)"
self.addTextToFile(atUrl: logsFile, text: text)
Expand Down
2 changes: 1 addition & 1 deletion analysis/ProcessParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ProcessParser: AftermathModule {
sanatizeInfo(&info)

guard let dateZone = dateFormatter.date(from: unformattedDate) else { continue }
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
let formattedDate = dateFormatter.string(from: dateZone)
let text = "\(formattedDate), PROCESS, \(info)"
self.addTextToFile(atUrl: self.storylineFile, text: text)
Expand Down
2 changes: 1 addition & 1 deletion filesystem/browsers/Safari.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Safari: BrowserModule {
let dateTimestamp = value as! Date
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US")
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)

let dateString = dateFormatter.string(from: dateTimestamp as Date)
Expand Down

0 comments on commit e794091

Please sign in to comment.