LibreOffice 25.2 Súgó
The Region service provides a collection of properties and methods to handle locale and region-related aspects of programming, such as:
Accessing locale and region-dependent settings such as number formatting, currency and timezones.
Converting timezones and calculate Daylight Saving Time (DST) offsets.
Transforming numbers into text in any supported language.
Egy nyelvet és egy országot kombináló karakterlánc "la-CO" formátumban. A nyelvi rész 2 vagy 3 kisbetűs karakterrel fejezhető ki, amit egy kötőjel választ el az országot jelképező 2 nagybetűs karaktertől.
For instance, "en-US" corresponds to the English language in the United States; "fr-BE" corresponds to the French language in Belgium, and so forth.
On some situations the full locale is not required and only the language or country may be specified.
Most properties and methods accept a locale as argument. If no locale is specified, then the user-interface locale is used, which is defined in the OfficeLocale property of the Platform service.
"Régió/Város" formátumú karakterlánc, például "Európa/Berlin", vagy egy időzóna azonosító, például "UTC" vagy "GMT-8:00". A lehetséges időzóna nevek és azonosítók listáját lásd a List of tz database timezones wiki oldalon.
Ha a Region szolgáltatás bármelyik metódusában érvénytelen időzóna karakterláncot ad meg, az nem eredményez futási hibát. Ehelyett a UTCDateTime és UTCNow metódusok az aktuális operációs rendszer dátumát és idejét adják vissza.
The time offset between the timezone and the Greenwich Meridian Time (GMT) is expressed in minutes.
The Daylight Saving Time (DST) is an additional offset.
The timezone and DST offsets may be positive or negative.
Before using the Region service the ScriptForge library needs to be loaded or imported:
The examples below in Basic and Python instantiate the Region service and access the Country property.
    GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")
    Dim oRegion As Variant
    oRegion = CreateScriptService("Region")
    MsgBox oRegion.Country("en-US") ' United States
  
    from scriptforge import CreateScriptService
    oRregion = CreateScriptService("Region")
    bas = CreateScriptService("Basic")
    bas.MsgBox(oRegion.Country("en-US"))
  All properties listed below accept a locale argument, provided as a string. Some properties require this argument to be in the format "la-CO", whereas others may receive "la" or "CO" as input.
| Név | Írásvédett | Típus | Területi beállítás | Leírás | 
|---|---|---|---|---|
| Country | Igen | String | "la‑CO" | Returns the country name in English corresponding to a given region. | 
| Currency | Igen | String | "la-CO" | Returns the ISO 4217 currency code of the specified region. | 
| DatePatterns | Igen | Karaktertömb | "la-CO" | Returns a zero-based array of strings containing the date acceptance patterns for the specified region. | 
| DateSeparator | Igen | String | "la-CO" | Returns the date separator used in the given region. | 
| DayAbbrevNames | Igen | Karaktertömb | "la-CO" | Returns a zero-based array of strings containing the list of abbreviated weekday names in the specified language. | 
| DayNames | Igen | Karaktertömb | "la-CO" | Returns a zero-based array of strings containing the list of weekday names in the specified language. | 
| DayNarrowNames | Igen | Karaktertömb | "la-CO" | Returns a zero-based array of strings containing the list of the initials of weekday names in the specified language. | 
| DecimalPoint | Igen | String | "la-CO" | Returns the decimal separator used in numbers in the specified region. | 
| Language | Igen | String | "la-CO" | Returns the name of the language, in English, of the specified region. | 
| ListSeparator | Igen | String | "la-CO" | Returns the list separator used in the specified region. | 
| MonthAbbrevNames | Igen | Karaktertömb | "la-CO" | Returns a zero-based array of strings containing the list of abbreviated month names in the specified language. | 
| MonthNames | Igen | Karaktertömb | "la-CO" | Returns a zero-based array of strings containing the list of month names in the specified language. | 
| MonthNarrowNames | Igen | Karaktertömb | "la-CO" | Returns a zero-based array of strings containing the list of the initials of month names in the specified language. | 
| ThousandSeparator | Igen | String | "la-CO" | Returns the thousands separator used in numbers in the specified region. | 
| TimeSeparator | Igen | String | "la-CO" | Returns the separator used to format times in the specified region. | 
| List of Methods in the Region Service | ||
|---|---|---|
Computes the additional Daylight Saving Time (DST) offset, in minutes, that is applicable to a given region and timezone.
svc.DSTOffset(localdatetime: date, timezone: str, opt locale: str): int
localdatetime: the local date and time expressed as a date.
timezone: the timezone for which the offset will be calculated.
locale: az országot meghatározó területi beállítás, amelyre vonatkozóan az eltolást kiszámítják, "la-CO" vagy "CO" formátumban megadva. Az alapértelmezett érték a Platform szolgáltatás OfficeLocale tulajdonságában a meghatározott területi beállítás.
      ' Calculates the offset applicable in the "America/Los_Angeles" timezone
      Dim aDateTime As Date, offset As Integer
      aDateTime = DateSerial(2022, 7, 1) + TimeSerial(16, 0, 0)
      offset = oRegion.DSTOffset(aDateTime, "America/Los_Angeles", "US") ' 60 (minutes)
      aDateTime = DateSerial(2022, 1, 1) + TimeSerial(16, 0, 0)
      offset = oRegion.DSTOffset(aDateTime, "America/Los_Angeles", "US") ' 0 (minutes)
    
      import datetime
      aDateTime = datetime.datetime(2022, 7, 1, 16, 0, 0)
      offset = oRegion.DSTOffset(aDateTime, "America/Los_Angeles", "US") ' 60 (minutes)
      aDateTime = datetime.datetime(2022, 1, 1, 16, 0, 0)
      offset = oRegion.DSTOffset(aDateTime, "America/Los_Angeles", "US") ' 0 (minutes)
    Computes the local date and time from a UTC date and time.
