[oleaut32 1/3] Implements function varformat:VarWeekdayName

Benjamin Arai me at benjaminarai.com
Mon Jul 24 20:46:44 CDT 2006


Implementation was tested using Windows XP and Wine.

Changelog:
 - Implements oleaut32 VarWeekdayName
 - 2/3 removes stub from oleaut32.spec
 - 3/3 Conformance test for VarWeekdayName
-------------- next part --------------

---
 dlls/oleaut32/varformat.c |   65 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/dlls/oleaut32/varformat.c b/dlls/oleaut32/varformat.c
index 77d1196..c52d3db 100644
--- a/dlls/oleaut32/varformat.c
+++ b/dlls/oleaut32/varformat.c
@@ -2,6 +2,7 @@
  * Variant formatting functions
  *
  * Copyright 2003 Jon Griffiths
+ * Copyright 2006 (Google) Benjamin Arai
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -2452,6 +2453,70 @@ HRESULT WINAPI VarFormatCurrency(LPVARIA
 }
 
 /**********************************************************************
+ *              VarWeekdayName [OLEAUT32.128]
+ *
+ * Print the specified month as localized name.
+ *
+ * PARAMS
+ *  iWeekday  [I] day number of week 0 = sys default, 1 = Monday, etc
+ *  fAbbrev   [I] 0 - full name, !0 - abbreviated name
+ *  iFirstDay [I] first day week, 0 = sys default, 1 = Monday, etc
+ *  dwFlags   [I] flag stuff. only VAR_CALENDAR_HIJRI possible.
+ *  pbstrOut  [O] Destination for weekday name
+ *
+ * RETURNS
+ *  Success: S_OK. pbstrOut contains the name.
+ *  Failure: E_INVALIDARG, if any parameter is invalid.
+ *           E_OUTOFMEMORY, if enough memory cannot be allocated.
+ *
+ */
+HRESULT WINAPI VarWeekdayName(INT iWeekday, INT fAbbrev, INT iFirstDay,
+                              ULONG dwFlags, BSTR *pbstrOut)
+{
+  DWORD localeValue;
+  INT size;
+  WCHAR *str;
+
+  if ((iWeekday < 1)  || (iWeekday > 7) ||
+      (iFirstDay < 0) || (iFirstDay > 7) ||
+      (pbstrOut == NULL))
+    return E_INVALIDARG;
+
+  if (dwFlags)
+    FIXME("Does not support dwFlags 0x%lx, ignoring.\n", dwFlags);
+
+  if (fAbbrev)
+    if (iFirstDay == 0)
+      localeValue = LOCALE_SABBREVDAYNAME1 + ((iWeekday + iFirstDay + 5) % 7);
+    else
+      localeValue = LOCALE_SABBREVDAYNAME1 + ((iWeekday + iFirstDay + 4) % 7);
+  else
+    if (iFirstDay == 0)
+      localeValue = LOCALE_SDAYNAME1 + ((iWeekday + iFirstDay + 5) % 7);
+    else
+      localeValue = LOCALE_SDAYNAME1 + ((iWeekday + iFirstDay + 4) % 7);
+
+  size = GetLocaleInfoW(LOCALE_USER_DEFAULT,localeValue, NULL, 0);
+  if (!size) {
+    FIXME("GetLocaleInfo 0x%lx failed.\n", localeValue);
+    return E_INVALIDARG;
+  }
+  str = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*size);
+  if (!str)
+    return E_OUTOFMEMORY;
+  size = GetLocaleInfoW(LOCALE_USER_DEFAULT,localeValue, str, size);
+  if (!size) {
+    FIXME("GetLocaleInfo of 0x%lx failed in 2nd stage?!\n", localeValue);
+    HeapFree(GetProcessHeap(),0,str);
+    return E_INVALIDARG;
+  }
+  *pbstrOut = SysAllocString(str);
+  HeapFree(GetProcessHeap(),0,str);
+  if (!*pbstrOut)
+    return E_OUTOFMEMORY;
+  return S_OK;
+}
+/**********************************************************************
  *              VarMonthName [OLEAUT32.129]
  *
  * Print the specified month as localized name.
-- 
1.4.0



More information about the wine-patches mailing list