Skip to content

Commit 883f3c5

Browse files
authored
Merge branch 'master' into ElastoGapUnit
2 parents 5c055d3 + 349a1fb commit 883f3c5

File tree

3 files changed

+44
-27
lines changed

3 files changed

+44
-27
lines changed

.mailmap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Hans Olsson <[email protected]>
4343
Hans Olsson <HansOlsson@7ce873d0-865f-4ce7-a662-4bb36ea78beb>
4444
Hans Olsson <[email protected]>
4545
Hans Olsson <hansolsson@7ce873d0-865f-4ce7-a662-4bb36ea78beb>
46+
Harisankar-Allimangalath <[email protected]>
4647
Henrik Tidefelt <[email protected]>
4748
Hubertus Tummescheit <Hubertus@7ce873d0-865f-4ce7-a662-4bb36ea78beb>
4849
Hubertus Tummescheit <[email protected]>
@@ -100,6 +101,7 @@ Peter Harman <[email protected]>
100101
Peter Harman <pharman@7ce873d0-865f-4ce7-a662-4bb36ea78beb>
101102
Philip Jordan <pjordan@7ce873d0-865f-4ce7-a662-4bb36ea78beb>
102103
Quentin Lambert <[email protected]>
104+
Rüdiger Franke <[email protected]>
103105
Rüdiger Franke <[email protected]>
104106
Rüdiger Franke <rfranke@7ce873d0-865f-4ce7-a662-4bb36ea78beb>
105107
Stefan Vorkoetter <[email protected]>

Modelica/ComplexBlocks/Sources/ComplexRampPhasor.mo

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ equation
1616
magnitude = if not useLogRamp then
1717
magnitude1 + (if time < startTime then
1818
0 else
19-
if time < (startTime + max(duration,eps)) then
20-
(time - startTime)*(magnitude2-magnitude1)/max(duration,eps)
19+
if time < (startTime + duration) then
20+
(time - startTime)*(magnitude2-magnitude1)/duration
2121
else
2222
magnitude2-magnitude1)
2323
else
2424
if time < startTime then magnitude1 else
25-
if time < (startTime + max(duration,eps)) then
26-
10^(log10(magnitude1) + (log10(magnitude2) - log10(magnitude1))*min(1, (time-startTime)/max(duration,eps)))
25+
if time < (startTime + duration) then
26+
10^(log10(magnitude1) + (log10(magnitude2) - log10(magnitude1))*min(1, (time-startTime)/duration))
2727
else
2828
magnitude2;
2929

Modelica/Resources/C-Sources/ModelicaInternal.c

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* ModelicaInternal.c - External functions for Modelica.Utilities
22
3-
Copyright (C) 2002-2020, Modelica Association and contributors
3+
Copyright (C) 2002-2023, Modelica Association and contributors
44
All rights reserved.
55
66
Redistribution and use in source and binary forms, with or without
@@ -38,6 +38,10 @@
3838
Added getcwd fallback in ModelicaInternal_fullPathName if
3939
realpath fails for non-existing path (ticket #3660)
4040
41+
Dec. 02, 2019: by Thomas Beutlich
42+
Removed call of localtime in ModelicaInternal_getTime
43+
(ticket #3246)
44+
4145
Nov. 13, 2019: by Thomas Beutlich
4246
Utilized blockwise I/O in ModelicaInternal_copyFile
4347
(ticket #3229)
@@ -1332,40 +1336,51 @@ void ModelicaInternal_getTime(_Out_ int* ms, _Out_ int* sec, _Out_ int* min, _Ou
13321336
*year = 0;
13331337
#else
13341338
struct tm* tlocal;
1335-
time_t calendarTime;
13361339
int ms0;
13371340
#if defined(_POSIX_) || (defined(_MSC_VER) && _MSC_VER >= 1400)
13381341
struct tm tres;
13391342
#endif
13401343

1341-
time(&calendarTime); /* Retrieve sec time */
1342-
#if defined(_POSIX_)
1343-
tlocal = localtime_r(&calendarTime, &tres); /* Time fields in local time zone */
1344-
#elif defined(_MSC_VER) && _MSC_VER >= 1400
1345-
localtime_s(&tres, &calendarTime); /* Time fields in local time zone */
1346-
tlocal = &tres;
1347-
#else
1348-
tlocal = localtime(&calendarTime); /* Time fields in local time zone */
1349-
#endif
1350-
1351-
/* Get millisecond resolution depending on platform */
13521344
#if defined(_WIN32)
1353-
{
13541345
#if defined(__BORLANDC__)
1355-
struct timeb timebuffer;
1346+
struct timeb timebuffer;
13561347
ftime( &timebuffer ); /* Retrieve ms time */
13571348
#else
1358-
struct _timeb timebuffer;
1349+
struct _timeb timebuffer;
13591350
_ftime( &timebuffer ); /* Retrieve ms time */
13601351
#endif
1361-
ms0 = (int)(timebuffer.millitm); /* Convert unsigned int to int */
1362-
}
1352+
#if defined(__BORLANDC__)
1353+
ftime(&timebuffer);
1354+
timebuffer.time -= 60 * timebuffer.timezone;
1355+
if (timebuffer.dstflag != 0)
1356+
timebuffer.time += 3600;
1357+
tlocal = gmtime(&timebuffer.time);
1358+
#elif defined(_MSC_VER) && _MSC_VER >= 1400
1359+
_ftime_s(&timebuffer);
1360+
timebuffer.time -= 60 * timebuffer.timezone;
1361+
if (timebuffer.dstflag != 0) {
1362+
int hours = 0;
1363+
_get_daylight(&hours);
1364+
timebuffer.time += 3600 * hours;
1365+
}
1366+
gmtime_s(&tres, &timebuffer.time);
1367+
tlocal = &tres;
13631368
#else
1364-
{
1365-
struct timeval tv;
1366-
gettimeofday(&tv, NULL);
1367-
ms0 = (int)(tv.tv_usec/1000); /* Convert microseconds to milliseconds */
1368-
}
1369+
_ftime(&timebuffer);
1370+
timebuffer.time -= 60 * timebuffer.timezone;
1371+
if (timebuffer.dstflag != 0)
1372+
timebuffer.time += 3600;
1373+
tlocal = gmtime(&timebuffer.time);
1374+
#endif
1375+
ms0 = (int)(timebuffer.millitm); /* Convert unsigned int to int */
1376+
#else
1377+
struct timeval tv;
1378+
struct timezone tz;
1379+
gettimeofday(&tv, &tz);
1380+
tv.tv_sec -= 60 * tz.tz_minuteswest;
1381+
gmtime_r(&tv.tv_sec, &tres);
1382+
tlocal = &tres;
1383+
ms0 = (int)(tv.tv_usec / 1000); /* Convert microseconds to milliseconds */
13691384
#endif
13701385

13711386
/* Do not memcpy as you do not know which sizes are in the struct */

0 commit comments

Comments
 (0)