svc.LocalDateTime(utcdatetime: date, timezone: str, opt locale: str): date
utcdatetime: the UTC date and time, expressed using a date object.
timezone: the timezone for which the local time will be calculated.
locale: az országot meghatározó területi beállítás, amelyre a helyi idő kiszámításra kerül, "la-CO" vagy "CO" formátumban megadva. Az alapértelmezett érték a Platform szolgáltatás OfficeLocale tulajdonságában a meghatározott területi beállítás.
      ' June 6th, 2022 at 10:30:45 (used here as UTC time)
      Dim UTCTime As Date, localTime As Date
      UTCTime = DateSerial(2022, 6, 23) + TimeSerial(10, 30, 45)
      ' Calculates local time in Sao Paulo, Brazil
      ' June 6th, 2022 at 07:30:45
      localTime = oRegion.LocalDateTime(UTCTime, "America/Sao_Paulo", "BR")
    
      import datetime
      utcTime = datetime.datetime(2022, 6, 23, 10, 30, 45)
      localTime = oRegion.LocalDateTime(utcTime, "America/Sao_Paulo", "BR")
    Converts numbers and monetary values into written text for any of the currently supported languages.
For a list of all supported languages visit the XNumberText Interface API reference.
svc.Number2Text(number: any, opt locale: str): str
szám: az írott szöveggé alakítandó szám. Megadható numerikus típus vagy karakterlánc formájában. Ha karakterláncot adunk meg, akkor egy előtagot lehet előtte adni, amely tájékoztat arról, hogy a számokat hogyan kell leírni. Lehetőség van ISO 4217-es pénznemkódok megadására is. További információért lásd az alábbi példákat.
locale: a nyelvet meghatározó nyelvi konfiguráció, amelyre a szám konvertálásra kerül, "la-CO" vagy "CO" formátumban megadva. Az alapértelmezett érték a Platform szolgáltatás OfficeLocale tulajdonságában a meghatározott nyelvi konfiguráció.
      ' Returns "one hundred five"
      Dim numText As String
      numText = oRegion.Number2Text(105, "en-US")
      ' Returns: "two point four two"
      numText = oRegion.Number2Text(2.42, "en-US")
      ' Returns: "twenty-five euro and ten cents" Notice the "EUR" currency symbol
      numText = oRegion.Number2Text("EUR 25.10", "en-US")
      ' Returns: "fifteenth"; Notice the "ordinal" prefix
      numText = oRegion.Number2Text("ordinal 15", "en-US")
    
      numText = oRegion.Number2Text(105, "en-US")
      numText = oRegion.Number2Text(2.42, "en-US")
      numText = oRegion.Number2Text("EUR 25.10", "en-US")
      numText = oRegion.Number2Text("ordinal 15", "en-US")
    Az adott nyelv összes támogatott előtagjának listáját a Number2Text speciális "help" argumentummal hívja meg. Az alábbi példában, ha feltételezzük, hogy a területi beállítás "en-US", akkor a MsgBox megjeleníti az "en-US" nyelvhez rendelkezésre álló előtagok listáját:
      prefixes = oRegion.Number2Text("help")
      MsgBox prefixes
      ' one, two, three
      ' ordinal: first, second, third
      ' ordinal-number: 1st, 2nd, 3rd
      ' year: nineteen ninety-nine, two thousand, two thousand one
      ' currency (for example, USD): two U.S. dollars and fifty cents
      ' money USD: two and 50/100 U.S. dollars
    Az üzenetmező első sorában nincs előtag, ami azt jelenti, hogy ez a szabványos formátum. A következő sorok tartalmazzák az előtagot és néhány példát a formátumot használó számokra.
