📅

日付メンションから日付設定

11/14 以前に取得した人は、こちらのテンプレートを再度取得してください。10時前のタスクでも正しく動作するようになりました。ちなみにこのテンプレートは、日本語・韓国語・中国語の人しか利用することができません。

オートメーション設定したデータベース

タイトルの最後に日付メンションを追加した後で、最後に「.」をタイプしてください。
 
名前
日付
入力したメンション
テキスト
日付なし
@10
今日10時
@10-11
今日10時から11時
@nm
次の月曜日
@12/10-12/13
12月10日から13日
@12/20 10-15
12月20日の10時から15時
@12/24 10-12/25 17
12月24日の10時から12月25日の17時

動作の様子

使った数式 (参考)

lets( /* array: スペース区切りの文字列 */ array, prop("トリガーページ").prop("名前").split(" "), /* array_length: array の長さ */ array_length, array.length(), /* arrow_index: → の位置 */ arrow_index, array.findIndex(current == "→"), /* last_has_time: 最後の要素が時刻なら true */ last_has_time, array.last().test(":"), /* JST offset */ offset, "00+09:00", ifs( /* → がなく、時刻もなし: 日付なし または 日付単体 */ arrow_index == -1 && last_has_time.not(), /* 日付の数値にマッチ: 3つの数字を得る */ let(ymd, array.last().match("\d+"), /* 数値が 3 つあれば日付処理 */ ymd.length() == 3 ? /* y を 10000 倍、m を 100 倍する */ ymd.map(current.toNumber() * pow(100, 2-index)) /* 加算して 8 桁の数値を得る */ .sum() /* 8桁の数値から日付を得る */ .parseDate() /* 日付でなければ空の日付を得る */ : "".toNumber().fromTimestamp() ), /* → がなく、時刻あり: 日付時刻 */ arrow_index == -1, /* 時刻は T の後ろに4桁を追加 */ [ array.at(-2).match("\d+").map(current.toNumber() * pow(100, 2-index)).sum(), (array.last().match("\d+").map(current.toNumber() * pow(100, 1-index)).sum() + 10000 + offset).substring(1) ].join("T").parseDate(), /* → の後ろが時刻のみ: 当日の時刻範囲 */ array_length - arrow_index == 2 && last_has_time, let( ymd, array.at(-4).match("\d+").map(current.toNumber() * pow(100, 2-index)).sum(), [ymd, (array.at(-3).match("\d+").map(current.toNumber() * pow(100, 1-index)).sum() + 10000 + offset).substring(1)] .join("T") .parseDate() .dateRange( [ymd, (array.last().match("\d+").map(current.toNumber() * pow(100, 1-index)).sum() + 10000 + offset).substring(1)] .join("T") .parseDate() ) ), /* 矢印の後ろが日付のみ: 日付範囲 */ array_length - arrow_index == 2, array.at(-3).match("\d+").map(current.toNumber() * pow(100, 2-index)) .sum().parseDate() .dateRange( array.last().match("\d+").map(current.toNumber() * pow(100, 2-index)) .sum().parseDate() ), [ array.at(-5).match("\d+").map(current.toNumber() * pow(100, 2-index)).sum(), (array.at(-4).match("\d+").map(current.toNumber() * pow(100, 1-index)).sum() + 10000 + offset).substring(1) ].join("T").parseDate() .dateRange( [ array.at(-2).match("\d+").map(current.toNumber() * pow(100, 2-index)).sum(), (array.last().match("\d+").map(current.toNumber() * pow(100, 1-index)).sum() + 10000 +offset).substring(1) ] .join("T").parseDate() ) ) )
Date property
 
lets( /* array: スペース区切りの文字列 */ array, ..split(" "), /* array_length: array の長さ */ array_length, array.length(), /* arrow_index: → の位置 */ arrow_index, array.findIndex(current == "→"), /* last_has_time: 最後の要素が時刻なら true */ last_has_time, array.last().test(":"), remain, ifs( /* → がなく、時刻もなし: 日付なし または 日付単体 */ arrow_index == -1 && last_has_time.not(), /* 日付の数値にマッチ: 3つの数字を得る */ let(ymd, array.last().match("\d+"), /* 数値が 3 つあれば日付処理 */ ymd.length() == 3 ? array_length - 1 : array_length ), /* → がなく、時刻あり: 日付時刻 */ arrow_index == -1, array_length - 2, /* → の後ろが時刻のみ: 当日の時刻範囲 */ array_length - arrow_index == 2 && last_has_time, array_length - 4, /* 矢印の後ろが日付のみ: 日付範囲 */ array_length - arrow_index == 2, array_length - 3, array_length - 5 ), array.slice(0, array_length) )
Title property