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

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  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.  
  20. #include <string.h>
  21. #include <time.h>
  22.  
  23. #include "xp_core.h"
  24. #include "ntypes.h"
  25. #ifndef __XPLOCALE__
  26. #define __XPLOCALE__
  27.  
  28. XP_BEGIN_PROTOS
  29.  
  30.  
  31. /**@name Locale Sensitive Operations */
  32. /*@{*/
  33.  
  34. /**
  35.  * Collate strings according to global locale.
  36.  *
  37.  * Compares two strings in the global locale.
  38.  * Returns a number less than 0 if the second string is greater, 
  39.  * 0 if they are the same, and greater than 0 if the first string is 
  40.  * greater, according to the sorting rules appropriate for the current 
  41.  * locale.
  42.  * This routine currently does not handle multiple charsets.
  43.  * The locale is controlled by the platform through a control panel or 
  44.  * the LC_TIME environment variable.
  45.  *
  46.  * @param    s1 Specifies string 1, in the global locale's charset
  47.  * @param    s2 Specifies string 2, in the global locale's charset
  48.  * @return   0 if s1 is equal to s2,
  49.  *           less than 0 if s2 is greater,
  50.  *           greater than 0 if s1 is greater
  51.  */
  52. PUBLIC int XP_StrColl(
  53.     const char *s1, 
  54.     const char *s2
  55. );
  56.  
  57.  
  58. /**
  59.  * Constants for XP_StrfTime.
  60.  *
  61.  * <UL>
  62.  * <LI>
  63.  * XP_TIME_FORMAT - format the date/time into time format.
  64.  * <LI>
  65.  * XP_TIME_WEEKDAY_TIME_FORMAT - format the date/time into "weekday name plus
  66.  *                               time" format.
  67.  * <LI>
  68.  * XP_DATE_TIME_FORMAT - format the date/time into "date plus time" format.
  69.  * <LI>
  70.  * XP_LONG_DATE_TIME_FORMAT - format the date/time into "long date plus time"
  71.  *                            format.
  72.  * </UL>
  73.  */
  74. enum XP_TIME_FORMAT_TYPE {
  75.     XP_TIME_FORMAT = 0,
  76.     XP_WEEKDAY_TIME_FORMAT = 1,
  77.     XP_DATE_TIME_FORMAT = 2,
  78.     XP_LONG_DATE_TIME_FORMAT = 3
  79. };
  80.  
  81. /**
  82.  * Format date/time string.
  83.  * 
  84.  * This routine takes a context as argument and figures out what charset the 
  85.  * context is in. Then it formats the specified time into a string using
  86.  * the platform's date/time formatting support. The locale is controlled by
  87.  * the platform through a control panel or the LC_TIME environment variable.
  88.  *
  89.  * @param context Specifies the context to access charset information
  90.  * @param result Returns the formatted date/time string
  91.  * @param maxsize Specifies the size of the result buffer
  92.  * @param format Specifies the desired format
  93.  * @param timeptr Specifies the date/time
  94.  * @return the size of the formatted date/time string.
  95.  * @see INTL_ctime
  96.  */
  97. PUBLIC size_t XP_StrfTime(
  98.     MWContext *context, 
  99.     char *result, 
  100.     size_t maxsize, 
  101.     int format,
  102.     const struct tm *timeptr
  103. );
  104.  
  105. /**
  106.  * Locale sensitive version of ANSI C ctime().
  107.  *
  108.  * This routine converts the specified date/time into a string using the
  109.  * platform's date/time formatting support. The returned string is similar to
  110.  * that returned by the ctime function, except that the locale is respected.
  111.  * The locale is controlled by the platform through a control panel or the
  112.  * LC_TIME environment variable.
  113.  *
  114.  * @param context Specifies the context to access charset information
  115.  * @param date Specifies the date/time
  116.  * @return the formatted date/time string in ctime style.
  117.  * @see XP_StrfTime
  118.  */
  119. PUBLIC const char *INTL_ctime(
  120.     MWContext *context, 
  121.     time_t *date
  122. );
  123.  
  124. /**
  125.  * The Front End function that implements XP_StrColl.
  126.  *
  127.  * Don't call this API. Use XP_StrColl instead.
  128.  *
  129.  * @see XP_StrColl
  130.  */
  131. MODULE_PRIVATE extern int FE_StrColl(
  132.     const char *s1, 
  133.     const char *s2
  134. );
  135.  
  136. /**
  137.  * The Front End function that implements XP_StrfTime.
  138.  *
  139.  * Don't call this API. Use XP_StrfTime instead.
  140.  *
  141.  * @see XP_StrfTime
  142.  */
  143. MODULE_PRIVATE extern size_t FE_StrfTime(
  144.     MWContext *context,  
  145.     char *result, 
  146.     size_t maxsize, 
  147.     int format,
  148.     const struct tm *timeptr
  149. );
  150. /*@}*/
  151.  
  152.  
  153. XP_END_PROTOS
  154.  
  155. #endif
  156.