parent
							
								
									1112a92023
								
							
						
					
					
						commit
						c596812d30
					
				| 
						 | 
				
			
			@ -14,5 +14,8 @@
 | 
			
		|||
    "format"
 | 
			
		||||
  ],
 | 
			
		||||
  "author": "Kato Twofold",
 | 
			
		||||
  "license": "MIT"
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "repository": {
 | 
			
		||||
    "url": "https://github.com/JustKato/Tyme.js"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,17 @@
 | 
			
		|||
/**
 | 
			
		||||
 * A dictionary for all of the days of the week
 | 
			
		||||
 */
 | 
			
		||||
 const dayDictionary: Array<string> = [
 | 
			
		||||
    "Sunday",
 | 
			
		||||
    "Monday",
 | 
			
		||||
    "Tuesday",
 | 
			
		||||
    "Wednesday",
 | 
			
		||||
    "Thursday",
 | 
			
		||||
    "Friday",
 | 
			
		||||
    "Saturday",
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export { 
 | 
			
		||||
    dayDictionary
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -1 +1,2 @@
 | 
			
		|||
export type monthType = "single" | "double" | "short" | "full"
 | 
			
		||||
export type monthType = "single" | "double" | "short" | "long";
 | 
			
		||||
export type dateType  = "single" | "double" | "short" | "long" | "dowsingle" | "dowdouble";
 | 
			
		||||
							
								
								
									
										28
									
								
								src/index.ts
								
								
								
								
							
							
						
						
									
										28
									
								
								src/index.ts
								
								
								
								
							| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
import { dayDictionary } from "./Dictionaries/dateDictionary";
 | 
			
		||||
import { monthDictionary } from "./Dictionaries/monthDictionary";
 | 
			
		||||
import { monthType } from "./Types/formatTypes";
 | 
			
		||||
import { dateType, monthType } from "./Types/formatTypes";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -30,7 +31,7 @@ export default class TymeJS {
 | 
			
		|||
     * Get the currently assigned date object
 | 
			
		||||
     * @returns The assigned Date object
 | 
			
		||||
     */
 | 
			
		||||
    public getDate(): Date {
 | 
			
		||||
    public getDateObject(): Date {
 | 
			
		||||
        return this.ts;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -53,7 +54,7 @@ export default class TymeJS {
 | 
			
		|||
     * Get the current month
 | 
			
		||||
     */
 | 
			
		||||
    public getMonth(mType: monthType): string {
 | 
			
		||||
 | 
			
		||||
        // get the index of the current month
 | 
			
		||||
        let monthIndex: number = this.ts.getMonth();
 | 
			
		||||
 | 
			
		||||
        if ( mType === "single" ) {
 | 
			
		||||
| 
						 | 
				
			
			@ -68,6 +69,27 @@ export default class TymeJS {
 | 
			
		|||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public getDate(dType: dateType): string {
 | 
			
		||||
 | 
			
		||||
        if ( dType == "single" ) {
 | 
			
		||||
            // get the index of the current day
 | 
			
		||||
            let currentDate: number = this.ts.getDate();
 | 
			
		||||
            return String(currentDate);
 | 
			
		||||
        } else if ( dType == "double" ) {
 | 
			
		||||
            // get the index of the current day
 | 
			
		||||
            let currentDate: number = this.ts.getDate();
 | 
			
		||||
            return String(currentDate).padStart(2, "0");
 | 
			
		||||
        } else if ( dType == 'dowsingle' ) {
 | 
			
		||||
            return String(this.ts.getDay());
 | 
			
		||||
        } else if ( dType == 'dowdouble' ) {
 | 
			
		||||
            return String(this.ts.getDay()).padStart(2, "0");
 | 
			
		||||
        } else if ( dType == "short") {
 | 
			
		||||
            return String(dayDictionary[this.ts.getDay() - 1]);
 | 
			
		||||
        } else {
 | 
			
		||||
            return String(dayDictionary[this.ts.getDay() - 1]).slice(0, 3);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,18 @@
 | 
			
		|||
import TymeJS from "../src";
 | 
			
		||||
 | 
			
		||||
let startDate: Date = new Date();
 | 
			
		||||
 | 
			
		||||
for ( let i = 0; i < 7; i++ ) {
 | 
			
		||||
    const a = new TymeJS(startDate);
 | 
			
		||||
    console.log(startDate, {
 | 
			
		||||
        single:    a.getDate("single"),
 | 
			
		||||
        double:    a.getDate("double"),
 | 
			
		||||
        dowsingle: a.getDate("dowsingle"),
 | 
			
		||||
        dowdouble: a.getDate("dowdouble"),
 | 
			
		||||
        full:      a.getDate("long"),
 | 
			
		||||
        short:     a.getDate("short"),
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    startDate.setDate(startDate.getDate() + 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -10,7 +10,7 @@ for ( let i = 0; i < 12; i++ ) {
 | 
			
		|||
    console.log({
 | 
			
		||||
        single: a.getMonth("single"),
 | 
			
		||||
        double: a.getMonth("double"),
 | 
			
		||||
        full:   a.getMonth("full"),
 | 
			
		||||
        full:   a.getMonth("long"),
 | 
			
		||||
        short:  a.getMonth("short"),
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in New Issue