コード例 #1
0
ファイル: cdate.c プロジェクト: mbrock/bigloo-llvm
/*---------------------------------------------------------------------*/
BGL_RUNTIME_DEF obj_t
bgl_seconds_to_date( long sec ) {
   obj_t res;

   bgl_mutex_lock( date_mutex );
   res = tm_to_date( localtime( (time_t *)&sec ) );
   bgl_mutex_unlock( date_mutex );
   
   return res;
}
コード例 #2
0
ファイル: sophon_date.c プロジェクト: sharpglasses/SophonJS
static Sophon_Result
time_to_local_date (Sophon_VM *vm, Sophon_Time *time, Sophon_Date *date)
{
	struct tm *d;
	time_t t;

	t = sophon_floor(*time / 1000);

	if (!(d = localtime(&t)))
		return SOPHON_ERR_ARG;

	return tm_to_date(date, time, d);
}
コード例 #3
0
ファイル: time.c プロジェクト: Potpourri/ponyc
void os_gmtime(date_t* date, int64_t sec, int64_t nsec)
{
  int64_t overflow_sec = nsec / 1000000000;
  nsec -= (overflow_sec * 1000000000);

  if(nsec < 0)
  {
    nsec += 1000000000;
    overflow_sec--;
  }

  time_t t = sec + overflow_sec;

  struct tm tm;

#ifdef PLATFORM_IS_WINDOWS
  gmtime_s(&tm, &t);
#else
  gmtime_r(&t, &tm);
#endif

  tm_to_date(&tm, nsec, date);
}
コード例 #4
0
ファイル: time.c プロジェクト: Perelandric/ponyc
PONY_API void ponyint_gmtime(date_t* date, int64_t sec, int64_t nsec)
{
  time_t overflow_sec = (time_t)(nsec / 1000000000);
  nsec -= (overflow_sec * 1000000000);

  if(nsec < 0)
  {
    nsec += 1000000000;
    overflow_sec--;
  }

  time_t t = (time_t)sec + overflow_sec;

  struct tm tm;

#ifdef PLATFORM_IS_WINDOWS
  gmtime_s(&tm, &t);
#else
  gmtime_r(&t, &tm);
#endif

  tm_to_date(&tm, (int)nsec, date);
}