shithub: werc

Download patch

ref: 2dc40e7c55add5037002f469a3da4c0e953e0433
parent: f59c93c585b568f1070cc6e9cd78a1318b910e1d
author: sl <sl@stanleylieber.com>
date: Wed Feb 10 15:29:27 EST 2016

bin/werclib.rc: add datei() and datet()

--- a/bin/werclib.rc
+++ b/bin/werclib.rc
@@ -120,6 +120,240 @@
     }
 }
 
+fn datei { datet | sed 's/T.*$//' }
+
+fn datet {
+	date=`{read}
+	switch($date(2)){
+	case Jan;	mo=01
+	case Feb;	mo=02
+	case Mar;	mo=03
+	case Apr;	mo=04
+	case May;	mo=05
+	case Jun;	mo=06
+	case Jul;	mo=07
+	case Aug;	mo=08
+	case Sep;	mo=09
+	case Oct;	mo=10
+	case Nov;	mo=11
+	case Dec;	mo=12
+	}
+	switch($date(3)){
+	case [0-9]
+		da=0^$date(3)
+	case *
+		da=$date(3)
+	}
+	switch($date(5)){
+	case A;	tz=+0100
+	case ADT;	tz=-0300
+	case AFT;	tz=+430
+	case AKDT;	tz=-0800
+	case AKST;	tz=-0900
+	case ALMT;	tz=+0600
+	case AMST;	tz=-0300
+	case AMT;	tz=-0400
+	case ANAST;	tz=+1200
+	case ANAT;	tz=+1200
+	case AQTT;	tz=+0500
+	case ART;	tz=-0300
+	case AST;	tz=-0400
+	case AZOST;	tz=+0000
+	case AZOT;	tz=-0100
+	case AZST;	tz=+0500
+	case AZT;	tz=+0400
+	case B;	tz=+0200
+	case BNT;	tz=+0800
+	case BOT;	tz=-0400
+	case BRST;	tz=-0200
+	case BRT;	tz=-0300
+	case BST;	tz=+0100
+	case BTT;	tz=+0600
+	case C;	tz=+0300
+	case CAST;	tz=+0800
+	case CAT;	tz=+0200
+	case CCT;	tz=+0630
+	case CDT;	tz=-0500
+	case CEST;	tz=+0200
+	case CET;	tz=+0100
+	case CHADT;	tz=+1345
+	case CHAST;	tz=+1245
+	case CKT;	tz=-1000
+	case CLST;	tz=-0300
+	case CLT;	tz=-0400
+	case COT;	tz=-0500
+	case CST;	tz=-0600
+	case CVT;	tz=-0100
+	case CXT;	tz=+0700
+	case ChST;	tz=+1000
+	case D;	tz=+0400
+	case DAVT;	tz=+0700
+	case E;	tz=+0500
+	case EASST;	tz=-0500
+	case EAST;	tz=-0600
+	case EAT;	tz=+0300
+	case ECT;	tz=-0500
+	case EDT;	tz=-0400
+	case EEST;	tz=+0300
+	case EET;	tz=+0200
+	case EGST;	tz=+0000
+	case EGT;	tz=-0100
+	case EST;	tz=-0500
+	case ET;	tz=-0500
+	case F;	tz=+0600
+	case FJST;	tz=+1300
+	case FJT;	tz=+1200
+	case FKST;	tz=-0300
+	case FKT;	tz=-0400
+	case FNT;	tz=-0200
+	case G;	tz=+0700
+	case GALT;	tz=-0600
+	case GAMT;	tz=-0900
+	case GET;	tz=+0400
+	case GFT;	tz=-0300
+	case GILT;	tz=+1200
+	case GMT;	tz=+0000
+	case GST;	tz=+0400
+	case GYT;	tz=-0400
+	case H;	tz=+0800
+	case HAA;	tz=-0300
+	case HAC;	tz=-0500
+	case HADT;	tz=-0900
+	case HAE;	tz=-0400
+	case HAP;	tz=-0700
+	case HAR;	tz=-0600
+	case HAST;	tz=-1000
+	case HAT;	tz=-0230
+	case HAY;	tz=-0800
+	case HKT;	tz=+0800
+	case HLV;	tz=-0430
+	case HNA;	tz=-0400
+	case HNC;	tz=-0600
+	case HNE;	tz=-0500
+	case HNP;	tz=-0800
+	case HNR;	tz=-0700
+	case HNT;	tz=-0330
+	case HNY;	tz=-0900
+	case HOVT;	tz=+0700
+	case I;	tz=+0900
+	case ICT;	tz=+0700
+	case IDT;	tz=+0300
+	case IOT;	tz=+0600
+	case IRDT;	tz=+0430
+	case IRKST;	tz=+0900
+	case IRKT;	tz=+0800
+	case IRST;	tz=+0330
+	case IST;	tz=+0200
+	case JST;	tz=+0900
+	case K;	tz=+1000
+	case KGT;	tz=+0600
+	case KRAST;	tz=+0800
+	case KRAT;	tz=+0700
+	case KST;	tz=+0900
+	case KUYT;	tz=+0400
+	case L;	tz=+1100
+	case LHDT;	tz=+1100
+	case LHST;	tz=+1030
+	case LINT;	tz=+1400
+	case M;	tz=+1200
+	case MAGST;	tz=+1200
+	case MAGT;	tz=+1100
+	case MART;	tz=-0930
+	case MAWT;	tz=+0500
+	case MDT;	tz=-0600
+	case MHT;	tz=+1200
+	case MMT;	tz=+0630
+	case MSD;	tz=+0400
+	case MSK;	tz=+0300
+	case MST;	tz=-0700
+	case MUT;	tz=+0400
+	case MVT;	tz=+0500
+	case MYT;	tz=+0800
+	case N;	tz=-0100
+	case NCT;	tz=+1100
+	case NDT;	tz=-0230
+	case NFT;	tz=+1130
+	case NOVST;	tz=+0700
+	case NOVT;	tz=+0600
+	case NPT;	tz=+0545
+	case NST;	tz=-0330
+	case NUT;	tz=-1100
+	case NZDT;	tz=+1300
+	case NZST;	tz=+1200
+	case O;	tz=-0200
+	case OMSST;	tz=+0700
+	case OMST;	tz=+0600
+	case P;	tz=-0300
+	case PDT;	tz=-0700
+	case PET;	tz=-0500
+	case PETST;	tz=+1200
+	case PETT;	tz=+1200
+	case PGT;	tz=+1000
+	case PHOT;	tz=+1300
+	case PHT;	tz=+0800
+	case PKT;	tz=+0500
+	case PMDT;	tz=-0200
+	case PMST;	tz=-0300
+	case PONT;	tz=+1100
+	case PST;	tz=-0800
+	case PT;	tz=-0800
+	case PWT;	tz=+0900
+	case PYST;	tz=-0300
+	case PYT;	tz=-0400
+	case Q;	tz=-0400
+	case R;	tz=-0500
+	case RET;	tz=+0400
+	case S;	tz=-0600
+	case SAMT;	tz=+0400
+	case SAST;	tz=+0200
+	case SBT;	tz=+1100
+	case SCT;	tz=+0400
+	case SGT;	tz=+0800
+	case SRT;	tz=-0300
+	case SST;	tz=-1100
+	case T;	tz=-0700
+	case TAHT;	tz=-1000
+	case TFT;	tz=+0500
+	case TJT;	tz=+0500
+	case TKT;	tz=-1000
+	case TLT;	tz=+0900
+	case TMT;	tz=+0500
+	case TVT;	tz=+1200
+	case U;	tz=-0800
+	case ULAT;	tz=+0800
+	case UYST;	tz=-0200
+	case UYT;	tz=-0300
+	case UZT;	tz=+0500
+	case V;	tz=-0900
+	case VET;	tz=-0430
+	case VLAST;	tz=+1100
+	case VLAT;	tz=+1000
+	case VUT;	tz=+1100
+	case W;	tz=-1000
+	case WAST;	tz=+0200
+	case WAT;	tz=+0100
+	case WDT;	tz=+0900
+	case WEST;	tz=+0100
+	case WET;	tz=+0000
+	case WFT;	tz=+1200
+	case WGST;	tz=-0200
+	case WGT;	tz=-0300
+	case WIB;	tz=+0700
+	case WIT;	tz=+0900
+	case WITA;	tz=+0800
+	case WST;	tz=+0800
+	case WT;	tz=+0000
+	case X;	tz=-1100
+	case Y;	tz=-1200
+	case YAKST;	tz=+1000
+	case YAKT;	tz=+0900
+	case YAPT;	tz=+1000
+	case YEKST;	tz=+0600
+	case YEKT;	tz=+0500
+	case Z;	tz=+0000
+	}
+	echo $date(6)^-$mo-$da^T^$date(4)^$tz
+}
 
 ##########################################################################
 ##########################################################################