mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-10 06:08:17 +02:00
LCL, added CFDateRefToDateTime to carbonproc
git-svn-id: trunk@48541 -
This commit is contained in:
parent
f74c22fd79
commit
ccb61c9d10
@ -29,7 +29,7 @@ interface
|
||||
|
||||
uses
|
||||
MacOSAll,
|
||||
Classes, SysUtils, Types, LCLType, LCLProc,
|
||||
Classes, SysUtils, DateUtils, Types, LCLType, LCLProc,
|
||||
Controls, Forms, Graphics, Math, GraphType;
|
||||
|
||||
const
|
||||
@ -106,6 +106,8 @@ function GetCarbonRect(const ARect: TRect): MacOSAll.Rect;
|
||||
function ParamsToCarbonRect(const AParams: TCreateParams): MacOSAll.Rect;
|
||||
function ParamsToRect(const AParams: TCreateParams): TRect;
|
||||
|
||||
function CFDateRefToDateTime(dateRef: CFDateRef): TDateTime;
|
||||
|
||||
type
|
||||
CGRectArray = Array of CGRect;
|
||||
|
||||
@ -918,6 +920,28 @@ begin
|
||||
Result.Bottom := AParams.Y + AParams.Height;
|
||||
end;
|
||||
|
||||
function CFDateRefToDateTime(dateRef: CFDateRef): TDateTime;
|
||||
var
|
||||
absTime: CFAbsoluteTime;
|
||||
gDate: CFGregorianDate;
|
||||
tz: CFTimeZoneRef;
|
||||
aTime: TDateTime;
|
||||
ok: boolean;
|
||||
begin
|
||||
absTime := CFDateGetAbsoluteTime(dateRef);
|
||||
tz := CFTimeZoneCopySystem;
|
||||
gDate := CFAbsoluteTimeGetGregorianDate(absTime, tz);
|
||||
CFRelease(tz);
|
||||
|
||||
with gDate do
|
||||
if not TryEncodeDateTime(
|
||||
trunc(year), trunc(month), trunc(day),
|
||||
trunc(hour), trunc(minute), trunc(second), 0, result)
|
||||
then
|
||||
result := 0;
|
||||
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Name: ExcludeRect
|
||||
Params: A - Source rectangle
|
||||
|
Loading…
Reference in New Issue
Block a user