StrFormatTime error with latest POL100 core

Bug reports and feature requests. New features can only be added to the current development version. Bug-fixes may be back-ported.

Current release: 099 / Current development: 100
Post Reply
yayafan
Novice Poster
Posts: 40
Joined: Sun Mar 15, 2015 2:26 am

StrFormatTime error with latest POL100 core

Post by yayafan »

I found something wrong with StrFormatTime function:
for example: var time := StrFormatTime( "%I:%M:%S %p", CInt( POLCore().systime )); it doesn't work
change to : var time := StrFormatTime( "%I:%M:%S", CInt( POLCore().systime )); it works
seems %p paramter doesnt' work in StrFormatTime function. If you add %p, then nothing will return.

below is the packagelog when I use ServerTime command to show time information in game:

[12/16 23:06:11] Logfile opened.
Server -> Client: 0x1C, 65 bytes
0000 1c 00 41 01 01 01 01 01 01 00 03 b2 00 03 53 79 ..A..... ......Sy
0010 73 74 65 6d 00 00 00 00 00 00 00 00 00 00 00 00 stem.... ........
0020 00 00 00 00 00 00 00 00 00 00 00 00 49 2f 4f 20 ........ ....I/O
0030 6c 6f 67 20 66 69 6c 65 20 6f 70 65 6e 65 64 2e log file opened.
0040 00 ........ ........

Client -> Server: 0xBF, 6 bytes
0000 bf 00 06 00 24 34 ....$4.. ........

Client -> Server: 0xAD, 36 bytes
0000 ad 00 24 00 02 b2 00 03 43 48 54 00 00 2e 00 73 ..$..... CHT....s
0010 00 65 00 72 00 76 00 65 00 72 00 74 00 69 00 6d .e.r.v.e .r.t.i.m
0020 00 65 00 00 .e...... ........

Server -> Client: 0xAE, 58 bytes
0000 ae 00 3a 01 01 01 01 01 01 00 03 e8 00 03 45 4e ..:..... ......EN
0010 55 00 53 79 73 74 65 6d 00 00 00 00 00 00 00 00 U.System ........
0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
0030 90 4a 62 32 66 42 95 93 00 00 .Jb2fB.. ........

Server -> Client: 0x1C, 54 bytes
0000 1c 00 36 01 01 01 01 01 01 00 00 37 00 03 53 79 ..6..... ...7..Sy
0010 73 74 65 6d 00 00 00 00 00 00 00 00 00 00 00 00 stem.... ........
0020 00 00 00 00 00 00 00 00 00 00 00 00 20 36 31 37 ........ .... 617
0030 30 38 30 32 37 00 08027... ........

Server -> Client: 0xAE, 60 bytes
0000 ae 00 3c 01 01 01 01 01 01 00 03 e8 00 03 45 4e ..<..... ......EN
0010 55 00 53 79 73 74 65 6d 00 00 00 00 00 00 00 00 U.System ........
0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
0030 67 0d 52 d9 56 68 65 e5 67 1f 00 00 g.R.Vhe. g.......

Server -> Client: 0x1C, 56 bytes
0000 1c 00 38 01 01 01 01 01 01 00 00 37 00 03 53 79 ..8..... ...7..Sy
0010 73 74 65 6d 00 00 00 00 00 00 00 00 00 00 00 00 stem.... ........
0020 00 00 00 00 00 00 00 00 00 00 00 00 20 31 32 2d ........ .... 12-
0030 31 36 2d 32 30 31 39 00 16-2019. ........

Server -> Client: 0xAE, 60 bytes
0000 ae 00 3c 01 01 01 01 01 01 00 03 e8 00 03 45 4e ..<..... ......EN
0010 55 00 53 79 73 74 65 6d 00 00 00 00 00 00 00 00 U.System ........
0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
0030 67 0d 52 d9 56 68 66 42 95 93 00 00 g.R.VhfB ........

Client -> Server: 0xBF, 6 bytes
0000 bf 00 06 00 24 80 ....$... ........

Client -> Server: 0xAD, 30 bytes
0000 ad 00 1e 00 02 b2 00 03 43 48 54 00 00 2e 00 73 ........ CHT....s
0010 00 74 00 6f 00 70 00 6c 00 6f 00 67 00 00 .t.o.p.l .o.g....

Log closed at %sMon Dec 16 23:06:20 2019
Skinny
Expert Poster
Posts: 76
Joined: Wed Dec 19, 2012 10:27 pm

Re: StrFormatTime error with latest POL100 core

Post by Skinny »

You can use %H instead %I.

It uses ISO 8601 (the 24-hour clock system).
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: StrFormatTime error with latest POL100 core

Post by Turley »

I haven't tested it, but other people tested it without any problems.
I guess it's some kind of locale problem.
What is the value of the environment variable LANG and LC_TIME
Skinny
Expert Poster
Posts: 76
Joined: Wed Dec 19, 2012 10:27 pm

Re: StrFormatTime error with latest POL100 core

Post by Skinny »

%p writes localized a.m. or p.m. (locale dependent)

https://en.cppreference.com/w/cpp/chrono/c/strftime
yayafan
Novice Poster
Posts: 40
Joined: Sun Mar 15, 2015 2:26 am

Re: StrFormatTime error with latest POL100 core

Post by yayafan »

I tried with LANG set to CHT and ENU, both have this problem.
What's LC_TIME ? I don't know the mean of it.
Post Reply