Each language has its own set of supported prefixes. The number of available prefixes may vary from language to language.
Ha egy adott nyelv vagy területi beállítás előtagjainak listáját szeretné megkapni, azt a Number2Text második argumentumaként adhatja meg. Az alábbi példa a "pt-BR" területi beállításhoz rendelkezésre álló előtagokat mutatja:
      prefixes = oRegion.Number2Text("help", "pt-BR")
      MsgBox prefixes
      ' um, dois, três
      ' feminine: uma, duas, três
      ' masculine: um, dois, três
      ' ordinal-feminine: primeira, segunda, terceira
      ' ordinal-masculine: primeiro, segundo, terceiro
      ' ordinal-number-feminine: 1.ª, 2.ª, 3.ª
      ' ordinal-number-masculine: 1.º, 2.º, 3.º
    Returns the offset between GMT and the given timezone and locale, in minutes.
svc.TimeZoneOffset(timezone: str, opt locale: str): int
timezone: the timezone for which the offset to the GMT will be calculated.
locale: az országot meghatározó területi beállítás, amelyre vonatkozóan az eltolást kiszámítják, "la-CO" vagy "CO" formátumban megadva. Az alapértelmezett érték a Platform szolgáltatás OfficeLocale tulajdonságában a meghatározott területi beállítás.
      Dim offset As Integer
      offset = oRegion.TimeZoneOffset("America/New_York", "US") ' -300
      offset = oRegion.TimeZoneOffset("Europe/Berlin", "DE") ' 60
    
      offset = oRegion.TimeZoneOffset("America/New_York", "US") # -300
      offset = oRegion.TimeZoneOffset("Europe/Berlin", "DE") # 60
    Returns the UTC date and time considering a given local date and time in a timezone.
svc.UTCDateTime(localdatetime: date, timezone: str, opt locale: str): date
localdatetime: the local date and time in a specific timezone expressed as a date.
timezone: the timezone for which the localdatetime argument was given.
locale: az országot meghatározó területi beállítás, amelyre a localdatetime argumentumot "la-CO" vagy "CO" formátumban megadták. Az alapértelmezett érték a Platform szolgáltatás OfficeLocale tulajdonságában a meghatározott területi beállítás.
      ' Date/Time in Berlin, June 23, 2022 at 14:30:00
      Dim localDT As Date, utcTime As Date
      localDT = DateSerial(2022, 6, 23) + TimeSerial(14, 30, 0)
      ' The UTC date/time is June 23, 2022 at 12:30:00
      utcTime = oRegion.UTCDateTime(localDT, "Europe/Berlin", "DE")
    
      import datetime
      localDT = datetime.datetime(2022, 6, 23, 14, 30, 0)
      utcTime = oRegion.UTCDateTime(localDT, "Europe/Berlin", "DE")
    Returns the current UTC date and time, given a timezone and locale.
This method uses the current date and time of your operating system to calculate the UTC time.
svc.UTCNow(timezone: str, opt locale: str): date
timezone: the timezone for which the current UTC time will be calculated.
locale: az országot meghatározó területi beállítás, amelyre az aktuális UTC-idő kiszámításra kerül, "la-CO" vagy "CO" formátumban megadva. Az alapértelmezett érték a Platform szolgáltatás OfficeLocale tulajdonságában a meghatározott területi beállítás.
      ' Suppose the operating system time is June 23rd, 2022 at 10:42:00
      ' If the computer is in Europe/Berlin, then UTC time is June 23rd, 2022 at 08:42:00
      Dim utcTime As Date
      utcTime = oRegion.UTCNow("Europe/Berlin", "DE")
    
      utcTime = oRegion.UTCNow("Europe/Berlin", "DE")