Πέμπτη 27 Οκτωβρίου 2022

Using Locale Id for Date() and Date$()

 This is a small demo which show the use of locale id in Date() and Date$(). See also Locale statement (Locale is also a read only variable). Here Locale statement handle the language format for boolean values (M2000 knows only Greek Αληθές/Ψευδές and not Greek True/False), because boolean values are not part of System (which are day and month names).


So the object of the example is to show how we can convert December 11, 2002 from a string which have date as in 1033 and in 1032 locale. Also see that date$(37601) always return "11/12/2002", which is the same format for date("11/12/2002")


Locale 1033 // English
date("11/12/2002") --> 37601
date("11/12/2002", 1032)=37601 --> True
date$(37601, 1032, "short date")="11/12/2002" --> True
date$(37601, 1032, "long date") --> "Τετάρτη, 11 Δεκεμβρίου 2002"
date("12/11/2002", 1033)=37601 --> True
date$(37601, 1033, "short date")="12/11/2002" --> True
date$(37601, 1033, "long date") --> "Wednesday, December 11, 2002"
date$(37601)="11/12/2002" --> True
Locale 1032 // Greek
date("11/12/2002") --> 37601
date("11/12/2002", 1032)=37601 --> Αληθές
date$(37601, 1032, "short date")="11/12/2002" --> Αληθές
date$(37601, 1032, "long date") --> "Τετάρτη, 11 Δεκεμβρίου 2002"
date("12/11/2002", 1033)=37601 --> Αληθές
date$(37601, 1033, "short date")="12/11/2002" --> Αληθές
date$(37601, 1033, "long date") --> "Wednesday, December 11, 2002"
date$(37601)="11/12/2002" --> Αληθές


Open "date.txt" for wide output as #a
Print #a, chrcode$(0xFEFF); // BOM UTF16LE
locale 1033
Print #a,"Locale 1033 // English"
Print #a, {date("11/12/2002") --> }, date("11/12/2002")
Print #a, {date("11/12/2002", 1032)=37601 --> }, date("11/12/2002", 1032)=37601
Print #a, {date$(37601, 1032, "short date")="11/12/2002" --> }, date$(37601, 1032, "short date")="11/12/2002"
Print #a, {date$(37601, 1032, "long date") --> }+"""", date$(37601, 1032, "long date"),""""
Print #a, {date("12/11/2002", 1033)=37601 --> }, date("12/11/2002", 1033)=37601
Print #a, {date$(37601, 1033, "short date")="12/11/2002" --> }, date$(37601, 1033, "short date")="12/11/2002"
Print #a, {date$(37601, 1033, "long date") --> }+"""", date$(37601, 1033, "long date"), """"
Print #a, {date$(37601)="11/12/2002" --> }, date$(37601)="11/12/2002"
locale 1032
Print #a,"Locale 1032 // Greek"
Print #a, {date("11/12/2002") --> }, date("11/12/2002")
Print #a, {date("11/12/2002", 1032)=37601 --> },date("11/12/2002", 1032)=37601
Print #a, {date$(37601, 1032, "short date")="11/12/2002" --> }, date$(37601, 1032, "short date")="11/12/2002"
Print #a, {date$(37601, 1032, "long date") --> }+"""", date$(37601, 1032, "long date"), """"
Print #a, {date("12/11/2002", 1033)=37601 --> }, date("12/11/2002", 1033)=37601
Print #a, {date$(37601, 1033, "short date")="12/11/2002" --> },date$(37601, 1033, "short date")="12/11/2002"
Print #a, {date$(37601, 1033, "long date") --> }+"""",date$(37601, 1033, "long date"),""""
Print #a, {date$(37601)="11/12/2002" --> }, date$(37601)="11/12/2002"
close #a
document k$
load.doc k$, "date.txt"
report k$
clipBoard k$

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου

You can feel free to write any suggestion, or idea on the subject.