home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / js / src / prmjtime.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.8 KB  |  114 lines

  1. /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef prmjtime_h___
  20. #define prmjtime_h___
  21. /*
  22.  * PR date stuff for mocha and java. Placed here temporarily not to break
  23.  * Navigator and localize changes to mocha.
  24.  */
  25. #include <time.h>
  26. #include "prlong.h"
  27. #ifdef MOZILLA_CLIENT
  28. #include "jscompat.h"
  29. #endif
  30.  
  31. PR_BEGIN_EXTERN_C
  32.  
  33. typedef struct PRMJTime       PRMJTime;
  34.  
  35. /*
  36.  * Broken down form of 64 bit time value.
  37.  */
  38. struct PRMJTime {
  39.     PRInt32 tm_usec;        /* microseconds of second (0-999999) */
  40.     PRInt8 tm_sec;        /* seconds of minute (0-59) */
  41.     PRInt8 tm_min;        /* minutes of hour (0-59) */
  42.     PRInt8 tm_hour;        /* hour of day (0-23) */
  43.     PRInt8 tm_mday;        /* day of month (1-31) */
  44.     PRInt8 tm_mon;        /* month of year (0-11) */
  45.     PRInt8 tm_wday;        /* 0=sunday, 1=monday, ... */
  46.     PRInt16 tm_year;        /* absolute year, AD */
  47.     PRInt16 tm_yday;        /* day of year (0 to 365) */
  48.     PRInt8 tm_isdst;        /* non-zero if DST in effect */
  49. };
  50.  
  51. /* Some handy constants */
  52. #define PRMJ_MSEC_PER_SEC        1000
  53. #define PRMJ_USEC_PER_SEC        1000000L
  54. #define PRMJ_NSEC_PER_SEC        1000000000L
  55. #define PRMJ_USEC_PER_MSEC    1000
  56. #define PRMJ_NSEC_PER_MSEC    1000000L
  57.  
  58. /* Return the current local time in micro-seconds */
  59. extern PR_IMPLEMENT(PRInt64) PRMJ_Now(void);
  60.  
  61. /* Return the current local time in micro-seconds */
  62. extern PR_IMPLEMENT(PRInt64) PRMJ_NowLocal(void);
  63.  
  64. /* Return the current local time, in milliseconds */
  65. extern PR_IMPLEMENT(PRInt64) PRMJ_NowMS(void);
  66.  
  67. /* Return the current local time in seconds */
  68. extern PR_IMPLEMENT(PRInt64) PRMJ_NowS(void);
  69.  
  70. /* Convert a local time value into a GMT time value */
  71. extern PR_IMPLEMENT(PRInt64) PRMJ_ToGMT(PRInt64 time);
  72.  
  73. /* Convert a GMT time value into a lcoal time value */
  74. extern PR_IMPLEMENT(PRInt64) PRMJ_ToLocal(PRInt64 time);
  75.  
  76. /* get the difference between this time zone and  gmt timezone in seconds */
  77. extern PR_IMPLEMENT(time_t) PRMJ_LocalGMTDifference(void);
  78.  
  79. /* Explode a 64 bit time value into its components */
  80. extern PR_IMPLEMENT(void) PRMJ_ExplodeTime(PRMJTime *to, PRInt64 time);
  81.  
  82. /* Compute the 64 bit time value from the components */
  83. extern PR_IMPLEMENT(PRInt64) PRMJ_ComputeTime(PRMJTime *tm);
  84.  
  85. /* Format a time value into a buffer. Same semantics as strftime() */
  86. extern PR_IMPLEMENT(size_t) PRMJ_FormatTime(char *buf, int buflen, char *fmt,
  87.                         PRMJTime *tm);
  88.  
  89. /*
  90.  * Format a time value into a buffer. Time is always in US English format,
  91.  * regardless of locale setting.
  92.  */
  93. extern PR_IMPLEMENT(size_t) PRMJ_FormatTimeUSEnglish(char* buf, size_t bufSize,
  94.                            const char* format,
  95.                            const PRMJTime* time);
  96.  
  97. /* Convert prtm structure into seconds since 1st January, 0 A.D. */
  98. extern PR_IMPLEMENT(PRInt64) PRMJ_mktime(PRMJTime *prtm);
  99.  
  100. /* Get the Local time into prtime from tsecs */
  101. extern PR_IMPLEMENT(void) PRMJ_localtime(PRInt64 tsecs,PRMJTime *prtm);
  102.  
  103. /* Get the gmt time into prtime from tsecs */
  104. extern PR_IMPLEMENT(void) PRMJ_gmtime(PRInt64 tsecs,PRMJTime *prtm);
  105.  
  106. /* Get the DST offset for the local time passed in
  107.  */
  108. extern PR_IMPLEMENT(PRInt64) PRMJ_DSTOffset(PRInt64 time);
  109.  
  110. PR_END_EXTERN_C
  111.  
  112. #endif /* prmjtime_h___ */
  113.  
  114.