hschumann2/TempleOS-Source-Code
0838
1 2#help_index "Misc/TOS/God;God/TOS"3 4I64 tos_timestamp=0,tos_type=0;5 6RegDft("TempleOS/TOSNIST","I64 tos_nist_offset=-8049;\n");7RegExe("TempleOS/TOSNIST");8 9public I64 CDate2Unix(CDate dt)10{//TempleOS datetime to Unix timestamp.11 return ToI64((dt-Str2Date("1/1/1970"))/CDATE_FREQ+NIST_TIME_OFFSET);12}13 14public CDate Unix2CDate(I64 timestamp)15{//Unix timestamp to TempleOS datetime.16 return (timestamp-NIST_TIME_OFFSET)*CDATE_FREQ+Str2Date("1/1/1970");17}18 19public U0 NISTBeaconSync()20{//Help get local clk in sync with NIST clk.21 I64 i,j;22 CDate dt;23 CDateStruct ds;24 while (!ScanChar) {25 dt=Now;26 Date2Struct(&ds,dt);27 i=CDate2Unix(dt);28 j=FloorI64(i,60);29 "%d %d %02d %02d\n",i,j,ds.sec,(60+ds.sec-(i-j))%60;30 Sleep(100);31 }32 tos_nist_offset=GetI64("tos_nist_offset (%d):",tos_nist_offset);33 RegWrite("TempleOS/TOSNIST","I64 tos_nist_offset=%d;\n",tos_nist_offset);34}35 36U0 NISTBeaconURL(I64 timestamp)37{//Insert NIST Beacon header into blog.38 U8 *tag;39 CDateStruct ds;40 CDate dt=Unix2CDate(timestamp);41 Date2Struct(&ds,dt+local_time_offset+30*CDATE_FREQ);42 "$TX,\"NIST Beacon Date:%D Time:%02d:%02d Unix TimeStamp:%u\","43 "HTML=\"https://beacon.nist.gov/home\"$\n",dt,ds.hour,ds.min,timestamp;44 tag=MStrPrint("https://beacon.nist.gov/rest/record/%d",timestamp);45 "$TX,\"NIST Beacon Record:%$Q\",HTML=\"%$Q\"$\n",tag,tag;46 Free(tag);47}48 49U0 NISTGodIns1()50{51 tos_type=PopUpPickLst("ExtDec5Bible\0LinuxWords\0HappyWords\0Words1000\0"52 "Words10k\0Hex5Bible\0Hex8Books\0Doodle\0Movie100\0Painting100\0"53 "Painting1000\0Poems100\0Metallica\0");54 switch (tos_type) {55 case: tos_timestamp=GodHeaderIns("Bible"); break;56 case: tos_timestamp=GodHeaderIns("LinuxWords"); break;57 case: tos_timestamp=GodHeaderIns("HappyWords"); break;58 case: tos_timestamp=GodHeaderIns("Words1000"); break;59 case: tos_timestamp=GodHeaderIns("Words10k"); break;60 case: tos_timestamp=GodHeaderIns("Bible"); break;61 case: tos_timestamp=GodHeaderIns("BookPick"); break;62 case: tos_timestamp=GodHeaderIns("Doodle"); break;63 case: tos_timestamp=GodHeaderIns("Movie100"); break;64 case: tos_timestamp=GodHeaderIns("Painting100"); break;65 case: tos_timestamp=GodHeaderIns("Painting1000"); break;66 case: tos_timestamp=GodHeaderIns("Poems100"); break;67 case: tos_timestamp=GodHeaderIns("Metallica"); break;68 }69 Once("tos_timestamp=%d;\ntos_type=%d;\n"70 "In(\"Blog(TRUE);\n\");",tos_timestamp,tos_type);71}72 73U0 NISTGodIns2()74{75 CRandExtDec5Form *gm=CAlloc(sizeof(CRandExtDec5Form));76 77 gm->timestamp=tos_timestamp;78 switch (tos_type) {79 case:80 if (DocForm(gm(CRandExtDec5Form *))) {81 NISTBeaconURL(gm->timestamp);82 TOSBookLines("~/Sup1/Sup1Blog/NumBible.TXT",ST_BIBLE_LINES,83 gm->rnd0,20,-5,FALSE,FALSE);84 }85 break;86 case:87 if (DocForm(gm(CHexWordForm *))) {88 NISTBeaconURL(gm->timestamp);89 Adam("GodInit(\"~/Sup1/Sup1Words/LinuxDict.TXT*\");");90 GodWordBatch(gm,16,5);91 }92 break;93 case:94 if (DocForm(gm(CHexWordForm *))) {95 NISTBeaconURL(gm->timestamp);96 Adam("GodInit(\"~/Sup1/Sup1Words/HappyWords.TXT*\");");97 GodWordBatch(gm,16,5);98 }99 break;100 case:101 if (DocForm(gm(CHexWordForm *))) {102 NISTBeaconURL(gm->timestamp);103 GodWordBatch(gm,10,3);104 }105 break;106 case:107 if (DocForm(gm(CHexWordForm *))) {108 NISTBeaconURL(gm->timestamp);109 GodWordBatch(gm,10,4);110 }111 break;112 case:113 if (DocForm(gm(CRandHex5Form *))) {114 "$TX,\"How this random Bible passage was chosen.\","115 "HTML=\"/Wb"116 "/Home/Web/TAD/NISTPassage.html\"$\n";117 NISTBeaconURL(gm->timestamp);118 TOSBookLines("~/Sup1/Sup1Blog/NumBible.TXT",ST_BIBLE_LINES,119 gm->rnd0,20,16,TRUE,TRUE);120 }121 break;122 case:123 if (DocForm(gm(CRandHex8Form *))) {124 "$TX,\"How this random book pick was chosen.\","125 "HTML=\"/Wb"126 "/Home/Web/TAD/NISTPick002.html\"$\n";127 NISTBeaconURL(gm->timestamp);128 GodBooksPassageU32(Str2I64(gm->rnd0,16),129 "~/*","C:/Home/Books?/*");130 }131 break;132 case:133 if (DocForm(gm(CHexWordForm *))) {134 NISTBeaconURL(gm->timestamp);135 TOSGodDoodle(GSRC_NIST_BEACON,gm);136 }137 break;138 case:139 if (DocForm(gm(CMoviesForm *))) {140 NISTBeaconURL(gm->timestamp);141 GodVideoDigits("Top 100 Movies",142 "http://www.afi.com/100years/movies10.aspx",143 gm->rnd0,2,"~/Sup1/Sup1Blog/Movies100.DD.Z");144 }145 break;146 case:147 if (DocForm(gm(CPaintings100Form *))) {148 NISTBeaconURL(gm->timestamp);149 GodWebIdx("Top 100 Paintings",150 "http://www.brushwiz.com/most-famous-paintings",151 gm->rnd0,2,"~/Sup1/Sup1Blog/Paintings100.DD.Z");152 }153 break;154 case:155 if (DocForm(gm(CPaintings1000Form *))) {156 NISTBeaconURL(gm->timestamp);157 GodWebIdx("Top 1000 Paintings",158 "http://en.most-famous-paintings.com/MostFamousPaintings."159 "nsf/ListOfTop1000MostPopularPainting",160 gm->rnd0,3,"~/Sup1/Sup1Blog/Paintings1000.DD.Z");161 }162 break;163 case:164 if (DocForm(gm(CPoems100Form *))) {165 NISTBeaconURL(gm->timestamp);166 GodWebIdx("Top 100 Poems",167 "http://100.best-poems.net/top-100-best-poems.html",168 gm->rnd0,2,"~/Sup1/Sup1Blog/Poems100.DD.Z");169 }170 break;171 case:172 if (DocForm(gm(CMetallicaForm *))) {173 NISTBeaconURL(gm->timestamp);174 GodVideoDigits("Metallica Song",175 "http://home.hccnet.nl/a.r.adams/lyrics/"176 "metallica/songindex.html",177 gm->rnd0,2,"~/Sup1/Sup1Blog/Metallica.DD.Z");178 }179 break;180 }181 Free(gm);182}183 