summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2008-06-09 23:52:56 +0200
committerTomas Bzatek <tbzatek@users.sourceforge.net>2008-06-09 23:52:56 +0200
commit47735c3d73cc677e519cd33b58232c97729596fa (patch)
tree32b96f0388721dd63668cb159d05e6c934536268
parentf9c7a5f62f96fab9ce5e3d2c205bc9da3046c4d4 (diff)
downloadtuxcmd-47735c3d73cc677e519cd33b58232c97729596fa.tar.xz
Date/time string formatting revisionv0.6.40
Added ability to set custom date/time format
-rw-r--r--UChecksumDruid.pas4
-rw-r--r--UConfig.pas25
-rw-r--r--UCore.pas6
-rw-r--r--UCoreUtils.pas87
-rw-r--r--UEngines.pas20
-rw-r--r--UGlibC_compat.pas17
-rw-r--r--UMain.pas2
-rw-r--r--UPreferences.pas132
-rw-r--r--USearch.pas6
-rw-r--r--vfs/UVFSCore.pas6
10 files changed, 265 insertions, 40 deletions
diff --git a/UChecksumDruid.pas b/UChecksumDruid.pas
index 121be80..188bac0 100644
--- a/UChecksumDruid.pas
+++ b/UChecksumDruid.pas
@@ -602,11 +602,11 @@ begin
s := Format('; Generated by WIN-SFV32 v1 [added for sfv32 compatibility]'#13#10'; Using Tux Commander v%s [%s] on %s'#13#10 +
'; http://tuxcmd.sourceforge.net/'#13#10'; '#13#10'; /----'#13#10, [ConstAboutVersion, ConstAboutBuildDate,
- FormatDateTime('mm.dd.yyyy "at" hh:nn:ss', Now)]);
+ SysUtils.FormatDateTime('mm.dd.yyyy "at" hh:nn:ss', Now)]);
for i := 0 to FileNames.Count - 1 do begin
Stat := Engine.GetFileInfoSL(FileNames[i]);
if Assigned(Stat) then s := s + Format('; %s %s %s'#13#10, [PadRightStr(IntToStr(Stat^.Size), 11),
- FormatDateTime('hh:nn.ss yyyy-mm-dd', Stat^.ModifyTime), ExtractFileName(FileNames[i])]);
+ SysUtils.FormatDateTime('hh:nn.ss yyyy-mm-dd', Stat^.ModifyTime), ExtractFileName(FileNames[i])]);
end;
s := s + '; \----'#13#10'; '#13#10;
diff --git a/UConfig.pas b/UConfig.pas
index 48cd1cf..08719d8 100644
--- a/UConfig.pas
+++ b/UConfig.pas
@@ -25,8 +25,8 @@ uses Classes, ULocale;
resourcestring
ConstAppTitle = 'Tux Commander';
- ConstAboutVersion = '0.6.39-dev';
- ConstAboutBuildDate = '2008-06-08';
+ ConstAboutVersion = '0.6.40-dev';
+ ConstAboutBuildDate = '2008-06-09';
{$IFDEF __FPC__}
{$INCLUDE fpcver.inc}
@@ -81,12 +81,12 @@ var ConfPanelSep, ConfRowHeight, ConfRowHeightReal, ConfNumHistoryItems,
ConfMainWindowLeftSortColumn, ConfMainWindowLeftSortType, ConfMainWindowRightSortColumn, ConfMainWindowRightSortType,
ConfSizeFormat, ConfSizeGroupPrecision, ConfCmdLineTerminalBehaviour, ConfViewerTerminalBehaviour,
ConfEditorTerminalBehaviour, ConfLeftTabBarTabIndex, ConfRightTabBarTabIndex, ConfSwitchOtherPanelBehaviour,
- ConfTabMaxLength: integer;
+ ConfTabMaxLength, ConfDateFormat, ConfTimeFormat, ConfDateTimeFormat: integer;
ConfLeftPath, ConfRightPath, ConfPanelFont, ConfProfileName, ConfViewer, ConfEditor, ConfTerminalCommand,
ConfNormalItemFGColor, ConfActiveItemFGColor, ConfInactiveItemFGColor, ConfSelectedItemFGColor, ConfLinkItemFGColor,
ConfDotFileItemFGColor, ConfNormalItemBGColor, ConfActiveItemBGColor, ConfInactiveItemBGColor,
- ParamLeftDir, ParamRightDir: string;
+ ParamLeftDir, ParamRightDir, ConfCustomDateFormat, ConfCustomTimeFormat: string;
ParamDebug, ConfShowDotFiles, ConfClearReadOnlyAttr, ConfDisableMouseRename, ConfUseSystemFont, ConfUseFileTypeIcons,
ConfFocusRefresh, ConfNewStyleAltO, ConfDirsInBold, ConfDisableDirectoryBrackets, ParamDisableGnome, ConfWMCompatMode,
@@ -237,6 +237,12 @@ begin
ConfTabMaxLength := 25;
ConfTempPath := '/tmp/tuxcmd';
ConfUseSmoothScrolling := False;
+ ConfDateFormat := 0;
+ ConfTimeFormat := 0;
+ ConfDateTimeFormat := 0;
+ ConfCustomDateFormat := '%x';
+ ConfCustomTimeFormat := '%X';
+
// Setup default values for colors
ConfNormalItemFGColor := ConfDefaultNormalItemFGColor;
@@ -453,6 +459,11 @@ begin
ConfTabMaxLength := IniFile.ReadInteger(ConfProfileName, 'TabMaxLength', ConfTabMaxLength);
ConfTempPath := IniFile.ReadString(ConfProfileName, 'TempPath', ConfTempPath);
ConfUseSmoothScrolling := IniFile.ReadBool(ConfProfileName, 'UseSmoothScrolling', ConfUseSmoothScrolling);
+ ConfDateFormat := IniFile.ReadInteger(ConfProfileName, 'DateFormat', ConfDateFormat);
+ ConfTimeFormat := IniFile.ReadInteger(ConfProfileName, 'TimeFormat', ConfTimeFormat);
+ ConfDateTimeFormat := IniFile.ReadInteger(ConfProfileName, 'DateTimeFormat', ConfDateTimeFormat);
+ ConfCustomDateFormat := IniFile.ReadString(ConfProfileName, 'CustomDateFormat', ConfCustomDateFormat);
+ ConfCustomTimeFormat := IniFile.ReadString(ConfProfileName, 'CustomTimeFormat', ConfCustomTimeFormat);
SearchForDefaultApps;
@@ -535,6 +546,12 @@ begin
IniFile.WriteInteger(ConfProfileName, 'TabMaxLength', ConfTabMaxLength);
IniFile.WriteString(ConfProfileName, 'TempPath', ConfTempPath);
IniFile.WriteBool(ConfProfileName, 'UseSmoothScrolling', ConfUseSmoothScrolling);
+ IniFile.WriteInteger(ConfProfileName, 'DateFormat', ConfDateFormat);
+ IniFile.WriteInteger(ConfProfileName, 'TimeFormat', ConfTimeFormat);
+ IniFile.WriteInteger(ConfProfileName, 'DateTimeFormat', ConfDateTimeFormat);
+ IniFile.WriteString(ConfProfileName, 'CustomDateFormat', ConfCustomDateFormat);
+ IniFile.WriteString(ConfProfileName, 'CustomTimeFormat', ConfCustomTimeFormat);
+
except
on E: Exception do DebugMsg(['*** Error: Cannot save user settings (', E.ClassName, '): ', E.Message]);
diff --git a/UCore.pas b/UCore.pas
index 8bc2654..a62495a 100644
--- a/UCore.pas
+++ b/UCore.pas
@@ -334,15 +334,15 @@ begin
ColumnData[ConfColumnIDs[j] - 1] := strdup(PChar(s2));
end;
5: begin
- s2 := FormatDateTime('ddddd tt', ModifyTime);
+ s2 := FormatDate(ModifyTime, True, True);
ColumnData[ConfColumnIDs[j] - 1] := strdup(PChar(s2));
end;
6: begin
- s2 := FormatDateTime('ddddd', ModifyTime);
+ s2 := FormatDate(ModifyTime, False, True);
ColumnData[ConfColumnIDs[j] - 1] := strdup(PChar(s2));
end;
7: begin
- s2 := FormatDateTime('tt', ModifyTime);
+ s2 := FormatDate(ModifyTime, True, False);
ColumnData[ConfColumnIDs[j] - 1] := strdup(PChar(s2));
end;
8: begin
diff --git a/UCoreUtils.pas b/UCoreUtils.pas
index 31c72b1..3290019 100644
--- a/UCoreUtils.pas
+++ b/UCoreUtils.pas
@@ -24,7 +24,7 @@ unit UCoreUtils;
interface
-uses gdk2pixbuf, gtk2, gdk2, glib2, SysUtils, Classes, Libc, GTKControls, GTKStdCtrls, GTKClasses, UEngines;
+uses gdk2pixbuf, gtk2, gdk2, glib2, SysUtils, Classes, Libc, UGlibC_compat, GTKControls, GTKStdCtrls, GTKClasses, UEngines;
type
PIntArray = ^TIntArray;
@@ -58,6 +58,7 @@ function GetSignalString(SignalNo: integer): string;
function UnixTimeToTDateTime(UnixTime: Int64): TDateTime;
function FormatSize(Value: Int64; Base: integer; OverrideSizeFormat: integer = -1): string;
+function FormatDate(Value: TTimeT; const FormatTime, FormatDate: boolean; OverrideTimeFormat: integer = -1; OverrideDateFormat: integer = -1; OverrideDateTimeFormat: integer = -1): string;
function AttrToStr(const Mode: Cardinal; IncludeFileType: boolean = True): string;
function AttrToOctal(const Mode: Cardinal): integer;
@@ -269,6 +270,90 @@ begin
end;
(********************************************************************************************************************************)
+function FormatDate(Value: TTimeT; const FormatTime, FormatDate: boolean; OverrideTimeFormat: integer = -1; OverrideDateFormat: integer = -1; OverrideDateTimeFormat: integer = -1): string;
+var DateString, TimeString: string;
+ DateFormat, TimeFormat: string;
+ df, tf, dtf: integer;
+ time_tm: Ptm;
+ Buf: PChar;
+ placed: integer;
+begin
+ DateString := '';
+ TimeString := '';
+ DateFormat := '';
+ TimeFormat := '';
+ Result := '';
+ if OverrideDateFormat >= 0 then df := OverrideDateFormat
+ else df := ConfDateFormat;
+ if OverrideTimeFormat >= 0 then tf := OverrideTimeFormat
+ else tf := ConfTimeFormat;
+ if OverrideDateTimeFormat >= 0 then dtf := OverrideDateTimeFormat
+ else dtf := ConfDateTimeFormat;
+ time_tm := localtime(@Value);
+
+ if FormatDate then begin
+ case df of
+ 0: DateFormat := '%x'; // System format
+ 1: DateFormat := '%Y-%m-%d'; // 2008-06-24
+ 2: DateFormat := '%Y/%m/%d'; // 2008/06/24
+ 3: DateFormat := '%d.%m.%Y'; // 24.06.2008
+ 4: DateFormat := '%d.%m.%y'; // 24.06.08
+ 5: DateFormat := '%d-%m-%Y'; // 24-06-2008
+ 6: DateFormat := '%d/%m/%Y'; // 24/06/2008
+ 7: DateFormat := '%m-%d-%Y'; // 06-24-2008
+ 8: DateFormat := '%m/%d/%Y'; // 06/24/2008
+ 9: DateFormat := '%d-%m-%y'; // 24-06-08
+ 10: DateFormat := '%d/%m/%y'; // 24/06/08
+ 11: DateFormat := '%m-%d-%y'; // 06-24-08
+ 12: DateFormat := '%m/%d/%y'; // 06/24/08
+ 13: DateFormat := '%y-%m-%d'; // 08-06-24
+ 14: DateFormat := '%y/%m/%d'; // 08/06/24
+ else DateFormat := ConfCustomDateFormat; // Custom date format
+ end;
+ Buf := malloc(255);
+ memset(Buf, 0, 255);
+ placed := strftime(Buf, 254, PChar(DateFormat), time_tm);
+ if placed <= 0 then DebugMsg(['FormatDate: error converting date. The result will be unpredictable.']);
+ DateString := String(StrToUTF8(Buf));
+ Libc.free(Buf);
+ end;
+
+ if FormatTime then begin
+ case tf of
+ 0: TimeFormat := '%X'; // System format
+ 1: TimeFormat := '%I:%M %P'; // 01:11 pm
+ 2: TimeFormat := '%l:%M %P'; // 1:11 pm
+ 3: TimeFormat := '%I:%M:%S %P'; // 01:11:11 pm
+ 4: TimeFormat := '%l:%M:%S %P'; // 1:11:11 pm
+ 5: TimeFormat := '%I:%M %p'; // 01:11 PM
+ 6: TimeFormat := '%l:%M %p'; // 1:11 PM
+ 7: TimeFormat := '%I:%M:%S %p'; // 01:11:11 PM
+ 8: TimeFormat := '%l:%M:%S %p'; // 1:11:11 PM
+ 9: TimeFormat := '%k:%M'; // 13:11
+ 10: TimeFormat := '%k:%M:%S'; // 13:11:11
+ 11: TimeFormat := '%H%M'; // 1311
+ else TimeFormat := ConfCustomTimeFormat; // Custom Time format
+ end;
+ Buf := malloc(255);
+ memset(Buf, 0, 255);
+ placed := strftime(Buf, 254, PChar(TimeFormat), time_tm);
+ if placed <= 0 then DebugMsg(['FormatDate: error converting time. The result will be unpredictable.']);
+ TimeString := String(StrToUTF8(Buf));
+ Libc.free(Buf);
+ end;
+
+ if FormatDate and FormatTime then begin
+ case dtf of
+ 0: Result := Format('%s %s', [DateString, TimeString]);
+ else Result := Format('%s %s', [TimeString, DateString]);
+ end;
+ end else
+ if FormatTime then Result := TimeString else
+ if FormatDate then Result := DateString;
+end;
+
+
+(********************************************************************************************************************************)
function AttrToStr(const Mode: Cardinal; IncludeFileType: boolean = True): string;
begin
if IncludeFileType then begin
diff --git a/UEngines.pas b/UEngines.pas
index 89fb4dd..219a621 100644
--- a/UEngines.pas
+++ b/UEngines.pas
@@ -21,7 +21,7 @@ unit UEngines;
interface
-uses glib2, gdk2, Classes, Libc;
+uses glib2, gdk2, Classes, Libc, UGlibC_compat;
const ERRException = -1;
@@ -49,7 +49,7 @@ type
UpDir: boolean;
Mode, UID, GID: Cardinal;
IsDir, IsLnk, IsBlk, IsChr, IsFIFO, IsSock, Selected, IsDotFile: boolean;
- ModifyTime: TDateTime;
+ ModifyTime: TTimeT;
Icon: Pointer;
ItemColor: PGdkColor;
end;
@@ -64,7 +64,7 @@ type
Size: Int64;
Mode, UID, GID: Cardinal;
IsDir, IsLnk, ForceMove, IsOnRO, IsExecutable: boolean;
- ModifyTime: TDateTime;
+ ModifyTime: TTimeT;
Level: word;
atime, mtime: Int64;
end;
@@ -189,7 +189,7 @@ procedure FreeDataItem(DataItem: PDataItem); overload;
implementation
-uses SysUtils, UCoreUtils, UConfig, UGlibC_compat;
+uses SysUtils, UCoreUtils, UConfig;
(********************************************************************************************************************************)
constructor TPanelEngine.Create;
@@ -309,9 +309,9 @@ begin
IsFIFO := __S_ISTYPE(StatBuf^.st_mode, __S_IFIFO);
IsSock := __S_ISTYPE(StatBuf^.st_mode, __S_IFSOCK);
{$IFDEF KYLIX}
- ModifyTime := UnixTimeToTDateTime(StatBuf^.st_mtime);
+ ModifyTime := StatBuf^.st_mtime;
{$ELSE}
- ModifyTime := UnixTimeToTDateTime(StatBuf^.st_mtim.tv_sec);
+ ModifyTime := StatBuf^.st_mtim.tv_sec;
{$ENDIF}
if StatBuf^.st_uid = 4294967295 then UID := getuid
else UID := StatBuf^.st_uid;
@@ -591,9 +591,9 @@ var Handle : PDirectoryStream;
end;
end;
{$IFDEF KYLIX}
- ModifyTime := UnixTimeToTDateTime(StatBuf_local^.st_mtime);
+ ModifyTime := StatBuf_local^.st_mtime;
{$ELSE}
- ModifyTime := UnixTimeToTDateTime(StatBuf_local^.st_mtim.tv_sec);
+ ModifyTime := StatBuf_local^.st_mtim.tv_sec;
{$ENDIF}
// DebugMsg([FormatDateTime('c', ModifyTime)]);
Level := ALevel + Ord(not AddCurrDirStage);
@@ -675,9 +675,9 @@ begin
ForceMove := False;
// DebugMsg(['x2']);
{$IFDEF KYLIX}
- ModifyTime := UnixTimeToTDateTime(StatBuf^.st_mtime);
+ ModifyTime := StatBuf^.st_mtime;
{$ELSE}
- ModifyTime := UnixTimeToTDateTime(StatBuf^.st_mtim.tv_sec);
+ ModifyTime := StatBuf^.st_mtim.tv_sec;
{$ENDIF}
// DebugMsg(['x2']);
if StatBuf^.st_uid = 4294967295 then UID := getuid
diff --git a/UGlibC_compat.pas b/UGlibC_compat.pas
index 342ab2d..95cd75d 100644
--- a/UGlibC_compat.pas
+++ b/UGlibC_compat.pas
@@ -26,6 +26,16 @@ uses Classes, SysUtils {$IFNDEF CPU64}, Libc{$ENDIF};
const GLIBC_LIB = 'libc.so.6';
type
+{$IFDEF KYLIX}
+ QWORD = Int64;
+{$ENDIF}
+
+{$IFNDEF CPU64}
+ TTimeT = DWORD;
+{$ELSE}
+ TTimeT = QWORD;
+{$ENDIF}
+
PGlibc_IOFile = pointer;
TGlibc_timespec = packed record
@@ -207,9 +217,6 @@ type
{$ENDIF}
end;
-{$IFDEF KYLIX}
- QWORD = Int64;
-{$ENDIF}
@@ -222,6 +229,10 @@ function glibc_stat64(const afile: PChar; buf: PGlibc_stat64): longint;
function glibc_lstat64(const path: PChar; buf: PGlibc_stat64): longint;
{$ENDIF}
+{
+function glibc_localtime(timep: Pointer): Pointer; cdecl; external GLIBC_LIB name 'localtime';
+function glibc_strftime(s: PChar; max: Longint; format: PChar; tm: Pointer): Longint; cdecl; external GLIBC_LIB name 'strftime';
+}
function glibc_statfs64(const path: PChar; buf: PGlibc_statfs64): longint; cdecl; external GLIBC_LIB name 'statfs64';
diff --git a/UMain.pas b/UMain.pas
index be60b0e..78dbcc3 100644
--- a/UMain.pas
+++ b/UMain.pas
@@ -6014,7 +6014,7 @@ begin
FRunFromVFS.SizeLabel2.Caption := Format('%s%s<span weight="ultrabold"> </span>', [FormatSize(Stat^.Size, 0), s]);
if (ConfSizeFormat < 5) or (Stat^.Size < 1024) then s := Format(' %s', [LANGHandleRunFromArchive_Bytes]);
FRunFromVFS.PackedSizeLabel2.Caption := Format('%s%s<span weight="ultrabold"> </span>', [FormatSize(Stat^.Size, 0), s]);
- FRunFromVFS.DateLabel2.Caption := Format('%s<span weight="ultrabold"> </span>', [FormatDateTime('ddddd tt', Stat^.ModifyTime)]);
+ FRunFromVFS.DateLabel2.Caption := Format('%s<span weight="ultrabold"> </span>', [FormatDate(Stat^.ModifyTime, True, True)]);
if (Command = '') and (not Stat^.IsExecutable) then begin
FRunFromVFS.OpensWithLabel2.Caption := Format('%s<span weight="ultrabold"> </span>', [LANGHandleRunFromArchive_NotAssociated]);
FRunFromVFS.ExecuteButton.Enabled := False;
diff --git a/UPreferences.pas b/UPreferences.pas
index fa6775d..90d5a5e 100644
--- a/UPreferences.pas
+++ b/UPreferences.pas
@@ -23,7 +23,7 @@ interface
uses
glib2, gtk2, pango, SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView,
- GTKUtils, GTKDialogs, GTKPixbuf, GTKClasses, GTKMenus,
+ GTKUtils, GTKDialogs, GTKPixbuf, GTKClasses, GTKMenus, Libc,
UCoreClasses, UGnome;
type
@@ -66,6 +66,15 @@ type
miEditorTerminalDetect, miEditorAlwaysTerminal, miEditorNoTerminal,
miTerminalDetect, miAlwaysTerminal, miNoTerminal: TGTKMenuItem;
ShowTextUIDsCheckBox: TGTKCheckButton;
+ DateFormatLabel: TGTKLabel;
+ DateFormatOptionMenu: TGTKOptionMenu;
+ CustomDateFormatEntry: TGTKEntry;
+ TimeFormatLabel: TGTKLabel;
+ TimeFormatOptionMenu: TGTKOptionMenu;
+ CustomTimeFormatEntry: TGTKEntry;
+ DateTimeFormatLabel: TGTKLabel;
+ DateTimeFormatOptionMenu: TGTKOptionMenu;
+
procedure FormCreate(Sender: TObject); override;
procedure FormDestroy(Sender: TObject);
procedure FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean);
@@ -75,8 +84,10 @@ type
procedure ColorButtonDefaultsToggled(Sender: TObject);
procedure DefaultRowHeightCheckBoxToggled(Sender: TObject);
procedure UseInternalViewerCheckBoxToggled(Sender: TObject);
+ procedure DateTimeFormatOptionMenuChanged(Sender: TObject);
private
DefaultGTKFont, LocalListFont: string;
+ FormatTime: time_t;
public
RebuildListViews, RebuildIcons: boolean;
procedure AssignDefaultValues;
@@ -93,8 +104,9 @@ uses ULocale, UFileAssoc, UCoreUtils, UConfig;
procedure TFPreferences.FormCreate(Sender: TObject);
var i: integer;
+ Item: TGTKMenuItem;
begin
- SetDefaultSize(450, 500);
+ SetDefaultSize(450, 570);
Caption := LANGPreferences_Caption;
Buttons := [mbOK, mbCancel];
ShowSeparator := False;
@@ -199,13 +211,13 @@ begin
miSizeFormat1 := TGTKMenuItem.CreateTyped(Self, itLabel);
miSizeFormat1.Caption := Format('%s (%s)', [LANGPreferencesmiSizeFormat1, FormatSize(123456, 0, 0)]);
miSizeFormat2 := TGTKMenuItem.CreateTyped(Self, itLabel);
- miSizeFormat2.Caption := '123456';
+ miSizeFormat2.Caption := FormatSize(123456, 0, 1);
miSizeFormat3 := TGTKMenuItem.CreateTyped(Self, itLabel);
- miSizeFormat3.Caption := '123,456';
+ miSizeFormat3.Caption := FormatSize(123456, 0, 2);
miSizeFormat4 := TGTKMenuItem.CreateTyped(Self, itLabel);
- miSizeFormat4.Caption := '123 456';
+ miSizeFormat4.Caption := FormatSize(123456, 0, 3);
miSizeFormat5 := TGTKMenuItem.CreateTyped(Self, itLabel);
- miSizeFormat5.Caption := '123''456';
+ miSizeFormat5.Caption := FormatSize(123456, 0, 4);
miSizeFormat6 := TGTKMenuItem.CreateTyped(Self, itLabel);
miSizeFormat6.Caption := LANGPreferencesmiSizeFormat6;
SizeFormatOptionMenu.Items.Add(miSizeFormat1);
@@ -214,8 +226,9 @@ begin
SizeFormatOptionMenu.Items.Add(miSizeFormat4);
SizeFormatOptionMenu.Items.Add(miSizeFormat5);
SizeFormatOptionMenu.Items.Add(miSizeFormat6);
- Table2.AddControlEx(1, 6, 1, 1, SizeFormatLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 2);
- Table2.AddControlEx(2, 6, 2, 1, SizeFormatOptionMenu, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 10, 2);
+ Table2.AddControl(0, 7, 1, 1, TGTKVBox.Create(Self), 0, 4);
+ Table2.AddControlEx(1, 8, 1, 1, SizeFormatLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 2);
+ Table2.AddControlEx(2, 8, 2, 1, SizeFormatOptionMenu, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 10, 2);
TerminalOptionMenu := TGTKOptionMenu.Create(Self);
miTerminalDetect := TGTKMenuItem.CreateTyped(Self, itLabel);
@@ -232,8 +245,76 @@ begin
CmdLineBehaviourLabel.XAlign := 0;
CmdLineBehaviourLabel.FocusControl := TerminalOptionMenu;
CmdLineBehaviourLabel.UseUnderline := True;
- Table2.AddControlEx(1, 7, 1, 1, CmdLineBehaviourLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 2);
- Table2.AddControlEx(2, 7, 2, 1, TerminalOptionMenu, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 10, 2);
+ Table2.AddControlEx(1, 6, 1, 1, CmdLineBehaviourLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 2);
+ Table2.AddControlEx(2, 6, 2, 1, TerminalOptionMenu, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 10, 2);
+
+ FormatTime := Libc.__time(nil);
+ DateFormatLabel := TGTKLabel.Create(Self);
+ DateFormatLabel.Caption := '_Date format:';
+ DateFormatLabel.XAlign := 0;
+ DateFormatLabel.UseUnderline := True;
+ DateFormatOptionMenu := TGTKOptionMenu.Create(Self);
+ DateFormatLabel.FocusControl := DateFormatOptionMenu;
+ Item := TGTKMenuItem.CreateTyped(Self, itLabel);
+ Item.Caption := Format('%s (%s)', ['System', FormatDate(FormatTime, False, True, -1, 0, -1)]);
+ DateFormatOptionMenu.Items.Add(Item);
+ for i := 1 to 14 do begin
+ Item := TGTKMenuItem.CreateTyped(Self, itLabel);
+ Item.Caption := FormatDate(FormatTime, False, True, -1, i, -1);
+ DateFormatOptionMenu.Items.Add(Item);
+ end;
+ Item := TGTKMenuItem.CreateTyped(Self, itLabel);
+ Item.Caption := 'Custom...';
+ DateFormatOptionMenu.Items.Add(Item);
+ DateFormatOptionMenu.OnChanged := DateTimeFormatOptionMenuChanged;
+ Table2.AddControlEx(1, 9, 1, 1, DateFormatLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 2);
+ Table2.AddControlEx(2, 9, 2, 1, DateFormatOptionMenu, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 10, 2);
+
+ CustomDateFormatEntry := TGTKEntry.Create(Self);
+ CustomDateFormatEntry.Enabled := False;
+ CustomDateFormatEntry.Tooltip := 'Enter custom date format string.'#10'Please see "man strftime" for syntax reference.';
+ Table2.AddControlEx(2, 10, 2, 1, CustomDateFormatEntry, [taoShrink], [taoShrink], 10, 2);
+
+ TimeFormatLabel := TGTKLabel.Create(Self);
+ TimeFormatLabel.Caption := '_Time format:';
+ TimeFormatLabel.XAlign := 0;
+ TimeFormatLabel.UseUnderline := True;
+ TimeFormatOptionMenu := TGTKOptionMenu.Create(Self);
+ TimeFormatLabel.FocusControl := TimeFormatOptionMenu;
+ Item := TGTKMenuItem.CreateTyped(Self, itLabel);
+ Item.Caption := Format('%s (%s)', ['System', FormatDate(FormatTime, True, False, 0, -1, -1)]);
+ TimeFormatOptionMenu.Items.Add(Item);
+ for i := 1 to 11 do begin
+ Item := TGTKMenuItem.CreateTyped(Self, itLabel);
+ Item.Caption := FormatDate(FormatTime, True, False, i, -1, -1);
+ TimeFormatOptionMenu.Items.Add(Item);
+ end;
+ Item := TGTKMenuItem.CreateTyped(Self, itLabel);
+ Item.Caption := 'Custom...';
+ TimeFormatOptionMenu.Items.Add(Item);
+ TimeFormatOptionMenu.OnChanged := DateTimeFormatOptionMenuChanged;
+ Table2.AddControlEx(1, 11, 1, 1, TimeFormatLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 2);
+ Table2.AddControlEx(2, 11, 2, 1, TimeFormatOptionMenu, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 10, 2);
+
+ CustomTimeFormatEntry := TGTKEntry.Create(Self);
+ CustomTimeFormatEntry.Enabled := False;
+ CustomTimeFormatEntry.Tooltip := 'Enter custom time format string.'#10'Please see "man strftime" for syntax reference.';
+ Table2.AddControlEx(2, 12, 2, 1, CustomTimeFormatEntry, [taoShrink], [taoShrink], 10, 2);
+
+ DateTimeFormatLabel := TGTKLabel.Create(Self);
+ DateTimeFormatLabel.Caption := 'Date/time _order:';
+ DateTimeFormatLabel.XAlign := 0;
+ DateTimeFormatLabel.UseUnderline := True;
+ DateTimeFormatOptionMenu := TGTKOptionMenu.Create(Self);
+ DateTimeFormatLabel.FocusControl := DateTimeFormatOptionMenu;
+ Item := TGTKMenuItem.CreateTyped(Self, itLabel);
+ Item.Caption := FormatDate(FormatTime, True, True, -1, -1, 0);
+ DateTimeFormatOptionMenu.Items.Add(Item);
+ Item := TGTKMenuItem.CreateTyped(Self, itLabel);
+ Item.Caption := FormatDate(FormatTime, True, True, -1, -1, 1);
+ DateTimeFormatOptionMenu.Items.Add(Item);
+ Table2.AddControlEx(1, 13, 1, 1, DateTimeFormatLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 2);
+ Table2.AddControlEx(2, 13, 2, 1, DateTimeFormatOptionMenu, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 10, 2);
// ********* PAGE Panels
@@ -590,6 +671,24 @@ begin
end;
+procedure TFPreferences.DateTimeFormatOptionMenuChanged(Sender: TObject);
+var Item: TGTKMenuItem;
+ OldIndex: integer;
+begin
+ CustomTimeFormatEntry.Enabled := TimeFormatOptionMenu.ItemIndex = TimeFormatOptionMenu.Items.Count - 1;
+ CustomDateFormatEntry.Enabled := DateFormatOptionMenu.ItemIndex = DateFormatOptionMenu.Items.Count - 1;
+
+ OldIndex := DateTimeFormatOptionMenu.ItemIndex;
+ DateTimeFormatOptionMenu.Items.Clear;
+ Item := TGTKMenuItem.CreateTyped(Self, itLabel);
+ Item.Caption := FormatDate(FormatTime, True, True, TimeFormatOptionMenu.ItemIndex, DateFormatOptionMenu.ItemIndex, 0);
+ DateTimeFormatOptionMenu.Items.Add(Item);
+ Item := TGTKMenuItem.CreateTyped(Self, itLabel);
+ Item.Caption := FormatDate(FormatTime, True, True, TimeFormatOptionMenu.ItemIndex, DateFormatOptionMenu.ItemIndex, 1);
+ DateTimeFormatOptionMenu.Items.Add(Item);
+ DateTimeFormatOptionMenu.ItemIndex := OldIndex;
+end;
+
(********************************************************************************************************************************)
procedure TFPreferences.ViewerBrowseButtonClick(Sender: TObject);
@@ -754,9 +853,16 @@ begin
WMCompatModeCheckBox.Checked := ConfWMCompatMode;
CompatUseLibcSystemCheckBox.Checked := ConfUseLibcSystem;
+ CustomTimeFormatEntry.Text := ConfCustomTimeFormat;
+ CustomDateFormatEntry.Text := ConfCustomDateFormat;
+ DateFormatOptionMenu.ItemIndex := ConfDateFormat;
+ TimeFormatOptionMenu.ItemIndex := ConfTimeFormat;
+ DateTimeFormatOptionMenu.ItemIndex := ConfDateTimeFormat;
+
DefaultFontCheckBoxToggled(Self);
ColorButtonDefaultsToggled(Self);
UseInternalViewerCheckBoxToggled(Self);
+ DateTimeFormatOptionMenuChanged(Self);
end;
procedure TFPreferences.SaveSettings;
@@ -815,6 +921,12 @@ begin
ConfUseLibcSystem := CompatUseLibcSystemCheckBox.Checked;
ConfDisableFileTips := DisableFileTipsCheckBox.Checked;
ConfShowFuncButtons := ShowFuncButtonsCheckBox.Checked;
+
+ ConfCustomTimeFormat := CustomTimeFormatEntry.Text;
+ ConfCustomDateFormat := CustomDateFormatEntry.Text;
+ ConfDateFormat := DateFormatOptionMenu.ItemIndex;
+ ConfTimeFormat := TimeFormatOptionMenu.ItemIndex;
+ ConfDateTimeFormat := DateTimeFormatOptionMenu.ItemIndex;
end;
(********************************************************************************************************************************)
diff --git a/USearch.pas b/USearch.pas
index a451fb6..45c75f9 100644
--- a/USearch.pas
+++ b/USearch.pas
@@ -292,11 +292,11 @@ begin
if not FUseGnomeWidgets then begin
ModifiedBetweenEntry1 := TGTKEntry.Create(Self);
- ModifiedBetweenEntry1.Tooltip := FormatDateTime(LANGSearch_ModifiedBetweenEntry1, Date);
+ ModifiedBetweenEntry1.Tooltip := SysUtils.FormatDateTime(LANGSearch_ModifiedBetweenEntry1, Date);
ModifiedBetweenEntry2 := TGTKEntry.Create(Self);
- ModifiedBetweenEntry2.Tooltip := FormatDateTime(LANGSearch_ModifiedBetweenEntry1, Date);
+ ModifiedBetweenEntry2.Tooltip := SysUtils.FormatDateTime(LANGSearch_ModifiedBetweenEntry1, Date);
NotModifiedAfterEntry := TGTKEntry.Create(Self);
- NotModifiedAfterEntry.Tooltip := FormatDateTime(LANGSearch_ModifiedBetweenEntry1, Date);
+ NotModifiedAfterEntry.Tooltip := SysUtils.FormatDateTime(LANGSearch_ModifiedBetweenEntry1, Date);
Table2.AddControlEx(2, 5, 2, 1, ModifiedBetweenEntry1, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 5, 2);
Table2.AddControlEx(5, 5, 2, 1, ModifiedBetweenEntry2, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 5, 2);
Table2.AddControlEx(2, 6, 2, 1, NotModifiedAfterEntry, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 5, 2);
diff --git a/vfs/UVFSCore.pas b/vfs/UVFSCore.pas
index e3bdf4c..ded912a 100644
--- a/vfs/UVFSCore.pas
+++ b/vfs/UVFSCore.pas
@@ -398,7 +398,7 @@ begin
IsFIFO := TVFSItemType(P^.ItemType) = vFifo;
IsSock := TVFSItemType(P^.ItemType) = vSock;
// DebugMsg(['Checkpoint 5']);
- ModifyTime := UnixTimeToTDateTime(P^.m_time);
+ ModifyTime := P^.m_time;
// DebugMsg(['Returned datetime: ', Longword(P^.m_time)]);
// DebugMsg(['Checkpoint 6']);
UID := P^.iUID;
@@ -588,7 +588,7 @@ begin
{***} IsOnRO := True;
IsExecutable := P^.iMode and S_IXUSR = S_IXUSR;
Mode := P^.iMode;
- ModifyTime := UnixTimeToTDateTime(P^.m_time);
+ ModifyTime := P^.m_time;
mtime := P^.m_time;
atime := P^.a_time;
UID := P^.iUID;
@@ -648,7 +648,7 @@ var Item: PDataItemSL;
{***} IsOnRO := True;
IsExecutable := AddCurrDirStage or (P^.iMode and S_IXUSR = S_IXUSR);
Mode := P^.iMode;
- ModifyTime := UnixTimeToTDateTime(P^.m_time);
+ ModifyTime := P^.m_time;
mtime := P^.m_time;
atime := P^.a_time;
UID := P^.iUID;