Action

Time/Date Tags

Posted by kjaymiller, Last update over 6 years ago

Adds the following tags to make reviews of periods of time easier:

  • Day of the Week (Monday , Tuesday, etc)
  • Month (January, February, etc)
  • Time of Day (Morning, Afternoon, Evening)

Morning is 4AM-10:59AM
Afternoon is 11AM-4:59PM(16:00)
Evening is 5:00PM (17:00) until 3:59AM

Steps

  • script

    // See online documentation for examples
    // http://getdrafts.com/scripting
    const today = new Date();
    
    const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
    
    const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
    
    const month = months[today.getMonth()];
    const year = today.getFullYear();
    const day = days[today.getDay()];
    
    //Figure out Morning, Afternoon, Evening
    const hour = today.getHours();
    
    if ( hour >= 4 && hour < 11) {
    var timeOfDay = 'Morning';
    };
    
    if ( hour >= 11 && hour < 16) {
    var timeOfDay = 'Afternoon';
    };
    
    if ( hour >= 16 && hour < 4) {
    var timeOfDay = 'Evening';
    };
    
    const tags = [month, day, year, timeOfDay];
    
    for (let tag of tags) {
    draft.addTag(tag)
    };

Options

  • After Success Nothing
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.