Article View: pl.comp.lang.delphi
Article #345810OLTypes - Typy zastępujące Integer, String, TDate... z możliwością przypisania Null
From: mihoo
Date: Mon, 22 May 2017 06:16
Date: Mon, 22 May 2017 06:16
37 lines
2649 bytes
2649 bytes
Przygotowałem bibliotekę typów zastępujących standardowe typy proste w Delphi.
Jest dostępna pod adresem
https://bitbucket.org/mihoor/oltypes/wiki/Home
Oprócz możliwości przypisywania Null-a, zmienne tych typów mają dodane zestawy metod, które uznałem za najczęściej wykorzystywane.
Przykład:
procedure OLDateTest();
var
d: TDate;
i: integer;
b: Boolean;
SuperD: OLDate;
begin
d := Date();
if SuperD.IsNull() then // Default value is Null
SuperD := d; // Assign regular TDate value
SuperD.Year := 2018; // Change the year
SuperD := SuperD.IncMonth(5); // Add 5 months
SuperD := '2017-05-12'; // You can use current format or ISO 8601;
b := SuperD.InRange('2018-01-01', '2019-01-01');
i := SuperD.EndOfAMonth(2018, 2).DaysInMonth();
SuperD := 'epm'; // The 'epm' is a SmartString interpreted as end of the prior month
ShowMessage(SuperD.ToString()); // like DateToStr
SuperD := Now(); // assigning TDateTime will cut off the time part UNLIKE in TDate
b := (SuperD = Date()); // so b is true
d := SuperD; // Assign OLDate to regular TDate variable
end;
Wiki zawiera kolejne przykłady. W repozytorium jest też projekt testowy, który jest świetnym źródłem wiedzy, jak używać biblioteki.
Technical Details
Message-ID:
<6d22eed4-10cd-4a3f-9623-9ced22d857a3@googlegroups.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!news.cyf-kr.edu.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!news.glorb.com!l39no802014qtb.0!news-out.google.com!v18ni5526ita.0!nntp.google.com!67no1290666itx.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Received: by 10.237.59.111 with SMTP id q44mr9641714qte.69.1495433807645; Sun, 21 May 2017 23:16:47 -0700 (PDT) X-Received: by 10.157.35.104 with SMTP id k37mr448514otd.14.1495433807595; Sun, 21 May 2017 23:16:47 -0700 (PDT) Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!news.cyf-kr.edu.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!news.glorb.com!l39no802014qtb.0!news-out.google.com!v18ni5526ita.0!nntp.google.com!67no1290666itx.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: pl.comp.lang.delphi Date: Sun, 21 May 2017 23:16:47 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=85.221.238.2; posting-account=mFKuAAoAAAAZmgeFmQdRL4aBSabT2lxn NNTP-Posting-Host: 85.221.238.2 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <6d22eed4-10cd-4a3f-9623-9ced22d857a3@googlegroups.com> Subject: OLTypes - Typy zastępujące Integer, String, TDate... z możliwością przypisania Null From: mihoo <rajewicz@wp.pl> Injection-Date: Mon, 22 May 2017 06:16:47 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit