{"id":357,"date":"2022-01-07T18:31:34","date_gmt":"2022-01-07T21:31:34","guid":{"rendered":"https:\/\/gladiston.net.br\/?page_id=357"},"modified":"2022-07-13T16:05:15","modified_gmt":"2022-07-13T19:05:15","slug":"formato-de-data-dentro-do-programa","status":"publish","type":"page","link":"https:\/\/gladiston.net.br\/en\/programacao\/lazarus-ide\/formato-de-data-dentro-do-programa\/","title":{"rendered":"Date format within the application"},"content":{"rendered":"<p>Lazarus like any other programming language takes some information from the operating system, for example when using:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mydate:=DateToStr(&#039;01\/01\/1970&#039;);<\/pre>\n\n\n\n<p>This will work fine on Windows, but it may fail in some graphical environments on Linux. This happens because the installed Windows is already localized in the Portuguese environment and is always the same in any edition, but in Linux the localization and translation, even if in Portuguese, the date format may be different.<\/p>\n\n\n\n<p>This occurs for example in GNOME version 41<\/p>\n\n\n\n<p>One way to solve this problem is to include the instructions below in the unit that initialized your program, right in the section&nbsp;<strong>initialization<\/strong>(maybe you have to create it)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>initialization DefaultFormatSettings.DateSeparator:=&#039;\/&#039;; DefaultFormatSettings.ShortDateFormat:=&#039;DD\/MM\/YYYY&#039;; DefaultFormatSettings.LongDateFormat:=&#039;dd&quot; &quot;mmmm&quot; &quot;yyyy&#039;; DefaultFormatSettings.CurrencyString:=&#039;R$&#039;; DefaultFormatSettings.DecimalSeparator:=&#039;,&#039;; \/\/ Abbreviated month names DefaultFormatSettings.ShortMonthNames[1] := &#039;Jan&#039;; DefaultFormatSettings.ShortMonthNames[2] := &#039;Feb&#039;; DefaultFormatSettings.ShortMonthNames[3] := &#039;Mar&#039;; DefaultFormatSettings.ShortMonthNames[4] := &#039;Abr&#039;; DefaultFormatSettings.ShortMonthNames[5] := &#039;May&#039;; DefaultFormatSettings.ShortMonthNames[6] := &#039;Jun&#039;; DefaultFormatSettings.ShortMonthNames[7] := &#039;Jul&#039;; DefaultFormatSettings.ShortMonthNames[8] := &#039;Aug&#039;; DefaultFormatSettings.ShortMonthNames[9] := &#039;Set&#039;; DefaultFormatSettings.ShortMonthNames[10] := &#039;Out&#039;; DefaultFormatSettings.ShortMonthNames[11] := &#039;Nov&#039;; DefaultFormatSettings.ShortMonthNames[12] := &#039;Ten&#039;; \/\/ Month name DefaultFormatSettings.LongMonthNames[1] := &#039;January&#039;; DefaultFormatSettings.LongMonthNames[2] := &#039;February&#039;; DefaultFormatSettings.LongMonthNames[3] := &#039;March&#039;; DefaultFormatSettings.LongMonthNames[4] := &#039;April&#039;; DefaultFormatSettings.LongMonthNames[5] := &#039;May&#039;; DefaultFormatSettings.LongMonthNames[6] := &#039;June&#039;; DefaultFormatSettings.LongMonthNames[7] := &#039;July&#039;; DefaultFormatSettings.LongMonthNames[8] := &#039;August&#039;; DefaultFormatSettings.LongMonthNames[9] := &#039;September&#039;; DefaultFormatSettings.LongMonthNames[10] := &#039;October&#039;; DefaultFormatSettings.LongMonthNames[11] := &#039;November&#039;; DefaultFormatSettings.LongMonthNames[12] := &#039;December&#039;; \/\/ Name of the abbreviated days of the week DefaultFormatSettings.ShortDayNames[1] := &#039;Dom&#039;; DefaultFormatSettings.ShortDayNames[2] := &#039;Mon&#039;; DefaultFormatSettings.ShortDayNames[3] := &#039;Have&#039;; DefaultFormatSettings.ShortDayNames[4] := &#039;Wed&#039;; DefaultFormatSettings.ShortDayNames[5] := &#039;Thu&#039;; DefaultFormatSettings.ShortDayNames[6] := &#039;Sex&#039;; DefaultFormatSettings.ShortDayNames[7] := &#039;Sat&#039;; \/\/ Name of days of the week DefaultFormatSettings.LongDayNames[1] := &#039;Sunday&#039;; DefaultFormatSettings.LongDayNames[2] := &#039;Monday&#039;; DefaultFormatSettings.LongDayNames[3] := &#039;Tuesday&#039;; DefaultFormatSettings.LongDayNames[4] := &#039;Wednesday&#039;; DefaultFormatSettings.LongDayNames[5] := &#039;Thursday&#039;; DefaultFormatSettings.LongDayNames[6] := &#039;Friday&#039;; DefaultFormatSettings.LongDayNames[7] := &#039;Saturday&#039;;<\/code><\/pre>\n\n\n\n<p>If your program will be internationalized, I recommend creating a form where the above variables can be modified according to the location where the program will be executed.<\/p>\n\n\n\n<p>The other way is to know the graphic environment correctly and adjust it to use date and time in Brazilian format.<\/p>","protected":false},"excerpt":{"rendered":"<p>O Lazarus assim como qualquer outra linguagem de programa\u00e7\u00e3o retira algumas informa\u00e7\u00f5es do sistema operacional, por exemplo, ao usar: minhadata:=DateToStr(\u201801\/01\/1970\u2019); Isto funcionar\u00e1 perfeitamente no Windows, mas \u00e9 poss\u00edvel que falhe em alguns ambientes gr\u00e1ficos no Linux. Isto acontece porque o Windows instalado j\u00e1 \u00e9 localizado no ambiente em portugu\u00eas e \u00e9 sempre igual em qualquer [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":159,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"templates\/template-full-width.php","meta":{"footnotes":""},"class_list":["post-357","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages\/357","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/comments?post=357"}],"version-history":[{"count":3,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages\/357\/revisions"}],"predecessor-version":[{"id":493,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages\/357\/revisions\/493"}],"up":[{"embeddable":true,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages\/159"}],"wp:attachment":[{"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/media?parent=357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}