起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 448|回复: 9

【结帖】时间格式化错,**

[复制链接]
发表于 2008-3-30 20:55:48 | 显示全部楼层 |阅读模式
我有值班表中起始时间字段,为时间日期弄,表现为时间,subtype为stTime型,但是在有些电脑中输入起始时间为8:00:00则会出错如图,有些电脑则不会出错,请问是何原因,如何解决呢?
谢谢~

time_error.jpg

20.52 KB, 下载次数: 318

回复

使用道具 举报

发表于 2008-3-31 08:36:21 | 显示全部楼层
应该是操作系统日期时间设置的问题,你对比一下正常和不正常的设置
回复 支持 反对

使用道具 举报

发表于 2008-3-31 11:35:44 | 显示全部楼层
我在实施中遇到过类似问题,是打开计划中心的时候报日期转换格式错误,解决步骤:
控制面版-->区域和语言选项-->区域选项-->[自定义]-->时间-->时间格式 改成:hh:mm:ss
其中AM符号:上午 PM符号: 下午
回复 支持 反对

使用道具 举报

发表于 2008-3-31 11:46:01 | 显示全部楼层
设置每一台机器的客户端不是好的解决方案
有两个全局变量,是日期时间格式的,在主界面上设置这两个变量就不受客户端设置的影响了
var ShortTimeFormat: string;
var LongTimeFormat: string;
回复 支持 反对

使用道具 举报

发表于 2008-3-31 11:51:14 | 显示全部楼层
更完整的变量列表
=================
Influence the way numeric or date/time values are formatted.

Unit

SysUtils

The following are a set of variables used to define the format for numeric or date/time strings:

var CurrencyString: string;

var CurrencyFormat: Byte;
var NegCurrFormat: Byte;
var ThousandSeparator: Char;
var DecimalSeparator: Char;
var CurrencyDecimals: Byte;
var DateSeparator: Char;
var ShortDateFormat: string;
var LongDateFormat: string;
var TimeSeparator: Char;
var TimeAMString: string;
var TimePMString: string;
var ShortTimeFormat: string;
var LongTimeFormat: string;

var ShortMonthNames: array[1..12] of string;
var LongMonthNames: array[1..12] of string;
var ShortDayNames: array[1..7] of string;
var LongDayNames: array[1..7] of string;
var SysLocale: TSysLocale;
var EraNames: array[1..7] of string;
var EraYearOffsets: array[1..7] of Integer;
var TwoDigitYearCenturyWindow: Word = 50;

var ListSeparator: Char;

Description

The SysUtils unit includes a number of variables that are used by various formatting routines. Values are assigned to these variables to define the formats of numeric and date/time strings. The initial values of these variables are fetched from the system registry using the GetLocaleInfo function in the Win32 API. VCL (non-console) applications automatically update these formatting variables in response to WM_WININICHANGE messages. The Application variable抯 UpdateFormatSettings method either allows or disallows changes in system settings. The default is True. Set this property to False to prevent the system settings from changing.

The description of each variable specifies the LOCALE_XXXX constant used to fetch the value.

Typed constant        Defines

CurrencyString        CurrencyString defines the currency symbol (or characters) used in floating-point to decimal conversions. The initial value is fetched from LOCALE_SCURRENCY.
CurrencyFormat        CurrencyFormat defines the currency symbol placement and separation used in floating-point
杢o杁ecimal conversions. Possible values are:
0 = $1
1 = 1$
2 = $ 1
3 = 1 $
The initial value is fetched from LOCALE_ICURRENCY.
NegCurrFormat        NegCurrFormat defines the currency format used in floating-point to decimal conversions of negative numbers. Possible values are:
0 = ($1)    4 = (1$)    8 = -1 $     12 = $ -1
1 = -$1     5 = -1$     9 = -$ 1     13 = 1- $
2 = $-1     6 = 1-$    10 = 1 $-    14 = ($ 1)
3 = $1-     7 = 1$-    11 = $ 1-    15 = (1 $)
The initial value is fetched from LOCALE_INEGCURR.

ThousandSeparator        ThousandSeparator is the character used to separate thousands in numbers with more than three digits to the left of the decimal separator. A value of #0 indicates that no thousand separator character should be output, even if the format string specifies it. The initial value is fetched from LOCALE_STHOUSAND.
DecimalSeparator        DecimalSeparator is the character used to separate the integer part from the fractional part of a number. This variable must have a value other than #0. The initial value is fetched from LOCALE_SDECIMAL.

