Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.1 KiB

  1. //***************************************************************************
  2. //
  3. // (c) 2000-2001 by Microsoft Corp. All Rights Reserved.
  4. //
  5. // datepart.h
  6. //
  7. // a-davcoo 28-Feb-00 Implements the SQL datepart operation.
  8. //
  9. //***************************************************************************
  10. #ifndef _DATEPART_H_
  11. #define _DATEPART_H_
  12. #include <strutils.h>
  13. #include <datetimeparser.h>
  14. #define DATEPART_YEAR 1 // "yy", "year"
  15. #define DATEPART_MONTH 3 // "mm", "month"
  16. #define DATEPART_DAY 5 // "dd", "day"
  17. #define DATEPART_HOUR 8 // "hh", "hour"
  18. #define DATEPART_MINUTE 9 // "mi", "minute"
  19. #define DATEPART_SECOND 10 // "ss", "second"
  20. #define DATEPART_MILLISECOND 11 // "ms", "millisecond"
  21. class CDMTFParser;
  22. // The CDatePart class implements the SQL "datepart" operation. To use
  23. // this class, construct an instance, supplying the date string you wish
  24. // to parse. Then use the GetPart() method to extract the specified part.
  25. // Contants for the "parts" are presented above. The class makes it's own
  26. // copy of the date string supplied during construction.
  27. class POLARITY CDatePart
  28. {
  29. public:
  30. CDatePart ();
  31. ~CDatePart ();
  32. HRESULT SetDate (LPCWSTR lpDate);
  33. HRESULT SetDate (LPCSTR lpDate);
  34. HRESULT GetPart (int datepart, int *value);
  35. protected:
  36. CDMTFParser *m_date;
  37. };
  38. class POLARITY CDMTFParser
  39. {
  40. public:
  41. enum {YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, MICROSECOND, OFFSET};
  42. CDMTFParser (LPCWSTR date);
  43. ~CDMTFParser (void);
  44. bool IsValid (void);
  45. bool IsInterval (void);
  46. bool IsUsed (int part);
  47. bool IsWildcard (int part);
  48. int GetValue (int part);
  49. protected:
  50. enum {INVALID=0x0, VALID=0x1, NOTSUPPLIED=0x2, NOTUSED=0x4};
  51. enum {NUMPARTS=8};
  52. bool m_valid;
  53. bool m_interval;
  54. int m_status[NUMPARTS];
  55. int m_part[NUMPARTS];
  56. void ParseDate (LPCWSTR date);
  57. void ParseInterval (LPCWSTR date);
  58. void ParseAbsolute (LPCWSTR date);
  59. int ParsePart (LPCWSTR date, int pos, int length, int *result, int min, int max);
  60. };
  61. #endif // _DATEPART_H_