当前位置:网站首页>QML type: locale, date
QML type: locale, date
2022-07-06 09:10:00 【Friendly, friend】
Locale
One 、 describe
This type provides locale specific properties and formatted data .
Locale The object can only pass through Qt.locale() Function creation . You can't create... Directly .
Qt.locale() The function returns a JS Locale object , Represents the locale with the specified name , The format for “language[_territory][.codeset][@modifier]” or “C”.
Support the concept of default locale , The default locale is determined by the locale of the system when the application starts . If no parameters are passed to Qt.locale(), Return the default locale object .
Two 、 Attribute members
1、amText : string
Use 12 Hour time “AM” Localized name of suffix .
2、decimalPoint : string
Decimal character .
3、exponential : string
Exponential character .
4、firstDayOfWeek : enumeration
The first day of the week .
- Locale.Sunday = 0
- Locale.Monday = 1
- Locale.Tuesday = 2
- Locale.Wednesday = 3
- Locale.Thursday = 4
- Locale.Friday = 5
- Locale.Saturday = 6
5、groupSeparator : string
Group separator .
6、measurementSystem : enumeration
The unit of measurement .
- Locale.MetricSystem: Metric units , For example, rice 、 Centimeters and millimeters .
- Locale.ImperialUSSystem: Imperial units , For example, inches and miles used in the United States .
- Locale.ImperialUKSystem: Imperial units , For example, inches and miles used in Britain .
- Locale.ImperialSystem: Provide compatibility . And Locale.ImperialUSSystem identical .
7、name : string
The language and country of this locale / The region is saved as “language_country” String of form , Among them, the language is two letters of lowercase ISO 639 The language code , Countries are capitalized with two or three letters ISO 3166 Country code .
8、nativeCountryName : string
The local name of the country .
9、nativeLanguageName : string
The local name of the language .
10、negativeSign : string
Negative sign character .
11、numberOptions : enumeration
Contains a set of options for number to string and string to number conversion .
12、percent : string
Percentage characters .
13、pmText : string
Use 12 Hour time “PM” Localized name of suffix .
14、positiveSign : string
Positive sign character .
15、textDirection : enumeration
Text direction of language .
- Qt.LeftToRight
- Qt.RightToLeft
16、uiLanguages : Array<string>
Returns an ordered list of locale names used for translation purposes in order of priority .
The return value indicates that the user wants to see UI Translated locale name .
17、weekDays : Array<int>
The number of days considered as working days according to the current locale , Sunday is 0, Saturday is 6.
18、zeroDigit : string
Zero character .
3、 ... and 、 Member functions
1、string currencySymbol(format)
Returns the currency symbol in the specified format :
- Locale.CurrencyIsoCode: Monetary ISO-4217 Code .
- Locale.CurrencySymbol: Currency symbols .
- Locale.CurrencyDisplayName: Name of currency .
2、string dateFormat(type)
string dateTimeFormat(type)
Returns the date used for the current locale 、 Date time format .type Specifies the FormatType. See... Below Date.
3、string dayName(day, type)
With type Specified optional FormatType Returns the localized name of the day (day Parameters 0 On behalf of Sunday ,1 On behalf of Monday , And so on ).
4、string formattedDataSize(int bytes, int precision, DataSizeFormat format)
Convert byte size to readable localized string . see QLocale::formattedDataSize().
5、string monthName(month, type)
With type Specified optional FormatType Returns the localized name of the month (0-11).
6、string standaloneDayName(day, type)
Returns the localized name of the date used as stand-alone text ( among 0 On behalf of Sunday ,1 On behalf of Monday , And so on ), Using the type designated FormatType.
If locale information does not specify an independent date name , Then the return value is the same as dayName() The same in .
7、string standaloneMonthName(month, type)
Returns the localized name of the month used as stand-alone text (0-11), use type Specified optional FormatType.
If the locale information does not specify an independent month name , Then the return value is the same as monthName() The same in .
8、string timeFormat(type)
Returns the time format used for the current locale .type Specifies the FormatType.
Date
One 、 describe
Date Object usage area (Locale) The setting function is extended JS Date object .
Two 、 Format enumeration values
When you need a format that matches your locale preferences , Use enumeration values :
- Locale.LongFormat: Longer format
- Locale.ShortFormat: Shorter format
- Locale.NarrowFormat: In context with Locale.ShortFormat identical
The format of the enumeration representation will depend on the locale , But it also depends on the method of enumeration .
for example , about en_US Language environment , Use the following format string :
3、 ... and 、 Member functions
1、string fromLocaleDateString(locale, dateString, format)
Use locale and format to put date strings dateString Convert to Date object .
If no format is specified , Will use Locale.LongFormat.
If the locale is not specified , The default locale will be used .
import QtQml 2.0
QtObject {
property var locale: Qt.locale()
property date currentDate: new Date()
property string dateString
Component.onCompleted: {
dateString = currentDate.toLocaleDateString();
print(Date.fromLocaleDateString(dateString));
}
}
2、string fromLocaleString(locale, dateTimeString, format)
Use locale and format to put date time strings dateTimeString Convert to Date object .
If no format is specified , Will use Locale.LongFormat.
If the locale is not specified , The default locale will be used .
import QtQml 2.0
QtObject {
property var locale: Qt.locale()
property string dateTimeString: "Tue 2013-09-17 10:56:06"
Component.onCompleted: {
print(Date.fromLocaleString(locale, dateTimeString, "ddd yyyy-MM-dd hh:mm:ss"));
}
}
3、string fromLocaleTimeString(locale, timeString, format)
Use locale and format to convert time strings timeString Convert to Date object .
If no format is specified , Will use Locale.LongFormat.
If the locale is not specified , The default locale will be used .
import QtQml 2.2
QtObject {
property var locale: Qt.locale()
property date currentTime: new Date()
property string timeString
Component.onCompleted: {
timeString = currentTime.toLocaleTimeString(locale, Locale.ShortFormat);
print(Date.fromLocaleTimeString(locale, timeString, Locale.ShortFormat));
}
}
4、string timeZoneUpdated()
notice JS The time zone of the engine system has changed , This is necessary for correct operation of date and time data .
This function should be called after the system time zone is updated .
The application that changes the time zone will call... After setting the new time zone timeZoneUpdated():
property string selectedTimeZone
onSelectedTimeZoneChanged: {
MyFunctions.setSystemTimeZone(selectedTimeZone)
Date.timeZoneUpdated()
}
5、string toLocaleDateString(locale, format)
take Date Converts to a string containing the date of the specified locale in the specified format .
If no format is specified , Will use Locale.LongFormat.
If the locale is not specified , The default locale will be used .
import QtQuick 2.0
Text {
text: "The date is: " + new Date().toLocaleDateString(Qt.locale("de_DE"))
}
6、string toLocaleString(locale, format)
take Date Converts to a string containing the date and time of the specified locale in the specified format .
If no format is specified , Will use Locale.LongFormat.
If the locale is not specified , The default locale will be used .
import QtQuick 2.0
Text {
text: "The date is: " + new Date().toLocaleString(Qt.locale("de_DE"))
}
7、string toLocaleTimeString(locale, format)
take Date Converts to a string containing the time of the specified locale in the specified format .
If no format is specified , Will use Locale.LongFormat.
If the locale is not specified , The default locale will be used .
import QtQuick 2.0
Text {
text: "The date is: " + new Date().toLocaleTimeString(Qt.locale("de_DE"))
}
边栏推荐
- [today in history] February 13: the father of transistors was born The 20th anniversary of net; Agile software development manifesto was born
- What is an R-value reference and what is the difference between it and an l-value?
- Leetcode: Sword finger offer 42 Maximum sum of continuous subarrays
- 力扣每日一题(二)
- Redis之性能指标、监控方式
- 五层网络体系结构
- LeetCode:26. Remove duplicates from an ordered array
- [Hacker News Weekly] data visualization artifact; Top 10 Web hacker technologies; Postman supports grpc
- CUDA implementation of self defined convolution attention operator
- LeetCode:162. Looking for peak
猜你喜欢
随机推荐
Leetcode: Jianzhi offer 03 Duplicate numbers in array
Simclr: comparative learning in NLP
LeetCode:236. The nearest common ancestor of binary tree
Li Kou daily question 1 (2)
LeetCode41——First Missing Positive——hashing in place & swap
LeetCode:394. String decoding
An article takes you to understand the working principle of selenium in detail
xargs命令的基本用法
Different data-driven code executes the same test scenario
CSP first week of question brushing
Digital people anchor 618 sign language with goods, convenient for 27.8 million people with hearing impairment
Problems encountered in connecting the database of the project and their solutions
Chapter 1 :Application of Artificial intelligence in Drug Design:Opportunity and Challenges
The carousel component of ant design calls prev and next methods in TS (typescript) environment
一改测试步骤代码就全写 为什么不试试用 Yaml实现数据驱动?
Advance Computer Network Review(1)——FatTree
SimCLR:NLP中的对比学习
[oc foundation framework] - < copy object copy >
KDD 2022论文合集(持续更新中)
Super efficient! The secret of swagger Yapi