[gradsusr] Date Issue for the DAY 2021

Jean Pierre Arabonis arabonis at yahoo.com
Sat Jan 2 04:06:52 EST 2021


Hi there 

    The following function works for me, I call it every time I need it from the main script, ie 

'set t 'whateverdow()say _nday
    The alternative is to use the linux date function to return dow from date but that is a messy solution.
    Cheers        JP 




***************************************************
function dow(args)

 'q Time'
 say result
 mm = substr(result,13,3)
 dy = substr(result,11,2)
 yr = substr(result,16,4)

if mm = JAN ; mn = 01 ; endif
if mm = FEB ; mn = 02 ; endif
if mm = MAR ; mn = 03 ; endif
if mm = APR ; mn = 04 ; endif
if mm = MAY ; mn = 05 ; endif
if mm = JUN ; mn = 06 ; endif
if mm = JUL ; mn = 07 ; endif
if mm = AUG ; mn = 08 ; endif
if mm = SEP ; mn = 09 ; endif
if mm = OCT ; mn = 10 ; endif
if mm = NOV ; mn = 11 ; endif
if mm = DEC ; mn = 12 ; endif

D.0=Sat
D.1=Sun
D.2=Mon
D.3=Tue
D.4=Wed
D.5=Thu
D.6=Fri

if (mn < 3)
  mn = mn + 12
  yr = yr - 1
endif
dofweek = math_mod(dy + math_int((13*(mn+1))/5) + yr + math_int(yr/4) - math_int(yr/100) + math_int(yr/400),7)
nday = D.dofweek
_nday = nday








-- Jean Pierre Arabonis arabonis at yahoo.com

    On Wednesday, 30 December 2020, 11:24:59 SAST, CW Weather <weatherstu at chorleyweather.com> wrote:  
 
 
Hi William, 




I've tried your solution plus the code below but im getting an issue somewhere. Im running the script in batch mode and it will use the control file for the dates but id fail to see that being the issue. It could be the sum code throwing the error but i dont even get an error code up, it just runs one image and cuts off, much like it would for a missing apostrophe. Headache of all headaches this one he he. 

day=substr(fdate,4,2)
mon=substr(fdate,6,3)
yy=substr(fdate,9,4)
year=yy-2000
j=year/100

if (mon = 'DEC') ; mm = 12 ; endif

if (mon = 'JAN')
mm = 13
year=yy-2000-1
j=year/100
endif

if (mon = 'FEB')
mm = 14
year=yy-2000-1
j=year/100
endif

if (mon = 'MAR') ; mm = 3 ; endif
if (mon = 'APR') ; mm = 4 ; endif
if (mon = 'MAY') ; mm = 5 ; endif
if (mon = 'JUN') ; mm = 6 ; endif
if (mon = 'JUL') ; mm = 7 ; endif
if (mon = 'AUG') ; mm = 8 ; endif
if (mon = 'SEP') ; mm = 9 ; endif
if (mon = 'OCT') ; mm = 10 ; endif
if (mon = 'NOV') ; mm = 11 ; endif

h = day + (13*(mm+1))/5 + year + year/4 + j/4 - 2*j
hmod = math_mod(h,7)
hint = math_int(hmod)

if (hint = 0) ; weekday = 'Sat' ; endif
if (hint = 1) ; weekday = 'Sun' ; endif
if (hint = 2) ; weekday = 'Mon' ; endif
if (hint = 3) ; weekday = 'Tue' ; endif
if (hint = 4) ; weekday = 'Wed' ; endif
if (hint = 5) ; weekday = 'Thu' ; endif
if (hint = 6) ; weekday = 'Fri' ; endif

say day' 'mm' 'h' 'hmod' 'hint
say weekday' 'fdate

'set strsiz 0.12'
'set string 1 r 5 0' ; 'draw string 2.64 8.2 ECMWF Sea Level Pressure'
'draw string 2.00 7.8 Run: 'huh 
'draw string 5.18 7.8 - - Valid: weekday' 'fdate













On 22-12-2020 17:41, L.B. wrote:

Stuart, After breaking down the month into a numerical value as you did, use that along with the day and current year into a function as such: if (month < 3)
  month = month + 12
  year = year -1
endif

dow = math_mod(day + math_int((13*(month+1))/5) + year + math_int(year/4) - math_int(year/100) + math_int(year/400),7) from here, the value 0 is Saturday, 1 is Sunday...6 is Friday

