From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13369 invoked by alias); 3 Jul 2015 20:55:17 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35681 Received: (qmail 19911 invoked from network); 3 Jul 2015 20:55:13 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1435956499; bh=H2Mu4GOf9AEK5l2a8umLt+g8ZVsKyGQmb3iiKX+YfvM=; h=From:To:Subject:Date:From:Subject; b=nRCipVrU3EgMwxfWSDHDV/+RmE9WxUvk/wV13FFPhKStspiPU0B5nLrLBpt/v7WB3s/H7SLSOv8gd3hnWWmbYpkt97Erjt/CH+Jxn8emGR2PMEh9oNDu4bsqVj2OK04f1FSwWWhHQPcUONbdcOJ1tKf9lucu7Bv3HX7NxhsD4KM+E3BOuOpemxQI8oTCIMrW8f55nYX1umTLoHjMr466VP+P/RZ8UTKwD46pFcfDpYGw5rZL7fq4lohq/It9rHRcG4e2chbfgSXGehtP783wX6VSaktWapKU/L08+ZaSitqaX/xYjAvrlwtvAtlTO9vGMj1zZ8jz+9hPiyaYj4A1Iw== X-Yahoo-Newman-Id: 655293.59283.bm@smtp126.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: EBFsUe4VM1mSmSQSUCv_1hGh5RChaw8wV0Loa9oCNuXSZeb zOLaFuVgIRvrhbg_UP97EUPo6TUS_D8cZrQv3gACViSmOPpMZd9zlUWzmp_w GsOiubNJcjbf3OKIuGKztaW.mDJZStZdr1MamAE3uobG8333U3Xm6556c6ID Q0NRkgEWepXxXrY3DCD_TRfyRPemLf_nHlbqINBSkDZ50Pa_OGJNdMB_0D4q 9OXZClz7oPr7ZfOgPYwfCAWAxabCzBYkjlnPm85V_wAxVIo84iTJudkrlkU8 gFSOI2wkkCjNhsnbeoNWOKkOJ_iISN8hB4_Z_xNmRA0LPCk7RE1pbSNXxpTY oI.FMQ.OfPWviTqcH5M0SJXSSig.JE5fRDp_b62r299qSDNHpL3Egu2aBC4q 9cVV12wuCuMq3fW5dLSe.hrfdCQkN27hSjT6JRgmsliP8EZiP9bCQ7a2B1yi tmtt0WMoyQDOSTpKvcXFD.hQFNmnCTj7SK85WVTcfDokrt4ZSnrY0.p_Xdti LkiO4sbU9_2oppG40mDfE.3NQiP8JAA-- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- From: Oliver Kiddle To: Zsh workers Subject: PATCH: initialise day of month in datetime module MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <9854.1435956498.1@thecus.kiddle.eu> Date: Fri, 03 Jul 2015 22:48:18 +0200 Message-ID: <9855.1435956498@thecus.kiddle.eu> Note the following: % strftime '%F %T' $(strftime -r '%Y%m' 201507) 2015-06-30 00:00:00 In a struct tm, tm_mday starts at 1 and not 0 so it is better to initialise it to 1 so the command above will instead return midnight on the 1st July. Oliver diff --git a/Src/Modules/datetime.c b/Src/Modules/datetime.c index 63a04dc..d941667 100644 --- a/Src/Modules/datetime.c +++ b/Src/Modules/datetime.c @@ -53,10 +53,12 @@ reverse_strftime(char *nam, char **argv, char *scalar, int quiet) * to use the current timezone. This is probably the best guess; * it's the one that will cause dates and times output by strftime * without the -r option and without an explicit timezone to be - * converted back correctly. + * converted back correctly. Additionally, tm_mday is set to 1 + * as that and not 0 corresponds to the first of the month. */ (void)memset(&tm, 0, sizeof(tm)); tm.tm_isdst = -1; + tm.tm_mday = 1; endp = strptime(argv[1], argv[0], &tm); if (!endp) {