wcsftime() on HPUX doesn't work


 
Thread Tools Search this Thread
Operating Systems HP-UX wcsftime() on HPUX doesn't work
# 1  
Old 09-05-2010
wcsftime() on HPUX doesn't work

Hi,
I'm wrote a small program on HPUX that uses wcsftime, but this function seems to be not working - I get 0 as a result, the output buffer returns empty, and errno is 0 :


Code:
#include <iostream>
using namespace std;

int main ()
{
  size_t formattedTimeLength = 0;
  wchar_t formattedTime[255] = {0};
  char formattedTimeN[255] = {0};
  struct timeval tv;
  time_t mSeconds;
  uint32_t mMilliSeconds;

  if (::gettimeofday( &tv, NULL ) == 0)
  {
    mSeconds = tv.tv_sec;
    mMilliSeconds = tv.tv_usec / 1000;
  }

  struct tm tmBuffer;
  struct tm* localTime = gmtime_r(&mSeconds, &tmBuffer);

  formattedTimeLength = wcsftime(formattedTime, 255, L"%Y-%m-%d %H:%M:%S", localTime);

  wcout << "formattedTimeLength = " << formattedTimeLength << ", formattedTime = " << formattedTime << endl;
  perror( "Error formatting time" );

  formattedTimeLength = strftime(formattedTimeN, 255, "%Y-%m-%d %H:%M:%S", localTime);

  cout << "formattedTimeLength = " << formattedTimeLength << ", formattedTimeN = " << formattedTimeN << endl;

  return 0;
}

BTW, I compiled it with aCC wcstest.cpp -AA +p +DD64 -fast -s +Z -mt

And another thing - _INCLUDE__STDC_A1_SOURCE is set, so wcsftime is defined as:
Code:
wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm *).


Last edited by Scott; 09-05-2010 at 08:37 AM.. Reason: Please use code tags, and text less formatting
# 2  
Old 09-05-2010
How come you did not include the wchar.h header?
# 3  
Old 09-06-2010
I've included iostream, it should be enough (it probably includes some other header files that include wchar.h).
The problem is not compiling it, it's on runtime.
# 4  
Old 09-07-2010
Not including the right headers can cause runtime errors, since the function may be implicitly defined as having the wrong arguments and return types.
# 5  
Old 09-12-2010
I don't think it matters in my case, but just to make sure I tried it with wchar.h included, and the result was the same.
# 6  
Old 09-13-2010
What about all the other headers you are missing? Did you include those?
# 7  
Old 09-14-2010
You're focusing on the headers, but I'm not sure this is the problem.
To be clear, strftime() returns the formatted time as expected.
The only problem is with wcsftime().
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

-ne 0 doesn't work -le does

Hi, I am using korn shell. until ] do echo "\$# = " $# echo "$1" shift done To the above script, I passed 2 parameters and the program control doesn't enter inside "until" loop. If I change it to until ] then it does work. Why numeric comparison is not working with -ne and works... (3 Replies)
Discussion started by: ab_2010
3 Replies

2. HP-UX

Sudo doesn't work

I edited sudoers like this:vi /etc/sudoers subex ALL =(root) NOPASSWD: /usr/ccs/bin/pstack But the respective user still is prompted for password, and even when the right password is used, the command is still not launched.$sudo usr/ccs/bin/pstack 26557 We trust you have received the usual... (5 Replies)
Discussion started by: black_fender
5 Replies

3. Shell Programming and Scripting

How come this if statement doesn't work?

greetings, the following code isn't working as i expect it to. the first dbl brackets do but the second set gets ignored. ie: if i'm on t70c6n229 it echoes "Something" and i expect it not to. what am i missing? if " ]] || " ]]; then echo "Something" fi thanx! (9 Replies)
Discussion started by: crimso
9 Replies

4. UNIX for Dummies Questions & Answers

Why doesn't this work?

find . -name "05_scripts" -type d -exec mv -f {}/'*.aep\ Logs' {}/.LogFiles \; Returns this failure: mv: rename ./019_0120_WS_WH_gate_insideTEST/05_scripts/*.aep\ Logs to ./019_0120_WS_WH_gate_insideTEST/05_scripts/.LogFiles/*.aep\ Logs: No such file or directory I don't know why it's trying... (4 Replies)
Discussion started by: scribling
4 Replies

5. Shell Programming and Scripting

Awk: Can anyone tell me why this doesn't work?

If there exists a field in stdin, print it, otherwise, print hello..... These print nothing: cat /dev/null | awk '{if ( length > 0 ) print $1; else print "hello"}' cat /dev/null | awk '{if ( $1 ) print $1; else print "hello"}'But the scripts work if I run them directly in a terminal: ... (8 Replies)
Discussion started by: ksheller
8 Replies

6. UNIX for Dummies Questions & Answers

my make doesn't work

hi I wrote the following makefile, I have just one problem, when i type make clean I get the message make 'clean' is up to date and any obj file is removed from my folder, what's wrong? Thank you CC = cc all: es.o elaboration.o $(CC) -o es es.o elaboration.o elaboration.o:... (0 Replies)
Discussion started by: Puntino
0 Replies

7. HP-UX

pstat_getdisk() call doesn’t work properly in HPUX 11.31 (11i V3)

As per the man page, pstat_getdisk() call returns the number of instances, which could be 0 upon successful completion, otherwise a value of -1 is returned. Please have a look at this sample program -> #include <stdio.h> #include <sys/pstat.h> int main() { int j = 0, ret; struct... (2 Replies)
Discussion started by: sandiworld
2 Replies

8. UNIX for Dummies Questions & Answers

Script doesn't work, but commands inside work

Howdie everyone... I have a shell script RemoveFiles.sh Inside this file, it only has two commands as below: rm -f ../../reportToday/temp/* rm -f ../../report/* My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
Discussion started by: cheongww
2 Replies

9. Shell Programming and Scripting

sed doesn't work

Hello I' m confused a bit. I want to replace string "&amp" with "&" using this command. sed 's/&amp/&/g' and it doesn't work. Nothing happens. On the other side this works: sed 's/&amp/@/g' or sed 's/&amp/^/g' !!! Can somebody help please? Thanks (3 Replies)
Discussion started by: billy5
3 Replies

10. Shell Programming and Scripting

Why doesn't this work?

cat .servers | while read LINE; do ssh jason@$LINE $1 done exit 1 ./command.ksh "ls -l ~jason" Why does this ONLY iterate on the first server in the list? It's not doing the command on all the servers in the list, what am I missing? Thanks! JP (2 Replies)
Discussion started by: jpeery
2 Replies
Login or Register to Ask a Question