CurrencyDecimals        CurrencyDecimals is the number of digits to the right of the decimal point in a currency amount. The initial value is fetched from LOCALE_ICURRDIGITS.
DateSeparator        DateSeparator is the character used to separate the year, month, and day parts of a date value. The initial value is fetched from LOCATE_SDATE.
ShortDateFormat        ShortDateFormat is the format string used to convert a date value to a short string suitable for editing. For a complete description of date and time format strings, see Date-Time format strings. The short date format should only use the date separator character and the  m, mm, d, dd, yy, and yyyy format specifiers. The initial value is fetched from LOCALE_SSHORTDATE.

LongDateFormat        LongDateFormat is the format string used to convert a date value to a long string suitable for display but not for editing. For a complete description of date and time format strings, see Date-Time format strings. The initial value is fetched from LOCALE_SLONGDATE.
TimeSeparator        TimeSeparator is the character used to separate the hour, minute, and second parts of a time value. The initial value is fetched from LOCALE_STIME.

TimeAMString        TimeAMString is the suffix string used for time values between 00:00 and 11:59 in 12-hour clock format. The initial value is fetched from LOCALE_S1159.
TimePMString        TimePMString is the suffix string used for time values between 12:00 and 23:59 in 12-hour clock format. The initial value is fetched from LOCALE_S2359.
ShortTimeFormat        ShortTimeFormat is the format string used to convert a time value to a short string with only hours and minutes. The default value is computed from LOCALE_ITIME and LOCALE_ITLZERO.

LongTimeFormat        LongTimeFormat is the format string used to convert a time value to a string with hours, minutes, and seconds. The default value is computed from LOCALE_ITIME and LOCALE_ITLZERO.
ShortMonthNames        ShortMonthNames is the array of strings containing short month names. The mmm format specifier in a format string passed to FormatDateTime causes a short month name to be substituted. The default values are fetched from the LOCALE_SABBREVMONTHNAME system locale entries.

LongMonthNames        LongMonthNames is the array of strings containing long month names. The mmmm format specifier in a format string passed to FormatDateTime causes a long month name to be substituted. The default values are fetched from the LOCALE_SMONTHNAME system locale entries.
ShortDayNames        ShortDayNames is the array of strings containing short day names. The ddd format specifier in a format string passed to FormatDateTime causes a short day name to be substituted. The default values are fetched from the LOCALE_SABBREVDAYNAME system locale entries.

LongDayNames        LongDayNames is the array of strings containing long day names. The dddd format specifier in a format string passed to FormatDateTime causes a long day name to be substituted. The default values are fetched from the LOCALE_SDAYNAME system locale entries.
SysLocale        Indicates the locale used by FormatDateTime to interpret dates.
EraNames        Controls the DateTimeToStr function (for East Asian locales).

EraYearOffsets        Controls the DateTimeToStr function (for East Asian locales).
TwoDigitYearCenturyWindow        Determines what century is added to two-digit years when string dates are converted to numeric dates with StrToDate or StrToDateTime The value of TwoDigitYearCenturyWindow, if it is nonzero, is subtracted from the current year to calculate the floating 損ivot?prior to which two-digit years are interpreted as falling in the next century. The default value is 50. You can use TwoDigitYearCenturyWindow to extend the life of legacy applications that are tied to two-digit-year data entry; but the best solution is to require four-digit input for years.

ListSeparator        The character used to separate items in a list. The default value is fetched from LOCALE_SLIST.
回复 支持 反对

使用道具 举报

发表于 2008-4-22 09:38:16 | 显示全部楼层
由于楼主长期未反馈,先结帖!
有问题请重新开帖!
回复 支持 反对

使用道具 举报

发表于 2008-5-14 11:20:45 | 显示全部楼层
楼主,情况如何?
先结贴,有反馈请发新贴
回复 支持 反对

使用道具 举报

发表于 2008-12-25 10:26:28 | 显示全部楼层
能不能详细讲下定义全局变量怎么用:最好有代码例子
var ShortTimeFormat: string;
var LongTimeFormat: string;
回复 支持 反对

使用道具 举报

发表于 2008-12-25 14:30:57 | 显示全部楼层
回复 支持 反对

使用道具 举报

发表于 2008-12-25 17:14:01 | 显示全部楼层
我还没有试试,要不你先试试,定义完变量,然后赋值,例如  ShortDateFormat := 'm/d/yyyy';
就可以了。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2025-7-28 20:05 , Processed in 0.045980 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表