-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
date: illegal option -- j (Mac OS X 10.4.11) #497
Comments
Hi @etanol85 It's a benign error as that piece of code just checks whether the certificate needs renewing, when it fails the code just renews the certificate. I've spent some time researching this and the |
You may be interested in this ... I use this awk program to mess with date ranges in my certificate script rather than trying to get This gives "TODAY" #!/bin/sh -
jdayjdat() {
awk '#!/usr/bin/awk -f
BEGIN{
days[0] = "Sunday";
days[1] = "Monday";
days[2] = "Tuesday";
days[3] = "Wednesday";
days[4] = "Thursday";
days[5] = "Friday";
days[6] = "Saturday";
months["jan"] = 1;
months["feb"] = 2;
months["mar"] = 3;
months["apr"] = 4;
months["may"] = 5;
months["jun"] = 6;
months["jul"] = 7;
months["aug"] = 8;
months["sep"] = 9;
months["oct"] = 10;
months["nov"] = 11;
months["dec"] = 12;
if(ARGC == 2) {
j = ARGV[1]+0;
if (j>0 && j<65536) j += 2400000
split(jdate(j),A);
print A[1];
} else if(ARGC >= 4) {
d = ARGV[1]; m = ARGV[2]; y = ARGV[3];
if (d+0 > 999 && y < 100) { ms = d; d = y; y = ms; }
ms = tolower(substr(m, 1, 3));
if (ms in months) m = months[ms];
else {
ms = tolower(substr(d, 1, 3));
if (ms in months) {
d = m;
m = months[ms];
}
}
if( y>31 && y<70 ) y+=2000;
if( y>31 && y<100) y+=1900;
if( m<1) {m+=12; y--;}
if( m>12) {m-=12; y++;}
jd = jday(d,m,y);
if (ARGC > 4) {
printf("Input: %04d-%02d-%02d\n", y, m, d);
print jd
js = jdate(jd);
split(js,A,/[- ]/);
print js;
print A[1], A[2], A[3], days[A[4]];
} else
print jd
} else
print "Incorrect arguments"
}
function jdate(j, y,m,d,dow)
{
# Julian date converter. Takes a julian date (the number of days since
# some distant epoch or other) and returns the broken out date.
# d = day of month;
# m = month;
# y = year (actual year, like 1977, not 77 unless it was 77 a.d.);
# dow = day of week (0->Sunday to 6->Saturday)
# These are Gregorian.
# Copied from Algorithm 199 in Collected algorithms of the CACM
# Author: Robert G. Tantzen, Translators: Nat Howard, Robert de Bath
j = j + 1
dow = (j + 1)%7;
j -= 1721119;
# This should be a Euclidean division. But dates before 0001-01-01 dont
# make much sense anyway. Or even Friday, 15 October 1582 when the
# Gregorian calendar started.
y = int((4 * j - 1)/146097);
j = 4 * j - 1 - 146097 * y;
d = int(j/4);
j = int((4 * d + 3)/1461);
d = 4 * d + 3 - 1461 * j;
d = int((d + 4)/4);
m = int((5 * d - 3)/153);
d = 5 * d - 3 - 153 * m;
d = int((d + 5) / 5);
y = 100 * y + j;
if(m < 10) m += 3; else { m -= 9; ++y; }
return sprintf("%04d-%02d-%02d %d", y, m, d, dow);
}
function jday(d,m,y, c,ya,j)
{
# Takes a date, and returns a Julian day. A Julian day is the number of
# days since some base date (in the very distant past).
# Handy for getting date of x number of days after a given Julian date
# (use jdate to get that from the Gregorian date).
# Author: Robert G. Tantzen, translators: Nat Howard, Robert de Bath
# Translated from the algol original in Collected Algorithms of CACM
# (This and jdate are algorithm 199).
if(m>2) m -=3; else { m +=9; --y; }
c = int(y/100);
ya = y - (100*c);
j = int(146097*c/4) + int(1461*ya/4) + int((153*m+2)/5) + d + 1721119;
return j - 1;
}
' "$@"
}
jdayjdat "$@" |
Thank you timkimber and rdebath! I just tried rdebath jdayjdat awk script, but it seems not to display the date correctly. When I ran jdayjdat $(date ’+%d %m %Y’) it prints 2459026 and today it is 26-06-2020, date gives: Fri Jun 26 09:02:29 CEST 2020 Am I missing something? |
Hi @etanol85 I found out recently that github actions support MacOS so I'll write a test for this scenario and post an update. |
When running getssl mydomain.com under MAC OS 10.4.11
I see the folowing error:
usage: date [-nu] [-r seconds] [+format]
date [[[[[cc]yy]mm]dd]hh]mm[.ss]
The script seems to continue despite this error but I don’t know if it works correctly.
man date gives:
DATE(1) BSD General Commands Manual DATE(1)
NAME
date -- display or set date and time
SYNOPSIS
date [-nu] [-r seconds] [+format]
date [-u] mmddhhmm[[cc]yy]
DESCRIPTION
date displays the current date and time when invoked without arguments.
Providing arguments will format the date and time in a user-defined way
or set the date. Only the superuser may set the date.
ENVIRONMENT VARIABLES
The following environment variables affect the execution of date :
FILES
/var/log/wtmp A record of date resets and time changes.
/var/log/messages A record of the user setting the time.
EXAMPLES
The command:
DIAGNOSTICS
The following exit values are returned:
0 The date was written successfully (either locally or globally)
DIAGNOSTICS
The following exit values are returned:
0 The date was written successfully (either locally or globally)
>0 An error occurred.
LEGACY SYNOPSIS
date [-nu] [-r seconds] [+format]
LEGACY DIAGNOSTICS
When invoked in legacy mode the following exit values are returned:
0 The date was written successfully
1 Unable to set the date
2 Able to set the local date, but unable to set it globally
SEE ALSO
gettimeofday(2), strftime(3), compat(5), utmp(5), timed(8)
STANDARDS
The date utility supports the Version 3 of the Single UNIX Specification
(
SUSv3''). It is also expected to be compatible with IEEE Std 1003.2 (
POSIX.2'').BSD September 22, 2004 BSD
(END)
The text was updated successfully, but these errors were encountered: