Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Slowly and surely the unix crept up on the Nintendo user ...


devel / comp.unix.programmer / Re: Looking for a MYSQL_TIME to struct tm conversion routine

SubjectAuthor
* Looking for a MYSQL_TIME to struct tm conversion routineLew Pitcher
+* Re: Looking for a MYSQL_TIME to struct tm conversion routineLawrence D'Oliveiro
|+* Totally pointless response (Was: Looking for a ...)Kenny McCormack
||`- Re: Totally pointless response (Was: Looking for a ...)Kaz Kylheku
|`* Re: Looking for a MYSQL_TIME to struct tm conversion routineMuttley
| +* This post has nothing to do with the OP and does not help the OP - please take iKenny McCormack
| |+- Re: Looking for a MYSQL_TIME to struct tm conversion routineMuttley
| |`- Re: This post has nothing to do with the OP and does not help theLew Pitcher
| `* Re: Looking for a MYSQL_TIME to struct tm conversion routineLew Pitcher
|  +* Re: Looking for a MYSQL_TIME to struct tm conversion routineMuttley
|  |+* Re: Looking for a MYSQL_TIME to struct tm conversion routineLew Pitcher
|  ||`- Re: Looking for a MYSQL_TIME to struct tm conversion routineLawrence D'Oliveiro
|  |`- Re: Looking for a MYSQL_TIME to struct tm conversion routinecandycanearter07
|  `* Re: Looking for a MYSQL_TIME to struct tm conversion routineLawrence D'Oliveiro
|   `- Re: Looking for a MYSQL_TIME to struct tm conversion routineScott Lurndal
`- Re: Looking for a MYSQL_TIME to struct tm conversion routineKees Nuyt

1
Looking for a MYSQL_TIME to struct tm conversion routine

<ut26ur$2bern$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11495&group=comp.unix.programmer#11495

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.programmer
Subject: Looking for a MYSQL_TIME to struct tm conversion routine
Date: Fri, 15 Mar 2024 19:18:51 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 86
Message-ID: <ut26ur$2bern$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 15 Mar 2024 19:18:51 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="bf9cc900155a9f125c2c234b6ef07519";
logging-data="2472823"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19vU7PAarcELIDJMC/BTAg03qby7fglYN0="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:5IN7AjM2RH3J4EpEbfw2dKbZ99s=
 by: Lew Pitcher - Fri, 15 Mar 2024 19:18 UTC

[reposted to comp.unix.programmer; mistakenly posted to comp.databases.mysql]

Hi, Guys

I'm converting some code that uses the Mysql/Mariadb C api from
text queries to prepared statements, and would like my public
interfaces to use struct tm (Unix "broken-down" time) instead of
MYSQL_TIME.

ISTM that in all the years of the Mysql C API, /someone/ probably
has tackled such an interface. So, instead of "re-inventing the
wheel", I thought that I'd ask around: can you direct me to
or provide the source code for a proper MYSQL_TIME to Unix struct tm
conversion routine?

FWIW, for testing purposes, I wrote my own naive conversion
functions: timeMtoU() (which converts MYSQL_TIME to struct tm),
and timeUtoM() (which converts struct tm to MYSQL_TIME)

I include the source code for these two functions, in case
someone can suggest improvements or bugfixes.

struct tm *timeMtoU(MYSQL_TIME *mtime, struct tm *utime)
{
/*
** Note:
** MYSQL_TIME year is always a positive value
** ranging from year 1000AD to year 9999AD, or
** year 0000 for special cases.
**
** MYSQL_TIME month ranges from 1 (January) to 12 (December),
** while struct tm tm_mon ranges from 0 (January) to 11 (December)
** Subtract 1 from month to get tm_mon
*/
memset(utime,0,sizeof *utime);

utime->tm_sec = mtime->second;
utime->tm_min = mtime->minute;
utime->tm_hour = mtime->hour;
utime->tm_mday = mtime->day;
utime->tm_mon = mtime->month - 1;
utime->tm_year = mtime->year - 1900;

utime->tm_isdst = -1; /* let time functions figure it out */

/*
** NB: we naively leave tm_wday and tm_yday set to 0.
** If the caller /requires/ a valid tm_wday and/or tm_yday
** it's going to have to manipulate the struct tm itself
*/

return utime;
}

MYSQL_TIME *timeUtoM(struct tm *utime, MYSQL_TIME *mtime)
{
/*
** NOTE:
** struct tm tm_year is number of years (+ve or -ve) from
** the year 1900. So, the year 1899 is tm_year = -1,
** and year 1901 is tm_year = 1.
**
** struct tm tm_mon ranges from 0 (January) to 11 (December)
** while MYSQL_TIME month ranges from 1 (January) to 12 (December)
** Add 1 to tm_mon to get month
*/
memset(mtime,0,sizeof *mtime);

mtime->year = 1900 + utime->tm_year; /* error before 1000AD */
mtime->month = utime->tm_mon + 1;
mtime->day = utime->tm_mday;
mtime->hour = utime->tm_hour;
mtime->minute = utime->tm_min;
mtime->second = utime->tm_sec;
mtime->neg = 0; /* never negative time */
mtime->second_part = 0;

return mtime;
}

Thanks in advance

--
Lew Pitcher
"In Skills We Trust"

Re: Looking for a MYSQL_TIME to struct tm conversion routine

<ut2e0k$2fd1e$8@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11496&group=comp.unix.programmer#11496

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.programmer
Subject: Re: Looking for a MYSQL_TIME to struct tm conversion routine
Date: Fri, 15 Mar 2024 21:19:16 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <ut2e0k$2fd1e$8@dont-email.me>
References: <ut26ur$2bern$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 15 Mar 2024 21:19:16 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="923cb71133c4c2bd336d691e5929520c";
logging-data="2602030"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+nhNalOPPBwdKPYLbYzRf6"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:IsJiDsA5X1z9T5a86tMykPdHQBY=
 by: Lawrence D'Oliv - Fri, 15 Mar 2024 21:19 UTC

On Fri, 15 Mar 2024 19:18:51 -0000 (UTC), Lew Pitcher wrote:

> I'm converting some code that uses the Mysql/Mariadb C api from text
> queries to prepared statements, and would like my public interfaces to
> use struct tm (Unix "broken-down" time) instead of MYSQL_TIME.

Never found much need for DBMS-specific date/time conversion routines.
Those sorts of things belong in the application logic, not in the
database.

Totally pointless response (Was: Looking for a ...)

<ut2fco$2i0fp$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11497&group=comp.unix.programmer#11497

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.programmer
Subject: Totally pointless response (Was: Looking for a ...)
Date: Fri, 15 Mar 2024 21:42:48 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <ut2fco$2i0fp$1@news.xmission.com>
References: <ut26ur$2bern$2@dont-email.me> <ut2e0k$2fd1e$8@dont-email.me>
Injection-Date: Fri, 15 Mar 2024 21:42:48 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2687481"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Fri, 15 Mar 2024 21:42 UTC

In article <ut2e0k$2fd1e$8@dont-email.me>,
Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>
>Never found much need for DBMS-specific date/time conversion routines.
>Those sorts of things belong in the application logic, not in the
>database.

What a totally pointless response.

--
If Jeb is Charlie Brown kicking a football-pulled-away, Mitt is a '50s
housewife with a black eye who insists to her friends the roast wasn't
dry.

Re: Totally pointless response (Was: Looking for a ...)

<20240315151656.56@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11498&group=comp.unix.programmer#11498

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.programmer
Subject: Re: Totally pointless response (Was: Looking for a ...)
Date: Fri, 15 Mar 2024 22:23:35 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <20240315151656.56@kylheku.com>
References: <ut26ur$2bern$2@dont-email.me> <ut2e0k$2fd1e$8@dont-email.me>
<ut2fco$2i0fp$1@news.xmission.com>
Injection-Date: Fri, 15 Mar 2024 22:23:35 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8c47a74d86a279d136db227d771d8013";
logging-data="2634566"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/RbE1eKFq7dpzTofqxoUVqiUptWA0XKw8="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:SNxBz0oQQBYKV1uOTuf2zH2Ga7g=
 by: Kaz Kylheku - Fri, 15 Mar 2024 22:23 UTC

On 2024-03-15, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> In article <ut2e0k$2fd1e$8@dont-email.me>,
> Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>
>>Never found much need for DBMS-specific date/time conversion routines.
>>Those sorts of things belong in the application logic, not in the
>>database.
>
> What a totally pointless response.

Luckily for me, the bot's operator seems to have put me in its killfile.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Looking for a MYSQL_TIME to struct tm conversion routine

<ut3rse$2ri7l$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11499&group=comp.unix.programmer#11499

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Mutt...@dastardlyhq.com
Newsgroups: comp.unix.programmer
Subject: Re: Looking for a MYSQL_TIME to struct tm conversion routine
Date: Sat, 16 Mar 2024 10:22:06 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <ut3rse$2ri7l$1@dont-email.me>
References: <ut26ur$2bern$2@dont-email.me> <ut2e0k$2fd1e$8@dont-email.me>
Injection-Date: Sat, 16 Mar 2024 10:22:06 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="848c210cca652bcca1aba4351b429794";
logging-data="3000565"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+LzIfgo4M81bDAhUXxXeSK"
Cancel-Lock: sha1:bGkjA1OH96Br4T38qJvPBfLX3uw=
 by: Mutt...@dastardlyhq.com - Sat, 16 Mar 2024 10:22 UTC

On Fri, 15 Mar 2024 21:19:16 -0000 (UTC)
Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>On Fri, 15 Mar 2024 19:18:51 -0000 (UTC), Lew Pitcher wrote:
>
>> I'm converting some code that uses the Mysql/Mariadb C api from text
>> queries to prepared statements, and would like my public interfaces to
>> use struct tm (Unix "broken-down" time) instead of MYSQL_TIME.
>
>Never found much need for DBMS-specific date/time conversion routines.
>Those sorts of things belong in the application logic, not in the
>database.

I assume you've not done my work with or on DBs. A lot of application logic
not to mention triggers are in the database itself in the form of PL/SQL, t-SQl
(or whatever procedural extension of SQL the DB supports) procedures/functions.
A lack of datetime functionality would be a show stopper in a lot of cases.

This post has nothing to do with the OP and does not help the OP - please take it elsewhere... (Was: Looking for a ...)

<ut3srq$2io0k$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11500&group=comp.unix.programmer#11500

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.programmer
Subject: This post has nothing to do with the OP and does not help the OP - please take it elsewhere... (Was: Looking for a ...)
Date: Sat, 16 Mar 2024 10:38:50 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <ut3srq$2io0k$1@news.xmission.com>
References: <ut26ur$2bern$2@dont-email.me> <ut2e0k$2fd1e$8@dont-email.me> <ut3rse$2ri7l$1@dont-email.me>
Injection-Date: Sat, 16 Mar 2024 10:38:50 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2711572"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sat, 16 Mar 2024 10:38 UTC

In article <ut3rse$2ri7l$1@dont-email.me>, <Muttley@dastardlyhq.com> wrote:
....
>I assume you've not done my work with or on DBs. A lot of application
>logic not to mention triggers are in the database itself in the form of
>PL/SQL, t-SQl (or whatever procedural extension of SQL the DB supports)
>procedures/functions. A lack of datetime functionality would be a show
>stopper in a lot of cases.

This is A) obvious and B) Off-topic.

Feel free to continue to discuss it - but please observe etiquette and
change the subject line accordingly (as I have done).

At this point, the likelihood that OP will ever get a meaningful/helpful
response is quickly approaching zero. Incidentally, I don't quite see what
OP's problem is - i.e., it looks like he's already come pretty close to a
solution already (by himself).

--
Atheism:
It's like being the only sober person in the car, and nobody will let you drive.

Re: Looking for a MYSQL_TIME to struct tm conversion routine

<ut3t9f$2rqs4$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11501&group=comp.unix.programmer#11501

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Mutt...@dastardlyhq.com
Newsgroups: comp.unix.programmer
Subject: Re: Looking for a MYSQL_TIME to struct tm conversion routine
Date: Sat, 16 Mar 2024 10:46:07 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <ut3t9f$2rqs4$1@dont-email.me>
References: <ut26ur$2bern$2@dont-email.me> <ut2e0k$2fd1e$8@dont-email.me> <ut3rse$2ri7l$1@dont-email.me> <ut3srq$2io0k$1@news.xmission.com>
Injection-Date: Sat, 16 Mar 2024 10:46:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="848c210cca652bcca1aba4351b429794";
logging-data="3009412"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19BZriu1vOLYu60koOp8HVU"
Cancel-Lock: sha1:fzPR12ksfjtS0S0JCs18Q93X/xo=
 by: Mutt...@dastardlyhq.com - Sat, 16 Mar 2024 10:46 UTC

On Sat, 16 Mar 2024 10:38:50 -0000 (UTC)
gazelle@shell.xmission.com (Kenny McCormack) wrote:
>In article <ut3rse$2ri7l$1@dont-email.me>, <Muttley@dastardlyhq.com> wrote:
>....
>>I assume you've not done my work with or on DBs. A lot of application
>>logic not to mention triggers are in the database itself in the form of
>>PL/SQL, t-SQl (or whatever procedural extension of SQL the DB supports)
>>procedures/functions. A lack of datetime functionality would be a show
>>stopper in a lot of cases.
>
>This is A) obvious and B) Off-topic.

Not obvious to the poster I replied to. As for off-topic , thats a matter of
opinion and its not as if this group gets hundreds of posts a day. This is
the first time anyone has posted since Feb 22nd.

>Feel free to continue to discuss it - but please observe etiquette and
>change the subject line accordingly (as I have done).

And I've changed it back. Most DB work is done on unix and the discussion
was programming so I'm not sure what your problem is. Are you having a bad day,
get out of bed the wrong side? And just for the record - this isn't your
personal newsgroup.

>At this point, the likelihood that OP will ever get a meaningful/helpful
>response is quickly approaching zero. Incidentally, I don't quite see what

I suspect the intersect of the small number of people who read this group
(and no doubt getting ever smaller due to attitudes like yours) and those
who've done mysql C API dev is somewhat limited to say the least.

Re: This post has nothing to do with the OP and does not help the OP - please take it elsewhere... (Was: Looking for a ...)

<ut4dvf$2uuhb$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11502&group=comp.unix.programmer#11502

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.programmer
Subject: Re: This post has nothing to do with the OP and does not help the
OP - please take it elsewhere... (Was: Looking for a ...)
Date: Sat, 16 Mar 2024 15:30:55 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 59
Message-ID: <ut4dvf$2uuhb$1@dont-email.me>
References: <ut26ur$2bern$2@dont-email.me> <ut2e0k$2fd1e$8@dont-email.me>
<ut3rse$2ri7l$1@dont-email.me> <ut3srq$2io0k$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 16 Mar 2024 15:30:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0d478cb3917a42150ec2e4931e843a34";
logging-data="3111467"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18IqyuCKORFKKIJSwcW+WO3auRcX3NylY0="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:FvCOLxm+k5eAxYLmC9C+l1wlI3M=
 by: Lew Pitcher - Sat, 16 Mar 2024 15:30 UTC

Hi, Kenny, et al.

On Sat, 16 Mar 2024 10:38:50 +0000, Kenny McCormack wrote:

> In article <ut3rse$2ri7l$1@dont-email.me>, <Muttley@dastardlyhq.com> wrote:
> ...
>>I assume you've not done my work with or on DBs. A lot of application
>>logic not to mention triggers are in the database itself in the form of
>>PL/SQL, t-SQl (or whatever procedural extension of SQL the DB supports)
>>procedures/functions. A lack of datetime functionality would be a show
>>stopper in a lot of cases.
>
> This is A) obvious and B) Off-topic.
>
> Feel free to continue to discuss it - but please observe etiquette and
> change the subject line accordingly (as I have done).

FWIW, there are some usenet posters that I do not follow. It appears that
this thread branched out from my original post when one of those people
posted an irrelevant reply. So be it.

> At this point, the likelihood that OP will ever get a meaningful/helpful
> response is quickly approaching zero. Incidentally, I don't quite see what
> OP's problem is - i.e., it looks like he's already come pretty close to a
> solution already (by himself).

I'm glad that you think that my solution is "pretty close". It covers my
current use-case fairly well, in that I can both query a table for a datetime
value and have my program logic properly evaluate and report the value, and
I can take input dates and times, evaluate them in logic, and properly insert
them into a table.

But, my "solution" doesn't cover date management corner cases[1] at all, and I
was hoping that there was a more general-purpose solution "out there"
somewhere :-) The good news is that I can continue to enhance and expand my
existing conversion logic, while the search continues.

[1] Necessary considerations that I /know/ the code doesn't cover:
a) MYSQL_TIME years extend from 1000AD TO 9999AD, but struct tm
years cover a greater range. I don't handle the cases where
my struct tm tm_year is out of range for MYSQL_TIME year.
Additionally, MYSQL_TIME reserves 0000-00-00 00:00:00 as a
special case, and I haven't decided how I should handle it.

b) MYSQL_TIME includes a flag that indicates "whether the time
is negative". What does that even mean? When MYSQL_TIME neg
is true, then what do the other values in MYSQL_TIME represent?

c) I completely ignore the requisite values for struct tm tm_wday
and struct tm tm_yday. Perhaps I shouldn't.

d) I fudge the value for struct tm tm_isdst.

e) I have no error handling or error reporting logic.

--
Lew Pitcher
"In Skills We Trust"

Re: Looking for a MYSQL_TIME to struct tm conversion routine

<ut4emd$2uuhb$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11503&group=comp.unix.programmer#11503

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.programmer
Subject: Re: Looking for a MYSQL_TIME to struct tm conversion routine
Date: Sat, 16 Mar 2024 15:43:10 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <ut4emd$2uuhb$2@dont-email.me>
References: <ut26ur$2bern$2@dont-email.me> <ut2e0k$2fd1e$8@dont-email.me>
<ut3rse$2ri7l$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 16 Mar 2024 15:43:10 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0d478cb3917a42150ec2e4931e843a34";
logging-data="3111467"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18xBcCKaf3LwinYz48X883gabxeDR4PG0A="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:ARQWknHheAY3crU6p52JzhARLDI=
 by: Lew Pitcher - Sat, 16 Mar 2024 15:43 UTC

On Sat, 16 Mar 2024 10:22:06 +0000, Muttley wrote:

> On Fri, 15 Mar 2024 21:19:16 -0000 (UTC)
> Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>On Fri, 15 Mar 2024 19:18:51 -0000 (UTC), Lew Pitcher wrote:
>>
>>> I'm converting some code that uses the Mysql/Mariadb C api from text
>>> queries to prepared statements, and would like my public interfaces to
>>> use struct tm (Unix "broken-down" time) instead of MYSQL_TIME.
>>
>>Never found much need for DBMS-specific date/time conversion routines.
>>Those sorts of things belong in the application logic, not in the
>>database.

And, that's where I'm trying to put them. /BUT/, the database /stores/
date/time values that the application logic must manipulate, and it is
/the interface/ between database and application that I'm concerned about.

> I assume you've not done my work with or on DBs. A lot of application logic
> not to mention triggers are in the database itself in the form of PL/SQL, t-SQl
> (or whatever procedural extension of SQL the DB supports) procedures/functions.
> A lack of datetime functionality would be a show stopper in a lot of cases.

In my case, I have date/time values that I accept from a commandline input
that I have to pass into a prepared statement query, /and/ other prepared statement
queries that return date/time values that my program logic then has to process
and report.

For my program, it is more convenient (and more conventional) if I express
date/time values as "broken-down time" in struct tm variables. However, the
MYSQL C prepared statement interface requires all DATE and TIME values be
expressed as MYSQL_TIME variables.

Rather than restrict my program logic to use MYSQL only, I prefer to use the
generic Unix functions, and isolate the MYSQL code in a separate module. The
interface to that module would accept struct tm date/time inputs and
return struct tm date/time outputs. Internally, it would transform struct tm
data to MYSQL_TIME for the "param" side of the queries, and MYSQL_TIME data to
struct tm for the "result" side of the queries.

My sample code, in the OP, serves (more or less) for the single query that
I am working on now. BUT, rather than reinvent the wheel, I was hoping to
locate a more general purpose set of functions that I can use on /all/ the
queries in my current project, and reuse for other projects, going forward.

--
Lew Pitcher
"In Skills We Trust"

Re: Looking for a MYSQL_TIME to struct tm conversion routine

<ut4g53$2vjhk$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11504&group=comp.unix.programmer#11504

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Mutt...@dastardlyhq.com
Newsgroups: comp.unix.programmer
Subject: Re: Looking for a MYSQL_TIME to struct tm conversion routine
Date: Sat, 16 Mar 2024 16:08:03 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <ut4g53$2vjhk$1@dont-email.me>
References: <ut26ur$2bern$2@dont-email.me> <ut2e0k$2fd1e$8@dont-email.me>
<ut3rse$2ri7l$1@dont-email.me>
<ut4emd$2uuhb$2@dont-email.me>
Injection-Date: Sat, 16 Mar 2024 16:08:03 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="848c210cca652bcca1aba4351b429794";
logging-data="3132980"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19qdlqzu4APLEs5Ez5QS91O"
Cancel-Lock: sha1:/xZGXK0SMPu//6cn7j4IYRKOfxU=
 by: Mutt...@dastardlyhq.com - Sat, 16 Mar 2024 16:08 UTC

On Sat, 16 Mar 2024 15:43:10 -0000 (UTC)
Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
>For my program, it is more convenient (and more conventional) if I express
>date/time values as "broken-down time" in struct tm variables. However, the
>MYSQL C prepared statement interface requires all DATE and TIME values be
>expressed as MYSQL_TIME variables.

All the databases I've worked on have had awkward (from a C/C++ API POV)
datetime structures. I imagine the reason is that their date range is way
broader than the unix one whether 32 or 64 bit so can't be stored as a simple
integer value.

Re: Looking for a MYSQL_TIME to struct tm conversion routine

<ut4hg1$2uuhb$3@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11505&group=comp.unix.programmer#11505

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.programmer
Subject: Re: Looking for a MYSQL_TIME to struct tm conversion routine
Date: Sat, 16 Mar 2024 16:30:57 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <ut4hg1$2uuhb$3@dont-email.me>
References: <ut26ur$2bern$2@dont-email.me> <ut2e0k$2fd1e$8@dont-email.me>
<ut3rse$2ri7l$1@dont-email.me> <ut4emd$2uuhb$2@dont-email.me>
<ut4g53$2vjhk$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 16 Mar 2024 16:30:57 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0d478cb3917a42150ec2e4931e843a34";
logging-data="3111467"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/9boMmjqooIFp5Qy9a0uwlkEHCRrT24xg="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:QYQMPnen5LLEJUZmvYilsEuyN/c=
 by: Lew Pitcher - Sat, 16 Mar 2024 16:30 UTC

On Sat, 16 Mar 2024 16:08:03 +0000, Muttley wrote:

> On Sat, 16 Mar 2024 15:43:10 -0000 (UTC)
> Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
>>For my program, it is more convenient (and more conventional) if I express
>>date/time values as "broken-down time" in struct tm variables. However, the
>>MYSQL C prepared statement interface requires all DATE and TIME values be
>>expressed as MYSQL_TIME variables.
>
> All the databases I've worked on have had awkward (from a C/C++ API POV)
> datetime structures. I imagine the reason is that their date range is way
> broader than the unix one whether 32 or 64 bit so can't be stored as a simple
> integer value.

Apparently, the MYSQL date range is alot /narrower/ than the Unix (64bit) time_t
timestamp and struct tm ones.

--
Lew Pitcher
"In Skills We Trust"

Re: Looking for a MYSQL_TIME to struct tm conversion routine

<ut4ijr$302ue$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11506&group=comp.unix.programmer#11506

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: candycan...@candycanearter07.nomail.afraid (candycanearter07)
Newsgroups: comp.unix.programmer
Subject: Re: Looking for a MYSQL_TIME to struct tm conversion routine
Date: Sat, 16 Mar 2024 16:50:03 -0000 (UTC)
Organization: the-candyden-of-code
Lines: 16
Message-ID: <ut4ijr$302ue$2@dont-email.me>
References: <ut26ur$2bern$2@dont-email.me> <ut2e0k$2fd1e$8@dont-email.me>
<ut3rse$2ri7l$1@dont-email.me> <ut4emd$2uuhb$2@dont-email.me>
<ut4g53$2vjhk$1@dont-email.me>
Injection-Date: Sat, 16 Mar 2024 16:50:03 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ca7053d0bcda3dc1734d13280277688d";
logging-data="3148750"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+D/pwsAMoaUiwH/zSyD8LvjkHtVMRFEtospfTxX+8P5Q=="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:+L4gmTOZl2Mqwud+SQ8gam5E1Ew=
 by: candycanearter07 - Sat, 16 Mar 2024 16:50 UTC

Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote at 16:08 this Saturday (GMT):
> On Sat, 16 Mar 2024 15:43:10 -0000 (UTC)
> Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
>>For my program, it is more convenient (and more conventional) if I express
>>date/time values as "broken-down time" in struct tm variables. However, the
>>MYSQL C prepared statement interface requires all DATE and TIME values be
>>expressed as MYSQL_TIME variables.
>
> All the databases I've worked on have had awkward (from a C/C++ API POV)
> datetime structures. I imagine the reason is that their date range is way
> broader than the unix one whether 32 or 64 bit so can't be stored as a simple
> integer value.

I thought the 64b time limit is sometime after the sun explodes though.
--
user <candycane> is generated from /dev/urandom

Re: Looking for a MYSQL_TIME to struct tm conversion routine

<ut547o$33m2r$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11507&group=comp.unix.programmer#11507

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.programmer
Subject: Re: Looking for a MYSQL_TIME to struct tm conversion routine
Date: Sat, 16 Mar 2024 21:50:48 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <ut547o$33m2r$2@dont-email.me>
References: <ut26ur$2bern$2@dont-email.me> <ut2e0k$2fd1e$8@dont-email.me>
<ut3rse$2ri7l$1@dont-email.me> <ut4emd$2uuhb$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 16 Mar 2024 21:50:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f7920a21ec63febd4cd65eac0ef9a9b4";
logging-data="3266651"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19gDxEstTqj+6bFmjZqwL3e"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:/qknBquMkMpzjUw0HS5pMxlwt7w=
 by: Lawrence D'Oliv - Sat, 16 Mar 2024 21:50 UTC

On Sat, 16 Mar 2024 15:43:10 -0000 (UTC), Lew Pitcher wrote:

> On Sat, 16 Mar 2024 10:22:06 +0000, Muttley wrote:
>
>> On Fri, 15 Mar 2024 21:19:16 -0000 (UTC)
>> Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>
>>>Never found much need for DBMS-specific date/time conversion routines.
>>>Those sorts of things belong in the application logic, not in the
>>>database.
>
> And, that's where I'm trying to put them. /BUT/, the database /stores/
> date/time values that the application logic must manipulate, and it is
> /the interface/ between database and application that I'm concerned
> about.

If you are trying to convert your database schema to get rid of date/time
types, I would recommend using a higher-level language than C for this
purpose. After all, it’s a one-off-type task, isn’t it? A language like
Python offers better data typing that would make the task easier.

Re: Looking for a MYSQL_TIME to struct tm conversion routine

<ut548i$33m2r$3@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11508&group=comp.unix.programmer#11508

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.programmer
Subject: Re: Looking for a MYSQL_TIME to struct tm conversion routine
Date: Sat, 16 Mar 2024 21:51:14 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 6
Message-ID: <ut548i$33m2r$3@dont-email.me>
References: <ut26ur$2bern$2@dont-email.me> <ut2e0k$2fd1e$8@dont-email.me>
<ut3rse$2ri7l$1@dont-email.me> <ut4emd$2uuhb$2@dont-email.me>
<ut4g53$2vjhk$1@dont-email.me> <ut4hg1$2uuhb$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 16 Mar 2024 21:51:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f7920a21ec63febd4cd65eac0ef9a9b4";
logging-data="3266651"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19LDWCoysShE4turoBoPjYe"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:5KGdMszOQ6GK1rALbWRtn1JaeqE=
 by: Lawrence D'Oliv - Sat, 16 Mar 2024 21:51 UTC

On Sat, 16 Mar 2024 16:30:57 -0000 (UTC), Lew Pitcher wrote:

> Apparently, the MYSQL date range is alot /narrower/ than the Unix
> (64bit) time_t timestamp and struct tm ones.

Another good reason for avoiding it?

Re: Looking for a MYSQL_TIME to struct tm conversion routine

<psEJN.709711$p%Mb.411343@fx15.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11509&group=comp.unix.programmer#11509

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx15.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Looking for a MYSQL_TIME to struct tm conversion routine
Newsgroups: comp.unix.programmer
References: <ut26ur$2bern$2@dont-email.me> <ut2e0k$2fd1e$8@dont-email.me> <ut3rse$2ri7l$1@dont-email.me> <ut4emd$2uuhb$2@dont-email.me> <ut547o$33m2r$2@dont-email.me>
Lines: 21
Message-ID: <psEJN.709711$p%Mb.411343@fx15.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sun, 17 Mar 2024 16:00:21 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sun, 17 Mar 2024 16:00:21 GMT
X-Received-Bytes: 1594
 by: Scott Lurndal - Sun, 17 Mar 2024 16:00 UTC

Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>On Sat, 16 Mar 2024 15:43:10 -0000 (UTC), Lew Pitcher wrote:
>
>> On Sat, 16 Mar 2024 10:22:06 +0000, Muttley wrote:
>>
>>> On Fri, 15 Mar 2024 21:19:16 -0000 (UTC)
>>> Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>>
>>>>Never found much need for DBMS-specific date/time conversion routines.
>>>>Those sorts of things belong in the application logic, not in the
>>>>database.
>>
>> And, that's where I'm trying to put them. /BUT/, the database /stores/
>> date/time values that the application logic must manipulate, and it is
>> /the interface/ between database and application that I'm concerned
>> about.
>
>If you are trying to convert your database schema to get rid of date/time
>types, I would recommend using a higher-level language than C for this

Another non-responsive and useless answer.

Re: Looking for a MYSQL_TIME to struct tm conversion routine

<ceieviprl7pfcgmnj2fadj2dg39upa8k0h@dim53.demon.nl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11510&group=comp.unix.programmer#11510

  copy link   Newsgroups: comp.unix.programmer
From: k.n...@nospam.demon.nl (Kees Nuyt)
Newsgroups: comp.unix.programmer
Subject: Re: Looking for a MYSQL_TIME to struct tm conversion routine
Date: Sun, 17 Mar 2024 20:58:10 +0100
Reply-To: k.nuyt@nospam.demon.nl
Message-ID: <ceieviprl7pfcgmnj2fadj2dg39upa8k0h@dim53.demon.nl>
References: <ut26ur$2bern$2@dont-email.me>
User-Agent: ForteAgent/7.10.32.1214
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feed.abavia.com!abe005.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 27
Injection-Date: Sun, 17 Mar 2024 20:58:11 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: Kees Nuyt - Sun, 17 Mar 2024 19:58 UTC

On Fri, 15 Mar 2024 19:18:51 -0000 (UTC), Lew Pitcher
<lew.pitcher@digitalfreehold.ca> wrote:

> Hi, Guys
>
> I'm converting some code that uses the Mysql/Mariadb C api from
> text queries to prepared statements, and would like my public
> interfaces to use struct tm (Unix "broken-down" time) instead of
> MYSQL_TIME.

[....]

It might be worth to have a look at the source code for the
SQLite date/time functions, it's open source, public domain
even.

https://www.sqlite.org/lang_datefunc.html
https://www.sqlite.org/src/file?name=src/date.c&ci=trunk

I have no idea if the internal structures fit your use case in
any way.
--
Regards,
Kees Nuyt

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor