winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
5.06k stars 198 forks source link

Add ability to create datetimes in the future using timestamps #7170

Open boyney123 opened 2 months ago

boyney123 commented 2 months ago

Use Case

I'm trying to set an expiry date (TTL) on a dynamodb field, and want to say the current date + 3 minutes in the future.

With Wing I believe there is no easy way to do this? My suggestion after speaking with @Chriscbr is maybe we can add a utility on the datetime.

Proposed Solution

Add fromTimestamp function onto the datetime.

let original = datetime.utcNow();
let later = datetime.fromTimestamp(original.timestamp + 5 * 60); (5 minutes in the future)

Implementation Notes

No response

Component

No response

Community Notes

Chriscbr commented 2 months ago

Related: https://github.com/winglang/wing/issues/7149