PageSourceSearch

https://winglang.io/assets/js/996f6889.f239959d.js

js winglang.io collected 2026-10-03 20:49:25 UTC 3,207 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[186],{26422:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>d,contentTitle:()=>r,default:()=>c,frontMatter:()=>s,metadata:()=>a,toc:()=>l});var o=t(74848),i=t(28453);const s={title:"Duration",id:"duration",slug:"/duration",sidebar_label:"Duration",description:"Get duration of time in Wing",keywords:["Wing language","Type reflection"],image:"/img/wing-by-example.png",custom_edit_url:"https://github.com/winglang/wing/blob/main/docs/by-example/37-duration.md"},r=void 0,a={id:"duration",title:"Duration",description:"Get duration of time in Wing",source:"@site/example_versioned_docs/version-latest/37-duration.md",sourceDirName:".",slug:"/duration",permalink:"/docs/learn/duration",draft:!1,unlisted:!1,editUrl:"https://github.com/winglang/wing/blob/main/docs/by-example/37-duration.md",tags:[],version:"latest",sidebarPosition:37,frontMatter:{title:"Duration",id:"duration",slug:"/duration",sidebar_label:"Duration",description:"Get duration of time in Wing",keywords:["Wing language","Type reflection"],image:"/img/wing-by-example.png",custom_edit_url:"https://github.com/winglang/wing/blob/main/docs/by-example/37-duration.md"},sidebar:"defaultSidebar",previous:{title:"Type reflection",permalink:"/docs/learn/type-reflection"},next:{title:"Using JavaScript with Wing",permalink:"/docs/learn/extern"}},d={},l=[];function u(n){const e={a:"a",code:"code",p:"p",pre:"pre",...(0,i.R)(),...n.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(e.p,{children:["The ",(0,o.jsx)(e.a,{href:"/docs/api/standard-library/std/duration",children:"duration"})," represents a length of time in Wing."]}),"\n",(0,o.jsx)(e.p,{children:"You can use this to get durations representing the amount of milliseconds, seconds, minutes, hours, days, and years."}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-js",metastring:'playground example title="main.w"',children:"let msInHour = duration.fromHours(1).milliseconds;\nlet msInSeconds = duration.fromSeconds(30).milliseconds;\nlet secondsInDay = duration.fromDays(1).seconds;\nlet hoursInDay = duration.fromDays(1).hours;\nlet hoursInMonth = duration.fromMonths(1).hours;\nlet daysInYear = duration.fromYears(1).days;\n\nlet durations = {\n  msInHour,\n  msInSeconds,\n  secondsInDay,\n  hoursInDay,\n  hoursInMonth,\n  daysInYear\n};\n\nlog(Json.stringify(durations));\n"})}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-bash",metastring:'title="Wing console output"',children:'# Run locally with wing console\n{"msInHour":3600000,"msInSeconds":30000,"secondsInDay":86400,"hoursInDay":24,"hoursInMonth":730,"daysInYear":365}\n'})})]})}function c(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,o.jsx)(e,{...n,children:(0,o.jsx)(u,{...n})}):u(n)}},28453:(n,e,t)=>{t.d(e,{R:()=>r,x:()=>a});var o=t(96540);const i={},s=o.createContext(i);function r(n){const e=o.useContext(s);return o.useMemo((function(){return"function"==typeof n?n(e):{...e,...n}}),[e,n])}function a(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:r(n.components),o.createElement(s.Provider,{value:e},n.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.