VGLD#84825 SLNKXLSX 1.02 betere datums voor 1970

svn path=/Slnkxlsx/trunk/; revision=66421
This commit is contained in:
Jos Groot Lipman
2024-10-02 13:28:49 +00:00
parent 45b0878412
commit 4ef4597279
3 changed files with 34 additions and 21 deletions

View File

@@ -3,6 +3,9 @@
#include "stdafx.h" #include "stdafx.h"
#include "SLNKWorksheet.h" #include "SLNKWorksheet.h"
#include "SLNKWorkbook.h" #include "SLNKWorkbook.h"
#include<ATLComTime.h>
// CWorksheet // CWorksheet
STDMETHODIMP CWorksheet::InterfaceSupportsErrorInfo(REFIID riid) STDMETHODIMP CWorksheet::InterfaceSupportsErrorInfo(REFIID riid)
@@ -122,29 +125,39 @@ STDMETHODIMP CWorksheet::write_unixtime(ULONG row, USHORT col, LONG64 unixtime,
return S_OK; return S_OK;
} }
unsigned int unix_stamp_of_DATE(DATE date)
{
//convert DATE to SYSTEMTIME
SYSTEMTIME st;
VariantTimeToSystemTime(date, &st);
//convert SYSTEMTIME to FILETIME
FILETIME ft;
SystemTimeToFileTime(&st, &ft);
//convert FILETIME to ULARGE_INTEGER
//then QuadPart is 64bit timestamp
ULARGE_INTEGER ul{ ft.dwLowDateTime, ft.dwHighDateTime };
return (unsigned int)((ul.QuadPart - 116444736000000000ULL) / 10000000);
}
// In JavaScript gebruik je new Date().getVarDate(); // In JavaScript gebruik je new Date().getVarDate();
STDMETHODIMP CWorksheet::write_vardate(ULONG row, USHORT col, DATE date, ULONG format) STDMETHODIMP CWorksheet::write_vardate(ULONG row, USHORT col, DATE date, ULONG format)
{ {
if (!m_worksheet) if (!m_worksheet)
return invalid(); return invalid();
write_unixtime(row, col, unix_stamp_of_DATE(date), format); COleDateTime odt(date);
lxw_datetime ldt = { odt.GetYear(), odt.GetMonth(), odt.GetDay() , odt.GetHour(), odt.GetMinute(), (double) odt.GetSecond()};
lxw_format* fmt = NULL;
switch (format)
{
case 0:
fmt = my_workbook->m_format_date;
ldt.hour = 0;
ldt.min = 0;
ldt.sec = 0.0;
worksheet_set_column(m_worksheet, col, col, 10.0, NULL);
break;
case 1:
fmt = my_workbook->m_format_datetime;
worksheet_set_column(m_worksheet, col, col, 15.0, NULL);
break;
case 2:
ldt.year = 0;
ldt.month = 0;
ldt.day = 0;
fmt = my_workbook->m_format_time;
worksheet_set_column(m_worksheet, col, col, 5.0, NULL);
break;
}
::worksheet_write_datetime(m_worksheet, row, col, &ldt, fmt);
return S_OK; return S_OK;
} }

View File

@@ -12,20 +12,20 @@
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{A3B53DEB-39D4-4C35-A066-A48073FE92D9}</ProjectGuid> <ProjectGuid>{A3B53DEB-39D4-4C35-A066-A48073FE92D9}</ProjectGuid>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<Keyword>AtlProj</Keyword> <Keyword>AtlProj</Keyword>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

View File

@@ -1,6 +1,6 @@
// Zorg dat versies alfabetisch altijd op elkaar volgen! // Zorg dat versies alfabetisch altijd op elkaar volgen!
#define SLNK_MAJOR_VERSION 1 #define SLNK_MAJOR_VERSION 1
#define SLNK_MINOR_VERSION 01 #define SLNK_MINOR_VERSION 02
#define SLNK_BUILD_VERSION 0 #define SLNK_BUILD_VERSION 0
// Define resource strings // Define resource strings