Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

12
LINES

< > BotCompany Repo | #1019450 // howLongAgo_toMS

JavaX fragment (include)

1  
static long howLongAgo_toMS(S s) {
2  
  int i = indexOfSpace(s);
3  
  S ns = replace(takeFirst(s, i), ",", "");
4  
  if (!isInteger(ns)) ret 0;
5  
  long n = parseLong(ns);
6  
  s = trimSubstring(s, i);
7  
  if (swic(s, "second")) ret n*1000;
8  
  if (swic(s, "minute")) ret n*60000;
9  
  if (swic(s, "hour")) ret n*60*60000;
10  
  if (swic(s, "day")) ret n*24*60*60000;
11  
  ret 0;
12  
}

Author comment

Began life as a copy of #1019449

download  show line numbers  debug dex  old transpilations   

Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1019450
Snippet name: howLongAgo_toMS
Eternal ID of this version: #1019450/4
Text MD5: 5fc74bf423bd99d25f81b30ea3ac8b80
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-07 00:41:04
Source code size: 364 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 308 / 348
Version history: 3 change(s)
Referenced in: [show references]