更改电脑时间后,用GETJULIANDATE函数获取时间出错。

k163x 2009-12-14 03:32:20
我无意中把电脑系统的时间调小了几分钟,结果编写的brew程序时间不能正确显示了。
显示的时间为0:0(本来应该是xx(时):xx(分)的),如果我把电脑的时间调大一点,它又能正确显示了,不知道什么原因。
代码如下:
/*===========================================================================

FILE: showtime.c
===========================================================================*/


/*===============================================================================
INCLUDES AND VARIABLE DEFINITIONS
=============================================================================== */
#include "AEEModGen.h" // Module interface definitions
#include "AEEAppGen.h" // Applet interface definitions
#include "AEEShell.h" // Shell interface definitions
#include "AEEStdLib.h"


#include "showtime.bid"


/*-------------------------------------------------------------------
Applet structure. All variables in here are reference via "pMe->"
-------------------------------------------------------------------*/
typedef struct _showtime {
AEEApplet a ; // First element of this structure must be AEEApplet
AEEDeviceInfo DeviceInfo; // always have access to the hardware device information

// add your own variables here...
uint32 count;


} showtime;

/*-------------------------------------------------------------------
Function Prototypes
-------------------------------------------------------------------*/
static boolean showtime_HandleEvent(showtime* pMe, AEEEvent eCode,
uint16 wParam, uint32 dwParam);
boolean showtime_InitAppData(showtime* pMe);
void showtime_FreeAppData(showtime* pMe);

static void callBack1(showtime *pMe);

/*===============================================================================
FUNCTION DEFINITIONS
=============================================================================== */

/*===========================================================================
FUNCTION: AEEClsCreateInstance
===========================================================================*/


static void callBack1 (showtime *pMe)
{



AECHAR szText[6] = {0};
JulianType date;

GETJULIANDATE(0,&date);

WSPRINTF(szText,sizeof(szText),(AECHAR*)L"%d:%d",date.wHour,date.wMinute);



IDISPLAY_DrawText(pMe->a.m_pIDisplay,AEE_FONT_BOLD,szText,-1,0,0,NULL,IDF_ALIGN_CENTER|IDF_ALIGN_MIDDLE);
IDISPLAY_Update(pMe->a.m_pIDisplay);
}

int AEEClsCreateInstance(AEECLSID ClsId, IShell *pIShell, IModule *po, void **ppObj)
{
*ppObj = NULL;

if( ClsId == AEECLSID_SHOWTIME )
{
// Create the applet and make room for the applet structure
if( AEEApplet_New(sizeof(showtime),
ClsId,
pIShell,
po,
(IApplet**)ppObj,
(AEEHANDLER)showtime_HandleEvent,
(PFNFREEAPPDATA)showtime_FreeAppData) ) // the FreeAppData function is called after sending EVT_APP_STOP to the HandleEvent function

{
//Initialize applet data, this is called before sending EVT_APP_START
// to the HandleEvent function
if(showtime_InitAppData((showtime*)*ppObj))
{
//Data initialized successfully
return(AEE_SUCCESS);
}
else
{
//Release the applet. This will free the memory allocated for the applet when
// AEEApplet_New was called.
IAPPLET_Release((IApplet*)*ppObj);
return EFAILED;
}

} // end AEEApplet_New

}

return(EFAILED);
}


/*===========================================================================
FUNCTION SampleAppWizard_HandleEvent
===========================================================================*/
static boolean showtime_HandleEvent(showtime* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{


switch (eCode)
{
// App is told it is starting up
case EVT_APP_START:
ISHELL_SetTimer(pMe->a.m_pIShell,
3000,
(PFNNOTIFY)callBack1,
(void*)pMe);


return(TRUE);


// App is told it is exiting
case EVT_APP_STOP:
// Add your code here...

return(TRUE);


// App is being suspended
case EVT_APP_SUSPEND:
// Add your code here...

return(TRUE);


// App is being resumed
case EVT_APP_RESUME:
// Add your code here...

return(TRUE);


// An SMS message has arrived for this app. Message is in the dwParam above as (char *)
// sender simply uses this format "//BREW:ClassId:Message", example //BREW:0x00000001:Hello World
case EVT_APP_MESSAGE:
// Add your code here...

return(TRUE);

// A key was pressed. Look at the wParam above to see which key was pressed. The key
// codes are in AEEVCodes.h. Example "AVK_1" means that the "1" key was pressed.
case EVT_KEY:
// Add your code here...

return(TRUE);
// Flip event. Look at the wParam above to know flip state.
case EVT_FLIP:
// wParam = FALSE, when flip is closed.
if(wParam == FALSE)
{
// Add your code here...
}
else
{
// Add your code here...
}

return(TRUE);

// Key-guard event. Look at the wParam above to know key-guard state.
case EVT_KEYGUARD:

// wParam = TRUE, when key-guard is enabled.
if(wParam == TRUE)
{
// Add your code here...
}
else
{
// Add your code here...
}

return(TRUE);

// If nothing fits up to this point then we'll just break out
default:
break;
}

return FALSE;
}


// this function is called when your application is starting up
boolean showtime_InitAppData(showtime* pMe)
{
// Get the device information for this handset.
// Reference all the data by looking at the pMe->DeviceInfo structure
// Check the API reference guide for all the handy device info you can get
pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo);
ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&pMe->DeviceInfo);

