如何格式化日期和时间
2009-11-07 09:31
363 查看
[Setup]
AppName=DateFormat
AppVerName=DateFormat
Uninstallable=false
UpdateUninstallLogAppName=false
DisableDirPage=true
DisableProgramGroupPage=true
DefaultDirName={pf}\DateFormat
DisableStartupPrompt=true
[Code]
#include "LangLib.iss"
type
TSystemTime = record
wYear : Word;
wMonth : Word;
wDayOfWeek : Word;
wDay : Word;
wHour : Word;
wMinute : Word;
wSecond : Word;
wMilliseconds : Word;
end;
procedure GetLocalTime(var lpSystemTime: TSystemTime); external
'GetLocalTime@kernel32.dll';
function GetDateFormat(Locale: Integer;dwFlags: LongInt;
var lpDate: TSystemTime; lpFormat: PChar; lpDateStr: String;
cchDate: Integer): Integer; external
'GetDateFormatA@kernel32.dll';
function GetTimeFormat(Locale: Integer;dwFlags: LongInt;
var lpTime: TSystemTime;lpFormat: PChar;lpTimeStr: String;
cchDate: Integer): Integer; external
'GetTimeFormatA@kernel32.dll';
function GetlastError(): Integer; external
'GetLastError@kernel32.dll';
var
lt : TSystemTime;
function InitializeSetup: Boolean;
begin
// Initialize Lanuage variables
InitLang;
GetLocalTime(lt);
Result := true;
end;
procedure AddDateTime( list: TlistBox; desc: String; lc: LCID );
var
datestring, timestring : String;
begin
list.Items.Add( desc + ' = ' + IntToStr( lc ) );
datestring := StringOfChar(' ',64);
GetDateFormat(lc, DATE_LONGDATE,lt, '' ,datestring,63);
datestring := CastIntegerToString( CastStringToInteger(datestring) );
list.Items.Add( ' Date = ' + datestring );
timestring := StringOfChar(' ',64);
GetTimeFormat(lc, 0, lt , '', timestring,63);
timestring := CastIntegerToString( CastStringToInteger(timestring) );
list.Items.Add( ' Time = ' + timestring );
end;
function DateTimeFormats( BackClicked: Boolean): Boolean;
var
MyList : TListBox;
Next: Boolean;
mylcid :LCID;
datestring, timestring, format: string;
begin
// First open the custom wizard page
ScriptDlgPageOpen();
// Set some captions
ScriptDlgPageSetCaption('Date Time Formats');
ScriptDlgPageSetSubCaption1('List of date and time formats');
MyList := TListBox.Create(WizardForm.ScriptDlgPanel);
MyList.Top := 8;
MyList.Width := WizardForm.ScriptDlgPanel.Width;
MyList.Parent := WizardForm.ScriptDlgPanel;
MyList.Height := WizardForm.ScriptDlgPanel.Height - 24;
AddDateTime( MyList, 'User Default LCID ', GetUserDefaultLCID );
AddDateTime( MyList, 'Systemt Default LCID ', GetSystemDefaultLCID );
mylcid := MakeLCID(MakeLangId(LANG_ITALIAN, SUBLANG_ITALIAN), SORT_DEFAULT);
AddDateTime( MyList, 'Italian LCID ', mylcid );
mylcid := MakeLCID(MakeLangId(LANG_SPANISH, SUBLANG_SPANISH_PUERTO_RICO), SORT_DEFAULT);
AddDateTime( MyList, 'Spanish (Puerto Rico) LCID ', mylcid );
mylcid := MakeLCID(MakeLangId(LANG_ENGLISH, SUBLANG_ENGLISH_EIRE), SORT_DEFAULT);
AddDateTime( MyList, 'English (Irish) LCID ', mylcid );
datestring := StringOfChar(' ',64);
format := 'dd dddd MMMM yyyy';
GetDateFormat(GetUserDefaultLCID,0,lt,format,datestring,63);
datestring := CastIntegerToString( CastStringToInteger(datestring) );
MyList.Items.Add( 'Custom format <' + format + '> = ' + datestring );
timestring := StringOfChar(' ',64);
format := 'hh''--''mm''--''ss';
GetTimeFormat(GetUserDefaultLCID,0,lt,format,timestring,63);
timestring := CastIntegerToString( CastStringToInteger(timestring) );
MyList.Items.Add( 'Custom format <' + format + '> = ' + timestring );
Next := ScriptDlgPageProcessCustom();
// See NextButtonClick and BackButtonClick: return True if the click should be allowed
if not BackClicked then
Result := Next
else
Result := not Next;
// Close the wizard page. Do a FullRestore only if the click (see above) is not allowed
ScriptDlgPageClose(not Result);
end;
function ScriptDlgPages(CurPage: Integer; BackClicked: Boolean): Boolean;
begin
if (not BackClicked and (CurPage = wpWelcome)) or (BackClicked and (CurPage = wpReady)) then begin
Result := DateTimeFormats( BackClicked )
end
else
Result := True;
end;
function NextButtonClick(CurPage: Integer): Boolean;
begin
Result := ScriptDlgPages(CurPage, False);
end;
function BackButtonClick(CurPage: Integer): Boolean;
begin
Result := ScriptDlgPages(CurPage, True);
end;本文出自 “学无止境” 博客,请务必保留此出处http://dqk1985.blog.51cto.com/1005868/223421
AppName=DateFormat
AppVerName=DateFormat
Uninstallable=false
UpdateUninstallLogAppName=false
DisableDirPage=true
DisableProgramGroupPage=true
DefaultDirName={pf}\DateFormat
DisableStartupPrompt=true
[Code]
#include "LangLib.iss"
type
TSystemTime = record
wYear : Word;
wMonth : Word;
wDayOfWeek : Word;
wDay : Word;
wHour : Word;
wMinute : Word;
wSecond : Word;
wMilliseconds : Word;
end;
procedure GetLocalTime(var lpSystemTime: TSystemTime); external
'GetLocalTime@kernel32.dll';
function GetDateFormat(Locale: Integer;dwFlags: LongInt;
var lpDate: TSystemTime; lpFormat: PChar; lpDateStr: String;
cchDate: Integer): Integer; external
'GetDateFormatA@kernel32.dll';
function GetTimeFormat(Locale: Integer;dwFlags: LongInt;
var lpTime: TSystemTime;lpFormat: PChar;lpTimeStr: String;
cchDate: Integer): Integer; external
'GetTimeFormatA@kernel32.dll';
function GetlastError(): Integer; external
'GetLastError@kernel32.dll';
var
lt : TSystemTime;
function InitializeSetup: Boolean;
begin
// Initialize Lanuage variables
InitLang;
GetLocalTime(lt);
Result := true;
end;
procedure AddDateTime( list: TlistBox; desc: String; lc: LCID );
var
datestring, timestring : String;
begin
list.Items.Add( desc + ' = ' + IntToStr( lc ) );
datestring := StringOfChar(' ',64);
GetDateFormat(lc, DATE_LONGDATE,lt, '' ,datestring,63);
datestring := CastIntegerToString( CastStringToInteger(datestring) );
list.Items.Add( ' Date = ' + datestring );
timestring := StringOfChar(' ',64);
GetTimeFormat(lc, 0, lt , '', timestring,63);
timestring := CastIntegerToString( CastStringToInteger(timestring) );
list.Items.Add( ' Time = ' + timestring );
end;
function DateTimeFormats( BackClicked: Boolean): Boolean;
var
MyList : TListBox;
Next: Boolean;
mylcid :LCID;
datestring, timestring, format: string;
begin
// First open the custom wizard page
ScriptDlgPageOpen();
// Set some captions
ScriptDlgPageSetCaption('Date Time Formats');
ScriptDlgPageSetSubCaption1('List of date and time formats');
MyList := TListBox.Create(WizardForm.ScriptDlgPanel);
MyList.Top := 8;
MyList.Width := WizardForm.ScriptDlgPanel.Width;
MyList.Parent := WizardForm.ScriptDlgPanel;
MyList.Height := WizardForm.ScriptDlgPanel.Height - 24;
AddDateTime( MyList, 'User Default LCID ', GetUserDefaultLCID );
AddDateTime( MyList, 'Systemt Default LCID ', GetSystemDefaultLCID );
mylcid := MakeLCID(MakeLangId(LANG_ITALIAN, SUBLANG_ITALIAN), SORT_DEFAULT);
AddDateTime( MyList, 'Italian LCID ', mylcid );
mylcid := MakeLCID(MakeLangId(LANG_SPANISH, SUBLANG_SPANISH_PUERTO_RICO), SORT_DEFAULT);
AddDateTime( MyList, 'Spanish (Puerto Rico) LCID ', mylcid );
mylcid := MakeLCID(MakeLangId(LANG_ENGLISH, SUBLANG_ENGLISH_EIRE), SORT_DEFAULT);
AddDateTime( MyList, 'English (Irish) LCID ', mylcid );
datestring := StringOfChar(' ',64);
format := 'dd dddd MMMM yyyy';
GetDateFormat(GetUserDefaultLCID,0,lt,format,datestring,63);
datestring := CastIntegerToString( CastStringToInteger(datestring) );
MyList.Items.Add( 'Custom format <' + format + '> = ' + datestring );
timestring := StringOfChar(' ',64);
format := 'hh''--''mm''--''ss';
GetTimeFormat(GetUserDefaultLCID,0,lt,format,timestring,63);
timestring := CastIntegerToString( CastStringToInteger(timestring) );
MyList.Items.Add( 'Custom format <' + format + '> = ' + timestring );
Next := ScriptDlgPageProcessCustom();
// See NextButtonClick and BackButtonClick: return True if the click should be allowed
if not BackClicked then
Result := Next
else
Result := not Next;
// Close the wizard page. Do a FullRestore only if the click (see above) is not allowed
ScriptDlgPageClose(not Result);
end;
function ScriptDlgPages(CurPage: Integer; BackClicked: Boolean): Boolean;
begin
if (not BackClicked and (CurPage = wpWelcome)) or (BackClicked and (CurPage = wpReady)) then begin
Result := DateTimeFormats( BackClicked )
end
else
Result := True;
end;
function NextButtonClick(CurPage: Integer): Boolean;
begin
Result := ScriptDlgPages(CurPage, False);
end;
function BackButtonClick(CurPage: Integer): Boolean;
begin
Result := ScriptDlgPages(CurPage, True);
end;本文出自 “学无止境” 博客,请务必保留此出处http://dqk1985.blog.51cto.com/1005868/223421
相关文章推荐
- Java - 日期和时间:- 如何取得年月日、时分秒?- 如何取得从1970年1月1日0时0分0秒到现在的毫秒数?- 如何取得某月的最后一天?- 如何格式化日期?
- [转]Sql server2005中如何格式化时间日期
- PHP+Mysql日期时间如何转换(UNIX时间戳和格式化日期)
- Sql server2005中如何格式化时间日期
- PHP+Mysql日期时间如何转换(UNIX时间戳和格式化日期)
- Sql server2005中如何格式化时间日期
- PHP+Mysql日期时间如何转换(UNIX时间戳和格式化日期)
- java中如何获得当前时间以及日期格式化的 4000 详解
- Sql server2005中如何格式化时间日期
- c#json如何格式化日期和时间
- PHP+Mysql日期时间如何转换(UNIX时间戳和格式化日期)
- Sql server2005中如何格式化时间日期
- Sql server2005中如何格式化时间日期
- Sql server2005中如何格式化时间日期
- easyUI如何格式化日期时间
- C#日期比较计算两个日期的时间间隔,日期格式化
- PHP 如何获取两个时间之间的年和月份及间隔天数 PHP两个日期之间的所有日期
- jsp页面格式化时间 fmt:formatDate格式化日期
- Mysql语句中格式化日期时间的方法
- 批处理(bat)命令获得并格式化日期和时间