FMX.AddressBook.Types.TContactDates.AddDate
Delphi
function AddDate(const AKind: TContactDate.TLabelKind; const ADate: TDate): TContactDate; overload;
function AddDate(const ALabel: string; const ADate: TDate): TContactDate; overload;
C++
TContactDate* __fastcall AddDate(const TContactDate::TLabelKind AKind, const System::TDate ADate)/* overload */;
TContactDate* __fastcall AddDate(const System::UnicodeString ALabel, const System::TDate ADate)/* overload */;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | FMX.AddressBook.Types.pas FMX.AddressBook.Types.hpp |
FMX.AddressBook.Types | TContactDates |
Description
Adds a new date to a list of the contact-related dates.
Use this method to add a new date to a list of the contact-related dates. The input parameters of this method allows you to specify the following characteristics:
ADate
: specifies a value of the TDate type that represents the contact-related date, such as the person birthday.AKind
: in the first overloaded method, this parameter specifies the kind of the contact date.Alabel
: in the second overloaded method, this parameter specifies an optional text label, such as "Birthday," "Anniversary," and like.
Examples
To clarify, consider the following examples. These code snippets illustrate how to specify the birthday date of the contact person, and save this contact to Address Book.
Delphi:
var
Contact: TAddressBookContact;
Locale: TFormatSettings;
Dates : TContactDates;
begin
Contact := AddressBook1.CreateContact(AddressBook1.DefaultSource);
try
// Specify the locale to use
Locale := TFormatSettings.Create('en-US');
Dates := TContactDates.Create;
try
// Add the birthday of the contact person
Dates.AddDate(TContactDate.TLabelKind.Birthday,StrToDate('12/17/1990',Locale));
Contact.Dates := Dates;
finally
Dates.Free;
end;
// Save the newly created contact
AddressBook1.SaveContact(Contact);
finally
Contact.Free;
end;
end;
C++Builder:
TAddressBookContact *Contact;
TContactDates *dates;
// Create a new contact
Contact = AddressBook1->CreateContact(AddressBook1->DefaultSource());
__try {
// Specify the locale to use
TFormatSettings locale = TFormatSettings::Create("en-US");
dates = new TContactDates();
__try {
// Add the birthday date of the contact person
dates->AddDate(TContactDate::TLabelKind::Birthday,
StrToDate("12/17/1990", locale));
Contact->Dates = dates;
}
__finally {
dates->Free();
}
// Save contact to Address Book
AddressBook1->SaveContact(Contact);
}
__finally {
Contact->Free();
}
For more information and samples, see Mobile Tutorial: Using an Address Book Component (iOS and Android).