-------William (L.B.) LaForce IV
Meteorologist
On Tue, Dec 22, 2020 at 11:28 AM CW Weather <weatherstu at chorleyweather.com> wrote:

Hi Miquel,




Using similar with substring but how would I integrate that with this code. I've tried Ryan's function but it is throwing an error up somewhere and i've yet to find it. Thanks in advance. And thanks to Ryan as well. 

regards,

Stuart. 




'query time'
time = subwrd(result,3)
day = subwrd(result,6)
datestr = subwrd (result, 3)
if (substr (datestr, 3, 1) = 'Z') ; zptr = 3 ; ;else ; zptr = 6 ; endif ;
timestr = substr (datestr, 1, 2)
date = substr (datestr, zptr+1, 99)
dd = substr (date, 1, 2)
mmm = substr (date, 3, 3)
yyyy = substr (date, 6, 4)

if (mmm = 'JAN') ; mm = 01 ; endif
if (mmm = 'FEB') ; mm = 02 ; endif
if (mmm = 'MAR') ; mm = 03 ; endif
if (mmm = 'APR') ; mm = 04 ; endif
if (mmm = 'MAY') ; mm = 05 ; endif
if (mmm = 'JUN') ; mm = 06 ; endif
if (mmm = 'JUL') ; mm = 07 ; endif
if (mmm = 'AUG') ; mm = 08 ; endif
if (mmm = 'SEP') ; mm = 09 ; endif
if (mmm = 'OCT') ; mm = 10 ; endif
if (mmm = 'NOV') ; mm = 11 ; endif
if (mmm = 'DEC') ; mm = 12 ; endif

date = day' 'dd'/'mm' 'timestr':00'













On 22-12-2020 16:01, Miquel Bernis wrote:

I'm dealing with the same problem. Using substr() you can split day (d), month (m), and year (y), and after that this algorithm looks like works for me. Returns 0 for a Sunday and up to 6 for a Saturday. arrayDOW.0=0
arrayDOW.1=3
arrayDOW.2=2
arrayDOW.3=5 
arrayDOW.4=0
arrayDOW.5=3
arrayDOW.6=5
arrayDOW.7=1
arrayDOW.8=4
arrayDOW.9=6 
arrayDOW.10=2
arrayDOW.11=4 if (m<3)
y=y-1
endif

parm=m-1
dofweek = math_mod((y + math_int(y/4) - math_int(y/100) + math_int(y/400) + arrayDOW.parm + d),7)
Missatge de CW Weather <weatherstu at chorleyweather.com> del dia dt., 22 de des. 2020 a les 8:07:

Hello Users, 




I know this subject has been covered recently with an issue with the date for 2021, with the DAY returning '???'. Is there a suitable work around on this for both grads and opengrads users? I know there is a work around with some of you implementing Zeller's congruence but alas I have no idea how to code or where to code it to. 




Any help on the matter would be greatly apricated. 
-- 

Kind regards,

Stuart Markham



Founder of CW Weather

Website: chorleyweather.com
_______________________________________________
 gradsusr mailing list
gradsusr at gradsusr.org
http://gradsusr.org/mailman/listinfo/gradsusr

_______________________________________________
 gradsusr mailing list
gradsusr at gradsusr.org
http://gradsusr.org/mailman/listinfo/gradsusr



-- 

Kind regards,

Stuart Markham



Founder of CW Weather

Website: chorleyweather.com
_______________________________________________
 gradsusr mailing list
gradsusr at gradsusr.org
http://gradsusr.org/mailman/listinfo/gradsusr

_______________________________________________
 gradsusr mailing list
gradsusr at gradsusr.org
http://gradsusr.org/mailman/listinfo/gradsusr



-- 

Kind regards,

Stuart Markham



Founder of CW Weather

Website: chorleyweather.com
_______________________________________________
gradsusr mailing list
gradsusr at gradsusr.org
http://gradsusr.org/mailman/listinfo/gradsusr
  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gradsusr.org/pipermail/gradsusr/attachments/20210102/a4480fe4/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 6b66f0ed.png
Type: image/png
Size: 11158 bytes
Desc: not available
URL: <http://gradsusr.org/pipermail/gradsusr/attachments/20210102/a4480fe4/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 6b66f0ed.png
Type: image/png
Size: 11158 bytes
Desc: not available
URL: <http://gradsusr.org/pipermail/gradsusr/attachments/20210102/a4480fe4/attachment-0003.png>


More information about the gradsusr mailing list