diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.form b/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.form index a2c34ea3f8..432bd9b5c3 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.form +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.form @@ -148,6 +148,9 @@ + + + diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.java b/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.java index 2b702bef4b..3d697b07ab 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.java @@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.corecomponents; import java.util.prefs.Preferences; import org.openide.util.NbPreferences; +import org.sleuthkit.autopsy.datamodel.ContentUtils; final class GeneralPanel extends javax.swing.JPanel { @@ -33,6 +34,7 @@ final class GeneralPanel extends javax.swing.JPanel { GeneralPanel(GeneralOptionsPanelController controller) { this.controller = controller; initComponents(); + ContentUtils.setDisplayInLocalTime(useLocalTimeRB.isSelected()); // TODO listen to changes in form fields and call controller.changed() } @@ -80,6 +82,11 @@ final class GeneralPanel extends javax.swing.JPanel { buttonGroup3.add(useGMTTimeRB); org.openide.awt.Mnemonics.setLocalizedText(useGMTTimeRB, org.openide.util.NbBundle.getMessage(GeneralPanel.class, "GeneralPanel.useGMTTimeRB.text")); // NOI18N + useGMTTimeRB.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + useGMTTimeRBActionPerformed(evt); + } + }); org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(GeneralPanel.class, "GeneralPanel.jLabel3.text")); // NOI18N @@ -144,6 +151,10 @@ final class GeneralPanel extends javax.swing.JPanel { // TODO add your handling code here: }//GEN-LAST:event_useBestViewerRBActionPerformed + private void useGMTTimeRBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_useGMTTimeRBActionPerformed + ContentUtils.setDisplayInLocalTime(useLocalTimeRB.isSelected()); + }//GEN-LAST:event_useGMTTimeRBActionPerformed + void load() { boolean keepPreferredViewer = prefs.getBoolean(KEEP_PREFERRED_VIEWER, false); keepCurrentViewerRB.setSelected(keepPreferredViewer); diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/ContentUtils.java b/Core/src/org/sleuthkit/autopsy/datamodel/ContentUtils.java index 121b5a1cfa..9cc844cae6 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/ContentUtils.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/ContentUtils.java @@ -50,7 +50,7 @@ public final class ContentUtils { private final static Logger logger = Logger.getLogger(ContentUtils.class.getName()); private static final SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); private static final SimpleDateFormat dateFormatterISO8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); - + private static boolean displayInLocalTime; // don't instantiate private ContentUtils() { throw new AssertionError(); @@ -104,12 +104,11 @@ public final class ContentUtils { public static String getStringTimeISO8601(long epochSeconds, Content c) { return getStringTimeISO8601(epochSeconds, getTimeZone(c)); } - + public static TimeZone getTimeZone(Content c) { - Preferences generalPanelPrefs = NbPreferences.root().node("/org/sleuthkit/autopsy/core"); - boolean useLocalTime = generalPanelPrefs.getBoolean("useLocalTime", true); + try { - if (!useLocalTime) { + if (!getDisplayInLocalTime()) { return TimeZone.getTimeZone("GMT"); } else { @@ -360,4 +359,18 @@ public final class ContentUtils { + cntnt.getClass().getSimpleName()); } } + /**sets displayInlocalTime value based on button in GeneralPanel.java + * + * @param flag + */ + public static void setDisplayInLocalTime(boolean flag) { + displayInLocalTime = flag; + } + /** get global timezone setting for displaying time values + * + * @return + */ + public static boolean getDisplayInLocalTime(){ + return displayInLocalTime; + } } diff --git a/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java b/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java index 479b98cfe0..7503d3147b 100644 --- a/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java +++ b/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java @@ -41,7 +41,9 @@ import java.util.List; import java.util.Locale; import java.util.Scanner; import java.util.Stack; +import java.util.TimeZone; import java.util.logging.Level; +import java.util.prefs.Preferences; import javafx.application.Platform; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; @@ -75,11 +77,11 @@ import org.openide.awt.ActionReference; import org.openide.awt.ActionReferences; import org.openide.awt.ActionRegistration; import org.openide.modules.InstalledFileLocator; -import org.openide.modules.ModuleInstall; import org.openide.nodes.Children; import org.openide.nodes.Node; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; +import org.openide.util.NbPreferences; import org.openide.util.actions.CallableSystemAction; import org.openide.util.actions.Presenter; import org.openide.util.lookup.Lookups; @@ -97,6 +99,7 @@ import org.sleuthkit.autopsy.datamodel.DisplayableItemNodeVisitor; import org.sleuthkit.autopsy.datamodel.FileNode; import org.sleuthkit.autopsy.ingest.IngestManager; import org.sleuthkit.autopsy.coreutils.ExecUtil; +import org.sleuthkit.autopsy.datamodel.ContentUtils; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.TskCoreException; @@ -112,7 +115,7 @@ import org.sleuthkit.datamodel.TskCoreException; * */ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, PropertyChangeListener { - + private static final Logger logger = Logger.getLogger(Timeline.class.getName()); private final java.io.File macRoot = InstalledFileLocator.getDefault().locate("mactime", Timeline.class.getPackage().getName(), false); private TimelineFrame mainFrame; //frame for holding all the elements @@ -142,12 +145,11 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, private EventHandler fxMouseExitedListener; private SleuthkitCase skCase; private boolean fxInited = false; - public Timeline() { super(); fxInited = Installer.isJavaFxInited(); - + // TimeZone.setDefault(TimeZone.getTimeZone("UTC")); //sets the default timezone to UTC unless otherwise stated } //Swing components and JavafX components don't play super well together @@ -914,17 +916,35 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, int prevYear = -1; YearEpoch ye = null; + while (scan.hasNextLine()) { String[] s = scan.nextLine().split(","); //1999-02-08T11:08:08Z, 78706, m..b, rrwxrwxrwx, 0, 0, 8355, /img... - // break the date into mon, day and year: Note that the ISO times are in GMT - String[] datetime = s[0].split("T"); //{1999-02-08, 11:08:08Z} - String[] date = datetime[0].split("-"); // {1999, 02, 08} + // break the date into year,month,day,hour,minute, and second: Note that the ISO times are in GMT + String delims = "[T:Z\\-]+"; //split by the delimiters + String[] date = s[0].split(delims); //{1999,02,08,11,08,08,...} + int year = Integer.valueOf(date[0]); int month = Integer.valueOf(date[1]) - 1; //Months are zero indexed: 1 = February, 6 = July, 11 = December int day = Integer.valueOf(date[2]); //Days are 1 indexed + int hour=Integer.valueOf(date[3]); + int minute=Integer.valueOf(date[4]); + int second=Integer.valueOf(date[5]); + + Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); //set calendar to GMT due to ISO format + calendar.set(year, month, day, hour, minute, second); + day=calendar.get(Calendar.DAY_OF_MONTH); // this is needed or else timezone change wont work. probably incorrect optimization by compiler + + //conversion to GMT + + if (!ContentUtils.getDisplayInLocalTime()) { + calendar.setTimeZone(TimeZone.getTimeZone("GMT")); + } + else{ + calendar.setTimeZone(TimeZone.getDefault());// local timezone OF the user. should be what the user SETS at startup + } - // get the object id out of the modified outpu + day=calendar.get(Calendar.DAY_OF_MONTH);//get the day which may be affected by timezone change long ObjId = Long.valueOf(s[4]); // when the year changes, create and add a new YearEpoch object to the list @@ -961,7 +981,6 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, // Get report path String bodyFilePath = moduleDir.getAbsolutePath() + java.io.File.separator + currentCase.getName() + "-" + datenotime + ".txt"; - // Run query to get all files final String filesAndDirs = "name != '.' " + "AND name != '..'"; @@ -1107,7 +1126,7 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, public void performAction() { initTimeline(); } - + private void initTimeline() { if (!Case.existsCurrentCase()) { return;