// Insert your code here for initializing or allocating resources...

pMe->count = 0;

// if there have been no failures up to this point then return success
return TRUE;
}

// this function is called when your application is exiting
void showtime_FreeAppData(showtime* pMe)
{
// insert your code here for freeing any resources you have allocated...

// example to use for releasing each interface:
// if ( pMe->pIMenuCtl != NULL ) // check for NULL first
// {
// IMENUCTL_Release(pMe->pIMenuCtl) // release the interface
// pMe->pIMenuCtl = NULL; // set to NULL so no problems trying to free later
// }
//

}

...全文
1810 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
在真机上应该是没有问题的
k163x 2009-12-14
  • 打赏
  • 举报
回复
跪求达人解决,不然我只有重装系统这条路了。。
本书全面介绍了UNIX系统的程序设计界面—系统调用界面和标准C库提供的许多函数。 本书的前15章着重于理论知识的阐述,主要内容包括UNIX文件和目录、进程环境、进程控制、 进程间通信以及各种I/O。在此基础上,分别按章介绍了多个应用实例,包括如何创建数据库函数库, PostScript 打印机驱动程序,调制解调器拨号器及在伪终端上运行其他程序的程序等。 本书内容丰富权威, 概念清晰精辟,一直以来被誉为UNIX编程的“圣经”,对于所有UNIX程序员—无论是初学者还是专家级人士 —都是一本无价的参考书籍。 目 录 译者序 译者简介 前言 第1章 UNIX基础知识 1 1.1 引言 1 1.2 登录 1 1.2.1 登录名 1 1.2.2 shell 1 1.3 文件和目录 2 1.3.1 文件系统 2 1.3.2 文件名 2 1.3.3 路径名 2 1.3.4 工作目录 4 1.3.5 起始目录 4 1.4 输入和输出 5 1.4.1 文件描述符 5 1.4.2 标准输入、标准输出和标准 出错 5 1.4.3 不用缓存的I/O 5 1.4.4 标准I/O 6 1.5 程序和进程 7 1.5.1 程序 7 1.5.2 进程和进程ID 7 1.5.3 进程控制 7 1.6 ANSI C 9 1.6.1 函数原型 9 1.6.2 类属指针 9 1.6.3 原始系统数据类型 10 1.7 出错处理 10 1.8 用户标识 11 1.8.1 用户ID 11 1.8.2 组ID 12 1.8.3 添加组ID 12 1.9 信号 12 1.10 UNIX时间值 14 1.11 系统调用和库函数 14 1.12 小结 16 习题 16 第2章 UNIX标准化及实现 17 2.1 引言 17 2.2 UNIX标准化 17 2.2.1 ANSI C 17 2.2.2 IEEE POSIX 18 2.2.3 X/Open XPG3 19 2.2.4 FIPS 19 2.3 UNIX实现 19 2.3.1 SVR4 20 2.3.2 4.3+BSD 20 2.4 标准和实现的关系 21 2.5 限制 21 2.5.1 ANSI C限制 22 2.5.2 POSIX限制 22 2.5.3 XPG3限制 24 2.5.4 sysconf、pathconf 和fpathconf 函数 24 2.5.5 FIPS 151-1要求 28 2.5.6 限制总结 28 2.5.7 未确定的运行时间限制 29 2.6 功能测试宏 32 2.7 基本系统数据类型 32 2.8 标准之间的冲突 33 2.9 小结 34 习题 34 第3章 文件I/O 35 3.1 引言 35 3.2 文件描述符 35 3.3 open函数 35 3.4 creat函数 37 3.5 close函数 37 3.6 lseek函数 38 3.7 read函数 40 3.8 write函数 41 3.9 I/O的效率 41 3.10 文件共享 42 3.11 原子操作 45 3.11.1 添加至一个文件 45 3.11.2 创建一个文件 45 3.12 dup和dup2函数 46 3.13 fcntl函数 47 3.14 ioctl函数 50 3.15 /dev/fd 51 3.16 小结 52 习题 52 第4章 文件和目录 54 4.1 引言 54 4.2 stat, fstat和lstat函数 54 4.3 文件类型 55 4.4 设置-用户-ID和设置-组-ID 57 4.5 文件存取许可权 58 4.6 新文件和目录的所有权 60 4.7 access函数 60 4.8 umask函数 62 4.9 chmod和fchmod函数 63 4.10 粘住位 65 4.11 chown, fchown和 lchown函数 66 4.12 文件长度 67 4.13 文件截短 68 4.14 文件系统 69 4.15 link, unlink, remove和rename 函数 71 4.16 符号连接 73 4.17 symlink 和readlink函数 76 4.18 文件的时间 76 4.19 utime函数 78 4.20 mkdir和rmdir函数

7,638

社区成员

发帖
与我相关
我的任务
社区描述
本论坛以AI、WoS 、XR、IoT、Auto、生成式AI等核心板块组成,为开发者提供便捷及高效的学习和交流平台。 高通开发者专区主页:https://qualcomm.csdn.net/
人工智能物联网机器学习 技术论坛(原bbs) 北京·东城区
社区管理员
  • csdnsqst0050
  • chipseeker
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